auth_getpwent.c | auth_getpwent.c | |||
---|---|---|---|---|
skipping to change at line 43 | skipping to change at line 43 | |||
#ifdef __GNUC__ | #ifdef __GNUC__ | |||
#ident "$Id: auth_getpwent.c,v 1.9 2009/02/13 14:23:26 mel Exp $" | #ident "$Id: auth_getpwent.c,v 1.9 2009/02/13 14:23:26 mel Exp $" | |||
#endif | #endif | |||
/* PUBLIC DEPENDENCIES */ | /* PUBLIC DEPENDENCIES */ | |||
#include "mechanisms.h" | #include "mechanisms.h" | |||
#include <unistd.h> | #include <unistd.h> | |||
#include <string.h> | #include <string.h> | |||
#include <pwd.h> | #include <pwd.h> | |||
#include <errno.h> | ||||
#include <syslog.h> | ||||
#ifdef HAVE_CRYPT_H | #ifdef HAVE_CRYPT_H | |||
#include <crypt.h> | #include <crypt.h> | |||
#endif | #endif | |||
# ifdef WITH_DES | # ifdef WITH_DES | |||
# ifdef WITH_SSL_DES | # ifdef WITH_SSL_DES | |||
# ifndef OPENSSL_DISABLE_OLD_DES_SUPPORT | # ifndef OPENSSL_DISABLE_OLD_DES_SUPPORT | |||
# define OPENSSL_DISABLE_OLD_DES_SUPPORT | # define OPENSSL_DISABLE_OLD_DES_SUPPORT | |||
# endif | # endif | |||
# include <openssl/des.h> | # include <openssl/des.h> | |||
# else | # else | |||
# include <des.h> | # include <des.h> | |||
# endif /* WITH_SSL_DES */ | # endif /* WITH_SSL_DES */ | |||
# endif /* WITH_DES */ | # endif /* WITH_DES */ | |||
# include "globals.h" | ||||
/* END PUBLIC DEPENDENCIES */ | /* END PUBLIC DEPENDENCIES */ | |||
#define RETURN(x) return strdup(x) | #define RETURN(x) return strdup(x) | |||
/* FUNCTION: auth_getpwent */ | /* FUNCTION: auth_getpwent */ | |||
char * /* R: allocated response string */ | char * /* R: allocated response string */ | |||
auth_getpwent ( | auth_getpwent ( | |||
/* PARAMETERS */ | /* PARAMETERS */ | |||
const char *login, /* I: plaintext authenticator */ | const char *login, /* I: plaintext authenticator */ | |||
const char *password, /* I: plaintext password */ | const char *password, /* I: plaintext password */ | |||
const char *service __attribute__((unused)), | const char *service __attribute__((unused)), | |||
const char *realm __attribute__((unused)) | const char *realm __attribute__((unused)) | |||
/* END PARAMETERS */ | /* END PARAMETERS */ | |||
) | ) | |||
{ | { | |||
/* VARIABLES */ | /* VARIABLES */ | |||
struct passwd *pw; /* pointer to passwd file entry */ | struct passwd *pw; /* pointer to passwd file entry */ | |||
int errnum; | ||||
/* END VARIABLES */ | /* END VARIABLES */ | |||
errno = 0; | ||||
pw = getpwnam(login); | pw = getpwnam(login); | |||
errnum = errno; | ||||
endpwent(); | endpwent(); | |||
if (pw == NULL) { | if (pw == NULL) { | |||
RETURN("NO"); | if (errnum != 0) { | |||
char *errstr; | ||||
if (flags & VERBOSE) { | ||||
syslog(LOG_DEBUG, "DEBUG: auth_getpwent: getpwnam(%s) failur | ||||
e: %m", login); | ||||
} | ||||
if (asprintf(&errstr, "NO Username lookup failure: %s", strerror | ||||
(errno)) == -1) { | ||||
/* XXX the hidden strdup() will likely fail and return NULL | ||||
here.... */ | ||||
RETURN("NO Username lookup failure: unknown error (ENOMEM fo | ||||
rmatting strerror())"); | ||||
} | ||||
return errstr; | ||||
} else { | ||||
if (flags & VERBOSE) { | ||||
syslog(LOG_DEBUG, "DEBUG: auth_getpwent: getpwnam(%s): inval | ||||
id username", login); | ||||
} | ||||
RETURN("NO Invalid username"); | ||||
} | ||||
} | } | |||
if (strcmp(pw->pw_passwd, (const char *)crypt(password, pw->pw_passwd)) ) { | if (strcmp(pw->pw_passwd, (const char *)crypt(password, pw->pw_passwd)) ) { | |||
RETURN("NO"); | if (flags & VERBOSE) { | |||
syslog(LOG_DEBUG, "DEBUG: auth_getpwent: %s: invalid password", | ||||
login); | ||||
} | ||||
RETURN("NO Incorrect password"); | ||||
} | } | |||
if (flags & VERBOSE) { | ||||
syslog(LOG_DEBUG, "DEBUG: auth_getpwent: OK: %s", login); | ||||
} | ||||
RETURN("OK"); | RETURN("OK"); | |||
} | } | |||
/* END FUNCTION: auth_getpwent */ | /* END FUNCTION: auth_getpwent */ | |||
/* END MODULE: auth_getpwent */ | /* END MODULE: auth_getpwent */ | |||
End of changes. 8 change blocks. | ||||
2 lines changed or deleted | 37 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |