add a mountopt flag for automatically adding uid
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Mon, 16 May 2011 00:06:41 +0000 (00:06 +0000)
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Mon, 16 May 2011 00:06:41 +0000 (00:06 +0000)
SVN revision: 59427

legacy/eeze/ChangeLog
legacy/eeze/src/lib/Eeze_Disk.h
legacy/eeze/src/lib/eeze_disk_mount.c
legacy/eeze/src/lib/eeze_disk_private.h

index f4de526e07a0648eb90576253ec2aaa6c8e99c22..bb855cad8edbf3761704b0ece3e62f14a1a027a6 100644 (file)
@@ -1,4 +1,7 @@
 2011-05-15  Mike Blumenkrantz (discomfitor/zmike)
++EEZE_DISK_MOUNTOPT_UID
+Add a uid=%i mount option using getuid, NOT geteuid
+--------------------------------------
 +eeze_disk_mount_wrapper_set
 +eeze_disk_mount_wrapper_get
 Allow use of wrapper exes for mount commands (such as sudo)
index b8d4e6d8b6e5ff1ed3706f13b214b40b945cd559..c3501c7f097c6c1c1b754b41df9785bc74d8d124 100644 (file)
@@ -48,7 +48,8 @@ typedef enum
    EEZE_DISK_MOUNTOPT_UTF8 = (1 << 2),
    EEZE_DISK_MOUNTOPT_NOEXEC = (1 << 3),
    EEZE_DISK_MOUNTOPT_NOSUID = (1 << 4),
-   EEZE_DISK_MOUNTOPT_REMOUNT = (1 << 5)
+   EEZE_DISK_MOUNTOPT_REMOUNT = (1 << 5),
+   EEZE_DISK_MOUNTOPT_UID = (1 << 6) /**< use current user's uid */
 } Eeze_Mount_Opts;
 
 
index f72b6ff49fa46e53c44280702fdc72fd648685c2..63a46ceb77eeb882dbbf64438808a3ee163b0288 100644 (file)
@@ -2,6 +2,8 @@
 #include "config.h"
 #endif
 
+#include <unistd.h>
+
 #include <Ecore.h>
 #include <Eeze.h>
 #include <Eeze_Disk.h>
@@ -154,6 +156,8 @@ eeze_disk_mountopts_set(Eeze_Disk *disk, unsigned long opts)
    if (opts != disk->mount_opts)
      disk->mount_cmd_changed = EINA_TRUE;
    disk->mount_opts = opts;
+   if (opts & EEZE_DISK_MOUNTOPT_UID)
+     disk->uid = getuid();
    return EINA_TRUE;
 }
 
@@ -265,6 +269,8 @@ eeze_disk_mount(Eeze_Disk *disk)
                eina_strbuf_append(disk->mount_cmd, "nosuid,");
              if (disk->mount_opts & EEZE_DISK_MOUNTOPT_REMOUNT)
                eina_strbuf_append(disk->mount_cmd, "remount,");
+             if (disk->mount_opts & EEZE_DISK_MOUNTOPT_UID)
+               eina_strbuf_append_printf(disk->mount_cmd, "uid=%i,", (int)disk->uid);
              eina_strbuf_append_printf(disk->mount_cmd, " UUID=%s %s", disk->cache.uuid, disk->mount_point);
           }
         disk->mount_cmd_changed = EINA_FALSE;
index 0c5b972484defa1751ba8f5b2dfdcdbe8a15c058..1959348a7bd597c164fd5cca14274bc6bf283cab 100644 (file)
@@ -55,6 +55,7 @@ struct _Eeze_Disk
    const char *mount_point;
    const char *mount_wrapper;
    unsigned long mount_opts;
+   uid_t uid;
 
    struct
      {