tangled
alpha
login
or
join now
tjh.dev
/
nixpkgs
Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
0
fork
atom
overview
issues
pulls
pipelines
physlock: add allowAnyUser option
Silvan Mosberger
8 years ago
cfd22b73
9a5fe79d
+41
-19
1 changed file
expand all
collapse all
unified
split
nixos
modules
services
security
physlock.nix
+41
-19
nixos/modules/services/security/physlock.nix
···
30
30
'';
31
31
};
32
32
33
33
+
allowAnyUser = mkOption {
34
34
+
type = types.bool;
35
35
+
default = false;
36
36
+
description = ''
37
37
+
Whether to allow any user to lock the screen. This will install a
38
38
+
setuid wrapper to allow any user to start physlock as root, which
39
39
+
is a minor security risk. Call the physlock binary to use this instead
40
40
+
of using the systemd service.
41
41
+
42
42
+
Note that you might need to relog to have the correct binary in your
43
43
+
PATH upon changing this option.
44
44
+
'';
45
45
+
};
46
46
+
33
47
disableSysRq = mkOption {
34
48
type = types.bool;
35
49
default = true;
···
79
93
80
94
###### implementation
81
95
82
82
-
config = mkIf cfg.enable {
96
96
+
config = mkIf cfg.enable (mkMerge [
97
97
+
{
83
98
84
84
-
# for physlock -l and physlock -L
85
85
-
environment.systemPackages = [ pkgs.physlock ];
99
99
+
# for physlock -l and physlock -L
100
100
+
environment.systemPackages = [ pkgs.physlock ];
86
101
87
87
-
systemd.services."physlock" = {
88
88
-
enable = true;
89
89
-
description = "Physlock";
90
90
-
wantedBy = optional cfg.lockOn.suspend "suspend.target"
91
91
-
++ optional cfg.lockOn.hibernate "hibernate.target"
92
92
-
++ cfg.lockOn.extraTargets;
93
93
-
before = optional cfg.lockOn.suspend "systemd-suspend.service"
94
94
-
++ optional cfg.lockOn.hibernate "systemd-hibernate.service"
95
95
-
++ cfg.lockOn.extraTargets;
96
96
-
serviceConfig.Type = "forking";
97
97
-
script = ''
98
98
-
${pkgs.physlock}/bin/physlock -d${optionalString cfg.disableSysRq "s"}
99
99
-
'';
100
100
-
};
102
102
+
systemd.services."physlock" = {
103
103
+
enable = true;
104
104
+
description = "Physlock";
105
105
+
wantedBy = optional cfg.lockOn.suspend "suspend.target"
106
106
+
++ optional cfg.lockOn.hibernate "hibernate.target"
107
107
+
++ cfg.lockOn.extraTargets;
108
108
+
before = optional cfg.lockOn.suspend "systemd-suspend.service"
109
109
+
++ optional cfg.lockOn.hibernate "systemd-hibernate.service"
110
110
+
++ cfg.lockOn.extraTargets;
111
111
+
serviceConfig = {
112
112
+
Type = "forking";
113
113
+
ExecStart = "${pkgs.physlock}/bin/physlock -d${optionalString cfg.disableSysRq "s"}";
114
114
+
};
115
115
+
};
101
116
102
102
-
security.pam.services.physlock = {};
117
117
+
security.pam.services.physlock = {};
118
118
+
119
119
+
}
120
120
+
121
121
+
(mkIf cfg.allowAnyUser {
122
122
+
123
123
+
security.wrappers.physlock = { source = "${pkgs.physlock}/bin/physlock"; user = "root"; };
103
124
104
104
-
};
125
125
+
})
126
126
+
]);
105
127
106
128
}