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';
22 my $smbd_build_options = Samba::bindir_path($self, "smbd") . " -b|";
23 open(IN, $smbd_build_options) or die("Unable to run $smbd_build_options: $!");
32 # If we were not built with ADS support, pretend we were never even available
33 print "smbd does not have ADS support\n" unless $found_ads;
37 # return smb.conf parameters applicable to @path, based on the underlying
39 sub get_fs_specific_conf($$)
41 my ($self, $path) = @_;
43 my $stat_out = `stat --file-system $path` or return "";
45 if ($stat_out =~ m/Type:\s+btrfs/) {
46 $mods .= "streams_xattr btrfs";
50 return "vfs objects = $mods";
57 my ($classname, $SambaCtx, $bindir, $srcdir, $server_maxtime) = @_;
58 my $self = { vars => {},
59 SambaCtx => $SambaCtx,
62 server_maxtime => $server_maxtime
70 my ($self, $envvars) = @_;
72 if (defined($envvars->{CTDB_PREFIX})) {
73 $self->teardown_env_ctdb($envvars);
75 $self->teardown_env_samba($envvars);
81 sub teardown_env_samba($$)
83 my ($self, $envvars) = @_;
86 # This should cause smbd to terminate gracefully
87 close($envvars->{STDIN_PIPE});
89 my $smbdpid = $envvars->{SMBD_TL_PID};
90 my $nmbdpid = $envvars->{NMBD_TL_PID};
91 my $winbinddpid = $envvars->{WINBINDD_TL_PID};
93 # This should give it time to write out the gcov data
95 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
96 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
97 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
100 && $winbinddchild == -1) {
107 if ($count <= 20 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
111 $self->stop_sig_term($smbdpid);
112 $self->stop_sig_term($nmbdpid);
113 $self->stop_sig_term($winbinddpid);
116 until ($count > 10) {
117 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
118 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
119 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
122 && $winbinddchild == -1) {
129 if ($count <= 10 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
133 warn("timelimit process did not quit on SIGTERM, sending SIGKILL");
134 $self->stop_sig_kill($smbdpid);
135 $self->stop_sig_kill($nmbdpid);
136 $self->stop_sig_kill($winbinddpid);
141 sub teardown_env_ctdb($$)
143 my ($self, $data) = @_;
145 if (defined($data->{SAMBA_NODES})) {
146 my $num_nodes = $data->{NUM_NODES};
147 my $nodes = $data->{SAMBA_NODES};
149 for (my $i = 0; $i < $num_nodes; $i++) {
150 if (defined($nodes->[$i])) {
151 $self->teardown_env_samba($nodes->[$i]);
156 close($data->{CTDB_STDIN_PIPE});
158 if (not defined($data->{SAMBA_NODES})) {
159 # Give waiting children time to exit
166 sub getlog_env_app($$$)
168 my ($self, $envvars, $name) = @_;
170 my $title = "$name LOG of: $envvars->{NETBIOSNAME}\n";
173 open(LOG, "<".$envvars->{$name."_TEST_LOG"});
175 seek(LOG, $envvars->{$name."_TEST_LOG_POS"}, SEEK_SET);
179 $envvars->{$name."_TEST_LOG_POS"} = tell(LOG);
182 return "" if $out eq $title;
189 my ($self, $envvars) = @_;
192 $ret .= $self->getlog_env_app($envvars, "SMBD");
193 $ret .= $self->getlog_env_app($envvars, "NMBD");
194 $ret .= $self->getlog_env_app($envvars, "WINBINDD");
201 my ($self, $envvars) = @_;
203 my $childpid = waitpid(-1, WNOHANG);
209 # Declare the environments Samba3 makes available.
210 # To be set up, they will be called as
211 # samba3->setup_$envname($self, $path, $dep_1_vars, $dep_2_vars, ...)
212 %Samba3::ENV_DEPS = (
213 # name => [dep_1, dep_2, ...],
215 nt4_dc_schannel => [],
222 nt4_member => ["nt4_dc"],
224 ad_member => ["ad_dc", "fl2008r2dc", "fl2003dc"],
225 ad_member_rfc2307 => ["ad_dc_ntvfs"],
226 ad_member_idmap_rid => ["ad_dc"],
227 ad_member_idmap_ad => ["fl2008r2dc"],
229 clusteredmember => ["nt4_dc"],
232 %Samba3::ENV_DEPS_POST = ();
236 my ($self, $path) = @_;
238 print "PROVISIONING NT4 DC...";
240 my $nt4_dc_options = "
245 raw NTLMv2 auth = yes
246 server schannel = auto
248 rpc_server:epmapper = external
249 rpc_server:spoolss = external
250 rpc_server:lsarpc = external
251 rpc_server:samr = external
252 rpc_server:netlogon = external
253 rpc_server:register_embedded_np = yes
254 rpc_server:FssagentRpc = external
256 rpc_daemon:epmd = fork
257 rpc_daemon:spoolssd = fork
258 rpc_daemon:lsasd = fork
259 rpc_daemon:fssd = fork
260 fss: sequence timeout = 1
261 check parent directory delete on close = yes
264 my $vars = $self->provision(
266 domain => "SAMBA-TEST",
267 server => "LOCALNT4DC2",
268 password => "localntdc2pass",
269 extra_options => $nt4_dc_options);
271 $vars or return undef;
273 if (not $self->check_or_start(
281 $vars->{DOMSID} = $vars->{SAMSID};
282 $vars->{DC_SERVER} = $vars->{SERVER};
283 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
284 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
285 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
286 $vars->{DC_USERNAME} = $vars->{USERNAME};
287 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
292 sub setup_nt4_dc_schannel
294 my ($self, $path) = @_;
296 print "PROVISIONING NT4 DC WITH SERVER SCHANNEL ...";
303 rpc_server:epmapper = external
304 rpc_server:spoolss = external
305 rpc_server:lsarpc = external
306 rpc_server:samr = external
307 rpc_server:netlogon = external
308 rpc_server:register_embedded_np = yes
310 rpc_daemon:epmd = fork
311 rpc_daemon:spoolssd = fork
312 rpc_daemon:lsasd = fork
314 server schannel = yes
315 # used to reproduce bug #12772
316 server max protocol = SMB2_02
319 my $vars = $self->provision(
321 domain => "NT4SCHANNEL",
322 server => "LOCALNT4DC9",
323 password => "localntdc9pass",
324 extra_options => $pdc_options);
326 $vars or return undef;
328 if (not $self->check_or_start(
336 $vars->{DOMSID} = $vars->{SAMSID};
337 $vars->{DC_SERVER} = $vars->{SERVER};
338 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
339 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
340 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
341 $vars->{DC_USERNAME} = $vars->{USERNAME};
342 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
349 my ($self, $prefix, $nt4_dc_vars) = @_;
353 print "PROVISIONING MEMBER...";
355 my $require_mutexes = "dbwrap_tdb_require_mutexes:* = yes";
356 if ($ENV{SELFTEST_DONT_REQUIRE_TDB_MUTEX_SUPPORT} // '' eq "1") {
357 $require_mutexes = "";
360 my $member_options = "
362 dbwrap_tdb_mutexes:* = yes
365 my $ret = $self->provision(
367 domain => $nt4_dc_vars->{DOMAIN},
368 server => "LOCALNT4MEMBER3",
369 password => "localnt4member3pass",
370 extra_options => $member_options);
372 $ret or return undef;
374 my $nmblookup = Samba::bindir_path($self, "nmblookup");
376 print "Waiting for the LOGON SERVER registration ...\n";
377 $rc = system("$nmblookup $ret->{CONFIGURATION} $ret->{DOMAIN}\#1c");
382 } while ($rc != 0 && $count < 10);
384 print "NMBD not reachable after 10 retries\n";
385 teardown_env($self, $ret);
389 my $net = Samba::bindir_path($self, "net");
390 # Add hosts file for name lookups
391 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
392 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
393 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
394 $cmd .= "$net rpc join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
395 $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}";
397 if (system($cmd) != 0) {
398 warn("Join failed\n$cmd");
402 # Add hosts file for name lookups
403 $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
404 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
405 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
406 $cmd .= "$net $ret->{CONFIGURATION} primarytrust dumpinfo | grep -q 'REDACTED SECRET VALUES'";
408 if (system($cmd) != 0) {
409 warn("check failed\n$cmd");
413 if (not $self->check_or_start(
421 $ret->{DOMSID} = $nt4_dc_vars->{DOMSID};
422 $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
423 $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
424 $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
425 $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME};
426 $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME};
427 $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD};
432 sub setup_clusteredmember
434 my ($self, $prefix, $nt4_dc_vars) = @_;
440 print "PROVISIONING CLUSTEREDMEMBER...\n";
442 my $prefix_abs = abs_path($prefix);
443 mkdir($prefix_abs, 0777);
445 my $server_name = "CLUSTEREDMEMBER";
447 my $ctdb_data = $self->setup_ctdb($prefix);
449 if (not $ctdb_data) {
450 print "No ctdb data\n";
454 print "PROVISIONING CLUSTERED SAMBA...\n";
456 my $num_nodes = $ctdb_data->{NUM_NODES};
457 my $nodes = $ctdb_data->{CTDB_NODES};
459 # Enable cleanup of earlier nodes if a later node fails
460 $ctdb_data->{SAMBA_NODES} = \@retvals;
462 for (my $i = 0; $i < $num_nodes; $i++) {
463 my $node = $nodes->[$i];
464 my $socket = $node->{SOCKET_FILE};
465 my $server_name = $node->{SERVER_NAME};
466 my $pub_iface = $node->{SOCKET_WRAPPER_DEFAULT_IFACE};
467 my $node_prefix = $node->{NODE_PREFIX};
469 print "NODE_PREFIX=${node_prefix}\n";
470 print "SOCKET=${socket}\n";
472 my $require_mutexes = "dbwrap_tdb_require_mutexes:* = yes";
473 if ($ENV{SELFTEST_DONT_REQUIRE_TDB_MUTEX_SUPPORT} // '' eq "1") {
474 $require_mutexes = "" ;
477 my $member_options = "
481 ctdbd socket = ${socket}
482 dbwrap_tdb_mutexes:* = yes
486 my $node_ret = $self->provision(
487 prefix => "$node_prefix",
488 domain => $nt4_dc_vars->{DOMAIN},
489 server => "$server_name",
490 password => "clustermember8pass",
491 netbios_name => "CLUSTEREDMEMBER",
492 share_dir => "${prefix_abs}/shared",
493 extra_options => $member_options,
494 no_delete_prefix => 1);
496 print "Provision node $i failed\n";
497 teardown_env($self, $ctdb_data);
501 my $nmblookup = Samba::bindir_path($self, "nmblookup");
503 print "Waiting for the LOGON SERVER registration ...\n";
504 $rc = system("$nmblookup $node_ret->{CONFIGURATION} " .
505 "$node_ret->{DOMAIN}\#1c");
510 } while ($rc != 0 && $count < 10);
513 print "NMBD not reachable after 10 retries\n";
514 teardown_env($self, $node_ret);
515 teardown_env($self, $ctdb_data);
519 push(@retvals, $node_ret);
522 $ret = {%$ctdb_data, %{$retvals[0]}};
524 my $net = Samba::bindir_path($self, "net");
526 $cmd .= "UID_WRAPPER_ROOT=1 ";
527 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
528 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
529 $cmd .= "$net join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
530 $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}";
532 if (system($cmd) != 0) {
533 warn("Join failed\n$cmd");
534 teardown_env($self, $ret);
538 for (my $i=0; $i<@retvals; $i++) {
539 my $node_provision = $retvals[$i];
541 $ok = $self->check_or_start(
542 env_vars => $node_provision,
545 child_cleanup => sub {
547 my $fh = $_->{STDIN_PIPE};
548 close($fh) if defined($fh);
551 teardown_env($self, $ret);
556 $ret->{DOMSID} = $nt4_dc_vars->{DOMSID};
557 $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
558 $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
559 $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
560 $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME};
561 $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME};
562 $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD};
569 my ($self, $prefix, $dcvars, $trustvars_f, $trustvars_e) = @_;
571 my $prefix_abs = abs_path($prefix);
574 # If we didn't build with ADS, pretend this env was never available
575 if (not $self->have_ads()) {
579 print "PROVISIONING S3 AD MEMBER...";
581 mkdir($prefix_abs, 0777);
583 my $share_dir="$prefix_abs/share";
584 push(@dirs, $share_dir);
586 my $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}";
587 push(@dirs, $substitution_path);
589 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice";
590 push(@dirs, $substitution_path);
592 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice/G_domain users";
593 push(@dirs, $substitution_path);
595 # Using '/' as the winbind separator is a bad idea ...
596 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}";
597 push(@dirs, $substitution_path);
599 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice";
600 push(@dirs, $substitution_path);
602 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}";
603 push(@dirs, $substitution_path);
605 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}/domain users";
606 push(@dirs, $substitution_path);
608 my $member_options = "
610 workgroup = $dcvars->{DOMAIN}
611 realm = $dcvars->{REALM}
612 netbios aliases = foo bar
613 template homedir = /home/%D/%G/%U
614 auth event notification = true
615 password server = $dcvars->{SERVER}
616 winbind scan trusted domains = no
617 winbind use krb5 enterprise principals = yes
620 path = $share_dir/D_%D/U_%U/G_%G
624 path = $share_dir/D_%D/u_%u/g_%g
629 my $ret = $self->provision(
631 domain => $dcvars->{DOMAIN},
632 server => "LOCALADMEMBER",
633 password => "loCalMemberPass",
634 extra_options => $member_options,
635 dc_server_ip => $dcvars->{SERVER_IP},
636 dc_server_ipv6 => $dcvars->{SERVER_IPV6});
638 $ret or return undef;
640 mkdir($_, 0777) foreach(@dirs);
643 $ret->{DOMAIN} = $dcvars->{DOMAIN};
644 $ret->{REALM} = $dcvars->{REALM};
645 $ret->{DOMSID} = $dcvars->{DOMSID};
649 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
650 $ctx->{domain} = $dcvars->{DOMAIN};
651 $ctx->{realm} = $dcvars->{REALM};
652 $ctx->{dnsname} = lc($dcvars->{REALM});
653 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
654 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
655 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
656 Samba::mk_krb5_conf($ctx, "");
658 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
659 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
661 my $net = Samba::bindir_path($self, "net");
662 # Add hosts file for name lookups
663 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
664 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
665 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
666 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
668 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
670 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
671 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
672 $cmd .= "$net join $ret->{CONFIGURATION}";
673 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
675 if (system($cmd) != 0) {
676 warn("Join failed\n$cmd");
680 # We need world access to this share, as otherwise the domain
681 # administrator from the AD domain provided by Samba4 can't
682 # access the share for tests.
683 chmod 0777, "$prefix/share";
685 if (not $self->check_or_start(
693 $ret->{DC_SERVER} = $dcvars->{SERVER};
694 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
695 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
696 $ret->{DC_SERVERCONFFILE} = $dcvars->{SERVERCONFFILE};
697 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
698 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
699 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
702 $ret->{TRUST_F_BOTH_SERVER} = $trustvars_f->{SERVER};
703 $ret->{TRUST_F_BOTH_SERVER_IP} = $trustvars_f->{SERVER_IP};
704 $ret->{TRUST_F_BOTH_SERVER_IPV6} = $trustvars_f->{SERVER_IPV6};
705 $ret->{TRUST_F_BOTH_NETBIOSNAME} = $trustvars_f->{NETBIOSNAME};
706 $ret->{TRUST_F_BOTH_USERNAME} = $trustvars_f->{USERNAME};
707 $ret->{TRUST_F_BOTH_PASSWORD} = $trustvars_f->{PASSWORD};
708 $ret->{TRUST_F_BOTH_DOMAIN} = $trustvars_f->{DOMAIN};
709 $ret->{TRUST_F_BOTH_REALM} = $trustvars_f->{REALM};
712 $ret->{TRUST_E_BOTH_SERVER} = $trustvars_e->{SERVER};
713 $ret->{TRUST_E_BOTH_SERVER_IP} = $trustvars_e->{SERVER_IP};
714 $ret->{TRUST_E_BOTH_SERVER_IPV6} = $trustvars_e->{SERVER_IPV6};
715 $ret->{TRUST_E_BOTH_NETBIOSNAME} = $trustvars_e->{NETBIOSNAME};
716 $ret->{TRUST_E_BOTH_USERNAME} = $trustvars_e->{USERNAME};
717 $ret->{TRUST_E_BOTH_PASSWORD} = $trustvars_e->{PASSWORD};
718 $ret->{TRUST_E_BOTH_DOMAIN} = $trustvars_e->{DOMAIN};
719 $ret->{TRUST_E_BOTH_REALM} = $trustvars_e->{REALM};
724 sub setup_ad_member_rfc2307
726 my ($self, $prefix, $dcvars) = @_;
728 # If we didn't build with ADS, pretend this env was never available
729 if (not $self->have_ads()) {
733 print "PROVISIONING S3 AD MEMBER WITH idmap_rfc2307 config...";
735 my $member_options = "
737 workgroup = $dcvars->{DOMAIN}
738 realm = $dcvars->{REALM}
740 idmap negative cache time = 0
741 idmap config * : backend = autorid
742 idmap config * : range = 1000000-1999999
743 idmap config * : rangesize = 100000
744 idmap config $dcvars->{DOMAIN} : backend = rfc2307
745 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
746 idmap config $dcvars->{DOMAIN} : ldap_server = ad
747 idmap config $dcvars->{DOMAIN} : bind_path_user = ou=idmap,dc=samba,dc=example,dc=com
748 idmap config $dcvars->{DOMAIN} : bind_path_group = ou=idmap,dc=samba,dc=example,dc=com
750 password server = $dcvars->{SERVER}
753 my $ret = $self->provision(
755 domain => $dcvars->{DOMAIN},
756 server => "RFC2307MEMBER",
757 password => "loCalMemberPass",
758 extra_options => $member_options,
759 dc_server_ip => $dcvars->{SERVER_IP},
760 dc_server_ipv6 => $dcvars->{SERVER_IPV6});
762 $ret or return undef;
765 $ret->{DOMAIN} = $dcvars->{DOMAIN};
766 $ret->{REALM} = $dcvars->{REALM};
767 $ret->{DOMSID} = $dcvars->{DOMSID};
770 my $prefix_abs = abs_path($prefix);
772 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
773 $ctx->{domain} = $dcvars->{DOMAIN};
774 $ctx->{realm} = $dcvars->{REALM};
775 $ctx->{dnsname} = lc($dcvars->{REALM});
776 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
777 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
778 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
779 Samba::mk_krb5_conf($ctx, "");
781 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
782 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
784 my $net = Samba::bindir_path($self, "net");
785 # Add hosts file for name lookups
786 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
787 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
788 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
789 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
791 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
793 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
794 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
795 $cmd .= "$net join $ret->{CONFIGURATION}";
796 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
798 if (system($cmd) != 0) {
799 warn("Join failed\n$cmd");
803 # We need world access to this share, as otherwise the domain
804 # administrator from the AD domain provided by Samba4 can't
805 # access the share for tests.
806 chmod 0777, "$prefix/share";
808 if (not $self->check_or_start(
816 $ret->{DC_SERVER} = $dcvars->{SERVER};
817 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
818 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
819 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
820 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
821 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
826 sub setup_ad_member_idmap_rid
828 my ($self, $prefix, $dcvars) = @_;
830 # If we didn't build with ADS, pretend this env was never available
831 if (not $self->have_ads()) {
835 print "PROVISIONING S3 AD MEMBER WITH idmap_rid config...";
837 my $member_options = "
839 workgroup = $dcvars->{DOMAIN}
840 realm = $dcvars->{REALM}
841 idmap config * : backend = tdb
842 idmap config * : range = 1000000-1999999
843 idmap config $dcvars->{DOMAIN} : backend = rid
844 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
845 # Prevent overridding the provisioned lib/krb5.conf which sets certain
846 # values required for tests to succeed
847 create krb5 conf = no
848 map to guest = bad user
851 my $ret = $self->provision(
853 domain => $dcvars->{DOMAIN},
854 server => "IDMAPRIDMEMBER",
855 password => "loCalMemberPass",
856 extra_options => $member_options,
857 dc_server_ip => $dcvars->{SERVER_IP},
858 dc_server_ipv6 => $dcvars->{SERVER_IPV6});
860 $ret or return undef;
863 $ret->{DOMAIN} = $dcvars->{DOMAIN};
864 $ret->{REALM} = $dcvars->{REALM};
865 $ret->{DOMSID} = $dcvars->{DOMSID};
868 my $prefix_abs = abs_path($prefix);
870 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
871 $ctx->{domain} = $dcvars->{DOMAIN};
872 $ctx->{realm} = $dcvars->{REALM};
873 $ctx->{dnsname} = lc($dcvars->{REALM});
874 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
875 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
876 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
877 Samba::mk_krb5_conf($ctx, "");
879 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
880 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
882 my $net = Samba::bindir_path($self, "net");
883 # Add hosts file for name lookups
884 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
885 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
886 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
887 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
889 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
891 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
892 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
893 $cmd .= "$net join $ret->{CONFIGURATION}";
894 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
896 if (system($cmd) != 0) {
897 warn("Join failed\n$cmd");
901 # We need world access to this share, as otherwise the domain
902 # administrator from the AD domain provided by Samba4 can't
903 # access the share for tests.
904 chmod 0777, "$prefix/share";
906 if (not $self->check_or_start(
914 $ret->{DC_SERVER} = $dcvars->{SERVER};
915 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
916 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
917 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
918 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
919 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
924 sub setup_ad_member_idmap_ad
926 my ($self, $prefix, $dcvars) = @_;
928 # If we didn't build with ADS, pretend this env was never available
929 if (not $self->have_ads()) {
933 print "PROVISIONING S3 AD MEMBER WITH idmap_ad config...";
935 my $member_options = "
937 workgroup = $dcvars->{DOMAIN}
938 realm = $dcvars->{REALM}
939 password server = $dcvars->{SERVER}
940 idmap config * : backend = tdb
941 idmap config * : range = 1000000-1999999
942 idmap config $dcvars->{DOMAIN} : backend = ad
943 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
944 idmap config $dcvars->{TRUST_DOMAIN} : backend = ad
945 idmap config $dcvars->{TRUST_DOMAIN} : range = 2000000-2999999
948 my $ret = $self->provision(
950 domain => $dcvars->{DOMAIN},
951 server => "IDMAPADMEMBER",
952 password => "loCalMemberPass",
953 extra_options => $member_options,
954 dc_server_ip => $dcvars->{SERVER_IP},
955 dc_server_ipv6 => $dcvars->{SERVER_IPV6});
957 $ret or return undef;
960 $ret->{DOMAIN} = $dcvars->{DOMAIN};
961 $ret->{REALM} = $dcvars->{REALM};
962 $ret->{DOMSID} = $dcvars->{DOMSID};
965 my $prefix_abs = abs_path($prefix);
967 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
968 $ctx->{domain} = $dcvars->{DOMAIN};
969 $ctx->{realm} = $dcvars->{REALM};
970 $ctx->{dnsname} = lc($dcvars->{REALM});
971 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
972 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
973 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
974 Samba::mk_krb5_conf($ctx, "");
976 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
977 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
979 my $net = Samba::bindir_path($self, "net");
980 # Add hosts file for name lookups
981 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
982 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
983 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
984 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
986 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
988 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
989 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
990 $cmd .= "$net join $ret->{CONFIGURATION}";
991 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
993 if (system($cmd) != 0) {
994 warn("Join failed\n$cmd");
998 # We need world access to this share, as otherwise the domain
999 # administrator from the AD domain provided by Samba4 can't
1000 # access the share for tests.
1001 chmod 0777, "$prefix/share";
1003 if (not $self->check_or_start(
1011 $ret->{DC_SERVER} = $dcvars->{SERVER};
1012 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1013 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1014 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1015 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1016 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1018 $ret->{TRUST_SERVER} = $dcvars->{TRUST_SERVER};
1019 $ret->{TRUST_USERNAME} = $dcvars->{TRUST_USERNAME};
1020 $ret->{TRUST_PASSWORD} = $dcvars->{TRUST_PASSWORD};
1021 $ret->{TRUST_DOMAIN} = $dcvars->{TRUST_DOMAIN};
1022 $ret->{TRUST_REALM} = $dcvars->{TRUST_REALM};
1023 $ret->{TRUST_DOMSID} = $dcvars->{TRUST_DOMSID};
1028 sub setup_simpleserver
1030 my ($self, $path) = @_;
1032 print "PROVISIONING simple server...";
1034 my $prefix_abs = abs_path($path);
1036 my $simpleserver_options = "
1039 vfs objects = xattr_tdb streams_depot
1044 path = $prefix_abs/share
1046 vfs objects = aio_pthread
1047 aio_pthread:aio open = yes
1048 smbd:async dosmode = no
1050 [vfs_aio_pthread_async_dosmode_default1]
1051 path = $prefix_abs/share
1053 vfs objects = aio_pthread
1054 store dos attributes = yes
1055 aio_pthread:aio open = yes
1056 smbd:async dosmode = yes
1058 [vfs_aio_pthread_async_dosmode_default2]
1059 path = $prefix_abs/share
1061 vfs objects = aio_pthread xattr_tdb
1062 store dos attributes = yes
1063 aio_pthread:aio open = yes
1064 smbd:async dosmode = yes
1066 [vfs_aio_pthread_async_dosmode_force_sync1]
1067 path = $prefix_abs/share
1069 vfs objects = aio_pthread
1070 store dos attributes = yes
1071 aio_pthread:aio open = yes
1072 smbd:async dosmode = yes
1073 # This simulates non linux systems
1074 smbd:force sync user path safe threadpool = yes
1075 smbd:force sync user chdir safe threadpool = yes
1076 smbd:force sync root path safe threadpool = yes
1077 smbd:force sync root chdir safe threadpool = yes
1079 [vfs_aio_pthread_async_dosmode_force_sync2]
1080 path = $prefix_abs/share
1082 vfs objects = aio_pthread xattr_tdb
1083 store dos attributes = yes
1084 aio_pthread:aio open = yes
1085 smbd:async dosmode = yes
1086 # This simulates non linux systems
1087 smbd:force sync user path safe threadpool = yes
1088 smbd:force sync user chdir safe threadpool = yes
1089 smbd:force sync root path safe threadpool = yes
1090 smbd:force sync root chdir safe threadpool = yes
1093 path = $prefix_abs/share
1094 vfs objects = aio_fork
1096 vfs_aio_fork:erratic_testing_mode=yes
1099 path = $prefix_abs/share
1101 store dos attributes = yes
1102 hide files = /hidefile/
1103 hide dot files = yes
1106 path = $prefix_abs/share
1108 smb encrypt = desired
1111 path = $prefix_abs/share
1112 hide new files timeout = 5
1115 my $vars = $self->provision(
1117 domain => "WORKGROUP",
1118 server => "LOCALSHARE4",
1119 password => "local4pass",
1120 extra_options => $simpleserver_options);
1122 $vars or return undef;
1124 if (not $self->check_or_start(
1134 sub create_file_chmod($$)
1136 my ($name, $mode) = @_;
1139 unless (open($fh, '>', $name)) {
1140 warn("Unable to open $name");
1146 sub setup_fileserver
1148 my ($self, $path) = @_;
1149 my $prefix_abs = abs_path($path);
1150 my $srcdir_abs = abs_path($self->{srcdir});
1152 print "PROVISIONING file server ...\n";
1156 mkdir($prefix_abs, 0777);
1158 my $usershare_dir="$prefix_abs/lib/usershare";
1160 mkdir("$prefix_abs/lib", 0755);
1161 remove_tree($usershare_dir);
1162 mkdir($usershare_dir, 01770);
1164 my $share_dir="$prefix_abs/share";
1166 # Create share directory structure
1167 my $lower_case_share_dir="$share_dir/lower-case";
1168 push(@dirs, $lower_case_share_dir);
1170 my $lower_case_share_dir_30000="$share_dir/lower-case-30000";
1171 push(@dirs, $lower_case_share_dir_30000);
1173 my $dfree_share_dir="$share_dir/dfree";
1174 push(@dirs, $dfree_share_dir);
1175 push(@dirs, "$dfree_share_dir/subdir1");
1176 push(@dirs, "$dfree_share_dir/subdir2");
1177 push(@dirs, "$dfree_share_dir/subdir3");
1179 my $quotadir_dir="$share_dir/quota";
1180 push(@dirs, $quotadir_dir);
1182 my $valid_users_sharedir="$share_dir/valid_users";
1183 push(@dirs,$valid_users_sharedir);
1185 my $offline_sharedir="$share_dir/offline";
1186 push(@dirs,$offline_sharedir);
1188 my $force_user_valid_users_dir = "$share_dir/force_user_valid_users";
1189 push(@dirs, $force_user_valid_users_dir);
1191 my $smbget_sharedir="$share_dir/smbget";
1192 push(@dirs,$smbget_sharedir);
1194 my $tarmode_sharedir="$share_dir/tarmode";
1195 push(@dirs,$tarmode_sharedir);
1197 my $usershare_sharedir="$share_dir/usershares";
1198 push(@dirs,$usershare_sharedir);
1200 my $dropbox_sharedir="$share_dir/dropbox";
1201 push(@dirs,$dropbox_sharedir);
1203 my $fileserver_options = "
1204 kernel change notify = yes
1205 rpc_server:mdssvc = embedded
1206 spotlight backend = elasticsearch
1207 elasticsearch:address = 127.0.0.35
1208 elasticsearch:port = 8080
1209 elasticsearch:mappings = $srcdir_abs/source3/rpc_server/mdssvc/elasticsearch_mappings.json
1211 usershare path = $usershare_dir
1212 usershare max shares = 10
1213 usershare allow guests = yes
1214 usershare prefix allow list = $usershare_sharedir
1216 get quota command = $prefix_abs/getset_quota.py
1217 set quota command = $prefix_abs/getset_quota.py
1227 path = $lower_case_share_dir
1228 comment = smb username is [%U]
1229 case sensitive = True
1230 default case = lower
1232 short preserve case = no
1234 path = $lower_case_share_dir_30000
1235 comment = smb username is [%U]
1236 case sensitive = True
1237 default case = lower
1239 short preserve case = no
1241 path = $dfree_share_dir
1242 comment = smb username is [%U]
1243 dfree command = $srcdir_abs/testprogs/blackbox/dfree.sh
1244 [valid-users-access]
1245 path = $valid_users_sharedir
1246 valid users = +userdup
1248 path = $offline_sharedir
1249 vfs objects = offline
1251 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878
1252 # RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651
1253 [force_user_valid_users]
1254 path = $force_user_valid_users_dir
1255 comment = force user with valid users combination test share
1256 valid users = +force_user
1257 force user = force_user
1258 force group = everyone
1259 write list = force_user
1262 path = $smbget_sharedir
1263 comment = smb username is [%U]
1267 comment = ignore system acls
1268 acl_xattr:ignore system acls = yes
1271 comment = inherit owner
1275 comment = inherit only unix owner
1276 inherit owner = unix only
1277 acl_xattr:ignore system acls = yes
1278 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=13690
1281 comment = force group test
1282 # force group = everyone
1286 comment = smb username is [%U]
1288 force create mode = 0664
1289 vfs objects = dirsort
1292 path = $dropbox_sharedir
1293 comment = smb username is [%U]
1298 comment = Home directories
1303 my $vars = $self->provision(
1305 domain => "WORKGROUP",
1306 server => "FILESERVER",
1307 password => "fileserver",
1308 extra_options => $fileserver_options,
1309 no_delete_prefix => 1);
1311 $vars or return undef;
1313 if (not $self->check_or_start(
1321 mkdir($_, 0777) foreach(@dirs);
1323 ## Create case sensitive lower case share dir
1324 foreach my $file ('a'..'z') {
1325 my $full_path = $lower_case_share_dir . '/' . $file;
1326 open my $fh, '>', $full_path;
1327 # Add some content to file
1328 print $fh $full_path;
1332 for (my $file = 1; $file < 51; ++$file) {
1333 my $full_path = $lower_case_share_dir . '/' . $file;
1334 open my $fh, '>', $full_path;
1335 # Add some content to file
1336 print $fh $full_path;
1340 # Create content for 30000 share
1341 foreach my $file ('a'..'z') {
1342 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1343 open my $fh, '>', $full_path;
1344 # Add some content to file
1345 print $fh $full_path;
1349 for (my $file = 1; $file < 30001; ++$file) {
1350 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1351 open my $fh, '>', $full_path;
1352 # Add some content to file
1353 print $fh $full_path;
1358 ## create a listable file in valid_users_share
1360 create_file_chmod("$valid_users_sharedir/foo", 0644) or return undef;
1367 my ($self, $prefix) = @_;
1369 # If we didn't build with ADS, pretend this env was never available
1370 if (not $self->have_ads()) {
1374 print "PROVISIONING server with security=ads...";
1376 my $ktest_options = "
1378 realm = ktest.samba.example.com
1380 username map = $prefix/lib/username.map
1381 server signing = required
1382 server min protocol = SMB3_00
1383 client max protocol = SMB3
1385 # This disables NTLM auth against the local SAM, which
1386 # we use can then test this setting by.
1387 ntlm auth = disabled
1390 my $ret = $self->provision(
1393 server => "LOCALKTEST6",
1394 password => "localktest6pass",
1395 extra_options => $ktest_options);
1397 $ret or return undef;
1400 my $prefix_abs = abs_path($prefix);
1402 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1403 $ctx->{domain} = "KTEST";
1404 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
1405 $ctx->{dnsname} = lc($ctx->{realm});
1406 $ctx->{kdc_ipv4} = "0.0.0.0";
1407 $ctx->{kdc_ipv6} = "::";
1408 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1409 Samba::mk_krb5_conf($ctx, "");
1411 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1413 open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map");
1415 $ret->{USERNAME} = KTEST\\Administrator
1419 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
1420 #Samba4 DC with the same parameters as are being used here. The
1421 #domain SID is S-1-5-21-1071277805-689288055-3486227160
1422 $ret->{SAMSID} = "S-1-5-21-1911091480-1468226576-2729736297";
1423 $ret->{DOMSID} = "S-1-5-21-1071277805-689288055-3486227160";
1425 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
1426 chmod 0600, "$prefix/private/secrets.tdb";
1428 #Make sure there's no old ntdb file.
1429 system("rm -f $prefix/private/secrets.ntdb");
1431 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
1432 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
1434 #and having in krb5.conf:
1435 # ticket_lifetime = 799718400
1436 # renew_lifetime = 799718400
1438 # The commands for the -2 keytab where were:
1439 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
1440 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
1441 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
1442 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1443 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1445 # and then for the -3 keytab, I did
1447 # net changetrustpw; kdestroy and the same again.
1449 # This creates a credential cache with a very long lifetime (2036 at
1450 # at 2011-04), and shows that running 'net changetrustpw' does not
1451 # break existing logins (for the secrets.tdb method at least).
1454 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
1456 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
1457 chmod 0600, "$prefix/krb5_ccache-2";
1459 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
1460 chmod 0600, "$prefix/krb5_ccache-3";
1462 # We need world access to this share, as otherwise the domain
1463 # administrator from the AD domain provided by ktest can't
1464 # access the share for tests.
1465 chmod 0777, "$prefix/share";
1467 if (not $self->check_or_start(
1476 sub setup_maptoguest
1478 my ($self, $path) = @_;
1480 print "PROVISIONING maptoguest...";
1483 map to guest = bad user
1487 my $vars = $self->provision(
1489 domain => "WORKGROUP",
1490 server => "maptoguest",
1491 password => "maptoguestpass",
1492 extra_options => $options);
1494 $vars or return undef;
1496 if (not $self->check_or_start(
1506 sub stop_sig_term($$) {
1507 my ($self, $pid) = @_;
1508 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1511 sub stop_sig_kill($$) {
1512 my ($self, $pid) = @_;
1513 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1518 my ($env_vars, $app, $pid) = @_;
1520 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
1527 my ($env_vars, $app) = @_;
1529 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
1535 # builds up the cmd args to run an s3 binary (i.e. smbd, nmbd, etc)
1538 my ($self, $binary, $env_vars, $options, $valgrind, $dont_log_stdout) = @_;
1540 my @optargs = ("-d0");
1541 if (defined($options)) {
1542 @optargs = split(/ /, $options);
1544 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1546 if (defined($valgrind)) {
1547 @preargs = split(/ /, $valgrind);
1549 my @args = ("-F", "--no-process-group",
1550 "-s", $env_vars->{SERVERCONFFILE},
1551 "-l", $env_vars->{LOGDIR});
1553 if (not defined($dont_log_stdout)) {
1554 push(@args, "--log-stdout");
1556 return (@preargs, $binary, @args, @optargs);
1559 sub check_or_start($$) {
1560 my ($self, %args) = @_;
1561 my $env_vars = $args{env_vars};
1562 my $nmbd = $args{nmbd} // "no";
1563 my $winbindd = $args{winbindd} // "no";
1564 my $smbd = $args{smbd} // "no";
1565 my $child_cleanup = $args{child_cleanup};
1569 # use a pipe for stdin in the child processes. This allows
1570 # those processes to monitor the pipe for EOF to ensure they
1571 # exit when the test script exits
1572 pipe($STDIN_READER, $env_vars->{STDIN_PIPE});
1574 my $binary = Samba::bindir_path($self, "nmbd");
1575 my @full_cmd = $self->make_bin_cmd($binary, $env_vars,
1576 $ENV{NMBD_OPTIONS}, $ENV{NMBD_VALGRIND},
1577 $ENV{NMBD_DONT_LOG_STDOUT});
1578 my $nmbd_envs = Samba::get_env_for_process("nmbd", $env_vars);
1579 delete $nmbd_envs->{RESOLV_WRAPPER_CONF};
1580 delete $nmbd_envs->{RESOLV_WRAPPER_HOSTS};
1582 # fork and exec() nmbd in the child process
1585 BINARY_PATH => $binary,
1586 FULL_CMD => [ @full_cmd ],
1587 LOG_FILE => $env_vars->{NMBD_TEST_LOG},
1588 PCAP_FILE => "env-$ENV{ENVNAME}-nmbd",
1589 ENV_VARS => $nmbd_envs,
1591 if ($nmbd ne "yes") {
1592 $daemon_ctx->{SKIP_DAEMON} = 1;
1594 my $pid = Samba::fork_and_exec(
1595 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
1597 $env_vars->{NMBD_TL_PID} = $pid;
1598 write_pid($env_vars, "nmbd", $pid);
1600 $binary = Samba::bindir_path($self, "winbindd");
1601 @full_cmd = $self->make_bin_cmd($binary, $env_vars,
1602 $ENV{WINBINDD_OPTIONS}, $ENV{WINBINDD_VALGRIND}, "N/A");
1604 if (not defined($ENV{WINBINDD_DONT_LOG_STDOUT})) {
1605 push(@full_cmd, "--stdout");
1608 # fork and exec() winbindd in the child process
1611 BINARY_PATH => $binary,
1612 FULL_CMD => [ @full_cmd ],
1613 LOG_FILE => $env_vars->{WINBINDD_TEST_LOG},
1614 PCAP_FILE => "env-$ENV{ENVNAME}-winbindd",
1616 if ($winbindd ne "yes") {
1617 $daemon_ctx->{SKIP_DAEMON} = 1;
1620 $pid = Samba::fork_and_exec(
1621 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
1623 $env_vars->{WINBINDD_TL_PID} = $pid;
1624 write_pid($env_vars, "winbindd", $pid);
1626 $binary = Samba::bindir_path($self, "smbd");
1627 @full_cmd = $self->make_bin_cmd($binary, $env_vars,
1628 $ENV{SMBD_OPTIONS}, $ENV{SMBD_VALGRIND},
1629 $ENV{SMBD_DONT_LOG_STDOUT});
1631 # fork and exec() smbd in the child process
1634 BINARY_PATH => $binary,
1635 FULL_CMD => [ @full_cmd ],
1636 LOG_FILE => $env_vars->{SMBD_TEST_LOG},
1637 PCAP_FILE => "env-$ENV{ENVNAME}-smbd",
1639 if ($smbd ne "yes") {
1640 $daemon_ctx->{SKIP_DAEMON} = 1;
1643 $pid = Samba::fork_and_exec(
1644 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
1646 $env_vars->{SMBD_TL_PID} = $pid;
1647 write_pid($env_vars, "smbd", $pid);
1649 # close the parent's read-end of the pipe
1650 close($STDIN_READER);
1652 return $self->wait_for_start($env_vars, $nmbd, $winbindd, $smbd);
1655 sub createuser($$$$$)
1657 my ($self, $username, $password, $conffile, $env) = @_;
1658 my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $username > /dev/null";
1661 while(my($var, $val) = each %$env) {
1662 $cmd = "$var=\"$val\" $cmd";
1665 unless (open(PWD, "|$cmd")) {
1666 warn("Unable to set password for $username account\n$cmd");
1669 print PWD "$password\n$password\n";
1670 unless (close(PWD)) {
1671 warn("Unable to set password for $username account\n$cmd");
1678 my ($self, %args) = @_;
1680 my $prefix = $args{prefix};
1681 my $domain = $args{domain};
1682 my $server = $args{server};
1683 my $password = $args{password};
1684 my $extra_options = $args{extra_options};
1685 my $dc_server_ip = $args{dc_server_ip};
1686 my $dc_server_ipv6 = $args{dc_server_ipv6};
1687 my $no_delete_prefix= $args{no_delete_prefix};
1688 my $netbios_name = $args{netbios_name} // $server;
1691 ## setup the various environment variables we need
1694 my $samsid = Samba::random_domain_sid();
1695 my $swiface = Samba::get_interface($server);
1697 my %createuser_env = ();
1698 my $server_ip = Samba::get_ipv4_addr($server);
1699 my $server_ipv6 = Samba::get_ipv6_addr($server);
1701 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
1704 my $unix_gids_str = $);
1705 my @unix_gids = split(" ", $unix_gids_str);
1707 my $prefix_abs = abs_path($prefix);
1708 my $bindir_abs = abs_path($self->{bindir});
1712 my $shrdir=$args{share_dir} // "$prefix_abs/share";
1713 push(@dirs,$shrdir);
1715 my $libdir="$prefix_abs/lib";
1716 push(@dirs,$libdir);
1718 my $piddir="$prefix_abs/pid";
1719 push(@dirs,$piddir);
1721 my $privatedir="$prefix_abs/private";
1722 push(@dirs,$privatedir);
1724 my $cachedir = "$prefix_abs/cachedir";
1725 push(@dirs, $cachedir);
1727 my $binddnsdir = "$prefix_abs/bind-dns";
1728 push(@dirs, $binddnsdir);
1730 my $lockdir="$prefix_abs/lockdir";
1731 push(@dirs,$lockdir);
1733 my $eventlogdir="$prefix_abs/lockdir/eventlog";
1734 push(@dirs,$eventlogdir);
1736 my $logdir="$prefix_abs/logs";
1737 push(@dirs,$logdir);
1739 my $driver32dir="$shrdir/W32X86";
1740 push(@dirs,$driver32dir);
1742 my $driver64dir="$shrdir/x64";
1743 push(@dirs,$driver64dir);
1745 my $driver40dir="$shrdir/WIN40";
1746 push(@dirs,$driver40dir);
1748 my $ro_shrdir="$shrdir/root-tmp";
1749 push(@dirs,$ro_shrdir);
1751 my $noperm_shrdir="$shrdir/noperm-tmp";
1752 push(@dirs,$noperm_shrdir);
1754 my $msdfs_shrdir="$shrdir/msdfsshare";
1755 push(@dirs,$msdfs_shrdir);
1757 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
1758 push(@dirs,$msdfs_deeppath);
1760 my $badnames_shrdir="$shrdir/badnames";
1761 push(@dirs,$badnames_shrdir);
1763 my $lease1_shrdir="$shrdir/SMB2_10";
1764 push(@dirs,$lease1_shrdir);
1766 my $lease2_shrdir="$shrdir/SMB3_00";
1767 push(@dirs,$lease2_shrdir);
1769 my $manglenames_shrdir="$shrdir/manglenames";
1770 push(@dirs,$manglenames_shrdir);
1772 my $widelinks_shrdir="$shrdir/widelinks";
1773 push(@dirs,$widelinks_shrdir);
1775 my $widelinks_linkdir="$shrdir/widelinks_foo";
1776 push(@dirs,$widelinks_linkdir);
1778 my $fsrvp_shrdir="$shrdir/fsrvp";
1779 push(@dirs,$fsrvp_shrdir);
1781 my $shadow_tstdir="$shrdir/shadow";
1782 push(@dirs,$shadow_tstdir);
1783 my $shadow_mntdir="$shadow_tstdir/mount";
1784 push(@dirs,$shadow_mntdir);
1785 my $shadow_basedir="$shadow_mntdir/base";
1786 push(@dirs,$shadow_basedir);
1787 my $shadow_shrdir="$shadow_basedir/share";
1788 push(@dirs,$shadow_shrdir);
1790 my $nosymlinks_shrdir="$shrdir/nosymlinks";
1791 push(@dirs,$nosymlinks_shrdir);
1793 my $local_symlinks_shrdir="$shrdir/local_symlinks";
1794 push(@dirs,$local_symlinks_shrdir);
1796 # this gets autocreated by winbindd
1797 my $wbsockdir="$prefix_abs/winbindd";
1799 my $nmbdsockdir="$prefix_abs/nmbd";
1800 unlink($nmbdsockdir);
1803 ## create the test directory layout
1805 die ("prefix_abs = ''") if $prefix_abs eq "";
1806 die ("prefix_abs = '/'") if $prefix_abs eq "/";
1808 mkdir($prefix_abs, 0777);
1809 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
1810 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
1811 system("rm -rf $prefix_abs/*");
1813 mkdir($_, 0777) foreach(@dirs);
1815 my $fs_specific_conf = $self->get_fs_specific_conf($shrdir);
1818 ## lockdir and piddir must be 0755
1820 chmod 0755, $lockdir;
1821 chmod 0755, $piddir;
1825 ## Create a directory without permissions to enter
1827 chmod 0000, $noperm_shrdir;
1830 ## create ro and msdfs share layout
1833 chmod 0755, $ro_shrdir;
1835 create_file_chmod("$ro_shrdir/unreadable_file", 0600) or return undef;
1837 create_file_chmod("$ro_shrdir/msdfs-target", 0600) or return undef;
1838 symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp",
1839 "$msdfs_shrdir/msdfs-src1";
1840 symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
1843 ## create bad names in $badnames_shrdir
1845 ## (An invalid name, would be mangled to 8.3).
1846 create_file_chmod("$badnames_shrdir/\340|\231\216\377\177",
1847 0600) or return undef;
1849 ## (A bad name, would not be mangled to 8.3).
1850 create_file_chmod("$badnames_shrdir/\240\276\346\327\377\177",
1851 0666) or return undef;
1853 ## (A bad good name).
1854 create_file_chmod("$badnames_shrdir/blank.txt",
1855 0666) or return undef;
1858 ## create mangleable directory names in $manglenames_shrdir
1860 my $manglename_target = "$manglenames_shrdir/foo:bar";
1861 mkdir($manglename_target, 0777);
1864 ## create symlinks for widelinks tests.
1866 my $widelinks_target = "$widelinks_linkdir/target";
1867 create_file_chmod("$widelinks_target", 0666) or return undef;
1870 ## This link should get ACCESS_DENIED
1872 symlink "$widelinks_target", "$widelinks_shrdir/source";
1874 ## This link should be allowed
1876 symlink "$widelinks_shrdir", "$widelinks_shrdir/dot";
1878 my $conffile="$libdir/server.conf";
1879 my $dfqconffile="$libdir/dfq.conf";
1880 my $errorinjectconf="$libdir/error_inject.conf";
1881 my $delayinjectconf="$libdir/delay_inject.conf";
1882 my $globalinjectconf="$libdir/global_inject.conf";
1884 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/third_party/nss_wrapper/nss_wrapper.pl";
1885 my $nss_wrapper_passwd = "$privatedir/passwd";
1886 my $nss_wrapper_group = "$privatedir/group";
1887 my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts";
1888 my $resolv_conf = "$privatedir/resolv.conf";
1889 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
1891 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
1893 my $fake_snap_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/fake_snap.pl";
1895 my @eventlog_list = ("dns server", "application");
1898 ## calculate uids and gids
1901 my ($max_uid, $max_gid);
1902 my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
1903 my ($uid_pdbtest_wkn);
1905 my ($uid_force_user);
1906 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
1907 my ($gid_userdup, $gid_everyone);
1908 my ($gid_force_user);
1913 my ($uid_slashuser);
1915 if ($unix_uid < 0xffff - 13) {
1918 $max_uid = $unix_uid;
1921 $uid_root = $max_uid - 1;
1922 $uid_nobody = $max_uid - 2;
1923 $uid_pdbtest = $max_uid - 3;
1924 $uid_pdbtest2 = $max_uid - 4;
1925 $uid_userdup = $max_uid - 5;
1926 $uid_pdbtest_wkn = $max_uid - 6;
1927 $uid_force_user = $max_uid - 7;
1928 $uid_smbget = $max_uid - 8;
1929 $uid_user1 = $max_uid - 9;
1930 $uid_user2 = $max_uid - 10;
1931 $uid_gooduser = $max_uid - 11;
1932 $uid_eviluser = $max_uid - 12;
1933 $uid_slashuser = $max_uid - 13;
1935 if ($unix_gids[0] < 0xffff - 8) {
1938 $max_gid = $unix_gids[0];
1941 $gid_nobody = $max_gid - 1;
1942 $gid_nogroup = $max_gid - 2;
1943 $gid_root = $max_gid - 3;
1944 $gid_domusers = $max_gid - 4;
1945 $gid_domadmins = $max_gid - 5;
1946 $gid_userdup = $max_gid - 6;
1947 $gid_everyone = $max_gid - 7;
1948 $gid_force_user = $max_gid - 8;
1954 unless (open(CONF, ">$conffile")) {
1955 warn("Unable to open $conffile");
1959 my $interfaces = Samba::get_interfaces_config($server);
1963 dcesrv:fuzz directory = $cachedir/fuzz
1964 netbios name = $netbios_name
1965 interfaces = $interfaces
1966 bind interfaces only = yes
1967 panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
1968 smbd:suicide mode = yes
1970 client min protocol = CORE
1971 server min protocol = LANMAN1
1975 private dir = $privatedir
1976 binddns dir = $binddnsdir
1977 pid directory = $piddir
1978 lock directory = $lockdir
1979 log file = $logdir/log.\%m
1984 state directory = $lockdir
1985 cache directory = $lockdir
1987 passdb backend = tdbsam
1991 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1992 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
1993 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1994 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
1995 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
1996 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
1997 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
1999 addprinter command = $mod_printer_pl -a -s $conffile --
2000 deleteprinter command = $mod_printer_pl -d -s $conffile --
2002 eventlog list = application \"dns server\"
2005 kernel change notify = no
2009 printcap name = /dev/null
2011 winbindd socket directory = $wbsockdir
2012 nmbd:socket dir = $nmbdsockdir
2013 idmap config * : range = 100000-200000
2014 winbind enum users = yes
2015 winbind enum groups = yes
2016 winbind separator = /
2017 include system krb5 conf = no
2019 # min receivefile size = 4000
2023 smbd:sharedelay = 100000
2024 smbd:writetimeupdatedelay = 500000
2028 store dos attributes = yes
2034 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot time_audit full_audit
2036 full_audit:syslog = no
2037 full_audit:success = none
2038 full_audit:failure = none
2041 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
2042 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
2043 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
2044 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
2045 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
2046 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
2047 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
2049 print notify backchannel = yes
2051 ncalrpc dir = $prefix_abs/ncalrpc
2053 # The samba3.blackbox.smbclient_s3 test uses this to test that
2054 # sending messages works, and that the %m sub works.
2055 message command = mv %s $shrdir/message.%m
2057 # fsrvp server requires registry shares
2058 registry shares = yes
2060 # Used by RPC SRVSVC tests
2061 add share command = $bindir_abs/smbaddshare
2062 change share command = $bindir_abs/smbchangeshare
2063 delete share command = $bindir_abs/smbdeleteshare
2065 # fruit:copyfile is a global option
2066 fruit:copyfile = yes
2068 #this does not mean that we use non-secure test env,
2069 #it just means we ALLOW one to be configured.
2070 allow insecure wide links = yes
2072 include = $globalinjectconf
2074 # Begin extra options
2078 #Include user defined custom parameters if set
2081 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
2082 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
2088 comment = smb username is [%U]
2091 comment = Load dirsort module
2092 vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot
2095 comment = encrypt smb username is [%U]
2096 smb encrypt = required
2097 vfs objects = dirsort
2107 force user = $unix_name
2109 [forceuser_unixonly]
2110 comment = force a user with unix user SID and group SID
2112 force user = pdbtest
2114 [forceuser_wkngroup]
2115 comment = force a user with well-known group SID
2117 force user = pdbtest_wkn
2121 force group = nogroup
2127 path = $noperm_shrdir
2133 write list = $unix_name
2136 valid users = $unix_name
2137 access based share enum = yes
2139 path = $msdfs_shrdir
2141 msdfs shuffle referrals = yes
2145 hide unreadable = yes
2148 case sensitive = yes
2151 hide unwriteable files = yes
2154 kernel share modes = no
2168 default devmode = no
2174 comment = smb username is [%U]
2176 nfs4acl_xattr:version = 40
2177 vfs objects = nfs4acl_xattr xattr_tdb
2179 [nfs4acl_special_40]
2181 comment = smb username is [%U]
2183 nfs4acl_xattr:version = 40
2184 vfs objects = nfs4acl_xattr xattr_tdb
2188 comment = smb username is [%U]
2190 vfs objects = nfs4acl_xattr xattr_tdb
2194 comment = smb username is [%U]
2195 vfs objects = nfs4acl_xattr xattr_tdb
2197 nfs4acl_xattr:encoding = xdr
2198 nfs4acl_xattr:version = 40
2202 comment = smb username is [%U]
2203 vfs objects = nfs4acl_xattr xattr_tdb
2205 nfs4acl_xattr:encoding = xdr
2206 nfs4acl_xattr:version = 41
2210 comment = smb username is [%U]
2211 vfs objects = nfs4acl_xattr xattr_tdb
2213 nfs4acl_xattr:encoding = nfs
2214 nfs4acl_xattr:version = 40
2215 nfs4acl_xattr:xattr_name = security.nfs4acl_xdr
2219 comment = smb username is [%U]
2220 vfs objects = nfs4acl_xattr xattr_tdb
2222 nfs4acl_xattr:encoding = nfs
2223 nfs4acl_xattr:version = 41
2224 nfs4acl_xattr:xattr_name = security.nfs4acl_xdr
2228 comment = smb username is [%U]
2230 force create mode = 777
2233 comment = smb username is [%U]
2235 force create mode = 0
2236 directory mask = 0777
2237 force directory mode = 0
2238 vfs objects = xattr_tdb streams_depot
2249 vfs objects = catia fruit streams_xattr acl_xattr xattr_tdb
2250 fruit:resource = file
2251 fruit:metadata = netatalk
2252 fruit:locking = netatalk
2253 fruit:encoding = native
2254 fruit:veto_appledouble = no
2258 # This is used by vfs.fruit tests that require real fs xattr
2259 vfs objects = catia fruit streams_xattr acl_xattr
2260 fruit:resource = file
2261 fruit:metadata = netatalk
2262 fruit:locking = netatalk
2263 fruit:encoding = native
2264 fruit:veto_appledouble = no
2266 [vfs_fruit_metadata_stream]
2268 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2269 fruit:resource = file
2270 fruit:metadata = stream
2271 fruit:veto_appledouble = no
2273 [vfs_fruit_stream_depot]
2275 vfs objects = fruit streams_depot acl_xattr xattr_tdb
2276 fruit:resource = stream
2277 fruit:metadata = stream
2278 fruit:veto_appledouble = no
2282 vfs objects = streams_xattr acl_xattr xattr_tdb
2284 [vfs_wo_fruit_stream_depot]
2286 vfs objects = streams_depot acl_xattr xattr_tdb
2288 [vfs_fruit_timemachine]
2290 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2291 fruit:resource = file
2292 fruit:metadata = stream
2293 fruit:time machine = yes
2294 fruit:time machine max size = 32K
2296 [vfs_fruit_wipe_intentionally_left_blank_rfork]
2298 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2299 fruit:resource = file
2300 fruit:metadata = stream
2301 fruit:wipe_intentionally_left_blank_rfork = true
2302 fruit:delete_empty_adfiles = false
2303 fruit:veto_appledouble = no
2305 [vfs_fruit_delete_empty_adfiles]
2307 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2308 fruit:resource = file
2309 fruit:metadata = stream
2310 fruit:wipe_intentionally_left_blank_rfork = true
2311 fruit:delete_empty_adfiles = true
2312 fruit:veto_appledouble = no
2314 [vfs_fruit_zero_fileid]
2316 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2317 fruit:resource = file
2318 fruit:metadata = stream
2319 fruit:zero_file_id=yes
2322 path = $badnames_shrdir
2326 path = $manglenames_shrdir
2334 path = $widelinks_shrdir
2339 path = $fsrvp_shrdir
2340 comment = fake shapshots using rsync
2341 vfs objects = shell_snap shadow_copy2
2342 shell_snap:check path command = $fake_snap_pl --check
2343 shell_snap:create command = $fake_snap_pl --create
2344 shell_snap:delete command = $fake_snap_pl --delete
2345 # a relative path here fails, the snapshot dir is no longer found
2346 shadow:snapdir = $fsrvp_shrdir/.snapshots
2349 path = $shadow_shrdir
2350 comment = previous versions snapshots under mount point
2351 vfs objects = shadow_copy2
2352 shadow:mountpoint = $shadow_mntdir
2355 path = $shadow_shrdir
2356 comment = previous versions snapshots outside mount point
2357 vfs objects = shadow_copy2
2358 shadow:mountpoint = $shadow_mntdir
2359 shadow:snapdir = $shadow_tstdir/.snapshots
2362 path = $shadow_shrdir
2363 comment = previous versions with subvolume snapshots, snapshots under base dir
2364 vfs objects = shadow_copy2
2365 shadow:mountpoint = $shadow_mntdir
2366 shadow:basedir = $shadow_basedir
2367 shadow:snapdir = $shadow_basedir/.snapshots
2370 path = $shadow_shrdir
2371 comment = previous versions with subvolume snapshots, snapshots outside mount point
2372 vfs objects = shadow_copy2
2373 shadow:mountpoint = $shadow_mntdir
2374 shadow:basedir = $shadow_basedir
2375 shadow:snapdir = $shadow_tstdir/.snapshots
2378 path = $shadow_shrdir
2379 comment = previous versions at volume root snapshots under mount point
2380 vfs objects = shadow_copy2
2381 shadow:mountpoint = $shadow_shrdir
2384 path = $shadow_shrdir
2385 comment = previous versions at volume root snapshots outside mount point
2386 vfs objects = shadow_copy2
2387 shadow:mountpoint = $shadow_shrdir
2388 shadow:snapdir = $shadow_tstdir/.snapshots
2391 path = $shadow_shrdir
2392 comment = previous versions snapshots everywhere
2393 vfs objects = shadow_copy2
2394 shadow:mountpoint = $shadow_mntdir
2395 shadow:snapdirseverywhere = yes
2398 path = $shadow_shrdir
2399 comment = previous versions using snapsharepath
2400 vfs objects = shadow_copy2
2401 shadow:mountpoint = $shadow_mntdir
2402 shadow:snapdir = $shadow_tstdir/.snapshots
2403 shadow:snapsharepath = share
2406 comment = Testing shadow:format with default option
2407 vfs object = shadow_copy2
2408 path = $shadow_shrdir
2411 shadow:mountpoint = $shadow_mntdir
2412 shadow:basedir = $shadow_basedir
2413 shadow:snapdir = $shadow_basedir/.snapshots
2414 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2417 comment = Testing shadow:format with only date component
2418 vfs object = shadow_copy2
2419 path = $shadow_shrdir
2422 shadow:mountpoint = $shadow_mntdir
2423 shadow:basedir = $shadow_basedir
2424 shadow:snapdir = $shadow_basedir/.snapshots
2425 shadow:format = \@GMT-%Y-%m-%d
2428 comment = Testing shadow:format with some hardcoded prefix
2429 vfs object = shadow_copy2
2430 path = $shadow_shrdir
2433 shadow:mountpoint = $shadow_mntdir
2434 shadow:basedir = $shadow_basedir
2435 shadow:snapdir = $shadow_basedir/.snapshots
2436 shadow:format = snap\@GMT-%Y.%m.%d-%H.%M.%S
2439 comment = Testing shadow:format with modified format
2440 vfs object = shadow_copy2
2441 path = $shadow_shrdir
2444 shadow:mountpoint = $shadow_mntdir
2445 shadow:basedir = $shadow_basedir
2446 shadow:snapdir = $shadow_basedir/.snapshots
2447 shadow:format = \@GMT-%Y.%m.%d-%H_%M_%S-snap
2450 comment = Testing shadow:snapprefix regex
2451 vfs object = shadow_copy2
2452 path = $shadow_shrdir
2455 shadow:mountpoint = $shadow_mntdir
2456 shadow:basedir = $shadow_basedir
2457 shadow:snapdir = $shadow_basedir/.snapshots
2458 shadow:snapprefix = \^s[a-z]*p\$
2459 shadow:format = _GMT-%Y.%m.%d-%H.%M.%S
2462 comment = Testing shadow:snapprefix with delim regex
2463 vfs object = shadow_copy2
2464 path = $shadow_shrdir
2467 shadow:mountpoint = $shadow_mntdir
2468 shadow:basedir = $shadow_basedir
2469 shadow:snapdir = $shadow_basedir/.snapshots
2470 shadow:delimiter = \@GMT
2471 shadow:snapprefix = [a-z]*
2472 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2475 path = $shadow_shrdir
2476 comment = previous versions with wide links allowed
2477 vfs objects = shadow_copy2
2478 shadow:mountpoint = $shadow_mntdir
2482 path = $shadow_tstdir
2483 comment = previous versions snapshots under mount point
2484 vfs objects = shadow_copy2 streams_xattr error_inject
2486 error_inject:pwrite = EBADF
2487 shadow:mountpoint = $shadow_tstdir
2490 path = $shrdir/dfree
2491 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2492 admin users = $unix_name
2493 include = $dfqconffile
2495 path = $shrdir/dfree
2496 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2497 admin users = $unix_name
2498 include = $dfqconffile
2499 dfree cache time = 60
2501 path = $shrdir/dfree
2502 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2504 include = $dfqconffile
2506 path = $shrdir/quota
2507 admin users = $unix_name
2509 [acl_xattr_ign_sysacl_posix]
2511 acl_xattr:ignore system acls = yes
2512 acl_xattr:default acl style = posix
2513 [acl_xattr_ign_sysacl_windows]
2515 acl_xattr:ignore system acls = yes
2516 acl_xattr:default acl style = windows
2520 mangled names = illegal
2524 path = $nosymlinks_shrdir
2525 follow symlinks = no
2529 path = $local_symlinks_shrdir
2530 follow symlinks = yes
2534 kernel oplocks = yes
2535 vfs objects = streams_xattr xattr_tdb
2539 vfs objects = streams_xattr xattr_tdb
2543 smbd:find async delay usec = 10000
2546 vfs objects = error_inject
2547 include = $errorinjectconf
2551 vfs objects = delay_inject
2552 kernel share modes = no
2555 include = $delayinjectconf
2559 vfs objects = delay_inject
2560 delay_inject:pread_send = 2000
2561 delay_inject:pwrite_send = 2000
2565 vfs objects = delay_inject
2566 delay_inject:brl_lock_windows = 90
2567 delay_inject:brl_lock_windows_use_timer = yes
2571 vfs objects = delay_inject
2572 delay_inject:brl_lock_windows = 90
2573 delay_inject:brl_lock_windows_use_timer = no
2576 path = $prefix_abs/share
2577 delete readonly = yes
2581 my $net = Samba::bindir_path($self, "net");
2583 $cmd .= "UID_WRAPPER_ROOT=1 ";
2584 $cmd .= "SMB_CONF_PATH=\"$conffile\" ";
2585 $cmd .= "$net setlocalsid $samsid";
2587 my $net_ret = system($cmd);
2588 if ($net_ret != 0) {
2589 warn("net setlocalsid failed: $net_ret\n$cmd");
2593 unless (open(ERRORCONF, ">$errorinjectconf")) {
2594 warn("Unable to open $errorinjectconf");
2599 unless (open(DELAYCONF, ">$delayinjectconf")) {
2600 warn("Unable to open $delayinjectconf");
2605 unless (open(DFQCONF, ">$dfqconffile")) {
2606 warn("Unable to open $dfqconffile");
2611 unless (open(DELAYCONF, ">$globalinjectconf")) {
2612 warn("Unable to open $globalinjectconf");
2618 ## create a test account
2621 unless (open(PASSWD, ">$nss_wrapper_passwd")) {
2622 warn("Unable to open $nss_wrapper_passwd");
2625 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
2626 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
2627 pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2628 pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2629 userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
2630 pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false
2631 force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false
2632 smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false
2633 user1:x:$uid_user1:$gid_nogroup:user1 gecos:$prefix_abs:/bin/false
2634 user2:x:$uid_user2:$gid_nogroup:user2 gecos:$prefix_abs:/bin/false
2635 gooduser:x:$uid_gooduser:$gid_domusers:gooduser gecos:$prefix_abs:/bin/false
2636 eviluser:x:$uid_eviluser:$gid_domusers:eviluser gecos::/bin/false
2637 slashuser:x:$uid_slashuser:$gid_domusers:slashuser gecos:/:/bin/false
2639 if ($unix_uid != 0) {
2640 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
2645 unless (open(GROUP, ">$nss_wrapper_group")) {
2646 warn("Unable to open $nss_wrapper_group");
2649 print GROUP "nobody:x:$gid_nobody:
2650 nogroup:x:$gid_nogroup:nobody
2651 $unix_name-group:x:$unix_gids[0]:
2652 domusers:X:$gid_domusers:
2653 domadmins:X:$gid_domadmins:
2654 userdup:x:$gid_userdup:$unix_name
2655 everyone:x:$gid_everyone:
2656 force_user:x:$gid_force_user:
2658 if ($unix_gids[0] != 0) {
2659 print GROUP "root:x:$gid_root:
2666 my $hostname = lc($server);
2667 unless (open(HOSTS, ">>$nss_wrapper_hosts")) {
2668 warn("Unable to open $nss_wrapper_hosts");
2671 print HOSTS "${server_ip} ${hostname}.samba.example.com ${hostname}\n";
2672 print HOSTS "${server_ipv6} ${hostname}.samba.example.com ${hostname}\n";
2676 unless (open(RESOLV_CONF, ">$resolv_conf")) {
2677 warn("Unable to open $resolv_conf");
2680 if (defined($dc_server_ip) or defined($dc_server_ipv6)) {
2681 if (defined($dc_server_ip)) {
2682 print RESOLV_CONF "nameserver $dc_server_ip\n";
2684 if (defined($dc_server_ipv6)) {
2685 print RESOLV_CONF "nameserver $dc_server_ipv6\n";
2688 print RESOLV_CONF "nameserver ${server_ip}\n";
2689 print RESOLV_CONF "nameserver ${server_ipv6}\n";
2693 foreach my $evlog (@eventlog_list) {
2694 my $evlogtdb = "$eventlogdir/$evlog.tdb";
2695 open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
2699 $createuser_env{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2700 $createuser_env{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2701 $createuser_env{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2702 $createuser_env{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2703 if ($ENV{SAMBA_DNS_FAKING}) {
2704 $createuser_env{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2706 $createuser_env{RESOLV_WRAPPER_CONF} = $resolv_conf;
2709 createuser($self, $unix_name, $password, $conffile, \%createuser_env) || die("Unable to create user");
2710 createuser($self, "force_user", $password, $conffile, \%createuser_env) || die("Unable to create force_user");
2711 createuser($self, "smbget_user", $password, $conffile, \%createuser_env) || die("Unable to create smbget_user");
2712 createuser($self, "user1", $password, $conffile, \%createuser_env) || die("Unable to create user1");
2713 createuser($self, "user2", $password, $conffile, \%createuser_env) || die("Unable to create user2");
2714 createuser($self, "gooduser", $password, $conffile, \%createuser_env) || die("Unable to create gooduser");
2715 createuser($self, "eviluser", $password, $conffile, \%createuser_env) || die("Unable to create eviluser");
2716 createuser($self, "slashuser", $password, $conffile, \%createuser_env) || die("Unable to create slashuser");
2718 open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
2719 print DNS_UPDATE_LIST "A $server. $server_ip\n";
2720 print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n";
2721 close(DNS_UPDATE_LIST);
2725 $ret{SERVER_IP} = $server_ip;
2726 $ret{SERVER_IPV6} = $server_ipv6;
2727 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
2728 $ret{NMBD_TEST_LOG_POS} = 0;
2729 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
2730 $ret{WINBINDD_TEST_LOG_POS} = 0;
2731 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
2732 $ret{SMBD_TEST_LOG_POS} = 0;
2733 $ret{SERVERCONFFILE} = $conffile;
2734 $ret{TESTENV_DIR} = $prefix_abs;
2735 $ret{CONFIGURATION} ="-s $conffile";
2736 $ret{LOCK_DIR} = $lockdir;
2737 $ret{SERVER} = $server;
2738 $ret{USERNAME} = $unix_name;
2739 $ret{USERID} = $unix_uid;
2740 $ret{DOMAIN} = $domain;
2741 $ret{SAMSID} = $samsid;
2742 $ret{NETBIOSNAME} = $server;
2743 $ret{PASSWORD} = $password;
2744 $ret{PIDDIR} = $piddir;
2745 $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir;
2746 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
2747 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
2748 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2749 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2750 $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2751 $ret{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2752 $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
2753 $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind";
2754 if ($ENV{SAMBA_DNS_FAKING}) {
2755 $ret{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2757 $ret{RESOLV_WRAPPER_CONF} = $resolv_conf;
2759 $ret{LOCAL_PATH} = "$shrdir";
2760 $ret{LOGDIR} = $logdir;
2763 # Avoid hitting system krb5.conf -
2764 # An env that needs Kerberos will reset this to the real
2767 $ret{KRB5_CONFIG} = abs_path($prefix) . "/no_krb5.conf";
2769 # Define KRB5CCNAME for each environment we set up
2770 $ret{KRB5_CCACHE} = abs_path($prefix) . "/krb5ccache";
2771 $ENV{KRB5CCNAME} = $ret{KRB5_CCACHE};
2776 sub wait_for_start($$$$$)
2778 my ($self, $envvars, $nmbd, $winbindd, $smbd) = @_;
2783 if ($nmbd eq "yes") {
2786 # give time for nbt server to register its names
2787 print "checking for nmbd\n";
2789 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
2790 my $nmblookup = Samba::bindir_path($self, "nmblookup");
2793 $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
2797 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
2798 system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
2799 system("$nmblookup $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
2800 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
2803 } while ($ret != 0 && $count < 10);
2805 print "NMBD not reachable after 10 retries\n";
2806 teardown_env($self, $envvars);
2811 if ($winbindd eq "yes") {
2812 print "checking for winbindd\n";
2814 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2815 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2816 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2817 $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping-dc";
2820 $ret = system($cmd);
2825 } while ($ret != 0 && $count < 20);
2827 print "WINBINDD not reachable after 20 seconds\n";
2828 teardown_env($self, $envvars);
2833 if ($smbd eq "yes") {
2834 # make sure smbd is also up set
2835 print "wait for smbd\n";
2839 $cmd = Samba::bindir_path($self, "smbclient");
2840 $cmd .= " $envvars->{CONFIGURATION}";
2841 $cmd .= " -L $envvars->{SERVER}";
2843 $cmd .= " -I $envvars->{SERVER_IP}";
2845 $ret = system($cmd);
2850 } while ($ret != 0 && $count < 20);
2852 print "SMBD failed to start up in a reasonable time (20sec)\n";
2853 teardown_env($self, $envvars);
2858 # Ensure we have domain users mapped.
2859 $netcmd = "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2860 $netcmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2861 $netcmd .= "UID_WRAPPER_ROOT='1' ";
2862 $netcmd .= Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} ";
2864 $cmd = $netcmd . "groupmap delete ntgroup=domusers";
2865 $ret = system($cmd);
2867 $cmd = $netcmd . "groupmap add rid=513 unixgroup=domusers type=domain";
2868 $ret = system($cmd);
2870 print("\"$cmd\" failed\n");
2874 $cmd = $netcmd . "groupmap delete ntgroup=domadmins";
2875 $ret = system($cmd);
2877 $cmd = $netcmd . "groupmap add rid=512 unixgroup=domadmins type=domain";
2878 $ret = system($cmd);
2880 print("\"$cmd\" failed\n");
2884 $cmd = $netcmd . "groupmap delete ntgroup=everyone";
2885 $ret = system($cmd);
2887 $cmd = $netcmd . "groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin";
2888 $ret = system($cmd);
2890 print("\"$cmd\" failed\n");
2894 # note: creating builtin groups requires winbindd for the
2896 my $create_builtin_users = "no";
2897 if ($winbindd eq "yes") {
2898 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2899 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2900 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2901 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
2902 my $wbinfo_out = qx($cmd 2>&1);
2904 # wbinfo doesn't give us a better error code then
2905 # WBC_ERR_DOMAIN_NOT_FOUND, but at least that's
2906 # different then WBC_ERR_WINBIND_NOT_AVAILABLE
2907 if ($wbinfo_out !~ /WBC_ERR_DOMAIN_NOT_FOUND/) {
2908 print("Failed to run \"wbinfo --sid-to-gid=S-1-5-32-545\": $wbinfo_out");
2909 teardown_env($self, $envvars);
2912 $create_builtin_users = "yes";
2915 if ($create_builtin_users eq "yes") {
2916 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2917 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2918 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2919 $cmd .= Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
2920 $cmd .= "sam createbuiltingroup Users";
2921 $ret = system($cmd);
2923 print "Failed to create BUILTIN\\Users group\n";
2924 teardown_env($self, $envvars);
2928 $cmd = Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
2929 $cmd .= "cache del IDMAP/SID2XID/S-1-5-32-545";
2932 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2933 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2934 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2935 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
2936 $ret = system($cmd);
2938 print "Missing \"BUILTIN\\Users\", did net sam createbuiltingroup Users fail?\n";
2939 teardown_env($self, $envvars);
2944 print $self->getlog_env($envvars);
2950 ## provision and start of ctdb
2954 my ($self, $prefix) = @_;
2957 my $data = $self->provision_ctdb($prefix, $num_nodes);
2958 $data or return undef;
2960 my $rc = $self->check_or_start_ctdb($data);
2962 print("check_or_start_ctdb() failed\n");
2966 $rc = $self->wait_for_start_ctdb($data);
2968 print "Cluster startup failed\n";
2975 sub provision_ctdb($$$$)
2977 my ($self, $prefix, $num_nodes, $no_delete_prefix) = @_;
2980 print "PROVISIONING CTDB...\n";
2982 my $prefix_abs = abs_path($prefix);
2985 # check / create directories:
2987 die ("prefix_abs = ''") if $prefix_abs eq "";
2988 die ("prefix_abs = '/'") if $prefix_abs eq "/";
2990 mkdir ($prefix_abs, 0777);
2992 print "CREATE CTDB TEST ENVIRONMENT in '$prefix_abs'...\n";
2994 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
2995 system("rm -rf $prefix_abs/*");
3002 for (my $i = 0; $i < $num_nodes; $i++) {
3004 my $server_name = "ctdb${i}";
3005 my $pub_iface = Samba::get_interface($server_name);
3006 my $ip = "127.0.0.${pub_iface}";
3008 $node{NODE_NUMBER} = "$i";
3009 $node{SERVER_NAME} = "$server_name";
3010 $node{SOCKET_WRAPPER_DEFAULT_IFACE} = "$pub_iface";
3013 push(@nodes, \%node);
3019 my $nodes_file = "$prefix/nodes.in";
3020 unless (open(NODES, ">$nodes_file")) {
3021 warn("Unable to open nodesfile '$nodes_file'");
3024 for (my $i = 0; $i < $num_nodes; $i++) {
3025 my $ip = $nodes[$i]->{IP};
3026 print NODES "${ip}\n";
3031 # local_daemons.sh setup
3033 # Socket wrapper setup is done by selftest.pl, so don't use
3034 # the CTDB-specific setup
3037 $cmd .= "ctdb/tests/local_daemons.sh " . $prefix_abs . " setup";
3038 $cmd .= " -n " . $num_nodes;
3039 $cmd .= " -N " . $nodes_file;
3040 # CTDB should not attempt to manage public addresses -
3041 # clients should just connect to CTDB private addresses
3042 $cmd .= " -P " . "/dev/null";
3044 my $ret = system($cmd);
3046 print("\"$cmd\" failed\n");
3051 # Unix domain socket and node directory for each daemon
3053 for (my $i = 0; $i < $num_nodes; $i++) {
3054 my ($cmd, $ret, $out);
3056 my $cmd_prefix = "ctdb/tests/local_daemons.sh ${prefix_abs}";
3062 $cmd = "${cmd_prefix} print-socket ${i}";
3067 print("\"$cmd\" failed\n");
3071 $nodes[$i]->{SOCKET_FILE} = "$out";
3077 $cmd = "${cmd_prefix} onnode ${i} 'echo \$CTDB_BASE'";
3082 print("\"$cmd\" failed\n");
3086 $nodes[$i]->{NODE_PREFIX} = "$out";
3091 $ret{CTDB_PREFIX} = "$prefix";
3092 $ret{NUM_NODES} = $num_nodes;
3093 $ret{CTDB_NODES} = \@nodes;
3098 sub check_or_start_ctdb($$) {
3099 my ($self, $data) = @_;
3101 my $prefix = $data->{CTDB_PREFIX};
3102 my $num_nodes = $data->{NUM_NODES};
3103 my $nodes = $data->{CTDB_NODES};
3106 # Share a single stdin pipe for all nodes
3107 pipe($STDIN_READER, $data->{CTDB_STDIN_PIPE});
3109 for (my $i = 0; $i < $num_nodes; $i++) {
3110 my $node = $nodes->[$i];
3112 $node->{STDIN_PIPE} = $data->{CTDB_STDIN_PIPE};
3114 my $cmd = "ctdb/tests/local_daemons.sh";
3115 my @full_cmd = ("$cmd", "$prefix", "start", "$i");
3116 # Dummy environment variables to avoid
3117 # Samba3::get_env_for_process() from generating them
3118 # and including UID_WRAPPER_ROOT=1, which causes
3119 # "Unable to secure ctdb socket" error.
3125 BINARY_PATH => $cmd,
3126 FULL_CMD => [ @full_cmd ],
3128 LOG_FILE => "/dev/null",
3129 ENV_VARS => $env_vars,
3132 print "STARTING CTDBD (node ${i})\n";
3134 # This does magic with $STDIN_READER, so use it
3135 my $ret = Samba::fork_and_exec($self,
3141 print("\"$cmd\" failed\n");
3142 teardown_env_ctdb($self, $data);
3147 close($STDIN_READER);
3152 sub wait_for_start_ctdb($$)
3154 my ($self, $data) = @_;
3156 my $prefix = $data->{CTDB_PREFIX};
3158 print "Wait for ctdbd...\n";
3160 my $ctdb = Samba::bindir_path($self, "ctdb");
3162 $cmd .= "ctdb/tests/local_daemons.sh ${prefix} onnode all";
3163 $cmd .= " ${ctdb} nodestatus all 2>&1";
3166 my $wait_seconds = 60;
3169 until ($count > $wait_seconds) {
3173 print "\ncluster became healthy\n";
3176 print "Waiting for CTDB...\n";
3181 if ($count > $wait_seconds) {
3182 print "\nGiving up to wait for CTDB...\n";
3184 print "CTDB log:\n";
3185 $cmd = "ctdb/tests/local_daemons.sh ${prefix} print-log all >&2";
3187 teardown_env_ctdb($self, $data);
3191 print "\nCTDB initialized\n";