Add cwd_optional to command details and enable it in the sudoers plugin.

If cwd_optional is set to true, a failure to set the cwd will be a
warning, not an error, and the command will still run.
Debian bug #598519
This commit is contained in:
Todd C. Miller
2020-03-31 19:43:48 -06:00
parent 9dea4bb244
commit 93aa9f9e90
7 changed files with 55 additions and 6 deletions

View File

@@ -564,7 +564,7 @@ sudoers_policy_exec_setup(char *argv[], char *envp[], mode_t cmnd_umask,
debug_return_bool(true); /* nothing to do */
/* Increase the length of command_info as needed, it is *not* checked. */
command_info = calloc(52, sizeof(char *));
command_info = calloc(53, sizeof(char *));
if (command_info == NULL)
goto oom;
@@ -619,6 +619,8 @@ sudoers_policy_exec_setup(char *argv[], char *envp[], mode_t cmnd_umask,
/* Set cwd to run user's homedir. */
if ((command_info[info_len++] = sudo_new_key_val("cwd", runas_pw->pw_dir)) == NULL)
goto oom;
if ((command_info[info_len++] = strdup("cwd_optional=true")) == NULL)
goto oom;
}
if ((command_info[info_len++] = sudo_new_key_val("runas_user", runas_pw->pw_name)) == NULL)
goto oom;