physlock: add allowAnyUser option
This commit is contained in:
parent
9a5fe79d07
commit
cfd22b733b
|
@ -30,6 +30,20 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
allowAnyUser = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Whether to allow any user to lock the screen. This will install a
|
||||||
|
setuid wrapper to allow any user to start physlock as root, which
|
||||||
|
is a minor security risk. Call the physlock binary to use this instead
|
||||||
|
of using the systemd service.
|
||||||
|
|
||||||
|
Note that you might need to relog to have the correct binary in your
|
||||||
|
PATH upon changing this option.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
disableSysRq = mkOption {
|
disableSysRq = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
|
@ -79,7 +93,8 @@ in
|
||||||
|
|
||||||
###### implementation
|
###### implementation
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable (mkMerge [
|
||||||
|
{
|
||||||
|
|
||||||
# for physlock -l and physlock -L
|
# for physlock -l and physlock -L
|
||||||
environment.systemPackages = [ pkgs.physlock ];
|
environment.systemPackages = [ pkgs.physlock ];
|
||||||
|
@ -93,14 +108,21 @@ in
|
||||||
before = optional cfg.lockOn.suspend "systemd-suspend.service"
|
before = optional cfg.lockOn.suspend "systemd-suspend.service"
|
||||||
++ optional cfg.lockOn.hibernate "systemd-hibernate.service"
|
++ optional cfg.lockOn.hibernate "systemd-hibernate.service"
|
||||||
++ cfg.lockOn.extraTargets;
|
++ cfg.lockOn.extraTargets;
|
||||||
serviceConfig.Type = "forking";
|
serviceConfig = {
|
||||||
script = ''
|
Type = "forking";
|
||||||
${pkgs.physlock}/bin/physlock -d${optionalString cfg.disableSysRq "s"}
|
ExecStart = "${pkgs.physlock}/bin/physlock -d${optionalString cfg.disableSysRq "s"}";
|
||||||
'';
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
security.pam.services.physlock = {};
|
security.pam.services.physlock = {};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
|
(mkIf cfg.allowAnyUser {
|
||||||
|
|
||||||
|
security.wrappers.physlock = { source = "${pkgs.physlock}/bin/physlock"; user = "root"; };
|
||||||
|
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue