* mcserv.c (do_classic_auth): Restore support for shadow

passwords.  Use crypt() instead of pw_encrypt() - the later is
missing on Slackware 8.0.  Reported by
Christian Laubscher <christian.laubscher@tiscalinet.ch>
This commit is contained in:
Pavel Roskin 2002-11-17 05:38:29 +00:00
parent f2331eeafc
commit 7ba4aacd85
2 changed files with 42 additions and 14 deletions

View File

@ -1,5 +1,10 @@
2002-11-16 Pavel Roskin <proski@gnu.org> 2002-11-16 Pavel Roskin <proski@gnu.org>
* mcserv.c (do_classic_auth): Restore support for shadow
passwords. Use crypt() instead of pw_encrypt() - the later is
missing on Slackware 8.0. Reported by
Christian Laubscher <christian.laubscher@tiscalinet.ch>
* Makefile.am: Consolidate mcserv libraries into MCSERVLIBS. * Makefile.am: Consolidate mcserv libraries into MCSERVLIBS.
2002-11-15 Pavel Roskin <proski@gnu.org> 2002-11-15 Pavel Roskin <proski@gnu.org>

View File

@ -80,12 +80,19 @@
# define PAM_ESTABLISH_CRED PAM_CRED_ESTABLISH # define PAM_ESTABLISH_CRED PAM_CRED_ESTABLISH
# endif # endif
#else #else
#endif /* !HAVE_PAM */
#ifdef HAVE_CRYPT_H #ifdef HAVE_CRYPT_H
# include <crypt.h> # include <crypt.h>
#else
extern char *crypt (const char *, const char *);
#endif /* !HAVE_CRYPT_H */ #endif /* !HAVE_CRYPT_H */
#endif /* !HAVE_PAM */
#ifdef HAVE_SHADOW_H
# include <shadow.h>
#else
# ifdef HAVE_SHADOW_SHADOW_H
# include <shadow/shadow.h>
# endif
#endif
#include "utilvfs.h" #include "utilvfs.h"
@ -881,20 +888,33 @@ do_ftp_auth (char *username, char *password)
static int static int
do_classic_auth (char *username, char *password) do_classic_auth (char *username, char *password)
{ {
struct passwd *this; int ret = 0;
int ret; char *encr_pwd = NULL;
struct passwd *pw;
#ifdef HAVE_SHADOW
struct spwd *spw;
#endif
if ((this = getpwnam (username)) == 0) if ((pw = getpwnam (username)) == 0)
return 0; return 0;
#ifdef HAVE_CRYPT #ifdef HAVE_SHADOW
if (strcmp (crypt (password, this->pw_passwd), this->pw_passwd) == 0) { setspent ();
ret = 1;
} else /* Password expiration is not checked! */
if ((spw = getspnam (username)) == NULL)
encr_pwd = "*";
else
encr_pwd = spw->sp_pwdp;
endspent ();
#else
encr_pwd = pw->pw_passwd;
#endif #endif
{
ret = 0; if (strcmp (crypt (password, encr_pwd), encr_pwd) == 0)
} ret = 1;
endpwent (); endpwent ();
return ret; return ret;
} }
@ -924,9 +944,12 @@ do_auth (char *username, char *password)
auth = 1; auth = 1;
else else
#endif #endif
#ifdef HAVE_CRYPT
if (do_classic_auth (username, password)) if (do_classic_auth (username, password))
auth = 1; auth = 1;
else if (ftp) else
#endif
if (ftp)
auth = do_ftp_auth (username, password); auth = do_ftp_auth (username, password);
#endif /* not pam */ #endif /* not pam */