mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
tmpfiles: add the h and H entries, file attributes
tmpfiles.d(5) has h to set file attributes, as chattr(1) does, and H
for the path and everything below it:
h /var/log/journal - - - - +C
tmpfiles skipped them as unsupported.
Add both. The argument is the letters chattr(1) has, after a + to
add them, which is the default, a - to remove them, or a = to have
just these set. Only files and directories have such attributes,
anything else is left alone.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
8 files changed
+131
-7
No files matched your search
+29
-2
@@ -1,6 +1,7 @@
|
||||
#!/bin/sh
|
||||
# Verify the t and T entries of tmpfiles, extended attributes. On the
|
||||
# file system of the sysroot, not all of this works on tmpfs.
|
||||
# Verify the t and T entries of tmpfiles, extended attributes, and the
|
||||
# h and H entries, file attributes. On the file system of the sysroot,
|
||||
# not all attributes work on tmpfs.
|
||||
set -eu
|
||||
|
||||
TEST_DIR=$(dirname "$0")
|
||||
@@ -21,6 +22,12 @@ assert_xattr()
|
||||
assert "$1 has $2" "$(texec sh -c "setfattr -x $2 $1 && echo yes || echo no")" = "yes"
|
||||
}
|
||||
|
||||
assert_attr()
|
||||
{
|
||||
assert "Attributes of $1 have $2: $3" \
|
||||
"$(texec sh -c "lsattr -d $1 | cut -d' ' -f1 | grep -q $2 && echo yes || echo no")" = "$3"
|
||||
}
|
||||
|
||||
test_teardown()
|
||||
{
|
||||
say "Running test teardown."
|
||||
@@ -42,3 +49,23 @@ assert_xattr $DIR/file user.one
|
||||
assert_xattr $DIR/file user.two
|
||||
assert_xattr $DIR/tree user.tree
|
||||
assert_xattr $DIR/tree/sub/file user.tree
|
||||
|
||||
sep
|
||||
say 'h sets file attributes, H on everything below the path too'
|
||||
tmpfiles <<CONF
|
||||
h $DIR/file - - - - +dA
|
||||
H $DIR/tree - - - - d
|
||||
CONF
|
||||
assert_attr $DIR/file d yes
|
||||
assert_attr $DIR/file A yes
|
||||
assert_attr $DIR/tree/sub/file d yes
|
||||
|
||||
say 'With - they are taken away, with = only those named are left'
|
||||
tmpfiles <<CONF
|
||||
h $DIR/file - - - - -d
|
||||
H $DIR/tree - - - - =A
|
||||
CONF
|
||||
assert_attr $DIR/file d no
|
||||
assert_attr $DIR/file A yes
|
||||
assert_attr $DIR/tree/sub/file d no
|
||||
assert_attr $DIR/tree/sub/file A yes
|
||||
Reference in new issue
Block a user