You are not logged in.

#1 2010-11-29 22:28:58

lardon
Member
Registered: 2008-05-31
Posts: 264
Website

Solving USB key unmount problems in KDE

(this is about a solved problem, posted in the hope that:
- someone with the same problem might find it helpful
- someone with more knowledge than me can provide a better explanation of what was happening and a better solution)

Since a while I've been getting a rather cryptic error when trying to unmount a usb key in dolphin:

org.freedesktop.Hal.Device.PermissionDeniedByPolicy
org.freedesktop.hal.storage.unmount-others no <-- (privilege,result)

Of course unmounting didn't work, and I had to fire up the terminal to unmount the key. Ugly.

Googling the problem pointed to a lot of outdated advice, such as creating a /etc/PolicyKit/PolicyKit.conf. After a lot of tinkering, I convinced myself that:

1) newer policykit versions don't use that file anymore
2) the hal in arch doesn't use policykit anyways

This post  ( http://bugs.gentoo.org/262856 ) by a gentoo user seemed very similar to mine, and hal in arch doesn't enable policy-kit, so I tried rebuilding the package from abs with policy-kit enabled. Unfortunately, for reasons that I didn't sort out, it didn't build.

I then resorted to the last option, patching the source code of hal directly. I found the incriminated code in tools/hal-storage-shared.c. Here are my patches:

diff -aur src.orig//tools/hal-storage-shared.c src.patched//tools/hal-storage-shared.c
--- src.orig//tools/hal-storage-shared.c    2008-08-10 15:50:10.000000000 +0200
+++ src.patched//tools/hal-storage-shared.c    2010-11-29 23:02:36.000000000 +0100
@@ -438,7 +438,7 @@
                         libhal_free_string (polkit_result);
                 }
 #else
-                permission_denied_privilege (action, "no");
+                //permission_denied_privilege (action, "no");
 #endif
     }
 
diff -aur hal-0.5.14/tools/hal-storage-shared.c patch/tools/hal-storage-shared.c
--- hal-0.5.14/tools/hal-storage-shared.c    2010-11-29 23:06:32.000000000 +0100
+++ patch/tools/hal-storage-shared.c    2010-11-29 23:09:36.000000000 +0100
@@ -513,7 +513,7 @@
     /* unmount was succesful, remove directory we created in Mount() */
     if (g_rmdir (mount_point_to_unmount) != 0) {
         unlink ("/media/.hal-mtab~");
-        unknown_error ("Cannot remove directory");
+        //unknown_error ("Cannot remove directory");
     }
 
     /* set new .hal-mtab file */

It seems that for some reason, hal thinks I'm not the user who mounted the device, which is weird, because /media/.hal-mtab shows me as the owner:

/dev/sdb1    1000    0    vfat    nosuid,nodev,uhelper=hal,uid=1000,utf8,shortname=mixed,flush    /media/SYSRESC

Anyways, removing the check fixes the problem, but of course it's pretty ugly since it disables the security checks.

In conclusion:
- does anyone have a better solution to offer?
- I hope this will help someone
- I think we can all look forward to the day when hal will no longer be required for KDE :-D

flattr-badge-large.png

Last edited by lardon (2010-12-01 10:32:21)


Autojump, the fastest way to navigate your filesystem from the command line!

Offline

Board footer

Powered by FluxBB