summaryrefslogtreecommitdiff
path: root/src/su.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1997-12-10 10:25:46 +0000
committerJim Meyering <jim@meyering.net>1997-12-10 10:25:46 +0000
commit3cd84da3a607381b666856481c3feb7d9161b706 (patch)
tree04c42a172aaa5a5740415709e989cd184d33fa96 /src/su.c
parent92f0098844fc806a94a3e1256dfa28137758d900 (diff)
downloadcoreutils-3cd84da3a607381b666856481c3feb7d9161b706.tar.xz
(main): Make sure pw->pw_shell is non-NULL before trying to strdup it.
Patch from Dick Streefland.
Diffstat (limited to 'src/su.c')
-rw-r--r--src/su.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/su.c b/src/su.c
index 108d06239..dda02fe09 100644
--- a/src/su.c
+++ b/src/su.c
@@ -530,6 +530,10 @@ main (int argc, char **argv)
error (1, 0, _("user %s does not exist"), new_user);
endpwent ();
+ /* make sure pw->pw_shell is non-zero */
+ if (pw->pw_shell == 0 || pw->pw_shell[0] == 0)
+ pw->pw_shell = (char *) DEFAULT_SHELL;
+
/* Make a copy of the password information and point pw at the local
copy instead. Otherwise, some systems (e.g. Linux) would clobber
the static data through the getlogin call from log_su. */
@@ -553,8 +557,6 @@ main (int argc, char **argv)
}
#endif
- if (pw->pw_shell == 0 || pw->pw_shell[0] == 0)
- pw->pw_shell = (char *) DEFAULT_SHELL;
if (shell == 0 && change_environment == 0)
shell = getenv ("SHELL");
if (shell != 0 && getuid () && restricted_shell (pw->pw_shell))