udev-extraconf:fix rootless X write to usb storage failed
v3 cover udev-extraconf:fix rootless X write to usb storage failed
Change from V2: reference other distribution (ubuntu 12.10).
The following changes since commit addcfcda84ed6b43b00f569a6060e3b78196ef52:
glib-2.0: disable tests for native builds, and respect ptest for LSB (2013-04-23 13:00:43 +0100)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib hongxu/fix-udev-xuser
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=hongxu/fix-udev-xuser
Hongxu Jia (1):
udev-extraconf:fix rootless X write to usb storage failed
meta/recipes-core/udev/udev-extraconf/mount.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
Signature · 1 line
1.7.10.4
PATCH v3 1/1 udev-extraconf:fix rootless X write to usb storage failed
Rootless X is owned by xuser, the problem is xuser could not have permissions to write to the usb storage when the file system is vfat(fat16/fat32):
1)On my distribution(Ubuntu 12.10), usb storage is auto mounted by gnome rather than udev, udev detects the plugin event and notify gnome to mount the device, the UID and GID of usb storage is inherited from the gnome's.
Login with username `jiahongxu', it has permissions to write usb storage:
...ubuntu log.......
$ mount /dev/sdb1 on /media/jiahongxu/fat type vfat (uid=1000,gid=1000,dmask=0077) $ ls /media/jiahongxu/ -al drwx------ 2 jiahongxu jiahongxu 16384 Jan 1 1970 fat ....................
Login with username `tester', it has permissions to write usb storage:
...ubuntu log.......
$ mount /dev/sdb1 on /media/tester/fat type vfat (uid=1001,gid=1002,dmask=0077) $ ls /media/root/ -al drwx------ 2 tester tester 16384 Jan 1 1970 fat ....................
2)Plug in the previous usb storage to yocto atom which rootless X is enable, xuser doesn't have permissions to write usb storage, the UID and GID of usb storage is inherited from udev's (root):
...yocto atom log...
$mount
/dev/sdb2 on /media/sdb2 type vfat
$ls /media/ -al
drwxr-xr-x 2 root root 16384 Jan 1 1970 sdb2
....................
3)In this situation to reference ubuntu, if rootless X is enable, grant xuser's UID and GID to usb storage while auto mounting by udev.
[YOCTO #4004]
--- meta/recipes-core/udev/udev-extraconf/mount.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
meta/recipes-core/udev/udev-extraconf/mount.sh +16 -0
@@ -27,6 +27,22 @@ automount() { MOUNT="$MOUNT -o silent" fi + # Setting for rootless X + if [ -f /etc/X11/Xusername ]; then + xusername="`cat /etc/X11/Xusername`" + case $ID_FS_TYPE in + # Such as fat12,fat16,fat32,vfat,msdos + vfat) + # Set the owner and group of the storage to xuser, only grant xuser + # with w/r/x permissions. + MOUNT="$MOUNT -o uid=`id "$xusername" -u`,gid=`id "$xusername" -g`,umask=077" + ;; + *) + # TODO + ;; + esac + fi + if ! $MOUNT -t auto $DEVNAME "/media/$name" then #logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"/media/$name\" failed!"
Signature · 1 line
1.7.10.4
Quoted 3 lines · Hongxu Jia
Rootless X is owned by xuser, the problem is xuser could not have permissions to write to the usb storage when the file system is vfat(fat16/fat32):
Did I miss something, but why not use a disk group that the xuser has access to? I don't really like tying the automounter to the exact configuration of the X server, especially when this will break again if the user is using a non-root Wayland session.
Ubuntu can set the user to the current user because as you say, the user environment is doing the mounting. At the moment, we don't have that.
Ross
Quoted 5 lines · Ross
Quoted 3 lines · Hongxu Jia
Rootless X is owned by xuser, the problem is xuser could not have permissions to write to the usb storage when the file system is vfat(fat16/fat32):
Quoted 8 lines
Did I miss something, but why not use a disk group that the xuser has access to? I don't really like tying the automounter to the exact configuration of the X server, especially when this will break again if the user is using a non-root Wayland session.
Ubuntu can set the user to the current user because as you say, the user environment is doing the mounting. At the moment, we don't have that.
You might want to look at pmount. It is an easy way to handle it without udisks.
--
Otavio Salvador O.S. Systems
E-mail: [email protected] http://www.ossystems.com.br
Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br