-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
auditd service fails to start because augenrules says rules have not changed #355
Comments
When augenrules says no change, it means that the rules on disk have not changed since the last time it compiled the rules from the pieces. Next it tries to load the rules. If you have -e 2, that is likely the reason why it fails. That said, if rules are loaded and they have not changed, it should not be a failure. Things are good. I'll look to see how we can change the code of augenrules to avoid failing when the rules are immutable or not changed. Auditd should still start no matter what happened in the audit-rules.service. |
Thanks for your fast answer. Maybe the solution would be to replace |
Commit 62b30cc should solve the problem. This has been there a long time unnoticed. I'll have another look at the systemd man pages to see if Requires is correct. There is a firm relationship between the 2 services that I really want enforced. |
Mmmh, I don't know much about auditd and its ecosystem, so I might be wrong here, but that patch feels wrong to me. How am I supposed to update the rules now ? The way I see it, immutable rules means you cannot alter the behavior at runtime, but you should still be able to edit them, and they will be enforced the next time the system boots. Immutable rules should be (AFAIU) a kernel thing only, not something userland utilities should check. Unless the rules are recompiled at boot without using augenrules ? |
I feel like the proper fix for this issue would be to replace these two lines: audit-userspace/init.d/augenrules Lines 121 to 122 in 62b30cc
with Why should the script call |
audit-userspace/init.d/augenrules Lines 117 to 127 in 62b30cc
I believe it should be: cmp -s "${TmpRules}" ${DestinationFile} > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "$0: No change"
rm -f "${TmpRules}"
exit 0
elif [ $OnlyCheck -eq 1 ] ; then
echo "$0: Rules have changed and should be updated"
rm -f "${TmpRules}"
exit 0
fi |
And commit a3d436f will allow checking in immutable mode. |
The reason it has to call try_load is because the rules need to get loaded. Normally the rules never change but they need to get into the kernel. Maybe troubleshooting has been done and the admin wants to get back to the normal baseline. For immutable rules, there is the system boot where nothing is loaded yet. Immutable rules can only be loaded at boot. They are used to prevent someone from modifying rules that would catch a specific action. I moved the exit so that at least a simple status message can be emitted before exiting. Please give the current file a test. I think it does what you need it to do. |
At first the script didn't work, the following error is emitted:
I replaced: if test $(auditctl -s | awk '$1 == "enabled" { print $2 }') == "2" With: if [ "$(auditctl -s | awk '$1 == "enabled" { print $2 }')" = "2" ] I also added quotes around the subshell command to prevent word globbing, as advised by shellcheck (even though that's unlikely considering you are telling awk to print a single token, but better be warning-free right?) Otherwise it works fine, thanks a lot ! I was a bit worried that it wouldn't be picked up by the kernel (next reboot) if While I'm here, shellcheck warns about the signal trap 13 and says that the name of the signal should be used instead. |
Strange, I don't get a warning on either F38 or F40 at line 50. How are you getting that? What version of bash do you have? The "test" and "[" commands are almost identical. |
What do you mean by F38 and F40 ?
I just ran the script like so:
Which uses the shebang defined at the top of the file.
The |
maybe you have e.g. to replace echo with printf if you wand to be POSIX compliant |
F38 and F40 are abbreviations for "Fedora 38" and "Fedora 40". They use bash 5.2.26 as the shell. There is no fix_augenrules. Fedora uses augenrules as shipped in this repo. Since you are on a distro using dash as the shell, that probably explains why you are seeing an issue where I'm not seeing a problem. Even shellcheck doesn't complain about line 50 not being posix compliant. It mentions trapping signals by number. I wanted to understand how you were getting a warning before I make any changes. I'll see how I can reproduce it so I know the fix is right. |
Alright, well I'm running Arch.
That's just the name I gave to the script, I copy/pasted it from this repo.
I'm not sure you got my point, my point is that at the beginning of the
Indeed, it's my bad, it's not shellcheck giving me a warning, it's bashls, my editor LSP for shell scripts: Which is a warning, but not a POSIX compliance issue. But that's not the main issue, the main issue is that you are not using So you can use the following if you want to, with a single if test "$(auditctl -s | awk '$1 == "enabled" { print $2 }')" = "2"; then But I advise against using if [ "$(auditctl -s | awk '$1 == "enabled" { print $2 }')" = "2" ] But really that's fine, use test if you want to, but please replace |
OK. I think it's all fixed now. Thanks for reporting the issue.
Never heard of it. But now that I have, it looks useful. |
Thanks a lot ! Have a nice week-end |
Hey, I'm facing an issue which is I believe related to
audit-rules.service
.I'm not sure what the initial trigger for this bug is but I believe it is due to the fact that auditd failed to start at boot because the kernel ran out of buffer space:
So I tried to start the
auditd.service
again usingsystemctl start auditd
, and now it fails with:The only dependency
auditd.service
has isaudit-rules.service
according to:audit-userspace/init.d/auditd.service
Line 6 in f1769e4
And indeed if I look at
audit-rules
logs I can see the following:augenrules
reports that rules haven't changed:/usr/bin/augenrules: No change
which is fine, right ? Still, it exits with code 1, resulting in a service failure.Might be worth mentioning that I set my rules to be immutable using
-e 2
.I'm not sure what is the correct way to fix this issue, should
augenrules
not exit with status 1 if it detects that rules haven't changed ? What does it even meanNo change
? Is it a "I was unable to change the rules" or is it a "rules are already set" ?Or should the systemd service not fail if status 1 is returned ?
I'm using auditd
4.0-1
on Linux hardened6.7.3
.Let me know if you need any additional info, cheers.
The text was updated successfully, but these errors were encountered: