[Samba] Share root directory appears in subdirectories. (Well, can't actually see it but can cd into it, even if its not there.) (Serious bug?)

Wiesner Thomas thomas at bau-konform.at
Sat Nov 24 14:58:15 GMT 2007

Additionally to the problems I reported earlier, I'Ve discovered another  
problem with my server/client setup.

find reports

find: WARNING: Hard link count is wrong for ./foo: this may be a bug in  
your filesystem driver.
Automatically turning on find's -noleaf option.  Earlier results may have  
failed to include directories that should have been searched.

in one directory and if I browse this directorya and I see
completely wrong files in it (Actually, I seem to see the contents of the  
upper level directory). This problem doesn't appear with
Win2K clients and the filesystem itself is OK.

Samba Version 3.0.24 on the server (Debian Etch), according to smbd -V.
As mount helper I use mount.cifs, compiled from samba-3.0.26a.
The kernels on the server and client are the Debian default kernels  
(2.6.18-5-486 and 2.6.18-5-686).

The directory structure looks like:

where dir2 is the mountpoint.

If I 'cd' into dir4 from dir3, I see the contest of dir2. It may have to  
do with the fact, that the name of dir4 is the
same as dir2 ...

/coffee/cup$ ls
   Dir contents of cup
/coffee/cup$ cd foo
/coffee/cup/foo$ ls
   cup, water
/coffee/cup/foo$ cd cup
/coffee/cup/foo/cup$ ls
   The contents of /coffee/cup and not of /coffee/cup/foo/cup are shown and  
I can even access those wrong files!

This seems to be a definite bug in either Samba or the filesystem driver.  
This may even be a security hole in some way.
(Can't think of any now, but who knows.)

I played around a bit and found the following out: The problem appears  
when a directory has the same name as the mount point.
I can even 'cd' into a directory which isn't there:

(Mount point is gstorage, share name is gstorage too, don't know if this  
matters, I haven't investigated it)
/cifsmounts/gstorage$ cd anydir
/cifsmounts/gstorage/anydir$ cd gstorage
Crazy. I seem to be in the root of the share again(!), even if the  
directory gstorage doesn't exist in 'anydir'.
I called it anydir, because it works from any directory (but it must be  
one level below the share root).
In /cifsmounts/gstorage/anydir/gstorage I can see the contents of the root  
of the share, again. If there is a dir with the share name
the contents are overridden, like described above.

I've tried this on a client running Same problem from this one  
too. Seems to be either an undisovered kernel or Samba Bug.

   mfg Wiesner Thomas

More information about the samba mailing list