]> granicus.if.org Git - sudo/commitdiff
Error out if sesh is run as a login shell but the shell it needs
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 14 Jul 2014 15:56:38 +0000 (09:56 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 14 Jul 2014 15:56:38 +0000 (09:56 -0600)
to run has no slash.  This shouldn't happen in practice.

src/sesh.c

index 86d8c09623459df7c02f4577c166dd1ff6644065..d939f1b473b1f6acdf1a5d75e04e4ae06c1bd753 100644 (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)
-           argv[0] = cp;
-       argv[0][0] = '-';
+       if ((cp = strrchr(argv[0], '/')) == NULL)
+           sudo_fatal(U_("unable to run %s as a login shell"), argv[0]);
+       *cp = '-';
+       argv[0] = cp;
     }
     sudo_execve(cmnd, argv, envp, noexec);
     sudo_warn(U_("unable to execute %s"), cmnd);