Skip to content

Commit

Permalink
tmpfiles: Don't call umask() in tests
Browse files Browse the repository at this point in the history
This affects *global state* and is almost certainly the cause
of 9baf570
  • Loading branch information
cgwalters committed Jan 24, 2025
1 parent e7d3023 commit 9df317a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions rust/src/tmpfiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ q /var/tmp 1777 root root 30d

#[test]
fn test_tmpfiles_d_translation() {
use nix::sys::stat::{umask, Mode};
use rustix::process::{getegid, geteuid};

// Create an empty file with the given mode
Expand All @@ -435,7 +434,6 @@ q /var/tmp 1777 root root 30d
db.mode(0o755);

// Prepare a minimal rootfs as playground.
umask(Mode::empty());
let rootfs = cap_tempfile::tempdir(cap_std::ambient_authority()).unwrap();
let uid = geteuid().as_raw();
let gid = getegid().as_raw();
Expand Down Expand Up @@ -468,8 +466,14 @@ q /var/tmp 1777 root root 30d
touch(&rootfs, "var/lib/systemd/random-seed", 0o770).unwrap();
rootfs.ensure_dir_with("var/lib/nfs", &db).unwrap();
touch(&rootfs, "var/lib/nfs/etab", 0o770).unwrap();
db.mode(0o777);
let global_rwx = Permissions::from_mode(0o777);
rootfs.ensure_dir_with("var/lib/test/nested", &db).unwrap();
rootfs
.set_permissions("var/lib/test", global_rwx.clone())
.unwrap();
rootfs
.set_permissions("var/lib/test/nested", global_rwx)
.unwrap();
touch(&rootfs, "var/lib/test/nested/file", 0o770).unwrap();
rootfs
.symlink("../", "var/lib/test/nested/symlink")
Expand Down

0 comments on commit 9df317a

Please sign in to comment.