1

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?

3
  • 1
    what is the name for that group user or users?
    – user192526
    Commented Nov 30, 2017 at 12:36
  • in my case it is users
    – Hias
    Commented Nov 30, 2017 at 13:40
  • 1
    A related question is unix.stackexchange.com/q/507975/5132 .
    – JdeBP
    Commented May 24, 2020 at 21:39

2 Answers 2

2

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!

1

I could apply permission to udisks with the following setting.

/etc/polkit-1/localauthority/50-local.d/50-udisks.pkla

[udisks]
Identity=unix-group:users
Action=org.freedesktop.udisks*
ResultAny=yes
ResultInactive=no
ResultActive=yes

Reference: https://mxlinux.org/wiki/system/mount-internal-partition-without-using-root-password/

1
  • Welcome to Unix! You could improve the answer by enabling code formatting on the /etc/polkit... URL and the Reference link having an alternate text assigned so it just says the text instead of the whole URL for accessibility. Commented Dec 22, 2022 at 1:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .