X-Git-Url: http://git.samba.org/?p=samba.git;a=blobdiff_plain;f=selftest%2Ftarget%2FSamba3.pm;h=554410580fadfa0140d8659f360e905fec5df198;hp=7ecb481a467a2fe2f5482d89f1364c49990e000f;hb=25ec8e8656f66fe51a0d48718cdcfd8b209f6ca0;hpb=70f4a96c68e91e407651e2487cc3c66a80262fa2 diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index 7ecb481a467..554410580fa 100755 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -11,6 +11,43 @@ use FindBin qw($RealBin); use POSIX; use target::Samba; +sub have_ads($) { + my ($self) = @_; + my $found_ads = 0; + my $smbd_build_options = Samba::bindir_path($self, "smbd") . " -b|"; + open(IN, $smbd_build_options) or die("Unable to run $smbd_build_options: $!"); + + while () { + if (/WITH_ADS/) { + $found_ads = 1; + } + } + close IN; + + # If we were not built with ADS support, pretend we were never even available + print "smbd does not have ADS support\n" unless $found_ads; + return $found_ads; +} + +# return smb.conf parameters applicable to @path, based on the underlying +# filesystem type +sub get_fs_specific_conf($$) +{ + my ($self, $path) = @_; + my $mods = ""; + my $stat_out = `stat --file-system $path` or return ""; + + if ($stat_out =~ m/Type:\s+btrfs/) { + $mods .= "btrfs "; + } + + if ($mods) { + return "vfs objects = $mods"; + } + + return undef; +} + sub new($$) { my ($classname, $bindir, $binary_mapping, $srcdir, $server_maxtime) = @_; my $self = { vars => {}, @@ -26,17 +63,56 @@ sub new($$) { sub teardown_env($$) { my ($self, $envvars) = @_; + my $count = 0; - my $smbdpid = read_pid($envvars, "smbd"); - my $nmbdpid = read_pid($envvars, "nmbd"); - my $winbinddpid = read_pid($envvars, "winbindd"); + # This should cause smbd to terminate gracefully + close($envvars->{STDIN_PIPE}); + + my $smbdpid = $envvars->{SMBD_TL_PID}; + my $nmbdpid = $envvars->{NMBD_TL_PID}; + my $winbinddpid = $envvars->{WINBINDD_TL_PID}; + + # This should give it time to write out the gcov data + until ($count > 20) { + my $smbdchild = Samba::cleanup_child($smbdpid, "smbd"); + my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd"); + my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd"); + if ($smbdchild == -1 + && $nmbdchild == -1 + && $winbinddchild == -1) { + last; + } + sleep(1); + $count++; + } + + if ($count <= 20 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) { + return; + } $self->stop_sig_term($smbdpid); $self->stop_sig_term($nmbdpid); $self->stop_sig_term($winbinddpid); - sleep(2); + $count = 0; + until ($count > 10) { + my $smbdchild = Samba::cleanup_child($smbdpid, "smbd"); + my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd"); + my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd"); + if ($smbdchild == -1 + && $nmbdchild == -1 + && $winbinddchild == -1) { + last; + } + sleep(1); + $count++; + } + if ($count <= 10 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) { + return; + } + + warn("timelimit process did not quit on SIGTERM, sending SIGKILL"); $self->stop_sig_kill($smbdpid); $self->stop_sig_kill($nmbdpid); $self->stop_sig_kill($winbinddpid); @@ -81,6 +157,8 @@ sub check_env($$) { my ($self, $envvars) = @_; + my $childpid = waitpid(-1, WNOHANG); + # TODO ... return 1; } @@ -88,22 +166,21 @@ sub check_env($$) sub setup_env($$$) { my ($self, $envname, $path) = @_; - + + $ENV{ENVNAME} = $envname; + + if (defined($self->{vars}->{$envname})) { + return $self->{vars}->{$envname}; + } + if ($envname eq "s3dc") { return $self->setup_s3dc("$path/s3dc"); - } elsif ($envname eq "secshare") { - return $self->setup_secshare("$path/secshare"); + } elsif ($envname eq "simpleserver") { + return $self->setup_simpleserver("$path/simpleserver"); } elsif ($envname eq "maptoguest") { return $self->setup_maptoguest("$path/maptoguest"); } elsif ($envname eq "ktest") { return $self->setup_ktest("$path/ktest"); - } elsif ($envname eq "secserver") { - if (not defined($self->{vars}->{s3dc})) { - if (not defined($self->setup_s3dc("$path/s3dc"))) { - return undef; - } - } - return $self->setup_secserver("$path/secserver", $self->{vars}->{s3dc}); } elsif ($envname eq "member") { if (not defined($self->{vars}->{s3dc})) { if (not defined($self->setup_s3dc("$path/s3dc"))) { @@ -126,25 +203,33 @@ sub setup_s3dc($$) domain master = yes domain logons = yes lanman auth = yes + + rpc_server:epmapper = external + rpc_server:spoolss = external + rpc_server:lsarpc = external + rpc_server:samr = external + rpc_server:netlogon = external + rpc_server:register_embedded_np = yes + + rpc_daemon:epmd = fork + rpc_daemon:spoolssd = fork + rpc_daemon:lsasd = fork "; my $vars = $self->provision($path, "LOCALS3DC2", - 2, "locals3dc2pass", $s3dc_options); $vars or return undef; - $self->check_or_start($vars, - "yes", "yes", "yes"); - - if (not $self->wait_for_start($vars)) { + if (not $self->check_or_start($vars, "yes", "yes", "yes")) { return undef; } $vars->{DC_SERVER} = $vars->{SERVER}; $vars->{DC_SERVER_IP} = $vars->{SERVER_IP}; + $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6}; $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME}; $vars->{DC_USERNAME} = $vars->{USERNAME}; $vars->{DC_PASSWORD} = $vars->{PASSWORD}; @@ -163,10 +248,10 @@ sub setup_member($$$) my $member_options = " security = domain server signing = on + dbwrap_tdb_mutexes:* = yes "; my $ret = $self->provision($prefix, "LOCALMEMBER3", - 3, "localmember3pass", $member_options); @@ -183,14 +268,13 @@ sub setup_member($$$) return undef; } - $self->check_or_start($ret, "yes", "yes", "yes"); - - if (not $self->wait_for_start($ret)) { + if (not $self->check_or_start($ret, "yes", "yes", "yes")) { return undef; } $ret->{DC_SERVER} = $s3dcvars->{SERVER}; $ret->{DC_SERVER_IP} = $s3dcvars->{SERVER_IP}; + $ret->{DC_SERVER_IPV6} = $s3dcvars->{SERVER_IPV6}; $ret->{DC_NETBIOSNAME} = $s3dcvars->{NETBIOSNAME}; $ret->{DC_USERNAME} = $s3dcvars->{USERNAME}; $ret->{DC_PASSWORD} = $s3dcvars->{PASSWORD}; @@ -200,9 +284,14 @@ sub setup_member($$$) sub setup_admember($$$$) { - my ($self, $prefix, $dcvars, $iface) = @_; + my ($self, $prefix, $dcvars) = @_; + + # If we didn't build with ADS, pretend this env was never available + if (not $self->have_ads()) { + return "UNKNOWN"; + } - print "PROVISIONING S3 AD MEMBER$iface..."; + print "PROVISIONING S3 AD MEMBER..."; my $member_options = " security = ads @@ -212,9 +301,8 @@ sub setup_admember($$$$) "; my $ret = $self->provision($prefix, - "LOCALADMEMBER$iface", - $iface, - "loCalMember${iface}Pass", + "LOCALADMEMBER", + "loCalMemberPass", $member_options); $ret or return undef; @@ -252,13 +340,13 @@ sub setup_admember($$$$) # access the share for tests. chmod 0777, "$prefix/share"; - $self->check_or_start($ret, - "yes", "yes", "yes"); - - $self->wait_for_start($ret); + if (not $self->check_or_start($ret, "yes", "yes", "yes")) { + return undef; + } $ret->{DC_SERVER} = $dcvars->{SERVER}; $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP}; + $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6}; $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME}; $ret->{DC_USERNAME} = $dcvars->{USERNAME}; $ret->{DC_PASSWORD} = $dcvars->{PASSWORD}; @@ -269,72 +357,79 @@ sub setup_admember($$$$) return $ret; } -sub setup_plugin_s4_dc($$$$) +sub setup_admember_rfc2307($$$$) { - my ($self, $prefix, $dcvars, $iface) = @_; + my ($self, $prefix, $dcvars) = @_; - print "PROVISIONING S4 PLUGIN AD DC$iface..."; + # If we didn't build with ADS, pretend this env was never available + if (not $self->have_ads()) { + return "UNKNOWN"; + } + + print "PROVISIONING S3 AD MEMBER WITH idmap_rfc2307 config..."; - my $plugin_s4_dc_options = " + my $member_options = " + security = ads + server signing = on workgroup = $dcvars->{DOMAIN} realm = $dcvars->{REALM} - - security = ads - domain logons = yes - passdb backend = samba4 - auth methods = guest samba4 - server signing = on - - rpc_server:epmapper = disabled - rpc_server:rpcecho = disabled - rpc_server:dssetup = disabled - rpc_server:svctl = disabled - rpc_server:ntsvcs = disabled - rpc_server:eventlog = disabled - rpc_server:initshutdown = disabled - - rpc_server:winreg = embedded - rpc_server:srvsvc = embedded - rpc_server:netdfs = embedded - rpc_server:wkssvc = embedded - rpc_server:spoolss = embedded - - rpc_server:lsarpc = external - rpc_server:netlogon = external - rpc_server:samr = external - - rpc_daemon:epmd = disabled - rpc_daemon:lsasd = disabled - rpc_daemon:spoolssd = disabled - - rpc_server:tcpip = no - -[IPC\$] - vfs objects = dfs_samba4 + idmap config $dcvars->{DOMAIN} : backend = rfc2307 + idmap config $dcvars->{DOMAIN} : range = 2000000-2999999 + idmap config $dcvars->{DOMAIN} : ldap_server = ad + idmap config $dcvars->{DOMAIN} : bind_path_user = ou=idmap,dc=samba,dc=example,dc=com + idmap config $dcvars->{DOMAIN} : bind_path_group = ou=idmap,dc=samba,dc=example,dc=com "; my $ret = $self->provision($prefix, - "plugindc", - $iface, - "pluGin${iface}Pass", - $plugin_s4_dc_options, 1); + "RFC2307MEMBER", + "loCalMemberPass", + $member_options); $ret or return undef; close(USERMAP); $ret->{DOMAIN} = $dcvars->{DOMAIN}; $ret->{REALM} = $dcvars->{REALM}; - $ret->{KRB5_CONFIG} = $dcvars->{KRB5_CONFIG}; + + my $ctx; + my $prefix_abs = abs_path($prefix); + $ctx = {}; + $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf"; + $ctx->{domain} = $dcvars->{DOMAIN}; + $ctx->{realm} = $dcvars->{REALM}; + $ctx->{dnsname} = lc($dcvars->{REALM}); + $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP}; + Samba::mk_krb5_conf($ctx, ""); + + $ret->{KRB5_CONFIG} = $ctx->{krb5_conf}; + + my $net = Samba::bindir_path($self, "net"); + my $cmd = ""; + $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" "; + $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" "; + $cmd .= "$net join $ret->{CONFIGURATION}"; + $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}"; + + if (system($cmd) != 0) { + warn("Join failed\n$cmd"); + return undef; + } # We need world access to this share, as otherwise the domain # administrator from the AD domain provided by Samba4 can't # access the share for tests. chmod 0777, "$prefix/share"; - $self->check_or_start($ret, - "no", "no", "yes"); + if (not $self->check_or_start($ret, "yes", "yes", "yes")) { + return undef; + } - $self->wait_for_start($ret); + $ret->{DC_SERVER} = $dcvars->{SERVER}; + $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP}; + $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6}; + $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME}; + $ret->{DC_USERNAME} = $dcvars->{USERNAME}; + $ret->{DC_PASSWORD} = $dcvars->{PASSWORD}; # Special case, this is called from Samba4.pm but needs to use the Samba3 check_env and get_log_env $ret->{target} = $self; @@ -342,74 +437,50 @@ sub setup_plugin_s4_dc($$$$) return $ret; } -sub setup_secshare($$) +sub setup_simpleserver($$) { my ($self, $path) = @_; print "PROVISIONING server with security=share..."; - my $secshare_options = " - security = share + my $prefix_abs = abs_path($path); + + my $simpleserver_options = " lanman auth = yes + vfs objects = xattr_tdb streams_depot + +[vfs_aio_fork] + path = $prefix_abs/share + vfs objects = aio_fork + read only = no + vfs_aio_fork:erratic_testing_mode=yes "; my $vars = $self->provision($path, "LOCALSHARE4", - 4, "local4pass", - $secshare_options); + $simpleserver_options); $vars or return undef; - $self->check_or_start($vars, "yes", "no", "yes"); - - if (not $self->wait_for_start($vars)) { + if (not $self->check_or_start($vars, "yes", "no", "yes")) { return undef; } - $self->{vars}->{secshare} = $vars; + $self->{vars}->{simpleserver} = $vars; return $vars; } -sub setup_secserver($$$) -{ - my ($self, $prefix, $s3dcvars) = @_; - - print "PROVISIONING server with security=server..."; - - my $secserver_options = " - security = server - password server = $s3dcvars->{SERVER_IP} -"; - - my $ret = $self->provision($prefix, - "LOCALSERVER5", - 5, - "localserver5pass", - $secserver_options); - - $ret or return undef; - - $self->check_or_start($ret, "yes", "no", "yes"); - - if (not $self->wait_for_start($ret)) { - return undef; - } - - $ret->{DC_SERVER} = $s3dcvars->{SERVER}; - $ret->{DC_SERVER_IP} = $s3dcvars->{SERVER_IP}; - $ret->{DC_NETBIOSNAME} = $s3dcvars->{NETBIOSNAME}; - $ret->{DC_USERNAME} = $s3dcvars->{USERNAME}; - $ret->{DC_PASSWORD} = $s3dcvars->{PASSWORD}; - - return $ret; -} - sub setup_ktest($$$) { my ($self, $prefix) = @_; + # If we didn't build with ADS, pretend this env was never available + if (not $self->have_ads()) { + return "UNKNOWN"; + } + print "PROVISIONING server with security=ads..."; my $ktest_options = " @@ -417,11 +488,11 @@ sub setup_ktest($$$) realm = ktest.samba.example.com security = ads username map = $prefix/lib/username.map + server signing = required "; my $ret = $self->provision($prefix, "LOCALKTEST6", - 6, "localktest6pass", $ktest_options); @@ -452,6 +523,9 @@ $ret->{USERNAME} = KTEST\\Administrator system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb"); chmod 0600, "$prefix/private/secrets.tdb"; +#Make sure there's no old ntdb file. + system("rm -f $prefix/private/secrets.ntdb"); + #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with: # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232" # @@ -488,9 +562,7 @@ $ret->{USERNAME} = KTEST\\Administrator # access the share for tests. chmod 0777, "$prefix/share"; - $self->check_or_start($ret, "yes", "no", "yes"); - - if (not $self->wait_for_start($ret)) { + if (not $self->check_or_start($ret, "yes", "no", "yes")) { return undef; } return $ret; @@ -508,16 +580,12 @@ map to guest = bad user my $vars = $self->provision($path, "maptoguest", - 7, "maptoguestpass", $options); $vars or return undef; - $self->check_or_start($vars, - "yes", "no", "yes"); - - if (not $self->wait_for_start($vars)) { + if (not $self->check_or_start($vars, "yes", "no", "yes")) { return undef; } @@ -558,6 +626,11 @@ sub read_pid($$) sub check_or_start($$$$$) { my ($self, $env_vars, $nmbd, $winbindd, $smbd) = @_; + # use a pipe for stdin in the child processes. This allows + # those processes to monitor the pipe for EOF to ensure they + # exit when the test script exits + pipe(STDIN_READER, $env_vars->{STDIN_PIPE}); + unlink($env_vars->{NMBD_TEST_LOG}); print "STARTING NMBD..."; my $pid = fork(); @@ -568,14 +641,16 @@ sub check_or_start($$$$$) { SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE}); $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG}; - $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR}; + $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR}; $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR}; $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD}; $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP}; - $ENV{NSS_WRAPPER_WINBIND_SO_PATH} = $env_vars->{NSS_WRAPPER_WINBIND_SO_PATH}; + $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS}; + $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH}; + $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX}; - $ENV{UID_WRAPPER} = "1"; + $ENV{ENVNAME} = "$ENV{ENVNAME}.nmbd"; if ($nmbd ne "yes") { $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub { @@ -587,20 +662,29 @@ sub check_or_start($$$$$) { exit 0; } + $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "nmbd"); my @optargs = ("-d0"); if (defined($ENV{NMBD_OPTIONS})) { @optargs = split(/ /, $ENV{NMBD_OPTIONS}); } - - $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "nmbd"); - my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime}); if(defined($ENV{NMBD_VALGRIND})) { @preargs = split(/ /, $ENV{NMBD_VALGRIND}); } + my @args = ("-F", "--no-process-group", + "-s", $env_vars->{SERVERCONFFILE}, + "-l", $env_vars->{LOGDIR}); + if (not defined($ENV{NMBD_DONT_LOG_STDOUT})) { + push(@args, "--log-stdout"); + } - exec(@preargs, Samba::bindir_path($self, "nmbd"), "-F", "--no-process-group", "--log-stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start nmbd: $!"); + close($env_vars->{STDIN_PIPE}); + open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!"; + + exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs) + or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!"); } + $env_vars->{NMBD_TL_PID} = $pid; write_pid($env_vars, "nmbd", $pid); print "DONE\n"; @@ -614,14 +698,16 @@ sub check_or_start($$$$$) { SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE}); $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG}; - $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR}; + $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR}; $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR}; $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD}; $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP}; - $ENV{NSS_WRAPPER_WINBIND_SO_PATH} = $env_vars->{NSS_WRAPPER_WINBIND_SO_PATH}; + $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS}; + $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH}; + $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX}; - $ENV{UID_WRAPPER} = "1"; + $ENV{ENVNAME} = "$ENV{ENVNAME}.winbindd"; if ($winbindd ne "yes") { $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub { @@ -633,22 +719,29 @@ sub check_or_start($$$$$) { exit 0; } + $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "winbindd"); my @optargs = ("-d0"); if (defined($ENV{WINBINDD_OPTIONS})) { @optargs = split(/ /, $ENV{WINBINDD_OPTIONS}); } - - $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "winbindd"); - my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime}); if(defined($ENV{WINBINDD_VALGRIND})) { @preargs = split(/ /, $ENV{WINBINDD_VALGRIND}); } + my @args = ("-F", "--no-process-group", + "-s", $env_vars->{SERVERCONFFILE}, + "-l", $env_vars->{LOGDIR}); + if (not defined($ENV{WINBINDD_DONT_LOG_STDOUT})) { + push(@args, "--stdout"); + } - print "Starting winbindd with config $env_vars->{SERVERCONFFILE}\n"; + close($env_vars->{STDIN_PIPE}); + open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!"; - exec(@preargs, Samba::bindir_path($self, "winbindd"), "-F", "--no-process-group", "--stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start winbindd: $!"); + exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs) + or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!"); } + $env_vars->{WINBINDD_TL_PID} = $pid; write_pid($env_vars, "winbindd", $pid); print "DONE\n"; @@ -662,14 +755,16 @@ sub check_or_start($$$$$) { SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE}); $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG}; - $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR}; + $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR}; $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR}; $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD}; $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP}; - $ENV{NSS_WRAPPER_WINBIND_SO_PATH} = $env_vars->{NSS_WRAPPER_WINBIND_SO_PATH}; + $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS}; + $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH}; + $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX}; - $ENV{UID_WRAPPER} = "1"; + $ENV{ENVNAME} = "$ENV{ENVNAME}.smbd"; if ($smbd ne "yes") { $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub { @@ -690,24 +785,40 @@ sub check_or_start($$$$$) { if(defined($ENV{SMBD_VALGRIND})) { @preargs = split(/ /,$ENV{SMBD_VALGRIND}); } - exec(@preargs, Samba::bindir_path($self, "smbd"), "-F", "--no-process-group", "--log-stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start smbd: $!"); + my @args = ("-F", "--no-process-group", + "-s", $env_vars->{SERVERCONFFILE}, + "-l", $env_vars->{LOGDIR}); + if (not defined($ENV{SMBD_DONT_LOG_STDOUT})) { + push(@args, "--log-stdout"); + } + + close($env_vars->{STDIN_PIPE}); + open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!"; + + exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs) + or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!"); } + $env_vars->{SMBD_TL_PID} = $pid; write_pid($env_vars, "smbd", $pid); print "DONE\n"; - return 0; + close(STDIN_READER); + + return $self->wait_for_start($env_vars, $nmbd, $winbindd, $smbd); } -sub provision($$$$$$$) +sub provision($$$$$$) { - my ($self, $prefix, $server, $swiface, $password, $extra_options, $no_delete_prefix) = @_; + my ($self, $prefix, $server, $password, $extra_options, $no_delete_prefix) = @_; ## ## setup the various environment variables we need ## + my $swiface = Samba::get_interface($server); my %ret = (); my $server_ip = "127.0.0.$swiface"; + my $server_ipv6 = sprintf("fd00:0000:0000:0000:0000:0000:5357:5f%02x", $swiface); my $domain = "SAMBA-TEST"; my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`); @@ -718,7 +829,6 @@ sub provision($$$$$$$) my $prefix_abs = abs_path($prefix); my $bindir_abs = abs_path($self->{bindir}); - my $vfs_modulesdir_abs = ($ENV{VFSLIBDIR} or $bindir_abs); my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file"; @@ -783,6 +893,15 @@ sub provision($$$$$$$) } mkdir($_, 0777) foreach(@dirs); + my $fs_specific_conf = $self->get_fs_specific_conf($shrdir); + + ## + ## lockdir and piddir must be 0755 + ## + chmod 0755, $lockdir; + chmod 0755, $piddir; + + ## ## create ro and msdfs share layout ## @@ -804,13 +923,14 @@ sub provision($$$$$$$) close(MSDFS_TARGET); chmod 0666, $msdfs_target; symlink "msdfs:$server_ip\\ro-tmp", "$msdfs_shrdir/msdfs-src1"; - symlink "msdfs:$server_ip\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2"; + symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2"; my $conffile="$libdir/server.conf"; my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/lib/nss_wrapper/nss_wrapper.pl"; my $nss_wrapper_passwd = "$privatedir/passwd"; my $nss_wrapper_group = "$privatedir/group"; + my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts"; my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl"; @@ -821,10 +941,10 @@ sub provision($$$$$$$) ## my ($max_uid, $max_gid); - my ($uid_nobody, $uid_root); - my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers); + my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2); + my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins); - if ($unix_uid < 0xffff - 2) { + if ($unix_uid < 0xffff - 4) { $max_uid = 0xffff; } else { $max_uid = $unix_uid; @@ -832,8 +952,10 @@ sub provision($$$$$$$) $uid_root = $max_uid - 1; $uid_nobody = $max_uid - 2; + $uid_pdbtest = $max_uid - 3; + $uid_pdbtest2 = $max_uid - 4; - if ($unix_gids[0] < 0xffff - 3) { + if ($unix_gids[0] < 0xffff - 5) { $max_gid = 0xffff; } else { $max_gid = $unix_gids[0]; @@ -843,6 +965,7 @@ sub provision($$$$$$$) $gid_nogroup = $max_gid - 2; $gid_root = $max_gid - 3; $gid_domusers = $max_gid - 4; + $gid_domadmins = $max_gid - 5; ## ## create conffile @@ -855,9 +978,10 @@ sub provision($$$$$$$) print CONF " [global] netbios name = $server - interfaces = $server_ip/8 + interfaces = $server_ip/8 $server_ipv6/64 bind interfaces only = yes - panic action = $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY) + panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY) + smbd:suicide mode = yes workgroup = $domain @@ -865,7 +989,7 @@ sub provision($$$$$$$) pid directory = $piddir lock directory = $lockdir log file = $logdir/log.\%m - log level = 0 + log level = 1 debug pid = yes max log size = 0 @@ -896,27 +1020,27 @@ sub provision($$$$$$$) printing = bsd printcap name = /dev/null - winbindd:socket dir = $wbsockdir + winbindd socket directory = $wbsockdir nmbd:socket dir = $nmbdsockdir idmap config * : range = 100000-200000 winbind enum users = yes winbind enum groups = yes + winbind separator = / # min receivefile size = 4000 - max protocol = SMB2 read only = no server signing = auto smbd:sharedelay = 100000 -# smbd:writetimeupdatedelay = 500000 + smbd:writetimeupdatedelay = 500000 map hidden = no map system = no map readonly = no store dos attributes = yes create mask = 755 dos filemode = yes - vfs objects = $vfs_modulesdir_abs/xattr_tdb.so $vfs_modulesdir_abs/streams_depot.so + vfs objects = acl_xattr fake_acls xattr_tdb streams_depot printing = vlp print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s @@ -927,19 +1051,9 @@ sub provision($$$$$$$) queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p lpq cache time = 0 + print notify backchannel = yes ncalrpc dir = $prefix_abs/ncalrpc - rpc_server:epmapper = external - rpc_server:spoolss = external - rpc_server:lsarpc = external - rpc_server:samr = external - rpc_server:netlogon = external - rpc_server:tcpip = yes - - rpc_daemon:epmd = fork - rpc_daemon:spoolssd = fork - rpc_daemon:lsasd = fork - resolv:host file = $dns_host_file # The samba3.blackbox.smbclient_s3 test uses this to test that @@ -961,6 +1075,15 @@ sub provision($$$$$$$) [tmp] path = $shrdir comment = smb username is [%U] +[tmpsort] + path = $shrdir + comment = Load dirsort module + vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot +[tmpenc] + path = $shrdir + comment = encrypt smb username is [%U] + smb encrypt = required + vfs objects = dirsort [tmpguest] path = $shrdir guest ok = yes @@ -979,6 +1102,13 @@ sub provision($$$$$$$) [ro-tmp] path = $ro_shrdir guest ok = yes +[write-list-tmp] + path = $shrdir + read only = yes + write list = $unix_name +[valid-users-tmp] + path = $shrdir + valid users = $unix_name [msdfs-share] path = $msdfs_shrdir msdfs root = yes @@ -992,6 +1122,14 @@ sub provision($$$$$$$) [hideunwrite] copy = tmp hide unwriteable files = yes +[durable] + copy = tmp + kernel share modes = no + kernel oplocks = no + posix locking = no +[fs_specific] + copy = tmp + $fs_specific_conf [print1] copy = tmp printable = yes @@ -1000,15 +1138,50 @@ sub provision($$$$$$$) copy = print1 [print3] copy = print1 + default devmode = no [lp] copy = print1 + +[nfs4acl_simple] + path = $shrdir + comment = smb username is [%U] + nfs4:mode = simple + vfs objects = nfs4acl_xattr xattr_tdb + +[nfs4acl_special] + path = $shrdir + comment = smb username is [%U] + nfs4:mode = special + vfs objects = nfs4acl_xattr xattr_tdb + [xcopy_share] path = $shrdir comment = smb username is [%U] create mask = 777 force create mode = 777 +[posix_share] + path = $shrdir + comment = smb username is [%U] + create mask = 0777 + force create mode = 0 + directory mask = 0777 + force directory mode = 0 + vfs objects = xattr_tdb +[aio] + copy = tmp + aio read size = 1 + aio write size = 1 + [print\$] copy = tmp + +[vfs_fruit] + path = $shrdir + vfs objects = catia fruit streams_xattr + fruit:ressource = file + fruit:metadata = netatalk + fruit:locking = netatalk + fruit:encoding = native "; close(CONF); @@ -1022,9 +1195,12 @@ sub provision($$$$$$$) } print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false +pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false +pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false "; if ($unix_uid != 0) { - print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false"; + print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false +"; } close(PASSWD); @@ -1036,13 +1212,26 @@ $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false nogroup:x:$gid_nogroup:nobody $unix_name-group:x:$unix_gids[0]: domusers:X:$gid_domusers: +domadmins:X:$gid_domadmins: "; if ($unix_gids[0] != 0) { - print GROUP "root:x:$gid_root:"; + print GROUP "root:x:$gid_root: +"; } close(GROUP); + ## hosts + my $hostname = lc($server); + unless (open(HOSTS, ">>$nss_wrapper_hosts")) { + warn("Unable to open $nss_wrapper_hosts"); + return undef; + } + print HOSTS "${server_ip} ${hostname}.samba.example.com ${hostname}\n"; + print HOSTS "${server_ipv6} ${hostname}.samba.example.com ${hostname}\n"; + close(HOSTS); + + foreach my $evlog (@eventlog_list) { my $evlogtdb = "$eventlogdir/$evlog.tdb"; open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb"); @@ -1051,8 +1240,9 @@ domusers:X:$gid_domusers: $ENV{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd; $ENV{NSS_WRAPPER_GROUP} = $nss_wrapper_group; + $ENV{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts; - my $cmd = Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $unix_name > /dev/null"; + my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $unix_name > /dev/null"; unless (open(PWD, "|$cmd")) { warn("Unable to set password for test account\n$cmd"); return undef; @@ -1064,12 +1254,17 @@ domusers:X:$gid_domusers: } print "DONE\n"; - open(HOSTS, ">>$ENV{SELFTEST_PREFIX}/dns_host_file") or die("Unable to open $ENV{SELFTEST_PREFIX}/dns_host_file"); - print HOSTS "A $server. $server_ip -"; - close(HOSTS); + open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list"); + print DNS_UPDATE_LIST "A $server. $server_ip\n"; + print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n"; + close(DNS_UPDATE_LIST); + + if (system("$ENV{SRCDIR_ABS}/source4/scripting/bin/samba_dnsupdate --all-interfaces --use-file=$dns_host_file -s $conffile --update-list=$prefix/dns_update_list --update-cache=$prefix/dns_update_cache --no-substiutions --no-credentials") != 0) { + die "Unable to update hostname into $dns_host_file"; + } $ret{SERVER_IP} = $server_ip; + $ret{SERVER_IPV6} = $server_ipv6; $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log"; $ret{NMBD_TEST_LOG_POS} = 0; $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log"; @@ -1085,57 +1280,123 @@ domusers:X:$gid_domusers: $ret{NETBIOSNAME} = $server; $ret{PASSWORD} = $password; $ret{PIDDIR} = $piddir; - $ret{WINBINDD_SOCKET_DIR} = $wbsockdir; + $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir; $ret{WINBINDD_PRIV_PIPE_DIR} = $wbsockprivdir; $ret{NMBD_SOCKET_DIR} = $nmbdsockdir; $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface; $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd; $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group; - $ret{NSS_WRAPPER_WINBIND_SO_PATH} = $ENV{NSS_WRAPPER_WINBIND_SO_PATH}; - if (not defined($ret{NSS_WRAPPER_WINBIND_SO_PATH})) { - $ret{NSS_WRAPPER_WINBIND_SO_PATH} = Samba::bindir_path($self, "default/nsswitch/libnss-winbind.so"); - } + $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts; + $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self); + $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind"; $ret{LOCAL_PATH} = "$shrdir"; + $ret{LOGDIR} = $logdir; return \%ret; } -sub wait_for_start($$) +sub wait_for_start($$$$$) { - my ($self, $envvars) = @_; + my ($self, $envvars, $nmbd, $winbindd, $smbd) = @_; + my $ret; - # give time for nbt server to register its names - print "delaying for nbt name registration\n"; - sleep(10); - # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init - system(Samba::bindir_path($self, "nmblookup3") ." $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__"); - system(Samba::bindir_path($self, "nmblookup3") ." $envvars->{CONFIGURATION} __SAMBA__"); - system(Samba::bindir_path($self, "nmblookup3") ." $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__"); - system(Samba::bindir_path($self, "nmblookup3") ." $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}"); - system(Samba::bindir_path($self, "nmblookup3") ." $envvars->{CONFIGURATION} $envvars->{SERVER}"); + if ($nmbd eq "yes") { + my $count = 0; - # make sure smbd is also up set - print "wait for smbd\n"; + # give time for nbt server to register its names + print "checking for nmbd\n"; - my $count = 0; - my $ret; - do { - $ret = system(Samba::bindir_path($self, "smbclient3") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139"); - if ($ret != 0) { - sleep(2); + # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init + my $nmblookup = Samba::bindir_path($self, "nmblookup"); + + do { + $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}"); + if ($ret != 0) { + sleep(1); + } else { + system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__"); + system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__"); + system("$nmblookup $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__"); + system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}"); + } + $count++; + } while ($ret != 0 && $count < 10); + if ($count == 10) { + print "NMBD not reachable after 10 retries\n"; + teardown_env($self, $envvars); + return 0; + } + } + + if ($winbindd eq "yes") { + print "checking for winbindd\n"; + my $count = 0; + do { + $ret = system("SELFTEST_WINBINDD_SOCKET_DIR=" . $envvars->{SELFTEST_WINBINDD_SOCKET_DIR} . " " . Samba::bindir_path($self, "wbinfo") . " --ping-dc"); + if ($ret != 0) { + sleep(2); + } + $count++; + } while ($ret != 0 && $count < 10); + if ($count == 10) { + print "WINBINDD not reachable after 20 seconds\n"; + teardown_env($self, $envvars); + return 0; + } + } + + if ($smbd eq "yes") { + # make sure smbd is also up set + print "wait for smbd\n"; + + my $count = 0; + do { + $ret = system(Samba::bindir_path($self, "smbclient3") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139"); + if ($ret != 0) { + sleep(2); + } + $count++ + } while ($ret != 0 && $count < 10); + if ($count == 10) { + print "SMBD failed to start up in a reasonable time (20sec)\n"; + teardown_env($self, $envvars); + return 0; } - $count++ - } while ($ret != 0 && $count < 10); - if ($count == 10) { - print "SMBD failed to start up in a reasonable time (20sec)\n"; - teardown_env($self, $envvars); - return 0; } + # Ensure we have domain users mapped. $ret = system(Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} groupmap add rid=513 unixgroup=domusers type=domain"); if ($ret != 0) { return 1; } + $ret = system(Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} groupmap add rid=512 unixgroup=domadmins type=domain"); + if ($ret != 0) { + return 1; + } + + if ($winbindd eq "yes") { + # note: creating builtin groups requires winbindd for the + # unix id allocator + $ret = system("SELFTEST_WINBINDD_SOCKET_DIR=" . $envvars->{SELFTEST_WINBINDD_SOCKET_DIR} . " " . Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} sam createbuiltingroup Users"); + if ($ret != 0) { + print "Failed to create BUILTIN\\Users group\n"; + return 0; + } + my $count = 0; + do { + system(Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} cache flush"); + $ret = system("SELFTEST_WINBINDD_SOCKET_DIR=" . $envvars->{SELFTEST_WINBINDD_SOCKET_DIR} . " " . Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545"); + if ($ret != 0) { + sleep(2); + } + $count++; + } while ($ret != 0 && $count < 10); + if ($count == 10) { + print "WINBINDD not reachable after 20 seconds\n"; + teardown_env($self, $envvars); + return 0; + } + } print $self->getlog_env($envvars);