mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 08:43:19 -04:00
login: Use getpwnam_r() instead of getpwnam().
Since we expect the entry to still be valid after calling into PAM, which may call getpwnam() itself, we need to use getpwnam_r(). MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: kevans, imp, allanjude, markj Differential Revision: https://reviews.freebsd.org/D43376 (cherry picked from commita3d80dd8aa) login: Missed an instance of getpwnam(). Fixes:a3d80dd8aaMFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D43423 (cherry picked from commit1e25eb287f)
This commit is contained in:
parent
93805b27ea
commit
e3057ee0bf
1 changed files with 8 additions and 4 deletions
|
|
@ -116,6 +116,8 @@ static u_int timeout = 300;
|
|||
/* Buffer for signal handling of timeout */
|
||||
static jmp_buf timeout_buf;
|
||||
|
||||
char pwbuf[1024];
|
||||
struct passwd pwres;
|
||||
struct passwd *pwd;
|
||||
static int failures;
|
||||
|
||||
|
|
@ -321,7 +323,7 @@ main(int argc, char *argv[])
|
|||
bail(NO_SLEEP_EXIT, 1);
|
||||
}
|
||||
|
||||
pwd = getpwnam(username);
|
||||
(void)getpwnam_r(username, &pwres, pwbuf, sizeof(pwbuf), &pwd);
|
||||
if (pwd != NULL && pwd->pw_uid == 0)
|
||||
rootlogin = 1;
|
||||
|
||||
|
|
@ -344,7 +346,7 @@ main(int argc, char *argv[])
|
|||
(void)setpriority(PRIO_PROCESS, 0, 0);
|
||||
}
|
||||
|
||||
if (pwd && rval == 0)
|
||||
if (pwd != NULL && rval == 0)
|
||||
break;
|
||||
|
||||
pam_cleanup();
|
||||
|
|
@ -708,8 +710,10 @@ auth_pam(void)
|
|||
pam_err = pam_get_item(pamh, PAM_USER, &item);
|
||||
if (pam_err == PAM_SUCCESS) {
|
||||
tmpl_user = (const char *)item;
|
||||
if (strcmp(username, tmpl_user) != 0)
|
||||
pwd = getpwnam(tmpl_user);
|
||||
if (strcmp(username, tmpl_user) != 0) {
|
||||
(void)getpwnam_r(tmpl_user, &pwres, pwbuf,
|
||||
sizeof(pwbuf), &pwd);
|
||||
}
|
||||
} else {
|
||||
pam_syslog("pam_get_item(PAM_USER)");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue