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

@@ -678,6 +678,15 @@ command_info_to_details(char * const info[], struct command_details *details)
SET_STRING("chroot=", chroot)
SET_STRING("command=", command)
SET_STRING("cwd=", cwd)
if (strncmp("cwd_optional=", info[i], sizeof("cwd_optional=") - 1) == 0) {
cp = info[i] + sizeof("cwd_optional=") - 1;
details->cwd_optional = sudo_strtobool(cp);
if (details->cwd_optional == -1) {
errno = EINVAL;
sudo_fatal("%s", info[i]);
}
break;
}
if (strncmp("closefrom=", info[i], sizeof("closefrom=") - 1) == 0) {
cp = info[i] + sizeof("closefrom=") - 1;
details->closefrom = sudo_strtonum(cp, 0, INT_MAX, &errstr);