mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
tmpfiles: add the t and T entries, extended attributes
tmpfiles.d(5) has t to set extended attributes on a path, and T for
the path and everything below it:
t /srv/www - - - - user.mime_type=text/html
tmpfiles skipped them as unsupported.
Add both. The argument is one or more NAME=VALUE with space between,
a value with space in it goes in quotes. They are set with
lsetxattr(), a link is never followed.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
5 files changed
+170
-2
No files matched your search
@@ -83,6 +83,7 @@ EXTRA_DIST += signal-service.sh
|
||||
EXTRA_DIST += testserv.sh
|
||||
EXTRA_DIST += tmpfiles-acl.sh
|
||||
EXTRA_DIST += tmpfiles-arg.sh
|
||||
EXTRA_DIST += tmpfiles-attr.sh
|
||||
EXTRA_DIST += tmpfiles-perm.sh
|
||||
EXTRA_DIST += tmpfiles-boot.sh
|
||||
EXTRA_DIST += tmpfiles-clean.sh
|
||||
@@ -168,6 +169,7 @@ if TESTSERV
|
||||
TESTS += testserv.sh
|
||||
TESTS += tmpfiles-acl.sh
|
||||
TESTS += tmpfiles-arg.sh
|
||||
TESTS += tmpfiles-attr.sh
|
||||
TESTS += tmpfiles-perm.sh
|
||||
TESTS += tmpfiles-boot.sh
|
||||
TESTS += tmpfiles-clean.sh
|
||||
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
#!/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.
|
||||
set -eu
|
||||
|
||||
TEST_DIR=$(dirname "$0")
|
||||
|
||||
DIR=/attr-test
|
||||
CONF=/tmp/attr.conf
|
||||
|
||||
tmpfiles()
|
||||
{
|
||||
run "cat > $CONF"
|
||||
run "/libexec/finit/tmpfiles --create $CONF"
|
||||
}
|
||||
|
||||
# The sysroot has setfattr but no getfattr, removing one that is not
|
||||
# set fails
|
||||
assert_xattr()
|
||||
{
|
||||
assert "$1 has $2" "$(texec sh -c "setfattr -x $2 $1 && echo yes || echo no")" = "yes"
|
||||
}
|
||||
|
||||
test_teardown()
|
||||
{
|
||||
say "Running test teardown."
|
||||
run "rm -rf $DIR $CONF"
|
||||
}
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. "$TEST_DIR/lib/setup.sh"
|
||||
|
||||
run "mkdir -p $DIR/tree/sub; touch $DIR/file $DIR/tree/sub/file"
|
||||
|
||||
sep
|
||||
say 't sets extended attributes, T on everything below the path too'
|
||||
tmpfiles <<CONF
|
||||
t $DIR/file - - - - user.one=1 user.two="two words"
|
||||
T $DIR/tree - - - - user.tree=yes
|
||||
CONF
|
||||
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
|
||||
Reference in new issue
Block a user