Skip to content

Commit 8050193

Browse files
committed
fagenrules: Validate new compiled rules
When `fagenrules` was run with invalid rules it broke `fapolicyd` startup, see below. # fapolicyd 04/17/2026 13:52:30 [ INFO ]: Can handle 524288 file descriptors 04/17/2026 13:52:30 [ INFO ]: Ruleset identity: 8b5126cc76e5372274fdf0024d2d13c274a52cda6611f15a577742bbace2dc99 04/17/2026 13:52:30 [ NOTICE ]: SHA256HASH object name is deprecated; use FILE_HASH instead # killall fapolicyd # echo 'a b c' > /etc/fapolicyd/rules.d/99.rules # fagenrules # fapolicyd 04/17/2026 13:53:35 [ INFO ]: Can handle 524288 file descriptors 04/17/2026 13:53:35 [ INFO ]: Ruleset identity: 308521d067909a4e66a429c5fafaf864cfe4071b00ba40ac24d63f2deb7ef36f 04/17/2026 13:53:35 [ NOTICE ]: SHA256HASH object name is deprecated; use FILE_HASH instead 04/17/2026 13:53:35 [ ERROR ]: Invalid decision (a) in line 15 With this change, `fapolicyd-cli --check-rules` is used before $TmpRules are renamed to /etc/fapolicyd/compiled.rules in order to prevent this behaviour. Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
1 parent b76d6c4 commit 8050193

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

init/fagenrules

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ END {
9797
for (i = 0; i < rest; i++) { printf "%s\n", rules[i]; }
9898
}' >> "${TmpRules}"
9999

100+
fapolicyd-cli --check-rules "${TmpRules}"
101+
err=$?
102+
if [ $err -ne 0 ]; then
103+
echo "Rules file content:"
104+
cat -n "${TmpRules}"
105+
rm -f "${TmpRules}"
106+
exit $err
107+
fi
108+
100109
# If the same then quit
101110
cmp -s "${TmpRules}" ${DestinationFile} > /dev/null 2>&1
102111
if [ $? -eq 0 ]; then

0 commit comments

Comments
 (0)