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.
This commit is contained in:
Todd C. Miller
2014-09-20 09:21:51 -06:00
parent d4d724b886
commit 7ab40be5c0
3 changed files with 11 additions and 2 deletions

View File

@@ -178,3 +178,12 @@
#ifndef _PATH_NETSVC_CONF #ifndef _PATH_NETSVC_CONF
# undef _PATH_NETSVC_CONF # undef _PATH_NETSVC_CONF
#endif /* _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 */

View File

@@ -155,7 +155,7 @@ sudo_execve(const char *path, char *const argv[], char *const envp[], bool noexe
nargv[0] = "sh"; nargv[0] = "sh";
nargv[1] = (char *)path; nargv[1] = (char *)path;
memcpy(nargv + 2, argv + 1, argc * sizeof(char *)); memcpy(nargv + 2, argv + 1, argc * sizeof(char *));
execve(_PATH_BSHELL, nargv, envp); execve(_PATH_SUDO_BSHELL, nargv, envp);
sudo_efree(nargv); sudo_efree(nargv);
} }
return -1; return -1;

View File

@@ -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. */ /* 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') { 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); ud->shell = sudo_estrdup(ud->shell);