Kill the command if intercept_setup() or ptrace_seize() fail.
This commit is contained in:
@@ -475,16 +475,20 @@ exec_nopty(struct command_details *details, struct command_status *cstat)
|
|||||||
*/
|
*/
|
||||||
fill_exec_closure_nopty(&ec, cstat, details, errpipe[0]);
|
fill_exec_closure_nopty(&ec, cstat, details, errpipe[0]);
|
||||||
|
|
||||||
/* Create event and closure for intercept mode. */
|
|
||||||
if (ISSET(details->flags, CD_INTERCEPT|CD_LOG_SUBCMDS)) {
|
if (ISSET(details->flags, CD_INTERCEPT|CD_LOG_SUBCMDS)) {
|
||||||
ec.intercept = intercept_setup(intercept_sv[0], ec.evbase, details);
|
bool success = true;
|
||||||
if (ec.intercept == NULL)
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ISSET(details->flags, CD_USE_PTRACE)) {
|
/* Create event and closure for intercept mode. */
|
||||||
/* Seize control of the command using ptrace(2). */
|
ec.intercept = intercept_setup(intercept_sv[0], ec.evbase, details);
|
||||||
exec_ptrace_seize(ec.cmnd_pid);
|
if (ec.intercept == NULL) {
|
||||||
|
success = false;
|
||||||
|
} else if (ISSET(details->flags, CD_USE_PTRACE)) {
|
||||||
|
/* Seize control of the command using ptrace(2). */
|
||||||
|
if (!exec_ptrace_seize(ec.cmnd_pid))
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
if (!success)
|
||||||
|
terminate_command(ec.cmnd_pid, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Restore signal mask now that signal handlers are setup. */
|
/* Restore signal mask now that signal handlers are setup. */
|
||||||
|
@@ -995,7 +995,13 @@ backchannel_cb(int fd, int what, void *v)
|
|||||||
ec->details->command, (int)ec->cmnd_pid);
|
ec->details->command, (int)ec->cmnd_pid);
|
||||||
if (ISSET(ec->details->flags, CD_USE_PTRACE)) {
|
if (ISSET(ec->details->flags, CD_USE_PTRACE)) {
|
||||||
/* Seize control of the command using ptrace(2). */
|
/* Seize control of the command using ptrace(2). */
|
||||||
exec_ptrace_seize(ec->cmnd_pid);
|
if (!exec_ptrace_seize(ec->cmnd_pid)) {
|
||||||
|
if (ec->cstat->type == CMD_INVALID) {
|
||||||
|
ec->cstat->type = CMD_ERRNO;
|
||||||
|
ec->cstat->val = errno;
|
||||||
|
}
|
||||||
|
sudo_ev_loopbreak(ec->evbase);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_WSTATUS:
|
case CMD_WSTATUS:
|
||||||
@@ -1675,7 +1681,7 @@ exec_pty(struct command_details *details, struct command_status *cstat)
|
|||||||
if (ISSET(details->flags, CD_INTERCEPT|CD_LOG_SUBCMDS)) {
|
if (ISSET(details->flags, CD_INTERCEPT|CD_LOG_SUBCMDS)) {
|
||||||
ec.intercept = intercept_setup(intercept_sv[0], ec.evbase, details);
|
ec.intercept = intercept_setup(intercept_sv[0], ec.evbase, details);
|
||||||
if (ec.intercept == NULL)
|
if (ec.intercept == NULL)
|
||||||
exit(EXIT_FAILURE);
|
terminate_command(ec.cmnd_pid, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Restore signal mask now that signal handlers are setup. */
|
/* Restore signal mask now that signal handlers are setup. */
|
||||||
|
Reference in New Issue
Block a user