0

I'm running a raspbian stretch and I want to grant every member of group user the right to mount and unmount usb-pendrives

Therefore I installed: udisks2

I created a *.rules file /usr/share/polkit-1/rules.d/50-udisks.rules with the following content:

polkit.addRule(function(action, subject) {


var YES = polkit.Result.YES;
  var permission = {
    // only required for udisks1:
    "org.freedesktop.udisks.filesystem-mount": YES,
    "org.freedesktop.udisks.filesystem-mount-system-internal": YES,
    "org.freedesktop.udisks.luks-unlock": YES,
    "org.freedesktop.udisks.drive-eject": YES,
    "org.freedesktop.udisks.drive-detach": YES,
    // only required for udisks2:
    "org.freedesktop.udisks2.filesystem-mount": YES,
    "org.freedesktop.udisks2.filesystem-mount-system": YES,
    "org.freedesktop.udisks2.encrypted-unlock": YES,
    "org.freedesktop.udisks2.eject-media": YES,
    "org.freedesktop.udisks2.power-off-drive": YES,
    // required for udisks2 if using udiskie from another seat (e.g. systemd):
    "org.freedesktop.udisks2.filesystem-mount-other-seat": YES,
    "org.freedesktop.udisks2.encrypted-unlock-other-seat": YES,
    "org.freedesktop.udisks2.eject-media-other-seat": YES,
    "org.freedesktop.udisks2.power-off-drive-other-seat": YES
  };
  if (subject.isInGroup("users")) {
    return permission[action.id];
  }
});

I restarted the polkit service:

systemctl restart polkit

When issuing: udiskctl mount -b /dev/sda1 a user is still asked to login as root.

Any idea what is going wrong?

  • 1
    what is the name for that group user or users? – user192526 Nov 30 '17 at 12:36
  • in my case it is users – Hias Nov 30 '17 at 13:40
0

it seems it's due to the fact that debian does not yet use the JavaScript style rules files. You have to place a *.pkla file like this in :/etc/polkit-1/localauthority/50-local.d/53-udisk.pkla

contents for a single user called "user":

/etc/polkit-1/localauthority/50-local.d/53-udisk.pkla

[Enable Controlling of udisk]
Identity=unix-user:user
Action=org.freedesktop.udisks.filesystem-mount;org.freedesktop.udisks.filesystem-mount-system-internal;org.freedesktop.udisks.luks-unlock;org.freedesktop.udisks.drive-eject;org.freedesktop.udisks.drive-detach;org.freedesktop.udisks2.filesystem-mount;org.freedesktop.udisks2.filesystem-mount-system;org.freedesktop.udisks2.encrypted-unlock;org.freedesktop.udisks2.eject-media;org.freedesktop.udisks2.power-off-drive;org.freedesktop.udisks2.filesystem-mount-other-seat;org.freedesktop.udisks2.encrypted-unlock-other-seat;org.freedesktop.udisks2.eject-media-other-seat;org.freedesktop.udisks2.power-off-drive-other-seat
ResultAny=yes
ResultInactive=yes
ResultActive=yes

This way it is working for me now on raspbian stretch or jessie!

Best Hias

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.