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.)
Best Answer
If you are on Ubuntu 19.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:
If it says < 0.106, then you can only use the old syntax.
You can create a .pkla file in
/etc/polkit-1/localauthority/