socket wrapper in samba3

Andrew Tridgell tridge at
Sun Jul 3 13:17:01 GMT 2005


 > Next round. Now it compiles with --enable-socket-wrapper.


I just tried it, and it works fine for smbd. I can run the samba4
torture suite fine against Samba3 smbd running as an ordinary user
with the socket wrapper code on. I can also run smbclient (either
samba3 or samba4 version) and commands like 'net rpc'. So far so good.

I also tried nmbd, and it only partly works. The problem is the
initial broadcast name registration code, which ends up trying to talk
to itself. This works fine in Samba4 where all sockets are
non-blocking, but just leads to nmbd blocking forever in Samba3.

One solution to this would be to make the socket wrapper code use
non-blocking sockets for DGRAM sockets. I tried that with the
following patch:

    --- lib/socket_wrapper.c        (revision 8093)
    +++ lib/socket_wrapper.c        (working copy)
    @@ -212,6 +212,10 @@
	    si->protocol = protocol;
	    si->fd = fd;

    +       if (type == SOCK_DGRAM) {
    +               set_blocking(fd, 0);
    +       }
	    DLIST_ADD(sockets, si);

	    return si->fd;

and found that with that change nmbd, nmblookup etc all work as
unprivileged users with the socket wrappers enabled. I do get some
warnings from nmbd about send failures, but it does work (and becomes
a master broaser etc).

It isn't an ideal solution though. A better solution might be for the
socket wrapper code to detect broadcast dgram sends, and to enable
non-blocking sends on blocking sockets only during those sends. That
would probably give maximum compatibility.

Alternatively, nmbd could be taught to use non-blocking sockets (its
really a bug that it uses blocking sockets in the first place).

Cheers, Tridge

More information about the samba-technical mailing list