We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7cced18 commit 2ec1ac7Copy full SHA for 2ec1ac7
test-framework/sudo-compliance-tests/src/sudoedit.rs
@@ -429,3 +429,32 @@ done",
429
430
assert_starts_with!(actual[actual.rfind('/').unwrap()..], "/foo");
431
}
432
+
433
+#[test]
434
+fn run_editor_as_correct_user() {
435
+ let env = Env(SUDOERS_ALL_ALL_NOPASSWD)
436
+ .user(USERNAME)
437
+ .file(
438
+ DEFAULT_EDITOR,
439
+ TextFile(
440
+ "#!/bin/sh
441
+id -un
442
+id -Gn",
443
+ )
444
+ .chmod(CHMOD_EXEC),
445
446
+ .build();
447
448
+ let output = Command::new("sh")
449
+ .arg("-c")
450
+ .arg(format!("{DEFAULT_EDITOR} && cd / && sudoedit foo"))
451
+ .as_user(USERNAME)
452
+ .output(&env);
453
454
+ output.assert_success();
455
456
+ assert_eq!(
457
+ output.stdout(),
458
+ format!("{USERNAME}\nusers\n{USERNAME}\nusers")
459
+ );
460
+}
0 commit comments