X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Fpasswd.c;h=2b2eadbb81b5b58bd3438cd5bcb132ceed08e238;hb=cf665b135b41d4f42067f9d9a8111c9602777cc1;hp=c8e6f56fe3e755fbbf86f96fd67b775124d2c29a;hpb=f3e0240915ed9f9b3a61781f5c7002d587563fe0;p=xscreensaver diff --git a/driver/passwd.c b/driver/passwd.c index c8e6f56f..2b2eadbb 100644 --- a/driver/passwd.c +++ b/driver/passwd.c @@ -1,5 +1,5 @@ /* passwd.c --- verifying typed passwords with the OS. - * xscreensaver, Copyright (c) 1993-1997 Jamie Zawinski + * xscreensaver, Copyright (c) 1993-1998 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -21,11 +21,16 @@ # include #endif +#ifdef HAVE_CRYPT_H +# include +#endif + #include #include #include #ifndef VMS # include +# include #else /* VMS */ # include "vms-pwd.h" #endif /* VMS */ @@ -61,7 +66,7 @@ # include # include -# define PRTYPE passwd_adjunct * +# define PWTYPE struct passwd_adjunct * # define PWPSLOT pwa_passwd # define GETPW getpwanam @@ -70,7 +75,7 @@ # include # include -# define PRTYPE struct s_passwd * +# define PWTYPE struct s_passwd * # define PWPSLOT pw_passwd # define GETPW getspwnam # define crypt bigcrypt @@ -87,7 +92,7 @@ #define False 0 -extern char *progname; +extern const char *blurb(void); static char *encrypted_root_passwd = 0; static char *encrypted_user_passwd = 0; @@ -170,7 +175,7 @@ get_encrypted_passwd(const char *user) } fprintf (stderr, "%s: couldn't get password of \"%s\"\n", - progname, (user ? user : "(null)")); + blurb(), (user ? user : "(null)")); return 0; } @@ -178,7 +183,7 @@ get_encrypted_passwd(const char *user) /* This has to be called before we've changed our effective user ID, - because it might need priveleges to get at the encrypted passwords. + because it might need privileges to get at the encrypted passwords. Returns false if we weren't able to get any passwords, and therefore, locking isn't possible. (It will also have written to stderr.) */ @@ -214,16 +219,18 @@ lock_init (int argc, char **argv) Bool passwd_valid_p (const char *typed_passwd) { + char *s = 0; /* note that on some systems, crypt() may return null */ + if (encrypted_user_passwd && - !strcmp ((char *) crypt (typed_passwd, encrypted_user_passwd), - encrypted_user_passwd)) + (s = (char *) crypt (typed_passwd, encrypted_user_passwd)) && + !strcmp (s, encrypted_user_passwd)) return True; /* do not allow root to have a null password. */ else if (typed_passwd[0] && encrypted_root_passwd && - !strcmp ((char *) crypt (typed_passwd, encrypted_root_passwd), - encrypted_root_passwd)) + (s = (char *) crypt (typed_passwd, encrypted_root_passwd)) && + !strcmp (s, encrypted_root_passwd)) return True; else @@ -234,5 +241,4 @@ passwd_valid_p (const char *typed_passwd) Bool lock_init (int argc, char **argv) { return True; } #endif /* VMS */ - #endif /* NO_LOCKING -- whole file */