umount.cifs: do not attempt to update /etc/mtab if it is symbolic link
authorShirish Pargaonkar <shirishpargaonkar@gmail.com>
Mon, 27 Jul 2009 16:02:35 +0000 (12:02 -0400)
committerJeff Layton <jlayton@redhat.com>
Mon, 27 Jul 2009 16:02:35 +0000 (12:02 -0400)
If /etc/mtab is a symbolic link to e.g. /proc/mounts, do not update it.

This is a fix for a bug reported in 4675 on samba bugzilla

Signed-off-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com>
client/umount.cifs.c

index 0005054467b4e6bf7fc40554ca7cd6b260be67cd..35563c1150b4b4575a55d786486dd7ea63b36f56 100644 (file)
@@ -146,9 +146,11 @@ static int remove_from_mtab(char * mountpoint)
        FILE * org_fd;
        FILE * new_fd;
        struct mntent * mount_entry;
+       struct stat statbuf;
 
-       /* Do we need to check if it is a symlink to e.g. /proc/mounts
-       in which case we probably do not want to update it? */
+       /* If it is a symlink, e.g. to /proc/mounts, no need to update it. */
+       if ((lstat(MOUNTED, &statbuf) == 0) && (S_ISLNK(statbuf.st_mode)))
+               return 0;
 
        /* Do we first need to check if it is writable? */ 
 
@@ -162,7 +164,6 @@ static int remove_from_mtab(char * mountpoint)
                printf("attempting to remove from mtab\n");
 
        org_fd = setmntent(MOUNTED, "r");
-
        if(org_fd == NULL) {
                printf("Can not open %s\n",MOUNTED);
                unlock_mtab();