[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha6-512-g16d2fdf

Jeff Layton jlayton at samba.org
Thu Feb 5 19:16:39 GMT 2009


The branch, master has been updated
       via  16d2fdf5750dbb344b19df23fb741fc8e0b43d10 (commit)
      from  f023bf94f1cfb0523cbbd24b5a44c6ae6450f261 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 16d2fdf5750dbb344b19df23fb741fc8e0b43d10
Author: Shirish Pargaonkar <shirishpargaonkar at gmail.com>
Date:   Thu Feb 5 14:12:42 2009 -0500

    umount.cifs: clean-up entries in /etc/mtab after unmount
    
    This patch removes the remaining entry in /etc/mtab after a filesystem
    is unmounted by canonicalizing the mountpoint supplied on the command
    line.
    
    Please refer to bug 4370 in samba bugzilla.

-----------------------------------------------------------------------

Summary of changes:
 source3/client/umount.cifs.c |   34 +++++++++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/client/umount.cifs.c b/source3/client/umount.cifs.c
index aff7cea..81925ed 100644
--- a/source3/client/umount.cifs.c
+++ b/source3/client/umount.cifs.c
@@ -33,6 +33,7 @@
 #include <errno.h>
 #include <string.h>
 #include <mntent.h>
+#include <limits.h>
 #include "mount.h"
 
 #define UNMOUNT_CIFS_VERSION_MAJOR "0"
@@ -231,6 +232,37 @@ static int remove_from_mtab(char * mountpoint)
 	return rc;
 }
 
+/* Make a canonical pathname from PATH.  Returns a freshly malloced string.
+   It is up the *caller* to ensure that the PATH is sensible.  i.e.
+   canonicalize ("/dev/fd0/.") returns "/dev/fd0" even though ``/dev/fd0/.''
+   is not a legal pathname for ``/dev/fd0''  Anything we cannot parse
+   we return unmodified.   */
+static char *
+canonicalize(char *path)
+{
+	char *canonical = malloc (PATH_MAX + 1);
+
+	if (!canonical) {
+		fprintf(stderr, "Error! Not enough memory!\n");
+		return NULL;
+	}
+
+	if (strlen(path) > PATH_MAX) {
+		fprintf(stderr, "Mount point string too long\n");
+		return NULL;
+	}
+
+	if (path == NULL)
+		return NULL;
+
+	if (realpath (path, canonical))
+		return canonical;
+
+	strncpy (canonical, path, PATH_MAX);
+	canonical[PATH_MAX] = '\0';
+	return canonical;
+}
+
 int main(int argc, char ** argv)
 {
 	int c;
@@ -304,7 +336,7 @@ int main(int argc, char ** argv)
 	argv += optind;
 	argc -= optind;
 
-	mountpoint = argv[0];
+	mountpoint = canonicalize(argv[0]);
 
 	if((argc < 1) || (argv[0] == NULL)) {
 		printf("\nMissing name of unmount directory\n");


-- 
Samba Shared Repository


More information about the samba-cvs mailing list