mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
tmpfiles: keep the owner of an existing path when none is given
An entry without a user or group, or with "-", made root the owner of
an existing directory or file:
mkdir -p /tmp/t && chown daemon:daemon /tmp/t
echo 'd /tmp/t' > t.conf
tmpfiles --create t.conf
stat -c %U:%G /tmp/t
This gave root:root. A missing field was read as "root" when parsing
the entry, the same as if it had been written out. tmpfiles.d(5)
only adjusts the owner when the entry gives one.
A missing user or group is now -1, and fdperm() looks at the two ids
separately, so "d /tmp/t - - sys" changes the group and keeps the
owner. mksubsys() and the service directories used uid -1 to skip
the chown altogether, they now pass -1 for the group as well.
Issue #523
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
5 files changed
+41
-35
No files matched your search
+10
-8
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
# Verify that tmpfiles leaves the mode of an existing directory alone
|
||||
# when the entry does not give one, issue #523
|
||||
# Verify that tmpfiles leaves the mode and owner of an existing
|
||||
# directory alone when the entry does not give them, issue #523
|
||||
set -eu
|
||||
|
||||
TEST_DIR=$(dirname "$0")
|
||||
@@ -30,10 +30,12 @@ say 'A new directory gets the default mode and owner'
|
||||
assert_perm "d $DIR" 755 root:root
|
||||
|
||||
sep
|
||||
say 'An existing directory keeps its mode when the entry gives none'
|
||||
run "chmod 1777 $DIR"
|
||||
assert_perm "d $DIR" 1777 root:root
|
||||
assert_perm "d $DIR - - -" 1777 root:root
|
||||
assert_perm "d $DIR 0750" 750 root:root
|
||||
assert_perm "e $DIR" 750 root:root
|
||||
say 'An existing directory keeps what the entry does not give'
|
||||
run "chmod 1777 $DIR; chown daemon:daemon $DIR"
|
||||
assert_perm "d $DIR" 1777 daemon:daemon
|
||||
assert_perm "d $DIR - - -" 1777 daemon:daemon
|
||||
assert_perm "d $DIR 0750" 750 daemon:daemon
|
||||
assert_perm "d $DIR - bin" 750 bin:daemon
|
||||
assert_perm "d $DIR - - sys" 750 bin:sys
|
||||
assert_perm "e $DIR" 750 bin:sys
|
||||
assert_perm "d $DIR 1777 root root" 1777 root:root
|
||||
Reference in new issue
Block a user