Fix for bug #4781: allow cleaning of /etc/mtab by canonicalizing mountpoint.
[samba.git] / source / client / umount.cifs.c
index e762be8f0622ca433d2a9ed581056efbc5b8a435..47ddd1e92eef8b80688c5975abcd8009fa32690a 100644 (file)
@@ -138,7 +138,7 @@ static int umount_check_perm(char * dir)
        return rc;
 }
 
-int lock_mtab(void)
+static int lock_mtab(void)
 {
        int rc;
        
@@ -151,12 +151,12 @@ int lock_mtab(void)
        
 }
 
-void unlock_mtab(void)
+static void unlock_mtab(void)
 {
        unlink(MOUNTED_LOCK);   
 }
 
-int remove_from_mtab(char * mountpoint)
+static int remove_from_mtab(char * mountpoint)
 {
        int rc;
        int num_matches;
@@ -342,6 +342,13 @@ int main(int argc, char ** argv)
 
        /* fixup path if needed */
 
+       /* Trim any trailing slashes */
+       while ((strlen(mountpoint) > 1) &&
+               (mountpoint[strlen(mountpoint)-1] == '/'))
+       {
+               mountpoint[strlen(mountpoint)-1] = '\0';
+       }
+
        /* make sure that this is a cifs filesystem */
        rc = statfs(mountpoint, &statbuf);