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") . " --configfile=/dev/null -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};
100 my $samba_dcerpcdpid = $envvars->{SAMBA_DCERPCD_TL_PID};
102 # This should give it time to write out the gcov data
103 until ($count > 20) {
104 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
105 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
106 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
107 my $samba_dcerpcdchild = Samba::cleanup_child(
108 $samba_dcerpcdpid, "samba-dcerpcd");
111 && $winbinddchild == -1
112 && $samba_dcerpcdpid == -1) {
120 kill(0, $smbdpid, $nmbdpid, $winbinddpid, $samba_dcerpcdpid) == 0) {
124 $self->stop_sig_term($smbdpid);
125 $self->stop_sig_term($nmbdpid);
126 $self->stop_sig_term($winbinddpid);
127 $self->stop_sig_term($samba_dcerpcdpid);
130 until ($count > 10) {
131 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
132 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
133 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
134 my $samba_dcerpcdpid = Samba::cleanup_child(
135 $samba_dcerpcdpid, "samba-dcerpcd");
138 && $winbinddchild == -1
139 && $samba_dcerpcdpid == -1) {
147 kill(0, $smbdpid, $nmbdpid, $winbinddpid, $samba_dcerpcdpid) == 0) {
151 warn("timelimit process did not quit on SIGTERM, sending SIGKILL");
152 $self->stop_sig_kill($smbdpid);
153 $self->stop_sig_kill($nmbdpid);
154 $self->stop_sig_kill($winbinddpid);
155 $self->stop_sig_kill($samba_dcerpcdpid);
160 sub teardown_env_ctdb($$)
162 my ($self, $data) = @_;
164 if (defined($data->{SAMBA_NODES})) {
165 my $num_nodes = $data->{NUM_NODES};
166 my $nodes = $data->{SAMBA_NODES};
168 for (my $i = 0; $i < $num_nodes; $i++) {
169 if (defined($nodes->[$i])) {
170 $self->teardown_env_samba($nodes->[$i]);
175 close($data->{CTDB_STDIN_PIPE});
177 if (not defined($data->{SAMBA_NODES})) {
178 # Give waiting children time to exit
185 sub getlog_env_app($$$)
187 my ($self, $envvars, $name) = @_;
189 my $title = "$name LOG of: $envvars->{NETBIOSNAME}\n";
192 open(LOG, "<".$envvars->{$name."_TEST_LOG"});
194 seek(LOG, $envvars->{$name."_TEST_LOG_POS"}, SEEK_SET);
198 $envvars->{$name."_TEST_LOG_POS"} = tell(LOG);
201 return "" if $out eq $title;
208 my ($self, $envvars) = @_;
211 $ret .= $self->getlog_env_app($envvars, "SMBD");
212 $ret .= $self->getlog_env_app($envvars, "NMBD");
213 $ret .= $self->getlog_env_app($envvars, "WINBINDD");
220 my ($self, $envvars) = @_;
222 my $childpid = waitpid(-1, WNOHANG);
228 # Declare the environments Samba3 makes available.
229 # To be set up, they will be called as
230 # samba3->setup_$envname($self, $path, $dep_1_vars, $dep_2_vars, ...)
231 %Samba3::ENV_DEPS = (
232 # name => [dep_1, dep_2, ...],
235 nt4_dc_smb1_done => ["nt4_dc_smb1"],
236 nt4_dc_schannel => [],
240 fileserver_smb1 => [],
241 fileserver_smb1_done => ["fileserver_smb1"],
245 nt4_member => ["nt4_dc"],
247 ad_member => ["ad_dc", "fl2008r2dc", "fl2003dc"],
248 ad_member_rfc2307 => ["ad_dc_ntvfs"],
249 ad_member_idmap_rid => ["ad_dc"],
250 admem_idmap_autorid => ["ad_dc"],
251 ad_member_idmap_ad => ["fl2008r2dc"],
252 ad_member_fips => ["ad_dc_fips"],
253 ad_member_offlogon => ["ad_dc"],
254 ad_member_oneway => ["fl2000dc"],
255 ad_member_idmap_nss => ["ad_dc"],
256 ad_member_s3_join => ["vampire_dc"],
258 clusteredmember => ["nt4_dc"],
261 %Samba3::ENV_DEPS_POST = ();
265 my ($self, $path, $more_conf, $server) = @_;
267 print "PROVISIONING NT4 DC...";
269 my $nt4_dc_options = "
274 raw NTLMv2 auth = yes
275 rpc start on demand helpers = false
277 CVE_2020_1472:warn_about_unused_debug_level = 3
278 server require schannel:schannel0\$ = no
279 server require schannel:schannel1\$ = no
280 server require schannel:schannel2\$ = no
281 server require schannel:schannel3\$ = no
282 server require schannel:schannel4\$ = no
283 server require schannel:schannel5\$ = no
284 server require schannel:schannel6\$ = no
285 server require schannel:schannel7\$ = no
286 server require schannel:schannel8\$ = no
287 server require schannel:schannel9\$ = no
288 server require schannel:schannel10\$ = no
289 server require schannel:schannel11\$ = no
290 server require schannel:torturetest\$ = no
292 server schannel require seal:schannel0\$ = no
293 server schannel require seal:schannel1\$ = no
294 server schannel require seal:schannel2\$ = no
295 server schannel require seal:schannel3\$ = no
296 server schannel require seal:schannel4\$ = no
297 server schannel require seal:schannel5\$ = no
298 server schannel require seal:schannel6\$ = no
299 server schannel require seal:schannel7\$ = no
300 server schannel require seal:schannel8\$ = no
301 server schannel require seal:schannel9\$ = no
302 server schannel require seal:schannel10\$ = no
303 server schannel require seal:schannel11\$ = no
304 server schannel require seal:torturetest\$ = no
306 vfs_default:VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS = no
308 fss: sequence timeout = 1
309 check parent directory delete on close = yes
312 if (defined($more_conf)) {
313 $nt4_dc_options = $nt4_dc_options . $more_conf;
315 if (!defined($server)) {
316 $server = "LOCALNT4DC2";
318 my $vars = $self->provision(
320 domain => "SAMBA-TEST",
322 password => "localntdc2pass",
323 extra_options => $nt4_dc_options);
325 $vars or return undef;
327 if (not $self->check_or_start(
329 samba_dcerpcd => "yes",
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};
347 sub setup_nt4_dc_smb1
349 my ($self, $path) = @_;
352 client min protocol = CORE
353 server min protocol = LANMAN1
355 return $self->setup_nt4_dc($path, $conf, "LCLNT4DC2SMB1");
358 sub setup_nt4_dc_smb1_done
360 my ($self, $path, $dep_env) = @_;
361 return $self->return_alias_env($path, $dep_env);
364 sub setup_nt4_dc_schannel
366 my ($self, $path) = @_;
368 print "PROVISIONING NT4 DC WITH SERVER SCHANNEL ...";
375 server schannel = yes
376 # used to reproduce bug #12772
377 server max protocol = SMB2_02
380 my $vars = $self->provision(
382 domain => "NT4SCHANNEL",
383 server => "LOCALNT4DC9",
384 password => "localntdc9pass",
385 extra_options => $pdc_options);
387 $vars or return undef;
389 if (not $self->check_or_start(
397 $vars->{DOMSID} = $vars->{SAMSID};
398 $vars->{DC_SERVER} = $vars->{SERVER};
399 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
400 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
401 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
402 $vars->{DC_USERNAME} = $vars->{USERNAME};
403 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
410 my ($self, $prefix, $nt4_dc_vars) = @_;
414 print "PROVISIONING MEMBER...";
416 my $require_mutexes = "dbwrap_tdb_require_mutexes:* = yes";
417 if ($ENV{SELFTEST_DONT_REQUIRE_TDB_MUTEX_SUPPORT} // '' eq "1") {
418 $require_mutexes = "";
421 my $member_options = "
423 dbwrap_tdb_mutexes:* = yes
426 my $ret = $self->provision(
428 domain => $nt4_dc_vars->{DOMAIN},
429 server => "LOCALNT4MEMBER3",
430 password => "localnt4member3pass",
431 extra_options => $member_options);
433 $ret or return undef;
435 my $nmblookup = Samba::bindir_path($self, "nmblookup");
437 print "Waiting for the LOGON SERVER registration ...\n";
438 $rc = system("$nmblookup $ret->{CONFIGURATION} $ret->{DOMAIN}\#1c");
443 } while ($rc != 0 && $count < 10);
445 print "NMBD not reachable after 10 retries\n";
446 teardown_env($self, $ret);
450 my $net = Samba::bindir_path($self, "net");
451 # Add hosts file for name lookups
452 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
453 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
454 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
455 $cmd .= "$net rpc join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
456 $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}";
458 if (system($cmd) != 0) {
459 warn("Join failed\n$cmd");
463 # Add hosts file for name lookups
464 $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
465 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
466 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
467 $cmd .= "$net $ret->{CONFIGURATION} primarytrust dumpinfo | grep -q 'REDACTED SECRET VALUES'";
469 if (system($cmd) != 0) {
470 warn("check failed\n$cmd");
474 if (not $self->check_or_start(
482 $ret->{DOMSID} = $nt4_dc_vars->{DOMSID};
483 $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
484 $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
485 $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
486 $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME};
487 $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME};
488 $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD};
493 sub setup_clusteredmember
495 my ($self, $prefix, $nt4_dc_vars) = @_;
501 print "PROVISIONING CLUSTEREDMEMBER...\n";
503 my $prefix_abs = abs_path($prefix);
504 mkdir($prefix_abs, 0777);
506 my $server_name = "CLUSTEREDMEMBER";
508 my $ctdb_data = $self->setup_ctdb($prefix);
510 if (not $ctdb_data) {
511 print "No ctdb data\n";
515 print "PROVISIONING CLUSTERED SAMBA...\n";
517 my $num_nodes = $ctdb_data->{NUM_NODES};
518 my $nodes = $ctdb_data->{CTDB_NODES};
520 # Enable cleanup of earlier nodes if a later node fails
521 $ctdb_data->{SAMBA_NODES} = \@retvals;
523 for (my $i = 0; $i < $num_nodes; $i++) {
524 my $node = $nodes->[$i];
525 my $socket = $node->{SOCKET_FILE};
526 my $server_name = $node->{SERVER_NAME};
527 my $pub_iface = $node->{SOCKET_WRAPPER_DEFAULT_IFACE};
528 my $node_prefix = $node->{NODE_PREFIX};
530 print "NODE_PREFIX=${node_prefix}\n";
531 print "SOCKET=${socket}\n";
533 my $require_mutexes = "dbwrap_tdb_require_mutexes:* = yes";
534 if ($ENV{SELFTEST_DONT_REQUIRE_TDB_MUTEX_SUPPORT} // '' eq "1") {
535 $require_mutexes = "" ;
538 my $member_options = "
542 ctdbd socket = ${socket}
544 dbwrap_tdb_mutexes:* = yes
548 my $node_ret = $self->provision(
549 prefix => "$node_prefix",
550 domain => $nt4_dc_vars->{DOMAIN},
551 server => "$server_name",
552 password => "clustermember8pass",
553 netbios_name => "CLUSTEREDMEMBER",
554 share_dir => "${prefix_abs}/shared",
555 extra_options => $member_options,
556 no_delete_prefix => 1);
558 print "Provision node $i failed\n";
559 teardown_env($self, $ctdb_data);
563 my $registry_share_template = "$node_ret->{SERVERCONFFILE}.registry_share_template";
564 unless (open(REGISTRYCONF, ">$registry_share_template")) {
565 warn("Unable to open $registry_share_template");
566 teardown_env($self, $node_ret);
567 teardown_env($self, $ctdb_data);
574 comment = smb username is [%U]
579 my $net = Samba::bindir_path($self, "net");
582 $cmd .= "UID_WRAPPER_ROOT=1 ";
583 $cmd .= "$net conf import $node_ret->{CONFIGURATION} ${registry_share_template}";
585 my $net_ret = system($cmd);
587 warn("net conf import failed: $net_ret\n$cmd");
588 teardown_env($self, $node_ret);
589 teardown_env($self, $ctdb_data);
593 my $nmblookup = Samba::bindir_path($self, "nmblookup");
595 print "Waiting for the LOGON SERVER registration ...\n";
596 $rc = system("$nmblookup $node_ret->{CONFIGURATION} " .
597 "$node_ret->{DOMAIN}\#1c");
602 } while ($rc != 0 && $count < 10);
605 print "NMBD not reachable after 10 retries\n";
606 teardown_env($self, $node_ret);
607 teardown_env($self, $ctdb_data);
611 push(@retvals, $node_ret);
614 $ret = {%$ctdb_data, %{$retvals[0]}};
616 my $net = Samba::bindir_path($self, "net");
618 $cmd .= "UID_WRAPPER_ROOT=1 ";
619 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
620 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
621 $cmd .= "$net join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
622 $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}";
624 if (system($cmd) != 0) {
625 warn("Join failed\n$cmd");
626 teardown_env($self, $ret);
630 for (my $i=0; $i<@retvals; $i++) {
631 my $node_provision = $retvals[$i];
633 $ok = $self->check_or_start(
634 env_vars => $node_provision,
637 child_cleanup => sub {
639 my $fh = $_->{STDIN_PIPE};
640 close($fh) if defined($fh);
643 teardown_env($self, $ret);
649 # Build a unclist for every share
651 unless (open(NODES, "<$ret->{CTDB_NODES_FILE}")) {
652 warn("Unable to open CTDB nodes file");
653 teardown_env($self, $ret);
660 my $conffile = $ret->{SERVERCONFFILE};
662 $cmd .= 'sed -n -e \'s|^\[\(.*\)\]$|\1|p\'';
663 $cmd .= " \"$conffile\"";
664 $cmd .= " | grep -vx 'global'";
669 warn("Listing shares failed\n$cmd");
670 teardown_env($self, $ret);
675 my $unclistdir = "${prefix_abs}/unclists";
676 mkdir($unclistdir, 0777);
677 foreach my $share (@shares) {
678 my $l = "${unclistdir}/${share}.txt";
679 unless (open(UNCLIST, ">${l}")) {
680 warn("Unable to open UNC list ${l}");
681 teardown_env($self, $ret);
684 foreach my $node (@nodes) {
685 print UNCLIST "//${node}/${share}\n";
690 $ret->{DOMSID} = $nt4_dc_vars->{DOMSID};
691 $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
692 $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
693 $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
694 $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME};
695 $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME};
696 $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD};
701 sub provision_ad_member
709 $extra_member_options,
712 $no_nss_winbind) = @_;
714 if (defined($offline_logon) && defined($no_nss_winbind)) {
715 warn ("Offline logon incompatible with no nss winbind\n");
719 my $prefix_abs = abs_path($prefix);
722 mkdir($prefix_abs, 0777);
724 my $share_dir="$prefix_abs/share";
725 push(@dirs, $share_dir);
727 my $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}";
728 push(@dirs, $substitution_path);
730 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice";
731 push(@dirs, $substitution_path);
733 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice/G_domain users";
734 push(@dirs, $substitution_path);
736 # Using '/' as the winbind separator is a bad idea ...
737 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}";
738 push(@dirs, $substitution_path);
740 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice";
741 push(@dirs, $substitution_path);
743 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}";
744 push(@dirs, $substitution_path);
746 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}/domain users";
747 push(@dirs, $substitution_path);
749 my $option_offline_logon = "no";
750 if (defined($offline_logon)) {
751 $option_offline_logon = "yes";
754 my $netbios_aliases = "";
755 if ($machine_account eq "LOCALADMEMBER") {
756 $netbios_aliases = "netbios aliases = foo bar";
759 unless (defined($extra_member_options)) {
760 $extra_member_options = "";
763 my $member_options = "
765 workgroup = $dcvars->{DOMAIN}
766 realm = $dcvars->{REALM}
768 template homedir = /home/%D/%G/%U
769 auth event notification = true
770 password server = $dcvars->{SERVER}
771 winbind scan trusted domains = no
772 winbind offline logon = $option_offline_logon
774 allow dcerpc auth level connect:lsarpc = yes
775 dcesrv:max auth states = 8
776 rpc start on demand helpers = false
778 # Begin extra member options
779 $extra_member_options
780 # End extra member options
783 path = $share_dir/D_%D/U_%U/G_%G
787 path = $share_dir/D_%D/u_%u/g_%g
792 valid users = ADDOMAIN/%U
794 [sub_valid_users_domain]
798 [sub_valid_users_group]
800 valid users = \@$dcvars->{DOMAIN}/%G
804 valid users = $dcvars->{DOMAIN}/$dcvars->{DC_USERNAME}
808 valid users = \"\@$dcvars->{DOMAIN}/domain users\"
810 [valid_users_unix_group]
812 valid users = \"+$dcvars->{DOMAIN}/domain users\"
814 [valid_users_nis_group]
816 valid users = \"&$dcvars->{DOMAIN}/domain users\"
818 [valid_users_unix_nis_group]
820 valid users = \"+&$dcvars->{DOMAIN}/domain users\"
822 [valid_users_nis_unix_group]
824 valid users = \"&+$dcvars->{DOMAIN}/domain users\"
828 invalid users = $dcvars->{DOMAIN}/$dcvars->{DC_USERNAME}
830 [valid_and_invalid_users]
832 valid users = $dcvars->{DOMAIN}/$dcvars->{DC_USERNAME} $dcvars->{DOMAIN}/alice
833 invalid users = $dcvars->{DOMAIN}/$dcvars->{DC_USERNAME}
836 my $ret = $self->provision(
838 domain => $dcvars->{DOMAIN},
839 realm => $dcvars->{REALM},
840 server => $machine_account,
841 password => "loCalMemberPass",
842 extra_options => $member_options,
843 resolv_conf => $dcvars->{RESOLV_CONF});
845 $ret or return undef;
847 mkdir($_, 0777) foreach(@dirs);
849 $ret->{DOMAIN} = $dcvars->{DOMAIN};
850 $ret->{REALM} = $dcvars->{REALM};
851 $ret->{DOMSID} = $dcvars->{DOMSID};
855 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
856 $ctx->{domain} = $dcvars->{DOMAIN};
857 $ctx->{realm} = $dcvars->{REALM};
858 $ctx->{dnsname} = lc($dcvars->{REALM});
859 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
860 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
861 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
862 Samba::mk_krb5_conf($ctx, "");
864 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
866 if (defined($force_fips_mode)) {
867 $ret->{GNUTLS_FORCE_FIPS_MODE} = "1";
868 $ret->{OPENSSL_FORCE_FIPS_MODE} = "1";
871 my $net = Samba::bindir_path($self, "net");
872 # Add hosts file for name lookups
873 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
874 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
875 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
876 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
878 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
880 if (defined($force_fips_mode)) {
881 $cmd .= "GNUTLS_FORCE_FIPS_MODE=1 ";
882 $cmd .= "OPENSSL_FORCE_FIPS_MODE=1 ";
884 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
885 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
886 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
887 $cmd .= "$net join $ret->{CONFIGURATION}";
888 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD} --use-kerberos=required";
890 if (system($cmd) != 0) {
891 warn("Join failed\n$cmd");
895 # We need world access to this share, as otherwise the domain
896 # administrator from the AD domain provided by Samba4 can't
897 # access the share for tests.
898 chmod 0777, "$prefix/share";
900 if (defined($offline_logon)) {
901 my $wbinfo = Samba::bindir_path($self, "wbinfo");
903 if (not $self->check_or_start(
905 winbindd => "yes")) {
909 # Fill samlogoncache for alice
910 $cmd = "NSS_WRAPPER_PASSWD='$ret->{NSS_WRAPPER_PASSWD}' ";
911 $cmd .= "NSS_WRAPPER_GROUP='$ret->{NSS_WRAPPER_GROUP}' ";
912 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
913 $cmd .= "$wbinfo --pam-logon=ADDOMAIN/alice%Secret007";
914 if (system($cmd) != 0) {
915 warn("Filling the cache failed\n$cmd");
919 $cmd = "NSS_WRAPPER_PASSWD='$ret->{NSS_WRAPPER_PASSWD}' ";
920 $cmd .= "NSS_WRAPPER_GROUP='$ret->{NSS_WRAPPER_GROUP}' ";
921 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
922 $cmd .= "$wbinfo --ccache-save=ADDOMAIN/alice%Secret007";
923 if (system($cmd) != 0) {
924 warn("Filling the cache failed\n$cmd");
928 # Fill samlogoncache for bob
929 $cmd = "NSS_WRAPPER_PASSWD='$ret->{NSS_WRAPPER_PASSWD}' ";
930 $cmd .= "NSS_WRAPPER_GROUP='$ret->{NSS_WRAPPER_GROUP}' ";
931 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
932 $cmd .= "$wbinfo --pam-logon=ADDOMAIN/bob%Secret007";
933 if (system($cmd) != 0) {
934 warn("Filling the cache failed\n$cmd");
938 $cmd = "NSS_WRAPPER_PASSWD='$ret->{NSS_WRAPPER_PASSWD}' ";
939 $cmd .= "NSS_WRAPPER_GROUP='$ret->{NSS_WRAPPER_GROUP}' ";
940 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
941 $cmd .= "$wbinfo --ccache-save=ADDOMAIN/bob%Secret007";
942 if (system($cmd) != 0) {
943 warn("Filling the cache failed\n$cmd");
947 # Set windindd offline
948 my $smbcontrol = Samba::bindir_path($self, "smbcontrol");
949 $cmd = "NSS_WRAPPER_PASSWD='$ret->{NSS_WRAPPER_PASSWD}' ";
950 $cmd .= "NSS_WRAPPER_GROUP='$ret->{NSS_WRAPPER_GROUP}' ";
951 $cmd .= "UID_WRAPPER_ROOT='1' ";
952 $cmd .= "$smbcontrol $ret->{CONFIGURATION} winbindd offline";
953 if (system($cmd) != 0) {
954 warn("Setting winbindd offline failed\n$cmd");
958 # Validate the offline cache
959 $cmd = "NSS_WRAPPER_PASSWD='$ret->{NSS_WRAPPER_PASSWD}' ";
960 $cmd .= "NSS_WRAPPER_GROUP='$ret->{NSS_WRAPPER_GROUP}' ";
961 $cmd .= "UID_WRAPPER_ROOT='1' ";
962 $cmd .= "$smbcontrol $ret->{CONFIGURATION} winbindd validate-cache";
963 if (system($cmd) != 0) {
964 warn("Validation of winbind credential cache failed\n$cmd");
965 teardown_env($self, $ret);
970 teardown_env($self, $ret);
972 ### Change SOCKET_WRAPPER_DIR so it can't connect to AD
973 my $swrap_env = $ENV{SOCKET_WRAPPER_DIR};
974 $ENV{SOCKET_WRAPPER_DIR} = "$prefix_abs";
976 # Start winbindd in offline mode
977 if (not $self->check_or_start(
979 winbindd => "offline")) {
983 # Set socket dir again
984 $ENV{SOCKET_WRAPPER_DIR} = $swrap_env;
987 if (defined($no_nss_winbind)) {
988 $ret->{NSS_WRAPPER_MODULE_SO_PATH} = "";
989 $ret->{NSS_WRAPPER_MODULE_FN_PREFIX} = "";
992 if (not $self->check_or_start(
994 samba_dcerpcd => "yes",
1002 $ret->{DC_SERVER} = $dcvars->{SERVER};
1003 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1004 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1005 $ret->{DC_SERVERCONFFILE} = $dcvars->{SERVERCONFFILE};
1006 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1007 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1008 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1011 $ret->{TRUST_F_BOTH_SERVER} = $trustvars_f->{SERVER};
1012 $ret->{TRUST_F_BOTH_SERVER_IP} = $trustvars_f->{SERVER_IP};
1013 $ret->{TRUST_F_BOTH_SERVER_IPV6} = $trustvars_f->{SERVER_IPV6};
1014 $ret->{TRUST_F_BOTH_NETBIOSNAME} = $trustvars_f->{NETBIOSNAME};
1015 $ret->{TRUST_F_BOTH_USERNAME} = $trustvars_f->{USERNAME};
1016 $ret->{TRUST_F_BOTH_PASSWORD} = $trustvars_f->{PASSWORD};
1017 $ret->{TRUST_F_BOTH_DOMAIN} = $trustvars_f->{DOMAIN};
1018 $ret->{TRUST_F_BOTH_REALM} = $trustvars_f->{REALM};
1021 $ret->{TRUST_E_BOTH_SERVER} = $trustvars_e->{SERVER};
1022 $ret->{TRUST_E_BOTH_SERVER_IP} = $trustvars_e->{SERVER_IP};
1023 $ret->{TRUST_E_BOTH_SERVER_IPV6} = $trustvars_e->{SERVER_IPV6};
1024 $ret->{TRUST_E_BOTH_NETBIOSNAME} = $trustvars_e->{NETBIOSNAME};
1025 $ret->{TRUST_E_BOTH_USERNAME} = $trustvars_e->{USERNAME};
1026 $ret->{TRUST_E_BOTH_PASSWORD} = $trustvars_e->{PASSWORD};
1027 $ret->{TRUST_E_BOTH_DOMAIN} = $trustvars_e->{DOMAIN};
1028 $ret->{TRUST_E_BOTH_REALM} = $trustvars_e->{REALM};
1041 # If we didn't build with ADS, pretend this env was never available
1042 if (not $self->have_ads()) {
1046 print "PROVISIONING AD MEMBER...";
1048 return $self->provision_ad_member($prefix,
1055 sub setup_ad_member_s3_join
1063 # If we didn't build with ADS, pretend this env was never available
1064 if (not $self->have_ads()) {
1068 print "PROVISIONING AD MEMBER...";
1070 return $self->provision_ad_member($prefix,
1077 sub setup_ad_member_rfc2307
1079 my ($self, $prefix, $dcvars) = @_;
1081 # If we didn't build with ADS, pretend this env was never available
1082 if (not $self->have_ads()) {
1086 print "PROVISIONING S3 AD MEMBER WITH idmap_rfc2307 config...";
1088 my $member_options = "
1090 workgroup = $dcvars->{DOMAIN}
1091 realm = $dcvars->{REALM}
1092 idmap cache time = 0
1093 idmap negative cache time = 0
1094 idmap config * : backend = autorid
1095 idmap config * : range = 1000000-1999999
1096 idmap config * : rangesize = 100000
1097 idmap config $dcvars->{DOMAIN} : backend = rfc2307
1098 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
1099 idmap config $dcvars->{DOMAIN} : ldap_server = ad
1100 idmap config $dcvars->{DOMAIN} : bind_path_user = ou=idmap,dc=samba,dc=example,dc=com
1101 idmap config $dcvars->{DOMAIN} : bind_path_group = ou=idmap,dc=samba,dc=example,dc=com
1103 password server = $dcvars->{SERVER}
1106 my $ret = $self->provision(
1108 domain => $dcvars->{DOMAIN},
1109 realm => $dcvars->{REALM},
1110 server => "RFC2307MEMBER",
1111 password => "loCalMemberPass",
1112 extra_options => $member_options,
1113 resolv_conf => $dcvars->{RESOLV_CONF});
1115 $ret or return undef;
1117 $ret->{DOMAIN} = $dcvars->{DOMAIN};
1118 $ret->{REALM} = $dcvars->{REALM};
1119 $ret->{DOMSID} = $dcvars->{DOMSID};
1122 my $prefix_abs = abs_path($prefix);
1124 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1125 $ctx->{domain} = $dcvars->{DOMAIN};
1126 $ctx->{realm} = $dcvars->{REALM};
1127 $ctx->{dnsname} = lc($dcvars->{REALM});
1128 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
1129 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
1130 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1131 Samba::mk_krb5_conf($ctx, "");
1133 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1135 my $net = Samba::bindir_path($self, "net");
1136 # Add hosts file for name lookups
1137 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
1138 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1139 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
1140 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
1142 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
1144 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
1145 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1146 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
1147 $cmd .= "$net join $ret->{CONFIGURATION}";
1148 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
1150 if (system($cmd) != 0) {
1151 warn("Join failed\n$cmd");
1155 # We need world access to this share, as otherwise the domain
1156 # administrator from the AD domain provided by Samba4 can't
1157 # access the share for tests.
1158 chmod 0777, "$prefix/share";
1160 if (not $self->check_or_start(
1168 $ret->{DC_SERVER} = $dcvars->{SERVER};
1169 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1170 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1171 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1172 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1173 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1178 sub setup_admem_idmap_autorid
1180 my ($self, $prefix, $dcvars) = @_;
1182 # If we didn't build with ADS, pretend this env was never available
1183 if (not $self->have_ads()) {
1187 print "PROVISIONING S3 AD MEMBER WITH idmap_autorid config...";
1189 my $member_options = "
1191 workgroup = $dcvars->{DOMAIN}
1192 realm = $dcvars->{REALM}
1193 idmap config * : backend = autorid
1194 idmap config * : range = 1000000-19999999
1195 idmap config * : rangesize = 1000000
1197 # Prevent overriding the provisioned lib/krb5.conf which sets certain
1198 # values required for tests to succeed
1199 create krb5 conf = no
1202 my $ret = $self->provision(
1204 domain => $dcvars->{DOMAIN},
1205 realm => $dcvars->{REALM},
1206 server => "ADMEMAUTORID",
1207 password => "loCalMemberPass",
1208 extra_options => $member_options,
1209 resolv_conf => $dcvars->{RESOLV_CONF});
1211 $ret or return undef;
1213 $ret->{DOMAIN} = $dcvars->{DOMAIN};
1214 $ret->{REALM} = $dcvars->{REALM};
1215 $ret->{DOMSID} = $dcvars->{DOMSID};
1218 my $prefix_abs = abs_path($prefix);
1220 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1221 $ctx->{domain} = $dcvars->{DOMAIN};
1222 $ctx->{realm} = $dcvars->{REALM};
1223 $ctx->{dnsname} = lc($dcvars->{REALM});
1224 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
1225 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
1226 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1227 Samba::mk_krb5_conf($ctx, "");
1229 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1231 my $net = Samba::bindir_path($self, "net");
1232 # Add hosts file for name lookups
1233 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
1234 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1235 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
1236 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
1238 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
1240 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
1241 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1242 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
1243 $cmd .= "$net join $ret->{CONFIGURATION}";
1244 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
1246 if (system($cmd) != 0) {
1247 warn("Join failed\n$cmd");
1251 # We need world access to this share, as otherwise the domain
1252 # administrator from the AD domain provided by Samba4 can't
1253 # access the share for tests.
1254 chmod 0777, "$prefix/share";
1256 if (not $self->check_or_start(
1264 $ret->{DC_SERVER} = $dcvars->{SERVER};
1265 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1266 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1267 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1268 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1269 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1274 sub setup_ad_member_idmap_rid
1276 my ($self, $prefix, $dcvars) = @_;
1278 # If we didn't build with ADS, pretend this env was never available
1279 if (not $self->have_ads()) {
1283 print "PROVISIONING S3 AD MEMBER WITH idmap_rid config...";
1285 my $member_options = "
1287 workgroup = $dcvars->{DOMAIN}
1288 realm = $dcvars->{REALM}
1289 idmap config * : backend = tdb
1290 idmap config * : range = 1000000-1999999
1291 idmap config $dcvars->{DOMAIN} : backend = rid
1292 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
1293 # Prevent overriding the provisioned lib/krb5.conf which sets certain
1294 # values required for tests to succeed
1295 create krb5 conf = no
1296 map to guest = bad user
1297 winbind expand groups = 10
1298 server signing = required
1301 my $ret = $self->provision(
1303 domain => $dcvars->{DOMAIN},
1304 realm => $dcvars->{REALM},
1305 server => "IDMAPRIDMEMBER",
1306 password => "loCalMemberPass",
1307 extra_options => $member_options,
1308 resolv_conf => $dcvars->{RESOLV_CONF});
1310 $ret or return undef;
1312 $ret->{DOMAIN} = $dcvars->{DOMAIN};
1313 $ret->{REALM} = $dcvars->{REALM};
1314 $ret->{DOMSID} = $dcvars->{DOMSID};
1317 my $prefix_abs = abs_path($prefix);
1319 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1320 $ctx->{domain} = $dcvars->{DOMAIN};
1321 $ctx->{realm} = $dcvars->{REALM};
1322 $ctx->{dnsname} = lc($dcvars->{REALM});
1323 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
1324 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
1325 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1326 Samba::mk_krb5_conf($ctx, "");
1328 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1330 my $net = Samba::bindir_path($self, "net");
1331 # Add hosts file for name lookups
1332 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
1333 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1334 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
1335 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
1337 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
1339 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
1340 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1341 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
1342 $cmd .= "$net join $ret->{CONFIGURATION}";
1343 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
1345 if (system($cmd) != 0) {
1346 warn("Join failed\n$cmd");
1350 # We need world access to this share, as otherwise the domain
1351 # administrator from the AD domain provided by Samba4 can't
1352 # access the share for tests.
1353 chmod 0777, "$prefix/share";
1355 if (not $self->check_or_start(
1363 $ret->{DC_SERVER} = $dcvars->{SERVER};
1364 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1365 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1366 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1367 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1368 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1373 sub setup_ad_member_idmap_ad
1375 my ($self, $prefix, $dcvars) = @_;
1377 # If we didn't build with ADS, pretend this env was never available
1378 if (not $self->have_ads()) {
1382 print "PROVISIONING S3 AD MEMBER WITH idmap_ad config...";
1384 my $member_options = "
1386 workgroup = $dcvars->{DOMAIN}
1387 realm = $dcvars->{REALM}
1388 password server = $dcvars->{SERVER}
1389 idmap config * : backend = tdb
1390 idmap config * : range = 1000000-1999999
1391 idmap config $dcvars->{DOMAIN} : backend = ad
1392 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
1393 idmap config $dcvars->{DOMAIN} : unix_primary_group = yes
1394 idmap config $dcvars->{DOMAIN} : unix_nss_info = yes
1395 idmap config $dcvars->{DOMAIN} : deny ous = \"ou=sub,DC=samba2008r2,DC=example,DC=com\"
1396 idmap config $dcvars->{TRUST_DOMAIN} : backend = ad
1397 idmap config $dcvars->{TRUST_DOMAIN} : range = 2000000-2999999
1398 gensec_gssapi:requested_life_time = 5
1401 my $ret = $self->provision(
1403 domain => $dcvars->{DOMAIN},
1404 realm => $dcvars->{REALM},
1405 server => "IDMAPADMEMBER",
1406 password => "loCalMemberPass",
1407 extra_options => $member_options,
1408 resolv_conf => $dcvars->{RESOLV_CONF});
1410 $ret or return undef;
1412 $ret->{DOMAIN} = $dcvars->{DOMAIN};
1413 $ret->{REALM} = $dcvars->{REALM};
1414 $ret->{DOMSID} = $dcvars->{DOMSID};
1417 my $prefix_abs = abs_path($prefix);
1419 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1420 $ctx->{domain} = $dcvars->{DOMAIN};
1421 $ctx->{realm} = $dcvars->{REALM};
1422 $ctx->{dnsname} = lc($dcvars->{REALM});
1423 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
1424 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
1425 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1426 Samba::mk_krb5_conf($ctx, "");
1428 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1430 my $net = Samba::bindir_path($self, "net");
1431 # Add hosts file for name lookups
1432 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
1433 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1434 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
1435 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
1437 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
1439 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
1440 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1441 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
1442 $cmd .= "$net join $ret->{CONFIGURATION}";
1443 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
1445 if (system($cmd) != 0) {
1446 warn("Join failed\n$cmd");
1450 # We need world access to this share, as otherwise the domain
1451 # administrator from the AD domain provided by Samba4 can't
1452 # access the share for tests.
1453 chmod 0777, "$prefix/share";
1455 if (not $self->check_or_start(
1463 $ret->{DC_SERVER} = $dcvars->{SERVER};
1464 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1465 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1466 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1467 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1468 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1470 $ret->{TRUST_SERVER} = $dcvars->{TRUST_SERVER};
1471 $ret->{TRUST_USERNAME} = $dcvars->{TRUST_USERNAME};
1472 $ret->{TRUST_PASSWORD} = $dcvars->{TRUST_PASSWORD};
1473 $ret->{TRUST_DOMAIN} = $dcvars->{TRUST_DOMAIN};
1474 $ret->{TRUST_REALM} = $dcvars->{TRUST_REALM};
1475 $ret->{TRUST_DOMSID} = $dcvars->{TRUST_DOMSID};
1480 sub setup_ad_member_oneway
1482 my ($self, $prefix, $dcvars) = @_;
1484 # If we didn't build with ADS, pretend this env was never available
1485 if (not $self->have_ads()) {
1489 print "PROVISIONING S3 AD MEMBER WITH one-way trust...";
1491 my $member_options = "
1493 workgroup = $dcvars->{DOMAIN}
1494 realm = $dcvars->{REALM}
1495 password server = $dcvars->{SERVER}
1496 idmap config * : backend = tdb
1497 idmap config * : range = 1000000-1999999
1498 gensec_gssapi:requested_life_time = 5
1501 my $ret = $self->provision(
1503 domain => $dcvars->{DOMAIN},
1504 server => "S2KMEMBER",
1505 password => "loCalS2KMemberPass",
1506 extra_options => $member_options,
1507 resolv_conf => $dcvars->{RESOLV_CONF});
1509 $ret or return undef;
1511 $ret->{DOMAIN} = $dcvars->{DOMAIN};
1512 $ret->{REALM} = $dcvars->{REALM};
1513 $ret->{DOMSID} = $dcvars->{DOMSID};
1516 my $prefix_abs = abs_path($prefix);
1518 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1519 $ctx->{domain} = $dcvars->{DOMAIN};
1520 $ctx->{realm} = $dcvars->{REALM};
1521 $ctx->{dnsname} = lc($dcvars->{REALM});
1522 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
1523 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
1524 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1525 Samba::mk_krb5_conf($ctx, "");
1527 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1529 my $net = Samba::bindir_path($self, "net");
1530 # Add hosts file for name lookups
1531 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
1532 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1533 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
1534 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
1536 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
1538 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
1539 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1540 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
1541 $cmd .= "$net join $ret->{CONFIGURATION}";
1542 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
1544 if (system($cmd) != 0) {
1545 warn("Join failed\n$cmd");
1549 if (not $self->check_or_start(
1551 winbindd => "yes")) {
1555 $ret->{DC_SERVER} = $dcvars->{SERVER};
1556 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1557 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1558 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1559 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1560 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1562 $ret->{TRUST_SERVER} = $dcvars->{TRUST_SERVER};
1563 $ret->{TRUST_USERNAME} = $dcvars->{TRUST_USERNAME};
1564 $ret->{TRUST_PASSWORD} = $dcvars->{TRUST_PASSWORD};
1565 $ret->{TRUST_DOMAIN} = $dcvars->{TRUST_DOMAIN};
1566 $ret->{TRUST_REALM} = $dcvars->{TRUST_REALM};
1567 $ret->{TRUST_DOMSID} = $dcvars->{TRUST_DOMSID};
1572 sub setup_ad_member_fips
1580 # If we didn't build with ADS, pretend this env was never available
1581 if (not $self->have_ads()) {
1585 print "PROVISIONING AD FIPS MEMBER...";
1587 return $self->provision_ad_member($prefix,
1596 sub setup_ad_member_offlogon
1604 # If we didn't build with ADS, pretend this env was never available
1605 if (not $self->have_ads()) {
1609 print "PROVISIONING AD MEMBER OFFLINE LOGON...";
1611 return $self->provision_ad_member($prefix,
1621 sub setup_ad_member_idmap_nss
1629 # If we didn't build with ADS, pretend this env was never available
1630 if (not $self->have_ads()) {
1634 print "PROVISIONING AD MEMBER WITHOUT NSS WINBIND WITH idmap_nss config...";
1636 my $extra_member_options = "
1637 # bob:x:65521:65531:localbob gecos:/:/bin/false
1638 # jane:x:65520:65531:localjane gecos:/:/bin/false
1639 # jackthemapper:x:65519:65531:localjackthemaper gecos:/:/bin/false
1640 # jacknomapper:x:65518:65531:localjacknomaper gecos:/:/bin/false
1641 idmap config $dcvars->{DOMAIN} : backend = nss
1642 idmap config $dcvars->{DOMAIN} : range = 65518-65521
1644 # Support SMB1 so that we can use posix_whoami().
1645 client min protocol = CORE
1646 server min protocol = LANMAN1
1648 username map = $prefix/lib/username.map
1651 my $ret = $self->provision_ad_member($prefix,
1656 $extra_member_options,
1661 open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map");
1663 !jacknomapper = \@jackthemappergroup
1664 !root = jacknomappergroup
1665 root = $dcvars->{DOMAIN}/root
1666 bob = $dcvars->{DOMAIN}/bob
1673 sub setup_simpleserver
1675 my ($self, $path) = @_;
1677 print "PROVISIONING simple server...";
1679 my $prefix_abs = abs_path($path);
1680 mkdir($prefix_abs, 0777);
1682 my $external_streams_depot="$prefix_abs/external_streams_depot";
1683 remove_tree($external_streams_depot);
1684 mkdir($external_streams_depot, 0777);
1686 my $simpleserver_options = "
1689 vfs objects = xattr_tdb streams_depot
1691 server smb encrypt = off
1694 path = $prefix_abs/share
1696 vfs objects = aio_pthread
1697 aio_pthread:aio open = yes
1698 smbd async dosmode = no
1700 [vfs_aio_pthread_async_dosmode_default1]
1701 path = $prefix_abs/share
1703 vfs objects = aio_pthread
1704 store dos attributes = yes
1705 aio_pthread:aio open = yes
1706 smbd async dosmode = yes
1708 [vfs_aio_pthread_async_dosmode_default2]
1709 path = $prefix_abs/share
1711 vfs objects = aio_pthread xattr_tdb
1712 store dos attributes = yes
1713 aio_pthread:aio open = yes
1714 smbd async dosmode = yes
1716 [async_dosmode_shadow_copy2]
1717 path = $prefix_abs/share
1719 vfs objects = shadow_copy2 xattr_tdb
1720 smbd async dosmode = yes
1723 path = $prefix_abs/share
1724 vfs objects = aio_fork
1726 vfs_aio_fork:erratic_testing_mode=yes
1729 path = $prefix_abs/share
1731 store dos attributes = yes
1732 hide files = /hidefile/
1733 hide dot files = yes
1736 path = $prefix_abs/share
1737 hide new files timeout = 5
1739 [external_streams_depot]
1740 path = $prefix_abs/share
1742 streams_depot:directory = $external_streams_depot
1745 my $vars = $self->provision(
1747 domain => "WORKGROUP",
1748 server => "LOCALSHARE4",
1749 password => "local4pass",
1750 extra_options => $simpleserver_options);
1752 $vars or return undef;
1754 if (not $self->check_or_start(
1764 sub create_file_chmod($$)
1766 my ($name, $mode) = @_;
1769 unless (open($fh, '>', $name)) {
1770 warn("Unable to open $name");
1776 sub setup_fileserver
1778 my ($self, $path, $more_conf, $server) = @_;
1779 my $prefix_abs = abs_path($path);
1780 my $srcdir_abs = abs_path($self->{srcdir});
1782 print "PROVISIONING file server ...\n";
1786 mkdir($prefix_abs, 0777);
1788 my $usershare_dir="$prefix_abs/lib/usershare";
1790 mkdir("$prefix_abs/lib", 0755);
1791 remove_tree($usershare_dir);
1792 mkdir($usershare_dir, 01770);
1794 my $share_dir="$prefix_abs/share";
1796 # Create share directory structure
1797 my $lower_case_share_dir="$share_dir/lower-case";
1798 push(@dirs, $lower_case_share_dir);
1800 my $lower_case_share_dir_30000="$share_dir/lower-case-30000";
1801 push(@dirs, $lower_case_share_dir_30000);
1803 my $dfree_share_dir="$share_dir/dfree";
1804 push(@dirs, $dfree_share_dir);
1805 push(@dirs, "$dfree_share_dir/subdir1");
1806 push(@dirs, "$dfree_share_dir/subdir2");
1807 push(@dirs, "$dfree_share_dir/subdir3");
1809 my $quotadir_dir="$share_dir/quota";
1810 push(@dirs, $quotadir_dir);
1812 my $valid_users_sharedir="$share_dir/valid_users";
1813 push(@dirs,$valid_users_sharedir);
1815 my $offline_sharedir="$share_dir/offline";
1816 push(@dirs,$offline_sharedir);
1818 my $force_user_valid_users_dir = "$share_dir/force_user_valid_users";
1819 push(@dirs, $force_user_valid_users_dir);
1821 my $tarmode_sharedir="$share_dir/tarmode";
1822 push(@dirs,$tarmode_sharedir);
1824 my $tarmode2_sharedir="$share_dir/tarmode2";
1825 push(@dirs,$tarmode2_sharedir);
1827 my $smbcacls_sharedir="$share_dir/smbcacls";
1828 push(@dirs,$smbcacls_sharedir);
1830 my $usershare_sharedir="$share_dir/usershares";
1831 push(@dirs,$usershare_sharedir);
1833 my $dropbox_sharedir="$share_dir/dropbox";
1834 push(@dirs,$dropbox_sharedir);
1836 my $bad_iconv_sharedir="$share_dir/bad_iconv";
1837 push(@dirs, $bad_iconv_sharedir);
1839 my $veto_sharedir="$share_dir/veto";
1840 push(@dirs,$veto_sharedir);
1842 my $virusfilter_sharedir="$share_dir/virusfilter";
1843 push(@dirs,$virusfilter_sharedir);
1845 my $delete_unwrite_sharedir="$share_dir/delete_unwrite";
1846 push(@dirs,$delete_unwrite_sharedir);
1847 push(@dirs, "$delete_unwrite_sharedir/delete_veto_yes");
1848 push(@dirs, "$delete_unwrite_sharedir/delete_veto_no");
1850 my $volume_serial_number_sharedir="$share_dir/volume_serial_number";
1851 push(@dirs, $volume_serial_number_sharedir);
1853 my $ip4 = Samba::get_ipv4_addr("FILESERVER");
1854 my $fileserver_options = "
1855 kernel change notify = yes
1856 spotlight backend = elasticsearch
1857 elasticsearch:address = $ip4
1858 elasticsearch:port = 8080
1859 elasticsearch:mappings = $srcdir_abs/source3/rpc_server/mdssvc/elasticsearch_mappings.json
1861 usershare path = $usershare_dir
1862 usershare max shares = 10
1863 usershare allow guests = yes
1864 usershare prefix allow list = $usershare_sharedir
1866 get quota command = $prefix_abs/getset_quota.py
1867 set quota command = $prefix_abs/getset_quota.py
1869 path = $tarmode_sharedir
1870 comment = tar test share
1871 xattr_tdb:file = $prefix_abs/tarmode-xattr.tdb
1873 path = $tarmode2_sharedir
1874 comment = tar test share
1875 xattr_tdb:file = $prefix_abs/tarmode2-xattr.tdb
1885 path = $lower_case_share_dir
1886 comment = smb username is [%U]
1887 case sensitive = True
1888 default case = lower
1890 short preserve case = no
1892 path = $lower_case_share_dir_30000
1893 comment = smb username is [%U]
1894 case sensitive = True
1895 default case = lower
1897 short preserve case = no
1899 path = $dfree_share_dir
1900 comment = smb username is [%U]
1901 dfree command = $srcdir_abs/testprogs/blackbox/dfree.sh
1902 [valid-users-access]
1903 path = $valid_users_sharedir
1904 valid users = +userdup
1906 path = $offline_sharedir
1907 vfs objects = offline
1909 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878
1910 # RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651
1911 [force_user_valid_users]
1912 path = $force_user_valid_users_dir
1913 comment = force user with valid users combination test share
1914 valid users = +force_user
1915 force user = force_user
1916 force group = everyone
1917 write list = force_user
1921 comment = ignore system acls
1922 acl_xattr:ignore system acls = yes
1925 comment = inherit owner
1929 comment = inherit only unix owner
1930 inherit owner = unix only
1931 acl_xattr:ignore system acls = yes
1932 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=13690
1935 comment = force group test
1936 # force group = everyone
1940 comment = smb username is [%U]
1942 force create mode = 0664
1943 vfs objects = dirsort
1946 path = $dropbox_sharedir
1947 comment = smb username is [%U]
1952 path = $bad_iconv_sharedir
1953 comment = smb username is [%U]
1956 [veto_files_nodelete]
1957 path = $veto_sharedir
1960 veto files = /veto_name*/
1961 delete veto files = no
1964 path = $veto_sharedir
1966 veto files = /veto_name*/
1967 delete veto files = yes
1969 [delete_veto_files_only]
1970 path = $veto_sharedir
1971 delete veto files = yes
1973 [veto_files_nohidden]
1974 path = $veto_sharedir
1978 path = $veto_sharedir
1979 veto files = /veto_name*/
1981 [delete_yes_unwrite]
1983 path = $delete_unwrite_sharedir
1984 hide unwriteable files = yes
1985 delete veto files = yes
1989 path = $delete_unwrite_sharedir
1990 hide unwriteable files = yes
1991 delete veto files = no
1994 path = $virusfilter_sharedir
1995 vfs objects = acl_xattr virusfilter
1996 virusfilter:scanner = dummy
1997 virusfilter:min file size = 0
1998 virusfilter:infected files = *infected*
1999 virusfilter:infected file action = rename
2000 virusfilter:scan on close = yes
2001 vfs_default:VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS = no
2003 [volumeserialnumber]
2004 path = $volume_serial_number_sharedir
2005 volume serial number = 0xdeadbeef
2009 vfs objects = acl_xattr
2010 acl_xattr:security_acl_name = user.hackme
2014 comment = Home directories
2019 if (defined($more_conf)) {
2020 $fileserver_options = $fileserver_options . $more_conf;
2022 if (!defined($server)) {
2023 $server = "FILESERVER";
2026 my $vars = $self->provision(
2028 domain => "WORKGROUP",
2030 password => "fileserver",
2031 extra_options => $fileserver_options,
2032 no_delete_prefix => 1);
2034 $vars or return undef;
2036 if (not $self->check_or_start(
2044 mkdir($_, 0777) foreach(@dirs);
2046 ## Create case sensitive lower case share dir
2047 foreach my $file ('a'..'z') {
2048 my $full_path = $lower_case_share_dir . '/' . $file;
2049 open my $fh, '>', $full_path;
2050 # Add some content to file
2051 print $fh $full_path;
2055 for (my $file = 1; $file < 51; ++$file) {
2056 my $full_path = $lower_case_share_dir . '/' . $file;
2057 open my $fh, '>', $full_path;
2058 # Add some content to file
2059 print $fh $full_path;
2063 # Create content for 30000 share
2064 foreach my $file ('a'..'z') {
2065 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
2066 open my $fh, '>', $full_path;
2067 # Add some content to file
2068 print $fh $full_path;
2072 for (my $file = 1; $file < 30001; ++$file) {
2073 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
2074 open my $fh, '>', $full_path;
2075 # Add some content to file
2076 print $fh $full_path;
2081 ## create a listable file in valid_users_share
2083 create_file_chmod("$valid_users_sharedir/foo", 0644) or return undef;
2086 ## create a valid utf8 filename which is invalid as a CP850 conversion
2088 create_file_chmod("$bad_iconv_sharedir/\xED\x9F\xBF", 0644) or return undef;
2091 ## create unwritable files inside inside the delete unwrite veto share dirs.
2093 unlink("$delete_unwrite_sharedir/delete_veto_yes/file_444");
2094 create_file_chmod("$delete_unwrite_sharedir/delete_veto_yes/file_444", 0444) or return undef;
2095 unlink("$delete_unwrite_sharedir/delete_veto_no/file_444");
2096 create_file_chmod("$delete_unwrite_sharedir/delete_veto_no/file_444", 0444) or return undef;
2101 sub setup_fileserver_smb1
2103 my ($self, $path) = @_;
2104 my $prefix_abs = abs_path($path);
2107 client min protocol = CORE
2108 server min protocol = LANMAN1
2109 check parent directory delete on close = yes
2112 path = $prefix_abs/share
2113 hide new files timeout = 5
2115 path = $prefix_abs/share
2117 vfs objects = aio_pthread
2118 aio_pthread:aio open = yes
2119 smbd async dosmode = no
2121 [vfs_aio_pthread_async_dosmode_default1]
2122 path = $prefix_abs/share
2124 vfs objects = aio_pthread
2125 store dos attributes = yes
2126 aio_pthread:aio open = yes
2127 smbd async dosmode = yes
2129 [vfs_aio_pthread_async_dosmode_default2]
2130 path = $prefix_abs/share
2132 vfs objects = aio_pthread xattr_tdb
2133 store dos attributes = yes
2134 aio_pthread:aio open = yes
2135 smbd async dosmode = yes
2138 path = $prefix_abs/share
2139 vfs objects = aio_fork
2141 vfs_aio_fork:erratic_testing_mode=yes
2143 return $self->setup_fileserver($path, $conf, "FILESERVERSMB1");
2146 sub setup_fileserver_smb1_done
2148 my ($self, $path, $dep_env) = @_;
2149 return $self->return_alias_env($path, $dep_env);
2154 my ($self, $prefix) = @_;
2156 # If we didn't build with ADS, pretend this env was never available
2157 if (not $self->have_ads()) {
2161 print "PROVISIONING server with security=ads...";
2163 my $ktest_options = "
2165 realm = ktest.samba.example.com
2167 server signing = required
2168 server min protocol = SMB3_00
2169 client max protocol = SMB3
2171 # This disables NTLM auth against the local SAM, which
2172 # we use can then test this setting by.
2173 ntlm auth = disabled
2175 idmap config * : backend = autorid
2176 idmap config * : range = 1000000-1999999
2177 idmap config * : rangesize = 100000
2180 my $ret = $self->provision(
2183 server => "LOCALKTEST6",
2184 password => "localktest6pass",
2185 extra_options => $ktest_options);
2187 $ret or return undef;
2190 my $prefix_abs = abs_path($prefix);
2192 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
2193 $ctx->{domain} = "KTEST";
2194 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
2195 $ctx->{dnsname} = lc($ctx->{realm});
2196 $ctx->{kdc_ipv4} = "0.0.0.0";
2197 $ctx->{kdc_ipv6} = "::";
2198 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
2199 Samba::mk_krb5_conf($ctx, "");
2201 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
2203 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
2204 #Samba4 DC with the same parameters as are being used here. The
2205 #domain SID is S-1-5-21-1071277805-689288055-3486227160
2206 $ret->{SAMSID} = "S-1-5-21-1911091480-1468226576-2729736297";
2207 $ret->{DOMSID} = "S-1-5-21-1071277805-689288055-3486227160";
2209 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
2210 chmod 0600, "$prefix/private/secrets.tdb";
2212 #Make sure there's no old ntdb file.
2213 system("rm -f $prefix/private/secrets.ntdb");
2215 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
2216 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
2218 #and having in krb5.conf:
2219 # ticket_lifetime = 799718400
2220 # renew_lifetime = 799718400
2222 # The commands for the -2 keytab where were:
2223 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
2224 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
2225 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
2226 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
2227 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
2229 # and then for the -3 keytab, I did
2231 # net changetrustpw; kdestroy and the same again.
2233 # This creates a credential cache with a very long lifetime (2036 at
2234 # at 2011-04), and shows that running 'net changetrustpw' does not
2235 # break existing logins (for the secrets.tdb method at least).
2238 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
2240 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
2241 chmod 0600, "$prefix/krb5_ccache-2";
2243 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
2244 chmod 0600, "$prefix/krb5_ccache-3";
2246 # We need world access to this share, as otherwise the domain
2247 # administrator from the AD domain provided by ktest can't
2248 # access the share for tests.
2249 chmod 0777, "$prefix/share";
2251 if (not $self->check_or_start(
2254 winbindd => "offline",
2261 sub setup_maptoguest
2263 my ($self, $path) = @_;
2264 my $prefix_abs = abs_path($path);
2265 my $libdir="$prefix_abs/lib";
2266 my $share_dir="$prefix_abs/share";
2267 my $errorinjectconf="$libdir/error_inject.conf";
2269 print "PROVISIONING maptoguest...";
2273 map to guest = bad user
2275 server min protocol = LANMAN1
2277 [force_user_error_inject]
2279 vfs objects = acl_xattr fake_acls xattr_tdb error_inject
2281 include = $errorinjectconf
2284 my $vars = $self->provision(
2286 domain => "WORKGROUP",
2287 server => "maptoguest",
2288 password => "maptoguestpass",
2289 extra_options => $options);
2291 $vars or return undef;
2293 if (not $self->check_or_start(
2304 sub stop_sig_term($$) {
2305 my ($self, $pid) = @_;
2306 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
2309 sub stop_sig_kill($$) {
2310 my ($self, $pid) = @_;
2311 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
2316 my ($env_vars, $app, $pid) = @_;
2318 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
2325 my ($env_vars, $app) = @_;
2327 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
2333 # builds up the cmd args to run an s3 binary (i.e. smbd, nmbd, etc)
2336 my ($self, $binary, $env_vars, $options, $valgrind, $dont_log_stdout) = @_;
2339 if (defined($options)) {
2340 @optargs = split(/ /, $options);
2342 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
2344 if (defined($valgrind)) {
2345 @preargs = split(/ /, $valgrind);
2347 my @args = ("-F", "--no-process-group",
2348 "--configfile=$env_vars->{SERVERCONFFILE}",
2349 "-l", $env_vars->{LOGDIR});
2351 if (not defined($dont_log_stdout)) {
2352 push(@args, "--debug-stdout");
2354 return (@preargs, $binary, @args, @optargs);
2357 sub check_or_start($$) {
2358 my ($self, %args) = @_;
2359 my $env_vars = $args{env_vars};
2360 my $nmbd = $args{nmbd} // "no";
2361 my $winbindd = $args{winbindd} // "no";
2362 my $smbd = $args{smbd} // "no";
2363 my $samba_dcerpcd = $args{samba_dcerpcd} // "no";
2364 my $child_cleanup = $args{child_cleanup};
2368 # use a pipe for stdin in the child processes. This allows
2369 # those processes to monitor the pipe for EOF to ensure they
2370 # exit when the test script exits
2371 pipe($STDIN_READER, $env_vars->{STDIN_PIPE});
2373 my $binary = Samba::bindir_path($self, "samba-dcerpcd");
2374 my @full_cmd = $self->make_bin_cmd(
2377 $ENV{SAMBA_DCERPCD_OPTIONS},
2378 $ENV{SAMBA_DCERPCD_VALGRIND},
2379 $ENV{SAMBA_DCERPCD_DONT_LOG_STDOUT});
2380 push(@full_cmd, '--libexec-rpcds');
2382 my $samba_dcerpcd_envs = Samba::get_env_for_process(
2383 "samba_dcerpcd", $env_vars);
2385 # fork and exec() samba_dcerpcd in the child process
2387 NAME => "samba_dcerpcd",
2388 BINARY_PATH => $binary,
2389 FULL_CMD => [ @full_cmd ],
2390 LOG_FILE => $env_vars->{SAMBA_DCERPCD_TEST_LOG},
2391 PCAP_FILE => "env-$ENV{ENVNAME}-samba_dcerpcd",
2392 ENV_VARS => $samba_dcerpcd_envs,
2394 if ($samba_dcerpcd ne "yes") {
2395 $daemon_ctx->{SKIP_DAEMON} = 1;
2398 my $pid = Samba::fork_and_exec(
2399 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
2401 $env_vars->{SAMBA_DCERPCD_TL_PID} = $pid;
2402 write_pid($env_vars, "samba_dcerpcd", $pid);
2404 $binary = Samba::bindir_path($self, "nmbd");
2405 @full_cmd = $self->make_bin_cmd($binary, $env_vars,
2406 $ENV{NMBD_OPTIONS}, $ENV{NMBD_VALGRIND},
2407 $ENV{NMBD_DONT_LOG_STDOUT});
2408 my $nmbd_envs = Samba::get_env_for_process("nmbd", $env_vars);
2409 delete $nmbd_envs->{RESOLV_WRAPPER_CONF};
2410 delete $nmbd_envs->{RESOLV_WRAPPER_HOSTS};
2412 # fork and exec() nmbd in the child process
2415 BINARY_PATH => $binary,
2416 FULL_CMD => [ @full_cmd ],
2417 LOG_FILE => $env_vars->{NMBD_TEST_LOG},
2418 PCAP_FILE => "env-$ENV{ENVNAME}-nmbd",
2419 ENV_VARS => $nmbd_envs,
2421 if ($nmbd ne "yes") {
2422 $daemon_ctx->{SKIP_DAEMON} = 1;
2424 $pid = Samba::fork_and_exec(
2425 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
2427 $env_vars->{NMBD_TL_PID} = $pid;
2428 write_pid($env_vars, "nmbd", $pid);
2430 $binary = Samba::bindir_path($self, "winbindd");
2431 @full_cmd = $self->make_bin_cmd($binary, $env_vars,
2432 $ENV{WINBINDD_OPTIONS},
2433 $ENV{WINBINDD_VALGRIND},
2434 $ENV{WINBINDD_DONT_LOG_STDOUT});
2436 # fork and exec() winbindd in the child process
2439 BINARY_PATH => $binary,
2440 FULL_CMD => [ @full_cmd ],
2441 LOG_FILE => $env_vars->{WINBINDD_TEST_LOG},
2442 PCAP_FILE => "env-$ENV{ENVNAME}-winbindd",
2444 if ($winbindd ne "yes" and $winbindd ne "offline") {
2445 $daemon_ctx->{SKIP_DAEMON} = 1;
2448 $pid = Samba::fork_and_exec(
2449 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
2451 $env_vars->{WINBINDD_TL_PID} = $pid;
2452 write_pid($env_vars, "winbindd", $pid);
2454 $binary = Samba::bindir_path($self, "smbd");
2455 @full_cmd = $self->make_bin_cmd($binary, $env_vars,
2456 $ENV{SMBD_OPTIONS}, $ENV{SMBD_VALGRIND},
2457 $ENV{SMBD_DONT_LOG_STDOUT});
2459 # fork and exec() smbd in the child process
2462 BINARY_PATH => $binary,
2463 FULL_CMD => [ @full_cmd ],
2464 LOG_FILE => $env_vars->{SMBD_TEST_LOG},
2465 PCAP_FILE => "env-$ENV{ENVNAME}-smbd",
2467 if ($smbd ne "yes") {
2468 $daemon_ctx->{SKIP_DAEMON} = 1;
2471 $pid = Samba::fork_and_exec(
2472 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
2474 $env_vars->{SMBD_TL_PID} = $pid;
2475 write_pid($env_vars, "smbd", $pid);
2477 # close the parent's read-end of the pipe
2478 close($STDIN_READER);
2480 return $self->wait_for_start($env_vars,
2487 sub createuser($$$$$)
2489 my ($self, $username, $password, $conffile, $env) = @_;
2490 my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $username > /dev/null";
2493 while(my($var, $val) = each %$env) {
2494 $cmd = "$var=\"$val\" $cmd";
2497 unless (open(PWD, "|$cmd")) {
2498 warn("Unable to set password for $username account\n$cmd");
2501 print PWD "$password\n$password\n";
2502 unless (close(PWD)) {
2503 warn("Unable to set password for $username account\n$cmd");
2510 my ($self, %args) = @_;
2512 my $prefix = $args{prefix};
2513 my $domain = $args{domain};
2514 my $realm = $args{realm};
2515 my $server = $args{server};
2516 my $password = $args{password};
2517 my $extra_options = $args{extra_options};
2518 my $resolv_conf = $args{resolv_conf};
2519 my $no_delete_prefix= $args{no_delete_prefix};
2520 my $netbios_name = $args{netbios_name} // $server;
2521 my $server_log_level = $ENV{SERVER_LOG_LEVEL} || 1;
2524 ## setup the various environment variables we need
2527 my $samsid = Samba::random_domain_sid();
2528 my $swiface = Samba::get_interface($server);
2530 my %createuser_env = ();
2531 my $server_ip = Samba::get_ipv4_addr($server);
2532 my $server_ipv6 = Samba::get_ipv6_addr($server);
2534 if (defined($realm)) {
2535 $dns_domain = lc($realm);
2537 $dns_domain = "samba.example.com";
2540 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
2543 my $unix_gids_str = $);
2544 my @unix_gids = split(" ", $unix_gids_str);
2546 my $prefix_abs = abs_path($prefix);
2547 my $bindir_abs = abs_path($self->{bindir});
2551 my $shrdir=$args{share_dir} // "$prefix_abs/share";
2552 push(@dirs,$shrdir);
2554 my $libdir="$prefix_abs/lib";
2555 push(@dirs,$libdir);
2557 my $piddir="$prefix_abs/pid";
2558 push(@dirs,$piddir);
2560 my $privatedir="$prefix_abs/private";
2561 push(@dirs,$privatedir);
2563 my $cachedir = "$prefix_abs/cachedir";
2564 push(@dirs, $cachedir);
2566 my $binddnsdir = "$prefix_abs/bind-dns";
2567 push(@dirs, $binddnsdir);
2569 my $lockdir="$prefix_abs/lockdir";
2570 push(@dirs,$lockdir);
2572 my $eventlogdir="$prefix_abs/lockdir/eventlog";
2573 push(@dirs,$eventlogdir);
2575 my $logdir="$prefix_abs/logs";
2576 push(@dirs,$logdir);
2578 my $driver32dir="$shrdir/W32X86";
2579 push(@dirs,$driver32dir);
2581 my $driver64dir="$shrdir/x64";
2582 push(@dirs,$driver64dir);
2584 my $driver40dir="$shrdir/WIN40";
2585 push(@dirs,$driver40dir);
2587 my $ro_shrdir="$shrdir/root-tmp";
2588 push(@dirs,$ro_shrdir);
2590 my $noperm_shrdir="$shrdir/noperm-tmp";
2591 push(@dirs,$noperm_shrdir);
2593 my $msdfs_shrdir="$shrdir/msdfsshare";
2594 push(@dirs,$msdfs_shrdir);
2596 my $msdfs_shrdir2="$shrdir/msdfsshare2";
2597 push(@dirs,$msdfs_shrdir2);
2599 my $msdfs_pathname_share="$shrdir/msdfs_pathname_share";
2600 push(@dirs,$msdfs_pathname_share);
2602 my $non_msdfs_pathname_share="$shrdir/non_msdfs_pathname_share";
2603 push(@dirs,$non_msdfs_pathname_share);
2605 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
2606 push(@dirs,$msdfs_deeppath);
2608 my $smbcacls_sharedir_dfs="$shrdir/smbcacls_sharedir_dfs";
2609 push(@dirs,$smbcacls_sharedir_dfs);
2611 my $smbcacls_share="$shrdir/smbcacls_share";
2612 push(@dirs,$smbcacls_share);
2614 my $smbcacls_share_testdir="$shrdir/smbcacls_share/smbcacls";
2615 push(@dirs,$smbcacls_share_testdir);
2617 my $badnames_shrdir="$shrdir/badnames";
2618 push(@dirs,$badnames_shrdir);
2620 my $lease1_shrdir="$shrdir/dynamic";
2621 push(@dirs,$lease1_shrdir);
2623 my $manglenames_shrdir="$shrdir/manglenames";
2624 push(@dirs,$manglenames_shrdir);
2626 my $widelinks_shrdir="$shrdir/widelinks";
2627 push(@dirs,$widelinks_shrdir);
2629 my $widelinks_linkdir="$shrdir/widelinks_foo";
2630 push(@dirs,$widelinks_linkdir);
2632 my $fsrvp_shrdir="$shrdir/fsrvp";
2633 push(@dirs,$fsrvp_shrdir);
2635 my $shadow_tstdir="$shrdir/shadow";
2636 push(@dirs,$shadow_tstdir);
2637 my $shadow_mntdir="$shadow_tstdir/mount";
2638 push(@dirs,$shadow_mntdir);
2639 my $shadow_basedir="$shadow_mntdir/base";
2640 push(@dirs,$shadow_basedir);
2641 my $shadow_shrdir="$shadow_basedir/share";
2642 push(@dirs,$shadow_shrdir);
2644 my $nosymlinks_shrdir="$shrdir/nosymlinks";
2645 push(@dirs,$nosymlinks_shrdir);
2647 my $local_symlinks_shrdir="$shrdir/local_symlinks";
2648 push(@dirs,$local_symlinks_shrdir);
2650 my $fruit_resource_stream_shrdir="$shrdir/fruit_resource_stream";
2651 push(@dirs,$fruit_resource_stream_shrdir);
2653 my $smbget_sharedir="$shrdir/smbget";
2654 push(@dirs, $smbget_sharedir);
2656 # this gets autocreated by winbindd
2657 my $wbsockdir="$prefix_abs/wbsock";
2659 my $nmbdsockdir="$prefix_abs/nmbd";
2660 unlink($nmbdsockdir);
2663 ## create the test directory layout
2665 die ("prefix_abs = ''") if $prefix_abs eq "";
2666 die ("prefix_abs = '/'") if $prefix_abs eq "/";
2668 mkdir($prefix_abs, 0777);
2669 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
2670 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
2671 system("rm -rf $prefix_abs/*");
2673 mkdir($_, 0777) foreach(@dirs);
2675 my $fs_specific_conf = $self->get_fs_specific_conf($shrdir);
2678 ## lockdir and piddir must be 0755
2680 chmod 0755, $lockdir;
2681 chmod 0755, $piddir;
2685 ## Create a directory without permissions to enter
2687 chmod 0000, $noperm_shrdir;
2690 ## create ro and msdfs share layout
2693 chmod 0755, $ro_shrdir;
2695 create_file_chmod("$ro_shrdir/readable_file", 0644) or return undef;
2696 create_file_chmod("$ro_shrdir/unreadable_file", 0600) or return undef;
2698 create_file_chmod("$ro_shrdir/msdfs-target", 0600) or return undef;
2699 symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp",
2700 "$msdfs_shrdir/msdfs-src1";
2701 symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
2702 symlink "msdfs:$server_ip\\smbcacls_sharedir_dfs,$server_ipv6\\smbcacls_sharedir_dfs",
2703 "$msdfs_shrdir/smbcacls_sharedir_dfs";
2705 symlink "msdfs:$server_ip\\msdfs-share2,$server_ipv6\\msdfs-share2", "$msdfs_shrdir/dfshop1";
2706 symlink "msdfs:$server_ip\\tmp,$server_ipv6\\tmp", "$msdfs_shrdir2/dfshop2";
2708 ## create bad names in $badnames_shrdir
2710 ## (An invalid name, would be mangled to 8.3).
2711 create_file_chmod("$badnames_shrdir/\340|\231\216\377\177",
2712 0600) or return undef;
2714 ## (A bad name, would not be mangled to 8.3).
2715 create_file_chmod("$badnames_shrdir/\240\276\346\327\377\177",
2716 0666) or return undef;
2718 ## (A bad good name).
2719 create_file_chmod("$badnames_shrdir/blank.txt",
2720 0666) or return undef;
2723 ## create mangleable directory names in $manglenames_shrdir
2725 my $manglename_target = "$manglenames_shrdir/foo:bar";
2726 mkdir($manglename_target, 0777);
2729 ## create symlinks for widelinks tests.
2731 my $widelinks_target = "$widelinks_linkdir/target";
2732 create_file_chmod("$widelinks_target", 0666) or return undef;
2735 ## This link should get an error
2737 symlink "$widelinks_target", "$widelinks_shrdir/source";
2739 ## This link should be allowed
2741 symlink "$widelinks_shrdir", "$widelinks_shrdir/dot";
2743 my $conffile="$libdir/server.conf";
2744 my $dfqconffile="$libdir/dfq.conf";
2745 my $errorinjectconf="$libdir/error_inject.conf";
2746 my $delayinjectconf="$libdir/delay_inject.conf";
2747 my $globalinjectconf="$libdir/global_inject.conf";
2748 my $aliceconfdir="$libdir";
2749 my $aliceconffile="$libdir/alice.conf";
2751 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/third_party/nss_wrapper/nss_wrapper.pl";
2752 my $nss_wrapper_passwd = "$privatedir/passwd";
2753 my $nss_wrapper_group = "$privatedir/group";
2754 my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts";
2755 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
2757 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
2759 my $fake_snap_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/fake_snap.pl";
2761 my @eventlog_list = ("dns server", "application");
2764 ## calculate uids and gids
2767 my ($max_uid, $max_gid);
2768 my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
2769 my ($uid_pdbtest_wkn);
2771 my ($uid_force_user);
2772 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
2773 my ($gid_userdup, $gid_everyone);
2774 my ($gid_force_user);
2775 my ($gid_jackthemapper);
2776 my ($gid_jacknomapper);
2781 my ($uid_slashuser);
2783 my ($uid_localjane);
2784 my ($uid_localjackthemapper);
2785 my ($uid_localjacknomapper);
2787 if ($unix_uid < 0xffff - 13) {
2790 $max_uid = $unix_uid;
2793 $uid_root = $max_uid - 1;
2794 $uid_nobody = $max_uid - 2;
2795 $uid_pdbtest = $max_uid - 3;
2796 $uid_pdbtest2 = $max_uid - 4;
2797 $uid_userdup = $max_uid - 5;
2798 $uid_pdbtest_wkn = $max_uid - 6;
2799 $uid_force_user = $max_uid - 7;
2800 $uid_smbget = $max_uid - 8;
2801 $uid_user1 = $max_uid - 9;
2802 $uid_user2 = $max_uid - 10;
2803 $uid_gooduser = $max_uid - 11;
2804 $uid_eviluser = $max_uid - 12;
2805 $uid_slashuser = $max_uid - 13;
2806 $uid_localbob = $max_uid - 14;
2807 $uid_localjane = $max_uid - 15;
2808 $uid_localjackthemapper = $max_uid - 16;
2809 $uid_localjacknomapper = $max_uid - 17;
2811 if ($unix_gids[0] < 0xffff - 8) {
2814 $max_gid = $unix_gids[0];
2817 $gid_nobody = $max_gid - 1;
2818 $gid_nogroup = $max_gid - 2;
2819 $gid_root = $max_gid - 3;
2820 $gid_domusers = $max_gid - 4;
2821 $gid_domadmins = $max_gid - 5;
2822 $gid_userdup = $max_gid - 6;
2823 $gid_everyone = $max_gid - 7;
2824 $gid_force_user = $max_gid - 8;
2825 $gid_jackthemapper = $max_gid - 9;
2826 $gid_jacknomapper = $max_gid - 10;
2832 unless (open(CONF, ">$conffile")) {
2833 warn("Unable to open $conffile");
2837 my $interfaces = Samba::get_interfaces_config($server);
2841 dcesrv:fuzz directory = $cachedir/fuzz
2842 netbios name = $netbios_name
2843 interfaces = $interfaces
2844 bind interfaces only = yes
2845 panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
2846 smbd:suicide mode = yes
2847 smbd:FSCTL_SMBTORTURE = yes
2848 smbd:validate_oplock_types = yes
2850 client min protocol = SMB2_02
2851 server min protocol = SMB2_02
2853 server multi channel support = yes
2857 private dir = $privatedir
2858 binddns dir = $binddnsdir
2859 pid directory = $piddir
2860 lock directory = $lockdir
2861 log file = $logdir/log.\%m
2862 log level = $server_log_level
2863 winbind debug traceid = yes
2867 debug syslog format = always
2868 debug hires timestamp = yes
2870 state directory = $lockdir
2871 cache directory = $lockdir
2873 passdb backend = tdbsam
2877 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
2878 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
2879 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
2880 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
2881 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
2882 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
2883 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
2885 addprinter command = $mod_printer_pl -a -s $conffile --
2886 deleteprinter command = $mod_printer_pl -d -s $conffile --
2888 eventlog list = application \"dns server\"
2891 kernel change notify = no
2895 printcap name = /dev/null
2897 winbindd socket directory = $wbsockdir
2898 nmbd:socket dir = $nmbdsockdir
2899 idmap config * : range = 100000-200000
2900 winbind enum users = yes
2901 winbind enum groups = yes
2902 winbind separator = /
2903 include system krb5 conf = no
2905 # min receivefile size = 4000
2909 smbd:sharedelay = 100000
2910 smbd:writetimeupdatedelay = 500000
2914 store dos attributes = yes
2920 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot time_audit full_audit
2922 full_audit:syslog = no
2923 full_audit:success = none
2924 full_audit:failure = none
2927 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
2928 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
2929 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
2930 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
2931 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
2932 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
2933 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
2935 print notify backchannel = yes
2937 ncalrpc dir = $prefix_abs/ncalrpc
2939 # The samba3.blackbox.smbclient_s3 test uses this to test that
2940 # sending messages works, and that the %m sub works.
2941 message command = mv %s $shrdir/message.%m
2943 # fsrvp server requires registry shares
2944 registry shares = yes
2946 # Used by RPC SRVSVC tests
2947 add share command = $bindir_abs/smbaddshare
2948 change share command = $bindir_abs/smbchangeshare
2949 delete share command = $bindir_abs/smbdeleteshare
2951 # fruit:copyfile is a global option
2952 fruit:copyfile = yes
2954 #this does not mean that we use non-secure test env,
2955 #it just means we ALLOW one to be configured.
2956 allow insecure wide links = yes
2958 include = $globalinjectconf
2960 # Begin extra options
2964 #Include user defined custom parameters if set
2967 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
2968 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
2973 path = $smbcacls_share
2974 comment = smb username is [%U]
2977 [smbcacls_sharedir_dfs]
2978 path = $smbcacls_sharedir_dfs
2979 comment = smb username is [%U]
2982 comment = smb username is [%U]
2985 comment = Load dirsort module
2986 vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot
2989 comment = encrypt smb username is [%U]
2990 server smb encrypt = required
2991 vfs objects = dirsort
3001 force user = $unix_name
3003 [forceuser_unixonly]
3004 comment = force a user with unix user SID and group SID
3006 force user = pdbtest
3008 [forceuser_wkngroup]
3009 comment = force a user with well-known group SID
3011 force user = pdbtest_wkn
3015 force group = nogroup
3021 path = $noperm_shrdir
3027 write list = $unix_name
3030 valid users = $unix_name
3031 access based share enum = yes
3033 path = $msdfs_shrdir
3035 msdfs shuffle referrals = yes
3038 path = $msdfs_shrdir
3043 path = $msdfs_shrdir2
3046 [msdfs-pathname-share]
3047 path = $msdfs_pathname_share
3050 [non-msdfs-pathname-share]
3051 path = $non_msdfs_pathname_share
3056 hide unreadable = yes
3059 case sensitive = yes
3062 hide unwriteable files = yes
3065 kernel share modes = no
3079 default devmode = no
3083 print command = $self->{srcdir}/source3/script/tests/printing/printing_var_exp_lpr_cmd.sh \"Windows user: %U\" \"UNIX user: %u\" \"Domain: %D\"
3090 comment = smb username is [%U]
3092 nfs4acl_xattr:version = 40
3093 vfs objects = nfs4acl_xattr xattr_tdb
3095 [nfs4acl_special_40]
3097 comment = smb username is [%U]
3099 nfs4acl_xattr:version = 40
3100 vfs objects = nfs4acl_xattr xattr_tdb
3104 comment = smb username is [%U]
3106 vfs objects = nfs4acl_xattr xattr_tdb
3110 comment = smb username is [%U]
3111 vfs objects = nfs4acl_xattr xattr_tdb
3113 nfs4acl_xattr:encoding = xdr
3114 nfs4acl_xattr:version = 40
3118 comment = smb username is [%U]
3119 vfs objects = nfs4acl_xattr xattr_tdb
3121 nfs4acl_xattr:encoding = xdr
3122 nfs4acl_xattr:version = 41
3126 comment = smb username is [%U]
3127 vfs objects = nfs4acl_xattr xattr_tdb
3129 nfs4acl_xattr:encoding = nfs
3130 nfs4acl_xattr:version = 40
3131 nfs4acl_xattr:xattr_name = security.nfs4acl_xdr
3135 comment = smb username is [%U]
3136 vfs objects = nfs4acl_xattr xattr_tdb
3138 nfs4acl_xattr:encoding = nfs
3139 nfs4acl_xattr:version = 41
3140 nfs4acl_xattr:xattr_name = security.nfs4acl_xdr
3144 comment = smb username is [%U]
3146 force create mode = 777
3149 comment = smb username is [%U]
3151 force create mode = 0
3152 directory mask = 0777
3153 force directory mode = 0
3154 vfs objects = xattr_tdb streams_depot
3156 vfs objects = fake_acls xattr_tdb streams_depot time_audit full_audit
3158 directory mask = 07777
3173 vfs objects = catia fruit streams_xattr acl_xattr xattr_tdb
3174 fruit:resource = file
3175 fruit:metadata = netatalk
3176 fruit:locking = netatalk
3177 fruit:encoding = native
3178 fruit:veto_appledouble = no
3182 # This is used by vfs.fruit tests that require real fs xattr
3183 vfs objects = catia fruit streams_xattr acl_xattr
3184 fruit:resource = file
3185 fruit:metadata = netatalk
3186 fruit:locking = netatalk
3187 fruit:encoding = native
3188 fruit:veto_appledouble = no
3190 [vfs_fruit_metadata_stream]
3192 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3193 fruit:resource = file
3194 fruit:metadata = stream
3195 fruit:veto_appledouble = no
3197 [vfs_fruit_stream_depot]
3199 vfs objects = fruit streams_depot acl_xattr xattr_tdb
3200 fruit:resource = stream
3201 fruit:metadata = stream
3202 fruit:veto_appledouble = no
3206 vfs objects = streams_xattr acl_xattr xattr_tdb
3208 [vfs_wo_fruit_stream_depot]
3210 vfs objects = streams_depot acl_xattr xattr_tdb
3212 [vfs_fruit_timemachine]
3214 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3215 fruit:resource = file
3216 fruit:metadata = stream
3217 fruit:time machine = yes
3218 fruit:time machine max size = 32K
3220 [vfs_fruit_wipe_intentionally_left_blank_rfork]
3222 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3223 fruit:resource = file
3224 fruit:metadata = stream
3225 fruit:wipe_intentionally_left_blank_rfork = true
3226 fruit:delete_empty_adfiles = false
3227 fruit:veto_appledouble = no
3229 [vfs_fruit_delete_empty_adfiles]
3231 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3232 fruit:resource = file
3233 fruit:metadata = stream
3234 fruit:wipe_intentionally_left_blank_rfork = true
3235 fruit:delete_empty_adfiles = true
3236 fruit:veto_appledouble = no
3238 [vfs_fruit_zero_fileid]
3240 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3241 fruit:resource = file
3242 fruit:metadata = stream
3243 fruit:zero_file_id=yes
3245 [fruit_resource_stream]
3246 path = $fruit_resource_stream_shrdir
3247 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3248 fruit:resource = stream
3249 fruit:metadata = stream
3252 path = $badnames_shrdir
3256 path = $manglenames_shrdir
3260 path = $shrdir/dynamic/%t
3262 root preexec = mkdir %P
3265 path = $widelinks_shrdir
3270 path = $fsrvp_shrdir
3271 comment = fake snapshots using rsync
3272 vfs objects = shell_snap shadow_copy2
3273 shell_snap:check path command = $fake_snap_pl --check
3274 shell_snap:create command = $fake_snap_pl --create
3275 shell_snap:delete command = $fake_snap_pl --delete
3276 # a relative path here fails, the snapshot dir is no longer found
3277 shadow:snapdir = $fsrvp_shrdir/.snapshots
3280 path = $shadow_shrdir
3281 comment = previous versions snapshots under mount point
3282 vfs objects = shadow_copy2
3283 shadow:mountpoint = $shadow_mntdir
3286 path = $shadow_shrdir
3287 comment = previous versions snapshots outside mount point
3288 vfs objects = shadow_copy2
3289 shadow:mountpoint = $shadow_mntdir
3290 shadow:snapdir = $shadow_tstdir/.snapshots
3293 path = $shadow_shrdir
3294 comment = previous versions with subvolume snapshots, snapshots under base dir
3295 vfs objects = shadow_copy2
3296 shadow:mountpoint = $shadow_mntdir
3297 shadow:basedir = $shadow_basedir
3298 shadow:snapdir = $shadow_basedir/.snapshots
3301 path = $shadow_shrdir
3302 comment = previous versions with subvolume snapshots, snapshots outside mount point
3303 vfs objects = shadow_copy2
3304 shadow:mountpoint = $shadow_mntdir
3305 shadow:basedir = $shadow_basedir
3306 shadow:snapdir = $shadow_tstdir/.snapshots
3309 path = $shadow_shrdir
3310 comment = previous versions at volume root snapshots under mount point
3311 vfs objects = shadow_copy2
3312 shadow:mountpoint = $shadow_shrdir
3315 path = $shadow_shrdir
3316 comment = previous versions at volume root snapshots outside mount point
3317 vfs objects = shadow_copy2
3318 shadow:mountpoint = $shadow_shrdir
3319 shadow:snapdir = $shadow_tstdir/.snapshots
3322 path = $shadow_shrdir
3323 comment = previous versions snapshots everywhere
3324 vfs objects = shadow_copy2
3325 shadow:mountpoint = $shadow_mntdir
3326 shadow:snapdirseverywhere = yes
3329 path = $shadow_shrdir
3330 comment = previous versions using snapsharepath
3331 vfs objects = shadow_copy2
3332 shadow:mountpoint = $shadow_mntdir
3333 shadow:snapdir = $shadow_tstdir/.snapshots
3334 shadow:snapsharepath = share
3337 comment = Testing shadow:format with default option
3338 vfs object = shadow_copy2
3339 path = $shadow_shrdir
3342 shadow:mountpoint = $shadow_mntdir
3343 shadow:basedir = $shadow_basedir
3344 shadow:snapdir = $shadow_basedir/.snapshots
3345 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
3348 comment = Testing shadow:format with only date component
3349 vfs object = shadow_copy2
3350 path = $shadow_shrdir
3353 shadow:mountpoint = $shadow_mntdir
3354 shadow:basedir = $shadow_basedir
3355 shadow:snapdir = $shadow_basedir/.snapshots
3356 shadow:format = \@GMT-%Y-%m-%d
3359 comment = Testing shadow:format with some hardcoded prefix
3360 vfs object = shadow_copy2
3361 path = $shadow_shrdir
3364 shadow:mountpoint = $shadow_mntdir
3365 shadow:basedir = $shadow_basedir
3366 shadow:snapdir = $shadow_basedir/.snapshots
3367 shadow:format = snap\@GMT-%Y.%m.%d-%H.%M.%S
3370 comment = Testing shadow:format with modified format
3371 vfs object = shadow_copy2
3372 path = $shadow_shrdir
3375 shadow:mountpoint = $shadow_mntdir
3376 shadow:basedir = $shadow_basedir
3377 shadow:snapdir = $shadow_basedir/.snapshots
3378 shadow:format = \@GMT-%Y.%m.%d-%H_%M_%S-snap
3381 comment = Testing shadow:snapprefix regex
3382 vfs object = shadow_copy2
3383 path = $shadow_shrdir
3386 shadow:mountpoint = $shadow_mntdir
3387 shadow:basedir = $shadow_basedir
3388 shadow:snapdir = $shadow_basedir/.snapshots
3389 shadow:snapprefix = \^s[a-z]*p\$
3390 shadow:format = _GMT-%Y.%m.%d-%H.%M.%S
3393 comment = Testing shadow:snapprefix with delim regex
3394 vfs object = shadow_copy2
3395 path = $shadow_shrdir
3398 shadow:mountpoint = $shadow_mntdir
3399 shadow:basedir = $shadow_basedir
3400 shadow:snapdir = $shadow_basedir/.snapshots
3401 shadow:delimiter = \@GMT
3402 shadow:snapprefix = [a-z]*
3403 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
3406 path = $shadow_shrdir
3407 comment = previous versions with wide links allowed
3408 vfs objects = shadow_copy2
3409 shadow:mountpoint = $shadow_mntdir
3413 path = $shadow_tstdir
3414 comment = previous versions snapshots under mount point
3415 vfs objects = shadow_copy2 streams_xattr error_inject
3417 error_inject:pwrite = EBADF
3418 shadow:mountpoint = $shadow_tstdir
3419 shadow:fixinodes = yes
3420 smbd async dosmode = yes
3423 path = $shadow_shrdir
3424 comment = previous versions with streams_depot
3425 vfs objects = streams_depot shadow_copy2
3428 path = $shrdir/dfree
3429 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
3430 admin users = $unix_name
3431 include = $dfqconffile
3433 path = $shrdir/dfree
3434 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
3435 admin users = $unix_name
3436 include = $dfqconffile
3437 dfree cache time = 60
3439 path = $shrdir/dfree
3440 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
3442 include = $dfqconffile
3444 path = $shrdir/quota
3445 admin users = $unix_name
3447 [acl_xattr_ign_sysacl_posix]
3449 acl_xattr:ignore system acls = yes
3450 acl_xattr:default acl style = posix
3451 [acl_xattr_ign_sysacl_windows]
3453 acl_xattr:ignore system acls = yes
3454 acl_xattr:default acl style = windows
3458 mangled names = illegal
3462 path = $nosymlinks_shrdir
3463 follow symlinks = no
3464 [nosymlinks_smb1allow]
3466 follow symlinks = yes
3470 path = $local_symlinks_shrdir
3471 follow symlinks = yes
3475 kernel oplocks = yes
3476 vfs objects = streams_xattr xattr_tdb
3480 vfs objects = streams_xattr xattr_tdb
3482 [streams_xattr_nostrict]
3485 vfs objects = streams_xattr xattr_tdb
3489 vfs objects = acl_xattr streams_xattr fake_acls xattr_tdb
3490 acl_xattr:ignore system acls = yes
3491 acl_xattr:security_acl_name = user.acl
3492 xattr_tdb:ignore_user_xattr = yes
3496 smbd:find async delay usec = 10000
3499 vfs objects = error_inject
3500 include = $errorinjectconf
3504 vfs objects = delay_inject
3505 kernel share modes = no
3508 include = $delayinjectconf
3512 vfs objects = delay_inject
3513 delay_inject:pread_send = 2000
3514 delay_inject:pwrite_send = 2000
3518 vfs objects = delay_inject
3519 delay_inject:brl_lock_windows = 90
3520 delay_inject:brl_lock_windows_use_timer = yes
3524 vfs objects = delay_inject
3525 delay_inject:brl_lock_windows = 90
3526 delay_inject:brl_lock_windows_use_timer = no
3529 path = $prefix_abs/share
3530 delete readonly = yes
3533 path = $prefix_abs/share
3535 server smb encrypt = desired
3538 path = $prefix_abs/share
3540 server smb encrypt = off
3544 honor change notify privilege = yes
3546 [acls_non_canonical]
3548 acl flag inherited canonicalization = no
3550 [full_audit_success_bad_name]
3552 full_audit:success = badname
3554 [full_audit_fail_bad_name]
3556 full_audit:failure = badname
3560 server addresses = $server_ipv6
3563 path = $smbget_sharedir
3564 comment = smb username is [%U]
3567 include = $aliceconfdir/%U.conf
3572 my $net = Samba::bindir_path($self, "net");
3574 $cmd .= "UID_WRAPPER_ROOT=1 ";
3575 $cmd .= "SMB_CONF_PATH=\"$conffile\" ";
3576 $cmd .= "$net setlocalsid $samsid";
3578 my $net_ret = system($cmd);
3579 if ($net_ret != 0) {
3580 warn("net setlocalsid failed: $net_ret\n$cmd");
3584 unless (open(ERRORCONF, ">$errorinjectconf")) {
3585 warn("Unable to open $errorinjectconf");
3590 unless (open(DELAYCONF, ">$delayinjectconf")) {
3591 warn("Unable to open $delayinjectconf");
3596 unless (open(DFQCONF, ">$dfqconffile")) {
3597 warn("Unable to open $dfqconffile");
3602 unless (open(DELAYCONF, ">$globalinjectconf")) {
3603 warn("Unable to open $globalinjectconf");
3608 unless (open(ALICECONF, ">$aliceconffile")) {
3609 warn("Unable to open $aliceconffile");
3616 comment = smb username is [%U]
3622 ## create a test account
3625 unless (open(PASSWD, ">$nss_wrapper_passwd")) {
3626 warn("Unable to open $nss_wrapper_passwd");
3629 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
3630 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
3631 pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
3632 pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
3633 userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
3634 pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false
3635 force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false
3636 smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false
3637 user1:x:$uid_user1:$gid_nogroup:user1 gecos:$prefix_abs:/bin/false
3638 user2:x:$uid_user2:$gid_nogroup:user2 gecos:$prefix_abs:/bin/false
3639 gooduser:x:$uid_gooduser:$gid_domusers:gooduser gecos:$prefix_abs:/bin/false
3640 eviluser:x:$uid_eviluser:$gid_domusers:eviluser gecos::/bin/false
3641 slashuser:x:$uid_slashuser:$gid_domusers:slashuser gecos:/:/bin/false
3642 bob:x:$uid_localbob:$gid_domusers:localbob gecos:/:/bin/false
3643 jane:x:$uid_localjane:$gid_domusers:localjane gecos:/:/bin/false
3644 jackthemapper:x:$uid_localjackthemapper:$gid_domusers:localjackthemaper gecos:/:/bin/false
3645 jacknomapper:x:$uid_localjacknomapper:$gid_domusers:localjacknomaper gecos:/:/bin/false
3647 if ($unix_uid != 0) {
3648 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
3653 unless (open(GROUP, ">$nss_wrapper_group")) {
3654 warn("Unable to open $nss_wrapper_group");
3657 print GROUP "nobody:x:$gid_nobody:
3658 nogroup:x:$gid_nogroup:nobody
3659 $unix_name-group:x:$unix_gids[0]:
3660 domusers:X:$gid_domusers:
3661 domadmins:X:$gid_domadmins:
3662 userdup:x:$gid_userdup:$unix_name
3663 everyone:x:$gid_everyone:
3664 force_user:x:$gid_force_user:
3665 jackthemappergroup:x:$gid_jackthemapper:jackthemapper
3666 jacknomappergroup:x:$gid_jacknomapper:jacknomapper
3668 if ($unix_gids[0] != 0) {
3669 print GROUP "root:x:$gid_root:
3676 my $hostname = lc($server);
3677 unless (open(HOSTS, ">>$nss_wrapper_hosts")) {
3678 warn("Unable to open $nss_wrapper_hosts");
3681 print HOSTS "${server_ip} ${hostname}.${dns_domain} ${hostname}\n";
3682 print HOSTS "${server_ipv6} ${hostname}.${dns_domain} ${hostname}\n";
3685 $resolv_conf = "$privatedir/no_resolv.conf" unless defined($resolv_conf);
3687 foreach my $evlog (@eventlog_list) {
3688 my $evlogtdb = "$eventlogdir/$evlog.tdb";
3689 open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
3693 $createuser_env{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
3694 $createuser_env{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
3695 $createuser_env{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
3696 $createuser_env{NSS_WRAPPER_HOSTNAME} = "${hostname}.${dns_domain}";
3697 if ($ENV{SAMBA_DNS_FAKING}) {
3698 $createuser_env{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
3700 $createuser_env{RESOLV_WRAPPER_CONF} = $resolv_conf;
3702 $createuser_env{RESOLV_CONF} = $resolv_conf;
3704 createuser($self, $unix_name, $password, $conffile, \%createuser_env) || die("Unable to create user");
3705 createuser($self, "force_user", $password, $conffile, \%createuser_env) || die("Unable to create force_user");
3706 createuser($self, "smbget_user", $password, $conffile, \%createuser_env) || die("Unable to create smbget_user");
3707 createuser($self, "user1", $password, $conffile, \%createuser_env) || die("Unable to create user1");
3708 createuser($self, "user2", $password, $conffile, \%createuser_env) || die("Unable to create user2");
3709 createuser($self, "gooduser", $password, $conffile, \%createuser_env) || die("Unable to create gooduser");
3710 createuser($self, "eviluser", $password, $conffile, \%createuser_env) || die("Unable to create eviluser");
3711 createuser($self, "slashuser", $password, $conffile, \%createuser_env) || die("Unable to create slashuser");
3712 createuser($self, "jackthemapper", "mApsEcrEt", $conffile, \%createuser_env) || die("Unable to create jackthemapper");
3713 createuser($self, "jacknomapper", "nOmApsEcrEt", $conffile, \%createuser_env) || die("Unable to create jacknomapper");
3715 open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
3716 print DNS_UPDATE_LIST "A $server. $server_ip\n";
3717 print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n";
3718 close(DNS_UPDATE_LIST);
3722 $ret{SERVER_IP} = $server_ip;
3723 $ret{SERVER_IPV6} = $server_ipv6;
3724 $ret{SAMBA_DCERPCD_TEST_LOG} = "$prefix/samba_dcerpcd_test.log";
3725 $ret{SAMBA_DCERPCD_LOG_POS} = 0;
3726 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
3727 $ret{NMBD_TEST_LOG_POS} = 0;
3728 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
3729 $ret{WINBINDD_TEST_LOG_POS} = 0;
3730 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
3731 $ret{SMBD_TEST_LOG_POS} = 0;
3732 $ret{SERVERCONFFILE} = $conffile;
3733 $ret{TESTENV_DIR} = $prefix_abs;
3734 $ret{CONFIGURATION} ="--configfile=$conffile";
3735 $ret{LOCK_DIR} = $lockdir;
3736 $ret{SERVER} = $server;
3737 $ret{USERNAME} = $unix_name;
3738 $ret{USERID} = $unix_uid;
3739 $ret{DOMAIN} = $domain;
3740 $ret{SAMSID} = $samsid;
3741 $ret{NETBIOSNAME} = $server;
3742 $ret{PASSWORD} = $password;
3743 $ret{PIDDIR} = $piddir;
3744 $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir;
3745 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
3746 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
3747 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
3748 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
3749 $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
3750 $ret{NSS_WRAPPER_HOSTNAME} = "${hostname}.${dns_domain}";
3751 $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
3752 $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind";
3753 if ($ENV{SAMBA_DNS_FAKING}) {
3754 $ret{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
3756 $ret{RESOLV_WRAPPER_CONF} = $resolv_conf;
3758 $ret{RESOLV_CONF} = $resolv_conf;
3759 $ret{LOCAL_PATH} = "$shrdir";
3760 $ret{LOGDIR} = $logdir;
3763 # Avoid hitting system krb5.conf -
3764 # An env that needs Kerberos will reset this to the real
3767 $ret{KRB5_CONFIG} = abs_path($prefix) . "/no_krb5.conf";
3769 # Define KRB5CCNAME for each environment we set up
3770 $ret{KRB5_CCACHE} = abs_path($prefix) . "/krb5ccache";
3771 $ENV{KRB5CCNAME} = $ret{KRB5_CCACHE};
3776 sub wait_for_start($$$$$)
3778 my ($self, $envvars, $nmbd, $winbindd, $smbd, $samba_dcerpcd) = @_;
3783 if ($samba_dcerpcd eq "yes") {
3785 my $rpcclient = Samba::bindir_path($self, "rpcclient");
3787 print "checking for samba_dcerpcd\n";
3790 $ret = system("$rpcclient $envvars->{CONFIGURATION} ncalrpc: -c epmmap");
3796 } while ($ret != 0 && $count < 10);
3799 print "samba_dcerpcd not reachable after 10 retries\n";
3800 teardown_env($self, $envvars);
3805 if ($nmbd eq "yes") {
3808 # give time for nbt server to register its names
3809 print "checking for nmbd\n";
3811 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
3812 my $nmblookup = Samba::bindir_path($self, "nmblookup");
3815 $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
3819 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
3820 system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
3821 system("$nmblookup $envvars->{CONFIGURATION} -U 10.255.255.255 __SAMBA__");
3822 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
3825 } while ($ret != 0 && $count < 10);
3827 print "NMBD not reachable after 10 retries\n";
3828 teardown_env($self, $envvars);
3833 if ($winbindd eq "yes" or $winbindd eq "offline") {
3834 print "checking for winbindd\n";
3836 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
3837 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3838 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3839 if ($winbindd eq "yes") {
3840 $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping-dc";
3841 } elsif ($winbindd eq "offline") {
3842 $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping";
3846 $ret = system($cmd);
3851 } while ($ret != 0 && $count < 20);
3853 print "WINBINDD not reachable after 20 seconds\n";
3854 teardown_env($self, $envvars);
3859 if ($smbd eq "yes") {
3860 # make sure smbd is also up set
3861 print "wait for smbd\n";
3865 if (defined($envvars->{GNUTLS_FORCE_FIPS_MODE})) {
3866 # We don't have NTLM in FIPS mode, so lets use
3867 # smbcontrol instead of smbclient.
3868 $cmd = Samba::bindir_path($self, "smbcontrol");
3869 $cmd .= " $envvars->{CONFIGURATION}";
3870 $cmd .= " smbd ping";
3872 # This uses NTLM which is not available in FIPS
3873 $cmd = Samba::bindir_path($self, "smbclient");
3874 $cmd .= " $envvars->{CONFIGURATION}";
3875 $cmd .= " -L $envvars->{SERVER}";
3877 $cmd .= " -I $envvars->{SERVER_IP}";
3881 $ret = system($cmd);
3886 } while ($ret != 0 && $count < 20);
3888 print "SMBD failed to start up in a reasonable time (20sec)\n";
3889 teardown_env($self, $envvars);
3894 # Ensure we have domain users mapped.
3895 $netcmd = "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3896 $netcmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3897 $netcmd .= "UID_WRAPPER_ROOT='1' ";
3898 $netcmd .= Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} ";
3900 $cmd = $netcmd . "groupmap delete ntgroup=domusers";
3901 $ret = system($cmd);
3903 $cmd = $netcmd . "groupmap add rid=513 unixgroup=domusers type=domain";
3904 $ret = system($cmd);
3906 print("\"$cmd\" failed\n");
3910 $cmd = $netcmd . "groupmap delete ntgroup=domadmins";
3911 $ret = system($cmd);
3913 $cmd = $netcmd . "groupmap add rid=512 unixgroup=domadmins type=domain";
3914 $ret = system($cmd);
3916 print("\"$cmd\" failed\n");
3920 $cmd = $netcmd . "groupmap delete ntgroup=everyone";
3921 $ret = system($cmd);
3923 $cmd = $netcmd . "groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin";
3924 $ret = system($cmd);
3926 print("\"$cmd\" failed\n");
3930 # note: creating builtin groups requires winbindd for the
3932 my $create_builtin_users = "no";
3933 if ($winbindd eq "yes") {
3934 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
3935 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3936 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3937 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
3938 my $wbinfo_out = qx($cmd 2>&1);
3940 # wbinfo doesn't give us a better error code then
3941 # WBC_ERR_DOMAIN_NOT_FOUND, but at least that's
3942 # different then WBC_ERR_WINBIND_NOT_AVAILABLE
3943 if ($wbinfo_out !~ /WBC_ERR_DOMAIN_NOT_FOUND/) {
3944 print("Failed to run \"wbinfo --sid-to-gid=S-1-5-32-545\": $wbinfo_out");
3945 teardown_env($self, $envvars);
3948 $create_builtin_users = "yes";
3951 if ($create_builtin_users eq "yes") {
3952 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
3953 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3954 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3955 $cmd .= Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
3956 $cmd .= "sam createbuiltingroup Users";
3957 $ret = system($cmd);
3959 print "Failed to create BUILTIN\\Users group\n";
3960 teardown_env($self, $envvars);
3964 $cmd = Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
3965 $cmd .= "cache del IDMAP/SID2XID/S-1-5-32-545";
3968 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
3969 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3970 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3971 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
3972 $ret = system($cmd);
3974 print "Missing \"BUILTIN\\Users\", did net sam createbuiltingroup Users fail?\n";
3975 teardown_env($self, $envvars);
3980 print $self->getlog_env($envvars);
3986 ## provision and start of ctdb
3990 my ($self, $prefix) = @_;
3993 my $data = $self->provision_ctdb($prefix, $num_nodes);
3994 $data or return undef;
3996 my $rc = $self->check_or_start_ctdb($data);
3998 print("check_or_start_ctdb() failed\n");
4002 $rc = $self->wait_for_start_ctdb($data);
4004 print "Cluster startup failed\n";
4011 sub provision_ctdb($$$$)
4013 my ($self, $prefix, $num_nodes, $no_delete_prefix) = @_;
4016 print "PROVISIONING CTDB...\n";
4018 my $prefix_abs = abs_path($prefix);
4021 # check / create directories:
4023 die ("prefix_abs = ''") if $prefix_abs eq "";
4024 die ("prefix_abs = '/'") if $prefix_abs eq "/";
4026 mkdir ($prefix_abs, 0777);
4028 print "CREATE CTDB TEST ENVIRONMENT in '$prefix_abs'...\n";
4030 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
4031 system("rm -rf $prefix_abs/*");
4038 for (my $i = 0; $i < $num_nodes; $i++) {
4040 my $server_name = "ctdb${i}";
4041 my $pub_iface = Samba::get_interface($server_name);
4042 my $ip = Samba::get_ipv4_addr($server_name);
4044 $node{NODE_NUMBER} = "$i";
4045 $node{SERVER_NAME} = "$server_name";
4046 $node{SOCKET_WRAPPER_DEFAULT_IFACE} = "$pub_iface";
4049 push(@nodes, \%node);
4055 my $nodes_file = "$prefix/nodes.in";
4056 unless (open(NODES, ">$nodes_file")) {
4057 warn("Unable to open nodesfile '$nodes_file'");
4060 for (my $i = 0; $i < $num_nodes; $i++) {
4061 my $ip = $nodes[$i]->{IP};
4062 print NODES "${ip}\n";
4067 # local_daemons.sh setup
4069 # Socket wrapper setup is done by selftest.pl, so don't use
4070 # the CTDB-specific setup
4073 $cmd .= "ctdb/tests/local_daemons.sh " . $prefix_abs . " setup";
4074 $cmd .= " -n " . $num_nodes;
4075 $cmd .= " -N " . $nodes_file;
4076 # CTDB should not attempt to manage public addresses -
4077 # clients should just connect to CTDB private addresses
4078 $cmd .= " -P " . "/dev/null";
4080 my $ret = system($cmd);
4082 print("\"$cmd\" failed\n");
4087 # Unix domain socket and node directory for each daemon
4089 for (my $i = 0; $i < $num_nodes; $i++) {
4090 my ($cmd, $ret, $out);
4092 my $cmd_prefix = "ctdb/tests/local_daemons.sh ${prefix_abs}";
4098 $cmd = "${cmd_prefix} print-socket ${i}";
4103 print("\"$cmd\" failed\n");
4107 $nodes[$i]->{SOCKET_FILE} = "$out";
4113 $cmd = "${cmd_prefix} onnode ${i} 'echo \$CTDB_BASE'";
4118 print("\"$cmd\" failed\n");
4122 $nodes[$i]->{NODE_PREFIX} = "$out";
4127 $ret{CTDB_PREFIX} = "$prefix";
4128 $ret{NUM_NODES} = $num_nodes;
4129 $ret{CTDB_NODES} = \@nodes;
4130 $ret{CTDB_NODES_FILE} = $nodes_file;
4135 sub check_or_start_ctdb($$) {
4136 my ($self, $data) = @_;
4138 my $prefix = $data->{CTDB_PREFIX};
4139 my $num_nodes = $data->{NUM_NODES};
4140 my $nodes = $data->{CTDB_NODES};
4143 # Share a single stdin pipe for all nodes
4144 pipe($STDIN_READER, $data->{CTDB_STDIN_PIPE});
4146 for (my $i = 0; $i < $num_nodes; $i++) {
4147 my $node = $nodes->[$i];
4149 $node->{STDIN_PIPE} = $data->{CTDB_STDIN_PIPE};
4151 my $cmd = "ctdb/tests/local_daemons.sh";
4152 my @full_cmd = ("$cmd", "$prefix", "start", "$i");
4155 BINARY_PATH => $cmd,
4156 FULL_CMD => [ @full_cmd ],
4158 LOG_FILE => "/dev/null",
4162 print "STARTING CTDBD (node ${i})\n";
4164 # This does magic with $STDIN_READER, so use it
4165 my $ret = Samba::fork_and_exec($self,
4171 print("\"$cmd\" failed\n");
4172 teardown_env_ctdb($self, $data);
4177 close($STDIN_READER);
4182 sub wait_for_start_ctdb($$)
4184 my ($self, $data) = @_;
4186 my $prefix = $data->{CTDB_PREFIX};
4188 print "Wait for ctdbd...\n";
4190 my $ctdb = Samba::bindir_path($self, "ctdb");
4192 $cmd .= "ctdb/tests/local_daemons.sh ${prefix} onnode all";
4193 $cmd .= " ${ctdb} nodestatus all 2>&1";
4196 my $wait_seconds = 60;
4199 until ($count > $wait_seconds) {
4203 print "\ncluster became healthy\n";
4206 print "Waiting for CTDB...\n";
4211 if ($count > $wait_seconds) {
4212 print "\nGiving up to wait for CTDB...\n";
4214 print "CTDB log:\n";
4215 $cmd = "ctdb/tests/local_daemons.sh ${prefix} print-log all >&2";
4217 teardown_env_ctdb($self, $data);
4221 print "\nCTDB initialized\n";