nixos/kerberos_server: disallow combining "all" with policies != "get-keys"

Nessdoor f500ae08 00a8c125

Changed files
+29 -10
nixos
modules
security
services
system
kerberos
+18 -10
nixos/modules/security/krb5/krb5-conf-format.nix
···
description = "Which principal the rule applies to";
};
access = mkOption {
-
type = either (listOf (enum [
-
"all"
-
"add"
-
"cpw"
-
"delete"
-
"get-keys"
-
"get"
-
"list"
-
"modify"
-
])) (enum [ "all" ]);
default = "all";
description = ''
The changes the principal is allowed to make.
···
:::{.important}
The "all" permission does not imply the "get-keys" permission. This
is consistent with the behavior of both MIT Kerberos and Heimdal.
:::
'';
};
···
description = "Which principal the rule applies to";
};
access = mkOption {
+
type = coercedTo str singleton (
+
listOf (enum [
+
"all"
+
"add"
+
"cpw"
+
"delete"
+
"get-keys"
+
"get"
+
"list"
+
"modify"
+
])
+
);
default = "all";
description = ''
The changes the principal is allowed to make.
···
:::{.important}
The "all" permission does not imply the "get-keys" permission. This
is consistent with the behavior of both MIT Kerberos and Heimdal.
+
:::
+
+
:::{.warning}
+
Value "all" is allowed as a list member only if it appears alone
+
or accompanied by "get-keys". Any other combination involving
+
"all" will raise an exception.
:::
'';
};
+11
nixos/modules/services/system/kerberos/default.nix
···
assertion = lib.length (lib.attrNames cfg.settings.realms) <= 1;
message = "Only one realm per server is currently supported.";
}
];
systemd.slices.system-kerberos-server = { };
···
assertion = lib.length (lib.attrNames cfg.settings.realms) <= 1;
message = "Only one realm per server is currently supported.";
}
+
{
+
assertion =
+
let
+
inherit (builtins) attrValues elem length;
+
realms = attrValues cfg.settings.realms;
+
accesses = lib.concatMap (r: map (a: a.access) r.acl) realms;
+
property = a: !elem "all" a || (length a <= 1) || (length a <= 2 && elem "get-keys" a);
+
in
+
builtins.all property accesses;
+
message = "Cannot specify \"all\" in a list with additional permissions other than \"get-keys\"";
+
}
];
systemd.slices.system-kerberos-server = { };