Skip to content

Commit

Permalink
Merge pull request #770 from memorysafety/test-long-username
Browse files Browse the repository at this point in the history
test sudo with long username
  • Loading branch information
pvdrz authored Sep 19, 2023
2 parents dfed67e + 2f7924f commit e2edeca
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test-framework/sudo-compliance-tests/src/sudo/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,27 @@ fn does_not_panic_on_io_errors_cli_error() -> Result<()> {

Ok(())
}

#[test]
#[ignore = "gh771"]
fn long_username() -> Result<()> {
// `useradd` limits usernames to 32 characters
// directly write to `/etc/passwd` to work around this limitation
let username = "a".repeat(33);
let env = Env(SUDOERS_ALL_ALL_NOPASSWD).build()?;

Command::new("sh")
.arg("-c")
.arg(format!(
"echo {username}:x:1000:1000::/tmp:/bin/sh >> /etc/passwd"
))
.output(&env)?
.assert_success()?;

Command::new("sudo")
.arg("-u")
.arg(username)
.arg("true")
.output(&env)?
.assert_success()
}

0 comments on commit e2edeca

Please sign in to comment.