diff options
author | Charl Botha <cpbotha@cpbotha.net> | 2001-06-15 21:24:30 +0000 |
---|---|---|
committer | Charl Botha <cpbotha@cpbotha.net> | 2001-06-15 21:24:30 +0000 |
commit | 3f19868cda933c3a3699f58f3d6e494689972aff (patch) | |
tree | 615e19e340cde26c950ff74ed394ff4dcc610d22 | |
parent | 5dc79060f1ad2a094e18dd3cc29c13bebeb6be80 (diff) | |
download | libpam-pwdfile-3f19868cda933c3a3699f58f3d6e494689972aff.tar.gz |
Integrated contributed patch.
-rw-r--r-- | README | 4 | ||||
-rw-r--r-- | changelog | 7 | ||||
-rw-r--r-- | pam_pwdfile.c | 17 |
3 files changed, 20 insertions, 8 deletions
@@ -1,8 +1,8 @@ README for pam_pwdfile PAM module - Charl P. Botha <cpbotha@ieee.org> -$Id: README,v 1.6 2001-05-12 09:58:43 cpbotha Exp $ +$Id: README,v 1.7 2001-06-15 21:24:30 cpbotha Exp $ --------------------------------------------------------------------------- -This is version 0.8 of pam_pwdfile. +This is version 0.9 of pam_pwdfile. This pam module can be used for the authentication service only, in cases where one wants to use a different set of passwords than those in the main @@ -1,7 +1,12 @@ changelog for pam_pwdfile PAM module - Charl P. Botha <cpbotha@ieee.org> -$Id: changelog,v 1.8 2001-05-12 09:58:43 cpbotha Exp $ +$Id: changelog,v 1.9 2001-06-15 21:24:30 cpbotha Exp $ --------------------------------------------------------------------------- +0.9: Fri Jun 15 23:23:31 CEST 2001 + +* integrated patch by Stephen Darragh <srd@it.net.au> to fix problems with + short MD5 crypts and trailing newlines. + 0.8: Sat May 12 11:57:18 CEST 2001 * the MrKen (aka MJ Turner) release. Removed unnecessary include that was diff --git a/pam_pwdfile.c b/pam_pwdfile.c index ac8e8cb..a5c994c 100644 --- a/pam_pwdfile.c +++ b/pam_pwdfile.c @@ -1,12 +1,12 @@ /* pam_pwdfile.c copyright 1999 by Charl P. Botha <cpbotha@ieee.org> * - * $Id: pam_pwdfile.c,v 1.12 2001-05-12 09:59:45 cpbotha Exp $ + * $Id: pam_pwdfile.c,v 1.13 2001-06-15 21:24:30 cpbotha Exp $ * * pam authentication module that can be pointed at any username/crypted * text file so that pam using application can use an alternate set of * passwords than specified in system password database * - * version 0.8 + * version 0.9 * * Copyright (c) Charl P. Botha, 1999. All rights reserved * @@ -179,15 +179,18 @@ int _set_auth_tok( pam_handle_t *pamh, static int fgetpwnam(FILE *stream, const char *name, char *password) { char tempLine[256], *tpointer, *curname, *curpass, *fgr; int loopdone, pwdfound; + int len; /* go to beginning of file */ rewind(stream); /* some control variables */ loopdone = pwdfound = 0; + /* fgets should do this, but we make sure */ + tempLine[255] = '\0'; /* iterate through lines in file, until end of file */ do { /* get the current line */ - fgr = fgets(tempLine,256,stream); + fgr = fgets(tempLine,255,stream); /* if it's valid, go on */ if ( fgr != NULL) { /* first get the username out */ @@ -197,6 +200,10 @@ static int fgetpwnam(FILE *stream, const char *name, char *password) { if (strcmp(curname,name)==0) { /* at least we know our loop is done */ loopdone = 1; + /* remove possible trailing newline */ + len = strlen(tpointer); + if (tpointer[len - 1] == '\n') + tpointer[len - 1] = '\0'; /* get the password and put it in its place */ curpass = strsep(&tpointer,":"); if (curpass != NULL) { @@ -318,7 +325,7 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, int flags, } /* DEBUG */ - D(_pam_log(LOG_ERR,"got crypted password == %s", crypted_password)); + D(_pam_log(LOG_ERR,"got crypted password == '%s'", crypted_password)); /* Extract the salt and set the passwd length, depending on MD5 or DES */ if (strncmp(crypted_password, "$1$", 3) == 0) { @@ -332,7 +339,7 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, int flags, } /* DEBUG */ - D(_pam_log(LOG_ERR,"user password crypted is %s", crypt(password,salt))); + D(_pam_log(LOG_ERR,"user password crypted is '%s'", crypt(password,salt))); /* if things don't match up, complain */ if (strcmp(crypt(password,salt),crypted_password)!=0) { |