diff options
author | Alan Coopersmith <alan.coopersmith@sun.com> | 2007-02-06 11:34:30 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@sun.com> | 2007-02-06 11:34:30 -0800 |
commit | 6e2362e825dfec6df73f1338088a850225ed92d2 (patch) | |
tree | ef73a930eb7cb09a357ed1170b6ccfc76b677eb0 | |
parent | f6ab9602b8418b035f12da171a7d6edfed464aee (diff) |
Rearrange checks for maximum username & password length
Give preference to standard definitions, use less hardcoded knowledge about
which platforms provide other definitions.
-rw-r--r-- | greeter/Login.h | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/greeter/Login.h b/greeter/Login.h index 10121d9..13484fe 100644 --- a/greeter/Login.h +++ b/greeter/Login.h @@ -155,29 +155,38 @@ from The Open Group. #ifdef __OpenBSD__ # include <sys/param.h> -/* 2.8 (200012) doesn't have _PW_NAME_LEN */ -# if OpenBSD > 200012 -# include <pwd.h> -# define NAME_LEN (_PW_NAME_LEN + 2) -# define PASSWORD_LEN (_PASSWORD_LEN + 2) -# endif #endif +#include <pwd.h> +#include <limits.h> + #ifdef USE_PAM # define NAME_LEN PAM_MAX_RESP_SIZE # define PASSWORD_LEN PAM_MAX_RESP_SIZE #endif +/* Defined to be in <limits.h> by SUSv2 */ +#if !defined(PASSWORD_LEN) && defined(PASS_MAX) +# define PASSWORD_LEN PASS_MAX +#endif + +/* _PW_NAME_LEN is found in <pwd.h> on OpenBSD > 2.8 (200012) */ +#if !defined(NAME_LEN) && defined(_PW_NAME_LEN) +# define NAME_LEN (_PW_NAME_LEN + 2) +#endif + +/* _PASSWORD_LEN appears to come from 4.4BSD-Lite <pwd.h> */ +#if !defined(PASSWORD_LEN) && defined(_PASSWORD_LEN) +# define PASSWORD_LEN (_PASSWORD_LEN + 2) +#endif + +/* Fallbacks if no other definition found */ #ifndef NAME_LEN # define NAME_LEN 32 #endif #ifndef PASSWORD_LEN -# ifdef PASS_MAX -# define PASSWORD_LEN PASS_MAX -# else -# define PASSWORD_LEN 32 -# endif +# define PASSWORD_LEN 32 #endif typedef struct _LoginData { |