summaryrefslogtreecommitdiffstats
path: root/login-utils/newgrp.c
diff options
context:
space:
mode:
authorSami Kerola2014-12-20 13:26:17 +0100
committerSami Kerola2015-01-05 23:53:01 +0100
commit51c52acfb1118b27841a026fb1664691cc7bf6e2 (patch)
treea0f3ccdfe44bf7b17cac706385c11528a25e7d1d /login-utils/newgrp.c
parentnewgrp: simplify if else clauses (diff)
downloadkernel-qcow2-util-linux-51c52acfb1118b27841a026fb1664691cc7bf6e2.tar.gz
kernel-qcow2-util-linux-51c52acfb1118b27841a026fb1664691cc7bf6e2.tar.xz
kernel-qcow2-util-linux-51c52acfb1118b27841a026fb1664691cc7bf6e2.zip
newgrp: move shell determination closer where it is used
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'login-utils/newgrp.c')
-rw-r--r--login-utils/newgrp.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/login-utils/newgrp.c b/login-utils/newgrp.c
index 3f5c72028..0fae08766 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);