I'm trying to write a new .rules file for PolicyKit. My test attempt (in the directory /etc/polkit-1/rules.d/) looks like this:

polkit.addRule(function(action, subject) {
    polkit.spawn(["rm","/home/gabriel/test"]);
    if (action.id == "org.freedesktop.policykit.exec") {
        polkit.log("action=" + action);
        polkit.log("subject=" + subject);
    }
    return polkit.Result.NOT_HANDLED;
});

But as far as I can tell, this code is never run. The test file is still there, and there's no log output after running something like $ pkexec -u otheruser bash

(I have tried marking the .rules files as executable.)

If you are on Ubuntu 17.04 (or lower) then you are still using the old version of PolKit, where there are no .rules files but only .pkla and .conf files.

on the command prompt, do

pkaction --version

if it says < 0.106, then you can only use the old syntax

You can create a .pkla file in /etc/polkit-1/localauthority/

Good luck !

  • 1
    Ubuntu 15.10 is still on the old version. pkaction --version gives pkaction version 0.105 – Roger Binns Mar 24 '16 at 17:38
  • 2
    Ubuntu 18.04 still carries 0.105!!!! Oh, my!!!! – Paco Porras Dec 13 '17 at 23:41
  • And even no 0.106+ version is in repos for Ubuntu! OMG! – Suncatcher May 6 at 8:07

To work as expected, you have to put your own .rules files in:

/usr/share/polkit-1/rules.d

Note that it should also solve this question.

  • Moving the file there didn't seem to change anything. Also, according to the polkit docs and the Arch wiki, /etc/polkit-1/rules.d should be used for user configuration. So I'm not sure what difference changing directories makes. – Keidax Oct 13 '14 at 16:47
  • @Keidax: what's the name of your .rules file? – Sylvain Pineau Oct 13 '14 at 16:49
  • Currently /usr/share/polkit-1/rules.d/10-udisks-personal.rules – Keidax Oct 13 '14 at 16:51

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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