Skip to content

can't set /run directory: neither $RUNTIME_DIRECTORY or --runstatedir are respected #490

@LordGrimmauld

Description

@LordGrimmauld

systemd services support setting a runtime directory via RuntimeDirectory, see systemd.exec(5). For this, it expects services to respect the $RUNTIME_DIRECTORY environment variable.

Currently, auditd hardcodes /var/run in various places, e.g.:

#define DEFAULT_PATH "/var/run/audispd_events"

#define STATE_REPORT "/var/run/auditd.state"

static const char *pidfile = "/var/run/auditd.pid";
static const char *state_file = "/var/run/auditd.state";

l = fopen("/var/run/audisp-ids.log", "wt");

This is fine if /var/run actually exists. On some systems (typically modern systemd systems), such as NixOS, /run is the actual runtime directory. /var/run -> /run is typically a symlink created by systemd-tmpfiles. This is fine as long as auditd starts after the systemd-tmpfiles-setup.service service. However, omitting this After= will result in various things failing. I discovered this while reviewing a cleanup PR to our audit setup (NixOS/nixpkgs#429553 (comment)). Such a dependency in the service is also not great, as it restricts how early in the boot process audit can start logging things.

Further, auditd polluting the global /run with files is not ideal. I'd prefer auditd using $RUNTIME_DIRECTORY/auditd/<...> for its various files. And while some of the audit files such as the audispd_events socket can be trivially moved using the config file, things like the pid file can not.

I understand this is a somewhat big change to request. I also understand $RUNTIME_DIRECTORY might not be set, especially on non-systemd setups, in which case it is probably fair to assume /var/run as a default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions