All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hongxu Jia <hongxu.jia@windriver.com>
To: <openembedded-core@lists.openembedded.org>
Subject: [PATCH 3/6] udev-extraconf:fix xuser write to usb storage failed
Date: Fri, 12 Jul 2013 17:29:27 +0800	[thread overview]
Message-ID: <f1135779e125e010377ca69cd4f072e538c8390c.1373599041.git.hongxu.jia@windriver.com> (raw)
In-Reply-To: <cover.1373599041.git.hongxu.jia@windriver.com>

Rootless X is owned by xuser, the problem is xuser doesn't have permissions to
write usb storage when the type of filesystem is vfat.
...
$ mount
/dev/sdb1 on /media/sdb1 type vfat
...
$ ls /media/ -al
drwxr-xr-x    2 root     root         16384 Jan  1  1970 sdb1
...

The usb storage is mounted to `/media/sd**' by a udev's mount.sh script,
modify the script to invoke pmount by xuser to resolve this issue.

[YOCTO #4004]

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 meta/recipes-core/udev/udev-extraconf/mount.sh | 31 ++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)
 mode change 100644 => 100755 meta/recipes-core/udev/udev-extraconf/mount.sh

diff --git a/meta/recipes-core/udev/udev-extraconf/mount.sh b/meta/recipes-core/udev/udev-extraconf/mount.sh
old mode 100644
new mode 100755
index d1419ed..07c8955
--- a/meta/recipes-core/udev/udev-extraconf/mount.sh
+++ b/meta/recipes-core/udev/udev-extraconf/mount.sh
@@ -8,6 +8,7 @@
 MOUNT="/bin/mount"
 PMOUNT="/usr/bin/pmount"
 UMOUNT="/bin/umount"
+PUMOUNT="/usr/bin/pumount"
 for line in `grep -v ^# /etc/udev/mount.blacklist`
 do
 	if [ ` expr match "$DEVNAME" "$line" ` -gt 0 ];
@@ -37,6 +38,28 @@ automount() {
 	fi
 }
 	
+autopmount() {
+	name="`basename "$DEVNAME"`"
+	xusername="root"
+
+	# If rootless X is enable, use a normal user (xuser) to invoke
+	# pmount to mount devices, so the user could have permissions
+	# to access the storage device.
+	if [ -f /etc/X11/Xusername ]; then
+		xusername="`cat /etc/X11/Xusername`"
+	fi
+
+	su -l -c "$PMOUNT -f $DEVNAME >/dev/null 2>&1" $xusername
+	grep -q "^$DEVNAME " /proc/mounts
+	if [ $? -ne 0 ];then
+		# logger "mount.sh/autopmount" "$PMOUNT $DEVNAME \"/media/$name\" failed!"
+		rm_dir "/media/$name"
+	else
+		logger "mount.sh/autopmount" "Auto-mount of [/media/$name] successful"
+		touch "/tmp/.automount-$name"
+	fi
+}
+
 rm_dir() {
 	# We do not want to rm -r populated directories
 	if test "`find "$1" | wc -l | tr -d " "`" -lt 2 -a -d "$1"
@@ -49,7 +72,7 @@ rm_dir() {
 
 if [ "$ACTION" = "add" ] && [ -n "$DEVNAME" ] && [ -n "$ID_FS_TYPE" ]; then
 	if [ -x "$PMOUNT" ]; then
-		$PMOUNT $DEVNAME 2> /dev/null
+		autopmount
 	elif [ -x $MOUNT ]; then
     		$MOUNT $DEVNAME 2> /dev/null
 	fi
@@ -67,7 +90,11 @@ fi
 if [ "$ACTION" = "remove" ] && [ -x "$UMOUNT" ] && [ -n "$DEVNAME" ]; then
 	for mnt in `cat /proc/mounts | grep "$DEVNAME" | cut -f 2 -d " " `
 	do
-		$UMOUNT $mnt
+		if [ -x "$PUMOUNT" ]; then
+			$PUMOUNT $mnt
+		else
+			$UMOUNT $mnt
+		fi
 	done
 	
 	# Remove empty directories from auto-mounter
-- 
1.8.1.2



  parent reply	other threads:[~2013-07-12  9:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-12  9:29 [PATCH 0/6] fix xuser write to usb storage failed Hongxu Jia
2013-07-12  9:29 ` [PATCH 1/6] pmount: add version 0.9.23 Hongxu Jia
2013-07-12  9:29 ` [PATCH 2/6] atom-pc:fix xuser write to usb storage failed Hongxu Jia
2013-07-15  7:14   ` Saul Wold
2013-07-15  7:42     ` Hongxu Jia
2013-07-12  9:29 ` Hongxu Jia [this message]
2013-07-12  9:29 ` [PATCH 4/6] udev: fix invoking pmount failed based on sysvinit Hongxu Jia
2013-07-12  9:29 ` [PATCH 5/6] pmount: allow users in disk group to perform pmount/pumount Hongxu Jia
2013-07-12  9:29 ` [PATCH 6/6] xuser-account: add xuser to disk group Hongxu Jia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f1135779e125e010377ca69cd4f072e538c8390c.1373599041.git.hongxu.jia@windriver.com \
    --to=hongxu.jia@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.