diff --git a/nixos/doc/manual/release-notes/rl-1609.xml b/nixos/doc/manual/release-notes/rl-1609.xml
index 1245411be179a..571ea3f8913dc 100644
--- a/nixos/doc/manual/release-notes/rl-1609.xml
+++ b/nixos/doc/manual/release-notes/rl-1609.xml
@@ -66,6 +66,11 @@ following incompatible changes:
environment.variables.
+
+ The audit service is no longer enabled by default.
+ Use security.audit.enable = true; to explicitly enable it.
+
+
diff --git a/nixos/modules/security/audit.nix b/nixos/modules/security/audit.nix
index f223f52ec487a..ebfe594d0c718 100644
--- a/nixos/modules/security/audit.nix
+++ b/nixos/modules/security/audit.nix
@@ -4,6 +4,7 @@ with lib;
let
cfg = config.security.audit;
+ enabled = cfg.enable == "lock" || cfg.enable;
failureModes = {
silent = 0;
@@ -11,6 +12,13 @@ let
panic = 2;
};
+ disableScript = pkgs.writeScript "audit-disable" ''
+ #!${pkgs.stdenv.shell} -eu
+ # Explicitly disable everything, as otherwise journald might start it.
+ auditctl -D
+ auditctl -e 0 -a task,never
+ '';
+
# TODO: it seems like people like their rules to be somewhat secret, yet they will not be if
# put in the store like this. At the same time, it doesn't feel like a huge deal and working
# around that is a pain so I'm leaving it like this for now.
@@ -47,7 +55,7 @@ in {
security.audit = {
enable = mkOption {
type = types.enum [ false true "lock" ];
- default = true; # The kernel seems to enable it by default with no rules anyway
+ default = false;
description = ''
Whether to enable the Linux audit system. The special `lock' value can be used to
enable auditing and prevent disabling it until a restart. Be careful about locking
@@ -91,7 +99,7 @@ in {
};
};
- config = mkIf (cfg.enable == "lock" || cfg.enable) {
+ config = {
systemd.services.audit = {
description = "Kernel Auditing";
wantedBy = [ "basic.target" ];
@@ -103,8 +111,8 @@ in {
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
- ExecStart = "@${startScript} audit-start";
- ExecStop = "@${stopScript} audit-stop";
+ ExecStart = "@${if enabled then startScript else disableScript} audit-start";
+ ExecStop = "@${stopScript} audit-stop";
};
};
};
diff --git a/pkgs/os-specific/linux/audit/default.nix b/pkgs/os-specific/linux/audit/default.nix
index de56a8b84160c..4b9137decc426 100644
--- a/pkgs/os-specific/linux/audit/default.nix
+++ b/pkgs/os-specific/linux/audit/default.nix
@@ -12,6 +12,8 @@ stdenv.mkDerivation rec {
sha256 = "0jwrww1vn7yqxmb84n6y4p58z34gga0ic4rs2msvpzc2x1hxrn31";
};
+ outputs = [ "dev" "out" "bin" "man" ];
+
buildInputs = [ openldap ]
++ stdenv.lib.optional enablePython python;