2024-09-04 09:59:10 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2017-07-09 18:59:09 +02:00
|
|
|
|
|
|
|
{
|
2024-09-04 09:59:45 +02:00
|
|
|
options.security.auditd.enable = lib.mkEnableOption "the Linux Audit daemon";
|
2017-07-09 18:59:09 +02:00
|
|
|
|
2024-09-04 09:59:45 +02:00
|
|
|
config = lib.mkIf config.security.auditd.enable {
|
2019-06-10 18:27:46 +03:00
|
|
|
boot.kernelParams = [ "audit=1" ];
|
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.audit ];
|
|
|
|
|
2017-07-09 18:59:09 +02:00
|
|
|
systemd.services.auditd = {
|
|
|
|
description = "Linux Audit daemon";
|
2025-03-12 17:59:34 +01:00
|
|
|
documentation = [ "man:auditd(8)" ];
|
2024-09-04 09:57:27 +02:00
|
|
|
wantedBy = [ "sysinit.target" ];
|
|
|
|
after = [
|
|
|
|
"local-fs.target"
|
|
|
|
"systemd-tmpfiles-setup.service"
|
|
|
|
];
|
|
|
|
before = [
|
|
|
|
"sysinit.target"
|
|
|
|
"shutdown.target"
|
|
|
|
];
|
2024-01-01 17:26:38 +01:00
|
|
|
conflicts = [ "shutdown.target" ];
|
2017-07-09 18:59:09 +02:00
|
|
|
|
|
|
|
unitConfig = {
|
|
|
|
ConditionVirtualization = "!container";
|
|
|
|
ConditionSecurity = [ "audit" ];
|
2017-08-01 21:45:01 +02:00
|
|
|
DefaultDependencies = false;
|
2017-07-09 18:59:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
path = [ pkgs.audit ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
2023-11-30 15:00:39 -08:00
|
|
|
ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p /var/log/audit";
|
2017-07-09 18:59:09 +02:00
|
|
|
ExecStart = "${pkgs.audit}/bin/auditd -l -n -s nochange";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|