Skip to content

Commit

Permalink
lint and fix polkit examples (#8381)
Browse files Browse the repository at this point in the history
* lint and fix polkit examples

Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>

* add changelog fragment

Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>

* remove changelog fragment

Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>

---------

Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
  • Loading branch information
konstruktoid authored May 19, 2024
1 parent 03240ad commit f82e7a7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
13 changes: 7 additions & 6 deletions plugins/become/machinectl.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@
EXAMPLES = r'''
# A polkit rule needed to use the module with a non-root user.
# See the Notes section for details.
60-machinectl-fast-user-auth.rules: |
polkit.addRule(function(action, subject) {
if(action.id == "org.freedesktop.machine1.host-shell" && subject.isInGroup("wheel")) {
return polkit.Result.AUTH_SELF_KEEP;
}
});
/etc/polkit-1/rules.d/60-machinectl-fast-user-auth.rules: |
polkit.addRule(function(action, subject) {
if(action.id == "org.freedesktop.machine1.host-shell" &&
subject.isInGroup("wheel")) {
return polkit.Result.AUTH_SELF_KEEP;
}
});
'''

from re import compile as re_compile
Expand Down
12 changes: 6 additions & 6 deletions plugins/become/run0.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@
# An example polkit rule that allows the user 'ansible' in the 'wheel' group
# to execute commands using run0 without authentication.
/etc/polkit-1/rules.d/60-run0-fast-user-auth.rules: |
polkit.addRule(function(action, subject) {
if(action.id == "org.freedesktop.systemd1.manage-units" &&
subject.isInGroup("wheel")
subject.user == "ansible") {
polkit.addRule(function(action, subject) {
if(action.id == "org.freedesktop.systemd1.manage-units" &&
subject.isInGroup("wheel") &&
subject.user == "ansible") {
return polkit.Result.YES;
}
});
}
});
"""

from re import compile as re_compile
Expand Down

0 comments on commit f82e7a7

Please sign in to comment.