Skip to content

Commit

Permalink
nixos/hardened: simplify script
Browse files Browse the repository at this point in the history
  • Loading branch information
joachifm committed Sep 22, 2017
1 parent 84bd2f4 commit 15a4f9d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nixos/modules/security/lock-kernel-modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ with lib;
description = "Disable kernel module loading";

wantedBy = [ config.systemd.defaultUnit ];
after = [ "systemd-udev-settle.service" "firewall.service" "systemd-modules-load.service" ] ++ wantedBy;

script = "echo -n 1 > /proc/sys/kernel/modules_disabled";
after = [ "systemd-udev-settle.service" "firewall.service" "systemd-modules-load.service" ] ++ wantedBy;

unitConfig.ConditionPathIsReadWrite = "/proc/sys/kernel";

serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStart = "/bin/sh -c 'echo -n 1 >/proc/sys/kernel/modules_disabled'";

This comment has been minimized.

Copy link
@Mic92

Mic92 Oct 3, 2017

Member

out of curiosity: Could this not be replaced by sysctl -w?

This comment has been minimized.

Copy link
@joachifm

joachifm Oct 3, 2017

Author Contributor

It could, I've just acquired the habit of writing directly to proc.

This comment has been minimized.

Copy link
@Mic92

Mic92 Oct 4, 2017

Member

You would actually not need a shell then.

This comment has been minimized.

Copy link
@joachifm

joachifm Oct 4, 2017

Author Contributor

Also true

};
};
};
Expand Down

2 comments on commit 15a4f9d

@edolstra
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the simplification here? Using ExecStart instead of script seems more verbose...

@Mic92
Copy link
Member

@Mic92 Mic92 commented on 15a4f9d Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do systemctl cat disable-kernel-module-loading, you can immediately see the effective command
without looking at the generated script. Also it saves building one derivation.

Please sign in to comment.