Re: Patch to fix SMB browsing bugs



On Fri, 2004-11-26 at 04:00 +0000, Nielsen wrote:

> > Another way would be to store a smb context in thread-local storage.
> > However, i'm not sure this is enough. You'd have to review all the samba
> > code used by libsmbclient and verify that there are no global variables
> > used. (Or at least no ones are modified after initialization.) I don't
> > think this is true...
> 
> I checked and you're correct. Samba 3.x and its various libraries aren't 
> threadsafe *or* reentrant in the least. Apparently this is something 
> that's being worked on for samba 4.x.
>
> Today I came across something else that we could try. Leave SMB network 
> access inside the lock (which can't really be helped). However we could 
> make sure to only call gnome-authentication stuff outside. Would work 
> something like this:
> 
> 1. Request comes in from gnome-vfs
> 2. Check our internal password cache. Possibly fill in a
>     password for auth_fn to return.
> 3. Enter lock.
> 4. Call appropriate libsmbclient function.
> 4a. auth_fn may be called at this point, may return cached pw,
>      or makes note of the server / share for which pw is needed.
> 5. Leave lock.
> 6. If libsmbclient returns EACCESS (or some such) we run the
>     gnome-auth prompt, cache the pw, and loop back to [2].
> 
> Naturally we'd cancel on user request etc... It maybe a little more 
> convoluted than the current code flow, but it may be more stable.
> 
> The only downside I can see is on initial connection to a server we'd 
> have an invalid request (with zero length pw) going first. Hopefully a 
> cache internal to gnome-vfs (as you spoke of above) would mitigate this 
> problem.

This is the way i initially wanted to implement it, and the obvious way.
However, there is a problem here (that i mentioned in my first mail). If
the auth_fn call doesn't return any password, or if the password
returned fails, libsmbclient automatically tries to log in as guest
before returning EACCESS. :(

This totally sucks ass in the case where guest login works, but gives
you limited permissions. In fact, this is already a problem. If you
accidentally mistype your password on the first try you might get logged
in as guest.

Fixing this in libsmbclient is a pretty small amount of work though, so
its likely that it can be fixed by us.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's a suave bohemian hairdresser with nothing left to lose. She's a violent 
kleptomaniac journalist in the wrong place at the wrong time. They fight 
crime! 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]