Commit f233955
committed
auditd: support loading plugin configs from symlinks
`auditd` previously did not support loading plugin configurations from
symlinked config files. This is problematic on systems such as NixOS,
which constructs basically the entirety of /etc using symlinks.
I considered why symlinks were not supported, and concluded the reason was
simplicity. While having a symlink point to a writable location would be
insecure, a user putting an insecure symlink to trigger this behavior could
also immediately do worse things.
There also were edge cases if the config file is replaced between the file
type check and the actual read. This is because `load_plugin_conf` uses
path based logic to check whether a file is a regular file or not, and then
asses the file path to `load_pconfig`. This means audispd would already
load symlinked configs if a regular file was replaced by a symlink at
precisely the right time in execution.
`load_pconfig` opens the supplied config file path using `open`. Crucially,
it does not set `O_NOFOLLOW`, meaning `load_pconfig` already supports
loading plugin configs from symlinks. The check in `load_pconfig` also
already uses the file-descriptor based `fstat` call, which mitigates the
replacement problems: file descriptors are stable.
This means, to support symlinks, it is sufficient to remove the check for
regular files from `load_plugin_conf`. This does change internal API: It
now is the responsibility of `load_pconfig` to make sure a plugin config
file is a regular file. This API change is purely internal, neither
`load_pconfig` nor `load_plugin_conf` are part of the public headers.
This change has been tested against auditd 4.0.3 and 4.0.5 in a NixOS VM.
The plugin config files af_unix.conf, au-remote.conf, filter.conf, syslog.conf
all successfully loaded through symlink.1 parent 263414b commit f233955
1 file changed
+1
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
122 | | - | |
123 | | - | |
| 121 | + | |
124 | 122 | | |
125 | 123 | | |
126 | 124 | | |
| |||
0 commit comments