Skip to content

Commit

Permalink
Add regression test for the IO safety violation
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 authored and squell committed Nov 25, 2024
1 parent 0107ff2 commit aab3180
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test-framework/e2e-tests/src/regression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,24 @@ fn syslog_writer_should_not_hang() -> Result<()> {

Ok(())
}

#[test]
fn no_permissions_should_not_violate_io_safety() -> Result<()> {
let env = Env(TextFile("ALL ALL=(ALL:ALL) NOPASSWD: ALL").chmod("644"))
.file("/bin/foo", "#!/bin/sh") // File not executable
.build()?;

let output = Command::new("sudo").arg("/bin/foo").output(&env)?;

assert!(!output.status().success());

let stderr = output.stderr();
assert!(!stderr.contains("IO Safety violation"), "{stderr}");

assert_eq!(
stderr,
"sudo-rs: cannot execute '/usr/bin/foo': Permission denied (os error 13)"
);

Ok(())
}

0 comments on commit aab3180

Please sign in to comment.