Error out if sesh is run as a login shell but the shell it needs

to run has no slash.  This shouldn't happen in practice.
This commit is contained in:
Todd C. Miller
2014-07-14 09:56:38 -06:00
parent 9071e95080
commit fb96eb2445

View File

@@ -74,9 +74,10 @@ main(int argc, char *argv[], char *envp[])
/* If invoked as a login shell, modify argv[0] accordingly. */
if (login_shell) {
if ((cp = strrchr(argv[0], '/')) != NULL)
if ((cp = strrchr(argv[0], '/')) == NULL)
sudo_fatal(U_("unable to run %s as a login shell"), argv[0]);
*cp = '-';
argv[0] = cp;
argv[0][0] = '-';
}
sudo_execve(cmnd, argv, envp, noexec);
sudo_warn(U_("unable to execute %s"), cmnd);