]> granicus.if.org Git - sudo/commitdiff
Workaround for "sudo -i command" and newer versions of bash which
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 26 Jun 2011 22:02:09 +0000 (18:02 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 26 Jun 2011 22:02:09 +0000 (18:02 -0400)
don't go into login mode when -c is specified unless -l is too.

plugins/sudoers/sudoers.c

index db4b88fbb77a7d54946894d68309e3fd9f4d04b8..e7524428217e8c87560d47815666b90a5ae2afd0 100644 (file)
@@ -580,6 +580,15 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[],
        /* Set cwd to run user's homedir. */
        command_info[info_len++] = fmt_string("cwd", runas_pw->pw_dir);
 
+       /*
+        * Newer versions of bash require the -l option to be used
+        * in conjunction with the -c option even if the shell name
+        * starts with a '-'.
+        */
+       if (NewArgc > 1 && strcmp(NewArgv[0], "-bash") == 0 &&
+           strcmp(NewArgv[1], "-c") == 0)
+           NewArgv[1] = "-lc";
+
 #if defined(__linux__) || defined(_AIX)
        /* Insert system-wide environment variables. */
        read_env_file(_PATH_ENVIRONMENT, TRUE);