mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 04:35:41 +03:00
nixos/security: init lsm option (#395855)
This commit is contained in:
commit
b2f0ccb56b
3 changed files with 31 additions and 4 deletions
|
@ -367,6 +367,7 @@
|
||||||
./security/auditd.nix
|
./security/auditd.nix
|
||||||
./security/ca.nix
|
./security/ca.nix
|
||||||
./security/chromium-suid-sandbox.nix
|
./security/chromium-suid-sandbox.nix
|
||||||
|
./security/default.nix
|
||||||
./security/dhparams.nix
|
./security/dhparams.nix
|
||||||
./security/doas.nix
|
./security/doas.nix
|
||||||
./security/duosec.nix
|
./security/duosec.nix
|
||||||
|
|
|
@ -200,10 +200,8 @@ in
|
||||||
sed '1,/\[qualifiers\]/d' $footer >> $out
|
sed '1,/\[qualifiers\]/d' $footer >> $out
|
||||||
'';
|
'';
|
||||||
|
|
||||||
boot.kernelParams = [
|
boot.kernelParams = [ "apparmor=1" ];
|
||||||
"apparmor=1"
|
security.lsm = [ "apparmor" ];
|
||||||
"security=apparmor"
|
|
||||||
];
|
|
||||||
|
|
||||||
systemd.services.apparmor = {
|
systemd.services.apparmor = {
|
||||||
after = [
|
after = [
|
||||||
|
|
28
nixos/modules/security/default.nix
Normal file
28
nixos/modules/security/default.nix
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
{ config, lib, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.security;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
security.lsm = lib.mkOption {
|
||||||
|
type = lib.types.uniq (lib.types.listOf lib.types.str);
|
||||||
|
default = [ ];
|
||||||
|
description = ''
|
||||||
|
A list of the LSMs to initialize in order.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf (lib.lists.length cfg.lsm > 0) {
|
||||||
|
assertions = [
|
||||||
|
{
|
||||||
|
assertion = builtins.length (lib.filter (lib.hasPrefix "security=") config.boot.kernelParams) == 0;
|
||||||
|
message = "security parameter in boot.kernelParams cannot be used when security.lsm is used";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
boot.kernelParams = [
|
||||||
|
"lsm=${lib.concatStringsSep "," cfg.lsm}"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue