#!/bin/sh # 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") 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" } 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." 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 <