How to disable poweroff/reboot to users?

Robby Workman robby at rlworkman.net
Sat Mar 18 05:48:28 CET 2017


On Fri, 17 Mar 2017 22:31:13 -0500
William Oquendo <woquendo at gmail.com> wrote:

> Hi all,
> How can I disable shutdown and reboot from the menu to all present and
> future users of a system running xfce?
> This might be a question that appears frequently but after searching
> and trying a lot of possibilities I cannot still make this happen. I
> have tried changing the permissions for the halt, xfsm*,
> xfce4-powermanager* commands (chmod o-x), creating a kioskrc file
> (very old suggestion), but none of them worked. My sistem details are:
> OS : Linux Slackware 14.2
> xfce4 version 4.12
> Thanks in advance


Create a file, e.g. "disallow-power-options.rules" in
/etc/polkit-1/rules.d/ with these contents:

polkit.addRule(function(action, subject) {
  if (action.id == "org.freedesktop.upower.suspend" &&
      subject.isInGroup("wheel")) {
    return polkit.Result.YES;
    } else {
      return polkit.Result.NO;
  }
});

polkit.addRule(function(action, subject) {
  if (action.id == "org.freedesktop.upower.hibernate" &&
      subject.isInGroup("wheel")) {
    return polkit.Result.YES;
    } else {
      return polkit.Result.NO;
  }
});


polkit.addRule(function(action, subject) {
  if (action.id.indexOf("org.freedesktop.consolekit.system.") == 0 && 
      subject.isInGroup("wheel")) {
      return polkit.Result.YES;
    } else {
      return polkit.Result.NO;
  }
});

Note that these rules will also disallow sleep/suspend and hibernate,
but they allow for all of these options if the logged in user happens
to be a member of the "wheel" group. Adjust these as needed/desired.

-RW 


More information about the Xfce mailing list