From 37c22b9d308a2536eb8a3d07919fcc29ac9c7101 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 7 Oct 2019 20:24:29 +0200 Subject: [PATCH] Revive systemd.coredump.enable --- nixos/doc/manual/release-notes/rl-1909.xml | 17 ++++++++++------- nixos/modules/rename.nix | 1 - nixos/modules/system/boot/systemd.nix | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/nixos/doc/manual/release-notes/rl-1909.xml b/nixos/doc/manual/release-notes/rl-1909.xml index a33027bdbd1..4d9229becc9 100644 --- a/nixos/doc/manual/release-notes/rl-1909.xml +++ b/nixos/doc/manual/release-notes/rl-1909.xml @@ -739,7 +739,7 @@ - This also configures the kernel to pass coredumps to systemd-coredump, + This also configures the kernel to pass core dumps to systemd-coredump, and restricts the SysRq key combinations to the sync command only. These sysctl snippets can be found in /etc/sysctl.d/50-*.conf, and overridden via boot.kernel.sysctl @@ -748,12 +748,15 @@ - Coredumps are now acquired by systemd-coredump by default. - systemd-coredump behaviour can still be modified via - . - To stick to the old behaviour (having the kernel dump to a file called core - in the working directory), without piping it through systemd-coredump, set - to "core". + Core dumps are now processed by systemd-coredump + by default. systemd-coredump behaviour can + still be modified via + . To stick to the + old behaviour (having the kernel dump to a file called + core in the working directory), without piping + it through systemd-coredump, set + to + false. diff --git a/nixos/modules/rename.nix b/nixos/modules/rename.nix index 564c53465e3..df8ebe50584 100644 --- a/nixos/modules/rename.nix +++ b/nixos/modules/rename.nix @@ -233,7 +233,6 @@ with lib; (mkRemovedOptionModule [ "services" "mysql" "rootPassword" ] "Use socket authentication or set the password outside of the nix store.") (mkRemovedOptionModule [ "services" "zabbixServer" "dbPassword" ] "Use services.zabbixServer.database.passwordFile instead.") (mkRemovedOptionModule [ "systemd" "generator-packages" ] "Use systemd.packages instead.") - (mkRemovedOptionModule [ "systemd" "coredump" "enable" ] "Enabled by default. Set boot.kernel.sysctl.\"kernel.core_pattern\" = \"core\"; to disable.") # ZSH (mkRenamedOptionModule [ "programs" "zsh" "enableSyntaxHighlighting" ] [ "programs" "zsh" "syntaxHighlighting" "enable" ]) diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix index 5cf437bfbcb..669eb6a7056 100644 --- a/nixos/modules/system/boot/systemd.nix +++ b/nixos/modules/system/boot/systemd.nix @@ -546,6 +546,16 @@ in ''; }; + systemd.coredump.enable = mkOption { + default = true; + type = types.bool; + description = '' + Whether core dumps should be processed by + systemd-coredump. If disabled, core dumps + appear in the current directory of the crashing process. + ''; + }; + systemd.coredump.extraConfig = mkOption { default = ""; type = types.lines; @@ -983,6 +993,10 @@ in # Don't bother with certain units in containers. systemd.services.systemd-remount-fs.unitConfig.ConditionVirtualization = "!container"; systemd.services.systemd-random-seed.unitConfig.ConditionVirtualization = "!container"; + + boot.kernel.sysctl = mkIf (!cfg.coredump.enable) { + "kernel.core_pattern" = "core"; + }; }; # FIXME: Remove these eventually.