fix
authorMiklos Szeredi <miklos@szeredi.hu>
Mon, 26 Sep 2005 10:22:22 +0000 (10:22 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Mon, 26 Sep 2005 10:22:22 +0000 (10:22 +0000)
ChangeLog
util/fusermount.c

index 21cf0297abdbc0c3a5066dd6357ec16007de5d19..c734e8b48e64f293e4adab3cf542b05a06aa5a6f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-09-26  Miklos Szeredi <miklos@szeredi.hu>
+
+       * fusermount: allow user umount in the case when /etc/mtab is a
+       symlink to /proc/mounts.  Reported by Balázs Pozsár.
+
 2005-09-23  Miklos Szeredi <miklos@szeredi.hu>
 
        * Check for special node ID values in lookup and creation
index 4c92b468a0f3ebac520136970f9cbda98c592f53..6ccc58e16d8db6f1ebdc6c8de2323db4b0c4589c 100644 (file)
@@ -160,6 +160,8 @@ static int remove_mount(const char *mnt, int quiet, const char *mtab,
     FILE *fp;
     FILE *newfp;
     const char *user = NULL;
+    char uidstr[32];
+    unsigned uidlen = 0;
     int found;
 
     fp = setmntent(mtab, "r");
@@ -180,6 +182,8 @@ static int remove_mount(const char *mnt, int quiet, const char *mtab,
         user = get_user_name();
         if (user == NULL)
             return -1;
+
+        uidlen = sprintf(uidstr, "%u", getuid());
     }
 
     found = 0;
@@ -191,7 +195,14 @@ static int remove_mount(const char *mnt, int quiet, const char *mtab,
                 removed = 1;
             else {
                 char *p = strstr(entp->mnt_opts, "user=");
-                if (p != NULL && strcmp(p + 5, user) == 0)
+                if (p && (p == entp->mnt_opts || *(p-1) == ',') &&
+                    strcmp(p + 5, user) == 0)
+                    removed = 1;
+                /* /etc/mtab is a link pointing to /proc/mounts: */
+                else if ((p = strstr(entp->mnt_opts, "user_id=")) && 
+                         (p == entp->mnt_opts || *(p-1) == ',') &&
+                         strncmp(p + 8, uidstr, uidlen) == 0 &&
+                         (*(p+8+uidlen) == ',' || *(p+8+uidlen) == '\0'))
                     removed = 1;
             }
         }