=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/su/su.c,v retrieving revision 1.40 retrieving revision 1.41 diff -c -r1.40 -r1.41 *** src/usr.bin/su/su.c 2001/06/25 21:29:31 1.40 --- src/usr.bin/su/su.c 2001/09/18 04:41:09 1.41 *************** *** 1,4 **** ! /* $OpenBSD: su.c,v 1.40 2001/06/25 21:29:31 hin Exp $ */ /* * Copyright (c) 1988 The Regents of the University of California. --- 1,4 ---- ! /* $OpenBSD: su.c,v 1.41 2001/09/18 04:41:09 millert Exp $ */ /* * Copyright (c) 1988 The Regents of the University of California. *************** *** 34,47 **** */ #ifndef lint ! char copyright[] = "@(#) Copyright (c) 1988 The Regents of the University of California.\n\ All rights reserved.\n"; #endif /* not lint */ #ifndef lint ! /*static char sccsid[] = "from: @(#)su.c 5.26 (Berkeley) 7/6/91";*/ ! static char rcsid[] = "$OpenBSD: su.c,v 1.40 2001/06/25 21:29:31 hin Exp $"; #endif /* not lint */ #include --- 34,50 ---- */ #ifndef lint ! static const char copyright[] = "@(#) Copyright (c) 1988 The Regents of the University of California.\n\ All rights reserved.\n"; #endif /* not lint */ #ifndef lint ! #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.41 2001/09/18 04:41:09 millert Exp $"; ! #endif #endif /* not lint */ #include *************** *** 87,93 **** int asme, asthem, authok, ch, fastlogin, prio; char *class, *style, *p, **g; char *user, *shell, *avshell, *username, **np, *fullname; ! char shellbuf[MAXPATHLEN], avshellbuf[MAXPATHLEN]; iscsh = UNSET; class = shell = style = NULL; --- 90,96 ---- int asme, asthem, authok, ch, fastlogin, prio; char *class, *style, *p, **g; char *user, *shell, *avshell, *username, **np, *fullname; ! char avshellbuf[MAXPATHLEN]; iscsh = UNSET; class = shell = style = NULL; *************** *** 144,150 **** ruid = getuid(); username = getlogin(); ! if(username != NULL) auth_setoption(as, "invokinguser", username); if (username == NULL || (pwd = getpwnam(username)) == NULL || --- 147,153 ---- ruid = getuid(); username = getlogin(); ! if (username != NULL) auth_setoption(as, "invokinguser", username); if (username == NULL || (pwd = getpwnam(username)) == NULL || *************** *** 153,163 **** if (pwd == NULL) auth_errx(as, 1, "who are you?"); if ((username = strdup(pwd->pw_name)) == NULL) ! auth_err(as, 1, "can't allocate memory"); if (asme) { if (pwd->pw_shell && *pwd->pw_shell) { ! strlcpy(shellbuf, pwd->pw_shell, sizeof(shellbuf)); ! shell = shellbuf; } else { shell = _PATH_BSHELL; iscsh = NO; --- 156,165 ---- if (pwd == NULL) auth_errx(as, 1, "who are you?"); if ((username = strdup(pwd->pw_name)) == NULL) ! auth_errx(as, 1, "can't allocate memory"); if (asme) { if (pwd->pw_shell && *pwd->pw_shell) { ! shell = strdup(pwd->pw_shell); } else { shell = _PATH_BSHELL; iscsh = NO; *************** *** 170,177 **** if ((pwd = getpwnam(user)) == NULL) auth_errx(as, 1, "unknown login %s", user); ! if ((user = strdup(pwd->pw_name)) == NULL) ! auth_err(as, 1, "can't allocate memory"); /* If the user specified a login class and we are root, use it */ if (ruid && class) --- 172,180 ---- if ((pwd = getpwnam(user)) == NULL) auth_errx(as, 1, "unknown login %s", user); ! if ((pwd = pw_dup(pwd)) == NULL) ! 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 (ruid && class)