Debian Codegraph @

doc/modules/guide/pages/privileges.adoc

raw
1 [[privileges]]
2 = Privileges and Permissions
3
4 When a user is logged into Cockpit, they are logged into a normal
5 session that has exactly the same privileges as if they logged in via
6 SSH or on the console.
7
8 However, Cockpit will usually try to escalate the privileges of the user
9 using https://www.freedesktop.org/wiki/Software/polkit/[Policy Kit] or
10 https://www.sudo.ws/[sudo]. If the user is able to escalate privileges
11 from the command line by typing in their password again (or without
12 typing in any password), then Cockpit will be able to escalate the
13 privileges of the session to "root" immediately upon login.
14
15 The user can change the privileges of a session from within that
16 session, via the "Administrative access" indicator in the top bar. From
17 that indicator, the user can drop "root" privileges and regain them. On
18 the next login, Cockpit will give the session the same privileges.
19
20 Usually a user needs to be in the `+wheel+` Unix user group for the user
21 to be able to escalate privileges in this way. However both Policy Kit
22 and sudo may be configured to use other criteria.
23
24 [[privileges-polkit]]
25 == Customizing Polkit Privileges
26
27 Services like
28 https://www.freedesktop.org/wiki/Software/systemd/[systemd] and
29 https://wiki.gnome.org/Projects/NetworkManager[NetworkManager] use
30 https://www.freedesktop.org/wiki/Software/polkit/[Polkit] to validate
31 and escalate privileges. It is possible to customize these rules with
32 files in `+/etc/polkit-1/rules.d+`.
33
34 Polkit rules files are
35 https://www.freedesktop.org/software/polkit/docs/latest/polkit.8.html[javascript
36 with specific methods and objects]. For example, placing the following
37 polkit rule to `+/etc/polkit-1/rules.d/10-operators.rule+` allows all
38 users in the `+operators+` group to start, stop, restart and otherwise
39 manage systemd services:
40
41 ....
42 polkit.addRule(function(action, subject) {
43 if (action.id == "org.freedesktop.systemd1.manage-units") {
44 if (subject.isInGroup("operators")) {
45 return polkit.Result.YES;
46 }
47 }
48 });
49 ....
50
51 In order to allow a certain group to perform any administrative action
52 you could add a rule like this:
53
54 ....
55 polkit.addAdminRule(function(action, subject) {
56 return ["unix-group:operators"];
57 });
58 ....