2 # Bootstrap Samba and run a number of tests against it.
3 # Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
4 # Published under the GNU GPL, v3 or later.
6 # NOTE: Refer to the README for more details about the various testenvs,
7 # and tips about adding new testenvs.
14 use FindBin qw($RealBin);
17 use File::Path 'remove_tree';
21 my ($self, $path, $env) = @_;
30 my $smbd_build_options = Samba::bindir_path($self, "smbd") . " -b|";
31 open(IN, $smbd_build_options) or die("Unable to run $smbd_build_options: $!");
40 # If we were not built with ADS support, pretend we were never even available
41 print "smbd does not have ADS support\n" unless $found_ads;
45 # return smb.conf parameters applicable to @path, based on the underlying
47 sub get_fs_specific_conf($$)
49 my ($self, $path) = @_;
51 my $stat_out = `stat --file-system $path` or return "";
53 if ($stat_out =~ m/Type:\s+btrfs/) {
54 $mods .= "streams_xattr btrfs";
58 return "vfs objects = $mods";
65 my ($classname, $SambaCtx, $bindir, $srcdir, $server_maxtime) = @_;
66 my $self = { vars => {},
67 SambaCtx => $SambaCtx,
70 server_maxtime => $server_maxtime
78 my ($self, $envvars) = @_;
80 if (defined($envvars->{CTDB_PREFIX})) {
81 $self->teardown_env_ctdb($envvars);
83 $self->teardown_env_samba($envvars);
89 sub teardown_env_samba($$)
91 my ($self, $envvars) = @_;
94 # This should cause smbd to terminate gracefully
95 close($envvars->{STDIN_PIPE});
97 my $smbdpid = $envvars->{SMBD_TL_PID};
98 my $nmbdpid = $envvars->{NMBD_TL_PID};
99 my $winbinddpid = $envvars->{WINBINDD_TL_PID};
101 # This should give it time to write out the gcov data
102 until ($count > 20) {
103 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
104 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
105 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
108 && $winbinddchild == -1) {
115 if ($count <= 20 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
119 $self->stop_sig_term($smbdpid);
120 $self->stop_sig_term($nmbdpid);
121 $self->stop_sig_term($winbinddpid);
124 until ($count > 10) {
125 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
126 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
127 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
130 && $winbinddchild == -1) {
137 if ($count <= 10 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
141 warn("timelimit process did not quit on SIGTERM, sending SIGKILL");
142 $self->stop_sig_kill($smbdpid);
143 $self->stop_sig_kill($nmbdpid);
144 $self->stop_sig_kill($winbinddpid);
149 sub teardown_env_ctdb($$)
151 my ($self, $data) = @_;
153 if (defined($data->{SAMBA_NODES})) {
154 my $num_nodes = $data->{NUM_NODES};
155 my $nodes = $data->{SAMBA_NODES};
157 for (my $i = 0; $i < $num_nodes; $i++) {
158 if (defined($nodes->[$i])) {
159 $self->teardown_env_samba($nodes->[$i]);
164 close($data->{CTDB_STDIN_PIPE});
166 if (not defined($data->{SAMBA_NODES})) {
167 # Give waiting children time to exit
174 sub getlog_env_app($$$)
176 my ($self, $envvars, $name) = @_;
178 my $title = "$name LOG of: $envvars->{NETBIOSNAME}\n";
181 open(LOG, "<".$envvars->{$name."_TEST_LOG"});
183 seek(LOG, $envvars->{$name."_TEST_LOG_POS"}, SEEK_SET);
187 $envvars->{$name."_TEST_LOG_POS"} = tell(LOG);
190 return "" if $out eq $title;
197 my ($self, $envvars) = @_;
200 $ret .= $self->getlog_env_app($envvars, "SMBD");
201 $ret .= $self->getlog_env_app($envvars, "NMBD");
202 $ret .= $self->getlog_env_app($envvars, "WINBINDD");
209 my ($self, $envvars) = @_;
211 my $childpid = waitpid(-1, WNOHANG);
217 # Declare the environments Samba3 makes available.
218 # To be set up, they will be called as
219 # samba3->setup_$envname($self, $path, $dep_1_vars, $dep_2_vars, ...)
220 %Samba3::ENV_DEPS = (
221 # name => [dep_1, dep_2, ...],
224 nt4_dc_smb1_done => ["nt4_dc_smb1"],
225 nt4_dc_schannel => [],
229 fileserver_smb1 => [],
230 fileserver_smb1_done => ["fileserver_smb1"],
234 nt4_member => ["nt4_dc"],
236 ad_member => ["ad_dc", "fl2008r2dc", "fl2003dc"],
237 ad_member_rfc2307 => ["ad_dc_ntvfs"],
238 ad_member_idmap_rid => ["ad_dc"],
239 ad_member_idmap_ad => ["fl2008r2dc"],
240 ad_member_fips => ["ad_dc_fips"],
242 clusteredmember_smb1 => ["nt4_dc"],
245 %Samba3::ENV_DEPS_POST = ();
249 my ($self, $path, $more_conf, $server) = @_;
251 print "PROVISIONING NT4 DC...";
253 my $nt4_dc_options = "
258 raw NTLMv2 auth = yes
259 server schannel = auto
261 rpc_server:epmapper = external
262 rpc_server:spoolss = external
263 rpc_server:lsarpc = external
264 rpc_server:samr = external
265 rpc_server:netlogon = external
266 rpc_server:register_embedded_np = yes
267 rpc_server:FssagentRpc = external
269 rpc_daemon:epmd = fork
270 rpc_daemon:spoolssd = fork
271 rpc_daemon:lsasd = fork
272 rpc_daemon:fssd = fork
273 fss: sequence timeout = 1
274 check parent directory delete on close = yes
277 if (defined($more_conf)) {
278 $nt4_dc_options = $nt4_dc_options . $more_conf;
280 if (!defined($server)) {
281 $server = "LOCALNT4DC2";
283 my $vars = $self->provision(
285 domain => "SAMBA-TEST",
287 password => "localntdc2pass",
288 extra_options => $nt4_dc_options);
290 $vars or return undef;
292 if (not $self->check_or_start(
300 $vars->{DOMSID} = $vars->{SAMSID};
301 $vars->{DC_SERVER} = $vars->{SERVER};
302 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
303 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
304 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
305 $vars->{DC_USERNAME} = $vars->{USERNAME};
306 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
311 sub setup_nt4_dc_smb1
313 my ($self, $path) = @_;
316 client min protocol = CORE
317 server min protocol = LANMAN1
319 return $self->setup_nt4_dc($path, $conf, "LCLNT4DC2SMB1");
322 sub setup_nt4_dc_smb1_done
324 my ($self, $path, $dep_env) = @_;
325 return $self->return_alias_env($path, $dep_env);
328 sub setup_nt4_dc_schannel
330 my ($self, $path) = @_;
332 print "PROVISIONING NT4 DC WITH SERVER SCHANNEL ...";
339 rpc_server:epmapper = external
340 rpc_server:spoolss = external
341 rpc_server:lsarpc = external
342 rpc_server:samr = external
343 rpc_server:netlogon = external
344 rpc_server:register_embedded_np = yes
346 rpc_daemon:epmd = fork
347 rpc_daemon:spoolssd = fork
348 rpc_daemon:lsasd = fork
350 server schannel = yes
351 # used to reproduce bug #12772
352 server max protocol = SMB2_02
355 my $vars = $self->provision(
357 domain => "NT4SCHANNEL",
358 server => "LOCALNT4DC9",
359 password => "localntdc9pass",
360 extra_options => $pdc_options);
362 $vars or return undef;
364 if (not $self->check_or_start(
372 $vars->{DOMSID} = $vars->{SAMSID};
373 $vars->{DC_SERVER} = $vars->{SERVER};
374 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
375 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
376 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
377 $vars->{DC_USERNAME} = $vars->{USERNAME};
378 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
385 my ($self, $prefix, $nt4_dc_vars) = @_;
389 print "PROVISIONING MEMBER...";
391 my $require_mutexes = "dbwrap_tdb_require_mutexes:* = yes";
392 if ($ENV{SELFTEST_DONT_REQUIRE_TDB_MUTEX_SUPPORT} // '' eq "1") {
393 $require_mutexes = "";
396 my $member_options = "
398 dbwrap_tdb_mutexes:* = yes
401 my $ret = $self->provision(
403 domain => $nt4_dc_vars->{DOMAIN},
404 server => "LOCALNT4MEMBER3",
405 password => "localnt4member3pass",
406 extra_options => $member_options);
408 $ret or return undef;
410 my $nmblookup = Samba::bindir_path($self, "nmblookup");
412 print "Waiting for the LOGON SERVER registration ...\n";
413 $rc = system("$nmblookup $ret->{CONFIGURATION} $ret->{DOMAIN}\#1c");
418 } while ($rc != 0 && $count < 10);
420 print "NMBD not reachable after 10 retries\n";
421 teardown_env($self, $ret);
425 my $net = Samba::bindir_path($self, "net");
426 # Add hosts file for name lookups
427 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
428 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
429 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
430 $cmd .= "$net rpc join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
431 $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}";
433 if (system($cmd) != 0) {
434 warn("Join failed\n$cmd");
438 # Add hosts file for name lookups
439 $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
440 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
441 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
442 $cmd .= "$net $ret->{CONFIGURATION} primarytrust dumpinfo | grep -q 'REDACTED SECRET VALUES'";
444 if (system($cmd) != 0) {
445 warn("check failed\n$cmd");
449 if (not $self->check_or_start(
457 $ret->{DOMSID} = $nt4_dc_vars->{DOMSID};
458 $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
459 $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
460 $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
461 $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME};
462 $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME};
463 $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD};
468 sub setup_clusteredmember_smb1
470 my ($self, $prefix, $nt4_dc_vars) = @_;
476 print "PROVISIONING CLUSTEREDMEMBER...\n";
478 my $prefix_abs = abs_path($prefix);
479 mkdir($prefix_abs, 0777);
481 my $server_name = "CLUSTEREDMEMBER";
483 my $ctdb_data = $self->setup_ctdb($prefix);
485 if (not $ctdb_data) {
486 print "No ctdb data\n";
490 print "PROVISIONING CLUSTERED SAMBA...\n";
492 my $num_nodes = $ctdb_data->{NUM_NODES};
493 my $nodes = $ctdb_data->{CTDB_NODES};
495 # Enable cleanup of earlier nodes if a later node fails
496 $ctdb_data->{SAMBA_NODES} = \@retvals;
498 for (my $i = 0; $i < $num_nodes; $i++) {
499 my $node = $nodes->[$i];
500 my $socket = $node->{SOCKET_FILE};
501 my $server_name = $node->{SERVER_NAME};
502 my $pub_iface = $node->{SOCKET_WRAPPER_DEFAULT_IFACE};
503 my $node_prefix = $node->{NODE_PREFIX};
505 print "NODE_PREFIX=${node_prefix}\n";
506 print "SOCKET=${socket}\n";
508 my $require_mutexes = "dbwrap_tdb_require_mutexes:* = yes";
509 if ($ENV{SELFTEST_DONT_REQUIRE_TDB_MUTEX_SUPPORT} // '' eq "1") {
510 $require_mutexes = "" ;
513 my $member_options = "
517 ctdbd socket = ${socket}
518 client min protocol = CORE
519 server min protocol = LANMAN1
520 dbwrap_tdb_mutexes:* = yes
524 my $node_ret = $self->provision(
525 prefix => "$node_prefix",
526 domain => $nt4_dc_vars->{DOMAIN},
527 server => "$server_name",
528 password => "clustermember8pass",
529 netbios_name => "CLUSTEREDMEMBER",
530 share_dir => "${prefix_abs}/shared",
531 extra_options => $member_options,
532 no_delete_prefix => 1);
534 print "Provision node $i failed\n";
535 teardown_env($self, $ctdb_data);
539 my $nmblookup = Samba::bindir_path($self, "nmblookup");
541 print "Waiting for the LOGON SERVER registration ...\n";
542 $rc = system("$nmblookup $node_ret->{CONFIGURATION} " .
543 "$node_ret->{DOMAIN}\#1c");
548 } while ($rc != 0 && $count < 10);
551 print "NMBD not reachable after 10 retries\n";
552 teardown_env($self, $node_ret);
553 teardown_env($self, $ctdb_data);
557 push(@retvals, $node_ret);
560 $ret = {%$ctdb_data, %{$retvals[0]}};
562 my $net = Samba::bindir_path($self, "net");
564 $cmd .= "UID_WRAPPER_ROOT=1 ";
565 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
566 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
567 $cmd .= "$net join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
568 $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}";
570 if (system($cmd) != 0) {
571 warn("Join failed\n$cmd");
572 teardown_env($self, $ret);
576 for (my $i=0; $i<@retvals; $i++) {
577 my $node_provision = $retvals[$i];
579 $ok = $self->check_or_start(
580 env_vars => $node_provision,
583 child_cleanup => sub {
585 my $fh = $_->{STDIN_PIPE};
586 close($fh) if defined($fh);
589 teardown_env($self, $ret);
595 # Build a unclist for every share
597 unless (open(NODES, "<$ret->{CTDB_NODES_FILE}")) {
598 warn("Unable to open CTDB nodes file");
599 teardown_env($self, $ret);
606 my $conffile = $ret->{SERVERCONFFILE};
608 $cmd .= 'sed -n -e \'s|^\[\(.*\)\]$|\1|p\'';
609 $cmd .= " \"$conffile\"";
610 $cmd .= " | grep -vx 'global'";
615 warn("Listing shares failed\n$cmd");
616 teardown_env($self, $ret);
621 my $unclistdir = "${prefix_abs}/unclists";
622 mkdir($unclistdir, 0777);
623 foreach my $share (@shares) {
624 my $l = "${unclistdir}/${share}.txt";
625 unless (open(UNCLIST, ">${l}")) {
626 warn("Unable to open UNC list ${l}");
627 teardown_env($self, $ret);
630 foreach my $node (@nodes) {
631 print UNCLIST "//${node}/${share}\n";
636 $ret->{DOMSID} = $nt4_dc_vars->{DOMSID};
637 $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
638 $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
639 $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
640 $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME};
641 $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME};
642 $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD};
647 sub provision_ad_member
654 $force_fips_mode) = @_;
656 my $prefix_abs = abs_path($prefix);
659 mkdir($prefix_abs, 0777);
661 my $share_dir="$prefix_abs/share";
662 push(@dirs, $share_dir);
664 my $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}";
665 push(@dirs, $substitution_path);
667 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice";
668 push(@dirs, $substitution_path);
670 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice/G_domain users";
671 push(@dirs, $substitution_path);
673 # Using '/' as the winbind separator is a bad idea ...
674 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}";
675 push(@dirs, $substitution_path);
677 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice";
678 push(@dirs, $substitution_path);
680 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}";
681 push(@dirs, $substitution_path);
683 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}/domain users";
684 push(@dirs, $substitution_path);
686 my $member_options = "
688 workgroup = $dcvars->{DOMAIN}
689 realm = $dcvars->{REALM}
690 netbios aliases = foo bar
691 template homedir = /home/%D/%G/%U
692 auth event notification = true
693 password server = $dcvars->{SERVER}
694 winbind scan trusted domains = no
695 winbind use krb5 enterprise principals = yes
697 allow dcerpc auth level connect:lsarpc = yes
698 dcesrv:max auth states = 8
700 rpc_server:epmapper = external
701 rpc_server:lsarpc = external
702 rpc_server:samr = external
703 rpc_server:netlogon = disabled
704 rpc_server:register_embedded_np = yes
706 rpc_daemon:epmd = fork
707 rpc_daemon:lsasd = fork
710 path = $share_dir/D_%D/U_%U/G_%G
714 path = $share_dir/D_%D/u_%u/g_%g
719 my $ret = $self->provision(
721 domain => $dcvars->{DOMAIN},
722 server => "LOCALADMEMBER",
723 password => "loCalMemberPass",
724 extra_options => $member_options,
725 resolv_conf => $dcvars->{RESOLV_CONF});
727 $ret or return undef;
729 mkdir($_, 0777) foreach(@dirs);
732 $ret->{DOMAIN} = $dcvars->{DOMAIN};
733 $ret->{REALM} = $dcvars->{REALM};
734 $ret->{DOMSID} = $dcvars->{DOMSID};
738 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
739 $ctx->{domain} = $dcvars->{DOMAIN};
740 $ctx->{realm} = $dcvars->{REALM};
741 $ctx->{dnsname} = lc($dcvars->{REALM});
742 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
743 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
744 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
745 Samba::mk_krb5_conf($ctx, "");
747 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
749 if (defined($force_fips_mode)) {
750 $ret->{GNUTLS_FORCE_FIPS_MODE} = "1";
751 $ret->{OPENSSL_FORCE_FIPS_MODE} = "1";
754 my $net = Samba::bindir_path($self, "net");
755 # Add hosts file for name lookups
756 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
757 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
758 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
759 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
761 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
763 if (defined($force_fips_mode)) {
764 $cmd .= "GNUTLS_FORCE_FIPS_MODE=1 ";
765 $cmd .= "OPENSSL_FORCE_FIPS_MODE=1 ";
767 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
768 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
769 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
770 $cmd .= "$net join $ret->{CONFIGURATION}";
771 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD} -k";
773 if (system($cmd) != 0) {
774 warn("Join failed\n$cmd");
778 # We need world access to this share, as otherwise the domain
779 # administrator from the AD domain provided by Samba4 can't
780 # access the share for tests.
781 chmod 0777, "$prefix/share";
783 if (not $self->check_or_start(
791 $ret->{DC_SERVER} = $dcvars->{SERVER};
792 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
793 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
794 $ret->{DC_SERVERCONFFILE} = $dcvars->{SERVERCONFFILE};
795 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
796 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
797 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
800 $ret->{TRUST_F_BOTH_SERVER} = $trustvars_f->{SERVER};
801 $ret->{TRUST_F_BOTH_SERVER_IP} = $trustvars_f->{SERVER_IP};
802 $ret->{TRUST_F_BOTH_SERVER_IPV6} = $trustvars_f->{SERVER_IPV6};
803 $ret->{TRUST_F_BOTH_NETBIOSNAME} = $trustvars_f->{NETBIOSNAME};
804 $ret->{TRUST_F_BOTH_USERNAME} = $trustvars_f->{USERNAME};
805 $ret->{TRUST_F_BOTH_PASSWORD} = $trustvars_f->{PASSWORD};
806 $ret->{TRUST_F_BOTH_DOMAIN} = $trustvars_f->{DOMAIN};
807 $ret->{TRUST_F_BOTH_REALM} = $trustvars_f->{REALM};
810 $ret->{TRUST_E_BOTH_SERVER} = $trustvars_e->{SERVER};
811 $ret->{TRUST_E_BOTH_SERVER_IP} = $trustvars_e->{SERVER_IP};
812 $ret->{TRUST_E_BOTH_SERVER_IPV6} = $trustvars_e->{SERVER_IPV6};
813 $ret->{TRUST_E_BOTH_NETBIOSNAME} = $trustvars_e->{NETBIOSNAME};
814 $ret->{TRUST_E_BOTH_USERNAME} = $trustvars_e->{USERNAME};
815 $ret->{TRUST_E_BOTH_PASSWORD} = $trustvars_e->{PASSWORD};
816 $ret->{TRUST_E_BOTH_DOMAIN} = $trustvars_e->{DOMAIN};
817 $ret->{TRUST_E_BOTH_REALM} = $trustvars_e->{REALM};
830 # If we didn't build with ADS, pretend this env was never available
831 if (not $self->have_ads()) {
835 print "PROVISIONING AD MEMBER...";
837 return $self->provision_ad_member($prefix, $dcvars, $trustvars_f, $trustvars_e);
840 sub setup_ad_member_rfc2307
842 my ($self, $prefix, $dcvars) = @_;
844 # If we didn't build with ADS, pretend this env was never available
845 if (not $self->have_ads()) {
849 print "PROVISIONING S3 AD MEMBER WITH idmap_rfc2307 config...";
851 my $member_options = "
853 workgroup = $dcvars->{DOMAIN}
854 realm = $dcvars->{REALM}
856 idmap negative cache time = 0
857 idmap config * : backend = autorid
858 idmap config * : range = 1000000-1999999
859 idmap config * : rangesize = 100000
860 idmap config $dcvars->{DOMAIN} : backend = rfc2307
861 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
862 idmap config $dcvars->{DOMAIN} : ldap_server = ad
863 idmap config $dcvars->{DOMAIN} : bind_path_user = ou=idmap,dc=samba,dc=example,dc=com
864 idmap config $dcvars->{DOMAIN} : bind_path_group = ou=idmap,dc=samba,dc=example,dc=com
866 password server = $dcvars->{SERVER}
869 my $ret = $self->provision(
871 domain => $dcvars->{DOMAIN},
872 server => "RFC2307MEMBER",
873 password => "loCalMemberPass",
874 extra_options => $member_options,
875 resolv_conf => $dcvars->{RESOLV_CONF});
877 $ret or return undef;
880 $ret->{DOMAIN} = $dcvars->{DOMAIN};
881 $ret->{REALM} = $dcvars->{REALM};
882 $ret->{DOMSID} = $dcvars->{DOMSID};
885 my $prefix_abs = abs_path($prefix);
887 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
888 $ctx->{domain} = $dcvars->{DOMAIN};
889 $ctx->{realm} = $dcvars->{REALM};
890 $ctx->{dnsname} = lc($dcvars->{REALM});
891 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
892 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
893 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
894 Samba::mk_krb5_conf($ctx, "");
896 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
898 my $net = Samba::bindir_path($self, "net");
899 # Add hosts file for name lookups
900 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
901 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
902 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
903 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
905 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
907 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
908 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
909 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
910 $cmd .= "$net join $ret->{CONFIGURATION}";
911 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
913 if (system($cmd) != 0) {
914 warn("Join failed\n$cmd");
918 # We need world access to this share, as otherwise the domain
919 # administrator from the AD domain provided by Samba4 can't
920 # access the share for tests.
921 chmod 0777, "$prefix/share";
923 if (not $self->check_or_start(
931 $ret->{DC_SERVER} = $dcvars->{SERVER};
932 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
933 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
934 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
935 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
936 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
941 sub setup_ad_member_idmap_rid
943 my ($self, $prefix, $dcvars) = @_;
945 # If we didn't build with ADS, pretend this env was never available
946 if (not $self->have_ads()) {
950 print "PROVISIONING S3 AD MEMBER WITH idmap_rid config...";
952 my $member_options = "
954 workgroup = $dcvars->{DOMAIN}
955 realm = $dcvars->{REALM}
956 idmap config * : backend = tdb
957 idmap config * : range = 1000000-1999999
958 idmap config $dcvars->{DOMAIN} : backend = rid
959 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
960 # Prevent overridding the provisioned lib/krb5.conf which sets certain
961 # values required for tests to succeed
962 create krb5 conf = no
963 map to guest = bad user
966 my $ret = $self->provision(
968 domain => $dcvars->{DOMAIN},
969 server => "IDMAPRIDMEMBER",
970 password => "loCalMemberPass",
971 extra_options => $member_options,
972 resolv_conf => $dcvars->{RESOLV_CONF});
974 $ret or return undef;
977 $ret->{DOMAIN} = $dcvars->{DOMAIN};
978 $ret->{REALM} = $dcvars->{REALM};
979 $ret->{DOMSID} = $dcvars->{DOMSID};
982 my $prefix_abs = abs_path($prefix);
984 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
985 $ctx->{domain} = $dcvars->{DOMAIN};
986 $ctx->{realm} = $dcvars->{REALM};
987 $ctx->{dnsname} = lc($dcvars->{REALM});
988 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
989 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
990 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
991 Samba::mk_krb5_conf($ctx, "");
993 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
995 my $net = Samba::bindir_path($self, "net");
996 # Add hosts file for name lookups
997 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
998 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
999 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
1000 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
1002 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
1004 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
1005 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1006 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
1007 $cmd .= "$net join $ret->{CONFIGURATION}";
1008 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
1010 if (system($cmd) != 0) {
1011 warn("Join failed\n$cmd");
1015 # We need world access to this share, as otherwise the domain
1016 # administrator from the AD domain provided by Samba4 can't
1017 # access the share for tests.
1018 chmod 0777, "$prefix/share";
1020 if (not $self->check_or_start(
1028 $ret->{DC_SERVER} = $dcvars->{SERVER};
1029 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1030 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1031 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1032 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1033 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1038 sub setup_ad_member_idmap_ad
1040 my ($self, $prefix, $dcvars) = @_;
1042 # If we didn't build with ADS, pretend this env was never available
1043 if (not $self->have_ads()) {
1047 print "PROVISIONING S3 AD MEMBER WITH idmap_ad config...";
1049 my $member_options = "
1051 workgroup = $dcvars->{DOMAIN}
1052 realm = $dcvars->{REALM}
1053 password server = $dcvars->{SERVER}
1054 idmap config * : backend = tdb
1055 idmap config * : range = 1000000-1999999
1056 idmap config $dcvars->{DOMAIN} : backend = ad
1057 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
1058 idmap config $dcvars->{TRUST_DOMAIN} : backend = ad
1059 idmap config $dcvars->{TRUST_DOMAIN} : range = 2000000-2999999
1062 my $ret = $self->provision(
1064 domain => $dcvars->{DOMAIN},
1065 server => "IDMAPADMEMBER",
1066 password => "loCalMemberPass",
1067 extra_options => $member_options,
1068 resolv_conf => $dcvars->{RESOLV_CONF});
1070 $ret or return undef;
1073 $ret->{DOMAIN} = $dcvars->{DOMAIN};
1074 $ret->{REALM} = $dcvars->{REALM};
1075 $ret->{DOMSID} = $dcvars->{DOMSID};
1078 my $prefix_abs = abs_path($prefix);
1080 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1081 $ctx->{domain} = $dcvars->{DOMAIN};
1082 $ctx->{realm} = $dcvars->{REALM};
1083 $ctx->{dnsname} = lc($dcvars->{REALM});
1084 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
1085 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
1086 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1087 Samba::mk_krb5_conf($ctx, "");
1089 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1091 my $net = Samba::bindir_path($self, "net");
1092 # Add hosts file for name lookups
1093 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
1094 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1095 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
1096 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
1098 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
1100 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
1101 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1102 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
1103 $cmd .= "$net join $ret->{CONFIGURATION}";
1104 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
1106 if (system($cmd) != 0) {
1107 warn("Join failed\n$cmd");
1111 # We need world access to this share, as otherwise the domain
1112 # administrator from the AD domain provided by Samba4 can't
1113 # access the share for tests.
1114 chmod 0777, "$prefix/share";
1116 if (not $self->check_or_start(
1124 $ret->{DC_SERVER} = $dcvars->{SERVER};
1125 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1126 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1127 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1128 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1129 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1131 $ret->{TRUST_SERVER} = $dcvars->{TRUST_SERVER};
1132 $ret->{TRUST_USERNAME} = $dcvars->{TRUST_USERNAME};
1133 $ret->{TRUST_PASSWORD} = $dcvars->{TRUST_PASSWORD};
1134 $ret->{TRUST_DOMAIN} = $dcvars->{TRUST_DOMAIN};
1135 $ret->{TRUST_REALM} = $dcvars->{TRUST_REALM};
1136 $ret->{TRUST_DOMSID} = $dcvars->{TRUST_DOMSID};
1141 sub setup_ad_member_fips
1149 # If we didn't build with ADS, pretend this env was never available
1150 if (not $self->have_ads()) {
1154 print "PROVISIONING AD FIPS MEMBER...";
1156 return $self->provision_ad_member($prefix,
1163 sub setup_simpleserver
1165 my ($self, $path) = @_;
1167 print "PROVISIONING simple server...";
1169 my $prefix_abs = abs_path($path);
1171 my $simpleserver_options = "
1174 vfs objects = xattr_tdb streams_depot
1179 path = $prefix_abs/share
1181 vfs objects = aio_pthread
1182 aio_pthread:aio open = yes
1183 smbd:async dosmode = no
1185 [vfs_aio_pthread_async_dosmode_default1]
1186 path = $prefix_abs/share
1188 vfs objects = aio_pthread
1189 store dos attributes = yes
1190 aio_pthread:aio open = yes
1191 smbd:async dosmode = yes
1193 [vfs_aio_pthread_async_dosmode_default2]
1194 path = $prefix_abs/share
1196 vfs objects = aio_pthread xattr_tdb
1197 store dos attributes = yes
1198 aio_pthread:aio open = yes
1199 smbd:async dosmode = yes
1201 [vfs_aio_pthread_async_dosmode_force_sync1]
1202 path = $prefix_abs/share
1204 vfs objects = aio_pthread
1205 store dos attributes = yes
1206 aio_pthread:aio open = yes
1207 smbd:async dosmode = yes
1208 # This simulates non linux systems
1209 smbd:force sync user path safe threadpool = yes
1210 smbd:force sync user chdir safe threadpool = yes
1211 smbd:force sync root path safe threadpool = yes
1212 smbd:force sync root chdir safe threadpool = yes
1214 [vfs_aio_pthread_async_dosmode_force_sync2]
1215 path = $prefix_abs/share
1217 vfs objects = aio_pthread xattr_tdb
1218 store dos attributes = yes
1219 aio_pthread:aio open = yes
1220 smbd:async dosmode = yes
1221 # This simulates non linux systems
1222 smbd:force sync user path safe threadpool = yes
1223 smbd:force sync user chdir safe threadpool = yes
1224 smbd:force sync root path safe threadpool = yes
1225 smbd:force sync root chdir safe threadpool = yes
1228 path = $prefix_abs/share
1229 vfs objects = aio_fork
1231 vfs_aio_fork:erratic_testing_mode=yes
1234 path = $prefix_abs/share
1236 store dos attributes = yes
1237 hide files = /hidefile/
1238 hide dot files = yes
1241 path = $prefix_abs/share
1243 smb encrypt = desired
1246 path = $prefix_abs/share
1247 hide new files timeout = 5
1250 my $vars = $self->provision(
1252 domain => "WORKGROUP",
1253 server => "LOCALSHARE4",
1254 password => "local4pass",
1255 extra_options => $simpleserver_options);
1257 $vars or return undef;
1259 if (not $self->check_or_start(
1269 sub create_file_chmod($$)
1271 my ($name, $mode) = @_;
1274 unless (open($fh, '>', $name)) {
1275 warn("Unable to open $name");
1281 sub setup_fileserver
1283 my ($self, $path, $more_conf, $server) = @_;
1284 my $prefix_abs = abs_path($path);
1285 my $srcdir_abs = abs_path($self->{srcdir});
1287 print "PROVISIONING file server ...\n";
1291 mkdir($prefix_abs, 0777);
1293 my $usershare_dir="$prefix_abs/lib/usershare";
1295 mkdir("$prefix_abs/lib", 0755);
1296 remove_tree($usershare_dir);
1297 mkdir($usershare_dir, 01770);
1299 my $share_dir="$prefix_abs/share";
1301 # Create share directory structure
1302 my $lower_case_share_dir="$share_dir/lower-case";
1303 push(@dirs, $lower_case_share_dir);
1305 my $lower_case_share_dir_30000="$share_dir/lower-case-30000";
1306 push(@dirs, $lower_case_share_dir_30000);
1308 my $dfree_share_dir="$share_dir/dfree";
1309 push(@dirs, $dfree_share_dir);
1310 push(@dirs, "$dfree_share_dir/subdir1");
1311 push(@dirs, "$dfree_share_dir/subdir2");
1312 push(@dirs, "$dfree_share_dir/subdir3");
1314 my $quotadir_dir="$share_dir/quota";
1315 push(@dirs, $quotadir_dir);
1317 my $valid_users_sharedir="$share_dir/valid_users";
1318 push(@dirs,$valid_users_sharedir);
1320 my $offline_sharedir="$share_dir/offline";
1321 push(@dirs,$offline_sharedir);
1323 my $force_user_valid_users_dir = "$share_dir/force_user_valid_users";
1324 push(@dirs, $force_user_valid_users_dir);
1326 my $smbget_sharedir="$share_dir/smbget";
1327 push(@dirs,$smbget_sharedir);
1329 my $tarmode_sharedir="$share_dir/tarmode";
1330 push(@dirs,$tarmode_sharedir);
1332 my $smbcacls_sharedir="$share_dir/smbcacls";
1333 push(@dirs,$smbcacls_sharedir);
1335 my $usershare_sharedir="$share_dir/usershares";
1336 push(@dirs,$usershare_sharedir);
1338 my $dropbox_sharedir="$share_dir/dropbox";
1339 push(@dirs,$dropbox_sharedir);
1341 my $bad_iconv_sharedir="$share_dir/bad_iconv";
1342 push(@dirs, $bad_iconv_sharedir);
1344 my $ip4 = Samba::get_ipv4_addr("FILESERVER");
1345 my $fileserver_options = "
1346 kernel change notify = yes
1347 rpc_server:mdssvc = embedded
1348 spotlight backend = elasticsearch
1349 elasticsearch:address = $ip4
1350 elasticsearch:port = 8080
1351 elasticsearch:mappings = $srcdir_abs/source3/rpc_server/mdssvc/elasticsearch_mappings.json
1353 usershare path = $usershare_dir
1354 usershare max shares = 10
1355 usershare allow guests = yes
1356 usershare prefix allow list = $usershare_sharedir
1358 get quota command = $prefix_abs/getset_quota.py
1359 set quota command = $prefix_abs/getset_quota.py
1369 path = $lower_case_share_dir
1370 comment = smb username is [%U]
1371 case sensitive = True
1372 default case = lower
1374 short preserve case = no
1376 path = $lower_case_share_dir_30000
1377 comment = smb username is [%U]
1378 case sensitive = True
1379 default case = lower
1381 short preserve case = no
1383 path = $dfree_share_dir
1384 comment = smb username is [%U]
1385 dfree command = $srcdir_abs/testprogs/blackbox/dfree.sh
1386 [valid-users-access]
1387 path = $valid_users_sharedir
1388 valid users = +userdup
1390 path = $offline_sharedir
1391 vfs objects = offline
1393 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878
1394 # RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651
1395 [force_user_valid_users]
1396 path = $force_user_valid_users_dir
1397 comment = force user with valid users combination test share
1398 valid users = +force_user
1399 force user = force_user
1400 force group = everyone
1401 write list = force_user
1404 path = $smbget_sharedir
1405 comment = smb username is [%U]
1409 comment = ignore system acls
1410 acl_xattr:ignore system acls = yes
1413 comment = inherit owner
1417 comment = inherit only unix owner
1418 inherit owner = unix only
1419 acl_xattr:ignore system acls = yes
1420 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=13690
1423 comment = force group test
1424 # force group = everyone
1428 comment = smb username is [%U]
1430 force create mode = 0664
1431 vfs objects = dirsort
1434 path = $dropbox_sharedir
1435 comment = smb username is [%U]
1440 path = $bad_iconv_sharedir
1441 comment = smb username is [%U]
1445 comment = Home directories
1450 if (defined($more_conf)) {
1451 $fileserver_options = $fileserver_options . $more_conf;
1453 if (!defined($server)) {
1454 $server = "FILESERVER";
1457 my $vars = $self->provision(
1459 domain => "WORKGROUP",
1461 password => "fileserver",
1462 extra_options => $fileserver_options,
1463 no_delete_prefix => 1);
1465 $vars or return undef;
1467 if (not $self->check_or_start(
1475 mkdir($_, 0777) foreach(@dirs);
1477 ## Create case sensitive lower case share dir
1478 foreach my $file ('a'..'z') {
1479 my $full_path = $lower_case_share_dir . '/' . $file;
1480 open my $fh, '>', $full_path;
1481 # Add some content to file
1482 print $fh $full_path;
1486 for (my $file = 1; $file < 51; ++$file) {
1487 my $full_path = $lower_case_share_dir . '/' . $file;
1488 open my $fh, '>', $full_path;
1489 # Add some content to file
1490 print $fh $full_path;
1494 # Create content for 30000 share
1495 foreach my $file ('a'..'z') {
1496 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1497 open my $fh, '>', $full_path;
1498 # Add some content to file
1499 print $fh $full_path;
1503 for (my $file = 1; $file < 30001; ++$file) {
1504 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1505 open my $fh, '>', $full_path;
1506 # Add some content to file
1507 print $fh $full_path;
1512 ## create a listable file in valid_users_share
1514 create_file_chmod("$valid_users_sharedir/foo", 0644) or return undef;
1517 ## create a valid utf8 filename which is invalid as a CP850 conversion
1519 create_file_chmod("$bad_iconv_sharedir/\xED\x9F\xBF", 0644) or return undef;
1524 sub setup_fileserver_smb1
1526 my ($self, $path) = @_;
1527 my $prefix_abs = abs_path($path);
1530 client min protocol = CORE
1531 server min protocol = LANMAN1
1534 path = $prefix_abs/share
1535 hide new files timeout = 5
1537 path = $prefix_abs/share
1539 vfs objects = aio_pthread
1540 aio_pthread:aio open = yes
1541 smbd:async dosmode = no
1543 [vfs_aio_pthread_async_dosmode_default1]
1544 path = $prefix_abs/share
1546 vfs objects = aio_pthread
1547 store dos attributes = yes
1548 aio_pthread:aio open = yes
1549 smbd:async dosmode = yes
1551 [vfs_aio_pthread_async_dosmode_default2]
1552 path = $prefix_abs/share
1554 vfs objects = aio_pthread xattr_tdb
1555 store dos attributes = yes
1556 aio_pthread:aio open = yes
1557 smbd:async dosmode = yes
1559 [vfs_aio_pthread_async_dosmode_force_sync1]
1560 path = $prefix_abs/share
1562 vfs objects = aio_pthread
1563 store dos attributes = yes
1564 aio_pthread:aio open = yes
1565 smbd:async dosmode = yes
1566 # This simulates non linux systems
1567 smbd:force sync user path safe threadpool = yes
1568 smbd:force sync user chdir safe threadpool = yes
1569 smbd:force sync root path safe threadpool = yes
1570 smbd:force sync root chdir safe threadpool = yes
1572 [vfs_aio_pthread_async_dosmode_force_sync2]
1573 path = $prefix_abs/share
1575 vfs objects = aio_pthread xattr_tdb
1576 store dos attributes = yes
1577 aio_pthread:aio open = yes
1578 smbd:async dosmode = yes
1579 # This simulates non linux systems
1580 smbd:force sync user path safe threadpool = yes
1581 smbd:force sync user chdir safe threadpool = yes
1582 smbd:force sync root path safe threadpool = yes
1583 smbd:force sync root chdir safe threadpool = yes
1586 path = $prefix_abs/share
1587 vfs objects = aio_fork
1589 vfs_aio_fork:erratic_testing_mode=yes
1591 return $self->setup_fileserver($path, $conf, "FILESERVERSMB1");
1594 sub setup_fileserver_smb1_done
1596 my ($self, $path, $dep_env) = @_;
1597 return $self->return_alias_env($path, $dep_env);
1602 my ($self, $prefix) = @_;
1604 # If we didn't build with ADS, pretend this env was never available
1605 if (not $self->have_ads()) {
1609 print "PROVISIONING server with security=ads...";
1611 my $ktest_options = "
1613 realm = ktest.samba.example.com
1615 username map = $prefix/lib/username.map
1616 server signing = required
1617 server min protocol = SMB3_00
1618 client max protocol = SMB3
1620 # This disables NTLM auth against the local SAM, which
1621 # we use can then test this setting by.
1622 ntlm auth = disabled
1625 my $ret = $self->provision(
1628 server => "LOCALKTEST6",
1629 password => "localktest6pass",
1630 extra_options => $ktest_options);
1632 $ret or return undef;
1635 my $prefix_abs = abs_path($prefix);
1637 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1638 $ctx->{domain} = "KTEST";
1639 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
1640 $ctx->{dnsname} = lc($ctx->{realm});
1641 $ctx->{kdc_ipv4} = "0.0.0.0";
1642 $ctx->{kdc_ipv6} = "::";
1643 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1644 Samba::mk_krb5_conf($ctx, "");
1646 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1648 open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map");
1650 $ret->{USERNAME} = KTEST\\Administrator
1654 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
1655 #Samba4 DC with the same parameters as are being used here. The
1656 #domain SID is S-1-5-21-1071277805-689288055-3486227160
1657 $ret->{SAMSID} = "S-1-5-21-1911091480-1468226576-2729736297";
1658 $ret->{DOMSID} = "S-1-5-21-1071277805-689288055-3486227160";
1660 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
1661 chmod 0600, "$prefix/private/secrets.tdb";
1663 #Make sure there's no old ntdb file.
1664 system("rm -f $prefix/private/secrets.ntdb");
1666 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
1667 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
1669 #and having in krb5.conf:
1670 # ticket_lifetime = 799718400
1671 # renew_lifetime = 799718400
1673 # The commands for the -2 keytab where were:
1674 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
1675 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
1676 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
1677 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1678 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1680 # and then for the -3 keytab, I did
1682 # net changetrustpw; kdestroy and the same again.
1684 # This creates a credential cache with a very long lifetime (2036 at
1685 # at 2011-04), and shows that running 'net changetrustpw' does not
1686 # break existing logins (for the secrets.tdb method at least).
1689 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
1691 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
1692 chmod 0600, "$prefix/krb5_ccache-2";
1694 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
1695 chmod 0600, "$prefix/krb5_ccache-3";
1697 # We need world access to this share, as otherwise the domain
1698 # administrator from the AD domain provided by ktest can't
1699 # access the share for tests.
1700 chmod 0777, "$prefix/share";
1702 if (not $self->check_or_start(
1711 sub setup_maptoguest
1713 my ($self, $path) = @_;
1715 print "PROVISIONING maptoguest...";
1718 map to guest = bad user
1722 my $vars = $self->provision(
1724 domain => "WORKGROUP",
1725 server => "maptoguest",
1726 password => "maptoguestpass",
1727 extra_options => $options);
1729 $vars or return undef;
1731 if (not $self->check_or_start(
1741 sub stop_sig_term($$) {
1742 my ($self, $pid) = @_;
1743 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1746 sub stop_sig_kill($$) {
1747 my ($self, $pid) = @_;
1748 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1753 my ($env_vars, $app, $pid) = @_;
1755 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
1762 my ($env_vars, $app) = @_;
1764 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
1770 # builds up the cmd args to run an s3 binary (i.e. smbd, nmbd, etc)
1773 my ($self, $binary, $env_vars, $options, $valgrind, $dont_log_stdout) = @_;
1775 my @optargs = ("-d0");
1776 if (defined($options)) {
1777 @optargs = split(/ /, $options);
1779 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1781 if (defined($valgrind)) {
1782 @preargs = split(/ /, $valgrind);
1784 my @args = ("-F", "--no-process-group",
1785 "-s", $env_vars->{SERVERCONFFILE},
1786 "-l", $env_vars->{LOGDIR});
1788 if (not defined($dont_log_stdout)) {
1789 push(@args, "--log-stdout");
1791 return (@preargs, $binary, @args, @optargs);
1794 sub check_or_start($$) {
1795 my ($self, %args) = @_;
1796 my $env_vars = $args{env_vars};
1797 my $nmbd = $args{nmbd} // "no";
1798 my $winbindd = $args{winbindd} // "no";
1799 my $smbd = $args{smbd} // "no";
1800 my $child_cleanup = $args{child_cleanup};
1804 # use a pipe for stdin in the child processes. This allows
1805 # those processes to monitor the pipe for EOF to ensure they
1806 # exit when the test script exits
1807 pipe($STDIN_READER, $env_vars->{STDIN_PIPE});
1809 my $binary = Samba::bindir_path($self, "nmbd");
1810 my @full_cmd = $self->make_bin_cmd($binary, $env_vars,
1811 $ENV{NMBD_OPTIONS}, $ENV{NMBD_VALGRIND},
1812 $ENV{NMBD_DONT_LOG_STDOUT});
1813 my $nmbd_envs = Samba::get_env_for_process("nmbd", $env_vars);
1814 delete $nmbd_envs->{RESOLV_WRAPPER_CONF};
1815 delete $nmbd_envs->{RESOLV_WRAPPER_HOSTS};
1817 # fork and exec() nmbd in the child process
1820 BINARY_PATH => $binary,
1821 FULL_CMD => [ @full_cmd ],
1822 LOG_FILE => $env_vars->{NMBD_TEST_LOG},
1823 PCAP_FILE => "env-$ENV{ENVNAME}-nmbd",
1824 ENV_VARS => $nmbd_envs,
1826 if ($nmbd ne "yes") {
1827 $daemon_ctx->{SKIP_DAEMON} = 1;
1829 my $pid = Samba::fork_and_exec(
1830 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
1832 $env_vars->{NMBD_TL_PID} = $pid;
1833 write_pid($env_vars, "nmbd", $pid);
1835 $binary = Samba::bindir_path($self, "winbindd");
1836 @full_cmd = $self->make_bin_cmd($binary, $env_vars,
1837 $ENV{WINBINDD_OPTIONS}, $ENV{WINBINDD_VALGRIND}, "N/A");
1839 if (not defined($ENV{WINBINDD_DONT_LOG_STDOUT})) {
1840 push(@full_cmd, "--stdout");
1843 # fork and exec() winbindd in the child process
1846 BINARY_PATH => $binary,
1847 FULL_CMD => [ @full_cmd ],
1848 LOG_FILE => $env_vars->{WINBINDD_TEST_LOG},
1849 PCAP_FILE => "env-$ENV{ENVNAME}-winbindd",
1851 if ($winbindd ne "yes") {
1852 $daemon_ctx->{SKIP_DAEMON} = 1;
1855 $pid = Samba::fork_and_exec(
1856 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
1858 $env_vars->{WINBINDD_TL_PID} = $pid;
1859 write_pid($env_vars, "winbindd", $pid);
1861 $binary = Samba::bindir_path($self, "smbd");
1862 @full_cmd = $self->make_bin_cmd($binary, $env_vars,
1863 $ENV{SMBD_OPTIONS}, $ENV{SMBD_VALGRIND},
1864 $ENV{SMBD_DONT_LOG_STDOUT});
1866 # fork and exec() smbd in the child process
1869 BINARY_PATH => $binary,
1870 FULL_CMD => [ @full_cmd ],
1871 LOG_FILE => $env_vars->{SMBD_TEST_LOG},
1872 PCAP_FILE => "env-$ENV{ENVNAME}-smbd",
1874 if ($smbd ne "yes") {
1875 $daemon_ctx->{SKIP_DAEMON} = 1;
1878 $pid = Samba::fork_and_exec(
1879 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
1881 $env_vars->{SMBD_TL_PID} = $pid;
1882 write_pid($env_vars, "smbd", $pid);
1884 # close the parent's read-end of the pipe
1885 close($STDIN_READER);
1887 return $self->wait_for_start($env_vars, $nmbd, $winbindd, $smbd);
1890 sub createuser($$$$$)
1892 my ($self, $username, $password, $conffile, $env) = @_;
1893 my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $username > /dev/null";
1896 while(my($var, $val) = each %$env) {
1897 $cmd = "$var=\"$val\" $cmd";
1900 unless (open(PWD, "|$cmd")) {
1901 warn("Unable to set password for $username account\n$cmd");
1904 print PWD "$password\n$password\n";
1905 unless (close(PWD)) {
1906 warn("Unable to set password for $username account\n$cmd");
1913 my ($self, %args) = @_;
1915 my $prefix = $args{prefix};
1916 my $domain = $args{domain};
1917 my $server = $args{server};
1918 my $password = $args{password};
1919 my $extra_options = $args{extra_options};
1920 my $resolv_conf = $args{resolv_conf};
1921 my $no_delete_prefix= $args{no_delete_prefix};
1922 my $netbios_name = $args{netbios_name} // $server;
1925 ## setup the various environment variables we need
1928 my $samsid = Samba::random_domain_sid();
1929 my $swiface = Samba::get_interface($server);
1931 my %createuser_env = ();
1932 my $server_ip = Samba::get_ipv4_addr($server);
1933 my $server_ipv6 = Samba::get_ipv6_addr($server);
1935 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
1938 my $unix_gids_str = $);
1939 my @unix_gids = split(" ", $unix_gids_str);
1941 my $prefix_abs = abs_path($prefix);
1942 my $bindir_abs = abs_path($self->{bindir});
1946 my $shrdir=$args{share_dir} // "$prefix_abs/share";
1947 push(@dirs,$shrdir);
1949 my $libdir="$prefix_abs/lib";
1950 push(@dirs,$libdir);
1952 my $piddir="$prefix_abs/pid";
1953 push(@dirs,$piddir);
1955 my $privatedir="$prefix_abs/private";
1956 push(@dirs,$privatedir);
1958 my $cachedir = "$prefix_abs/cachedir";
1959 push(@dirs, $cachedir);
1961 my $binddnsdir = "$prefix_abs/bind-dns";
1962 push(@dirs, $binddnsdir);
1964 my $lockdir="$prefix_abs/lockdir";
1965 push(@dirs,$lockdir);
1967 my $eventlogdir="$prefix_abs/lockdir/eventlog";
1968 push(@dirs,$eventlogdir);
1970 my $logdir="$prefix_abs/logs";
1971 push(@dirs,$logdir);
1973 my $driver32dir="$shrdir/W32X86";
1974 push(@dirs,$driver32dir);
1976 my $driver64dir="$shrdir/x64";
1977 push(@dirs,$driver64dir);
1979 my $driver40dir="$shrdir/WIN40";
1980 push(@dirs,$driver40dir);
1982 my $ro_shrdir="$shrdir/root-tmp";
1983 push(@dirs,$ro_shrdir);
1985 my $noperm_shrdir="$shrdir/noperm-tmp";
1986 push(@dirs,$noperm_shrdir);
1988 my $msdfs_shrdir="$shrdir/msdfsshare";
1989 push(@dirs,$msdfs_shrdir);
1991 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
1992 push(@dirs,$msdfs_deeppath);
1994 my $smbcacls_sharedir_dfs="$shrdir/smbcacls_sharedir_dfs";
1995 push(@dirs,$smbcacls_sharedir_dfs);
1997 my $badnames_shrdir="$shrdir/badnames";
1998 push(@dirs,$badnames_shrdir);
2000 my $lease1_shrdir="$shrdir/SMB2_10";
2001 push(@dirs,$lease1_shrdir);
2003 my $lease2_shrdir="$shrdir/SMB3_00";
2004 push(@dirs,$lease2_shrdir);
2006 my $manglenames_shrdir="$shrdir/manglenames";
2007 push(@dirs,$manglenames_shrdir);
2009 my $widelinks_shrdir="$shrdir/widelinks";
2010 push(@dirs,$widelinks_shrdir);
2012 my $widelinks_linkdir="$shrdir/widelinks_foo";
2013 push(@dirs,$widelinks_linkdir);
2015 my $fsrvp_shrdir="$shrdir/fsrvp";
2016 push(@dirs,$fsrvp_shrdir);
2018 my $shadow_tstdir="$shrdir/shadow";
2019 push(@dirs,$shadow_tstdir);
2020 my $shadow_mntdir="$shadow_tstdir/mount";
2021 push(@dirs,$shadow_mntdir);
2022 my $shadow_basedir="$shadow_mntdir/base";
2023 push(@dirs,$shadow_basedir);
2024 my $shadow_shrdir="$shadow_basedir/share";
2025 push(@dirs,$shadow_shrdir);
2027 my $nosymlinks_shrdir="$shrdir/nosymlinks";
2028 push(@dirs,$nosymlinks_shrdir);
2030 my $local_symlinks_shrdir="$shrdir/local_symlinks";
2031 push(@dirs,$local_symlinks_shrdir);
2033 # this gets autocreated by winbindd
2034 my $wbsockdir="$prefix_abs/winbindd";
2036 my $nmbdsockdir="$prefix_abs/nmbd";
2037 unlink($nmbdsockdir);
2040 ## create the test directory layout
2042 die ("prefix_abs = ''") if $prefix_abs eq "";
2043 die ("prefix_abs = '/'") if $prefix_abs eq "/";
2045 mkdir($prefix_abs, 0777);
2046 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
2047 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
2048 system("rm -rf $prefix_abs/*");
2050 mkdir($_, 0777) foreach(@dirs);
2052 my $fs_specific_conf = $self->get_fs_specific_conf($shrdir);
2055 ## lockdir and piddir must be 0755
2057 chmod 0755, $lockdir;
2058 chmod 0755, $piddir;
2062 ## Create a directory without permissions to enter
2064 chmod 0000, $noperm_shrdir;
2067 ## create ro and msdfs share layout
2070 chmod 0755, $ro_shrdir;
2072 create_file_chmod("$ro_shrdir/unreadable_file", 0600) or return undef;
2074 create_file_chmod("$ro_shrdir/msdfs-target", 0600) or return undef;
2075 symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp",
2076 "$msdfs_shrdir/msdfs-src1";
2077 symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
2078 symlink "msdfs:$server_ip\\smbcacls_sharedir_dfs,$server_ipv6\\smbcacls_sharedir_dfs",
2079 "$msdfs_shrdir/smbcacls_sharedir_dfs";
2082 ## create bad names in $badnames_shrdir
2084 ## (An invalid name, would be mangled to 8.3).
2085 create_file_chmod("$badnames_shrdir/\340|\231\216\377\177",
2086 0600) or return undef;
2088 ## (A bad name, would not be mangled to 8.3).
2089 create_file_chmod("$badnames_shrdir/\240\276\346\327\377\177",
2090 0666) or return undef;
2092 ## (A bad good name).
2093 create_file_chmod("$badnames_shrdir/blank.txt",
2094 0666) or return undef;
2097 ## create mangleable directory names in $manglenames_shrdir
2099 my $manglename_target = "$manglenames_shrdir/foo:bar";
2100 mkdir($manglename_target, 0777);
2103 ## create symlinks for widelinks tests.
2105 my $widelinks_target = "$widelinks_linkdir/target";
2106 create_file_chmod("$widelinks_target", 0666) or return undef;
2109 ## This link should get ACCESS_DENIED
2111 symlink "$widelinks_target", "$widelinks_shrdir/source";
2113 ## This link should be allowed
2115 symlink "$widelinks_shrdir", "$widelinks_shrdir/dot";
2117 my $conffile="$libdir/server.conf";
2118 my $dfqconffile="$libdir/dfq.conf";
2119 my $errorinjectconf="$libdir/error_inject.conf";
2120 my $delayinjectconf="$libdir/delay_inject.conf";
2121 my $globalinjectconf="$libdir/global_inject.conf";
2123 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/third_party/nss_wrapper/nss_wrapper.pl";
2124 my $nss_wrapper_passwd = "$privatedir/passwd";
2125 my $nss_wrapper_group = "$privatedir/group";
2126 my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts";
2127 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
2129 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
2131 my $fake_snap_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/fake_snap.pl";
2133 my @eventlog_list = ("dns server", "application");
2136 ## calculate uids and gids
2139 my ($max_uid, $max_gid);
2140 my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
2141 my ($uid_pdbtest_wkn);
2143 my ($uid_force_user);
2144 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
2145 my ($gid_userdup, $gid_everyone);
2146 my ($gid_force_user);
2151 my ($uid_slashuser);
2153 if ($unix_uid < 0xffff - 13) {
2156 $max_uid = $unix_uid;
2159 $uid_root = $max_uid - 1;
2160 $uid_nobody = $max_uid - 2;
2161 $uid_pdbtest = $max_uid - 3;
2162 $uid_pdbtest2 = $max_uid - 4;
2163 $uid_userdup = $max_uid - 5;
2164 $uid_pdbtest_wkn = $max_uid - 6;
2165 $uid_force_user = $max_uid - 7;
2166 $uid_smbget = $max_uid - 8;
2167 $uid_user1 = $max_uid - 9;
2168 $uid_user2 = $max_uid - 10;
2169 $uid_gooduser = $max_uid - 11;
2170 $uid_eviluser = $max_uid - 12;
2171 $uid_slashuser = $max_uid - 13;
2173 if ($unix_gids[0] < 0xffff - 8) {
2176 $max_gid = $unix_gids[0];
2179 $gid_nobody = $max_gid - 1;
2180 $gid_nogroup = $max_gid - 2;
2181 $gid_root = $max_gid - 3;
2182 $gid_domusers = $max_gid - 4;
2183 $gid_domadmins = $max_gid - 5;
2184 $gid_userdup = $max_gid - 6;
2185 $gid_everyone = $max_gid - 7;
2186 $gid_force_user = $max_gid - 8;
2192 unless (open(CONF, ">$conffile")) {
2193 warn("Unable to open $conffile");
2197 my $interfaces = Samba::get_interfaces_config($server);
2201 dcesrv:fuzz directory = $cachedir/fuzz
2202 netbios name = $netbios_name
2203 interfaces = $interfaces
2204 bind interfaces only = yes
2205 panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
2206 smbd:suicide mode = yes
2207 smbd:FSCTL_SMBTORTURE = yes
2209 client min protocol = SMB2_02
2210 server min protocol = SMB2_02
2214 private dir = $privatedir
2215 binddns dir = $binddnsdir
2216 pid directory = $piddir
2217 lock directory = $lockdir
2218 log file = $logdir/log.\%m
2223 state directory = $lockdir
2224 cache directory = $lockdir
2226 passdb backend = tdbsam
2230 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
2231 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
2232 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
2233 add user to group script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type member --action add --member %u --name %g --group_path $nss_wrapper_group
2234 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
2235 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
2236 delete user from group script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type member --action delete --member %u --name %g --group_path $nss_wrapper_group
2238 addprinter command = $mod_printer_pl -a -s $conffile --
2239 deleteprinter command = $mod_printer_pl -d -s $conffile --
2241 eventlog list = application \"dns server\"
2244 kernel change notify = no
2248 printcap name = /dev/null
2250 winbindd socket directory = $wbsockdir
2251 nmbd:socket dir = $nmbdsockdir
2252 idmap config * : range = 100000-200000
2253 winbind enum users = yes
2254 winbind enum groups = yes
2255 winbind separator = /
2256 include system krb5 conf = no
2258 # min receivefile size = 4000
2262 smbd:sharedelay = 100000
2263 smbd:writetimeupdatedelay = 500000
2267 store dos attributes = yes
2273 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot time_audit full_audit
2275 full_audit:syslog = no
2276 full_audit:success = none
2277 full_audit:failure = none
2280 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
2281 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
2282 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
2283 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
2284 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
2285 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
2286 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
2288 print notify backchannel = yes
2290 ncalrpc dir = $prefix_abs/ncalrpc
2292 # The samba3.blackbox.smbclient_s3 test uses this to test that
2293 # sending messages works, and that the %m sub works.
2294 message command = mv %s $shrdir/message.%m
2296 # fsrvp server requires registry shares
2297 registry shares = yes
2299 # Used by RPC SRVSVC tests
2300 add share command = $bindir_abs/smbaddshare
2301 change share command = $bindir_abs/smbchangeshare
2302 delete share command = $bindir_abs/smbdeleteshare
2304 # fruit:copyfile is a global option
2305 fruit:copyfile = yes
2307 #this does not mean that we use non-secure test env,
2308 #it just means we ALLOW one to be configured.
2309 allow insecure wide links = yes
2311 include = $globalinjectconf
2313 # Begin extra options
2317 #Include user defined custom parameters if set
2320 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
2321 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
2325 [smbcacls_sharedir_dfs]
2326 path = $smbcacls_sharedir_dfs
2327 comment = smb username is [%U]
2330 comment = smb username is [%U]
2333 comment = Load dirsort module
2334 vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot
2337 comment = encrypt smb username is [%U]
2338 smb encrypt = required
2339 vfs objects = dirsort
2349 force user = $unix_name
2351 [forceuser_unixonly]
2352 comment = force a user with unix user SID and group SID
2354 force user = pdbtest
2356 [forceuser_wkngroup]
2357 comment = force a user with well-known group SID
2359 force user = pdbtest_wkn
2363 force group = nogroup
2369 path = $noperm_shrdir
2375 write list = $unix_name
2378 valid users = $unix_name
2379 access based share enum = yes
2381 path = $msdfs_shrdir
2383 msdfs shuffle referrals = yes
2387 hide unreadable = yes
2390 case sensitive = yes
2393 hide unwriteable files = yes
2396 kernel share modes = no
2410 default devmode = no
2416 comment = smb username is [%U]
2418 nfs4acl_xattr:version = 40
2419 vfs objects = nfs4acl_xattr xattr_tdb
2421 [nfs4acl_special_40]
2423 comment = smb username is [%U]
2425 nfs4acl_xattr:version = 40
2426 vfs objects = nfs4acl_xattr xattr_tdb
2430 comment = smb username is [%U]
2432 vfs objects = nfs4acl_xattr xattr_tdb
2436 comment = smb username is [%U]
2437 vfs objects = nfs4acl_xattr xattr_tdb
2439 nfs4acl_xattr:encoding = xdr
2440 nfs4acl_xattr:version = 40
2444 comment = smb username is [%U]
2445 vfs objects = nfs4acl_xattr xattr_tdb
2447 nfs4acl_xattr:encoding = xdr
2448 nfs4acl_xattr:version = 41
2452 comment = smb username is [%U]
2453 vfs objects = nfs4acl_xattr xattr_tdb
2455 nfs4acl_xattr:encoding = nfs
2456 nfs4acl_xattr:version = 40
2457 nfs4acl_xattr:xattr_name = security.nfs4acl_xdr
2461 comment = smb username is [%U]
2462 vfs objects = nfs4acl_xattr xattr_tdb
2464 nfs4acl_xattr:encoding = nfs
2465 nfs4acl_xattr:version = 41
2466 nfs4acl_xattr:xattr_name = security.nfs4acl_xdr
2470 comment = smb username is [%U]
2472 force create mode = 777
2475 comment = smb username is [%U]
2477 force create mode = 0
2478 directory mask = 0777
2479 force directory mode = 0
2480 vfs objects = xattr_tdb streams_depot
2491 vfs objects = catia fruit streams_xattr acl_xattr xattr_tdb
2492 fruit:resource = file
2493 fruit:metadata = netatalk
2494 fruit:locking = netatalk
2495 fruit:encoding = native
2496 fruit:veto_appledouble = no
2500 # This is used by vfs.fruit tests that require real fs xattr
2501 vfs objects = catia fruit streams_xattr acl_xattr
2502 fruit:resource = file
2503 fruit:metadata = netatalk
2504 fruit:locking = netatalk
2505 fruit:encoding = native
2506 fruit:veto_appledouble = no
2508 [vfs_fruit_metadata_stream]
2510 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2511 fruit:resource = file
2512 fruit:metadata = stream
2513 fruit:veto_appledouble = no
2515 [vfs_fruit_stream_depot]
2517 vfs objects = fruit streams_depot acl_xattr xattr_tdb
2518 fruit:resource = stream
2519 fruit:metadata = stream
2520 fruit:veto_appledouble = no
2524 vfs objects = streams_xattr acl_xattr xattr_tdb
2526 [vfs_wo_fruit_stream_depot]
2528 vfs objects = streams_depot acl_xattr xattr_tdb
2530 [vfs_fruit_timemachine]
2532 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2533 fruit:resource = file
2534 fruit:metadata = stream
2535 fruit:time machine = yes
2536 fruit:time machine max size = 32K
2538 [vfs_fruit_wipe_intentionally_left_blank_rfork]
2540 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2541 fruit:resource = file
2542 fruit:metadata = stream
2543 fruit:wipe_intentionally_left_blank_rfork = true
2544 fruit:delete_empty_adfiles = false
2545 fruit:veto_appledouble = no
2547 [vfs_fruit_delete_empty_adfiles]
2549 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2550 fruit:resource = file
2551 fruit:metadata = stream
2552 fruit:wipe_intentionally_left_blank_rfork = true
2553 fruit:delete_empty_adfiles = true
2554 fruit:veto_appledouble = no
2556 [vfs_fruit_zero_fileid]
2558 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2559 fruit:resource = file
2560 fruit:metadata = stream
2561 fruit:zero_file_id=yes
2564 path = $badnames_shrdir
2568 path = $manglenames_shrdir
2576 path = $widelinks_shrdir
2581 path = $fsrvp_shrdir
2582 comment = fake shapshots using rsync
2583 vfs objects = shell_snap shadow_copy2
2584 shell_snap:check path command = $fake_snap_pl --check
2585 shell_snap:create command = $fake_snap_pl --create
2586 shell_snap:delete command = $fake_snap_pl --delete
2587 # a relative path here fails, the snapshot dir is no longer found
2588 shadow:snapdir = $fsrvp_shrdir/.snapshots
2591 path = $shadow_shrdir
2592 comment = previous versions snapshots under mount point
2593 vfs objects = shadow_copy2
2594 shadow:mountpoint = $shadow_mntdir
2597 path = $shadow_shrdir
2598 comment = previous versions snapshots outside mount point
2599 vfs objects = shadow_copy2
2600 shadow:mountpoint = $shadow_mntdir
2601 shadow:snapdir = $shadow_tstdir/.snapshots
2604 path = $shadow_shrdir
2605 comment = previous versions with subvolume snapshots, snapshots under base dir
2606 vfs objects = shadow_copy2
2607 shadow:mountpoint = $shadow_mntdir
2608 shadow:basedir = $shadow_basedir
2609 shadow:snapdir = $shadow_basedir/.snapshots
2612 path = $shadow_shrdir
2613 comment = previous versions with subvolume snapshots, snapshots outside mount point
2614 vfs objects = shadow_copy2
2615 shadow:mountpoint = $shadow_mntdir
2616 shadow:basedir = $shadow_basedir
2617 shadow:snapdir = $shadow_tstdir/.snapshots
2620 path = $shadow_shrdir
2621 comment = previous versions at volume root snapshots under mount point
2622 vfs objects = shadow_copy2
2623 shadow:mountpoint = $shadow_shrdir
2626 path = $shadow_shrdir
2627 comment = previous versions at volume root snapshots outside mount point
2628 vfs objects = shadow_copy2
2629 shadow:mountpoint = $shadow_shrdir
2630 shadow:snapdir = $shadow_tstdir/.snapshots
2633 path = $shadow_shrdir
2634 comment = previous versions snapshots everywhere
2635 vfs objects = shadow_copy2
2636 shadow:mountpoint = $shadow_mntdir
2637 shadow:snapdirseverywhere = yes
2640 path = $shadow_shrdir
2641 comment = previous versions using snapsharepath
2642 vfs objects = shadow_copy2
2643 shadow:mountpoint = $shadow_mntdir
2644 shadow:snapdir = $shadow_tstdir/.snapshots
2645 shadow:snapsharepath = share
2648 comment = Testing shadow:format with default option
2649 vfs object = shadow_copy2
2650 path = $shadow_shrdir
2653 shadow:mountpoint = $shadow_mntdir
2654 shadow:basedir = $shadow_basedir
2655 shadow:snapdir = $shadow_basedir/.snapshots
2656 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2659 comment = Testing shadow:format with only date component
2660 vfs object = shadow_copy2
2661 path = $shadow_shrdir
2664 shadow:mountpoint = $shadow_mntdir
2665 shadow:basedir = $shadow_basedir
2666 shadow:snapdir = $shadow_basedir/.snapshots
2667 shadow:format = \@GMT-%Y-%m-%d
2670 comment = Testing shadow:format with some hardcoded prefix
2671 vfs object = shadow_copy2
2672 path = $shadow_shrdir
2675 shadow:mountpoint = $shadow_mntdir
2676 shadow:basedir = $shadow_basedir
2677 shadow:snapdir = $shadow_basedir/.snapshots
2678 shadow:format = snap\@GMT-%Y.%m.%d-%H.%M.%S
2681 comment = Testing shadow:format with modified format
2682 vfs object = shadow_copy2
2683 path = $shadow_shrdir
2686 shadow:mountpoint = $shadow_mntdir
2687 shadow:basedir = $shadow_basedir
2688 shadow:snapdir = $shadow_basedir/.snapshots
2689 shadow:format = \@GMT-%Y.%m.%d-%H_%M_%S-snap
2692 comment = Testing shadow:snapprefix regex
2693 vfs object = shadow_copy2
2694 path = $shadow_shrdir
2697 shadow:mountpoint = $shadow_mntdir
2698 shadow:basedir = $shadow_basedir
2699 shadow:snapdir = $shadow_basedir/.snapshots
2700 shadow:snapprefix = \^s[a-z]*p\$
2701 shadow:format = _GMT-%Y.%m.%d-%H.%M.%S
2704 comment = Testing shadow:snapprefix with delim regex
2705 vfs object = shadow_copy2
2706 path = $shadow_shrdir
2709 shadow:mountpoint = $shadow_mntdir
2710 shadow:basedir = $shadow_basedir
2711 shadow:snapdir = $shadow_basedir/.snapshots
2712 shadow:delimiter = \@GMT
2713 shadow:snapprefix = [a-z]*
2714 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2717 path = $shadow_shrdir
2718 comment = previous versions with wide links allowed
2719 vfs objects = shadow_copy2
2720 shadow:mountpoint = $shadow_mntdir
2724 path = $shadow_tstdir
2725 comment = previous versions snapshots under mount point
2726 vfs objects = shadow_copy2 streams_xattr error_inject
2728 error_inject:pwrite = EBADF
2729 shadow:mountpoint = $shadow_tstdir
2732 path = $shrdir/dfree
2733 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2734 admin users = $unix_name
2735 include = $dfqconffile
2737 path = $shrdir/dfree
2738 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2739 admin users = $unix_name
2740 include = $dfqconffile
2741 dfree cache time = 60
2743 path = $shrdir/dfree
2744 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2746 include = $dfqconffile
2748 path = $shrdir/quota
2749 admin users = $unix_name
2751 [acl_xattr_ign_sysacl_posix]
2753 acl_xattr:ignore system acls = yes
2754 acl_xattr:default acl style = posix
2755 [acl_xattr_ign_sysacl_windows]
2757 acl_xattr:ignore system acls = yes
2758 acl_xattr:default acl style = windows
2762 mangled names = illegal
2766 path = $nosymlinks_shrdir
2767 follow symlinks = no
2771 path = $local_symlinks_shrdir
2772 follow symlinks = yes
2776 kernel oplocks = yes
2777 vfs objects = streams_xattr xattr_tdb
2781 vfs objects = streams_xattr xattr_tdb
2785 smbd:find async delay usec = 10000
2788 vfs objects = error_inject
2789 include = $errorinjectconf
2793 vfs objects = delay_inject
2794 kernel share modes = no
2797 include = $delayinjectconf
2801 vfs objects = delay_inject
2802 delay_inject:pread_send = 2000
2803 delay_inject:pwrite_send = 2000
2807 vfs objects = delay_inject
2808 delay_inject:brl_lock_windows = 90
2809 delay_inject:brl_lock_windows_use_timer = yes
2813 vfs objects = delay_inject
2814 delay_inject:brl_lock_windows = 90
2815 delay_inject:brl_lock_windows_use_timer = no
2818 path = $prefix_abs/share
2819 delete readonly = yes
2823 my $net = Samba::bindir_path($self, "net");
2825 $cmd .= "UID_WRAPPER_ROOT=1 ";
2826 $cmd .= "SMB_CONF_PATH=\"$conffile\" ";
2827 $cmd .= "$net setlocalsid $samsid";
2829 my $net_ret = system($cmd);
2830 if ($net_ret != 0) {
2831 warn("net setlocalsid failed: $net_ret\n$cmd");
2835 unless (open(ERRORCONF, ">$errorinjectconf")) {
2836 warn("Unable to open $errorinjectconf");
2841 unless (open(DELAYCONF, ">$delayinjectconf")) {
2842 warn("Unable to open $delayinjectconf");
2847 unless (open(DFQCONF, ">$dfqconffile")) {
2848 warn("Unable to open $dfqconffile");
2853 unless (open(DELAYCONF, ">$globalinjectconf")) {
2854 warn("Unable to open $globalinjectconf");
2860 ## create a test account
2863 unless (open(PASSWD, ">$nss_wrapper_passwd")) {
2864 warn("Unable to open $nss_wrapper_passwd");
2867 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
2868 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
2869 pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2870 pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2871 userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
2872 pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false
2873 force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false
2874 smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false
2875 user1:x:$uid_user1:$gid_nogroup:user1 gecos:$prefix_abs:/bin/false
2876 user2:x:$uid_user2:$gid_nogroup:user2 gecos:$prefix_abs:/bin/false
2877 gooduser:x:$uid_gooduser:$gid_domusers:gooduser gecos:$prefix_abs:/bin/false
2878 eviluser:x:$uid_eviluser:$gid_domusers:eviluser gecos::/bin/false
2879 slashuser:x:$uid_slashuser:$gid_domusers:slashuser gecos:/:/bin/false
2881 if ($unix_uid != 0) {
2882 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
2887 unless (open(GROUP, ">$nss_wrapper_group")) {
2888 warn("Unable to open $nss_wrapper_group");
2891 print GROUP "nobody:x:$gid_nobody:
2892 nogroup:x:$gid_nogroup:nobody
2893 $unix_name-group:x:$unix_gids[0]:
2894 domusers:X:$gid_domusers:
2895 domadmins:X:$gid_domadmins:
2896 userdup:x:$gid_userdup:$unix_name
2897 everyone:x:$gid_everyone:
2898 force_user:x:$gid_force_user:
2900 if ($unix_gids[0] != 0) {
2901 print GROUP "root:x:$gid_root:
2908 my $hostname = lc($server);
2909 unless (open(HOSTS, ">>$nss_wrapper_hosts")) {
2910 warn("Unable to open $nss_wrapper_hosts");
2913 print HOSTS "${server_ip} ${hostname}.samba.example.com ${hostname}\n";
2914 print HOSTS "${server_ipv6} ${hostname}.samba.example.com ${hostname}\n";
2917 $resolv_conf = "$privatedir/no_resolv.conf" unless defined($resolv_conf);
2919 foreach my $evlog (@eventlog_list) {
2920 my $evlogtdb = "$eventlogdir/$evlog.tdb";
2921 open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
2925 $createuser_env{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2926 $createuser_env{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2927 $createuser_env{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2928 $createuser_env{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2929 if ($ENV{SAMBA_DNS_FAKING}) {
2930 $createuser_env{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2932 $createuser_env{RESOLV_WRAPPER_CONF} = $resolv_conf;
2934 $createuser_env{RESOLV_CONF} = $resolv_conf;
2936 createuser($self, $unix_name, $password, $conffile, \%createuser_env) || die("Unable to create user");
2937 createuser($self, "force_user", $password, $conffile, \%createuser_env) || die("Unable to create force_user");
2938 createuser($self, "smbget_user", $password, $conffile, \%createuser_env) || die("Unable to create smbget_user");
2939 createuser($self, "user1", $password, $conffile, \%createuser_env) || die("Unable to create user1");
2940 createuser($self, "user2", $password, $conffile, \%createuser_env) || die("Unable to create user2");
2941 createuser($self, "gooduser", $password, $conffile, \%createuser_env) || die("Unable to create gooduser");
2942 createuser($self, "eviluser", $password, $conffile, \%createuser_env) || die("Unable to create eviluser");
2943 createuser($self, "slashuser", $password, $conffile, \%createuser_env) || die("Unable to create slashuser");
2945 open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
2946 print DNS_UPDATE_LIST "A $server. $server_ip\n";
2947 print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n";
2948 close(DNS_UPDATE_LIST);
2952 $ret{SERVER_IP} = $server_ip;
2953 $ret{SERVER_IPV6} = $server_ipv6;
2954 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
2955 $ret{NMBD_TEST_LOG_POS} = 0;
2956 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
2957 $ret{WINBINDD_TEST_LOG_POS} = 0;
2958 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
2959 $ret{SMBD_TEST_LOG_POS} = 0;
2960 $ret{SERVERCONFFILE} = $conffile;
2961 $ret{TESTENV_DIR} = $prefix_abs;
2962 $ret{CONFIGURATION} ="-s $conffile";
2963 $ret{LOCK_DIR} = $lockdir;
2964 $ret{SERVER} = $server;
2965 $ret{USERNAME} = $unix_name;
2966 $ret{USERID} = $unix_uid;
2967 $ret{DOMAIN} = $domain;
2968 $ret{SAMSID} = $samsid;
2969 $ret{NETBIOSNAME} = $server;
2970 $ret{PASSWORD} = $password;
2971 $ret{PIDDIR} = $piddir;
2972 $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir;
2973 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
2974 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
2975 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2976 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2977 $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2978 $ret{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2979 $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
2980 $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind";
2981 if ($ENV{SAMBA_DNS_FAKING}) {
2982 $ret{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2984 $ret{RESOLV_WRAPPER_CONF} = $resolv_conf;
2986 $ret{RESOLV_CONF} = $resolv_conf;
2987 $ret{LOCAL_PATH} = "$shrdir";
2988 $ret{LOGDIR} = $logdir;
2991 # Avoid hitting system krb5.conf -
2992 # An env that needs Kerberos will reset this to the real
2995 $ret{KRB5_CONFIG} = abs_path($prefix) . "/no_krb5.conf";
2997 # Define KRB5CCNAME for each environment we set up
2998 $ret{KRB5_CCACHE} = abs_path($prefix) . "/krb5ccache";
2999 $ENV{KRB5CCNAME} = $ret{KRB5_CCACHE};
3004 sub wait_for_start($$$$$)
3006 my ($self, $envvars, $nmbd, $winbindd, $smbd) = @_;
3011 if ($nmbd eq "yes") {
3014 # give time for nbt server to register its names
3015 print "checking for nmbd\n";
3017 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
3018 my $nmblookup = Samba::bindir_path($self, "nmblookup");
3021 $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
3025 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
3026 system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
3027 system("$nmblookup $envvars->{CONFIGURATION} -U 10.255.255.255 __SAMBA__");
3028 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
3031 } while ($ret != 0 && $count < 10);
3033 print "NMBD not reachable after 10 retries\n";
3034 teardown_env($self, $envvars);
3039 if ($winbindd eq "yes") {
3040 print "checking for winbindd\n";
3042 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
3043 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3044 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3045 $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping-dc";
3048 $ret = system($cmd);
3053 } while ($ret != 0 && $count < 20);
3055 print "WINBINDD not reachable after 20 seconds\n";
3056 teardown_env($self, $envvars);
3061 if ($smbd eq "yes") {
3062 # make sure smbd is also up set
3063 print "wait for smbd\n";
3067 if (defined($envvars->{GNUTLS_FORCE_FIPS_MODE})) {
3068 # We don't have NTLM in FIPS mode, so lets use
3069 # smbcontrol instead of smbclient.
3070 $cmd = Samba::bindir_path($self, "smbcontrol");
3071 $cmd .= " $envvars->{CONFIGURATION}";
3072 $cmd .= " smbd ping";
3074 # This uses NTLM which is not available in FIPS
3075 $cmd = Samba::bindir_path($self, "smbclient");
3076 $cmd .= " $envvars->{CONFIGURATION}";
3077 $cmd .= " -L $envvars->{SERVER}";
3079 $cmd .= " -I $envvars->{SERVER_IP}";
3083 $ret = system($cmd);
3088 } while ($ret != 0 && $count < 20);
3090 print "SMBD failed to start up in a reasonable time (20sec)\n";
3091 teardown_env($self, $envvars);
3096 # Ensure we have domain users mapped.
3097 $netcmd = "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3098 $netcmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3099 $netcmd .= "UID_WRAPPER_ROOT='1' ";
3100 $netcmd .= Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} ";
3102 $cmd = $netcmd . "groupmap delete ntgroup=domusers";
3103 $ret = system($cmd);
3105 $cmd = $netcmd . "groupmap add rid=513 unixgroup=domusers type=domain";
3106 $ret = system($cmd);
3108 print("\"$cmd\" failed\n");
3112 $cmd = $netcmd . "groupmap delete ntgroup=domadmins";
3113 $ret = system($cmd);
3115 $cmd = $netcmd . "groupmap add rid=512 unixgroup=domadmins type=domain";
3116 $ret = system($cmd);
3118 print("\"$cmd\" failed\n");
3122 $cmd = $netcmd . "groupmap delete ntgroup=everyone";
3123 $ret = system($cmd);
3125 $cmd = $netcmd . "groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin";
3126 $ret = system($cmd);
3128 print("\"$cmd\" failed\n");
3132 # note: creating builtin groups requires winbindd for the
3134 my $create_builtin_users = "no";
3135 if ($winbindd eq "yes") {
3136 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
3137 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3138 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3139 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
3140 my $wbinfo_out = qx($cmd 2>&1);
3142 # wbinfo doesn't give us a better error code then
3143 # WBC_ERR_DOMAIN_NOT_FOUND, but at least that's
3144 # different then WBC_ERR_WINBIND_NOT_AVAILABLE
3145 if ($wbinfo_out !~ /WBC_ERR_DOMAIN_NOT_FOUND/) {
3146 print("Failed to run \"wbinfo --sid-to-gid=S-1-5-32-545\": $wbinfo_out");
3147 teardown_env($self, $envvars);
3150 $create_builtin_users = "yes";
3153 if ($create_builtin_users eq "yes") {
3154 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
3155 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3156 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3157 $cmd .= Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
3158 $cmd .= "sam createbuiltingroup Users";
3159 $ret = system($cmd);
3161 print "Failed to create BUILTIN\\Users group\n";
3162 teardown_env($self, $envvars);
3166 $cmd = Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
3167 $cmd .= "cache del IDMAP/SID2XID/S-1-5-32-545";
3170 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
3171 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3172 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3173 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
3174 $ret = system($cmd);
3176 print "Missing \"BUILTIN\\Users\", did net sam createbuiltingroup Users fail?\n";
3177 teardown_env($self, $envvars);
3182 print $self->getlog_env($envvars);
3188 ## provision and start of ctdb
3192 my ($self, $prefix) = @_;
3195 my $data = $self->provision_ctdb($prefix, $num_nodes);
3196 $data or return undef;
3198 my $rc = $self->check_or_start_ctdb($data);
3200 print("check_or_start_ctdb() failed\n");
3204 $rc = $self->wait_for_start_ctdb($data);
3206 print "Cluster startup failed\n";
3213 sub provision_ctdb($$$$)
3215 my ($self, $prefix, $num_nodes, $no_delete_prefix) = @_;
3218 print "PROVISIONING CTDB...\n";
3220 my $prefix_abs = abs_path($prefix);
3223 # check / create directories:
3225 die ("prefix_abs = ''") if $prefix_abs eq "";
3226 die ("prefix_abs = '/'") if $prefix_abs eq "/";
3228 mkdir ($prefix_abs, 0777);
3230 print "CREATE CTDB TEST ENVIRONMENT in '$prefix_abs'...\n";
3232 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
3233 system("rm -rf $prefix_abs/*");
3240 for (my $i = 0; $i < $num_nodes; $i++) {
3242 my $server_name = "ctdb${i}";
3243 my $pub_iface = Samba::get_interface($server_name);
3244 my $ip = Samba::get_ipv4_addr($server_name);
3246 $node{NODE_NUMBER} = "$i";
3247 $node{SERVER_NAME} = "$server_name";
3248 $node{SOCKET_WRAPPER_DEFAULT_IFACE} = "$pub_iface";
3251 push(@nodes, \%node);
3257 my $nodes_file = "$prefix/nodes.in";
3258 unless (open(NODES, ">$nodes_file")) {
3259 warn("Unable to open nodesfile '$nodes_file'");
3262 for (my $i = 0; $i < $num_nodes; $i++) {
3263 my $ip = $nodes[$i]->{IP};
3264 print NODES "${ip}\n";
3269 # local_daemons.sh setup
3271 # Socket wrapper setup is done by selftest.pl, so don't use
3272 # the CTDB-specific setup
3275 $cmd .= "ctdb/tests/local_daemons.sh " . $prefix_abs . " setup";
3276 $cmd .= " -n " . $num_nodes;
3277 $cmd .= " -N " . $nodes_file;
3278 # CTDB should not attempt to manage public addresses -
3279 # clients should just connect to CTDB private addresses
3280 $cmd .= " -P " . "/dev/null";
3282 my $ret = system($cmd);
3284 print("\"$cmd\" failed\n");
3289 # Unix domain socket and node directory for each daemon
3291 for (my $i = 0; $i < $num_nodes; $i++) {
3292 my ($cmd, $ret, $out);
3294 my $cmd_prefix = "ctdb/tests/local_daemons.sh ${prefix_abs}";
3300 $cmd = "${cmd_prefix} print-socket ${i}";
3305 print("\"$cmd\" failed\n");
3309 $nodes[$i]->{SOCKET_FILE} = "$out";
3315 $cmd = "${cmd_prefix} onnode ${i} 'echo \$CTDB_BASE'";
3320 print("\"$cmd\" failed\n");
3324 $nodes[$i]->{NODE_PREFIX} = "$out";
3329 $ret{CTDB_PREFIX} = "$prefix";
3330 $ret{NUM_NODES} = $num_nodes;
3331 $ret{CTDB_NODES} = \@nodes;
3332 $ret{CTDB_NODES_FILE} = $nodes_file;
3337 sub check_or_start_ctdb($$) {
3338 my ($self, $data) = @_;
3340 my $prefix = $data->{CTDB_PREFIX};
3341 my $num_nodes = $data->{NUM_NODES};
3342 my $nodes = $data->{CTDB_NODES};
3345 # Share a single stdin pipe for all nodes
3346 pipe($STDIN_READER, $data->{CTDB_STDIN_PIPE});
3348 for (my $i = 0; $i < $num_nodes; $i++) {
3349 my $node = $nodes->[$i];
3351 $node->{STDIN_PIPE} = $data->{CTDB_STDIN_PIPE};
3353 my $cmd = "ctdb/tests/local_daemons.sh";
3354 my @full_cmd = ("$cmd", "$prefix", "start", "$i");
3355 # Dummy environment variables to avoid
3356 # Samba3::get_env_for_process() from generating them
3357 # and including UID_WRAPPER_ROOT=1, which causes
3358 # "Unable to secure ctdb socket" error.
3364 BINARY_PATH => $cmd,
3365 FULL_CMD => [ @full_cmd ],
3367 LOG_FILE => "/dev/null",
3368 ENV_VARS => $env_vars,
3371 print "STARTING CTDBD (node ${i})\n";
3373 # This does magic with $STDIN_READER, so use it
3374 my $ret = Samba::fork_and_exec($self,
3380 print("\"$cmd\" failed\n");
3381 teardown_env_ctdb($self, $data);
3386 close($STDIN_READER);
3391 sub wait_for_start_ctdb($$)
3393 my ($self, $data) = @_;
3395 my $prefix = $data->{CTDB_PREFIX};
3397 print "Wait for ctdbd...\n";
3399 my $ctdb = Samba::bindir_path($self, "ctdb");
3401 $cmd .= "ctdb/tests/local_daemons.sh ${prefix} onnode all";
3402 $cmd .= " ${ctdb} nodestatus all 2>&1";
3405 my $wait_seconds = 60;
3408 until ($count > $wait_seconds) {
3412 print "\ncluster became healthy\n";
3415 print "Waiting for CTDB...\n";
3420 if ($count > $wait_seconds) {
3421 print "\nGiving up to wait for CTDB...\n";
3423 print "CTDB log:\n";
3424 $cmd = "ctdb/tests/local_daemons.sh ${prefix} print-log all >&2";
3426 teardown_env_ctdb($self, $data);
3430 print "\nCTDB initialized\n";