From f82e7a7b83099f2f1fda9a4dfb81586732577bbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sj=C3=B6gren?= Date: Sun, 19 May 2024 20:50:41 +0200 Subject: [PATCH] lint and fix polkit examples (#8381) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lint and fix polkit examples Signed-off-by: Thomas Sjögren * add changelog fragment Signed-off-by: Thomas Sjögren * remove changelog fragment Signed-off-by: Thomas Sjögren --------- Signed-off-by: Thomas Sjögren --- plugins/become/machinectl.py | 13 +++++++------ plugins/become/run0.py | 12 ++++++------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/plugins/become/machinectl.py b/plugins/become/machinectl.py index 9b9ac7ec51..e2773ed6a5 100644 --- a/plugins/become/machinectl.py +++ b/plugins/become/machinectl.py @@ -78,12 +78,13 @@ DOCUMENTATION = ''' 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 diff --git a/plugins/become/run0.py b/plugins/become/run0.py index 1d6d7cb754..a718e86f24 100644 --- a/plugins/become/run0.py +++ b/plugins/become/run0.py @@ -69,13 +69,13 @@ EXAMPLES = r""" # 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