Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewrite arg0_passed tests #919

Merged
merged 1 commit into from
Nov 28, 2024
Merged
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
14 changes: 5 additions & 9 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");
let stderr = output.stderr();
assert_starts_with!(stderr, "/nib/sleep:");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out this doesn't actually work on FreeBSD:

---- sudo::path_search::arg0_native_is_passed_from_commandline stdout ----
thread 'sudo::path_search::arg0_native_is_passed_from_commandline' panicked at sudo-compliance-tests/src/sudo/path_search.rs:130:5:
"usage: sleep number[unit] ...\nUnit can be 's' (seconds, the default), m (minutes), h (hours), or d (days)." did not start with "/nib/sleep:"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #922


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", "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
Loading