You are not logged in.

#1 2014-05-30 14:07:59

still_waiting_for_EOF
Member
Registered: 2014-05-30
Posts: 3

Udev fails to mount as user

Hi!

I've recently gotten an Ipod Classic and would like to automount it as a non-root user (so my Amarok instance can unmount  and eject the ipod). The problem is that Udev doesnt want to mount the drive. It relabels the disk correctly to 'ipod', drops privileges to the non-root user but then just silently doesn't mount the disk. Google left me clueless with hundreds of irrelevant clicks, so I hope you guys can help me out.

I've set up the following rule in /etc/udev/rules.d/40-ipod.rules:

ATTRS{idVendor}=="05ac", ATTRS{idProduct}=="1261", KERNEL=="sd?1", SYMLINK+="ipod",  MODE="0666"
ACTION=="add", KERNEL=="sd?1", ATTRS{idVendor}=="05ac", ATTRS{idProduct}=="1261", RUN+="/usr/bin/mkdir -p /mnt/ipod" 
ACTION=="add", KERNEL=="sd?1", ATTRS{idVendor}=="05ac", ATTRS{idProduct}=="1261", RUN+="/usr/bin/chown [myusername]:[myusername] /mnt/ipod"  
ACTION=="add", KERNEL=="sd?1", ATTRS{idVendor}=="05ac", ATTRS{idProduct}=="1261", RUN+="/usr/bin/su [myusername] -c '/usr/bin/mount /dev/ipod'"

Needless to say but [myusername] is substituted with my real username.

fstab:

# /dev/sdc1 LABEL=IPOD
UUID=3141-5926          /mnt/ipod       vfat    rw,noauto,user,uid=[myusername]     0 2

journalctl:

May 30 15:34:46 w530 kernel: scsi 17:0:0:0: Direct-Access     Apple    iPod             1.62 PQ: 0 ANSI: 0
May 30 15:34:46 w530 kernel: sd 17:0:0:0: [sdh] Spinning up disk...
May 30 15:34:51 w530 kernel: .ready
May 30 15:34:51 w530 kernel: sd 17:0:0:0: [sdh] 39023511 4096-byte logical blocks: (159 GB/148 GiB)
May 30 15:34:51 w530 kernel: sd 17:0:0:0: [sdh] Write Protect is off
May 30 15:34:51 w530 kernel: sd 17:0:0:0: [sdh] Mode Sense: 68 00 00 08
May 30 15:34:51 w530 kernel: sd 17:0:0:0: [sdh] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
May 30 15:34:51 w530 kernel: sd 17:0:0:0: [sdh] 39023511 4096-byte logical blocks: (159 GB/148 GiB)
May 30 15:34:51 w530 kernel:  sdh: sdh1
May 30 15:34:51 w530 kernel: sd 17:0:0:0: [sdh] 39023511 4096-byte logical blocks: (159 GB/148 GiB)
May 30 15:34:51 w530 kernel: sd 17:0:0:0: [sdh] Attached SCSI removable disk
May 30 15:34:52 w530 kernel: FAT-fs (sdh1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
May 30 15:34:55 w530 sudo[14117]: root : TTY=unknown ; PWD=/ ; USER=[myusername] ; COMMAND=/usr/bin/mount /dev/ipod
May 30 15:34:55 w530 sudo[14117]: pam_unix(sudo:session): session opened for user [myusername] by (uid=0)
May 30 15:34:55 w530 sudo[14117]: pam_unix(sudo:session): session closed for user [myusername]
May 30 15:34:55 w530 kernel: FAT-fs (sdh1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
May 30 15:35:11 w530 sudo[14177]: root : TTY=pts/5 ; PWD=/home/[myusername] ; USER=[myusername] ; COMMAND=/usr/bin/mount /dev/ipod
May 30 15:35:11 w530 sudo[14177]: pam_unix(sudo:session): session opened for user [myusername] by (uid=0)
May 30 15:35:11 w530 sudo[14177]: pam_unix(sudo:session): session closed for user [myusername]
May 30 15:36:56 w530 su[14393]: (to [myusername]) [myusername] on pts/5
May 30 15:36:56 w530 su[14393]: pam_unix(su:session): session opened for user [myusername] by (uid=0)
May 30 15:37:06 w530 su[14393]: pam_unix(su:session): session closed for user [myusername]

It opens the session but silently fails to mount the disk, running the exact same script (/usr/bin/su [myusername] -c '/usr/bin/mount /dev/ipod) in a shell does mount the disk successfully.
I've desperately tried sudo -u [myusername] /usr/bin/mount /dev/ipod with the same result.

My guess would be that the kernel has some permission problem with udev dropping to a different uid. I am clueless right now as to what I can do to get this damn ipod to automount.

And another thing: Why does the kernel keep complaining that the volume "wasnt properly unmounted"? I've fsck'ed it five times now, the vfat-filesystem somehow keeps re-setting the dirtybit. Or are these two problems correlated?

Any help will be greatly appreciated!

Last edited by still_waiting_for_EOF (2014-05-30 14:09:43)

Offline

#2 2014-05-30 16:00:15

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: Udev fails to mount as user

You cannot call mount from a udev rule. It occurs in a different mount namespace -- one that it never propagated back to the root NS.

Offline

Board footer

Powered by FluxBB