summaryrefslogtreecommitdiffstats
path: root/test/units/TEST-22-TMPFILES.16.sh
blob: 3d3d0c88e7b6d7daa54f52359289937f1f70caba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# Test for conditionalized execute bit ('X' bit)
set -eux
set -o pipefail

# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh

rm -f /tmp/acl_exec
touch /tmp/acl_exec

# No ACL set yet
systemd-tmpfiles --dry-run --create - <<EOF
a /tmp/acl_exec - - - - u:root:rwX
EOF
assert_not_in 'user:root:rw-' "$(getfacl -Ec /tmp/acl_exec)"

systemd-tmpfiles --create - <<EOF
a /tmp/acl_exec - - - - u:root:rwX
EOF
assert_in 'user:root:rw-' "$(getfacl -Ec /tmp/acl_exec)"

# Set another ACL and append
setfacl -m g:root:x /tmp/acl_exec

systemd-tmpfiles --create - <<EOF
a+ /tmp/acl_exec - - - - u:root:rwX
EOF
acl="$(getfacl -Ec /tmp/acl_exec)"
assert_in 'user:root:rwx' "$acl"
assert_in 'group:root:--x' "$acl"

# Reset ACL (no append)
systemd-tmpfiles --create - <<EOF
a /tmp/acl_exec - - - - u:root:rwX
EOF
assert_in 'user:root:rw-' "$(getfacl -Ec /tmp/acl_exec)"

rm -f /tmp/acl_exec