Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Polkit rule for Fedora Media Writer

Policy Kit is a complex piece of software that tries to do more than it probably should. And sometimes you get stuck using software like that. Thankfully, there's a great manpage on the Internet for writing the rules.

I added a policykit rule so that Fedora Media Writer (a gui for placing an image on removable media) would work with my "admins" user group. I use a FreeIPA group named admins instead of the local group wheel.

Write a new file, /usr/share/spolkit-1/rules.d/fedora-media-writer.rules and fill with these contents.

polkit.addRule(function(action, subject) {
   if (action.id == "org.freedesktop.udisks2.open-device") {
      polkit.log("action=" + action);
      polkit.log("subject=" + subject);
      if (subject.isInGroup("wheel") || subject.isInGroup("admins")) {
         return polkit.Result.YES;
      }
   }
});

The policykit daemon should immediately detect the changes.

Comments