diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-06-20 18:15:36 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-06-20 18:15:36 +0000 |
commit | 686bd4be827b8dfb27f2d87ca7190550ce065f67 (patch) | |
tree | 59ee183aa5d002015911195475bb903e9ce562c9 /usr.bin | |
parent | d69369bc82d2a3180c3dd6ae36160e895e821da7 (diff) |
Call setusershell() before using getusershell() to guarantee we
start checking on the first line of /etc/shells.
Also call endusershell() when we are done. From FreeBSD.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/su/su.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/usr.bin/su/su.c b/usr.bin/su/su.c index 7b9d519872d..0d37812ea8f 100644 --- a/usr.bin/su/su.c +++ b/usr.bin/su/su.c @@ -1,4 +1,4 @@ -/* $OpenBSD: su.c,v 1.52 2003/06/03 02:56:17 millert Exp $ */ +/* $OpenBSD: su.c,v 1.53 2003/06/20 18:15:35 millert Exp $ */ /* * Copyright (c) 1988 The Regents of the University of California. @@ -39,7 +39,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "from: @(#)su.c 5.26 (Berkeley) 7/6/91"; #else -static const char rcsid[] = "$OpenBSD: su.c,v 1.52 2003/06/03 02:56:17 millert Exp $"; +static const char rcsid[] = "$OpenBSD: su.c,v 1.53 2003/06/20 18:15:35 millert Exp $"; #endif #endif /* not lint */ @@ -64,7 +64,7 @@ static const char rcsid[] = "$OpenBSD: su.c,v 1.52 2003/06/03 02:56:17 millert E char *getloginname(void); char *ontty(void); -int chshell(char *); +int chshell(const char *); int verify_user(char *, struct passwd *, char *, login_cap_t *, auth_session_t *); void usage(void); @@ -364,14 +364,20 @@ verify_user(char *from, struct passwd *pwd, char *style, } int -chshell(char *sh) +chshell(const char *sh) { char *cp; + int found = 0; - while ((cp = getusershell()) != NULL) - if (strcmp(cp, sh) == 0) - return (1); - return (0); + setusershell(); + while ((cp = getusershell()) != NULL) { + if (strcmp(cp, sh) == 0) { + found = 1; + break; + } + } + endusershell(); + return (found); } char * |