conf-files: make conf-file enumerators provide more detailed information of enumerated files (#38006)

This introduces `struct ConfFile` that stores detailed information of an
enumerated file, and introduces `conf_files_list_full()` and friends
that provide results in `ConfFile`.
Then make udev, hwdb, catalog, and cat-files use the new function and
struct to make them not read files outside of specified root directory.
This commit is contained in:
Yu Watanabe
2025-07-11 13:50:47 +09:00
committed by GitHub
20 changed files with 857 additions and 490 deletions
+11 -7
View File
@@ -132,11 +132,11 @@ assert_0 "${rules_dir}"
# Directory with a loop.
ln -s . "${rules_dir}/loop.rules"
assert_1 "${rules_dir}"
assert_0 "${rules_dir}"
rm "${rules_dir}/loop.rules"
# Empty rules.
touch "${rules_dir}/empty.rules"
# Effectively empty rules.
echo '#' >"${rules_dir}/empty.rules"
assert_0 --root="${workdir}"
: >"${exo}"
assert_0 --root="${workdir}" --no-summary
@@ -315,8 +315,10 @@ if ! getent passwd 12345 >/dev/null; then
test_syntax_error 'OWNER="12345"' "Unknown user '12345', ignoring."
fi
# regular user
test_syntax_error 'OWNER="testuser"' "User 'testuser' is not a system user, ignoring."
test_syntax_error "OWNER=\"$(id -u testuser)\"" "User '$(id -u testuser)' is not a system user, ignoring."
if getent passwd testuser >/dev/null; then
test_syntax_error 'OWNER="testuser"' "User 'testuser' is not a system user, ignoring."
test_syntax_error "OWNER=\"$(id -u testuser)\"" "User '$(id -u testuser)' is not a system user, ignoring."
fi
test_syntax_error 'GROUP{a}="b"' 'Invalid attribute for GROUP.'
test_syntax_error 'GROUP-="b"' 'Invalid operator for GROUP.'
test_syntax_error 'GROUP!="b"' 'Invalid operator for GROUP.'
@@ -345,8 +347,10 @@ if ! getent group 12345 >/dev/null; then
test_syntax_error 'GROUP="12345"' "Unknown group '12345', ignoring."
fi
# regular group
test_syntax_error 'GROUP="testuser"' "Group 'testuser' is not a system group, ignoring."
test_syntax_error "GROUP=\"$(id -g testuser)\"" "Group '$(id -g testuser)' is not a system group, ignoring."
if getent group testuser >/dev/null; then
test_syntax_error 'GROUP="testuser"' "Group 'testuser' is not a system group, ignoring."
test_syntax_error "GROUP=\"$(id -g testuser)\"" "Group '$(id -g testuser)' is not a system group, ignoring."
fi
test_syntax_error 'MODE{a}="b"' 'Invalid attribute for MODE.'
test_syntax_error 'MODE-="b"' 'Invalid operator for MODE.'
test_syntax_error 'MODE!="b"' 'Invalid operator for MODE.'
+1
View File
@@ -313,6 +313,7 @@ if [[ ! -v ASAN_OPTIONS ]]; then
# check that systemd-analyze cat-config paths work in a chroot
mkdir -p /tmp/root
mount --bind / /tmp/root
mount -t proc proc /tmp/root/proc
if mountpoint -q /usr; then
mount --bind /usr /tmp/root/usr
fi