From: Todd C. Miller Date: Sat, 20 Sep 2014 15:21:51 +0000 (-0600) Subject: On AIX, _PATH_BSHELL is /usr/bin/bsh but we want to use /usr/bin/sh X-Git-Tag: SUDO_1_8_11^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7ab40be5c0231e162b7c8c863fa8da36456e90ab;p=sudo On AIX, _PATH_BSHELL is /usr/bin/bsh but we want to use /usr/bin/sh (which is usually ksh). This makes sudo's behavior when executing a shell without the #! magic number match execvp() on AIX. --- diff --git a/pathnames.h.in b/pathnames.h.in index f6d247270..797cc037c 100644 --- a/pathnames.h.in +++ b/pathnames.h.in @@ -178,3 +178,12 @@ #ifndef _PATH_NETSVC_CONF # undef _PATH_NETSVC_CONF #endif /* _PATH_NETSVC_CONF */ + +/* On AIX, _PATH_BSHELL is /usr/bin/bsh but we want /usr/bin/sh */ +#ifndef _PATH_SUDO_BSHELL +# ifdef _AIX +# define _PATH_SUDO_BSHELL "/usr/bin/sh" +# else +# define _PATH_SUDO_BSHELL _PATH_BSHELL +# endif +#endif /* _PATH_SUDO_BSHELL */ diff --git a/src/exec_common.c b/src/exec_common.c index 4d8a597df..914fc7023 100644 --- a/src/exec_common.c +++ b/src/exec_common.c @@ -155,7 +155,7 @@ sudo_execve(const char *path, char *const argv[], char *const envp[], bool noexe nargv[0] = "sh"; nargv[1] = (char *)path; memcpy(nargv + 2, argv + 1, argc * sizeof(char *)); - execve(_PATH_BSHELL, nargv, envp); + execve(_PATH_SUDO_BSHELL, nargv, envp); sudo_efree(nargv); } return -1; diff --git a/src/sudo.c b/src/sudo.c index aa66e5ba7..164014c41 100644 --- a/src/sudo.c +++ b/src/sudo.c @@ -471,7 +471,7 @@ get_user_info(struct user_details *ud) /* Stash user's shell for use with the -s flag; don't pass to plugin. */ if ((ud->shell = getenv("SHELL")) == NULL || ud->shell[0] == '\0') { - ud->shell = pw->pw_shell[0] ? pw->pw_shell : _PATH_BSHELL; + ud->shell = pw->pw_shell[0] ? pw->pw_shell : _PATH_SUDO_BSHELL; } ud->shell = sudo_estrdup(ud->shell);