Bug 4370 - umount.cfis does not remove mtab entry for relative links
umount.cfis does not remove mtab entry for relative links
Product: CifsVFS
Classification: Unclassified
Component: user space tools
Other Windows XP
: P3 normal
: ---
Assigned To: Steve French
Depends on:
  Show dependency treegraph
Reported: 2007-02-06 04:41 UTC by Diego Santa Cruz
Modified: 2009-05-04 06:23 UTC (History)
5 users (show)

See Also:

patch to unmount a filesyetem specified by not absolute path (2.56 KB, patch)
2008-02-22 09:19 UTC, Shirish S. Pargaonkar
no flags Details
patch to unmount cifs filesytem with entry in /etc/mtab removed (1.78 KB, text/plain)
2008-02-25 11:35 UTC, Shirish S. Pargaonkar
no flags Details
canonicalize the path given to umount.cifs (374 bytes, patch)
2009-02-02 10:46 UTC, Shirish S. Pargaonkar
no flags Details
canonicalize the path supplied to umount.cifs command (1.43 KB, patch)
2009-02-02 10:48 UTC, Shirish S. Pargaonkar
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Diego Santa Cruz 2007-02-06 04:41:28 UTC
Calling suid umount.cfis as a regular user using a relative path as the mount point successfully umounts but does not remove the entry from /etc/mtab

For instance after
# mount.cifs //winmachine/shared /mnt/test

# cd /mnt
# umount.cifs test

does not remove the entry from /etc/mtab. However

# umount.cifs /mnt/test
works correctly.
Comment 1 Shirish S. Pargaonkar 2007-03-15 09:19:54 UTC
I am not sure this should be a bug.

Imagine you had two shares mounted on

Now if you were to cd to /mnt and issue command   umount.cifs test,
which directory should be unmounted and its entry in /etc/mtab removed?

I think for umount.cifs, you should supply what was mounted on!
Comment 2 Diego Santa Cruz 2007-03-19 03:18:26 UTC
I think there is a misunderstanding here. The case you suggest is a little different in that the mount points are


And cd'ing to /mnt and issuing the command

umount.cifs test

should actually not umount anything (and actually it does not as far as I have tested).

What I consider a bug is to actually succeed the umount but leave the entry in /etc/mtab. If the umount succeeds then umount.cifs should have figured out the absolute path anyway (ar am I mistaken on this?) and should then remove the /etc/mtab entry.
Comment 3 Shirish S. Pargaonkar 2007-03-21 16:47:26 UTC
Yes, agree.  Sent the working code fix to umount.cifs.c to Steve.
Will wait for what he has to say.
Comment 4 Quel Qun 2008-02-20 12:30:38 UTC
Still valid a year later on Mandriva cooker with mount-cifs-3.0.28-4mdv2008.1
Comment 5 Shirish S. Pargaonkar 2008-02-22 09:19:28 UTC
Created attachment 3143 [details]
patch to unmount a filesyetem specified by not absolute path

Here is one attempt to fix the problem.   Will post it to the mailing list.
One concern I have is, do we have to consider that path specified to umount command can be relative i.e. ../dir or somethigng like that which will have characters like /, ., and ..
Comment 6 Shirish S. Pargaonkar 2008-02-22 12:42:17 UTC
umount.c calls canonicalize to canonize the directory supplied on the
command line.
Comment 7 Shirish S. Pargaonkar 2008-02-25 11:35:06 UTC
Created attachment 3148 [details]
patch to unmount cifs filesytem with entry in /etc/mtab removed

This is second attempt at the patch, this one handles characters like ., ..,
and / in the path specified to umount.cifs.
Uses standard function canonicalize (which in turn calls function realpath).
Comment 8 Kori Danse 2008-12-09 18:21:33 UTC
Hello all,

I follow this bug from:

I have something else to report. Over at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=461048 there is better description of the bug. On my system it might not have anything to do with relative paths or trailing slashes. Rather scripts. When umount.cifs is used in a script, the /etc/mtab entry is not removed.

# umount.cifs -V
umount.cifs version: 0.5-3.0.28a

# uname -a
Linux htms04 2.6.24-19-server #1 SMP Wed Jun 18 15:18:00 UTC 2008 i686 GNU/Linux

It's a really lame bug because my /etc/mtab just grows and grows because of mounting and unmounting from the backup scripts run everyday from cron. BTW, they run as root. Yes, I ran the script as root as well. When from bash or dash, it works. When run from in a script, it does not remove the /etc/mtab entry.
Comment 9 Kori Danse 2008-12-09 19:33:23 UTC
Commenting on my comment. I was using double slashes in my script. So this bug also kicks into action with double slashes ( path delimters // \\ )

Sorry for the confusion
Comment 10 Debian samba package maintainers (PUBLIC MAILING LIST) 2009-01-03 13:20:24 UTC
This bug is no longer in 3.2.5 nor in 3.3.0-rc2
Comment 11 Jeff Layton 2009-01-15 07:08:59 UTC
It doesn't look like Shirish's patches have been committed. Is this really fixed? If so, how was it done?
Comment 12 Scott Webster 2009-01-28 20:27:47 UTC
Running debian and this bug seems to still exist in 3.2.5 for me.
Comment 13 Shirish S. Pargaonkar 2009-02-02 04:39:37 UTC
I can't recreate this problem

cifstest6:/mnt # smbd -V
Version 3.2.5-1.3-2022

cifstest6:~ # type umount.cifs
umount.cifs is hashed (/sbin/umount.cifs)

cifstest6:~ # /sbin/umount.cifs -V
umount.cifs version: 0.5-3.2.5-1.3-2022

cifstest6:~ # mount
//cifstest1/public on /mnt/smb_a type cifs (rw,mand)

cifstest6:~ # cd /mnt

cifstest6:/ # umount.cifs /mnt/smb_a

cifstest6:/mnt # cat /etc/mtab

- mount entry does not exist in file /etc/mtab anymore.
Comment 14 Shirish S. Pargaonkar 2009-02-02 04:49:20 UTC
(In reply to comment #1)

I tried above as a non-root user (using sudo command) and could not 
recreate the problem, /etc/mtab is sans the entry after umount.cifs.
Comment 15 Shirish S. Pargaonkar 2009-02-02 04:54:41 UTC
I am sorry, please disregard comments #13 and #14, I was not recreating
the problem correct way, it still exists, entries still remain in /etc/mtab.

I think the patch I posted in #7 should be considered.
Comment 16 Shirish S. Pargaonkar 2009-02-02 10:46:44 UTC
Created attachment 3905 [details]
canonicalize the path given to umount.cifs

This is the same patch in comment #7, redone with the umount.cifs.c in
samba 3.3.0
Comment 17 Shirish S. Pargaonkar 2009-02-02 10:48:12 UTC
Created attachment 3906 [details]
 canonicalize the path supplied to umount.cifs command

A different definition of function canonicalize, using the same one in smbumount.
Comment 18 Jeff Layton 2009-05-04 06:23:20 UTC
This patch has been committed to master for some time. Closing case.