Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos: Disable audit by default #17916

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions nixos/doc/manual/release-notes/rl-1609.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ following incompatible changes:</para>
<literal>environment.variables</literal>.</para>
</listitem>

<listitem>
<para>The <literal>audit</literal> service is no longer enabled by default.
Use <literal>security.audit.enable = true;</literal> to explicitly enable it.
</listitem>

</itemizedlist>


Expand Down
16 changes: 12 additions & 4 deletions nixos/modules/security/audit.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ with lib;

let
cfg = config.security.audit;
enabled = cfg.enable == "lock" || cfg.enable;

failureModes = {
silent = 0;
printk = 1;
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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -91,7 +99,7 @@ in {
};
};

config = mkIf (cfg.enable == "lock" || cfg.enable) {
config = {
systemd.services.audit = {
description = "Kernel Auditing";
wantedBy = [ "basic.target" ];
Expand All @@ -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";
};
};
};
Expand Down
2 changes: 2 additions & 0 deletions pkgs/os-specific/linux/audit/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ stdenv.mkDerivation rec {
sha256 = "0jwrww1vn7yqxmb84n6y4p58z34gga0ic4rs2msvpzc2x1hxrn31";
};

outputs = [ "dev" "out" "bin" "man" ];

buildInputs = [ openldap ]
++ stdenv.lib.optional enablePython python;

Expand Down