Skip to content

Commit 84bc552

Browse files
committed
add failing compliance test
1 parent b63dee9 commit 84bc552

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test-framework/sudo-compliance-tests/src/sudoedit.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,3 +398,31 @@ done",
398398
);
399399
}
400400
}
401+
402+
#[test]
403+
fn can_edit_in_current_dir() {
404+
let env = Env(SUDOERS_ALL_ALL_NOPASSWD)
405+
.user(USERNAME)
406+
.file(
407+
DEFAULT_EDITOR,
408+
TextFile(
409+
"#!/bin/sh
410+
411+
for f in \"$@\"
412+
do echo \"$f\" > \"$f\"
413+
done",
414+
)
415+
.chmod(CHMOD_EXEC),
416+
)
417+
.build();
418+
419+
Command::new("sh")
420+
.args(["-c", "cd / && sudoedit foo"])
421+
.as_user(USERNAME)
422+
.output(&env)
423+
.assert_success();
424+
425+
let actual = Command::new("cat").arg("/foo").output(&env).stdout();
426+
427+
assert_starts_with!(actual[actual.rfind('/').unwrap()..], "/foo");
428+
}

0 commit comments

Comments
 (0)