fusermount: don't try to create a lock file if /etc/mtab is a symlink
authorMiklos Szeredi <miklos@szeredi.hu>
Wed, 18 Oct 2006 08:17:08 +0000 (08:17 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Wed, 18 Oct 2006 08:17:08 +0000 (08:17 +0000)
ChangeLog
util/fusermount.c

index 08f6a9effe1c058b64b15b429ce7f7cbe974b53a..3cd47958e7fe66df9a86d6fb98b5d0392d0ea706 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-10-18  Miklos Szeredi <miklos@szeredi.hu>
+
+       * fusermount: don't try to create a lock file if /etc/mtab is a
+       symlink.  Report and patch from Alexei Sheplyakov (debian bug
+       #393693)
+
 2006-10-17  Miklos Szeredi <miklos@szeredi.hu>
 
        * Minor changes, sync with mainline tree
index dc30fde92b2bcf87877a6664b0199a3776ba5fb5..014d4eafe5f8f7385d29c22bb49793c5c752d55e 100644 (file)
@@ -108,6 +108,13 @@ static int lock_mtab(void)
     const char *mtab_lock = _PATH_MOUNTED ".fuselock";
     int mtablock;
     int res;
+    struct stat mtab_stat;
+
+    /* /etc/mtab could be a symlink to /proc/mounts */
+    if (!lstat(_PATH_MOUNTED, &mtab_stat)) {
+        if (S_ISLNK(mtab_stat.st_mode))
+            return -1;
+    }
 
     mtablock = open(mtab_lock, O_RDWR | O_CREAT, 0600);
     if (mtablock >= 0) {
@@ -880,13 +887,8 @@ static int mount_fuse(const char *mnt, const char *opts)
     if (fd == -1)
         return -1;
 
-    if (geteuid() == 0) {
+    if (geteuid() == 0)
         mtablock = lock_mtab();
-        if (mtablock < 0) {
-            close(fd);
-            return -1;
-        }
-    }
 
     drop_privs();
     read_conf();