test: tmpfiles: add tests on conditionalized execute bit
This commit is contained in:
@@ -13,6 +13,7 @@ import subprocess
|
||||
import tempfile
|
||||
import pwd
|
||||
import grp
|
||||
from pathlib import Path
|
||||
|
||||
try:
|
||||
from systemd import id128
|
||||
@@ -202,6 +203,27 @@ def test_hard_cleanup(*, user):
|
||||
def test_base64():
|
||||
test_content('f~ {} - - - - UGlmZgpQYWZmClB1ZmYgCg==', "Piff\nPaff\nPuff \n", user=False)
|
||||
|
||||
def test_conditionalized_execute_bit():
|
||||
c = subprocess.run(exe_with_args + ['--version', '|', 'grep', '-F', '+ACL'], shell=True, stdout=subprocess.DEVNULL)
|
||||
if c.returncode != 0:
|
||||
return 0
|
||||
|
||||
d = tempfile.TemporaryDirectory(prefix='test-acl.', dir=temp_dir.name)
|
||||
temp = Path(d.name) / "cond_exec"
|
||||
temp.touch()
|
||||
temp.chmod(0o644)
|
||||
|
||||
test_line(f"a {temp} - - - - u:root:Xwr", user=False, returncode=0)
|
||||
c = subprocess.run(["getfacl", "-Ec", temp],
|
||||
stdout=subprocess.PIPE, check=True, text=True)
|
||||
assert "user:root:rw-" in c.stdout
|
||||
|
||||
temp.chmod(0o755)
|
||||
test_line(f"a+ {temp} - - - - u:root:Xwr,g:root:rX", user=False, returncode=0)
|
||||
c = subprocess.run(["getfacl", "-Ec", temp],
|
||||
stdout=subprocess.PIPE, check=True, text=True)
|
||||
assert "user:root:rwx" in c.stdout and "group:root:r-x" in c.stdout
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_invalids(user=False)
|
||||
test_invalids(user=True)
|
||||
@@ -214,3 +236,5 @@ if __name__ == '__main__':
|
||||
test_hard_cleanup(user=True)
|
||||
|
||||
test_base64()
|
||||
|
||||
test_conditionalized_execute_bit()
|
||||
|
||||
Reference in New Issue
Block a user