udisks icon indicating copy to clipboard operation
udisks copied to clipboard

Authentication every time to mount as a root user

Open Jebrano opened this issue 1 year ago • 3 comments

After an update couple of weeks ago, I kept getting a pop-up asking for permission to mount any partition, even though I have always been a root user, it used to mount them automatically on login, and I don't know the reason why it has changed.

I followed these instructions to grant myself permission, but it didn't work. I also tried adding the partitions entry to /etc/fstab/ but it made my system boot into emergency mode, so I stopped messing with it. I don't know what to do next. Here is the pop-up image The content of 50-udiskie.rules with the appropriate file permission.

polkit.addRule(function(action, subject) {
  var YES = polkit.Result.YES;
  var permission = {
    // required for udisks1:
    "org.freedesktop.udisks.filesystem-mount": YES,
    "org.freedesktop.udisks.luks-unlock": YES,
    "org.freedesktop.udisks.drive-eject": YES,
    "org.freedesktop.udisks.drive-detach": YES,
    // required for udisks2:
    "org.freedesktop.udisks2.filesystem-mount-system": YES
    "org.freedesktop.udisks2.filesystem-mount": 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.filesystem-unmount-others": YES,
    "org.freedesktop.udisks2.encrypted-unlock-other-seat": YES,
    "org.freedesktop.udisks2.encrypted-unlock-system": YES,
    "org.freedesktop.udisks2.eject-media-other-seat": YES,
    "org.freedesktop.udisks2.power-off-drive-other-seat": YES
  };
  if (subject.isInGroup("root")) {
    return permission[action.id];
  }
});

and here is how I wrote the new partition line in /etc/fstab:

UUID=10746B3E-7447-4AD6-BE14-FA386F2CB999 /run/media/jubran/Extra\040Data ntfs defaults 0 2

Jebrano avatar Feb 06 '24 17:02 Jebrano

The polkit prompt looks sane. Nothing has changed on UDisks side other than introducing org.freedesktop.udisks2.filesystem-mount-other-user action which is not your case according to the screenshot.

Any messages from the udisksd process? This looks like your polkit rules override doesn't work. If you enter the password, does it mount properly?

tbzatek avatar Feb 08 '24 15:02 tbzatek

@tbzatek yes it does mount properly, and how can I see messages from the process, I didn't even invoke it from the terminal, but when I do try to mount from the terminal and cancel the auth request this message print out Error mounting /dev/sda2: GDBus.Error:org.freedesktop.UDisks2.Error.NotAuthorized: Not authorized to perform operation

Jebrano avatar Feb 09 '24 09:02 Jebrano

@tbzatek yes it does mount properly, and how can I see messages from the process, I didn't even invoke it from the terminal

Depends on your distribution. Most common is logging into /var/log/messages, some init systems may redirect the daemon messages elsewhere. Also depends whether udisksd was started by an init system or autostarted by dbus daemon.

but when I do try to mount from the terminal and cancel the auth request this message print out Error mounting /dev/sda2: GDBus.Error:org.freedesktop.UDisks2.Error.NotAuthorized: Not authorized to perform operation

That works as expected, also indicates that your polkit rule override doesn't work.

As the rules look like using JavaScript scripting, make sure that your polkit daemon is built with scripting support. Newer polkit releases allowed use of duktape JavaScript engine instead of SpiderMonkey. Perhaps it's disabled altogether.

tbzatek avatar Feb 27 '24 17:02 tbzatek