Skip to content

Commit 3ef338e

Browse files
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 a6d1843 commit 3ef338e

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

audisp/audispd.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,7 @@ static void load_plugin_conf(conf_llist *plugin)
123123
plugin_conf_t config;
124124
const char *ext, *reason = NULL;
125125

126-
if (e->d_type != DT_REG)
127-
reason = "not a regular file";
128-
else if (e->d_name[0] == '.')
126+
if (e->d_name[0] == '.')
129127
reason = "hidden file";
130128
else if (count_dots(e->d_name) > 1)
131129
reason = "backup file";

0 commit comments

Comments
 (0)