From Mageia wiki
Jump to: navigation, search

This page lists usefull polkit policy files to enable or disable certain behavious for normal users systemwide. The policies should all be saved as root to /etc/polkit-1/rules.d/

Disable hibernate

To disable hibernate function and hide Hibernation entry from the KDE Leave menu, create /etc/polkit-1/rules.d/99-disable-hibernate.rules with these lines:

// Disable hibernate for all users
polkit.addRule(function(action, subject) {
   if ((action.id == "org.freedesktop.login1.hibernate")) {
      return polkit.Result.NO;
   }
});
polkit.addRule(function(action, subject) {
   if ((action.id == "org.freedesktop.login1.hibernate-multiple-sessions")) {
      return polkit.Result.NO;
   }
});


Disable suspend

To disable suspend function and hide Suspend entry from the KDE Leave menu, create /etc/polkit-1/rules.d/99-disable-suspend.rules with these lines:

// Disable suspend for all users
polkit.addRule(function(action, subject) {
   if ((action.id == "org.freedesktop.login1.suspend")) {
      return polkit.Result.NO;
   }
});
polkit.addRule(function(action, subject) {
   if ((action.id == "org.freedesktop.login1.suspend-multiple-sessions")) {
      return polkit.Result.NO;
   }
});


Mount devices by users without password

WARNING: This allows normal users to mount internal partitions, which may be a security issue. Please consider the implications.

To allow users to mount devices (e.g. another partition of internal drive) without authentication, create /etc/polkit-1/rules.d/99-allow-mount.rules with these lines:

// Allow all users to mount devices without authentication
polkit.addRule(function(action, subject) {
   if ((action.id == "org.freedesktop.udisks2.filesystem-mount")) {
      return polkit.Result.YES;
   }
});
polkit.addRule(function(action, subject) {
   if ((action.id == "org.freedesktop.udisks2.filesystem-mount-system")) {
      return polkit.Result.YES;
   }
});

additional category to create table of contents links