From 24cfe44b07c0c457a6ab0b826dc6f8afe83b5009 Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Wed, 22 Jul 2009 13:35:57 +0000 Subject: [PATCH] * libmisc/shell.c, src/su.c: Execute the scripts with "sh -" rather than "sh". --- ChangeLog | 5 +++++ libmisc/shell.c | 2 +- src/su.c | 9 +++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index caa4f095..0e59abd8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-07-22 Nicolas François + + * libmisc/shell.c, src/su.c: Execute the scripts with "sh -" + rather than "sh". + 2009-07-22 Nicolas François * configure.in, libmisc/shell.c, libmisc/setupenv.c, src/newgrp.c, diff --git a/libmisc/shell.c b/libmisc/shell.c index 4e70505a..e253ae3f 100644 --- a/libmisc/shell.c +++ b/libmisc/shell.c @@ -85,7 +85,7 @@ int shell (const char *file, /*@null@*/const char *arg, char *const envp[]) * Assume this is a shell script (with no shebang). * Interpret it with /bin/sh */ - execle (SHELL, "sh", file, (char *)0, envp); + execle (SHELL, "sh", "-", file, (char *)0, envp); err = errno; } diff --git a/src/su.c b/src/su.c index c6772a76..c4c25a1d 100644 --- a/src/su.c +++ b/src/su.c @@ -194,12 +194,13 @@ void execve_shell (const char *shellstr, char *args[], char *const envp[]) while (NULL != args[n_args]) { n_args++; } - targs = (char **) xmalloc ((n_args + 2) * sizeof (args[0])); + targs = (char **) xmalloc ((n_args + 3) * sizeof (args[0])); targs[0] = "sh"; - targs[1] = xstrdup (shellstr); - targs[n_args+1] = NULL; + targs[1] = "-"; + targs[2] = xstrdup (shellstr); + targs[n_args+2] = NULL; while (1 != n_args) { - targs[n_args] = args[n_args - 1]; + targs[n_args+1] = args[n_args - 1]; n_args--; }