Skip to content

Conversation

@aanderse
Copy link
Contributor

  • intended to be read commit by commit
  • more testing required
  • mix of new features and bug fixes

i created some tests...

subtest: boot-time tmpfiles processingx 25.05, entering runlevel 2
machine: shell connected
machine: succeed: test -d /run/tmpfiles-test/boot-created
machine: succeed: test -f /run/tmpfiles-test/boot-created/marker
machine: succeed: cat /run/tmpfiles-test/boot-created/marker
(finished: boot-time tmpfiles processing, in 6.168s)
subtest: d - create directory
machine: succeed: echo 'd /tmp/test-d 0755 root root -' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: test -d /tmp/test-d
machine: succeed: stat -c %a /tmp/test-d
(finished: d - create directory, in 0.016s)
subtest: d - create nested directories
machine: succeed: echo 'd /tmp/test-nested/a/b/c 0755 root root -' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: test -d /tmp/test-nested/a/b/c
(finished: d - create nested directories, in 0.004s)
subtest: d - directory with mode 0700
machine: succeed: echo 'd /tmp/test-private 0700 root root -' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: stat -c %a /tmp/test-private
(finished: d - directory with mode 0700, in 0.008s)
subtest: D - create directory (cleanup variant)
machine: succeed: echo 'D /tmp/test-D 0755 root root -' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: test -d /tmp/test-D
(finished: D - create directory (cleanup variant), in 0.004s)
subtest: D - remove cleans contents but keeps directory
machine: succeed: touch /tmp/test-D/somefile
machine: succeed: test -f /tmp/test-D/somefile
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --remove /tmp/test.conf
machine: fail: test -f /tmp/test-D/somefile
machine: succeed: test -d /tmp/test-D
(finished: D - remove cleans contents but keeps directory, in 0.011s)
subtest: f - create empty file
machine: succeed: echo 'f /tmp/test-f-empty 0644 root root -' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: test -f /tmp/test-f-empty
machine: succeed: stat -c %s /tmp/test-f-empty
(finished: f - create empty file, in 0.01s)
subtest: f - create file with content
machine: succeed: echo 'f /tmp/test-f-content 0644 root root - hello world' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: cat /tmp/test-f-content
(finished: f - create file with content, in 0.009s)
subtest: f - does not overwrite existing file
machine: succeed: echo 'original' > /tmp/test-f-nooverwrite
machine: succeed: echo 'f /tmp/test-f-nooverwrite 0644 root root - new content' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: cat /tmp/test-f-nooverwrite
(finished: f - does not overwrite existing file, in 0.009s)
subtest: F - create/truncate file
machine: succeed: echo 'existing content' > /tmp/test-F
machine: succeed: echo 'F /tmp/test-F 0644 root root - new content' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: cat /tmp/test-F
(finished: F - create/truncate file, in 0.008s)
subtest: f+ - force create/truncate
machine: succeed: echo 'old' > /tmp/test-fplus
machine: succeed: echo 'f+ /tmp/test-fplus 0644 root root - replaced' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: cat /tmp/test-fplus
(finished: f+ - force create/truncate, in 0.011s)
subtest: L - create symlink
machine: succeed: echo 'L /tmp/test-link - - - - /etc/hostname' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: test -L /tmp/test-link
machine: succeed: readlink /tmp/test-link
(finished: L - create symlink, in 0.011s)
subtest: L - does not replace existing
machine: succeed: ln -sf /etc/passwd /tmp/test-link-noforce
machine: succeed: echo 'L /tmp/test-link-noforce - - - - /etc/hostname' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: readlink /tmp/test-link-noforce
(finished: L - does not replace existing, in 0.016s)
subtest: L+ - force replace symlink
machine: succeed: ln -sf /etc/passwd /tmp/test-link-force
machine: succeed: echo 'L+ /tmp/test-link-force - - - - /etc/hostname' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: readlink /tmp/test-link-force
(finished: L+ - force replace symlink, in 0.015s)
subtest: L+ - replace regular file with symlink
machine: succeed: echo 'blocker' > /tmp/test-link-replace
machine: succeed: test -f /tmp/test-link-replace
machine: fail: test -L /tmp/test-link-replace
machine: succeed: echo 'L+ /tmp/test-link-replace - - - - /etc/hostname' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: test -L /tmp/test-link-replace
(finished: L+ - replace regular file with symlink, in 0.005s)
subtest: r - remove single file
machine: succeed: touch /tmp/test-r-file
machine: succeed: test -f /tmp/test-r-file
machine: succeed: echo 'r /tmp/test-r-file' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --remove /tmp/test.conf
machine: fail: test -e /tmp/test-r-file
(finished: r - remove single file, in 0.01s)
subtest: r - remove with glob pattern
machine: succeed: touch /tmp/glob-test-1.tmp /tmp/glob-test-2.tmp /tmp/glob-keep.txt
machine: succeed: echo 'r /tmp/glob-test-*.tmp' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --remove /tmp/test.conf
machine: fail: test -e /tmp/glob-test-1.tmp
machine: fail: test -e /tmp/glob-test-2.tmp
machine: succeed: test -e /tmp/glob-keep.txt
(finished: r - remove with glob pattern, in 0.01s)
subtest: r - no error if file doesn't exist
machine: fail: test -e /tmp/nonexistent-file
machine: succeed: echo 'r /tmp/nonexistent-file' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --remove /tmp/test.conf
(finished: r - no error if file doesn't exist, in 0.005s)
subtest: R - recursive removal
machine: succeed: mkdir -p /tmp/test-R/a/b/c
machine: succeed: touch /tmp/test-R/file1 /tmp/test-R/a/file2 /tmp/test-R/a/b/c/file3
machine: succeed: echo 'R /tmp/test-R' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --remove /tmp/test.conf
machine: fail: test -e /tmp/test-R
(finished: R - recursive removal, in 0.016s)
subtest: clean - removes files older than age
machine: succeed: mkdir -p /tmp/test-age
machine: succeed: touch /tmp/test-age/old-file
machine: succeed: echo 'd /tmp/test-age 0755 root root 1d' > /tmp/test.conf
machine: succeed: NO_FAKE_STAT=1 faketime '+2 days' /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --clean /tmp/test.conf
machine: fail: test -f /tmp/test-age/old-file
machine: succeed: touch /tmp/test-age/new-file
machine: succeed: test -f /tmp/test-age/new-file
(finished: clean - removes files older than age, in 0.03s)
subtest: clean - keeps files newer than age
machine: succeed: mkdir -p /tmp/test-age-keep
machine: succeed: touch /tmp/test-age-keep/recent-file
machine: succeed: echo 'd /tmp/test-age-keep 0755 root root 1d' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --clean /tmp/test.conf
machine: succeed: test -f /tmp/test-age-keep/recent-file
(finished: clean - keeps files newer than age, in 0.014s)
subtest: clean - age suffix 's' (seconds)
machine: succeed: mkdir -p /tmp/test-age-s
machine: succeed: touch /tmp/test-age-s/old
machine: succeed: echo 'd /tmp/test-age-s 0755 root root 60s' > /tmp/test.conf
machine: succeed: NO_FAKE_STAT=1 faketime '+2 minutes' /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --clean /tmp/test.conf
machine: fail: test -f /tmp/test-age-s/old
(finished: clean - age suffix 's' (seconds), in 0.022s)
subtest: clean - age suffix 'm' (minutes)
machine: succeed: mkdir -p /tmp/test-age-m
machine: succeed: touch /tmp/test-age-m/old
machine: succeed: echo 'd /tmp/test-age-m 0755 root root 5m' > /tmp/test.conf
machine: succeed: NO_FAKE_STAT=1 faketime '+10 minutes' /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --clean /tmp/test.conf
machine: fail: test -f /tmp/test-age-m/old
(finished: clean - age suffix 'm' (minutes), in 0.02s)
subtest: clean - age suffix 'h' (hours)
machine: succeed: mkdir -p /tmp/test-age-h
machine: succeed: touch /tmp/test-age-h/old
machine: succeed: echo 'd /tmp/test-age-h 0755 root root 2h' > /tmp/test.conf
machine: succeed: NO_FAKE_STAT=1 faketime '+3 hours' /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --clean /tmp/test.conf
machine: fail: test -f /tmp/test-age-h/old
(finished: clean - age suffix 'h' (hours), in 0.021s)
subtest: clean - age suffix 'w' (weeks)
machine: succeed: mkdir -p /tmp/test-age-w
machine: succeed: touch /tmp/test-age-w/old
machine: succeed: echo 'd /tmp/test-age-w 0755 root root 1w' > /tmp/test.conf
machine: succeed: NO_FAKE_STAT=1 faketime '+2 weeks' /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --clean /tmp/test.conf
machine: fail: test -f /tmp/test-age-w/old
(finished: clean - age suffix 'w' (weeks), in 0.019s)
subtest: clean - age '-' means no cleanup
machine: succeed: mkdir -p /tmp/test-age-none
machine: succeed: touch /tmp/test-age-none/ancient
machine: succeed: echo 'd /tmp/test-age-none 0755 root root -' > /tmp/test.conf
machine: succeed: NO_FAKE_STAT=1 faketime '+1 year' /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --clean /tmp/test.conf
machine: succeed: test -f /tmp/test-age-none/ancient
(finished: clean - age '-' means no cleanup, in 0.02s)
subtest: clean - age '0' means no cleanup
machine: succeed: mkdir -p /tmp/test-age-zero
machine: succeed: touch /tmp/test-age-zero/ancient
machine: succeed: echo 'd /tmp/test-age-zero 0755 root root 0' > /tmp/test.conf
machine: succeed: NO_FAKE_STAT=1 faketime '+1 year' /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --clean /tmp/test.conf
machine: succeed: test -f /tmp/test-age-zero/ancient
(finished: clean - age '0' means no cleanup, in 0.022s)
subtest: clean - recursive cleanup
machine: succeed: mkdir -p /tmp/test-age-recursive/sub1/sub2
machine: succeed: touch /tmp/test-age-recursive/root.txt
machine: succeed: touch /tmp/test-age-recursive/sub1/mid.txt
machine: succeed: touch /tmp/test-age-recursive/sub1/sub2/deep.txt
machine: succeed: echo 'd /tmp/test-age-recursive 0755 root root 1d' > /tmp/test.conf
machine: succeed: NO_FAKE_STAT=1 faketime '+2 days' /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --clean /tmp/test.conf
machine: fail: test -f /tmp/test-age-recursive/root.txt
machine: fail: test -f /tmp/test-age-recursive/sub1/mid.txt
machine: fail: test -f /tmp/test-age-recursive/sub1/sub2/deep.txt
(finished: clean - recursive cleanup, in 0.037s)
subtest: clean - D type also cleans
machine: succeed: mkdir -p /tmp/test-D-clean
machine: succeed: touch /tmp/test-D-clean/old
machine: succeed: echo 'D /tmp/test-D-clean 0755 root root 1d' > /tmp/test.conf
machine: succeed: NO_FAKE_STAT=1 faketime '+2 days' /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --clean /tmp/test.conf
machine: fail: test -f /tmp/test-D-clean/old
machine: succeed: test -d /tmp/test-D-clean
(finished: clean - D type also cleans, in 0.027s)
subtest: clean - e type cleans matching directories
machine: succeed: mkdir -p /tmp/test-e-clean
machine: succeed: touch /tmp/test-e-clean/old
machine: succeed: echo 'e /tmp/test-e-clean 0755 root root 1d' > /tmp/test.conf
machine: succeed: NO_FAKE_STAT=1 faketime '+2 days' /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --clean /tmp/test.conf
machine: fail: test -f /tmp/test-e-clean/old
(finished: clean - e type cleans matching directories, in 0.028s)
subtest: clean - does not remove directory root itself
machine: succeed: mkdir -p /tmp/test-clean-root
machine: succeed: touch /tmp/test-clean-root/file
machine: succeed: echo 'd /tmp/test-clean-root 0755 root root 1d' > /tmp/test.conf
machine: succeed: NO_FAKE_STAT=1 faketime '+2 days' /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --clean /tmp/test.conf
machine: succeed: test -d /tmp/test-clean-root
(finished: clean - does not remove directory root itself, in 0.033s)
subtest: w - write to existing file
machine: succeed: touch /tmp/test-w
machine: succeed: echo 'w /tmp/test-w - - - - content' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: cat /tmp/test-w
(finished: w - write to existing file, in 0.012s)
subtest: w+ - append to file
machine: succeed: echo 'line1' > /tmp/test-wplus
machine: succeed: echo 'w+ /tmp/test-wplus - - - - line2' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: cat /tmp/test-wplus
(finished: w+ - append to file, in 0.008s)
subtest: p - create FIFO
machine: succeed: echo 'p /tmp/test-fifo 0644 root root -' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: test -p /tmp/test-fifo
(finished: p - create FIFO, in 0.005s)
subtest: combined --create --remove --clean
machine: succeed: mkdir -p /tmp/test-combined
machine: succeed: touch /tmp/test-combined/old
machine: succeed: echo 'd /tmp/test-combined 0755 root root 1d' > /tmp/test.conf
machine: succeed: NO_FAKE_STAT=1 faketime '+2 days' /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create --remove --clean /tmp/test.conf
machine: succeed: test -d /tmp/test-combined
machine: fail: test -f /tmp/test-combined/old
(finished: combined --create --remove --clean, in 0.018s)
subtest: idempotency - running create twice is safe
machine: succeed: echo 'd /tmp/test-idem 0755 root root -' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: test -d /tmp/test-idem
(finished: idempotency - running create twice is safe, in 0.005s)
subtest: idempotency - file with content
machine: succeed: echo 'f /tmp/test-idem-file 0644 root root - test' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: cat /tmp/test-idem-file
(finished: idempotency - file with content, in 0.01s)
subtest: escape - newline in content
machine: succeed: echo 'f /tmp/test-escape-n 0644 root root - line1\nline2' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: cat /tmp/test-escape-n
(finished: escape - newline in content, in 0.008s)
subtest: escape - tab in content
machine: succeed: echo 'f /tmp/test-escape-t 0644 root root - col1\tcol2' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: cat /tmp/test-escape-t
(finished: escape - tab in content, in 0.009s)
subtest: escape - hex in content
machine: succeed: echo 'f /tmp/test-escape-hex 0644 root root - \x41\x42\x43' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: cat /tmp/test-escape-hex
(finished: escape - hex in content, in 0.009s)
subtest: escape - octal in content
machine: succeed: echo 'f /tmp/test-escape-oct 0644 root root - \101\102\103' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: cat /tmp/test-escape-oct
(finished: escape - octal in content, in 0.009s)
subtest: escape - backslash in content
machine: succeed: echo 'f /tmp/test-escape-bs 0644 root root - back\\slash' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: cat /tmp/test-escape-bs
(finished: escape - backslash in content, in 0.007s)
subtest: glob - r with wildcard pattern
machine: succeed: mkdir -p /tmp/glob-r-test
machine: succeed: touch /tmp/glob-r-test/file1.tmp /tmp/glob-r-test/file2.tmp /tmp/glob-r-test/keep.txt
machine: succeed: echo 'r /tmp/glob-r-test/*.tmp' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --remove /tmp/test.conf
machine: fail: test -f /tmp/glob-r-test/file1.tmp
machine: fail: test -f /tmp/glob-r-test/file2.tmp
machine: succeed: test -f /tmp/glob-r-test/keep.txt
(finished: glob - r with wildcard pattern, in 0.015s)
subtest: glob - w writes to multiple matching files
machine: succeed: mkdir -p /tmp/glob-w-test
machine: succeed: touch /tmp/glob-w-test/file1.txt /tmp/glob-w-test/file2.txt
machine: succeed: echo 'w /tmp/glob-w-test/*.txt - - - - glob-content' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: cat /tmp/glob-w-test/file1.txt
machine: succeed: cat /tmp/glob-w-test/file2.txt
(finished: glob - w writes to multiple matching files, in 0.024s)
subtest: e - adjust existing directory permissions
machine: succeed: mkdir -p /tmp/test-e-adjust
machine: succeed: chmod 700 /tmp/test-e-adjust
machine: succeed: stat -c %a /tmp/test-e-adjust
machine: succeed: echo 'e /tmp/test-e-adjust 0755 root root -' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: stat -c %a /tmp/test-e-adjust
(finished: e - adjust existing directory permissions, in 0.024s)
subtest: e - does not create non-existent directory
machine: fail: test -d /tmp/test-e-nonexistent
machine: succeed: echo 'e /tmp/test-e-nonexistent 0755 root root -' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: fail: test -d /tmp/test-e-nonexistent
(finished: e - does not create non-existent directory, in 0.004s)
subtest: e - with glob pattern
machine: succeed: mkdir -p /tmp/test-e-glob1 /tmp/test-e-glob2
machine: succeed: chmod 700 /tmp/test-e-glob1 /tmp/test-e-glob2
machine: succeed: echo 'e /tmp/test-e-glob* 0755 root root -' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: stat -c %a /tmp/test-e-glob1
machine: succeed: stat -c %a /tmp/test-e-glob2
(finished: e - with glob pattern, in 0.025s)
subtest: r - removal order: parent before child
machine: succeed: mkdir -p /tmp/test-order/subdir
machine: succeed: touch /tmp/test-order/subdir/file
machine: succeed: printf 'R /tmp/test-order\nr /tmp/test-order/subdir/file\n' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --remove /tmp/test.conf
machine: fail: test -e /tmp/test-order
(finished: r - removal order: parent before child, in 0.013s)
subtest: r - removal order: child before parent
machine: succeed: mkdir -p /tmp/test-order2/subdir
machine: succeed: touch /tmp/test-order2/subdir/file
machine: succeed: printf 'r /tmp/test-order2/subdir/file\nR /tmp/test-order2\n' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --remove /tmp/test.conf
machine: fail: test -e /tmp/test-order2
(finished: r - removal order: child before parent, in 0.018s)
subtest: p+ - force replace regular file with FIFO
machine: succeed: echo 'blocker' > /tmp/test-fifo-replace
machine: succeed: test -f /tmp/test-fifo-replace
machine: fail: test -p /tmp/test-fifo-replace
machine: succeed: echo 'p+ /tmp/test-fifo-replace 0644 root root -' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: test -p /tmp/test-fifo-replace
(finished: p+ - force replace regular file with FIFO, in 0.007s)
subtest: L - relative symlink target
machine: succeed: mkdir -p /tmp/test-link-rel
machine: succeed: touch /tmp/test-link-rel/target
machine: succeed: echo 'L /tmp/test-link-rel/link - - - - target' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: test -L /tmp/test-link-rel/link
machine: succeed: test -e /tmp/test-link-rel/link
(finished: L - relative symlink target, in 0.022s)
subtest: L+ - replace directory with symlink
machine: succeed: mkdir -p /tmp/test-link-dir
machine: succeed: touch /tmp/test-link-dir/file-inside
machine: succeed: test -d /tmp/test-link-dir
machine: succeed: echo 'L+ /tmp/test-link-dir - - - - /tmp' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: test -L /tmp/test-link-dir
(finished: L+ - replace directory with symlink, in 0.019s)
subtest: multiple config files on command line
machine: succeed: echo 'd /tmp/multi-test1 0755 root root -' > /tmp/test1.conf
machine: succeed: echo 'd /tmp/multi-test2 0755 root root -' > /tmp/test2.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test1.conf /tmp/test2.conf
machine: succeed: test -d /tmp/multi-test1
machine: succeed: test -d /tmp/multi-test2
(finished: multiple config files on command line, in 0.005s)
subtest: clean - empty directory is not removed
machine: succeed: mkdir -p /tmp/test-clean-empty
machine: succeed: echo 'd /tmp/test-clean-empty 0755 root root 1s' > /tmp/test.conf
machine: succeed: NO_FAKE_STAT=1 faketime '+2 seconds' /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --clean /tmp/test.conf
machine: succeed: test -d /tmp/test-clean-empty
(finished: clean - empty directory is not removed, in 0.014s)
subtest: clean - nested old directories
machine: succeed: mkdir -p /tmp/test-clean-nested/a/b
machine: succeed: touch /tmp/test-clean-nested/a/b/file
machine: succeed: echo 'd /tmp/test-clean-nested 0755 root root 1d' > /tmp/test.conf
machine: succeed: NO_FAKE_STAT=1 faketime '+2 days' /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --clean /tmp/test.conf
machine: fail: test -f /tmp/test-clean-nested/a/b/file
machine: succeed: test -d /tmp/test-clean-nested
(finished: clean - nested old directories, in 0.018s)
subtest: d - create directory with specific user:group
machine: succeed: echo 'd /tmp/test-owner-d 0755 testuser testgroup -' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: test -d /tmp/test-owner-d
machine: succeed: stat -c %U:%G /tmp/test-owner-d
(finished: d - create directory with specific user:group, in 0.011s)
subtest: f - create file with specific user:group
machine: succeed: echo 'f /tmp/test-owner-f 0644 testuser testgroup - owned-content' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: test -f /tmp/test-owner-f
machine: succeed: stat -c %U:%G /tmp/test-owner-f
(finished: f - create file with specific user:group, in 0.009s)
subtest: d - user by name, group defaults to root
machine: succeed: echo 'd /tmp/test-owner-useronly 0755 testuser - -' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: stat -c %U:%G /tmp/test-owner-useronly
(finished: d - user by name, group defaults to root, in 0.009s)
subtest: d - defaults to root:root with dash
machine: succeed: echo 'd /tmp/test-owner-dash 0755 - - -' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: stat -c %U:%G /tmp/test-owner-dash
(finished: d - defaults to root:root with dash, in 0.011s)
subtest: e - adjust ownership on existing directory
machine: succeed: mkdir -p /tmp/test-owner-e
machine: succeed: chown root:root /tmp/test-owner-e
machine: succeed: stat -c %U:%G /tmp/test-owner-e
machine: succeed: echo 'e /tmp/test-owner-e 0755 testuser testgroup -' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: stat -c %U:%G /tmp/test-owner-e
(finished: e - adjust ownership on existing directory, in 0.031s)
subtest: ownership - numeric uid:gid
machine: succeed: echo 'd /tmp/test-owner-numeric 0755 1234 5678 -' > /tmp/test.conf
machine: succeed: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles --create /tmp/test.conf
machine: succeed: stat -c %u /tmp/test-owner-numeric
machine: succeed: stat -c %g /tmp/test-owner-numeric
(finished: ownership - numeric uid:gid, in 0.025s)
subtest: error - requires at least one action flag
machine: succeed: echo 'd /tmp/foo 0755 root root -' > /tmp/test.conf
machine: fail: /nix/store/fzc72p7cdyd0f3c46lfwqxif8zpcf1cl-finit-4.16/libexec/finit/tmpfiles /tmp/test.conf
(finished: error - requires at least one action flag, in 0.004s)
subtest: shutdown
machine: initiating shutdown
machine: waitForShutdown
machine: VM has shut down

Rename the command-line flag variables to be more descriptive:

  c_flag -> create_flag
  r_flag -> remove_flag

This improves code readability.
Add support for the --clean (-C) flag to remove files and directories
older than the age specified in tmpfiles.d configuration entries.

The age field (6th column) in tmpfiles.d entries can now be used with
'd', 'D', and 'e' type entries to clean up old files.  Supported time
suffixes are: s (seconds), m (minutes), h (hours), d (days), w (weeks).

Example configuration:
    d /tmp/cache 0755 root root 10d

When run with --clean, files in /tmp/cache older than 10 days will be
removed.  The directory itself is preserved.

Uses a conservative cleanup approach matching systemd-tmpfiles:
 - Files: kept if ANY of atime, ctime, mtime is recent
 - Directories: kept if ANY of atime, mtime is recent (ctime excluded
   because cleanup itself updates directory ctime)

A value of "-" or "0" for age disables cleanup for that entry.

Note: x/X exclusion patterns are recognized but not yet implemented.
Allow specifying one or more configuration files as command line
arguments instead of always processing all files in the standard
tmpfiles.d directories.

This enables targeted operations on specific config files:

    tmpfiles --create /etc/tmpfiles.d/myapp.conf
    tmpfiles --clean /tmp/test.conf /tmp/other.conf

When no config files are specified, the existing behavior of
processing all *.conf files in the standard directories is preserved.

Also refactors file processing into a helper function to reduce
code duplication.
The L+ type should replace existing entries with a symlink. Previously,
rmrf() was always called which is only appropriate for directories.
Now we check if the path is a directory first, and use erase() for
files and symlinks.
Add parse_uid() and parse_gid() helper functions that support both
numeric IDs and name lookups. Update the d/D directory creation
handlers to use these new functions.

This allows config files to specify ownership using numeric UIDs and
GIDs instead of only usernames and group names, matching systemd-tmpfiles
behavior.
According to tmpfiles.d(5), the 'e' type adjusts the mode and ownership
of existing paths but should not create them. Previously, mksubsys()
was used which could create directories.

Now we explicitly check if the path is an existing directory before
adjusting its permissions.
When f or F types write content to a file, the mode and ownership
specified in the config should be applied. Previously, ownership was
only applied when create() was used (i.e., when no argument was
specified).

Now we explicitly apply mode and ownership after writing content to
the file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant