]> git.ipfire.org Git - thirdparty/systemd.git/commit
tmpfiles: skip redundant label writes to avoid unnecessary timestamp changes
authorNandakumar Raghavan <naraghavan@microsoft.com>
Tue, 7 Apr 2026 06:33:41 +0000 (06:33 +0000)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 8 Apr 2026 13:48:10 +0000 (14:48 +0100)
commit8a8f22f1d8eb52ede2f3597b9e3674182beec2b4
treee05e8da0ec6367cfc085f58f46f4f60490f845f3
parent40d0fb2eb2ded4b87173858887174d49878cdda0
tmpfiles: skip redundant label writes to avoid unnecessary timestamp changes

When systemd-tmpfiles processes a 'z' (relabel) entry, fd_set_perms()
unconditionally calls label_fix_full() even when mode, owner, and group
already match. This causes setfilecon_raw() (SELinux) or xsetxattr() (SMACK)
to write the security label even if it is already correct, which on some
kernels updates the file's timestamps unnecessarily.

Fix this by comparing the current label with the desired label before
writing, and skipping the write when they already match. This is consistent
with how fd_set_perms() already skips chmod/chown when the values are
unchanged.
src/basic/xattr-util.c
src/shared/selinux-util.c
src/shared/smack-util.c