Skip to content

Commit

Permalink
rewrite arg0_passed tests so it is clearer they are focussed on the d…
Browse files Browse the repository at this point in the history
…irectory hierarchy
  • Loading branch information
squell committed Nov 28, 2024
1 parent 87e51e9 commit 470d057
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions test-framework/sudo-compliance-tests/src/sudo/path_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,12 @@ fn arg0_native_is_passed_from_commandline() -> Result<()> {
let output = Command::new("sh")
.args([
"-c",
"ln -s /bin/ls /bin/foo; sudo /bin/foo --invalid-flag; true",
"ln -s /bin /nib; sudo /nib/sleep --invalid-flag; true",
])
.output(&env)?;

let mut stderr = output.stderr();
// On GNU, this will report "/bin/foo: ...". but FreeBSD's `ls` does not print its full invoked path in error
if stderr.starts_with("/bin/") {
stderr = &stderr[5..]
}
assert_starts_with!(stderr, "foo: unrecognized option");
assert_starts_with!(stderr, "/nib/sleep:");

Ok(())
}
Expand Down Expand Up @@ -162,11 +158,11 @@ fn arg0_script_is_passed_from_commandline() -> Result<()> {
.build()?;

let output = Command::new("sh")
.args(["-c", &format!("ln -s {path} /bin/foo; sudo /bin/foo")])
.args(["-c", &format!("ln -s /bin /nib; sudo /nib/my-script")])
.output(&env)?;

let stdout = output.stdout()?;
assert_eq!(stdout, "/bin/foo");
assert_eq!(stdout, "/nib/my-script");

Ok(())
}
Expand Down

0 comments on commit 470d057

Please sign in to comment.