hal/tools hal-system-storage-mount,1.2,1.3

Kay Sievers kay at freedesktop.org
Tue Dec 13 15:51:30 PST 2005


Update of /cvs/hal/hal/tools
In directory gabe:/tmp/cvs-serv23800/tools

Modified Files:
	hal-system-storage-mount 
Log Message:
2005-12-14  Kay Sievers  <kay.sievers at vrfy.org>

        Add HAL_METHOD_INVOKED_BY_UID to the method-call environment
        and use it to mount FAT, NTFS and hfs volumes to make them available
        to the user who invoked the method.
        * hald/hald_dbus.c: (hald_exec_method):
        * tools/hal-system-storage-mount:


Index: hal-system-storage-mount
===================================================================
RCS file: /cvs/hal/hal/tools/hal-system-storage-mount,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- hal-system-storage-mount	12 Dec 2005 17:50:16 -0000	1.2
+++ hal-system-storage-mount	13 Dec 2005 23:51:28 -0000	1.3
@@ -8,12 +8,18 @@
 MOUNT_ROOT="/media"
 
 # Check for environment variables
-if [ "$HAL_PROP_BLOCK_DEVICE" == "" ] || [ "$HAL_PROP_INFO_UDI" == "" ] ; then
+if [ "$HAL_PROP_BLOCK_DEVICE" == "" ] || [ "$HAL_PROP_INFO_UDI" == "" ]; then
     echo "Missing or empty environment variable(s)." >&2
     echo "This script should be started by hald." >&2
     exit 1
 fi
 
+if [ "$HAL_METHOD_INVOKED_BY_UID" == "" ]; then
+    echo "org.freedesktop.Hal.Device.Volume.PermissionDenied" >&2
+    echo "" >&2
+    exit 1
+fi
+
 # check if device is already mounted
 if [ "$HAL_PROP_VOLUME_IS_MOUNTED" = "true" ]; then
     echo "org.freedesktop.Hal.Device.Volume.AlreadyMounted" >&2
@@ -106,6 +112,22 @@
     done
 fi
 
+# special handling for certain filesystems
+case "$MOUNTTYPE" in
+    vfat)
+	MOUNTOPTIONS="$MOUNTOPTIONS,quiet,shortname=winnt,uid=$HAL_METHOD_INVOKED_BY_UID"
+	;;
+    ntfs)
+	MOUNTOPTIONS="$MOUNTOPTIONS,uid=$HAL_METHOD_INVOKED_BY_UID"
+	;;
+    hfs|hfsplus)
+	MOUNTOPTIONS="$MOUNTOPTIONS,uid=$HAL_METHOD_INVOKED_BY_UID"
+	;;
+    iso9660|udf)
+	MOUNTOPTIONS="$MOUNTOPTIONS,uid=$HAL_METHOD_INVOKED_BY_UID"
+	;;
+esac
+
 # append number to mountpoint if it already exists
 if [ -e "$MOUNT_ROOT/$MOUNTPOINT" ]; then
     NUM=1;
@@ -129,7 +151,7 @@
 fi
 
 # mount and return status
-mount -o "nosuid,nodev$MOUNTOPTIONS" -t "$MOUNTTYPE" "$HAL_PROP_BLOCK_DEVICE" "$MOUNT_ROOT/$MOUNTPOINT" > /dev/null 2>&1
+mount -o "noexec,nosuid,nodev$MOUNTOPTIONS" -t "$MOUNTTYPE" "$HAL_PROP_BLOCK_DEVICE" "$MOUNT_ROOT/$MOUNTPOINT" > /dev/null 2>&1
 if [ $? -ne 0 ]; then
     if [ -n "$MOUNTPOINT_CREATED" ]; then
 	rmdir "$MOUNT_ROOT/$MOUNTPOINT"




More information about the hal-commit mailing list