diff options
Diffstat (limited to 'modules/pam_unix')
-rw-r--r-- | modules/pam_unix/support.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/modules/pam_unix/support.c b/modules/pam_unix/support.c index df5044e9..a4e24210 100644 --- a/modules/pam_unix/support.c +++ b/modules/pam_unix/support.c @@ -346,13 +346,12 @@ static void _unix_cleanup(pam_handle_t *pamh UNUSED, void *data, int error_statu int _unix_getpwnam(pam_handle_t *pamh, const char *name, int files, int nis, struct passwd **ret) { - FILE *passwd; char *buf = NULL; int matched = 0; - char *slogin, *spasswd, *suid, *sgid, *sgecos, *shome, *sshell, *p; - size_t retlen; if (!matched && files && strchr(name, ':') == NULL) { + FILE *passwd; + passwd = fopen("/etc/passwd", "r"); if (passwd != NULL) { size_t n = 0, userlen; @@ -363,6 +362,8 @@ int _unix_getpwnam(pam_handle_t *pamh, const char *name, while ((r = getline(&buf, &n, passwd)) != -1) { if ((size_t)r > userlen && (buf[userlen] == ':') && (strncmp(name, buf, userlen) == 0)) { + char *p; + p = buf + strlen(buf) - 1; while (isspace((unsigned char)*p) && (p >= buf)) { *p-- = '\0'; @@ -401,6 +402,9 @@ int _unix_getpwnam(pam_handle_t *pamh, const char *name, #endif if (matched && (ret != NULL)) { + char *slogin, *spasswd, *suid, *sgid, *sgecos, *shome, *sshell, *p; + size_t retlen; + *ret = NULL; slogin = buf; |