testing samba3 with samba4

Andrew Tridgell tridge at osdl.org
Sun Jul 3 07:58:28 GMT 2005


Volker,

 > Attached find a patch to samba4 that might make in the future make testing the
 > samba3 smbd using the samba4 smbtorture a bit easier.

Could you consider putting the socket wrapper code from Samba4 into
Samba3 instead? Jelmer deliberately wrote that code in a way that
didn't tie it to Samba4 so it could be used for Samba3 testing as
well.

The differences between the two techniques are:

 - the socketpair_tcp method (as used in Samba3 currently) only works
   for a single TCP connection. It doesn't handle udp at all, and
   can't handle multiple tcp connections at once. It relies on the
   'inetd' mode of smbd and runs smbd as a child process

 - the socket_wrapper method in Samba4 works for all types of sockets
   (UDP, TCP, unixdomain) and for both datagram and stream modes. It
   allows you to have as many simultaneous sockets open as you like,
   and allows you to run smbd in its 'normal' mode of a daemon, not
   just in "one socket on stdin" mode.

To enable it, you need to #include "socket_wrapper.h" with
SOCKET_WRAPPER_REPLACE defined. 

At runtime it then checks for the SOCKET_WRAPPER_DIR environment
variable, and then replaces all socket related calls with wrapper
calls that go via unix domain sockets.

The big advantages are:

 - we can test WINS, NBT, LDAP, SMB, RPC etc etc all with the one
   framework

 - we can run smbd in very close to its normal mode of operation

 - we can open multiple connections to the same server, we can
   properly test nmbd, nmblookup etc

 - we can test all of the interface binding code, plus broadcasts etc

So I'd much rather see this new method adopted rather than putting the
old method into Samba4.

The old method also fails to be completely safe. The original aim of
the old socketpair_tcp code was to not expose testing running on build
farm machines to local attack by opening any sockets that could be
exploited by local users. That theory broke down when smbd started
using udp for oplock handling. Those udp calls are exposed to local
users on the build farm machines.

With the socket wrapper code, we are completely safe from local
attack, as long as the socket wrapper directory is not accessible by
other users, as all sockets appear as unix domain sockets in that
directory.

Cheers, Tridge


More information about the samba-technical mailing list