Samba caching directory handles? (Writes to incorrect home dir)

James Sutherland jas88 at
Tue May 15 12:23:55 GMT 2001

On Tue, 15 May 2001, Andrew Bartlett wrote:
> James Sutherland wrote:
> > On Tue, 15 May 2001, Andrew Bartlett wrote:
> >
> > > What I am wondering is if samba does any caching of directory handles or
> > > the like, and whether samba could be mis-translating //servername/homes
> > > to the wrong user, using the directory from a previous user.  Is this at
> > > all possible?
> >
> > IIRC, Windows does this: when a new user logs on, it finds a cached
> > "\\servername\homes" connection, and continues to use that. ISTR there's a
> > caveat about this in the docs - something along the lines of "don't use
> > \\servername\home for a home directory mapped to /home/%U because Windows
> > will cache the first user's \\server\home and reuse it for the next user"?
> In this case the connection (session setup) is over, as the utmp support
> shows that the vuid has been invalidated, and the user logged out.  So
> its probably not this.

It is: Windows caches the connection even after you log out. Stupid,
broken and insecure, but unless you're planning to send Microsoft a patch
to fix it, I think we're stuck with it :-)

> > Can you switch to something like \\server\home\username as the home
> > directory? This will be a nuisance for users - everything becomes
> > "H:\username" instead of "H:\" - but at least their home directories will
> > be private again! Alternatively, perhaps you could use \\server\username -
> > so each user has a different sharename for their home directory?
> Note that this is not a 'domain logon', its a normal file-share
> connction, and the drive is successfuly un-mapped when the user hits the
> 'disconnect' button on our logon applet.

The drive is unmapped, but Windows doesn't drop the connection: it keeps
it cached.

> Note also that there are no errors being reported, just mysteriously
> appering files.  What I am wondering is if somthing is keeping the
> directory open, and if samba is then accidently pulling this out of the
> 'cache', and creating a new file in it.

That's EXACTLY what happens - except it's WINDOWS doing this, not Samba.

> All the home directories are mod 0700, as a matter of note.
> Also, changing how this works is not an option - we have a fairly large
> number of users, and this is how they expect it to work.  We have them
> trained...

The "feature" of \\server\homes doesn't work properly, and since this is a
Windows bug not a Samba one, there's nothing that can be done. Either
change to using \\server\username (which should be transparent, at least
if you're using something like NET USE /HOME) or put up with Windows
occasionally getting different users mixed up.

"Our attitude with TCP/IP is, `Hey, we'll do it, but don't make a big
system, because we can't fix it if it breaks -- nobody can.'"

"TCP/IP is OK if you've got a little informal club, and it doesn't make
any difference if it takes a while to fix it."
		-- Ken Olson, in Digital News, 1988

More information about the samba-technical mailing list