-
Notifications
You must be signed in to change notification settings - Fork 232
Description
I started running the audit-testsuite against the NixOS auditd module to try and make stuff work properly. Currently, our audit runs but is broken in a couple subtle ways. Particularly, it does load the config at Edit: we do pass /etc/audit/auditd.conf, despite it being a symlink!-l, this is intended.
One thing i found:
vm-test-run-auditd> machine # Error opening config file (Too many levels of symbolic links)
vm-test-run-auditd> machine # NOTE - using built-in end_of_event_timeout: 2
vm-test-run-auditd> machine # NOTE - using built-in logs: /var/log/audit/audit.log
I suspect part of the issue is in here:
audit-userspace/audisp/plugins/remote/remote-config.c
Lines 244 to 245 in 2b7c23f
| mode = O_RDONLY; | |
| rc = open(file, mode); |
| if (fstat(fd, &st) < 0) { |
| if (!S_ISREG(st.st_mode)) { |
There is no
O_NOFOLLOW, and the stat syscall is fstat, not lstat, which means it doesn't actually check whether the config file is a symlink.
However, the error code (Too many levels of symbolic links) comes from the kernel:
https://github.com/linux-audit/audit-kernel/blob/729b4babd69517766ae39e21902caa810625e247/net/9p/error.c#L80
This suggests something is actually using O_NOFOLLOW, see the open manual page:
O_NOFOLLOW If path names a symbolic link, fail and set errno to [ELOOP].
I'll either have to patch the kernel module, or patch the userspace audit daemon to pass an absolute path to the kernel. Not sure which of the two options would be better.
Edit: Needs set_allow_links in the ausearch tool to correctly load config, or else O_NOFOLLOW is added.
After #467, plugins from symlinks works. Config from symlinks not working is a little surprising, because until i ran the kernel test suite this never actually complained.