tmpfiles: keep the mode of an existing directory when none is given

A d entry without a mode reset an existing directory to 0755.  On
finix a bare "d /tmp" line took the sticky bit and the write
permission for others off the /tmp mount, so nobody but root could
create files there:

    mkdir -p /tmp/t && chmod 1777 /tmp/t
    echo 'd /tmp/t' > t.conf
    tmpfiles --create t.conf
    stat -c %a /tmp/t

This gave 755.  Commit 3a72d126 made the chmod of an existing
directory work, and it used the 0755 default for a new directory as
the mode to set.

The default is now only for creating the directory.  With no mode in
the entry, dirperm() leaves the mode alone.

Fixes #523

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
(cherry picked from commit 94bdccd2002d8847736743cb31e9b7bd56bdcada)
This commit is contained in:
Joachim Wiberg committed 2026-11-20 17:51:40 +01:00
1 parent 90523404b3
commit 513f47813e
4 files changed
+49 -9

No files matched your search

+2
View File
@@ -65,6 +65,7 @@ EXTRA_DIST += start-stop-sysv.sh
EXTRA_DIST += start-stop-serv.sh
EXTRA_DIST += signal-service.sh
EXTRA_DIST += testserv.sh
EXTRA_DIST += tmpfiles-perm.sh
EXTRA_DIST += unexpected-restart.sh
AM_TESTS_ENVIRONMENT = SYSROOT='$(abs_builddir)/sysroot/';
@@ -115,6 +116,7 @@ TESTS += start-stop-serv.sh
TESTS += signal-service.sh
if TESTSERV
TESTS += testserv.sh
TESTS += tmpfiles-perm.sh
endif
TESTS += unexpected-restart.sh