Bug 378321 - device notifier not mounting device: problem with polkit
Summary: device notifier not mounting device: problem with polkit
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Disks & Devices widget (show other bugs)
Version: 5.9.4
Platform: Other Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-31 17:14 UTC by Olivier Carton
Modified: 2020-11-25 01:20 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.20
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Carton 2017-03-31 17:14:59 UTC
When a plug USB key, the devices notifier pops up.  If I click to "Open in
file manager", the device is not mounted and Dolphin is not launched.  If I
click on the small button of the right, the device is then mounted.  I
I think that the problem is more or less related to the interaction with
polkit.  I have traced the ruled fired by polkit (see below).  The main
difference is that in the former case local=false active=false while in the
latter case local=true active=true

There is also another problem but I do not know whether it is related or
not. Even when the device is mounted, if I click to "Open in file manager",
Dolphin is not launched.


# Rule fired by polkit when clicking "Open in file manager"
Mar 31 09:26:45 salto polkitd[2604]: /etc/polkit-1/rules.d/10-debug.rules:7: action=[Action id='org.freedesktop.udisks2.filesystem-mount' id.version='Joliet Extension' id.usage='filesystem' drive.serial='7AA3BA73' id.label='neon user 20170119-10:37' partition.flags='0x00000080' polkit.gettext_domain='udisks2' drive.removable.bus='usb' drive='JetFlash Transcend 16GB (/dev/sdb1)' partition.number='1' id.uuid='2017-01-19-10-37-42-00' partition.uuid='036e0dfc-01' drive.vendor='JetFlash' device='/dev/sdb1' id.type='iso9660' partition.type='0x00' polkit.message='Authentication is required to mount $(drive)' drive.revision='8.07' drive.model='Transcend 16GB' drive.removable.media='thumb' drive.removable='true']

Mar 31 09:26:45 salto polkitd[2604]: /etc/polkit-1/rules.d/10-debug.rules:8: subject=[Subject pid=2893 user='carton' groups=users,wheel,video,plugdev seat='' session='' local=false active=false]


# Rule fired by polkit when clicking the small button on the right.
Mar 31 09:27:26 salto polkitd[2604]: /etc/polkit-1/rules.d/10-debug.rules:7: action=[Action id='org.freedesktop.udisks2.filesystem-mount' id.version='Joliet Extension' id.usage='filesystem' drive.serial='7AA3BA73' id.label='neon user 20170119-10:37' partition.flags='0x00000080' polkit.gettext_domain='udisks2' drive.removable.bus='usb' drive='JetFlash Transcend 16GB (/dev/sdb1)' partition.number='1' id.uuid='2017-01-19-10-37-42-00' partition.uuid='036e0dfc-01' drive.vendor='JetFlash' device='/dev/sdb1' id.type='iso9660' partition.type='0x00' polkit.message='Authentication is required to mount $(drive)' drive.revision='8.07' drive.model='Transcend 16GB' drive.removable.media='thumb' drive.removable='true']

Mar 31 09:27:26 salto polkitd[2604]: /etc/polkit-1/rules.d/10-debug.rules:8: subject=[Subject pid=2964 user='carton' groups=users,wheel,video,plugdev seat='' session='' local=true active=true]


My configuration:
Qt: 5.7.1
PLasma: 5.9.4
Frameworks 5.32.0
Comment 1 Kai Uwe Broulik 2017-04-01 15:10:30 UTC
Thanks for your analysis, unfortunately I can't see an obvious reason why the two methods result in different PolicyKit calls.

The "mount" button ends up doing the following:
        if (device.is<Solid::StorageAccess>()) {
            Solid::StorageAccess *access = device.as<Solid::StorageAccess>();
            if (access && !access->isAccessible()) {
                access->setup();
            }
        }

Whereas triggering an action before executing it does the following:
 if (device.is<Solid::StorageAccess>()
            && !device.as<Solid::StorageAccess>()->isAccessible()) {
        Solid::StorageAccess *access = device.as<Solid::StorageAccess>();

        connect(access, &Solid::StorageAccess::setupDone,
                this, &DelayedExecutor::_k_storageSetupDone);

        access->setup();

With _k_storageSetupDone being called once the device is mounted and then the action is executed. Also, "setup" just asks UDisks on DBus to mount the given device which then does PolicyKit authentication - that's not somthing we do on our side.
Comment 2 Olivier Carton 2017-04-02 13:06:26 UTC
Thank you for taking care of it.

Here are some more information.  If I try to mount using udisk
directly with something like "udisksctl mount -b /dev/sdb1", it
works.

If I add a file /etc/polkit-1/rules.d/10-udisks.rules containing

polkit.addRule(function(action, subject) { 
    if (action.id == "org.freedesktop.udisks2.filesystem-mount" && subject.isInGroup("plugdev")) { 
        return "yes"; 
    } 
}); 

it solves the problem.  This means by the way that the bug is not
so annoying but it also shows that the problem comes really from
the interaction with polkit.  From what you say, this interaction
is done by udisk.  Is udisk "called" in the way in both scenarios ?


However, this trick does not solve the second problem I mentioned.  Dolphin
still does not start.
Comment 3 Nate Graham 2020-11-25 01:20:59 UTC
This is fixed in the 5.20 UI overhaul.