Problem in Ubuntu: when count of logged in users more than one and USB flash drive is connectig to the PC and after switching the user the window of authentication appears. This annoying popup can be simply fixed.

Authentication is required to mount USB /dev/sdc1

Checking the file:

$ sudo nano /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla

which actions we have for this rule:

[Mounting, checking, etc. of internal drives]
Identity=unix-group:admin;unix-group:sudo
Action=org.freedesktop.udisks.filesystem-*;org.freedesktop.udisks.drive-ata-smart*;org.freedesktop.udisks2.filesystem-mount-system;org.freedesktop.udisks2.encrypted-unlock-system;org.freedesktop.udisks2.filesystem-fstab;
ResultActive=yes

We're interesting in mounting rule org.freedesktop.udisks2.filesystem-mount-system

To fix our bug you should made changes to the file /usr/share/polkit-1/actions/org.freedesktop.UDisks2.policy

$ sudo nano /usr/share/polkit-1/actions/org.freedesktop.UDisks2.policy

in action <action id="org.freedesktop.udisks2.filesystem-mount-system">

change 

    <defaults>
      <allow_any>auth_admin</allow_any>
      <allow_inactive>auth_admin</allow_inactive>
      <allow_active>auth_admin_keep</allow_active>
    </defaults>

to

   <defaults>
      <allow_any>no</allow_any>
      <allow_inactive>no</allow_inactive>
      <allow_active>auth_admin_keep</allow_active>
    </defaults>

Finally USB flash drive will be mounted ONLY for current active user and there will be no popup window when activating another user session. No more password enering to mount usb drive. Use USB drive only in active user session. 

In this case the popup still had a place when you want to unmount USB flash drive from another user.

thom

9 months 1 week ago

Hi, Thanks for it ! It's working for multi-user and also for multi-seat computer to mount usb key/drive on the good user. But It's not solving the same problem with an android phone as a usb storage. Have you an idea about wich rules / actions i have to modify to mount the usb phone one the good user ? Thanks

Add new comment

The content of this field is kept private and will not be shown publicly.
  • No HTML tags allowed.