User:Masato

From Void Linux Wiki
Jump to: navigation, search

Scratch space for test edits (...and vandalism...)


related to Post Installation page mention of polkit rules to override shutdown permissions. possibly expand and make it into a page, as polkit documentation, while clear enough, it very sparse; it only gives a small handful of examples, and you're left to figure out the language and how to do other things for yourself... I definitely had to look at other examples from other wikis, plus some trial and error, to get even this much.

Example Polkit rule for overriding default policy

Create a rules file in /etc/polkit-1/rules.d/ (rules files must be named with the .rules extension).

# /etc/polkit-1/rules.d/10-shutdownpolicy.rules
polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.consolekit.system.stop" &&
        subject.isInGroup("untrusted")) {
        return "no";
    }
});

The above rule prevents members of the "untrusted" group from shutting down the system. You'll need a rule for every action that you wish to override.

For a list of actions defined in your installation, run

# pkaction

In addition to actions, some useful conditions include:

    subject.user == "username"        // Matches username
    ! subject.isInGroup("group")      // Matches users NOT in "group"

For more information on Polkit rules, see "man 8 polkit."

Note that some DEs like XFCE may use "org.freedesktop.upower.*" actions for suspend/hibernate, rather than those from consolekit, so make sure you cover all relevant actions when writing rules.