version 1.40, 2001/06/25 21:29:31 |
version 1.41, 2001/09/18 04:41:09 |
|
|
*/ |
*/ |
|
|
#ifndef lint |
#ifndef lint |
char copyright[] = |
static const char copyright[] = |
"@(#) Copyright (c) 1988 The Regents of the University of California.\n\ |
"@(#) Copyright (c) 1988 The Regents of the University of California.\n\ |
All rights reserved.\n"; |
All rights reserved.\n"; |
#endif /* not lint */ |
#endif /* not lint */ |
|
|
#ifndef lint |
#ifndef lint |
/*static char sccsid[] = "from: @(#)su.c 5.26 (Berkeley) 7/6/91";*/ |
#if 0 |
static char rcsid[] = "$OpenBSD$"; |
static const char sccsid[] = "from: @(#)su.c 5.26 (Berkeley) 7/6/91"; |
|
#else |
|
static const char rcsid[] = "$OpenBSD$"; |
|
#endif |
#endif /* not lint */ |
#endif /* not lint */ |
|
|
#include <sys/param.h> |
#include <sys/param.h> |
|
|
int asme, asthem, authok, ch, fastlogin, prio; |
int asme, asthem, authok, ch, fastlogin, prio; |
char *class, *style, *p, **g; |
char *class, *style, *p, **g; |
char *user, *shell, *avshell, *username, **np, *fullname; |
char *user, *shell, *avshell, *username, **np, *fullname; |
char shellbuf[MAXPATHLEN], avshellbuf[MAXPATHLEN]; |
char avshellbuf[MAXPATHLEN]; |
|
|
iscsh = UNSET; |
iscsh = UNSET; |
class = shell = style = NULL; |
class = shell = style = NULL; |
|
|
ruid = getuid(); |
ruid = getuid(); |
username = getlogin(); |
username = getlogin(); |
|
|
if(username != NULL) |
if (username != NULL) |
auth_setoption(as, "invokinguser", username); |
auth_setoption(as, "invokinguser", username); |
|
|
if (username == NULL || (pwd = getpwnam(username)) == NULL || |
if (username == NULL || (pwd = getpwnam(username)) == NULL || |
|
|
if (pwd == NULL) |
if (pwd == NULL) |
auth_errx(as, 1, "who are you?"); |
auth_errx(as, 1, "who are you?"); |
if ((username = strdup(pwd->pw_name)) == NULL) |
if ((username = strdup(pwd->pw_name)) == NULL) |
auth_err(as, 1, "can't allocate memory"); |
auth_errx(as, 1, "can't allocate memory"); |
if (asme) { |
if (asme) { |
if (pwd->pw_shell && *pwd->pw_shell) { |
if (pwd->pw_shell && *pwd->pw_shell) { |
strlcpy(shellbuf, pwd->pw_shell, sizeof(shellbuf)); |
shell = strdup(pwd->pw_shell); |
shell = shellbuf; |
|
} else { |
} else { |
shell = _PATH_BSHELL; |
shell = _PATH_BSHELL; |
iscsh = NO; |
iscsh = NO; |
|
|
|
|
if ((pwd = getpwnam(user)) == NULL) |
if ((pwd = getpwnam(user)) == NULL) |
auth_errx(as, 1, "unknown login %s", user); |
auth_errx(as, 1, "unknown login %s", user); |
if ((user = strdup(pwd->pw_name)) == NULL) |
if ((pwd = pw_dup(pwd)) == NULL) |
auth_err(as, 1, "can't allocate memory"); |
auth_errx(as, 1, "can't allocate memory"); |
|
user = pwd->pw_name; |
|
|
/* If the user specified a login class and we are root, use it */ |
/* If the user specified a login class and we are root, use it */ |
if (ruid && class) |
if (ruid && class) |