Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/exec/use_pty/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,7 @@ impl<'a> MonitorClosure<'a> {
Err(err) => registry.set_break(err),
Ok(error_code) => {
// Received error code from the command, forward it to the parent.
self.backchannel
.send(&ParentMessage::IoError(error_code))
.ok();
registry.set_break(io::Error::from_raw_os_error(error_code));
}
}
}
Expand Down
22 changes: 20 additions & 2 deletions test-framework/sudo-compliance-tests/src/sudo/misc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use sudo_test::User;
use sudo_test::{helpers::assert_ls_output, Command, Env, BIN_SUDO};
use sudo_test::{helpers::assert_ls_output, is_original_sudo, Command, Env, User, BIN_SUDO};

use crate::{Result, PANIC_EXIT_CODE, SUDOERS_ALL_ALL_NOPASSWD, USERNAME};

Expand Down Expand Up @@ -202,6 +201,25 @@ fn does_not_panic_on_io_errors_cli_error() -> Result<()> {
Ok(())
}

#[test]
fn does_not_panic_on_invalid_executable() {
let env = Env(SUDOERS_ALL_ALL_NOPASSWD).build();

let output = Command::new("bash")
.args(["-c", "sudo /tmp; a=$?; sleep .1; exit $a"])
.tty(true) // Necessary to reproduce the panic
.output(&env);
output.assert_exit_code(1);

assert!(!output.stderr().contains("panic"), "{output:?}");
assert!(!output.stdout_unchecked().contains("panic"), "{output:?}");
if is_original_sudo() {
assert_contains!(output.stdout_unchecked(), "command not found");
} else {
assert_contains!(output.stdout_unchecked(), "Permission denied");
}
}

#[test]
#[cfg_attr(
target_os = "freebsd",
Expand Down
Loading