[patch] do not attempt to update /etc/mtab if it is symbolic link

Shirish Pargaonkar <[email protected]>
Newsgroups gmane.linux.file-systems.cifs
Message-ID <[email protected]>
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

_______________________________________________
linux-cifs-client mailing list
[email protected]
https://lists.samba.org/mailman/listinfo/linux-cifs-client
umount.cifs.symlink.1.patch (application/octet-stream, 888 B)
diff --git a/source3/client/umount.cifs.c b/source3/client/umount.cifs.c
index 81925ed..a85e399 100644
--- a/source3/client/umount.cifs.c
+++ b/source3/client/umount.cifs.c
@@ -146,9 +146,11 @@ static int remove_from_mtab(char * mount
 	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 * mount
 		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();
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.