2

I tried to add the following rule to polkit:

polkit.addRule(function(action, subject) {
if (action.id == "org.freedesktop.systemd1.manage-units") {
    polkit.log("action=" + action)
    polkit.log("subject=" + subject)
    polkit.log("unit="+action.lookup("unit"))
    polkit.log("verb="+action.lookup("verb"))
    if (action.lookup("unit") == "jira.service" ||
        action.lookup("unit") == "bamboo.service" ||
        action.lookup("unit") == "bitbucket.service") {
        var verb = action.lookup("verb");
        if (verb == "start" || verb == "stop" || verb == "restart") {
            polkit.log("returning YES")
            return polkit.Result.YES;
        }
    }
}
polkit.log("returning NO") });

When I run:

systemctl stop bamboo

I get:

Failed to stop bamboo.service: Interactive authentication required.

And the /var/log/secure file has the following lines:

Apr 12 11:19:00 myhost polkitd[1081]: Registered Authentication Agent for unix-process:22681:1068941302 (system bus name :1.192164 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)
Apr 12 11:19:00 myhost polkitd[1081]: /etc/polkit-1/rules.d/10-buildsys-mgmt.rules:3: action=[Action id='org.freedesktop.systemd1.manage-units']
Apr 12 11:19:00 myhost polkitd[1081]: /etc/polkit-1/rules.d/10-buildsys-mgmt.rules:4: subject=[Subject pid=22681 user='myuser' groups=wheel,cvsgrp, seat='' session='' local=false active=false]
Apr 12 11:19:00 myhost polkitd[1081]: /etc/polkit-1/rules.d/10-buildsys-mgmt.rules:5: unit=undefined
Apr 12 11:19:00 myhost polkitd[1081]: /etc/polkit-1/rules.d/10-buildsys-mgmt.rules:6: verb=undefined
Apr 12 11:19:00 myhost polkitd[1081]: /etc/polkit-1/rules.d/10-buildsys-mgmt.rules:17: returning NO
Apr 12 11:19:00 myhost polkitd[1081]: Unregistered Authentication Agent for unix-process:22681:1068941302 (system bus name :1.192164, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)

The important part is that the action object doesn't seem to have keys defined for "unit" or "verb". I cribbed this rule from here: https://wiki.archlinux.org/index.php/Polkit#Allow_management_of_individual_systemd_units_by_regular_users

  • Any progress on this? – devin Aug 24 '16 at 19:41
1

This functionality was committed here: https://github.com/systemd/systemd/commit/88ced61bf9673407f4b15bf51b1b408fd78c149d and is available after and including systemd version 226. So it may not be available yet for your distro. RedHat 7 has currently systemd v219.

I too want this, and am currently opening a request ticket to RedHat.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.