Warning: THE VOID WIKI IS DEPRECATED. It is no longer being maintained, contains outdated and incorrect information, and will eventually be shut down. Please refer to the Void Handbook, https://docs.voidlinux.org/, for the official documentation. If you can't find the information you're seeking, please raise an issue at https://github.com/void-linux/void-docs/issues

User:Masato

From Void Linux Wiki
Jump to navigation Jump to 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.