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, $domain, $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($domain)) {
316 $domain = "SAMBA-TEST";
318 if (!defined($server)) {
319 $server = "LOCALNT4DC2";
321 my $vars = $self->provision(
325 password => "localntdc2pass",
326 extra_options => $nt4_dc_options);
328 $vars or return undef;
330 if (not $self->check_or_start(
332 samba_dcerpcd => "yes",
339 $vars->{DOMSID} = $vars->{SAMSID};
340 $vars->{DC_SERVER} = $vars->{SERVER};
341 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
342 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
343 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
344 $vars->{DC_USERNAME} = $vars->{USERNAME};
345 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
350 sub setup_nt4_dc_smb1
352 my ($self, $path) = @_;
355 client min protocol = CORE
356 server min protocol = LANMAN1
358 return $self->setup_nt4_dc($path, $conf, "NT4SMB1", "LCLNT4DC2SMB1");
361 sub setup_nt4_dc_smb1_done
363 my ($self, $path, $dep_env) = @_;
364 return $self->return_alias_env($path, $dep_env);
367 sub setup_nt4_dc_schannel
369 my ($self, $path) = @_;
371 print "PROVISIONING NT4 DC WITH SERVER SCHANNEL ...";
378 server schannel = yes
379 # used to reproduce bug #12772
380 server max protocol = SMB2_02
383 my $vars = $self->provision(
385 domain => "NT4SCHANNEL",
386 server => "LOCALNT4DC9",
387 password => "localntdc9pass",
388 extra_options => $pdc_options);
390 $vars or return undef;
392 if (not $self->check_or_start(
400 $vars->{DOMSID} = $vars->{SAMSID};
401 $vars->{DC_SERVER} = $vars->{SERVER};
402 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
403 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
404 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
405 $vars->{DC_USERNAME} = $vars->{USERNAME};
406 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
413 my ($self, $prefix, $nt4_dc_vars) = @_;
417 print "PROVISIONING MEMBER...";
419 my $require_mutexes = "dbwrap_tdb_require_mutexes:* = yes";
420 if ($ENV{SELFTEST_DONT_REQUIRE_TDB_MUTEX_SUPPORT} // '' eq "1") {
421 $require_mutexes = "";
424 my $member_options = "
426 dbwrap_tdb_mutexes:* = yes
429 my $ret = $self->provision(
431 domain => $nt4_dc_vars->{DOMAIN},
432 server => "LOCALNT4MEMBER3",
433 password => "localnt4member3pass",
434 extra_options => $member_options);
436 $ret or return undef;
438 my $nmblookup = Samba::bindir_path($self, "nmblookup");
440 print "Waiting for the LOGON SERVER registration ...\n";
441 $rc = system("$nmblookup $ret->{CONFIGURATION} $ret->{DOMAIN}\#1c");
446 } while ($rc != 0 && $count < 10);
448 print "NMBD not reachable after 10 retries\n";
449 teardown_env($self, $ret);
453 my $net = Samba::bindir_path($self, "net");
454 # Add hosts file for name lookups
455 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
456 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
457 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
458 $cmd .= "$net rpc join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
459 $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}";
461 if (system($cmd) != 0) {
462 warn("Join failed\n$cmd");
466 # Add hosts file for name lookups
467 $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
468 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
469 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
470 $cmd .= "$net $ret->{CONFIGURATION} primarytrust dumpinfo | grep -q 'REDACTED SECRET VALUES'";
472 if (system($cmd) != 0) {
473 warn("check failed\n$cmd");
477 if (not $self->check_or_start(
485 $ret->{DOMSID} = $nt4_dc_vars->{DOMSID};
486 $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
487 $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
488 $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
489 $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME};
490 $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME};
491 $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD};
496 sub setup_clusteredmember
498 my ($self, $prefix, $nt4_dc_vars) = @_;
504 print "PROVISIONING CLUSTEREDMEMBER...\n";
506 my $prefix_abs = abs_path($prefix);
507 mkdir($prefix_abs, 0777);
509 my $ctdb_data = $self->setup_ctdb($prefix);
511 if (not $ctdb_data) {
512 print "No ctdb data\n";
516 print "PROVISIONING CLUSTERED SAMBA...\n";
518 my $num_nodes = $ctdb_data->{NUM_NODES};
519 my $nodes = $ctdb_data->{CTDB_NODES};
521 # Enable cleanup of earlier nodes if a later node fails
522 $ctdb_data->{SAMBA_NODES} = \@retvals;
524 for (my $i = 0; $i < $num_nodes; $i++) {
525 my $node = $nodes->[$i];
526 my $socket = $node->{SOCKET_FILE};
527 my $server_name = $node->{SERVER_NAME};
528 my $pub_iface = $node->{SOCKET_WRAPPER_DEFAULT_IFACE};
529 my $node_prefix = $node->{NODE_PREFIX};
531 print "CTDB_BASE=${node_prefix}\n";
532 print "CTDB_SOCKET=${socket}\n";
534 my $require_mutexes = "dbwrap_tdb_require_mutexes:* = yes";
535 if ($ENV{SELFTEST_DONT_REQUIRE_TDB_MUTEX_SUPPORT} // '' eq "1") {
536 $require_mutexes = "" ;
539 my $member_options = "
543 rpc start on demand helpers = false
544 rpcd witness:include node ips = yes
545 ctdbd socket = ${socket}
547 dbwrap_tdb_mutexes:* = yes
551 my $node_ret = $self->provision(
552 prefix => "$node_prefix",
553 domain => $nt4_dc_vars->{DOMAIN},
554 server => "$server_name",
555 password => "clustermember8pass",
556 netbios_name => "CLUSTEREDMEMBER",
557 share_dir => "${prefix_abs}/shared",
558 extra_options => $member_options,
559 no_delete_prefix => 1);
561 print "Provision node $i failed\n";
562 teardown_env($self, $ctdb_data);
566 my $registry_share_template = "$node_ret->{SERVERCONFFILE}.registry_share_template";
567 unless (open(REGISTRYCONF, ">$registry_share_template")) {
568 warn("Unable to open $registry_share_template");
569 teardown_env($self, $node_ret);
570 teardown_env($self, $ctdb_data);
577 comment = smb username is [%U]
582 my $net = Samba::bindir_path($self, "net");
585 $cmd .= "UID_WRAPPER_ROOT=1 ";
586 $cmd .= "$net conf import $node_ret->{CONFIGURATION} ${registry_share_template}";
588 my $net_ret = system($cmd);
590 warn("net conf import failed: $net_ret\n$cmd");
591 teardown_env($self, $node_ret);
592 teardown_env($self, $ctdb_data);
596 my $nmblookup = Samba::bindir_path($self, "nmblookup");
598 print "Waiting for the LOGON SERVER registration ...\n";
599 $rc = system("$nmblookup $node_ret->{CONFIGURATION} " .
600 "$node_ret->{DOMAIN}\#1c");
605 } while ($rc != 0 && $count < 10);
608 print "NMBD not reachable after 10 retries\n";
609 teardown_env($self, $node_ret);
610 teardown_env($self, $ctdb_data);
614 push(@retvals, $node_ret);
617 $ret = {%$ctdb_data, %{$retvals[0]}};
619 my $net = Samba::bindir_path($self, "net");
621 $cmd .= "UID_WRAPPER_ROOT=1 ";
622 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
623 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
624 $cmd .= "$net join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
625 $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}";
627 if (system($cmd) != 0) {
628 warn("Join failed\n$cmd");
629 teardown_env($self, $ret);
633 for (my $i=0; $i<@retvals; $i++) {
634 my $node_provision = $retvals[$i];
636 $ok = $self->check_or_start(
637 env_vars => $node_provision,
638 samba_dcerpcd => "yes",
641 child_cleanup => sub {
643 my $fh = $_->{STDIN_PIPE};
644 close($fh) if defined($fh);
647 teardown_env($self, $ret);
653 # Build a unclist for every share
655 unless (open(NODES, "<$ret->{CTDB_NODES_FILE}")) {
656 warn("Unable to open CTDB nodes file");
657 teardown_env($self, $ret);
664 my $conffile = $ret->{SERVERCONFFILE};
666 $cmd .= 'sed -n -e \'s|^\[\(.*\)\]$|\1|p\'';
667 $cmd .= " \"$conffile\"";
668 $cmd .= " | grep -vx 'global'";
673 warn("Listing shares failed\n$cmd");
674 teardown_env($self, $ret);
679 my $unclistdir = "${prefix_abs}/unclists";
680 mkdir($unclistdir, 0777);
681 foreach my $share (@shares) {
682 my $l = "${unclistdir}/${share}.txt";
683 unless (open(UNCLIST, ">${l}")) {
684 warn("Unable to open UNC list ${l}");
685 teardown_env($self, $ret);
688 foreach my $node (@nodes) {
689 print UNCLIST "//${node}/${share}\n";
694 $ret->{DOMSID} = $nt4_dc_vars->{DOMSID};
695 $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
696 $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
697 $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
698 $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME};
699 $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME};
700 $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD};
705 sub provision_ad_member
713 $extra_member_options,
716 $no_nss_winbind) = @_;
718 if (defined($offline_logon) && defined($no_nss_winbind)) {
719 warn ("Offline logon incompatible with no nss winbind\n");
723 my $prefix_abs = abs_path($prefix);
726 mkdir($prefix_abs, 0777);
728 my $share_dir="$prefix_abs/share";
729 push(@dirs, $share_dir);
731 my $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}";
732 push(@dirs, $substitution_path);
734 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice";
735 push(@dirs, $substitution_path);
737 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice/G_domain users";
738 push(@dirs, $substitution_path);
740 # Using '/' as the winbind separator is a bad idea ...
741 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}";
742 push(@dirs, $substitution_path);
744 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice";
745 push(@dirs, $substitution_path);
747 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}";
748 push(@dirs, $substitution_path);
750 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}/domain users";
751 push(@dirs, $substitution_path);
753 my $smbcacls_sharedir="$share_dir/smbcacls";
754 push(@dirs,$smbcacls_sharedir);
756 my $option_offline_logon = "no";
757 if (defined($offline_logon)) {
758 $option_offline_logon = "yes";
761 my $netbios_aliases = "";
762 if ($machine_account eq "LOCALADMEMBER") {
763 $netbios_aliases = "netbios aliases = foo bar";
766 unless (defined($extra_member_options)) {
767 $extra_member_options = "";
770 my $member_options = "
772 workgroup = $dcvars->{DOMAIN}
773 realm = $dcvars->{REALM}
775 template homedir = /home/%D/%G/%U
776 auth event notification = true
777 password server = $dcvars->{SERVER}
778 winbind scan trusted domains = no
779 winbind offline logon = $option_offline_logon
781 allow dcerpc auth level connect:lsarpc = yes
782 dcesrv:max auth states = 8
783 rpc start on demand helpers = false
785 # Begin extra member options
786 $extra_member_options
787 # End extra member options
790 path = $share_dir/D_%D/U_%U/G_%G
794 path = $share_dir/D_%D/u_%u/g_%g
799 valid users = ADDOMAIN/%U
801 [sub_valid_users_domain]
805 [sub_valid_users_group]
807 valid users = \@$dcvars->{DOMAIN}/%G
811 valid users = $dcvars->{DOMAIN}/$dcvars->{DC_USERNAME}
815 valid users = \"\@$dcvars->{DOMAIN}/domain users\"
817 [valid_users_unix_group]
819 valid users = \"+$dcvars->{DOMAIN}/domain users\"
821 [valid_users_nis_group]
823 valid users = \"&$dcvars->{DOMAIN}/domain users\"
825 [valid_users_unix_nis_group]
827 valid users = \"+&$dcvars->{DOMAIN}/domain users\"
829 [valid_users_nis_unix_group]
831 valid users = \"&+$dcvars->{DOMAIN}/domain users\"
835 invalid users = $dcvars->{DOMAIN}/$dcvars->{DC_USERNAME}
837 [valid_and_invalid_users]
839 valid users = $dcvars->{DOMAIN}/$dcvars->{DC_USERNAME} $dcvars->{DOMAIN}/alice
840 invalid users = $dcvars->{DOMAIN}/$dcvars->{DC_USERNAME}
843 my $ret = $self->provision(
845 domain => $dcvars->{DOMAIN},
846 realm => $dcvars->{REALM},
847 server => $machine_account,
848 password => "loCalMemberPass",
849 extra_options => $member_options,
850 resolv_conf => $dcvars->{RESOLV_CONF});
852 $ret or return undef;
854 mkdir($_, 0777) foreach(@dirs);
856 $ret->{DOMAIN} = $dcvars->{DOMAIN};
857 $ret->{REALM} = $dcvars->{REALM};
858 $ret->{DOMSID} = $dcvars->{DOMSID};
862 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
863 $ctx->{domain} = $dcvars->{DOMAIN};
864 $ctx->{realm} = $dcvars->{REALM};
865 $ctx->{dnsname} = lc($dcvars->{REALM});
866 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
867 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
868 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
869 Samba::mk_krb5_conf($ctx, "");
871 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
873 if (defined($force_fips_mode)) {
874 $ret->{GNUTLS_FORCE_FIPS_MODE} = "1";
875 $ret->{OPENSSL_FORCE_FIPS_MODE} = "1";
878 my $net = Samba::bindir_path($self, "net");
879 # Add hosts file for name lookups
880 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
881 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
882 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
883 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
885 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
887 if (defined($force_fips_mode)) {
888 $cmd .= "GNUTLS_FORCE_FIPS_MODE=1 ";
889 $cmd .= "OPENSSL_FORCE_FIPS_MODE=1 ";
891 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
892 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
893 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
894 $cmd .= "$net join $ret->{CONFIGURATION}";
895 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD} --use-kerberos=required";
897 if (system($cmd) != 0) {
898 warn("Join failed\n$cmd");
902 # We need world access to this share, as otherwise the domain
903 # administrator from the AD domain provided by Samba4 can't
904 # access the share for tests.
905 chmod 0777, "$prefix/share";
907 if (defined($offline_logon)) {
908 my $wbinfo = Samba::bindir_path($self, "wbinfo");
910 if (not $self->check_or_start(
912 winbindd => "yes")) {
916 # Fill samlogoncache for alice
917 $cmd = "NSS_WRAPPER_PASSWD='$ret->{NSS_WRAPPER_PASSWD}' ";
918 $cmd .= "NSS_WRAPPER_GROUP='$ret->{NSS_WRAPPER_GROUP}' ";
919 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
920 $cmd .= "$wbinfo --pam-logon=ADDOMAIN/alice%Secret007";
921 if (system($cmd) != 0) {
922 warn("Filling the cache failed\n$cmd");
926 $cmd = "NSS_WRAPPER_PASSWD='$ret->{NSS_WRAPPER_PASSWD}' ";
927 $cmd .= "NSS_WRAPPER_GROUP='$ret->{NSS_WRAPPER_GROUP}' ";
928 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
929 $cmd .= "$wbinfo --ccache-save=ADDOMAIN/alice%Secret007";
930 if (system($cmd) != 0) {
931 warn("Filling the cache failed\n$cmd");
935 # Fill samlogoncache for bob
936 $cmd = "NSS_WRAPPER_PASSWD='$ret->{NSS_WRAPPER_PASSWD}' ";
937 $cmd .= "NSS_WRAPPER_GROUP='$ret->{NSS_WRAPPER_GROUP}' ";
938 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
939 $cmd .= "$wbinfo --pam-logon=ADDOMAIN/bob%Secret007";
940 if (system($cmd) != 0) {
941 warn("Filling the cache failed\n$cmd");
945 $cmd = "NSS_WRAPPER_PASSWD='$ret->{NSS_WRAPPER_PASSWD}' ";
946 $cmd .= "NSS_WRAPPER_GROUP='$ret->{NSS_WRAPPER_GROUP}' ";
947 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
948 $cmd .= "$wbinfo --ccache-save=ADDOMAIN/bob%Secret007";
949 if (system($cmd) != 0) {
950 warn("Filling the cache failed\n$cmd");
954 # Set windindd offline
955 my $smbcontrol = Samba::bindir_path($self, "smbcontrol");
956 $cmd = "NSS_WRAPPER_PASSWD='$ret->{NSS_WRAPPER_PASSWD}' ";
957 $cmd .= "NSS_WRAPPER_GROUP='$ret->{NSS_WRAPPER_GROUP}' ";
958 $cmd .= "UID_WRAPPER_ROOT='1' ";
959 $cmd .= "$smbcontrol $ret->{CONFIGURATION} winbindd offline";
960 if (system($cmd) != 0) {
961 warn("Setting winbindd offline failed\n$cmd");
965 # Validate the offline cache
966 $cmd = "NSS_WRAPPER_PASSWD='$ret->{NSS_WRAPPER_PASSWD}' ";
967 $cmd .= "NSS_WRAPPER_GROUP='$ret->{NSS_WRAPPER_GROUP}' ";
968 $cmd .= "UID_WRAPPER_ROOT='1' ";
969 $cmd .= "$smbcontrol $ret->{CONFIGURATION} winbindd validate-cache";
970 if (system($cmd) != 0) {
971 warn("Validation of winbind credential cache failed\n$cmd");
972 teardown_env($self, $ret);
977 teardown_env($self, $ret);
979 ### Change SOCKET_WRAPPER_DIR so it can't connect to AD
980 my $swrap_env = $ENV{SOCKET_WRAPPER_DIR};
981 $ENV{SOCKET_WRAPPER_DIR} = "$prefix_abs";
983 # Start winbindd in offline mode
984 if (not $self->check_or_start(
986 winbindd => "offline")) {
990 # Set socket dir again
991 $ENV{SOCKET_WRAPPER_DIR} = $swrap_env;
994 if (defined($no_nss_winbind)) {
995 $ret->{NSS_WRAPPER_MODULE_SO_PATH} = "";
996 $ret->{NSS_WRAPPER_MODULE_FN_PREFIX} = "";
999 if (not $self->check_or_start(
1001 samba_dcerpcd => "yes",
1009 $ret->{DC_SERVER} = $dcvars->{SERVER};
1010 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1011 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1012 $ret->{DC_SERVERCONFFILE} = $dcvars->{SERVERCONFFILE};
1013 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1014 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1015 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1016 $ret->{DOMAIN_ADMIN} = $dcvars->{DOMAIN_ADMIN};
1017 $ret->{DOMAIN_ADMIN_PASSWORD} = $dcvars->{DOMAIN_ADMIN_PASSWORD};
1018 $ret->{DOMAIN_USER} = $dcvars->{DOMAIN_USER};
1019 $ret->{DOMAIN_USER_PASSWORD} = $dcvars->{DOMAIN_USER_PASSWORD};
1022 $ret->{TRUST_F_BOTH_SERVER} = $trustvars_f->{SERVER};
1023 $ret->{TRUST_F_BOTH_SERVER_IP} = $trustvars_f->{SERVER_IP};
1024 $ret->{TRUST_F_BOTH_SERVER_IPV6} = $trustvars_f->{SERVER_IPV6};
1025 $ret->{TRUST_F_BOTH_NETBIOSNAME} = $trustvars_f->{NETBIOSNAME};
1026 $ret->{TRUST_F_BOTH_USERNAME} = $trustvars_f->{USERNAME};
1027 $ret->{TRUST_F_BOTH_PASSWORD} = $trustvars_f->{PASSWORD};
1028 $ret->{TRUST_F_BOTH_DOMAIN} = $trustvars_f->{DOMAIN};
1029 $ret->{TRUST_F_BOTH_REALM} = $trustvars_f->{REALM};
1032 $ret->{TRUST_E_BOTH_SERVER} = $trustvars_e->{SERVER};
1033 $ret->{TRUST_E_BOTH_SERVER_IP} = $trustvars_e->{SERVER_IP};
1034 $ret->{TRUST_E_BOTH_SERVER_IPV6} = $trustvars_e->{SERVER_IPV6};
1035 $ret->{TRUST_E_BOTH_NETBIOSNAME} = $trustvars_e->{NETBIOSNAME};
1036 $ret->{TRUST_E_BOTH_USERNAME} = $trustvars_e->{USERNAME};
1037 $ret->{TRUST_E_BOTH_PASSWORD} = $trustvars_e->{PASSWORD};
1038 $ret->{TRUST_E_BOTH_DOMAIN} = $trustvars_e->{DOMAIN};
1039 $ret->{TRUST_E_BOTH_REALM} = $trustvars_e->{REALM};
1052 # If we didn't build with ADS, pretend this env was never available
1053 if (not $self->have_ads()) {
1057 print "PROVISIONING AD MEMBER...";
1059 return $self->provision_ad_member($prefix,
1066 sub setup_ad_member_s3_join
1074 # If we didn't build with ADS, pretend this env was never available
1075 if (not $self->have_ads()) {
1079 print "PROVISIONING AD MEMBER...";
1081 return $self->provision_ad_member($prefix,
1088 sub setup_ad_member_rfc2307
1090 my ($self, $prefix, $dcvars) = @_;
1092 # If we didn't build with ADS, pretend this env was never available
1093 if (not $self->have_ads()) {
1097 print "PROVISIONING S3 AD MEMBER WITH idmap_rfc2307 config...";
1099 my $member_options = "
1101 workgroup = $dcvars->{DOMAIN}
1102 realm = $dcvars->{REALM}
1103 idmap cache time = 0
1104 idmap negative cache time = 0
1105 idmap config * : backend = autorid
1106 idmap config * : range = 1000000-1999999
1107 idmap config * : rangesize = 100000
1108 idmap config $dcvars->{DOMAIN} : backend = rfc2307
1109 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
1110 idmap config $dcvars->{DOMAIN} : ldap_server = ad
1111 idmap config $dcvars->{DOMAIN} : bind_path_user = ou=idmap,dc=samba,dc=example,dc=com
1112 idmap config $dcvars->{DOMAIN} : bind_path_group = ou=idmap,dc=samba,dc=example,dc=com
1114 password server = $dcvars->{SERVER}
1117 my $ret = $self->provision(
1119 domain => $dcvars->{DOMAIN},
1120 realm => $dcvars->{REALM},
1121 server => "RFC2307MEMBER",
1122 password => "loCalMemberPass",
1123 extra_options => $member_options,
1124 resolv_conf => $dcvars->{RESOLV_CONF});
1126 $ret or return undef;
1128 $ret->{DOMAIN} = $dcvars->{DOMAIN};
1129 $ret->{REALM} = $dcvars->{REALM};
1130 $ret->{DOMSID} = $dcvars->{DOMSID};
1133 my $prefix_abs = abs_path($prefix);
1135 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1136 $ctx->{domain} = $dcvars->{DOMAIN};
1137 $ctx->{realm} = $dcvars->{REALM};
1138 $ctx->{dnsname} = lc($dcvars->{REALM});
1139 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
1140 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
1141 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1142 Samba::mk_krb5_conf($ctx, "");
1144 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1146 my $net = Samba::bindir_path($self, "net");
1147 # Add hosts file for name lookups
1148 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
1149 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1150 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
1151 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
1153 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
1155 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
1156 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1157 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
1158 $cmd .= "$net join $ret->{CONFIGURATION}";
1159 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
1161 if (system($cmd) != 0) {
1162 warn("Join failed\n$cmd");
1166 # We need world access to this share, as otherwise the domain
1167 # administrator from the AD domain provided by Samba4 can't
1168 # access the share for tests.
1169 chmod 0777, "$prefix/share";
1171 if (not $self->check_or_start(
1179 $ret->{DC_SERVER} = $dcvars->{SERVER};
1180 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1181 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1182 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1183 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1184 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1185 $ret->{DOMAIN_ADMIN} = $dcvars->{DOMAIN_ADMIN};
1186 $ret->{DOMAIN_ADMIN_PASSWORD} = $dcvars->{DOMAIN_ADMIN_PASSWORD};
1187 $ret->{DOMAIN_USER} = $dcvars->{DOMAIN_USER};
1188 $ret->{DOMAIN_USER_PASSWORD} = $dcvars->{DOMAIN_USER_PASSWORD};
1193 sub setup_admem_idmap_autorid
1195 my ($self, $prefix, $dcvars) = @_;
1197 # If we didn't build with ADS, pretend this env was never available
1198 if (not $self->have_ads()) {
1202 print "PROVISIONING S3 AD MEMBER WITH idmap_autorid config...";
1204 my $member_options = "
1206 workgroup = $dcvars->{DOMAIN}
1207 realm = $dcvars->{REALM}
1208 idmap config * : backend = autorid
1209 idmap config * : range = 1000000-19999999
1210 idmap config * : rangesize = 1000000
1212 # Prevent overriding the provisioned lib/krb5.conf which sets certain
1213 # values required for tests to succeed
1214 create krb5 conf = no
1217 my $ret = $self->provision(
1219 domain => $dcvars->{DOMAIN},
1220 realm => $dcvars->{REALM},
1221 server => "ADMEMAUTORID",
1222 password => "loCalMemberPass",
1223 extra_options => $member_options,
1224 resolv_conf => $dcvars->{RESOLV_CONF});
1226 $ret or return undef;
1228 $ret->{DOMAIN} = $dcvars->{DOMAIN};
1229 $ret->{REALM} = $dcvars->{REALM};
1230 $ret->{DOMSID} = $dcvars->{DOMSID};
1233 my $prefix_abs = abs_path($prefix);
1235 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1236 $ctx->{domain} = $dcvars->{DOMAIN};
1237 $ctx->{realm} = $dcvars->{REALM};
1238 $ctx->{dnsname} = lc($dcvars->{REALM});
1239 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
1240 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
1241 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1242 Samba::mk_krb5_conf($ctx, "");
1244 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1246 my $net = Samba::bindir_path($self, "net");
1247 # Add hosts file for name lookups
1248 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
1249 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1250 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
1251 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
1253 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
1255 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
1256 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1257 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
1258 $cmd .= "$net join $ret->{CONFIGURATION}";
1259 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
1261 if (system($cmd) != 0) {
1262 warn("Join failed\n$cmd");
1266 # We need world access to this share, as otherwise the domain
1267 # administrator from the AD domain provided by Samba4 can't
1268 # access the share for tests.
1269 chmod 0777, "$prefix/share";
1271 if (not $self->check_or_start(
1279 $ret->{DC_SERVER} = $dcvars->{SERVER};
1280 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1281 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1282 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1283 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1284 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1285 $ret->{DOMAIN_ADMIN} = $dcvars->{DOMAIN_ADMIN};
1286 $ret->{DOMAIN_ADMIN_PASSWORD} = $dcvars->{DOMAIN_ADMIN_PASSWORD};
1287 $ret->{DOMAIN_USER} = $dcvars->{DOMAIN_USER};
1288 $ret->{DOMAIN_USER_PASSWORD} = $dcvars->{DOMAIN_USER_PASSWORD};
1293 sub setup_ad_member_idmap_rid
1295 my ($self, $prefix, $dcvars) = @_;
1297 # If we didn't build with ADS, pretend this env was never available
1298 if (not $self->have_ads()) {
1302 print "PROVISIONING S3 AD MEMBER WITH idmap_rid config...";
1304 my $member_options = "
1306 workgroup = $dcvars->{DOMAIN}
1307 realm = $dcvars->{REALM}
1308 idmap config * : backend = tdb
1309 idmap config * : range = 1000000-1999999
1310 idmap config $dcvars->{DOMAIN} : backend = rid
1311 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
1312 # Prevent overriding the provisioned lib/krb5.conf which sets certain
1313 # values required for tests to succeed
1314 create krb5 conf = no
1315 map to guest = bad user
1316 winbind expand groups = 10
1317 server signing = required
1320 my $ret = $self->provision(
1322 domain => $dcvars->{DOMAIN},
1323 realm => $dcvars->{REALM},
1324 server => "IDMAPRIDMEMBER",
1325 password => "loCalMemberPass",
1326 extra_options => $member_options,
1327 resolv_conf => $dcvars->{RESOLV_CONF});
1329 $ret or return undef;
1331 $ret->{DOMAIN} = $dcvars->{DOMAIN};
1332 $ret->{REALM} = $dcvars->{REALM};
1333 $ret->{DOMSID} = $dcvars->{DOMSID};
1336 my $prefix_abs = abs_path($prefix);
1338 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1339 $ctx->{domain} = $dcvars->{DOMAIN};
1340 $ctx->{realm} = $dcvars->{REALM};
1341 $ctx->{dnsname} = lc($dcvars->{REALM});
1342 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
1343 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
1344 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1345 Samba::mk_krb5_conf($ctx, "");
1347 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1349 my $net = Samba::bindir_path($self, "net");
1350 # Add hosts file for name lookups
1351 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
1352 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1353 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
1354 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
1356 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
1358 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
1359 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1360 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
1361 $cmd .= "$net join $ret->{CONFIGURATION}";
1362 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
1364 if (system($cmd) != 0) {
1365 warn("Join failed\n$cmd");
1369 # We need world access to this share, as otherwise the domain
1370 # administrator from the AD domain provided by Samba4 can't
1371 # access the share for tests.
1372 chmod 0777, "$prefix/share";
1374 if (not $self->check_or_start(
1382 $ret->{DC_SERVER} = $dcvars->{SERVER};
1383 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1384 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1385 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1386 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1387 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1388 $ret->{DOMAIN_ADMIN} = $dcvars->{DOMAIN_ADMIN};
1389 $ret->{DOMAIN_ADMIN_PASSWORD} = $dcvars->{DOMAIN_ADMIN_PASSWORD};
1390 $ret->{DOMAIN_USER} = $dcvars->{DOMAIN_USER};
1391 $ret->{DOMAIN_USER_PASSWORD} = $dcvars->{DOMAIN_USER_PASSWORD};
1396 sub setup_ad_member_idmap_ad
1398 my ($self, $prefix, $dcvars) = @_;
1400 # If we didn't build with ADS, pretend this env was never available
1401 if (not $self->have_ads()) {
1405 print "PROVISIONING S3 AD MEMBER WITH idmap_ad config...";
1407 my $member_options = "
1409 workgroup = $dcvars->{DOMAIN}
1410 realm = $dcvars->{REALM}
1411 password server = $dcvars->{SERVER}
1412 idmap config * : backend = tdb
1413 idmap config * : range = 1000000-1999999
1414 idmap config $dcvars->{DOMAIN} : backend = ad
1415 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
1416 idmap config $dcvars->{DOMAIN} : unix_primary_group = yes
1417 idmap config $dcvars->{DOMAIN} : unix_nss_info = yes
1418 idmap config $dcvars->{DOMAIN} : deny ous = \"ou=sub,DC=samba2008r2,DC=example,DC=com\"
1419 idmap config $dcvars->{TRUST_DOMAIN} : backend = ad
1420 idmap config $dcvars->{TRUST_DOMAIN} : range = 2000000-2999999
1421 gensec_gssapi:requested_life_time = 5
1422 winbind scan trusted domains = yes
1423 winbind expand groups = 1
1426 my $ret = $self->provision(
1428 domain => $dcvars->{DOMAIN},
1429 realm => $dcvars->{REALM},
1430 server => "IDMAPADMEMBER",
1431 password => "loCalMemberPass",
1432 extra_options => $member_options,
1433 resolv_conf => $dcvars->{RESOLV_CONF});
1435 $ret or return undef;
1437 $ret->{DOMAIN} = $dcvars->{DOMAIN};
1438 $ret->{REALM} = $dcvars->{REALM};
1439 $ret->{DOMSID} = $dcvars->{DOMSID};
1442 my $prefix_abs = abs_path($prefix);
1444 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1445 $ctx->{domain} = $dcvars->{DOMAIN};
1446 $ctx->{realm} = $dcvars->{REALM};
1447 $ctx->{dnsname} = lc($dcvars->{REALM});
1448 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
1449 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
1450 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1451 Samba::mk_krb5_conf($ctx, "");
1453 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1455 my $net = Samba::bindir_path($self, "net");
1456 # Add hosts file for name lookups
1457 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
1458 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1459 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
1460 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
1462 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
1464 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
1465 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1466 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
1467 $cmd .= "$net join $ret->{CONFIGURATION}";
1468 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
1470 if (system($cmd) != 0) {
1471 warn("Join failed\n$cmd");
1475 # We need world access to this share, as otherwise the domain
1476 # administrator from the AD domain provided by Samba4 can't
1477 # access the share for tests.
1478 chmod 0777, "$prefix/share";
1480 if (not $self->check_or_start(
1488 $ret->{DC_SERVER} = $dcvars->{SERVER};
1489 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1490 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1491 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1492 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1493 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1494 $ret->{DOMAIN_ADMIN} = $dcvars->{DOMAIN_ADMIN};
1495 $ret->{DOMAIN_ADMIN_PASSWORD} = $dcvars->{DOMAIN_ADMIN_PASSWORD};
1496 $ret->{DOMAIN_USER} = $dcvars->{DOMAIN_USER};
1497 $ret->{DOMAIN_USER_PASSWORD} = $dcvars->{DOMAIN_USER_PASSWORD};
1499 $ret->{TRUST_SERVER} = $dcvars->{TRUST_SERVER};
1500 $ret->{TRUST_USERNAME} = $dcvars->{TRUST_USERNAME};
1501 $ret->{TRUST_PASSWORD} = $dcvars->{TRUST_PASSWORD};
1502 $ret->{TRUST_DOMAIN} = $dcvars->{TRUST_DOMAIN};
1503 $ret->{TRUST_REALM} = $dcvars->{TRUST_REALM};
1504 $ret->{TRUST_DOMSID} = $dcvars->{TRUST_DOMSID};
1509 sub setup_ad_member_oneway
1511 my ($self, $prefix, $dcvars) = @_;
1513 # If we didn't build with ADS, pretend this env was never available
1514 if (not $self->have_ads()) {
1518 print "PROVISIONING S3 AD MEMBER WITH one-way trust...";
1520 my $member_options = "
1522 workgroup = $dcvars->{DOMAIN}
1523 realm = $dcvars->{REALM}
1524 password server = $dcvars->{SERVER}
1525 idmap config * : backend = tdb
1526 idmap config * : range = 1000000-1999999
1527 gensec_gssapi:requested_life_time = 5
1530 my $ret = $self->provision(
1532 domain => $dcvars->{DOMAIN},
1533 server => "S2KMEMBER",
1534 password => "loCalS2KMemberPass",
1535 extra_options => $member_options,
1536 resolv_conf => $dcvars->{RESOLV_CONF});
1538 $ret or return undef;
1540 $ret->{DOMAIN} = $dcvars->{DOMAIN};
1541 $ret->{REALM} = $dcvars->{REALM};
1542 $ret->{DOMSID} = $dcvars->{DOMSID};
1545 my $prefix_abs = abs_path($prefix);
1547 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1548 $ctx->{domain} = $dcvars->{DOMAIN};
1549 $ctx->{realm} = $dcvars->{REALM};
1550 $ctx->{dnsname} = lc($dcvars->{REALM});
1551 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
1552 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
1553 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1554 Samba::mk_krb5_conf($ctx, "");
1556 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1558 my $net = Samba::bindir_path($self, "net");
1559 # Add hosts file for name lookups
1560 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
1561 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1562 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
1563 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
1565 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
1567 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
1568 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1569 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
1570 $cmd .= "$net join $ret->{CONFIGURATION}";
1571 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
1573 if (system($cmd) != 0) {
1574 warn("Join failed\n$cmd");
1578 if (not $self->check_or_start(
1580 winbindd => "yes")) {
1584 $ret->{DC_SERVER} = $dcvars->{SERVER};
1585 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1586 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1587 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1588 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1589 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1590 $ret->{DOMAIN_ADMIN} = $dcvars->{DOMAIN_ADMIN};
1591 $ret->{DOMAIN_ADMIN_PASSWORD} = $dcvars->{DOMAIN_ADMIN_PASSWORD};
1592 $ret->{DOMAIN_USER} = $dcvars->{DOMAIN_USER};
1593 $ret->{DOMAIN_USER_PASSWORD} = $dcvars->{DOMAIN_USER_PASSWORD};
1595 $ret->{TRUST_SERVER} = $dcvars->{TRUST_SERVER};
1596 $ret->{TRUST_USERNAME} = $dcvars->{TRUST_USERNAME};
1597 $ret->{TRUST_PASSWORD} = $dcvars->{TRUST_PASSWORD};
1598 $ret->{TRUST_DOMAIN} = $dcvars->{TRUST_DOMAIN};
1599 $ret->{TRUST_REALM} = $dcvars->{TRUST_REALM};
1600 $ret->{TRUST_DOMSID} = $dcvars->{TRUST_DOMSID};
1605 sub setup_ad_member_fips
1613 # If we didn't build with ADS, pretend this env was never available
1614 if (not $self->have_ads()) {
1618 print "PROVISIONING AD FIPS MEMBER...";
1620 return $self->provision_ad_member($prefix,
1629 sub setup_ad_member_offlogon
1637 # If we didn't build with ADS, pretend this env was never available
1638 if (not $self->have_ads()) {
1642 print "PROVISIONING AD MEMBER OFFLINE LOGON...";
1644 return $self->provision_ad_member($prefix,
1654 sub setup_ad_member_idmap_nss
1662 # If we didn't build with ADS, pretend this env was never available
1663 if (not $self->have_ads()) {
1667 print "PROVISIONING AD MEMBER WITHOUT NSS WINBIND WITH idmap_nss config...";
1669 my $extra_member_options = "
1670 # bob:x:65521:65531:localbob gecos:/:/bin/false
1671 # jane:x:65520:65531:localjane gecos:/:/bin/false
1672 # jackthemapper:x:65519:65531:localjackthemaper gecos:/:/bin/false
1673 # jacknomapper:x:65518:65531:localjacknomaper gecos:/:/bin/false
1674 idmap config $dcvars->{DOMAIN} : backend = nss
1675 idmap config $dcvars->{DOMAIN} : range = 65518-65521
1677 # Support SMB1 so that we can use posix_whoami().
1678 client min protocol = CORE
1679 server min protocol = LANMAN1
1681 username map = $prefix/lib/username.map
1684 my $ret = $self->provision_ad_member($prefix,
1689 $extra_member_options,
1694 open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map");
1696 !jacknomapper = \@jackthemappergroup
1697 !root = jacknomappergroup
1698 root = $dcvars->{DOMAIN}/root
1699 bob = $dcvars->{DOMAIN}/bob
1706 sub setup_simpleserver
1708 my ($self, $path) = @_;
1710 print "PROVISIONING simple server...";
1712 my $prefix_abs = abs_path($path);
1713 mkdir($prefix_abs, 0777);
1715 my $external_streams_depot="$prefix_abs/external_streams_depot";
1716 remove_tree($external_streams_depot);
1717 mkdir($external_streams_depot, 0777);
1719 my $simpleserver_options = "
1722 vfs objects = xattr_tdb streams_depot
1724 server smb encrypt = off
1725 allow trusted domains = no
1728 path = $prefix_abs/share
1730 vfs objects = aio_pthread
1731 aio_pthread:aio open = yes
1732 smbd async dosmode = no
1734 [vfs_aio_pthread_async_dosmode_default1]
1735 path = $prefix_abs/share
1737 vfs objects = aio_pthread
1738 store dos attributes = yes
1739 aio_pthread:aio open = yes
1740 smbd async dosmode = yes
1742 [vfs_aio_pthread_async_dosmode_default2]
1743 path = $prefix_abs/share
1745 vfs objects = aio_pthread xattr_tdb
1746 store dos attributes = yes
1747 aio_pthread:aio open = yes
1748 smbd async dosmode = yes
1750 [async_dosmode_shadow_copy2]
1751 path = $prefix_abs/share
1753 vfs objects = shadow_copy2 xattr_tdb
1754 smbd async dosmode = yes
1757 path = $prefix_abs/share
1758 vfs objects = aio_fork
1760 vfs_aio_fork:erratic_testing_mode=yes
1763 path = $prefix_abs/share
1765 store dos attributes = yes
1766 hide files = /hidefile/
1767 hide dot files = yes
1770 path = $prefix_abs/share
1771 hide new files timeout = 5
1773 [external_streams_depot]
1774 path = $prefix_abs/share
1776 streams_depot:directory = $external_streams_depot
1779 my $vars = $self->provision(
1781 domain => "WORKGROUP",
1782 server => "LOCALSHARE4",
1783 password => "local4pass",
1784 extra_options => $simpleserver_options);
1786 $vars or return undef;
1788 if (not $self->check_or_start(
1798 sub create_file_chmod($$)
1800 my ($name, $mode) = @_;
1803 unless (open($fh, '>', $name)) {
1804 warn("Unable to open $name");
1810 sub setup_fileserver
1812 my ($self, $path, $more_conf, $server) = @_;
1813 my $prefix_abs = abs_path($path);
1814 my $srcdir_abs = abs_path($self->{srcdir});
1816 print "PROVISIONING file server ...\n";
1820 mkdir($prefix_abs, 0777);
1822 my $usershare_dir="$prefix_abs/lib/usershare";
1824 mkdir("$prefix_abs/lib", 0755);
1825 remove_tree($usershare_dir);
1826 mkdir($usershare_dir, 01770);
1828 my $share_dir="$prefix_abs/share";
1830 # Create share directory structure
1831 my $lower_case_share_dir="$share_dir/lower-case";
1832 push(@dirs, $lower_case_share_dir);
1834 my $lower_case_share_dir_30000="$share_dir/lower-case-30000";
1835 push(@dirs, $lower_case_share_dir_30000);
1837 my $dfree_share_dir="$share_dir/dfree";
1838 push(@dirs, $dfree_share_dir);
1839 push(@dirs, "$dfree_share_dir/subdir1");
1840 push(@dirs, "$dfree_share_dir/subdir2");
1841 push(@dirs, "$dfree_share_dir/subdir3");
1843 my $quotadir_dir="$share_dir/quota";
1844 push(@dirs, $quotadir_dir);
1846 my $valid_users_sharedir="$share_dir/valid_users";
1847 push(@dirs,$valid_users_sharedir);
1849 my $offline_sharedir="$share_dir/offline";
1850 push(@dirs,$offline_sharedir);
1852 my $force_user_valid_users_dir = "$share_dir/force_user_valid_users";
1853 push(@dirs, $force_user_valid_users_dir);
1855 my $tarmode_sharedir="$share_dir/tarmode";
1856 push(@dirs,$tarmode_sharedir);
1858 my $tarmode2_sharedir="$share_dir/tarmode2";
1859 push(@dirs,$tarmode2_sharedir);
1861 my $smbcacls_sharedir="$share_dir/smbcacls";
1862 push(@dirs,$smbcacls_sharedir);
1864 my $usershare_sharedir="$share_dir/usershares";
1865 push(@dirs,$usershare_sharedir);
1867 my $dropbox_sharedir="$share_dir/dropbox";
1868 push(@dirs,$dropbox_sharedir);
1870 my $bad_iconv_sharedir="$share_dir/bad_iconv";
1871 push(@dirs, $bad_iconv_sharedir);
1873 my $veto_sharedir="$share_dir/veto";
1874 push(@dirs,$veto_sharedir);
1876 my $virusfilter_sharedir="$share_dir/virusfilter";
1877 push(@dirs,$virusfilter_sharedir);
1879 my $delete_unwrite_sharedir="$share_dir/delete_unwrite";
1880 push(@dirs,$delete_unwrite_sharedir);
1881 push(@dirs, "$delete_unwrite_sharedir/delete_veto_yes");
1882 push(@dirs, "$delete_unwrite_sharedir/delete_veto_no");
1884 my $volume_serial_number_sharedir="$share_dir/volume_serial_number";
1885 push(@dirs, $volume_serial_number_sharedir);
1887 my $ip4 = Samba::get_ipv4_addr("FILESERVER");
1888 my $fileserver_options = "
1889 smb3 unix extensions = yes
1890 kernel change notify = yes
1891 spotlight backend = elasticsearch
1892 elasticsearch:address = $ip4
1893 elasticsearch:port = 8080
1894 elasticsearch:mappings = $srcdir_abs/source3/rpc_server/mdssvc/elasticsearch_mappings.json
1896 usershare path = $usershare_dir
1897 usershare max shares = 10
1898 usershare allow guests = yes
1899 usershare prefix allow list = $usershare_sharedir
1901 get quota command = $prefix_abs/getset_quota.py
1902 set quota command = $prefix_abs/getset_quota.py
1904 path = $tarmode_sharedir
1905 comment = tar test share
1906 xattr_tdb:file = $prefix_abs/tarmode-xattr.tdb
1908 path = $tarmode2_sharedir
1909 comment = tar test share
1910 xattr_tdb:file = $prefix_abs/tarmode2-xattr.tdb
1920 path = $lower_case_share_dir
1921 comment = smb username is [%U]
1922 case sensitive = True
1923 default case = lower
1925 short preserve case = no
1927 path = $lower_case_share_dir_30000
1928 comment = smb username is [%U]
1929 case sensitive = True
1930 default case = lower
1932 short preserve case = no
1934 path = $dfree_share_dir
1935 comment = smb username is [%U]
1936 dfree command = $srcdir_abs/testprogs/blackbox/dfree.sh
1937 [valid-users-access]
1938 path = $valid_users_sharedir
1939 valid users = +userdup
1941 path = $offline_sharedir
1942 vfs objects = offline
1944 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878
1945 # RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651
1946 [force_user_valid_users]
1947 path = $force_user_valid_users_dir
1948 comment = force user with valid users combination test share
1949 valid users = +force_user
1950 force user = force_user
1951 force group = everyone
1952 write list = force_user
1956 comment = ignore system acls
1957 acl_xattr:ignore system acls = yes
1960 comment = inherit owner
1964 comment = inherit only unix owner
1965 inherit owner = unix only
1966 acl_xattr:ignore system acls = yes
1967 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=13690
1970 comment = force group test
1971 # force group = everyone
1975 comment = smb username is [%U]
1977 force create mode = 0664
1978 vfs objects = dirsort
1981 path = $dropbox_sharedir
1982 comment = smb username is [%U]
1987 path = $bad_iconv_sharedir
1988 comment = smb username is [%U]
1991 [veto_files_nodelete]
1992 path = $veto_sharedir
1995 veto files = /veto_name*/
1996 delete veto files = no
1999 path = $veto_sharedir
2001 veto files = /veto_name*/
2002 delete veto files = yes
2004 [delete_veto_files_only]
2005 path = $veto_sharedir
2006 delete veto files = yes
2008 [veto_files_nohidden]
2009 path = $veto_sharedir
2013 path = $veto_sharedir
2014 veto files = /veto_name*/
2016 [delete_yes_unwrite]
2018 path = $delete_unwrite_sharedir
2019 hide unwriteable files = yes
2020 delete veto files = yes
2024 path = $delete_unwrite_sharedir
2025 hide unwriteable files = yes
2026 delete veto files = no
2029 path = $virusfilter_sharedir
2030 vfs objects = acl_xattr virusfilter
2031 virusfilter:scanner = dummy
2032 virusfilter:min file size = 0
2033 virusfilter:infected files = *infected*
2034 virusfilter:infected file action = rename
2035 virusfilter:scan on close = yes
2036 vfs_default:VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS = no
2038 [volumeserialnumber]
2039 path = $volume_serial_number_sharedir
2040 volume serial number = 0xdeadbeef
2044 vfs objects = acl_xattr
2045 acl_xattr:security_acl_name = user.hackme
2050 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot time_audit full_audit io_uring
2054 comment = Home directories
2059 if (defined($more_conf)) {
2060 $fileserver_options = $fileserver_options . $more_conf;
2062 if (!defined($server)) {
2063 $server = "FILESERVER";
2066 my $vars = $self->provision(
2068 domain => "WORKGROUP",
2070 password => "fileserver",
2071 extra_options => $fileserver_options,
2072 no_delete_prefix => 1);
2074 $vars or return undef;
2076 if (not $self->check_or_start(
2084 mkdir($_, 0777) foreach(@dirs);
2086 ## Create case sensitive lower case share dir
2087 foreach my $file ('a'..'z') {
2088 my $full_path = $lower_case_share_dir . '/' . $file;
2089 open my $fh, '>', $full_path;
2090 # Add some content to file
2091 print $fh $full_path;
2095 for (my $file = 1; $file < 51; ++$file) {
2096 my $full_path = $lower_case_share_dir . '/' . $file;
2097 open my $fh, '>', $full_path;
2098 # Add some content to file
2099 print $fh $full_path;
2103 # Create content for 30000 share
2104 foreach my $file ('a'..'z') {
2105 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
2106 open my $fh, '>', $full_path;
2107 # Add some content to file
2108 print $fh $full_path;
2112 for (my $file = 1; $file < 30001; ++$file) {
2113 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
2114 open my $fh, '>', $full_path;
2115 # Add some content to file
2116 print $fh $full_path;
2121 ## create a listable file in valid_users_share
2123 create_file_chmod("$valid_users_sharedir/foo", 0644) or return undef;
2126 ## create a valid utf8 filename which is invalid as a CP850 conversion
2128 create_file_chmod("$bad_iconv_sharedir/\xED\x9F\xBF", 0644) or return undef;
2131 ## create unwritable files inside inside the delete unwrite veto share dirs.
2133 unlink("$delete_unwrite_sharedir/delete_veto_yes/file_444");
2134 create_file_chmod("$delete_unwrite_sharedir/delete_veto_yes/file_444", 0444) or return undef;
2135 unlink("$delete_unwrite_sharedir/delete_veto_no/file_444");
2136 create_file_chmod("$delete_unwrite_sharedir/delete_veto_no/file_444", 0444) or return undef;
2141 sub setup_fileserver_smb1
2143 my ($self, $path) = @_;
2144 my $prefix_abs = abs_path($path);
2147 client min protocol = CORE
2148 server min protocol = LANMAN1
2149 check parent directory delete on close = yes
2152 path = $prefix_abs/share
2153 hide new files timeout = 5
2155 path = $prefix_abs/share
2157 vfs objects = aio_pthread
2158 aio_pthread:aio open = yes
2159 smbd async dosmode = no
2161 [vfs_aio_pthread_async_dosmode_default1]
2162 path = $prefix_abs/share
2164 vfs objects = aio_pthread
2165 store dos attributes = yes
2166 aio_pthread:aio open = yes
2167 smbd async dosmode = yes
2169 [vfs_aio_pthread_async_dosmode_default2]
2170 path = $prefix_abs/share
2172 vfs objects = aio_pthread xattr_tdb
2173 store dos attributes = yes
2174 aio_pthread:aio open = yes
2175 smbd async dosmode = yes
2178 path = $prefix_abs/share
2179 vfs objects = aio_fork
2181 vfs_aio_fork:erratic_testing_mode=yes
2183 return $self->setup_fileserver($path, $conf, "FILESERVERSMB1");
2186 sub setup_fileserver_smb1_done
2188 my ($self, $path, $dep_env) = @_;
2189 return $self->return_alias_env($path, $dep_env);
2194 my ($self, $prefix) = @_;
2196 # If we didn't build with ADS, pretend this env was never available
2197 if (not $self->have_ads()) {
2201 print "PROVISIONING server with security=ads...";
2203 my $ktest_options = "
2205 realm = ktest.samba.example.com
2207 server signing = required
2208 server min protocol = SMB3_00
2209 client max protocol = SMB3
2211 # This disables NTLM auth against the local SAM, which
2212 # we use can then test this setting by.
2213 ntlm auth = disabled
2215 idmap config * : backend = autorid
2216 idmap config * : range = 1000000-1999999
2217 idmap config * : rangesize = 100000
2220 my $ret = $self->provision(
2223 server => "LOCALKTEST6",
2224 password => "localktest6pass",
2225 extra_options => $ktest_options);
2227 $ret or return undef;
2230 my $prefix_abs = abs_path($prefix);
2232 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
2233 $ctx->{domain} = "KTEST";
2234 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
2235 $ctx->{dnsname} = lc($ctx->{realm});
2236 $ctx->{kdc_ipv4} = "0.0.0.0";
2237 $ctx->{kdc_ipv6} = "::";
2238 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
2239 Samba::mk_krb5_conf($ctx, "");
2241 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
2243 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
2244 #Samba4 DC with the same parameters as are being used here. The
2245 #domain SID is S-1-5-21-1071277805-689288055-3486227160
2246 $ret->{SAMSID} = "S-1-5-21-1911091480-1468226576-2729736297";
2247 $ret->{DOMSID} = "S-1-5-21-1071277805-689288055-3486227160";
2249 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
2250 chmod 0600, "$prefix/private/secrets.tdb";
2252 #Make sure there's no old ntdb file.
2253 system("rm -f $prefix/private/secrets.ntdb");
2255 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
2256 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
2258 #and having in krb5.conf:
2259 # ticket_lifetime = 799718400
2260 # renew_lifetime = 799718400
2262 # The commands for the -2 keytab where were:
2263 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
2264 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
2265 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
2266 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
2267 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
2269 # and then for the -3 keytab, I did
2271 # net changetrustpw; kdestroy and the same again.
2273 # This creates a credential cache with a very long lifetime (2036 at
2274 # at 2011-04), and shows that running 'net changetrustpw' does not
2275 # break existing logins (for the secrets.tdb method at least).
2278 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
2280 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
2281 chmod 0600, "$prefix/krb5_ccache-2";
2283 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
2284 chmod 0600, "$prefix/krb5_ccache-3";
2286 # We need world access to this share, as otherwise the domain
2287 # administrator from the AD domain provided by ktest can't
2288 # access the share for tests.
2289 chmod 0777, "$prefix/share";
2291 if (not $self->check_or_start(
2294 winbindd => "offline",
2301 sub setup_maptoguest
2303 my ($self, $path) = @_;
2304 my $prefix_abs = abs_path($path);
2305 my $libdir="$prefix_abs/lib";
2306 my $share_dir="$prefix_abs/share";
2307 my $errorinjectconf="$libdir/error_inject.conf";
2309 print "PROVISIONING maptoguest...";
2313 map to guest = bad user
2315 server min protocol = LANMAN1
2317 [force_user_error_inject]
2319 vfs objects = acl_xattr fake_acls xattr_tdb error_inject
2321 include = $errorinjectconf
2324 my $vars = $self->provision(
2326 domain => "WORKGROUP",
2327 server => "maptoguest",
2328 password => "maptoguestpass",
2329 extra_options => $options);
2331 $vars or return undef;
2333 if (not $self->check_or_start(
2344 sub stop_sig_term($$) {
2345 my ($self, $pid) = @_;
2346 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
2349 sub stop_sig_kill($$) {
2350 my ($self, $pid) = @_;
2351 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
2356 my ($env_vars, $app, $pid) = @_;
2358 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
2365 my ($env_vars, $app) = @_;
2367 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
2373 # builds up the cmd args to run an s3 binary (i.e. smbd, nmbd, etc)
2376 my ($self, $binary, $env_vars, $options, $valgrind, $dont_log_stdout) = @_;
2379 if (defined($options)) {
2380 @optargs = split(/ /, $options);
2382 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
2384 if (defined($valgrind)) {
2385 @preargs = split(/ /, $valgrind);
2387 my @args = ("-F", "--no-process-group",
2388 "--configfile=$env_vars->{SERVERCONFFILE}",
2389 "-l", $env_vars->{LOGDIR});
2391 if (not defined($dont_log_stdout)) {
2392 push(@args, "--debug-stdout");
2394 return (@preargs, $binary, @args, @optargs);
2397 sub check_or_start($$) {
2398 my ($self, %args) = @_;
2399 my $env_vars = $args{env_vars};
2400 my $nmbd = $args{nmbd} // "no";
2401 my $winbindd = $args{winbindd} // "no";
2402 my $smbd = $args{smbd} // "no";
2403 my $samba_dcerpcd = $args{samba_dcerpcd} // "no";
2404 my $child_cleanup = $args{child_cleanup};
2408 # use a pipe for stdin in the child processes. This allows
2409 # those processes to monitor the pipe for EOF to ensure they
2410 # exit when the test script exits
2411 pipe($STDIN_READER, $env_vars->{STDIN_PIPE});
2413 my $binary = Samba::bindir_path($self, "samba-dcerpcd");
2414 my @full_cmd = $self->make_bin_cmd(
2417 $ENV{SAMBA_DCERPCD_OPTIONS},
2418 $ENV{SAMBA_DCERPCD_VALGRIND},
2419 $ENV{SAMBA_DCERPCD_DONT_LOG_STDOUT});
2420 push(@full_cmd, '--libexec-rpcds');
2422 my $samba_dcerpcd_envs = Samba::get_env_for_process(
2423 "samba_dcerpcd", $env_vars);
2425 # fork and exec() samba_dcerpcd in the child process
2427 NAME => "samba_dcerpcd",
2428 BINARY_PATH => $binary,
2429 FULL_CMD => [ @full_cmd ],
2430 LOG_FILE => $env_vars->{SAMBA_DCERPCD_TEST_LOG},
2431 PCAP_FILE => "env-$ENV{ENVNAME}-samba_dcerpcd",
2432 ENV_VARS => $samba_dcerpcd_envs,
2434 if ($samba_dcerpcd ne "yes") {
2435 $daemon_ctx->{SKIP_DAEMON} = 1;
2438 my $pid = Samba::fork_and_exec(
2439 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
2441 $env_vars->{SAMBA_DCERPCD_TL_PID} = $pid;
2442 write_pid($env_vars, "samba_dcerpcd", $pid);
2444 $binary = Samba::bindir_path($self, "nmbd");
2445 @full_cmd = $self->make_bin_cmd($binary, $env_vars,
2446 $ENV{NMBD_OPTIONS}, $ENV{NMBD_VALGRIND},
2447 $ENV{NMBD_DONT_LOG_STDOUT});
2448 my $nmbd_envs = Samba::get_env_for_process("nmbd", $env_vars);
2449 delete $nmbd_envs->{RESOLV_WRAPPER_CONF};
2450 delete $nmbd_envs->{RESOLV_WRAPPER_HOSTS};
2452 # fork and exec() nmbd in the child process
2455 BINARY_PATH => $binary,
2456 FULL_CMD => [ @full_cmd ],
2457 LOG_FILE => $env_vars->{NMBD_TEST_LOG},
2458 PCAP_FILE => "env-$ENV{ENVNAME}-nmbd",
2459 ENV_VARS => $nmbd_envs,
2461 if ($nmbd ne "yes") {
2462 $daemon_ctx->{SKIP_DAEMON} = 1;
2464 $pid = Samba::fork_and_exec(
2465 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
2467 $env_vars->{NMBD_TL_PID} = $pid;
2468 write_pid($env_vars, "nmbd", $pid);
2470 $binary = Samba::bindir_path($self, "winbindd");
2471 @full_cmd = $self->make_bin_cmd($binary, $env_vars,
2472 $ENV{WINBINDD_OPTIONS},
2473 $ENV{WINBINDD_VALGRIND},
2474 $ENV{WINBINDD_DONT_LOG_STDOUT});
2476 # fork and exec() winbindd in the child process
2479 BINARY_PATH => $binary,
2480 FULL_CMD => [ @full_cmd ],
2481 LOG_FILE => $env_vars->{WINBINDD_TEST_LOG},
2482 PCAP_FILE => "env-$ENV{ENVNAME}-winbindd",
2484 if ($winbindd ne "yes" and $winbindd ne "offline") {
2485 $daemon_ctx->{SKIP_DAEMON} = 1;
2488 $pid = Samba::fork_and_exec(
2489 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
2491 $env_vars->{WINBINDD_TL_PID} = $pid;
2492 write_pid($env_vars, "winbindd", $pid);
2494 $binary = Samba::bindir_path($self, "smbd");
2495 @full_cmd = $self->make_bin_cmd($binary, $env_vars,
2496 $ENV{SMBD_OPTIONS}, $ENV{SMBD_VALGRIND},
2497 $ENV{SMBD_DONT_LOG_STDOUT});
2499 # fork and exec() smbd in the child process
2502 BINARY_PATH => $binary,
2503 FULL_CMD => [ @full_cmd ],
2504 LOG_FILE => $env_vars->{SMBD_TEST_LOG},
2505 PCAP_FILE => "env-$ENV{ENVNAME}-smbd",
2507 if ($smbd ne "yes") {
2508 $daemon_ctx->{SKIP_DAEMON} = 1;
2511 $pid = Samba::fork_and_exec(
2512 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
2514 $env_vars->{SMBD_TL_PID} = $pid;
2515 write_pid($env_vars, "smbd", $pid);
2517 # close the parent's read-end of the pipe
2518 close($STDIN_READER);
2520 return $self->wait_for_start($env_vars,
2527 sub createuser($$$$$)
2529 my ($self, $username, $password, $conffile, $env) = @_;
2530 my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $username > /dev/null";
2533 while(my($var, $val) = each %$env) {
2534 $cmd = "$var=\"$val\" $cmd";
2537 unless (open(PWD, "|$cmd")) {
2538 warn("Unable to set password for $username account\n$cmd");
2541 print PWD "$password\n$password\n";
2542 unless (close(PWD)) {
2543 warn("Unable to set password for $username account\n$cmd");
2550 my ($self, %args) = @_;
2552 my $prefix = $args{prefix};
2553 my $domain = $args{domain};
2554 my $realm = $args{realm};
2555 my $server = $args{server};
2556 my $password = $args{password};
2557 my $extra_options = $args{extra_options};
2558 my $resolv_conf = $args{resolv_conf};
2559 my $no_delete_prefix= $args{no_delete_prefix};
2560 my $netbios_name = $args{netbios_name} // $server;
2561 my $server_log_level = $ENV{SERVER_LOG_LEVEL} || 1;
2564 ## setup the various environment variables we need
2567 my $samsid = Samba::random_domain_sid();
2568 my $swiface = Samba::get_interface($server);
2570 my %createuser_env = ();
2571 my $server_ip = Samba::get_ipv4_addr($server);
2572 my $server_ipv6 = Samba::get_ipv6_addr($server);
2574 if (defined($realm)) {
2575 $dns_domain = lc($realm);
2577 $dns_domain = "samba.example.com";
2580 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
2583 my $unix_gids_str = $);
2584 my @unix_gids = split(" ", $unix_gids_str);
2586 my $prefix_abs = abs_path($prefix);
2587 my $bindir_abs = abs_path($self->{bindir});
2591 my $shrdir=$args{share_dir} // "$prefix_abs/share";
2592 push(@dirs,$shrdir);
2594 my $libdir="$prefix_abs/lib";
2595 push(@dirs,$libdir);
2597 my $piddir="$prefix_abs/pid";
2598 push(@dirs,$piddir);
2600 my $privatedir="$prefix_abs/private";
2601 push(@dirs,$privatedir);
2603 my $cachedir = "$prefix_abs/cachedir";
2604 push(@dirs, $cachedir);
2606 my $binddnsdir = "$prefix_abs/bind-dns";
2607 push(@dirs, $binddnsdir);
2609 my $lockdir="$prefix_abs/lockdir";
2610 push(@dirs,$lockdir);
2612 my $eventlogdir="$prefix_abs/lockdir/eventlog";
2613 push(@dirs,$eventlogdir);
2615 my $logdir="$prefix_abs/logs";
2616 push(@dirs,$logdir);
2618 my $driver32dir="$shrdir/W32X86";
2619 push(@dirs,$driver32dir);
2621 my $driver64dir="$shrdir/x64";
2622 push(@dirs,$driver64dir);
2624 my $driver40dir="$shrdir/WIN40";
2625 push(@dirs,$driver40dir);
2627 my $ro_shrdir="$shrdir/root-tmp";
2628 push(@dirs,$ro_shrdir);
2630 my $noperm_shrdir="$shrdir/noperm-tmp";
2631 push(@dirs,$noperm_shrdir);
2633 my $msdfs_shrdir="$shrdir/msdfsshare";
2634 push(@dirs,$msdfs_shrdir);
2636 my $msdfs_shrdir2="$shrdir/msdfsshare2";
2637 push(@dirs,$msdfs_shrdir2);
2639 my $msdfs_pathname_share="$shrdir/msdfs_pathname_share";
2640 push(@dirs,$msdfs_pathname_share);
2642 my $non_msdfs_pathname_share="$shrdir/non_msdfs_pathname_share";
2643 push(@dirs,$non_msdfs_pathname_share);
2645 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
2646 push(@dirs,$msdfs_deeppath);
2648 my $smbcacls_sharedir_dfs="$shrdir/smbcacls_sharedir_dfs";
2649 push(@dirs,$smbcacls_sharedir_dfs);
2651 my $smbcacls_share="$shrdir/smbcacls_share";
2652 push(@dirs,$smbcacls_share);
2654 my $smbcacls_share_testdir="$shrdir/smbcacls_share/smbcacls";
2655 push(@dirs,$smbcacls_share_testdir);
2657 my $badnames_shrdir="$shrdir/badnames";
2658 push(@dirs,$badnames_shrdir);
2660 my $lease1_shrdir="$shrdir/dynamic";
2661 push(@dirs,$lease1_shrdir);
2663 my $manglenames_shrdir="$shrdir/manglenames";
2664 push(@dirs,$manglenames_shrdir);
2666 my $widelinks_shrdir="$shrdir/widelinks";
2667 push(@dirs,$widelinks_shrdir);
2669 my $widelinks_linkdir="$shrdir/widelinks_foo";
2670 push(@dirs,$widelinks_linkdir);
2672 my $fsrvp_shrdir="$shrdir/fsrvp";
2673 push(@dirs,$fsrvp_shrdir);
2675 my $shadow_tstdir="$shrdir/shadow";
2676 push(@dirs,$shadow_tstdir);
2677 my $shadow_mntdir="$shadow_tstdir/mount";
2678 push(@dirs,$shadow_mntdir);
2679 my $shadow_basedir="$shadow_mntdir/base";
2680 push(@dirs,$shadow_basedir);
2681 my $shadow_shrdir="$shadow_basedir/share";
2682 push(@dirs,$shadow_shrdir);
2684 my $nosymlinks_shrdir="$shrdir/nosymlinks";
2685 push(@dirs,$nosymlinks_shrdir);
2687 my $local_symlinks_shrdir="$shrdir/local_symlinks";
2688 push(@dirs,$local_symlinks_shrdir);
2690 my $worm_shrdir="$shrdir/worm";
2691 push(@dirs,$worm_shrdir);
2693 my $fruit_resource_stream_shrdir="$shrdir/fruit_resource_stream";
2694 push(@dirs,$fruit_resource_stream_shrdir);
2696 my $smbget_sharedir="$shrdir/smbget";
2697 push(@dirs, $smbget_sharedir);
2699 my $recycle_shrdir="$shrdir/recycle";
2700 push(@dirs,$recycle_shrdir);
2702 my $fakedircreatetimes_shrdir="$shrdir/fakedircreatetimes";
2703 push(@dirs,$fakedircreatetimes_shrdir);
2705 # this gets autocreated by winbindd
2706 my $wbsockdir="$prefix_abs/wbsock";
2708 my $nmbdsockdir="$prefix_abs/nmbd";
2709 unlink($nmbdsockdir);
2712 ## create the test directory layout
2714 die ("prefix_abs = ''") if $prefix_abs eq "";
2715 die ("prefix_abs = '/'") if $prefix_abs eq "/";
2717 mkdir($prefix_abs, 0777);
2718 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
2719 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
2720 system("rm -rf $prefix_abs/*");
2722 mkdir($_, 0777) foreach(@dirs);
2724 my $fs_specific_conf = $self->get_fs_specific_conf($shrdir);
2727 ## lockdir and piddir must be 0755
2729 chmod 0755, $lockdir;
2730 chmod 0755, $piddir;
2734 ## Create a directory without permissions to enter
2736 chmod 0000, $noperm_shrdir;
2739 ## create ro and msdfs share layout
2742 chmod 0755, $ro_shrdir;
2744 create_file_chmod("$ro_shrdir/readable_file", 0644) or return undef;
2745 create_file_chmod("$ro_shrdir/unreadable_file", 0600) or return undef;
2747 create_file_chmod("$ro_shrdir/msdfs-target", 0600) or return undef;
2748 symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp",
2749 "$msdfs_shrdir/msdfs-src1";
2750 symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
2751 symlink "msdfs:$server_ip\\smbcacls_sharedir_dfs,$server_ipv6\\smbcacls_sharedir_dfs",
2752 "$msdfs_shrdir/smbcacls_sharedir_dfs";
2754 symlink "msdfs:$server_ip\\msdfs-share2,$server_ipv6\\msdfs-share2", "$msdfs_shrdir/dfshop1";
2755 symlink "msdfs:$server_ip\\tmp,$server_ipv6\\tmp", "$msdfs_shrdir2/dfshop2";
2757 ## create bad names in $badnames_shrdir
2759 ## (An invalid name, would be mangled to 8.3).
2760 create_file_chmod("$badnames_shrdir/\340|\231\216\377\177",
2761 0600) or return undef;
2763 ## (A bad name, would not be mangled to 8.3).
2764 create_file_chmod("$badnames_shrdir/\240\276\346\327\377\177",
2765 0666) or return undef;
2767 ## (A bad good name).
2768 create_file_chmod("$badnames_shrdir/blank.txt",
2769 0666) or return undef;
2772 ## create mangleable directory names in $manglenames_shrdir
2774 my $manglename_target = "$manglenames_shrdir/foo:bar";
2775 mkdir($manglename_target, 0777);
2778 ## create symlinks for widelinks tests.
2780 my $widelinks_target = "$widelinks_linkdir/target";
2781 create_file_chmod("$widelinks_target", 0666) or return undef;
2784 ## This link should get an error
2786 symlink "$widelinks_target", "$widelinks_shrdir/source";
2788 ## This link should be allowed
2790 symlink "$widelinks_shrdir", "$widelinks_shrdir/dot";
2792 my $conffile="$libdir/server.conf";
2793 my $dfqconffile="$libdir/dfq.conf";
2794 my $errorinjectconf="$libdir/error_inject.conf";
2795 my $delayinjectconf="$libdir/delay_inject.conf";
2796 my $globalinjectconf="$libdir/global_inject.conf";
2797 my $aliceconfdir="$libdir";
2798 my $aliceconffile="$libdir/alice.conf";
2800 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/third_party/nss_wrapper/nss_wrapper.pl";
2801 my $nss_wrapper_passwd = "$privatedir/passwd";
2802 my $nss_wrapper_group = "$privatedir/group";
2803 my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts";
2804 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
2806 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
2808 my $fake_snap_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/fake_snap.pl";
2810 my @eventlog_list = ("dns server", "application");
2813 ## calculate uids and gids
2816 my ($max_uid, $max_gid);
2817 my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
2818 my ($uid_pdbtest_wkn);
2820 my ($uid_force_user);
2821 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
2822 my ($gid_userdup, $gid_everyone);
2823 my ($gid_force_user);
2824 my ($gid_jackthemapper);
2825 my ($gid_jacknomapper);
2830 my ($uid_slashuser);
2832 my ($uid_localjane);
2833 my ($uid_localjackthemapper);
2834 my ($uid_localjacknomapper);
2836 if ($unix_uid < 0xffff - 13) {
2839 $max_uid = $unix_uid;
2842 $uid_root = $max_uid - 1;
2843 $uid_nobody = $max_uid - 2;
2844 $uid_pdbtest = $max_uid - 3;
2845 $uid_pdbtest2 = $max_uid - 4;
2846 $uid_userdup = $max_uid - 5;
2847 $uid_pdbtest_wkn = $max_uid - 6;
2848 $uid_force_user = $max_uid - 7;
2849 $uid_smbget = $max_uid - 8;
2850 $uid_user1 = $max_uid - 9;
2851 $uid_user2 = $max_uid - 10;
2852 $uid_gooduser = $max_uid - 11;
2853 $uid_eviluser = $max_uid - 12;
2854 $uid_slashuser = $max_uid - 13;
2855 $uid_localbob = $max_uid - 14;
2856 $uid_localjane = $max_uid - 15;
2857 $uid_localjackthemapper = $max_uid - 16;
2858 $uid_localjacknomapper = $max_uid - 17;
2860 if ($unix_gids[0] < 0xffff - 8) {
2863 $max_gid = $unix_gids[0];
2866 $gid_nobody = $max_gid - 1;
2867 $gid_nogroup = $max_gid - 2;
2868 $gid_root = $max_gid - 3;
2869 $gid_domusers = $max_gid - 4;
2870 $gid_domadmins = $max_gid - 5;
2871 $gid_userdup = $max_gid - 6;
2872 $gid_everyone = $max_gid - 7;
2873 $gid_force_user = $max_gid - 8;
2874 $gid_jackthemapper = $max_gid - 9;
2875 $gid_jacknomapper = $max_gid - 10;
2881 unless (open(CONF, ">$conffile")) {
2882 warn("Unable to open $conffile");
2886 my $interfaces = Samba::get_interfaces_config($server);
2890 dcesrv:fuzz directory = $cachedir/fuzz
2891 netbios name = $netbios_name
2892 interfaces = $interfaces
2893 bind interfaces only = yes
2894 panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
2895 smbd:suicide mode = yes
2896 smbd:FSCTL_SMBTORTURE = yes
2897 smbd:validate_oplock_types = yes
2899 client min protocol = SMB2_02
2900 server min protocol = SMB2_02
2902 server multi channel support = yes
2906 private dir = $privatedir
2907 binddns dir = $binddnsdir
2908 pid directory = $piddir
2909 lock directory = $lockdir
2910 log file = $logdir/log.\%m
2911 log level = $server_log_level
2912 winbind debug traceid = yes
2916 debug syslog format = always
2917 debug hires timestamp = yes
2919 state directory = $lockdir
2920 cache directory = $lockdir
2922 passdb backend = tdbsam
2926 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
2927 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
2928 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
2929 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
2930 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
2931 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
2932 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
2934 addprinter command = $mod_printer_pl -a -s $conffile --
2935 deleteprinter command = $mod_printer_pl -d -s $conffile --
2937 eventlog list = application \"dns server\"
2940 kernel change notify = no
2944 printcap name = /dev/null
2946 winbindd socket directory = $wbsockdir
2947 nmbd:socket dir = $nmbdsockdir
2948 idmap config * : range = 100000-200000
2949 winbind enum users = yes
2950 winbind enum groups = yes
2951 winbind separator = /
2952 include system krb5 conf = no
2954 # min receivefile size = 4000
2958 smbd:sharedelay = 100000
2959 smbd:writetimeupdatedelay = 500000
2963 store dos attributes = yes
2969 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot time_audit full_audit
2971 full_audit:syslog = no
2972 full_audit:success = none
2973 full_audit:failure = none
2976 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
2977 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
2978 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
2979 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
2980 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
2981 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
2982 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
2984 print notify backchannel = yes
2986 ncalrpc dir = $prefix_abs/ncalrpc
2988 # The samba3.blackbox.smbclient_s3 test uses this to test that
2989 # sending messages works, and that the %m sub works.
2990 message command = mv %s $shrdir/message.%m
2992 # fsrvp server requires registry shares
2993 registry shares = yes
2995 # Used by RPC SRVSVC tests
2996 add share command = $bindir_abs/smbaddshare
2997 change share command = $bindir_abs/smbchangeshare
2998 delete share command = $bindir_abs/smbdeleteshare
3000 # fruit:copyfile is a global option
3001 fruit:copyfile = yes
3003 #this does not mean that we use non-secure test env,
3004 #it just means we ALLOW one to be configured.
3005 allow insecure wide links = yes
3007 include = $globalinjectconf
3009 # Begin extra options
3013 #Include user defined custom parameters if set
3016 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
3017 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
3022 path = $smbcacls_share
3023 comment = smb username is [%U]
3026 [smbcacls_sharedir_dfs]
3027 path = $smbcacls_sharedir_dfs
3028 comment = smb username is [%U]
3031 comment = smb username is [%U]
3034 comment = Load dirsort module
3035 vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot
3038 comment = encrypt smb username is [%U]
3039 server smb encrypt = required
3040 vfs objects = dirsort
3050 force user = $unix_name
3052 [forceuser_unixonly]
3053 comment = force a user with unix user SID and group SID
3055 force user = pdbtest
3057 [forceuser_wkngroup]
3058 comment = force a user with well-known group SID
3060 force user = pdbtest_wkn
3064 force group = nogroup
3070 path = $noperm_shrdir
3076 write list = $unix_name
3079 valid users = $unix_name
3080 access based share enum = yes
3082 path = $msdfs_shrdir
3084 msdfs shuffle referrals = yes
3087 path = $msdfs_shrdir
3092 path = $msdfs_shrdir2
3095 [msdfs-pathname-share]
3096 path = $msdfs_pathname_share
3099 [non-msdfs-pathname-share]
3100 path = $non_msdfs_pathname_share
3105 hide unreadable = yes
3108 case sensitive = yes
3111 hide unwriteable files = yes
3114 kernel share modes = no
3128 default devmode = no
3132 print command = $self->{srcdir}/source3/script/tests/printing/printing_var_exp_lpr_cmd.sh \"Windows user: %U\" \"UNIX user: %u\" \"Domain: %D\"
3139 comment = smb username is [%U]
3141 nfs4acl_xattr:version = 40
3142 vfs objects = nfs4acl_xattr xattr_tdb
3144 [nfs4acl_special_40]
3146 comment = smb username is [%U]
3148 nfs4acl_xattr:version = 40
3149 vfs objects = nfs4acl_xattr xattr_tdb
3153 comment = smb username is [%U]
3155 vfs objects = nfs4acl_xattr xattr_tdb
3159 comment = smb username is [%U]
3160 vfs objects = nfs4acl_xattr xattr_tdb
3162 nfs4acl_xattr:encoding = xdr
3163 nfs4acl_xattr:version = 40
3167 comment = smb username is [%U]
3168 vfs objects = nfs4acl_xattr xattr_tdb
3170 nfs4acl_xattr:encoding = xdr
3171 nfs4acl_xattr:version = 41
3175 comment = smb username is [%U]
3176 vfs objects = nfs4acl_xattr xattr_tdb
3178 nfs4acl_xattr:encoding = nfs
3179 nfs4acl_xattr:version = 40
3180 nfs4acl_xattr:xattr_name = security.nfs4acl_xdr
3184 comment = smb username is [%U]
3185 vfs objects = nfs4acl_xattr xattr_tdb
3187 nfs4acl_xattr:encoding = nfs
3188 nfs4acl_xattr:version = 41
3189 nfs4acl_xattr:xattr_name = security.nfs4acl_xdr
3193 comment = smb username is [%U]
3195 force create mode = 777
3198 comment = smb username is [%U]
3200 force create mode = 0
3201 directory mask = 0777
3202 force directory mode = 0
3203 vfs objects = xattr_tdb streams_depot
3205 vfs objects = fake_acls xattr_tdb streams_depot time_audit full_audit
3207 directory mask = 07777
3222 vfs objects = catia fruit streams_xattr acl_xattr xattr_tdb
3223 fruit:resource = file
3224 fruit:metadata = netatalk
3225 fruit:locking = netatalk
3226 fruit:encoding = native
3227 fruit:veto_appledouble = no
3231 # This is used by vfs.fruit tests that require real fs xattr
3232 vfs objects = catia fruit streams_xattr acl_xattr
3233 fruit:resource = file
3234 fruit:metadata = netatalk
3235 fruit:locking = netatalk
3236 fruit:encoding = native
3237 fruit:veto_appledouble = no
3239 [vfs_fruit_metadata_stream]
3241 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3242 fruit:resource = file
3243 fruit:metadata = stream
3244 fruit:veto_appledouble = no
3246 [vfs_fruit_stream_depot]
3248 vfs objects = fruit streams_depot acl_xattr xattr_tdb
3249 fruit:resource = stream
3250 fruit:metadata = stream
3251 fruit:veto_appledouble = no
3255 vfs objects = streams_xattr acl_xattr xattr_tdb
3257 [vfs_wo_fruit_stream_depot]
3259 vfs objects = streams_depot acl_xattr xattr_tdb
3261 [vfs_fruit_timemachine]
3263 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3264 fruit:resource = file
3265 fruit:metadata = stream
3266 fruit:time machine = yes
3267 fruit:time machine max size = 32K
3269 [vfs_fruit_wipe_intentionally_left_blank_rfork]
3271 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3272 fruit:resource = file
3273 fruit:metadata = stream
3274 fruit:wipe_intentionally_left_blank_rfork = true
3275 fruit:delete_empty_adfiles = false
3276 fruit:veto_appledouble = no
3278 [vfs_fruit_delete_empty_adfiles]
3280 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3281 fruit:resource = file
3282 fruit:metadata = stream
3283 fruit:wipe_intentionally_left_blank_rfork = true
3284 fruit:delete_empty_adfiles = true
3285 fruit:veto_appledouble = no
3287 [vfs_fruit_zero_fileid]
3289 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3290 fruit:resource = file
3291 fruit:metadata = stream
3292 fruit:zero_file_id=yes
3293 fruit:validate_afpinfo = no
3295 [fruit_resource_stream]
3296 path = $fruit_resource_stream_shrdir
3297 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3298 fruit:resource = stream
3299 fruit:metadata = stream
3302 path = $badnames_shrdir
3306 path = $manglenames_shrdir
3310 path = $shrdir/dynamic/%t
3312 root preexec = mkdir %P
3315 path = $widelinks_shrdir
3320 path = $fsrvp_shrdir
3321 comment = fake snapshots using rsync
3322 vfs objects = shell_snap shadow_copy2
3323 shell_snap:check path command = $fake_snap_pl --check
3324 shell_snap:create command = $fake_snap_pl --create
3325 shell_snap:delete command = $fake_snap_pl --delete
3326 # a relative path here fails, the snapshot dir is no longer found
3327 shadow:snapdir = $fsrvp_shrdir/.snapshots
3330 path = $shadow_shrdir
3331 comment = previous versions snapshots under mount point
3332 vfs objects = shadow_copy2
3333 shadow:mountpoint = $shadow_mntdir
3336 path = $shadow_shrdir
3337 comment = previous versions snapshots outside mount point
3338 vfs objects = shadow_copy2
3339 shadow:mountpoint = $shadow_mntdir
3340 shadow:snapdir = $shadow_tstdir/.snapshots
3343 path = $shadow_shrdir
3344 comment = previous versions with subvolume snapshots, snapshots under base dir
3345 vfs objects = shadow_copy2
3346 shadow:mountpoint = $shadow_mntdir
3347 shadow:basedir = $shadow_basedir
3348 shadow:snapdir = $shadow_basedir/.snapshots
3351 path = $shadow_shrdir
3352 comment = previous versions with subvolume snapshots, snapshots outside mount point
3353 vfs objects = shadow_copy2
3354 shadow:mountpoint = $shadow_mntdir
3355 shadow:basedir = $shadow_basedir
3356 shadow:snapdir = $shadow_tstdir/.snapshots
3359 path = $shadow_shrdir
3360 comment = previous versions at volume root snapshots under mount point
3361 vfs objects = shadow_copy2
3362 shadow:mountpoint = $shadow_shrdir
3365 path = $shadow_shrdir
3366 comment = previous versions at volume root snapshots outside mount point
3367 vfs objects = shadow_copy2
3368 shadow:mountpoint = $shadow_shrdir
3369 shadow:snapdir = $shadow_tstdir/.snapshots
3372 path = $shadow_shrdir
3373 comment = previous versions snapshots everywhere
3374 vfs objects = shadow_copy2
3375 shadow:mountpoint = $shadow_mntdir
3376 shadow:snapdirseverywhere = yes
3379 path = $shadow_shrdir
3380 comment = previous versions using snapsharepath
3381 vfs objects = shadow_copy2
3382 shadow:mountpoint = $shadow_mntdir
3383 shadow:snapdir = $shadow_tstdir/.snapshots
3384 shadow:snapsharepath = share
3387 comment = Testing shadow:format with default option
3388 vfs object = shadow_copy2
3389 path = $shadow_shrdir
3392 shadow:mountpoint = $shadow_mntdir
3393 shadow:basedir = $shadow_basedir
3394 shadow:snapdir = $shadow_basedir/.snapshots
3395 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
3398 comment = Testing shadow:format with only date component
3399 vfs object = shadow_copy2
3400 path = $shadow_shrdir
3403 shadow:mountpoint = $shadow_mntdir
3404 shadow:basedir = $shadow_basedir
3405 shadow:snapdir = $shadow_basedir/.snapshots
3406 shadow:format = \@GMT-%Y-%m-%d
3409 comment = Testing shadow:format with some hardcoded prefix
3410 vfs object = shadow_copy2
3411 path = $shadow_shrdir
3414 shadow:mountpoint = $shadow_mntdir
3415 shadow:basedir = $shadow_basedir
3416 shadow:snapdir = $shadow_basedir/.snapshots
3417 shadow:format = snap\@GMT-%Y.%m.%d-%H.%M.%S
3420 comment = Testing shadow:format with modified format
3421 vfs object = shadow_copy2
3422 path = $shadow_shrdir
3425 shadow:mountpoint = $shadow_mntdir
3426 shadow:basedir = $shadow_basedir
3427 shadow:snapdir = $shadow_basedir/.snapshots
3428 shadow:format = \@GMT-%Y.%m.%d-%H_%M_%S-snap
3431 comment = Testing shadow:snapprefix regex
3432 vfs object = shadow_copy2
3433 path = $shadow_shrdir
3436 shadow:mountpoint = $shadow_mntdir
3437 shadow:basedir = $shadow_basedir
3438 shadow:snapdir = $shadow_basedir/.snapshots
3439 shadow:snapprefix = \^s[a-z]*p\$
3440 shadow:format = _GMT-%Y.%m.%d-%H.%M.%S
3443 comment = Testing shadow:snapprefix with delim regex
3444 vfs object = shadow_copy2
3445 path = $shadow_shrdir
3448 shadow:mountpoint = $shadow_mntdir
3449 shadow:basedir = $shadow_basedir
3450 shadow:snapdir = $shadow_basedir/.snapshots
3451 shadow:delimiter = \@GMT
3452 shadow:snapprefix = [a-z]*
3453 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
3456 path = $shadow_shrdir
3457 comment = previous versions with wide links allowed
3458 vfs objects = shadow_copy2
3459 shadow:mountpoint = $shadow_mntdir
3463 path = $shadow_tstdir
3464 comment = previous versions snapshots under mount point
3465 vfs objects = shadow_copy2 streams_xattr
3466 shadow:mountpoint = $shadow_tstdir
3467 shadow:fixinodes = yes
3468 smbd async dosmode = yes
3471 path = $shadow_shrdir
3472 comment = previous versions with streams_depot
3473 vfs objects = streams_depot shadow_copy2
3476 path = $shrdir/dfree
3477 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
3478 admin users = $unix_name
3479 include = $dfqconffile
3481 path = $shrdir/dfree
3482 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
3483 admin users = $unix_name
3484 include = $dfqconffile
3485 dfree cache time = 60
3487 path = $shrdir/dfree
3488 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
3490 include = $dfqconffile
3492 path = $shrdir/quota
3493 admin users = $unix_name
3495 [acl_xattr_ign_sysacl_posix]
3497 acl_xattr:ignore system acls = yes
3498 acl_xattr:default acl style = posix
3499 [acl_xattr_ign_sysacl_windows]
3501 acl_xattr:ignore system acls = yes
3502 acl_xattr:default acl style = windows
3506 mangled names = illegal
3510 path = $nosymlinks_shrdir
3511 follow symlinks = no
3512 [nosymlinks_smb1allow]
3514 follow symlinks = yes
3518 path = $local_symlinks_shrdir
3519 follow symlinks = yes
3525 worm:grace_period = 1
3526 comment = vfs_worm with 1s grace_period
3530 kernel oplocks = yes
3531 vfs objects = streams_xattr xattr_tdb
3535 vfs objects = streams_xattr xattr_tdb
3537 [streams_xattr_nostrict]
3540 vfs objects = streams_xattr xattr_tdb
3544 vfs objects = acl_xattr streams_xattr fake_acls xattr_tdb
3545 acl_xattr:ignore system acls = yes
3546 acl_xattr:security_acl_name = user.acl
3547 xattr_tdb:ignore_user_xattr = yes
3551 smbd:find async delay usec = 10000
3554 vfs objects = error_inject
3555 include = $errorinjectconf
3559 vfs objects = delay_inject
3560 kernel share modes = no
3563 include = $delayinjectconf
3567 vfs objects = delay_inject
3568 delay_inject:pread_send = 2000
3569 delay_inject:pwrite_send = 2000
3573 vfs objects = delay_inject
3574 delay_inject:brl_lock_windows = 90
3575 delay_inject:brl_lock_windows_use_timer = yes
3579 vfs objects = delay_inject
3580 delay_inject:brl_lock_windows = 90
3581 delay_inject:brl_lock_windows_use_timer = no
3584 path = $prefix_abs/share
3585 delete readonly = yes
3588 path = $prefix_abs/share
3590 server smb encrypt = desired
3593 path = $prefix_abs/share
3595 server smb encrypt = off
3599 honor change notify privilege = yes
3601 [acls_non_canonical]
3603 acl flag inherited canonicalization = no
3605 [full_audit_success_bad_name]
3607 full_audit:success = badname
3609 [full_audit_fail_bad_name]
3611 full_audit:failure = badname
3615 server addresses = $server_ipv6
3618 path = $smbget_sharedir
3619 comment = smb username is [%U]
3623 path = $recycle_shrdir
3624 vfs objects = recycle
3625 recycle : repository = .trash
3626 recycle : exclude = *.tmp
3627 recycle : directory_mode = 755
3629 [fakedircreatetimes]
3631 path = $fakedircreatetimes_shrdir
3632 fake directory create times = yes
3635 path = $smbget_sharedir
3636 comment = smb username is [%U]
3639 include = $aliceconfdir/%U.conf
3644 my $net = Samba::bindir_path($self, "net");
3646 $cmd .= "UID_WRAPPER_ROOT=1 ";
3647 $cmd .= "SMB_CONF_PATH=\"$conffile\" ";
3648 $cmd .= "$net setlocalsid $samsid";
3650 my $net_ret = system($cmd);
3651 if ($net_ret != 0) {
3652 warn("net setlocalsid failed: $net_ret\n$cmd");
3656 unless (open(ERRORCONF, ">$errorinjectconf")) {
3657 warn("Unable to open $errorinjectconf");
3662 unless (open(DELAYCONF, ">$delayinjectconf")) {
3663 warn("Unable to open $delayinjectconf");
3668 unless (open(DFQCONF, ">$dfqconffile")) {
3669 warn("Unable to open $dfqconffile");
3674 unless (open(DELAYCONF, ">$globalinjectconf")) {
3675 warn("Unable to open $globalinjectconf");
3680 unless (open(ALICECONF, ">$aliceconffile")) {
3681 warn("Unable to open $aliceconffile");
3688 comment = smb username is [%U]
3694 ## create a test account
3697 unless (open(PASSWD, ">$nss_wrapper_passwd")) {
3698 warn("Unable to open $nss_wrapper_passwd");
3701 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
3702 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
3703 pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
3704 pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
3705 userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
3706 pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false
3707 force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false
3708 smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false
3709 user1:x:$uid_user1:$gid_nogroup:user1 gecos:$prefix_abs:/bin/false
3710 user2:x:$uid_user2:$gid_nogroup:user2 gecos:$prefix_abs:/bin/false
3711 gooduser:x:$uid_gooduser:$gid_domusers:gooduser gecos:$prefix_abs:/bin/false
3712 eviluser:x:$uid_eviluser:$gid_domusers:eviluser gecos::/bin/false
3713 slashuser:x:$uid_slashuser:$gid_domusers:slashuser gecos:/:/bin/false
3714 bob:x:$uid_localbob:$gid_domusers:localbob gecos:/:/bin/false
3715 jane:x:$uid_localjane:$gid_domusers:localjane gecos:/:/bin/false
3716 jackthemapper:x:$uid_localjackthemapper:$gid_domusers:localjackthemaper gecos:/:/bin/false
3717 jacknomapper:x:$uid_localjacknomapper:$gid_domusers:localjacknomaper gecos:/:/bin/false
3719 if ($unix_uid != 0) {
3720 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
3725 unless (open(GROUP, ">$nss_wrapper_group")) {
3726 warn("Unable to open $nss_wrapper_group");
3729 print GROUP "nobody:x:$gid_nobody:
3730 nogroup:x:$gid_nogroup:nobody
3731 $unix_name-group:x:$unix_gids[0]:
3732 domusers:X:$gid_domusers:
3733 domadmins:X:$gid_domadmins:
3734 userdup:x:$gid_userdup:$unix_name
3735 everyone:x:$gid_everyone:
3736 force_user:x:$gid_force_user:
3737 jackthemappergroup:x:$gid_jackthemapper:jackthemapper
3738 jacknomappergroup:x:$gid_jacknomapper:jacknomapper
3740 if ($unix_gids[0] != 0) {
3741 print GROUP "root:x:$gid_root:
3748 my $hostname = lc($server);
3749 unless (open(HOSTS, ">>$nss_wrapper_hosts")) {
3750 warn("Unable to open $nss_wrapper_hosts");
3753 print HOSTS "${server_ip} ${hostname}.${dns_domain} ${hostname}\n";
3754 print HOSTS "${server_ipv6} ${hostname}.${dns_domain} ${hostname}\n";
3757 $resolv_conf = "$privatedir/no_resolv.conf" unless defined($resolv_conf);
3759 foreach my $evlog (@eventlog_list) {
3760 my $evlogtdb = "$eventlogdir/$evlog.tdb";
3761 open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
3765 $createuser_env{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
3766 $createuser_env{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
3767 $createuser_env{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
3768 $createuser_env{NSS_WRAPPER_HOSTNAME} = "${hostname}.${dns_domain}";
3769 if ($ENV{SAMBA_DNS_FAKING}) {
3770 $createuser_env{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
3772 $createuser_env{RESOLV_WRAPPER_CONF} = $resolv_conf;
3774 $createuser_env{RESOLV_CONF} = $resolv_conf;
3776 createuser($self, $unix_name, $password, $conffile, \%createuser_env) || die("Unable to create user");
3777 createuser($self, "force_user", $password, $conffile, \%createuser_env) || die("Unable to create force_user");
3778 createuser($self, "smbget_user", $password, $conffile, \%createuser_env) || die("Unable to create smbget_user");
3779 createuser($self, "user1", $password, $conffile, \%createuser_env) || die("Unable to create user1");
3780 createuser($self, "user2", $password, $conffile, \%createuser_env) || die("Unable to create user2");
3781 createuser($self, "gooduser", $password, $conffile, \%createuser_env) || die("Unable to create gooduser");
3782 createuser($self, "eviluser", $password, $conffile, \%createuser_env) || die("Unable to create eviluser");
3783 createuser($self, "slashuser", $password, $conffile, \%createuser_env) || die("Unable to create slashuser");
3784 createuser($self, "jackthemapper", "mApsEcrEt", $conffile, \%createuser_env) || die("Unable to create jackthemapper");
3785 createuser($self, "jacknomapper", "nOmApsEcrEt", $conffile, \%createuser_env) || die("Unable to create jacknomapper");
3787 open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
3788 print DNS_UPDATE_LIST "A $server. $server_ip\n";
3789 print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n";
3790 close(DNS_UPDATE_LIST);
3794 $ret{SERVER_IP} = $server_ip;
3795 $ret{SERVER_IPV6} = $server_ipv6;
3796 $ret{SAMBA_DCERPCD_TEST_LOG} = "$prefix/samba_dcerpcd_test.log";
3797 $ret{SAMBA_DCERPCD_LOG_POS} = 0;
3798 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
3799 $ret{NMBD_TEST_LOG_POS} = 0;
3800 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
3801 $ret{WINBINDD_TEST_LOG_POS} = 0;
3802 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
3803 $ret{SMBD_TEST_LOG_POS} = 0;
3804 $ret{SERVERCONFFILE} = $conffile;
3805 $ret{TESTENV_DIR} = $prefix_abs;
3806 $ret{CONFIGURATION} ="--configfile=$conffile";
3807 $ret{LOCK_DIR} = $lockdir;
3808 $ret{SERVER} = $server;
3809 $ret{USERNAME} = $unix_name;
3810 $ret{USERID} = $unix_uid;
3811 $ret{DOMAIN} = $domain;
3812 $ret{SAMSID} = $samsid;
3813 $ret{NETBIOSNAME} = $netbios_name;
3814 $ret{PASSWORD} = $password;
3815 $ret{PIDDIR} = $piddir;
3816 $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir;
3817 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
3818 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
3819 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
3820 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
3821 $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
3822 $ret{NSS_WRAPPER_HOSTNAME} = "${hostname}.${dns_domain}";
3823 $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
3824 $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind";
3825 if ($ENV{SAMBA_DNS_FAKING}) {
3826 $ret{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
3828 $ret{RESOLV_WRAPPER_CONF} = $resolv_conf;
3830 $ret{RESOLV_CONF} = $resolv_conf;
3831 $ret{LOCAL_PATH} = "$shrdir";
3832 $ret{LOGDIR} = $logdir;
3835 # Avoid hitting system krb5.conf -
3836 # An env that needs Kerberos will reset this to the real
3839 $ret{KRB5_CONFIG} = abs_path($prefix) . "/no_krb5.conf";
3841 # Define KRB5CCNAME for each environment we set up
3842 $ret{KRB5_CCACHE} = abs_path($prefix) . "/krb5ccache";
3843 $ENV{KRB5CCNAME} = $ret{KRB5_CCACHE};
3848 sub wait_for_start($$$$$)
3850 my ($self, $envvars, $nmbd, $winbindd, $smbd, $samba_dcerpcd) = @_;
3855 if ($samba_dcerpcd eq "yes") {
3857 my $rpcclient = Samba::bindir_path($self, "rpcclient");
3859 print "checking for samba_dcerpcd\n";
3862 $ret = system("UID_WRAPPER_ROOT=1 $rpcclient $envvars->{CONFIGURATION} ncalrpc: -c epmmap");
3868 } while ($ret != 0 && $count < 10);
3871 print "samba_dcerpcd not reachable after 10 retries\n";
3872 teardown_env($self, $envvars);
3877 if ($nmbd eq "yes") {
3880 # give time for nbt server to register its names
3881 print "checking for nmbd\n";
3883 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
3884 my $nmblookup = Samba::bindir_path($self, "nmblookup");
3887 $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
3891 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
3892 system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
3893 system("$nmblookup $envvars->{CONFIGURATION} -U 10.255.255.255 __SAMBA__");
3894 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
3897 } while ($ret != 0 && $count < 10);
3899 print "NMBD not reachable after 10 retries\n";
3900 teardown_env($self, $envvars);
3905 if ($winbindd eq "yes" or $winbindd eq "offline") {
3906 print "checking for winbindd\n";
3908 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
3909 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3910 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3911 if ($winbindd eq "yes") {
3912 $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping-dc";
3913 } elsif ($winbindd eq "offline") {
3914 $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping";
3918 $ret = system($cmd);
3923 } while ($ret != 0 && $count < 20);
3925 print "WINBINDD not reachable after 20 seconds\n";
3926 teardown_env($self, $envvars);
3931 if ($smbd eq "yes") {
3932 # make sure smbd is also up set
3933 print "wait for smbd\n";
3937 if (defined($envvars->{GNUTLS_FORCE_FIPS_MODE})) {
3938 # We don't have NTLM in FIPS mode, so lets use
3939 # smbcontrol instead of smbclient.
3940 $cmd = Samba::bindir_path($self, "smbcontrol");
3941 $cmd .= " $envvars->{CONFIGURATION}";
3942 $cmd .= " smbd ping";
3944 # This uses NTLM which is not available in FIPS
3945 $cmd = Samba::bindir_path($self, "smbclient");
3946 $cmd .= " $envvars->{CONFIGURATION}";
3947 $cmd .= " -L $envvars->{SERVER}";
3949 $cmd .= " -I $envvars->{SERVER_IP}";
3953 $ret = system($cmd);
3958 } while ($ret != 0 && $count < 20);
3960 print "SMBD failed to start up in a reasonable time (20sec)\n";
3961 teardown_env($self, $envvars);
3966 # Ensure we have domain users mapped.
3967 $netcmd = "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3968 $netcmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3969 $netcmd .= "UID_WRAPPER_ROOT='1' ";
3970 $netcmd .= Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} ";
3972 $cmd = $netcmd . "groupmap delete ntgroup=domusers";
3973 $ret = system($cmd);
3975 $cmd = $netcmd . "groupmap add rid=513 unixgroup=domusers type=domain";
3976 $ret = system($cmd);
3978 print("\"$cmd\" failed\n");
3982 $cmd = $netcmd . "groupmap delete ntgroup=domadmins";
3983 $ret = system($cmd);
3985 $cmd = $netcmd . "groupmap add rid=512 unixgroup=domadmins type=domain";
3986 $ret = system($cmd);
3988 print("\"$cmd\" failed\n");
3992 $cmd = $netcmd . "groupmap delete ntgroup=everyone";
3993 $ret = system($cmd);
3995 $cmd = $netcmd . "groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin";
3996 $ret = system($cmd);
3998 print("\"$cmd\" failed\n");
4002 # note: creating builtin groups requires winbindd for the
4004 my $create_builtin_users = "no";
4005 if ($winbindd eq "yes") {
4006 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
4007 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
4008 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
4009 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
4010 my $wbinfo_out = qx($cmd 2>&1);
4012 # wbinfo doesn't give us a better error code then
4013 # WBC_ERR_DOMAIN_NOT_FOUND, but at least that's
4014 # different then WBC_ERR_WINBIND_NOT_AVAILABLE
4015 if ($wbinfo_out !~ /WBC_ERR_DOMAIN_NOT_FOUND/) {
4016 print("Failed to run \"wbinfo --sid-to-gid=S-1-5-32-545\": $wbinfo_out");
4017 teardown_env($self, $envvars);
4020 $create_builtin_users = "yes";
4023 if ($create_builtin_users eq "yes") {
4024 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
4025 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
4026 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
4027 $cmd .= Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
4028 $cmd .= "sam createbuiltingroup Users";
4029 $ret = system($cmd);
4031 print "Failed to create BUILTIN\\Users group\n";
4032 teardown_env($self, $envvars);
4036 $cmd = Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
4037 $cmd .= "cache del IDMAP/SID2XID/S-1-5-32-545";
4040 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
4041 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
4042 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
4043 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
4044 $ret = system($cmd);
4046 print "Missing \"BUILTIN\\Users\", did net sam createbuiltingroup Users fail?\n";
4047 teardown_env($self, $envvars);
4052 print $self->getlog_env($envvars);
4058 ## provision and start of ctdb
4062 my ($self, $prefix) = @_;
4065 my $data = $self->provision_ctdb($prefix, $num_nodes);
4066 $data or return undef;
4068 my $rc = $self->check_or_start_ctdb($data);
4070 print("check_or_start_ctdb() failed\n");
4074 $rc = $self->wait_for_start_ctdb($data);
4076 print "Cluster startup failed\n";
4083 sub provision_ctdb($$$$)
4085 my ($self, $prefix, $num_nodes, $no_delete_prefix) = @_;
4088 print "PROVISIONING CTDB...\n";
4090 my $prefix_abs = abs_path($prefix);
4093 # check / create directories:
4095 die ("prefix_abs = ''") if $prefix_abs eq "";
4096 die ("prefix_abs = '/'") if $prefix_abs eq "/";
4098 mkdir ($prefix_abs, 0777);
4100 print "CREATE CTDB TEST ENVIRONMENT in '$prefix_abs'...\n";
4102 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
4103 system("rm -rf $prefix_abs/*");
4110 for (my $i = 0; $i < $num_nodes; $i++) {
4112 my $server_name = "ctdb${i}";
4113 my $pub_iface = Samba::get_interface($server_name);
4114 my $ip = Samba::get_ipv4_addr($server_name);
4116 $node{NODE_NUMBER} = "$i";
4117 $node{SERVER_NAME} = "$server_name";
4118 $node{SOCKET_WRAPPER_DEFAULT_IFACE} = "$pub_iface";
4121 push(@nodes, \%node);
4127 my $nodes_file = "$prefix/nodes.in";
4128 unless (open(NODES, ">$nodes_file")) {
4129 warn("Unable to open nodesfile '$nodes_file'");
4132 for (my $i = 0; $i < $num_nodes; $i++) {
4133 my $ip = $nodes[$i]->{IP};
4134 print NODES "${ip}\n";
4139 # local_daemons.sh setup
4141 # Socket wrapper setup is done by selftest.pl, so don't use
4142 # the CTDB-specific setup
4145 $cmd .= "ctdb/tests/local_daemons.sh " . $prefix_abs . " setup";
4146 $cmd .= " -n " . $num_nodes;
4147 $cmd .= " -N " . $nodes_file;
4148 # CTDB should not attempt to manage public addresses -
4149 # clients should just connect to CTDB private addresses
4150 $cmd .= " -P " . "/dev/null";
4152 my $ret = system($cmd);
4154 print("\"$cmd\" failed\n");
4159 # Unix domain socket and node directory for each daemon
4161 for (my $i = 0; $i < $num_nodes; $i++) {
4162 my ($cmd, $ret, $out);
4164 my $cmd_prefix = "ctdb/tests/local_daemons.sh ${prefix_abs}";
4170 $cmd = "${cmd_prefix} print-socket ${i}";
4175 print("\"$cmd\" failed\n");
4179 $nodes[$i]->{SOCKET_FILE} = "$out";
4185 $cmd = "${cmd_prefix} onnode ${i} 'echo \$CTDB_BASE'";
4190 print("\"$cmd\" failed\n");
4194 $nodes[$i]->{NODE_PREFIX} = "$out";
4199 $ret{CTDB_PREFIX} = "$prefix";
4200 $ret{NUM_NODES} = $num_nodes;
4201 $ret{CTDB_NODES} = \@nodes;
4202 $ret{CTDB_NODES_FILE} = $nodes_file;
4204 for (my $i = 0; $i < $num_nodes; $i++) {
4205 my $node = $nodes[$i];
4206 my $socket = $node->{SOCKET_FILE};
4207 my $server_name = $node->{SERVER_NAME};
4208 my $node_prefix = $node->{NODE_PREFIX};
4209 my $ip = $node->{IP};
4211 $ret{"CTDB_BASE_NODE${i}"} = $node_prefix;
4212 $ret{"CTDB_SOCKET_NODE${i}"} = $socket;
4213 $ret{"CTDB_SERVER_NAME_NODE${i}"} = $server_name;
4214 $ret{"CTDB_IFACE_IP_NODE${i}"} = $ip;
4217 $ret{CTDB_BASE} = $ret{CTDB_BASE_NODE0};
4218 $ret{CTDB_SOCKET} = $ret{CTDB_SOCKET_NODE0};
4219 $ret{CTDB_SERVER_NAME} = $ret{CTDB_SERVER_NAME_NODE0};
4220 $ret{CTDB_IFACE_IP} = $ret{CTDB_IFACE_IP_NODE0};
4225 sub check_or_start_ctdb($$) {
4226 my ($self, $data) = @_;
4228 my $prefix = $data->{CTDB_PREFIX};
4229 my $num_nodes = $data->{NUM_NODES};
4230 my $nodes = $data->{CTDB_NODES};
4233 # Share a single stdin pipe for all nodes
4234 pipe($STDIN_READER, $data->{CTDB_STDIN_PIPE});
4236 for (my $i = 0; $i < $num_nodes; $i++) {
4237 my $node = $nodes->[$i];
4239 $node->{STDIN_PIPE} = $data->{CTDB_STDIN_PIPE};
4241 my $cmd = "ctdb/tests/local_daemons.sh";
4242 my @full_cmd = ("$cmd", "$prefix", "start", "$i");
4245 BINARY_PATH => $cmd,
4246 FULL_CMD => [ @full_cmd ],
4248 LOG_FILE => "/dev/null",
4252 print "STARTING CTDBD (node ${i})\n";
4254 # This does magic with $STDIN_READER, so use it
4255 my $ret = Samba::fork_and_exec($self,
4261 print("\"$cmd\" failed\n");
4262 teardown_env_ctdb($self, $data);
4267 close($STDIN_READER);
4272 sub wait_for_start_ctdb($$)
4274 my ($self, $data) = @_;
4276 my $prefix = $data->{CTDB_PREFIX};
4278 print "Wait for ctdbd...\n";
4280 my $ctdb = Samba::bindir_path($self, "ctdb");
4282 $cmd .= "ctdb/tests/local_daemons.sh ${prefix} onnode all";
4283 $cmd .= " ${ctdb} nodestatus all 2>&1";
4286 my $wait_seconds = 60;
4289 until ($count > $wait_seconds) {
4293 print "\ncluster became healthy\n";
4296 print "Waiting for CTDB...\n";
4301 if ($count > $wait_seconds) {
4302 print "\nGiving up to wait for CTDB...\n";
4304 print "CTDB log:\n";
4305 $cmd = "ctdb/tests/local_daemons.sh ${prefix} print-log all >&2";
4307 teardown_env_ctdb($self, $data);
4311 print "\nCTDB initialized\n";