# dbus + hald - privilege issues

## sesamsys

Hello!

I emerged hald and dbus to handle external drives for my laptop. I own two USB harddisks with NTFS filesystem. They work nicely, when I plug them they are found and mounted except for the tiny problem that I have to be root to access them.  Anyone knows a workaround so that I can maintain the dbus+hald automatic handling (no manual fstabbing) with user privileges for accessing, please?

----------

## darkphader

Is it possible it's a udev permissions issue?

----------

## sesamsys

I don't know is it? How can a service have a permission?

----------

## darkphader

If you're using udev it creates the device node. When I plug in my usb stick udev creates /dev/sdb:

```
~ # ls -l /dev/sdb

brw-rw----  1 root disk 8, 16 Jul 16 19:43 /dev/sdb

```

I am a member of the "disk" group so I can use the device.

If your devices get the same permissions make sure you are a member of the "disk" group.

The service, AFAIK, wont override the device permissions and that may be why you can't use the drives except as root.

Chris

----------

## sesamsys

I have added my username to the disk group. ls -l /dev/sdb results in the same groups as you posted. However it still says permission denied when I try to access it.

```
sesam@serenity ~ $ groups sesam

disk wheel floppy audio cdrom video games usb users portage

sesam@serenity ~ $ ls -l /dev/sdb

brw-rw----  1 root disk 8, 16 Jul 17 09:26 /dev/sdb

sesam@serenity ~ $ cd /media/RAKLAP_II/

bash: cd: /media/RAKLAP_II/: Permission denied

sesam@serenity ~ $ ls -l /media/RAKLAP_II/

ls: /media/RAKLAP_II/: Permission denied

sesam@serenity ~ $ su

Password:

serenity sesam # ls -l /media/RAKLAP_II/

total 4

dr-x------  1 root root    0 Jul 13 19:16 c_image

dr-x------  1 root root 4096 Jul 13 19:15 d_image

dr-x------  1 root root    0 Jul 13 19:16 RECYCLER
```

Seems like when dbus/hald mounts it, it becomes root-only... :/

----------

## darkphader

 *sesamsys wrote:*   

> Seems like when dbus/hald mounts it

 

Hmmm...dbus/hald doesn't actually mount it, does it? It doesn't do it here. I usually have to mount it myself, hald just shows me that it's there and what it is. I thought that ivman or something else was needed for automounting.

----------

## sesamsys

HM, no, I have to manually mount it. But then... how to mount it user-readable?

----------

## sesamsys

I tried the following:

```
mount -o umask=0 /dev/sdb
```

and it worked perfectly. However I still have to be temporarily root to issue that command. Also if I just doubleclick the removable drive in the Gnome File Browser, it is automatically mounted for root only.

----------

## darkphader

It works here for me using KDE, but it sounds like the fstab update isn't doing what you need.

When hal updates fstab by writing in the line that adds the device and mount point, "user" should be one of the options. For example when I plug in my usb stick the line added to fstab is:

```
/dev/sdb1               /media/usbdisk          vfat    user,exec,noauto,utf8,noatime,sync,managed 0 0
```

 The "user" option is what allows a non-root user to mount and umount the device.

As a note, hal does look for the kernel source when compiling so whenever I install a new kernel I re-merge hal. I have found that sometimes it doesn't work correctly if I eliminate that step.

----------

## sesamsys

It adds ther user option to my fstab. However it is the umask=0 option that allows me to actually see the files inside. I can mount the drive without a problem as user even just when I want to look at the content says it that I have not enough privileges. And to mount it umasked, I need to be a root as well. I guess all this occurs because it is in NTFS.

----------

## darkphader

 *sesamsys wrote:*   

> I can mount the drive without a problem as user even just when I want to look at the content says it that I have not enough privileges.

 

Ahh...guess I didn't read carefully enough. In the past I mounted some ntfs partitions and used a uid=<myuserid> as an option.

Looks like you need to write a custom .fdi file for the device.

----------

## sesamsys

What shall I write in the .fdi file and where do I put it? By the way, what is an .fdi file?  :Smile: 

----------

## darkphader

 *sesamsys wrote:*   

> What shall I write in the .fdi file and where do I put it? By the way, what is an .fdi file? :)

 

They are files, from what I gather, that customize the hal rules for devices. I have not looked any further into it or ever written one myself. You may want check with the hal mailing list or on IRC.

----------

## Alighieri

You're not by chance using ivman to mount the drive? Hald and dbus do not mount anything. They only send messages. Ivman does not handle permissions correctly (at least the way it is installed in Gentoo). Use gnome-volume-manager or the KDE equivalent. Those volume managers run as user-level processes, so it will be you mounting the drive and not root. See the "user" option to mount.

----------

## darkphader

 *Alighieri wrote:*   

> You're not by chance using ivman to mount the drive? Hald and dbus do not mount anything. They only send messages. Ivman does not handle permissions correctly (at least the way it is installed in Gentoo). Use gnome-volume-manager or the KDE equivalent. Those volume managers run as user-level processes, so it will be you mounting the drive and not root. See the "user" option to mount.

 

You've missed it completely. He is mounting it as a user because hal adds "user" to the options in fstab. The problem is that he also needs a uid=<hisuserid>, or a umask=0 option in order to read the files because the filesystem is NTFS. Without one of these options, even if mounted as a user, permissions are not granted at the file level.

So he needs to instruct hal to add one of these options to the fstab entry it creates.

----------

## Alighieri

 *darkphader wrote:*   

> 
> 
> You've missed it completely. He is mounting it as a user because hal adds "user" to the options in fstab. The problem is that he also needs a uid=<hisuserid>, or a umask=0 option in order to read the files because the filesystem is NTFS. Without one of these options, even if mounted as a user, permissions are not granted at the file level.
> 
> So he needs to instruct hal to add one of these options to the fstab entry it creates.

 

Doh...  :Embarassed:  (Should have RTFP.)

----------

## darkphader

 *Alighieri wrote:*   

> Doh... :oops: (Should have RTFP.)

 

I missed it earlier as well, don't feel alone<g>.

----------

