Skip to content

Commit 43d0f4c

Browse files
authored
Fix the permission flags that visudo sets on the temporary file (#1185)
2 parents 5d8ca26 + 989cae8 commit 43d0f4c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/visudo/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ fn run(file_arg: Option<&str>, perms: bool, owner: bool) -> io::Result<()> {
222222
.truncate(true)
223223
.open(&tmp_path)?;
224224

225-
tmp_file.set_permissions(Permissions::from_mode(0o700))?;
225+
tmp_file.set_permissions(Permissions::from_mode(0o600))?;
226226

227227
let result = edit_sudoers_file(
228228
existed,

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,14 @@ ls -l /tmp/sudoers-*/sudoers > {LOGS_PATH}"#
160160

161161
let ls_output = Command::new("cat").arg(LOGS_PATH).output(&env).stdout();
162162

163-
assert_ls_output(&ls_output, "-rwx------", "root", ROOT_GROUP);
163+
if sudo_test::is_original_sudo() {
164+
//TODO: this is incorrect, will be fixed in a future sudo; the
165+
//point of the test anyway is that the file is not accessible
166+
//by any other than the owner.
167+
assert_ls_output(&ls_output, "-rwx------", "root", ROOT_GROUP);
168+
} else {
169+
assert_ls_output(&ls_output, "-rw-------", "root", ROOT_GROUP);
170+
}
164171
}
165172

166173
#[test]

0 commit comments

Comments
 (0)