summaryrefslogtreecommitdiff
path: root/lib/libc/gen/auth_subr.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/gen/auth_subr.c')
-rw-r--r--lib/libc/gen/auth_subr.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/libc/gen/auth_subr.c b/lib/libc/gen/auth_subr.c
index 4f133d5c46b..9fd6d442121 100644
--- a/lib/libc/gen/auth_subr.c
+++ b/lib/libc/gen/auth_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auth_subr.c,v 1.48 2015/11/02 17:03:29 mmcc Exp $ */
+/* $OpenBSD: auth_subr.c,v 1.49 2015/11/24 22:03:33 millert Exp $ */
/*
* Copyright (c) 2000-2002,2004 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -616,7 +616,8 @@ DEF_WEAK(auth_setdata);
int
auth_setpwd(auth_session_t *as, struct passwd *pwd)
{
- char *instance;
+ struct passwd pwstore;
+ char *instance, pwbuf[_PW_BUF_LEN];
if (pwd == NULL && as->pwd == NULL && as->name == NULL)
return (-1); /* true failure */
@@ -633,12 +634,15 @@ auth_setpwd(auth_session_t *as, struct passwd *pwd)
*/
if (as->name == NULL)
return (0);
- if ((pwd = getpwnam(as->name)) == NULL) {
+ getpwnam_r(as->name, &pwstore, pwbuf, sizeof(pwbuf), &pwd);
+ if (pwd == NULL) {
instance = strchr(as->name, '/');
if (instance == NULL)
return (as->pwd ? 0 : 1);
- if (strcmp(instance, "/root") == 0)
- pwd = getpwnam(instance + 1);
+ if (strcmp(instance, "/root") == 0) {
+ getpwnam_r(instance + 1, &pwstore, pwbuf,
+ sizeof(pwbuf), &pwd);
+ }
if (pwd == NULL)
return (as->pwd ? 0 : 1);
}