You are not logged in.

#1 2013-10-16 19:27:43

jrussell
Member
From: Cape Town, South Africa
Registered: 2012-08-16
Posts: 510

polkit rules not being used

I have some polkits rules which I have made:
/etc/polkit-1/rules.d/10-test.rules:

russell-server% sudo cat /etc/polkit-1/rules.d/10-test.rules
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.power-off" ||
	action.id == "org.freedesktop.login1.power-off-multiple-sessions" ||
	action.id == "org.freedesktop.login1.reboot" ||
	action.id == "org.freedesktop.login1.reboot-multiple-sessions" ||
	action.id == "org.freedesktop.login1.hibernate" ||
        action.id == "org.freedesktop.login1.hibernate-multiple-sessions"
	) {
        return polkit.Result.NO;
    }
});

As far as I know these should prevent suspend, reboot etc.

On rebooting my computer, from the top left menu of lightdm-gtk-greeter I can see reboot and shutdown options and I CAN reboot and suspend and shutdown the computer from those options and from tty without sudo and from xfce terminal on the first login from a cold boot....but I shouldn't be able to?

Whats wierd is that after loging in to a user session, then logging out back to lightdm, those options disappear in the top right and then trying to reboot/suspend from tty or from xfce is not allowed unless Im root as expected.

So it seems my polkit rules are only used after a user logs in and then logs out again.

Any ideas?

Last edited by jrussell (2013-10-16 19:30:43)


bitcoin: 1G62YGRFkMDwhGr5T5YGovfsxLx44eZo7U

Offline

#2 2013-10-17 12:07:15

jrussell
Member
From: Cape Town, South Africa
Registered: 2012-08-16
Posts: 510

Re: polkit rules not being used

Can anyone confirm this with lightdm or another dm with these rules? I'll test with gdm later today.


bitcoin: 1G62YGRFkMDwhGr5T5YGovfsxLx44eZo7U

Offline

#3 2013-10-18 00:20:45

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: polkit rules not being used

Don't you need a user specification? That is the function says it will map from (action, subject) to result but it only seems to mention the action and result parts.

Note: I've never done this - the comment is just based on the structure of the function, the examples in the wiki and the way the default actions are specified.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#4 2013-10-18 06:18:54

jrussell
Member
From: Cape Town, South Africa
Registered: 2012-08-16
Posts: 510

Re: polkit rules not being used

Apparently the rules I posted should be set for all users
https://wiki.archlinux.org/index.php/Po … _hibernate

Unless I missed something.


bitcoin: 1G62YGRFkMDwhGr5T5YGovfsxLx44eZo7U

Offline

#5 2013-10-18 23:23:30

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: polkit rules not being used

No, I think you're right. I can't see why it doesn't work.

What do your logs say? This page includes some examples of getting it to log stuff which might be useful for figuring out what's happening?


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#6 2014-02-03 09:34:11

solar
Member
Registered: 2011-03-01
Posts: 77

Re: polkit rules not being used

heya... did you figure it out jrussell?

I added an automount rule, and it worked... suddenly now it doesn't.. thinking due to an update?

Anyway, with pkaction only udisks policies show as registered.. if I remove udisks (and only keep udisks2) I get an empty list... so when trying to adding a rule it just won't work, and nemo goes ... error: no action bla bla error.


I am hilariously insane. yup. you won't notice though.. I promise...I think.

Offline

Board footer

Powered by FluxBB