You are not logged in.

#1 2016-08-21 18:14:17

anisotropo
Member
Registered: 2015-06-13
Posts: 4

Polkit for shutting down

Hi,

I'd like to know what's wrong with this polkit:

polkit.addRule(function(action, subject) {
    if ((action.id == "org.freedesktop.login1.suspend" ||
         action.id == "org.freedesktop.login1.suspend-multiple-sessions" ||
         action.id == "org.freedesktop.login1.hibernate" ||
         action.id == "org.freedesktop.login1.hibernate-multiple-sessions") && subject.isInGroup("power"))
    {
        return polkit.Result.YES;
    }
});

I'm trying to let shutdown the system to the users in "power" group.

Thanks.

Offline

#2 2016-08-21 21:13:30

damjan
Member
Registered: 2006-05-30
Posts: 451

Re: Polkit for shutting down

None of those actions is shutdown (or power-off). afaik the action you need is org.freedesktop.login1.power-off

http://winaero.com/blog/how-to-enable-s … an-jessie/

Offline

#3 2016-08-22 08:28:44

anisotropo
Member
Registered: 2015-06-13
Posts: 4

Re: Polkit for shutting down

Thanks, damjan, I didn't notice.

By the way, I'm not sure if the tutorial in your link is the correct way of doing it. I thought that admin settings should be made in /etc. Settings in /usr could change with a system upgrade.

I made a new rule in /etc/polkit-1/rules.d/48-shutdown-power-group.rules:

polkit.addRule(function(action, subject) {
    if ((action.id == "org.freedesktop.login1.reboot" ||
         action.id == "org.freedesktop.login1.reboot-multiple-sessions" ||
         action.id == "org.freedesktop.login1.power-off" ||
         action.id == "org.freedesktop.login1.power-off-multiple-sessions" ||
         action.id == "org.freedesktop.login1.suspend" ||
         action.id == "org.freedesktop.login1.suspend-multiple-sessions" ||
         action.id == "org.freedesktop.login1.hibernate" ||
         action.id == "org.freedesktop.login1.hibernate-multiple-sessions") && subject.isInGroup("power"))
    {
    return polkit.Result.YES;
    }
});

This works for  me now. I can reboot or shutdown with any user in the "power" group.

Offline

Board footer

Powered by FluxBB