Jump to content

ROX DevTray: USB key auto-mounted but NOT writable


theYinYeti
 Share

Recommended Posts

Hello,

 

Due to my growing dislike with Gnome, I'm now a happy ROX user (ROX-Session, ROX-Filer, Metacity).

However, I'd like removable media to be easily manageable. Currently, I use DevTray, which auto-detects the USB key, auto-mounts it, and opens it in ROX-Filer. But I cannot write to the key!

 

Here's the output of some commands while the key is mounted (/media/disk):

$ ls -la /media/
total 21
drwxr-xr-x  5 root root   184 2008-01-11 10:55 ./
drwxr-xr-x 22 root adm	544 2008-01-11 09:00 ../
drwxr-xr-x  2 root root	48 2007-09-05 11:39 cdrom/
drwxr-xr-x  4 root root 16384 1970-01-01 01:00 disk/
drwxr-xr-x  2 root root	48 2007-09-05 11:39 floppy/
-rw-r--r--  1 root root	69 2008-01-11 10:55 .hal-mtab
-rw-------  1 root root	 0 2008-01-11 09:07 .hal-mtab-lock
$ mount
/dev/hda6 on / type reiserfs (rw,noatime,notail,user_xattr)
none on /proc type proc (rw)
/dev/hda7 on /home type reiserfs (rw,noatime,notail,user_xattr)
none on /tmp type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
none on /sys/fs/fuse/connections type fusectl (rw)
/dev/sda1 on /media/disk type vfat (rw,nosuid,nodev,uhelper=hal,flush)
//160.14.120.10/Backup on /home/yves/.mnt/smb/backup type cifs (rw,mand)
$ grep sda1 /etc/fstab
$ find /etc/hal/
/etc/hal/
/etc/hal/fdi
/etc/hal/fdi/information
/etc/hal/fdi/policy
/etc/hal/fdi/preprobe
$ ls -l /dev/sda1
brw-rw---- 1 root disk 8, 1 2008-01-11 10:55 /dev/sda1
$ id
uid=501(yves) gid=100(users) groupes=4(adm),5(tty),6(disk),7(lp),19(floppy),21(tape),22(cdrom),43(usb),71(messagebus),73(haldaemon),80(cdwriter),
81(audio),82(video),96(zeroinst),97(ivman),100(users),102(xgrp)
$ ps -eww o cmd | grep -Ei 'ivman|hal|messagebus|sda'
hald
hald-runner
hald-addon-input: Listening on /dev/input/event4 /dev/input/event3 /dev/input/event0 /dev/input/event5 /dev/input/event6
hald-addon-acpi: listening on acpid socket /var/run/acpid.socket
hald-addon-storage: polling /dev/hdc (every 2 sec)
hald-addon-storage: polling /dev/sda (every 2 sec)
grep --color -Ei ivman|hal|messagebus|sda

 

I tried removing pmount/pumount from the system, but those were obviously unused because this causes no change at all...

In case this is of any importance, several configuration panels of DevTray throw an alert (AttributeError: type object 'XXX' has no attribute 'icons') for each UI change (field entry, check box...).

 

Yves.

Edited by theYinYeti
Link to comment
Share on other sites

No. As you can see, I have nothing there.

And I don't know if anything should be there because I have no experience with HAL. I just thought this information might be important since the mount options mention "uhelper=hal".

 

What is in charge of the user rights when there's no line in /etc/fstab in the first place?

 

Yves.

Link to comment
Share on other sites

I took a look, but it is almost the same advice I already read from DevTray home-page links. It doesn't work, probably because of missing groups: the mentionned groups don't exist in Mandriva. I went as far as creating those groups and registering myself in them, to no avail.

As for pmount/pumount, this leads to nowhere because DevTray doesn't seem to use them, or at least it doesn't change anything.

 

(BTW: /etc/hal is empty because the files are in /usr/share/hal instead)

 

So I went to the source: hal.freedesktop.org. There, I looked at the doc, looked at the output of lshal, and I wrote this file: /usr/share/hal/usr/share/hal/fdi/policy/20thirdparty/yg.usb-storage.fdi

<deviceinfo version="0.2">
	<device>
			<match key="@storage.physical_device:info.bus" string="usb">
					<match key="block.is_volume" bool="true">
							<append key="volume.mount.valid_options" type="strlist">gid</append>
							<merge key="volume.policy.mount_option.umask=002" type="bool">true</merge>
							<merge key="volume.policy.mount_option.gid=6" type="bool">true</merge>
					</match>
			</match>
	</device>
</deviceinfo>

After hal is restarted, the file is taken into account, but it doesn't work. Before the change, the mount point was created, the device mounted on it, and I could unmount it; however I couldn't write to the device. After the change, nothing happens; all I can do is, with root, create a mount point and manually mount /dev/sda1 on it.

 

What is wrong with my file?

Besides, I'd like the mount point name to be the value of "@block.storage_device:info.product" (or is "storage.model" a surer choice?); is it possible?

 

Yves.

Edited by theYinYeti
Link to comment
Share on other sites

Further reading the HAL documentation, I saw that /usr/share/hal is for the distribution, and /etc/hal is for the administrator (me). I also found an error in my above file. So I put this modified file in /etc/hal/fdi/information:

<deviceinfo version="0.2">
 <device>
<match key="@block.storage_device:@storage.originating_device:info.bus" string="usb">
  <match key="block.is_volume" bool="true">
	<append key="volume.mount.valid_options" type="strlist">gid</append>
	<merge key="volume.policy.mount_option.umask=002" type="bool">true</merge>
	<merge key="volume.policy.mount_option.gid=6" type="bool">true</merge>
	<merge key="volume.mount_point" type="string">/media/usb</merge>
  </match>
</match>
 </device>
</deviceinfo>

My file is seen. Here's the diff from the "sda1" udi without my file to the same udi with my file:

25c25
<   volume.is_mounted = true  (bool)
---
>   volume.is_mounted = false  (bool)
30,31c30,31
<   volume.mount.valid_options = {'ro', 'sync', 'dirsync', 'noatime', 'nodiratime', 'noexec', 'quiet', 'remount', 'exec', 'utf8', 'shortname=', 'codepage=', 'iocharset=', 'umask=', 'dmask=', 'fmask=', 'uid=', 'flush'} (string list)
<   volume.mount_point = '/media/disk'  (string)
---
>   volume.mount.valid_options = {'gid', 'ro', 'sync', 'dirsync', 'noatime', 'nodiratime', 'noexec', 'quiet', 'remount', 'exec', 'utf8', 'shortname=', 'codepage=', 'iocharset=', 'umask=', 'dmask=', 'fmask=', 'uid=', 'flush'} (string list)
>   volume.mount_point = '/media/usb'  (string)
40a41
>   volume.policy.mount_option.gid=6 = true  (bool)
41a43
>   volume.policy.mount_option.umask=002 = true  (bool)

However, the "<merge...>/media/usb</merge>" line is in my file because without it the "volume.mount_point" becomes empty when my file is in use!

And more importantly, although my file is seen and apparently correct, nothing happens: no mount point created, no automatic anything...

 

Yves.

Edited by theYinYeti
Link to comment
Share on other sites

Yet another error:

<append key="volume.mount.valid_options" type="strlist">gid=</append>

 

But even with this correction, nothing changes. I looked at the diff on lshal between the standard config and my changed configuration: nothing unusual. I now think the problem comes from DevTray. I'll look at the source code and let you know.

 

Yves.

Link to comment
Share on other sites

I browsed the DevTray source code. I found nothing. For all places I saw that checked for some values in the lshal output, I checked that the values were as expected. All was fine. Yet, the icon doesn't appear, the mount point is not created, and so on...

 

What I don't understand is that the lshal output is really not very different from what it is when it "kind of" works (read-only). I'll keep searching... Maybe it's the group; there's something with groups in this matter... I'll try changing the group back to root, and the umask to 000.

 

Yves.

Link to comment
Share on other sites

Well... As I don't achieve anything, I took a new look at your link, scarecrow.

 

pacman -S dbus hal
I supposed it was done, since

[root@localhost ~]# rpm -qa | grep -Ei 'dbus|hal'
hal-info-0.0-5.20070925.1mdv2008.0
hal-0.5.10-0.rc2.4mdv2008.0
libdbus-qt-1_1-0.70-2mdv2008.0
libdbus-glib-1_2-0.74-1mdv2008.0
ndesk-dbus-glib-0.3-1mdv2008.0
perl-Net-DBus-0.33.5-1mdv2008.0
qt4-qtdbus-4.3.1-12mdv2008.0
dbus-1.0.2-10mdv2008.0
libdbus-1_3-devel-1.0.2-10mdv2008.0
python-dbus-0.82.2-2mdv2008.0
libhal1-0.5.10-0.rc2.4mdv2008.0
ndesk-dbus-0.5.2-2mdv2008.0
libdbus-glib-1_2-devel-0.74-1mdv2008.0
libdbus-1_3-1.0.2-10mdv2008.0
dbus-x11-1.0.2-10mdv2008.0
libqtdbus4-4.3.1-12mdv2008.0

 

DAEMONS=(syslog-ng hal network netfs ...)
I supposed it was done, since

[root@localhost ~]# service messagebus status
dbus-daemon (pid 8074 3282) est en cours d'exécution...
[root@localhost ~]# service haldaemon status
hald (pid 3733) est en cours d'exécution...

 

gpasswd -a username optical

gpasswd -a username storage

I didn't do anything related to this: Mandriva doesn't have those groups, and I don't know the Mandriva equivalents, although I suspect "cdrom", "cdwriter", and "disk" are, but I'm already part of those groups.

 

Policies

NOTE: this is deprecated from hal => 0.5.10

I must be deprecated for me, because:

[root@localhost ~]# rpm -q hal
hal-0.5.10-0.rc2.4mdv2008.0

I tried nonetheless...

A closer look on the iPod example led me to some fixes on my file, which is now like that:

<deviceinfo version="0.2">
 <device>
<match key="@block.storage_device:@storage.originating_device:info.bus" string="usb">
  <match key="block.is_volume" bool="true">
	<append key="volume.mount.valid_options" type="strlist">gid=</append>
	<merge key="volume.policy.mount_option.umask=002" type="bool">true</merge>
	<merge key="volume.policy.mount_option.gid=6" type="bool">true</merge>
	<merge key="volume.policy.desired_mount_point" type="copy_property">@block.storage_device:storage.model</merge>
  </match>
</match>
 </device>
</deviceinfo>

There is improvement with this file. Now the key is seen, the mount point is auto-created with the device name :) and it is auto-mounted (by me=yves), and I (me: yves) can unmount it. BUT it still has the wrong rights, despite the good lshal output:

[yves@localhost ~]$ ls -lad /media/USB2FlashStorage/
drwxr-xr-x 4 root root 16384 1970-01-01 01:00 /media/USB2FlashStorage//
[yves@localhost ~]$ lshal | sed -n '/sda1/,/^$/ p'
 block.device = '/dev/sda1'  (string)
 block.is_volume = true  (bool)
 block.major = 8  (0x8)  (int)
 block.minor = 1  (0x1)  (int)
 block.storage_device = '/org/freedesktop/Hal/devices/storage_serial_Ut163_USB2FlashStorage_070801e07f725b_0_0'  (string)
 info.capabilities = {'volume', 'block'} (string list)
 info.category = 'volume'  (string)
 info.interfaces = {'org.freedesktop.Hal.Device.Volume'} (string list)
 info.parent = '/org/freedesktop/Hal/devices/storage_serial_Ut163_USB2FlashStorage_070801e07f725b_0_0'  (string)
 info.product = 'Volume (vfat)'  (string)
 info.udi = '/org/freedesktop/Hal/devices/volume_uuid_D841_58F1'  (string)
 linux.hotplug_type = 3  (0x3)  (int)
 linux.sysfs_path = '/sys/block/sda/sda1'  (string)
 org.freedesktop.Hal.Device.Volume.method_argnames = {'mount_point fstype extra_options', 'extra_options', 'extra_options'} (string list)
 org.freedesktop.Hal.Device.Volume.method_execpaths = {'hal-storage-mount', 'hal-storage-unmount', 'hal-storage-eject'} (string list)
 org.freedesktop.Hal.Device.Volume.method_names = {'Mount', 'Unmount', 'Eject'} (string list)
 org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'} (string list)
 storage.model = ''  (string)
 volume.block_size = 512  (0x200)  (int)
 volume.fstype = 'vfat'  (string)
 volume.fsusage = 'filesystem'  (string)
 volume.fsversion = 'FAT16'  (string)
 volume.ignore = false  (bool)
 volume.is_disc = false  (bool)
 volume.is_mounted = true  (bool)
 volume.is_mounted_read_only = false  (bool)
 volume.is_partition = true  (bool)
 volume.label = ''  (string)
 volume.linux.is_device_mapper = false  (bool)
 volume.mount.valid_options = {'ro', 'sync', 'dirsync', 'noatime', 'nodiratime', 'noexec', 'quiet', 'remount', 'exec', 'utf8', 'shortname=', 'codepage=', 'iocharset=', 'umask=', 'dmask=', 'fmask=', 'uid=', 'flush', 'gid='} (string list)
 volume.mount_point = '/media/USB2FlashStorage'  (string)
 volume.num_blocks = 1974208  (0x1e1fc0)  (int)
 volume.partition.flags = {'boot'} (string list)
 volume.partition.label = ''  (string)
 volume.partition.media_size = 1010826752  (0x3c3ffe00)  (uint64)
 volume.partition.number = 1  (0x1)  (int)
 volume.partition.scheme = 'mbr'  (string)
 volume.partition.start = 32256  (0x7e00)  (uint64)
 volume.partition.type = '0x06'  (string)
 volume.partition.uuid = ''  (string)
 volume.policy.desired_mount_point = 'USB2FlashStorage'  (string)
 volume.policy.mount_option.gid=6 = true  (bool)
 volume.policy.mount_option.iocharset=utf8 = true  (bool)
 volume.policy.mount_option.umask=002 = true  (bool)
 volume.size = 1010794496  (0x3c3f8000)  (uint64)
 volume.unmount.valid_options = {'lazy'} (string list)
 volume.uuid = 'D841-58F1'  (string)

The wanted result was (but IS NOT):

[yves@localhost ~]$ ls -lad /media/USB2FlashStorage/
drwxrwxr-x 4 root disk 16384 1970-01-01 01:00 /media/USB2FlashStorage//

 

The "troubleshooting" section about DBus policy seems like a good starting point for the remaining problem, but I don't want to impose a user, just a group. I'll let you know how things go.

 

Yves.

Link to comment
Share on other sites

I think this DBus policy idea is a dead-end, as far as my problem is concerned, after all. I tried creating the file /etc/dbus-1/system.d/yg.usb-storage.conf:

<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>

 <!-- HAL: allow mounted for group "disk". -->

 <policy group="disk">
<allow send_interface="org.freedesktop.Hal.Device.SystemPowerManagement"/>
<allow send_interface="org.freedesktop.Hal.Device.VideoAdapterPM"/>
<allow send_interface="org.freedesktop.Hal.Device.LaptopPanel"/>
<allow send_interface="org.freedesktop.Hal.Device.Volume"/>
<allow send_interface="org.freedesktop.Hal.Device.Volume.Crypto"/>
 </policy>

</busconfig>

It doesn't work. Looking at the actual contents, it is in fact no surprise. This configuration deals with rights on the bus: users from the "disk" group have the right to send data on the bus to the given interfaces. There's nothing about mounting, actually.

 

So back to HAL. How can I configure HAL so that the mount path is owned by a given group, and with the umask I want?

 

Yves.

Link to comment
Share on other sites

Guest potorange

I'd also like to resolve the same issue on here on Fedora...

 

My use cas is: my parents in law just bought a 500Gb external harddrive as a backup disk,

the disk is ext3 formated but the root of the disk is writable only by root :

 

# ls -ld /media/*

drwxr-xr-x 3 root root 4096 jan 16 23:14 /media/disk

 

I'd like the mount point to belong to group 'disk' and to be group writable.

 

I'm currently looking into hal-storage-mount sourcecode where all the mounting magic stands AFAICS.

 

hal-storage-mount.c

 

I'm trying to figure out from ther where I could/should set up mountpoint characteristics (uid, gid, umask ...)

 

Help anyone ?

Link to comment
Share on other sites

I've looked at the above source file. I don't see anything wrong with it.

uid= is treated in a special way so that it works as expected, and umask is given somewhere as an example mount option to use, so it must be supported. Hence at the very least, files should be owned by the requested UID.

As for the GID, while gid= is not treated in a special way as uid= is, at least I don't see anything that would prevent gid= to work.

For now, I'll consider HAL source code sane, and not at fault.

 

In fact, I think I found the culprits in my case: those are gnome-mount and DevTray; the former because it seems not to honnor the mount options from the lshal output, only those from the gconf tree!, the latter because it uses option '--mount-options' instead of '--extra-mount-options' when calling gnome-mount, and because there's a faulty "elif".

 

For those using DevTray, here's my diff on DevTray-0.3.2/Handlers/Volume/__init__.py:

--- __init__.ORIG.py	2008-01-21 13:54:34.000000000 +0100
+++ __init__.py	2008-01-21 13:47:15.000000000 +0100
@@ -106,10 +106,12 @@
					opts += 'flush,'
				elif 'sync' in valid_opts and volume.o_sync.int_value:
					opts += 'sync,'
-				elif 'uid=' in valid_opts:
+				if 'uid=' in valid_opts:
					opts += 'uid=%d,' % os.getuid()
+				if 'gid=' in valid_opts:
+					opts += 'gid=%d,' % os.getgid()
				if opts:
-					cmd.append('-o')
+					cmd.append('--extra-mount-options')
					cmd.append(opts)
		processes.PipeThroughCommand.__init__(self, cmd, None, None)
		self.__error = ''
@@ -700,6 +702,8 @@
					mount_opts.append('flush')
				if 'uid=' in valid_opts:
					mount_opts.append('uid=%d' % os.getuid())
+				if 'gid=' in valid_opts:
+					mount_opts.append('gid=%d' % os.getgid())
			self.__volume.get_device().Mount('', fstype, mount_opts,
							reply_handler = self._mount_reply,
							error_handler = self._mount_error)

From the changes I made, the change from '-o' to '--extra-mount-options' has no effect because gnome-mount doesn't get usefull default values from the HAL tree. The second set of changes (line 700) is actually useless so far because the mount method used is gnome-mount. So the changes mainly come down to the change from 'elif' to 'if', and the addition of the equivalent lines for 'gid='.

 

Now:

$ ls -lad /media/USB2FlashStorage/
drwxr-xr-x 4 yves users 16384 1970-01-01 01:00 /media/USB2FlashStorage//

 

As far as I'm concerned, the main error is corrected. However, I'd still like to get the right umask, and generally all options specified in the HAL tree (including the right group instead of my own main group).

Unfortunately, I don't know python at all, and I don't have time to look for gnome-mount source code.

 

Yves.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...