CentOS 8.x Disable graphical power-off option for non-admin users

From Notes_Wiki
Revision as of 04:40, 7 December 2021 by Saurabh (talk | contribs) (Created page with "<yambe:breadcrumb self="Disable graphical power-off option for non-admin users">CentOS 8.x System Administration|System Administration</yambe:breadcrumb> =CentOS 8.x Disable g...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<yambe:breadcrumb self="Disable graphical power-off option for non-admin users">CentOS 8.x System Administration|System Administration</yambe:breadcrumb>

CentOS 8.x Disable graphical power-off option for non-admin users

Normally when users do graphical login, they can use the menu option to power-off the system. If we want to disable non-admin (non-root) users from powering of the system we can use:

  1. Create '/etc/polkit-1/rules.d/55-inhibit-shutdown.rules' with:
    polkit.addRule(function(action, subject) {
    if ((action.id == "org.freedesktop.consolekit.system.stop" || action.id == "org.freedesktop.consolekit.system.poweroff") && subject.isInGroup("admin")) {
    return polkit.Result.YES;
    }
    else {
    return polkit.Result.NO;
    }
    });

Refer: https://forums.centos.org/viewtopic.php?t=58193