diff --git a/ChangeLog b/ChangeLog index aafef322..caa4f095 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-07-22 Nicolas François + + * configure.in, libmisc/shell.c, libmisc/setupenv.c, src/newgrp.c, + src/su.c: Let the system shell be configurable. + 2009-07-20 Nicolas François * NEWS, src/su.c, libmisc/shell.c: Added support for shells being a diff --git a/configure.in b/configure.in index 0be585b7..861356b3 100644 --- a/configure.in +++ b/configure.in @@ -491,6 +491,8 @@ if test "$enable_utmpx" = "yes"; then [Define if utmpx should be used]) fi +AC_DEFINE_UNQUOTED(SHELL, [$SHELL], [The default shell.]) + AM_GNU_GETTEXT_VERSION(0.16) AM_GNU_GETTEXT([external], [need-ngettext]) AM_CONDITIONAL(USE_NLS, test "x$USE_NLS" = "xyes") diff --git a/libmisc/setupenv.c b/libmisc/setupenv.c index 69388136..7d6f7dea 100644 --- a/libmisc/setupenv.c +++ b/libmisc/setupenv.c @@ -242,7 +242,7 @@ void setup_env (struct passwd *info) */ if ((NULL == info->pw_shell) || ('\0' == *info->pw_shell)) { - static char temp_pw_shell[] = "/bin/sh"; + static char temp_pw_shell[] = SHELL; info->pw_shell = temp_pw_shell; } diff --git a/libmisc/shell.c b/libmisc/shell.c index 2dd3bb25..4e70505a 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 ("/bin/sh", "sh", file, (char *)0, envp); + execle (SHELL, "sh", file, (char *)0, envp); err = errno; } diff --git a/src/newgrp.c b/src/newgrp.c index e4ea4115..3a03a65c 100644 --- a/src/newgrp.c +++ b/src/newgrp.c @@ -722,7 +722,7 @@ int main (int argc, char **argv) */ if (cflag) { closelog (); - execl ("/bin/sh", "sh", "-c", command, (char *) 0); + execl (SHELL, "sh", "-c", command, (char *) 0); #ifdef WITH_AUDIT snprintf (audit_buf, sizeof(audit_buf), "changing new-gid=%lu", (unsigned long) gid); @@ -730,7 +730,7 @@ int main (int argc, char **argv) audit_buf, NULL, (unsigned int) getuid (), 0); #endif - perror ("/bin/sh"); + perror (SHELL); exit ((errno == ENOENT) ? E_CMD_NOTFOUND : E_CMD_NOEXEC); } @@ -757,7 +757,7 @@ int main (int argc, char **argv) } else if ((NULL != pwd->pw_shell) && ('\0' != pwd->pw_shell[0])) { prog = pwd->pw_shell; } else { - prog = "/bin/sh"; + prog = SHELL; } /* diff --git a/src/su.c b/src/su.c index 3e87425e..c6772a76 100644 --- a/src/su.c +++ b/src/su.c @@ -203,7 +203,7 @@ void execve_shell (const char *shellstr, char *args[], char *const envp[]) n_args--; } - (void) execve ("/bin/sh", targs, envp); + (void) execve (SHELL, targs, envp); } else { errno = err; } @@ -724,7 +724,7 @@ int main (int argc, char **argv) * Set the default shell. */ if ((NULL == shellstr) || ('\0' == shellstr[0])) { - shellstr = "/bin/sh"; + shellstr = SHELL; } (void) signal (SIGINT, SIG_IGN);