From 51c52acfb1118b27841a026fb1664691cc7bf6e2 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 20 Dec 2014 12:26:17 +0000 Subject: [PATCH] newgrp: move shell determination closer where it is used Signed-off-by: Sami Kerola --- login-utils/newgrp.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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); -- 2.47.3