nixos/users: require one of users.users.name.{isSystemUser,isNormalUser}
As the only consequence of isSystemUser is that if the uid is null then it's allocated below 500, if a user has uid = something below 500 then we don't require isSystemUser to be set. Motivation: https://github.com/NixOS/nixpkgs/issues/112647
This commit is contained in:
@@ -306,6 +306,7 @@ in {
|
||||
description = "PulseAudio system service user";
|
||||
home = stateDir;
|
||||
createHome = true;
|
||||
isSystemUser = true;
|
||||
};
|
||||
|
||||
users.groups.pulse.gid = gid;
|
||||
|
||||
@@ -92,6 +92,8 @@ let
|
||||
the user's UID is allocated in the range for system users
|
||||
(below 500) or in the range for normal users (starting at
|
||||
1000).
|
||||
Exactly one of <literal>isNormalUser</literal> and
|
||||
<literal>isSystemUser</literal> must be true.
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -107,6 +109,8 @@ let
|
||||
<option>useDefaultShell</option> to <literal>true</literal>,
|
||||
and <option>isSystemUser</option> to
|
||||
<literal>false</literal>.
|
||||
Exactly one of <literal>isNormalUser</literal> and
|
||||
<literal>isSystemUser</literal> must be true.
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -521,6 +525,7 @@ in {
|
||||
};
|
||||
nobody = {
|
||||
uid = ids.uids.nobody;
|
||||
isSystemUser = true;
|
||||
description = "Unprivileged account (don't use!)";
|
||||
group = "nogroup";
|
||||
};
|
||||
@@ -608,17 +613,28 @@ in {
|
||||
Neither the root account nor any wheel user has a password or SSH authorized key.
|
||||
You must set one to prevent being locked out of your system.'';
|
||||
}
|
||||
] ++ flip mapAttrsToList cfg.users (name: user:
|
||||
{
|
||||
] ++ flatten (flip mapAttrsToList cfg.users (name: user:
|
||||
[
|
||||
{
|
||||
assertion = (user.hashedPassword != null)
|
||||
-> (builtins.match ".*:.*" user.hashedPassword == null);
|
||||
-> (builtins.match ".*:.*" user.hashedPassword == null);
|
||||
message = ''
|
||||
The password hash of user "${user.name}" contains a ":" character.
|
||||
This is invalid and would break the login system because the fields
|
||||
of /etc/shadow (file where hashes are stored) are colon-separated.
|
||||
Please check the value of option `users.users."${user.name}".hashedPassword`.'';
|
||||
}
|
||||
);
|
||||
The password hash of user "${user.name}" contains a ":" character.
|
||||
This is invalid and would break the login system because the fields
|
||||
of /etc/shadow (file where hashes are stored) are colon-separated.
|
||||
Please check the value of option `users.users."${user.name}".hashedPassword`.'';
|
||||
}
|
||||
{
|
||||
assertion = let
|
||||
xor = a: b: a && !b || b && !a;
|
||||
isEffectivelySystemUser = user.isSystemUser || (user.uid != null && user.uid < 500);
|
||||
in xor isEffectivelySystemUser user.isNormalUser;
|
||||
message = ''
|
||||
Exactly one of users.users.${user.name}.isSystemUser and users.users.${user.name}.isNormalUser must be set.
|
||||
'';
|
||||
}
|
||||
]
|
||||
));
|
||||
|
||||
warnings =
|
||||
builtins.filter (x: x != null) (
|
||||
|
||||
@@ -169,6 +169,7 @@ let
|
||||
(map (mkAuthorizedKey cfg false) cfg.authorizedKeys
|
||||
++ map (mkAuthorizedKey cfg true) cfg.authorizedKeysAppendOnly);
|
||||
useDefaultShell = true;
|
||||
isSystemUser = true;
|
||||
};
|
||||
groups.${cfg.group} = { };
|
||||
};
|
||||
|
||||
@@ -197,6 +197,7 @@ in {
|
||||
group = pgmanage;
|
||||
home = cfg.sqlRoot;
|
||||
createHome = true;
|
||||
isSystemUser = true;
|
||||
};
|
||||
groups.${pgmanage} = {
|
||||
name = pgmanage;
|
||||
|
||||
@@ -64,6 +64,7 @@ in
|
||||
|
||||
users.users = mkIf (cfg.user == "bazarr") {
|
||||
bazarr = {
|
||||
isSystemUser = true;
|
||||
group = cfg.group;
|
||||
home = "/var/lib/${config.systemd.services.bazarr.serviceConfig.StateDirectory}";
|
||||
};
|
||||
|
||||
@@ -21,6 +21,7 @@ let
|
||||
calls in `libstore/build.cc', don't add any supplementary group
|
||||
here except "nixbld". */
|
||||
uid = builtins.add config.ids.uids.nixbld nr;
|
||||
isSystemUser = true;
|
||||
group = "nixbld";
|
||||
extraGroups = [ "nixbld" ];
|
||||
};
|
||||
|
||||
@@ -34,7 +34,10 @@ in {
|
||||
|
||||
users = {
|
||||
groups._tuptime.members = [ "_tuptime" ];
|
||||
users._tuptime.description = "tuptime database owner";
|
||||
users._tuptime = {
|
||||
isSystemUser = true;
|
||||
description = "tuptime database owner";
|
||||
};
|
||||
};
|
||||
|
||||
systemd = {
|
||||
|
||||
@@ -73,6 +73,7 @@ let
|
||||
users.${variant} = {
|
||||
description = "BIRD Internet Routing Daemon user";
|
||||
group = variant;
|
||||
isSystemUser = true;
|
||||
};
|
||||
groups.${variant} = {};
|
||||
};
|
||||
|
||||
@@ -243,8 +243,10 @@ in
|
||||
xlog.journal = true;
|
||||
};
|
||||
|
||||
users.users.ncdns =
|
||||
{ description = "ncdns daemon user"; };
|
||||
users.users.ncdns = {
|
||||
isSystemUser = true;
|
||||
description = "ncdns daemon user";
|
||||
};
|
||||
|
||||
systemd.services.ncdns = {
|
||||
description = "ncdns daemon";
|
||||
|
||||
@@ -93,6 +93,7 @@ in
|
||||
users.users.pixiecore = {
|
||||
description = "Pixiecore daemon user";
|
||||
group = "pixiecore";
|
||||
isSystemUser = true;
|
||||
};
|
||||
|
||||
networking.firewall = mkIf cfg.openFirewall {
|
||||
|
||||
@@ -75,6 +75,7 @@ in {
|
||||
description = "Pleroma user";
|
||||
home = cfg.stateDir;
|
||||
extraGroups = [ cfg.group ];
|
||||
isSystemUser = true;
|
||||
};
|
||||
groups."${cfg.group}" = {};
|
||||
};
|
||||
|
||||
@@ -264,6 +264,7 @@ in
|
||||
|
||||
users.users.privacyidea = mkIf (cfg.user == "privacyidea") {
|
||||
group = cfg.group;
|
||||
isSystemUser = true;
|
||||
};
|
||||
|
||||
users.groups.privacyidea = mkIf (cfg.group == "privacyidea") {};
|
||||
@@ -294,6 +295,7 @@ in
|
||||
|
||||
users.users.pi-ldap-proxy = mkIf (cfg.ldap-proxy.user == "pi-ldap-proxy") {
|
||||
group = cfg.ldap-proxy.group;
|
||||
isSystemUser = true;
|
||||
};
|
||||
|
||||
users.groups.pi-ldap-proxy = mkIf (cfg.ldap-proxy.group == "pi-ldap-proxy") {};
|
||||
|
||||
@@ -607,6 +607,7 @@ in {
|
||||
home = "${cfg.home}";
|
||||
group = "nextcloud";
|
||||
createHome = true;
|
||||
isSystemUser = true;
|
||||
};
|
||||
users.groups.nextcloud.members = [ "nextcloud" config.services.nginx.user ];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user