From: Sami Kerola Date: Sat, 20 Dec 2014 12:26:17 +0000 (+0000) Subject: newgrp: move shell determination closer where it is used X-Git-Tag: v2.26-rc1~96 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51c52acfb1118b27841a026fb1664691cc7bf6e2;p=thirdparty%2Futil-linux.git newgrp: move shell determination closer where it is used Signed-off-by: Sami Kerola --- diff --git a/login-utils/newgrp.c b/login-utils/newgrp.c index 3f5c720286..0fae08766e 100644 --- a/login-utils/newgrp.c +++ b/login-utils/newgrp.c @@ -202,9 +202,6 @@ int main(int argc, char *argv[]) if (!(pw_entry = getpwuid(getuid()))) err(EXIT_FAILURE, _("who are you?")); - shell = (pw_entry->pw_shell && *pw_entry->pw_shell ? - pw_entry->pw_shell : _PATH_BSHELL); - if (argc < 2) { if (setgid(pw_entry->pw_gid) < 0) err(EXIT_FAILURE, _("setgid failed")); @@ -225,8 +222,9 @@ int main(int argc, char *argv[]) if (setuid(getuid()) < 0) err(EXIT_FAILURE, _("setuid failed")); - fflush(stdout); - fflush(stderr); + fflush(NULL); + shell = (pw_entry->pw_shell && *pw_entry->pw_shell ? + pw_entry->pw_shell : _PATH_BSHELL); execl(shell, shell, (char *)0); warn(_("failed to execute %s"), shell); fflush(stderr);