selftest: Fix code spelling
[Samba.git] / selftest / target / Samba3.pm
blobd9e174736154a5758268d112c0da463ae2de6b93
1 #!/usr/bin/perl
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.
9 package Samba3;
11 use strict;
12 use warnings;
13 use Cwd qw(abs_path);
14 use FindBin qw($RealBin);
15 use POSIX;
16 use target::Samba;
17 use File::Path 'remove_tree';
19 sub return_alias_env
21 my ($self, $path, $env) = @_;
23 # just an alias
24 return $env;
27 sub have_ads($) {
28 my ($self) = @_;
29 my $found_ads = 0;
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: $!");
33 while (<IN>) {
34 if (/WITH_ADS/) {
35 $found_ads = 1;
38 close IN;
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;
42 return $found_ads;
45 # return smb.conf parameters applicable to @path, based on the underlying
46 # filesystem type
47 sub get_fs_specific_conf($$)
49 my ($self, $path) = @_;
50 my $mods = "";
51 my $stat_out = `stat --file-system $path` or return "";
53 if ($stat_out =~ m/Type:\s+btrfs/) {
54 $mods .= "streams_xattr btrfs";
57 if ($mods) {
58 return "vfs objects = $mods";
61 return '';
64 sub new($$) {
65 my ($classname, $SambaCtx, $bindir, $srcdir, $server_maxtime) = @_;
66 my $self = { vars => {},
67 SambaCtx => $SambaCtx,
68 bindir => $bindir,
69 srcdir => $srcdir,
70 server_maxtime => $server_maxtime
72 bless $self;
73 return $self;
76 sub teardown_env($$)
78 my ($self, $envvars) = @_;
80 if (defined($envvars->{CTDB_PREFIX})) {
81 $self->teardown_env_ctdb($envvars);
82 } else {
83 $self->teardown_env_samba($envvars);
86 return;
89 sub teardown_env_samba($$)
91 my ($self, $envvars) = @_;
92 my $count = 0;
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");
109 if ($smbdchild == -1
110 && $nmbdchild == -1
111 && $winbinddchild == -1
112 && $samba_dcerpcdpid == -1) {
113 last;
115 sleep(1);
116 $count++;
119 if ($count <= 20 &&
120 kill(0, $smbdpid, $nmbdpid, $winbinddpid, $samba_dcerpcdpid) == 0) {
121 return;
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);
129 $count = 0;
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");
136 if ($smbdchild == -1
137 && $nmbdchild == -1
138 && $winbinddchild == -1
139 && $samba_dcerpcdpid == -1) {
140 last;
142 sleep(1);
143 $count++;
146 if ($count <= 10 &&
147 kill(0, $smbdpid, $nmbdpid, $winbinddpid, $samba_dcerpcdpid) == 0) {
148 return;
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);
157 return 0;
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
179 sleep(5);
182 return 0;
185 sub getlog_env_app($$$)
187 my ($self, $envvars, $name) = @_;
189 my $title = "$name LOG of: $envvars->{NETBIOSNAME}\n";
190 my $out = $title;
192 open(LOG, "<".$envvars->{$name."_TEST_LOG"});
194 seek(LOG, $envvars->{$name."_TEST_LOG_POS"}, SEEK_SET);
195 while (<LOG>) {
196 $out .= $_;
198 $envvars->{$name."_TEST_LOG_POS"} = tell(LOG);
199 close(LOG);
201 return "" if $out eq $title;
203 return $out;
206 sub getlog_env($$)
208 my ($self, $envvars) = @_;
209 my $ret = "";
211 $ret .= $self->getlog_env_app($envvars, "SMBD");
212 $ret .= $self->getlog_env_app($envvars, "NMBD");
213 $ret .= $self->getlog_env_app($envvars, "WINBINDD");
215 return $ret;
218 sub check_env($$)
220 my ($self, $envvars) = @_;
222 my $childpid = waitpid(-1, WNOHANG);
224 # TODO ...
225 return 1;
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, ...],
233 nt4_dc => [],
234 nt4_dc_smb1 => [],
235 nt4_dc_smb1_done => ["nt4_dc_smb1"],
236 nt4_dc_schannel => [],
238 simpleserver => [],
239 fileserver => [],
240 fileserver_smb1 => [],
241 fileserver_smb1_done => ["fileserver_smb1"],
242 maptoguest => [],
243 ktest => [],
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 = ();
263 sub setup_nt4_dc
265 my ($self, $path, $more_conf, $server) = @_;
267 print "PROVISIONING NT4 DC...";
269 my $nt4_dc_options = "
270 domain master = yes
271 domain logons = yes
272 lanman auth = yes
273 ntlm auth = yes
274 raw NTLMv2 auth = yes
275 rpc start on demand helpers = false
277 CVE_2020_1472:warn_about_unused_debug_level = 3
278 server require schannel:schannel0\$ = no
279 server require schannel:schannel1\$ = no
280 server require schannel:schannel2\$ = no
281 server require schannel:schannel3\$ = no
282 server require schannel:schannel4\$ = no
283 server require schannel:schannel5\$ = no
284 server require schannel:schannel6\$ = no
285 server require schannel:schannel7\$ = no
286 server require schannel:schannel8\$ = no
287 server require schannel:schannel9\$ = no
288 server require schannel:schannel10\$ = no
289 server require schannel:schannel11\$ = no
290 server require schannel:torturetest\$ = no
292 server schannel require seal:schannel0\$ = no
293 server schannel require seal:schannel1\$ = no
294 server schannel require seal:schannel2\$ = no
295 server schannel require seal:schannel3\$ = no
296 server schannel require seal:schannel4\$ = no
297 server schannel require seal:schannel5\$ = no
298 server schannel require seal:schannel6\$ = no
299 server schannel require seal:schannel7\$ = no
300 server schannel require seal:schannel8\$ = no
301 server schannel require seal:schannel9\$ = no
302 server schannel require seal:schannel10\$ = no
303 server schannel require seal:schannel11\$ = no
304 server schannel require seal:torturetest\$ = no
306 vfs_default:VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS = no
308 fss: sequence timeout = 1
309 check parent directory delete on close = yes
312 if (defined($more_conf)) {
313 $nt4_dc_options = $nt4_dc_options . $more_conf;
315 if (!defined($server)) {
316 $server = "LOCALNT4DC2";
318 my $vars = $self->provision(
319 prefix => $path,
320 domain => "SAMBA-TEST",
321 server => $server,
322 password => "localntdc2pass",
323 extra_options => $nt4_dc_options);
325 $vars or return undef;
327 if (not $self->check_or_start(
328 env_vars => $vars,
329 samba_dcerpcd => "yes",
330 nmbd => "yes",
331 winbindd => "yes",
332 smbd => "yes")) {
333 return undef;
336 $vars->{DOMSID} = $vars->{SAMSID};
337 $vars->{DC_SERVER} = $vars->{SERVER};
338 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
339 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
340 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
341 $vars->{DC_USERNAME} = $vars->{USERNAME};
342 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
344 return $vars;
347 sub setup_nt4_dc_smb1
349 my ($self, $path) = @_;
350 my $conf = "
351 [global]
352 client min protocol = CORE
353 server min protocol = LANMAN1
355 return $self->setup_nt4_dc($path, $conf, "LCLNT4DC2SMB1");
358 sub setup_nt4_dc_smb1_done
360 my ($self, $path, $dep_env) = @_;
361 return $self->return_alias_env($path, $dep_env);
364 sub setup_nt4_dc_schannel
366 my ($self, $path) = @_;
368 print "PROVISIONING NT4 DC WITH SERVER SCHANNEL ...";
370 my $pdc_options = "
371 domain master = yes
372 domain logons = yes
373 lanman auth = yes
375 server schannel = yes
376 # used to reproduce bug #12772
377 server max protocol = SMB2_02
380 my $vars = $self->provision(
381 prefix => $path,
382 domain => "NT4SCHANNEL",
383 server => "LOCALNT4DC9",
384 password => "localntdc9pass",
385 extra_options => $pdc_options);
387 $vars or return undef;
389 if (not $self->check_or_start(
390 env_vars => $vars,
391 nmbd => "yes",
392 winbindd => "yes",
393 smbd => "yes")) {
394 return undef;
397 $vars->{DOMSID} = $vars->{SAMSID};
398 $vars->{DC_SERVER} = $vars->{SERVER};
399 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
400 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
401 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
402 $vars->{DC_USERNAME} = $vars->{USERNAME};
403 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
405 return $vars;
408 sub setup_nt4_member
410 my ($self, $prefix, $nt4_dc_vars) = @_;
411 my $count = 0;
412 my $rc;
414 print "PROVISIONING MEMBER...";
416 my $require_mutexes = "dbwrap_tdb_require_mutexes:* = yes";
417 if ($ENV{SELFTEST_DONT_REQUIRE_TDB_MUTEX_SUPPORT} // '' eq "1") {
418 $require_mutexes = "";
421 my $member_options = "
422 security = domain
423 dbwrap_tdb_mutexes:* = yes
424 ${require_mutexes}
426 my $ret = $self->provision(
427 prefix => $prefix,
428 domain => $nt4_dc_vars->{DOMAIN},
429 server => "LOCALNT4MEMBER3",
430 password => "localnt4member3pass",
431 extra_options => $member_options);
433 $ret or return undef;
435 my $nmblookup = Samba::bindir_path($self, "nmblookup");
436 do {
437 print "Waiting for the LOGON SERVER registration ...\n";
438 $rc = system("$nmblookup $ret->{CONFIGURATION} $ret->{DOMAIN}\#1c");
439 if ($rc != 0) {
440 sleep(1);
442 $count++;
443 } while ($rc != 0 && $count < 10);
444 if ($count == 10) {
445 print "NMBD not reachable after 10 retries\n";
446 teardown_env($self, $ret);
447 return 0;
450 my $net = Samba::bindir_path($self, "net");
451 # Add hosts file for name lookups
452 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
453 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
454 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
455 $cmd .= "$net rpc join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
456 $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}";
458 if (system($cmd) != 0) {
459 warn("Join failed\n$cmd");
460 return undef;
463 # Add hosts file for name lookups
464 $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
465 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
466 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
467 $cmd .= "$net $ret->{CONFIGURATION} primarytrust dumpinfo | grep -q 'REDACTED SECRET VALUES'";
469 if (system($cmd) != 0) {
470 warn("check failed\n$cmd");
471 return undef;
474 if (not $self->check_or_start(
475 env_vars => $ret,
476 nmbd => "yes",
477 winbindd => "yes",
478 smbd => "yes")) {
479 return undef;
482 $ret->{DOMSID} = $nt4_dc_vars->{DOMSID};
483 $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
484 $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
485 $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
486 $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME};
487 $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME};
488 $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD};
490 return $ret;
493 sub setup_clusteredmember
495 my ($self, $prefix, $nt4_dc_vars) = @_;
496 my $count = 0;
497 my $rc;
498 my @retvals = ();
499 my $ret;
501 print "PROVISIONING CLUSTEREDMEMBER...\n";
503 my $prefix_abs = abs_path($prefix);
504 mkdir($prefix_abs, 0777);
506 my $server_name = "CLUSTEREDMEMBER";
508 my $ctdb_data = $self->setup_ctdb($prefix);
510 if (not $ctdb_data) {
511 print "No ctdb data\n";
512 return undef;
515 print "PROVISIONING CLUSTERED SAMBA...\n";
517 my $num_nodes = $ctdb_data->{NUM_NODES};
518 my $nodes = $ctdb_data->{CTDB_NODES};
520 # Enable cleanup of earlier nodes if a later node fails
521 $ctdb_data->{SAMBA_NODES} = \@retvals;
523 for (my $i = 0; $i < $num_nodes; $i++) {
524 my $node = $nodes->[$i];
525 my $socket = $node->{SOCKET_FILE};
526 my $server_name = $node->{SERVER_NAME};
527 my $pub_iface = $node->{SOCKET_WRAPPER_DEFAULT_IFACE};
528 my $node_prefix = $node->{NODE_PREFIX};
530 print "NODE_PREFIX=${node_prefix}\n";
531 print "SOCKET=${socket}\n";
533 my $require_mutexes = "dbwrap_tdb_require_mutexes:* = yes";
534 if ($ENV{SELFTEST_DONT_REQUIRE_TDB_MUTEX_SUPPORT} // '' eq "1") {
535 $require_mutexes = "" ;
538 my $member_options = "
539 security = domain
540 server signing = on
541 clustering = yes
542 ctdbd socket = ${socket}
543 include = registry
544 dbwrap_tdb_mutexes:* = yes
545 ${require_mutexes}
548 my $node_ret = $self->provision(
549 prefix => "$node_prefix",
550 domain => $nt4_dc_vars->{DOMAIN},
551 server => "$server_name",
552 password => "clustermember8pass",
553 netbios_name => "CLUSTEREDMEMBER",
554 share_dir => "${prefix_abs}/shared",
555 extra_options => $member_options,
556 no_delete_prefix => 1);
557 if (not $node_ret) {
558 print "Provision node $i failed\n";
559 teardown_env($self, $ctdb_data);
560 return undef;
563 my $registry_share_template = "$node_ret->{SERVERCONFFILE}.registry_share_template";
564 unless (open(REGISTRYCONF, ">$registry_share_template")) {
565 warn("Unable to open $registry_share_template");
566 teardown_env($self, $node_ret);
567 teardown_env($self, $ctdb_data);
568 return undef;
571 print REGISTRYCONF "
572 [registry_share]
573 copy = tmp
574 comment = smb username is [%U]
577 close(REGISTRYCONF);
579 my $net = Samba::bindir_path($self, "net");
580 my $cmd = "";
582 $cmd .= "UID_WRAPPER_ROOT=1 ";
583 $cmd .= "$net conf import $node_ret->{CONFIGURATION} ${registry_share_template}";
585 my $net_ret = system($cmd);
586 if ($net_ret != 0) {
587 warn("net conf import failed: $net_ret\n$cmd");
588 teardown_env($self, $node_ret);
589 teardown_env($self, $ctdb_data);
590 return undef;
593 my $nmblookup = Samba::bindir_path($self, "nmblookup");
594 do {
595 print "Waiting for the LOGON SERVER registration ...\n";
596 $rc = system("$nmblookup $node_ret->{CONFIGURATION} " .
597 "$node_ret->{DOMAIN}\#1c");
598 if ($rc != 0) {
599 sleep(1);
601 $count++;
602 } while ($rc != 0 && $count < 10);
604 if ($count == 10) {
605 print "NMBD not reachable after 10 retries\n";
606 teardown_env($self, $node_ret);
607 teardown_env($self, $ctdb_data);
608 return undef;
611 push(@retvals, $node_ret);
614 $ret = {%$ctdb_data, %{$retvals[0]}};
616 my $net = Samba::bindir_path($self, "net");
617 my $cmd = "";
618 $cmd .= "UID_WRAPPER_ROOT=1 ";
619 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
620 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
621 $cmd .= "$net join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
622 $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}";
624 if (system($cmd) != 0) {
625 warn("Join failed\n$cmd");
626 teardown_env($self, $ret);
627 return undef;
630 for (my $i=0; $i<@retvals; $i++) {
631 my $node_provision = $retvals[$i];
632 my $ok;
633 $ok = $self->check_or_start(
634 env_vars => $node_provision,
635 winbindd => "yes",
636 smbd => "yes",
637 child_cleanup => sub {
638 map {
639 my $fh = $_->{STDIN_PIPE};
640 close($fh) if defined($fh);
641 } @retvals });
642 if (not $ok) {
643 teardown_env($self, $ret);
644 return undef;
649 # Build a unclist for every share
651 unless (open(NODES, "<$ret->{CTDB_NODES_FILE}")) {
652 warn("Unable to open CTDB nodes file");
653 teardown_env($self, $ret);
654 return undef;
656 my @nodes = <NODES>;
657 close(NODES);
658 chomp @nodes;
660 my $conffile = $ret->{SERVERCONFFILE};
661 $cmd = "";
662 $cmd .= 'sed -n -e \'s|^\[\(.*\)\]$|\1|p\'';
663 $cmd .= " \"$conffile\"";
664 $cmd .= " | grep -vx 'global'";
666 my @shares = `$cmd`;
667 $rc = $?;
668 if ($rc != 0) {
669 warn("Listing shares failed\n$cmd");
670 teardown_env($self, $ret);
671 return undef;
673 chomp @shares;
675 my $unclistdir = "${prefix_abs}/unclists";
676 mkdir($unclistdir, 0777);
677 foreach my $share (@shares) {
678 my $l = "${unclistdir}/${share}.txt";
679 unless (open(UNCLIST, ">${l}")) {
680 warn("Unable to open UNC list ${l}");
681 teardown_env($self, $ret);
682 return undef;
684 foreach my $node (@nodes) {
685 print UNCLIST "//${node}/${share}\n";
687 close(UNCLIST);
690 $ret->{DOMSID} = $nt4_dc_vars->{DOMSID};
691 $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
692 $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
693 $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
694 $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME};
695 $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME};
696 $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD};
698 return $ret;
701 sub provision_ad_member
703 my ($self,
704 $prefix,
705 $machine_account,
706 $dcvars,
707 $trustvars_f,
708 $trustvars_e,
709 $extra_member_options,
710 $force_fips_mode,
711 $offline_logon,
712 $no_nss_winbind) = @_;
714 if (defined($offline_logon) && defined($no_nss_winbind)) {
715 warn ("Offline logon incompatible with no nss winbind\n");
716 return undef;
719 my $prefix_abs = abs_path($prefix);
720 my @dirs = ();
722 mkdir($prefix_abs, 0777);
724 my $share_dir="$prefix_abs/share";
725 push(@dirs, $share_dir);
727 my $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}";
728 push(@dirs, $substitution_path);
730 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice";
731 push(@dirs, $substitution_path);
733 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice/G_domain users";
734 push(@dirs, $substitution_path);
736 # Using '/' as the winbind separator is a bad idea ...
737 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}";
738 push(@dirs, $substitution_path);
740 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice";
741 push(@dirs, $substitution_path);
743 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}";
744 push(@dirs, $substitution_path);
746 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}/domain users";
747 push(@dirs, $substitution_path);
749 my $option_offline_logon = "no";
750 if (defined($offline_logon)) {
751 $option_offline_logon = "yes";
754 my $netbios_aliases = "";
755 if ($machine_account eq "LOCALADMEMBER") {
756 $netbios_aliases = "netbios aliases = foo bar";
759 unless (defined($extra_member_options)) {
760 $extra_member_options = "";
763 my $member_options = "
764 security = ads
765 workgroup = $dcvars->{DOMAIN}
766 realm = $dcvars->{REALM}
767 $netbios_aliases
768 template homedir = /home/%D/%G/%U
769 auth event notification = true
770 password server = $dcvars->{SERVER}
771 winbind scan trusted domains = no
772 winbind offline logon = $option_offline_logon
774 allow dcerpc auth level connect:lsarpc = yes
775 dcesrv:max auth states = 8
776 rpc start on demand helpers = false
778 # Begin extra member options
779 $extra_member_options
780 # End extra member options
782 [sub_dug]
783 path = $share_dir/D_%D/U_%U/G_%G
784 writeable = yes
786 [sub_dug2]
787 path = $share_dir/D_%D/u_%u/g_%g
788 writeable = yes
790 [sub_valid_users]
791 path = $share_dir
792 valid users = ADDOMAIN/%U
794 [sub_valid_users_domain]
795 path = $share_dir
796 valid users = %D/%U
798 [sub_valid_users_group]
799 path = $share_dir
800 valid users = \@$dcvars->{DOMAIN}/%G
802 [valid_users]
803 path = $share_dir
804 valid users = $dcvars->{DOMAIN}/$dcvars->{DC_USERNAME}
806 [valid_users_group]
807 path = $share_dir
808 valid users = \"\@$dcvars->{DOMAIN}/domain users\"
810 [valid_users_unix_group]
811 path = $share_dir
812 valid users = \"+$dcvars->{DOMAIN}/domain users\"
814 [valid_users_nis_group]
815 path = $share_dir
816 valid users = \"&$dcvars->{DOMAIN}/domain users\"
818 [valid_users_unix_nis_group]
819 path = $share_dir
820 valid users = \"+&$dcvars->{DOMAIN}/domain users\"
822 [valid_users_nis_unix_group]
823 path = $share_dir
824 valid users = \"&+$dcvars->{DOMAIN}/domain users\"
826 [invalid_users]
827 path = $share_dir
828 invalid users = $dcvars->{DOMAIN}/$dcvars->{DC_USERNAME}
830 [valid_and_invalid_users]
831 path = $share_dir
832 valid users = $dcvars->{DOMAIN}/$dcvars->{DC_USERNAME} $dcvars->{DOMAIN}/alice
833 invalid users = $dcvars->{DOMAIN}/$dcvars->{DC_USERNAME}
836 my $ret = $self->provision(
837 prefix => $prefix,
838 domain => $dcvars->{DOMAIN},
839 realm => $dcvars->{REALM},
840 server => $machine_account,
841 password => "loCalMemberPass",
842 extra_options => $member_options,
843 resolv_conf => $dcvars->{RESOLV_CONF});
845 $ret or return undef;
847 mkdir($_, 0777) foreach(@dirs);
849 $ret->{DOMAIN} = $dcvars->{DOMAIN};
850 $ret->{REALM} = $dcvars->{REALM};
851 $ret->{DOMSID} = $dcvars->{DOMSID};
853 my $ctx;
854 $ctx = {};
855 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
856 $ctx->{domain} = $dcvars->{DOMAIN};
857 $ctx->{realm} = $dcvars->{REALM};
858 $ctx->{dnsname} = lc($dcvars->{REALM});
859 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
860 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
861 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
862 Samba::mk_krb5_conf($ctx, "");
864 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
866 if (defined($force_fips_mode)) {
867 $ret->{GNUTLS_FORCE_FIPS_MODE} = "1";
868 $ret->{OPENSSL_FORCE_FIPS_MODE} = "1";
871 my $net = Samba::bindir_path($self, "net");
872 # Add hosts file for name lookups
873 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
874 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
875 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
876 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
877 } else {
878 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
880 if (defined($force_fips_mode)) {
881 $cmd .= "GNUTLS_FORCE_FIPS_MODE=1 ";
882 $cmd .= "OPENSSL_FORCE_FIPS_MODE=1 ";
884 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
885 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
886 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
887 $cmd .= "$net join $ret->{CONFIGURATION}";
888 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD} --use-kerberos=required";
890 if (system($cmd) != 0) {
891 warn("Join failed\n$cmd");
892 return undef;
895 # We need world access to this share, as otherwise the domain
896 # administrator from the AD domain provided by Samba4 can't
897 # access the share for tests.
898 chmod 0777, "$prefix/share";
900 if (defined($offline_logon)) {
901 my $wbinfo = Samba::bindir_path($self, "wbinfo");
903 if (not $self->check_or_start(
904 env_vars => $ret,
905 winbindd => "yes")) {
906 return undef;
909 # Fill samlogoncache for alice
910 $cmd = "NSS_WRAPPER_PASSWD='$ret->{NSS_WRAPPER_PASSWD}' ";
911 $cmd .= "NSS_WRAPPER_GROUP='$ret->{NSS_WRAPPER_GROUP}' ";
912 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
913 $cmd .= "$wbinfo --pam-logon=ADDOMAIN/alice%Secret007";
914 if (system($cmd) != 0) {
915 warn("Filling the cache failed\n$cmd");
916 return undef;
919 $cmd = "NSS_WRAPPER_PASSWD='$ret->{NSS_WRAPPER_PASSWD}' ";
920 $cmd .= "NSS_WRAPPER_GROUP='$ret->{NSS_WRAPPER_GROUP}' ";
921 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
922 $cmd .= "$wbinfo --ccache-save=ADDOMAIN/alice%Secret007";
923 if (system($cmd) != 0) {
924 warn("Filling the cache failed\n$cmd");
925 return undef;
928 # Fill samlogoncache for bob
929 $cmd = "NSS_WRAPPER_PASSWD='$ret->{NSS_WRAPPER_PASSWD}' ";
930 $cmd .= "NSS_WRAPPER_GROUP='$ret->{NSS_WRAPPER_GROUP}' ";
931 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
932 $cmd .= "$wbinfo --pam-logon=ADDOMAIN/bob%Secret007";
933 if (system($cmd) != 0) {
934 warn("Filling the cache failed\n$cmd");
935 return undef;
938 $cmd = "NSS_WRAPPER_PASSWD='$ret->{NSS_WRAPPER_PASSWD}' ";
939 $cmd .= "NSS_WRAPPER_GROUP='$ret->{NSS_WRAPPER_GROUP}' ";
940 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
941 $cmd .= "$wbinfo --ccache-save=ADDOMAIN/bob%Secret007";
942 if (system($cmd) != 0) {
943 warn("Filling the cache failed\n$cmd");
944 return undef;
947 # Set windindd offline
948 my $smbcontrol = Samba::bindir_path($self, "smbcontrol");
949 $cmd = "NSS_WRAPPER_PASSWD='$ret->{NSS_WRAPPER_PASSWD}' ";
950 $cmd .= "NSS_WRAPPER_GROUP='$ret->{NSS_WRAPPER_GROUP}' ";
951 $cmd .= "UID_WRAPPER_ROOT='1' ";
952 $cmd .= "$smbcontrol $ret->{CONFIGURATION} winbindd offline";
953 if (system($cmd) != 0) {
954 warn("Setting winbindd offline failed\n$cmd");
955 return undef;
958 # Validate the offline cache
959 $cmd = "NSS_WRAPPER_PASSWD='$ret->{NSS_WRAPPER_PASSWD}' ";
960 $cmd .= "NSS_WRAPPER_GROUP='$ret->{NSS_WRAPPER_GROUP}' ";
961 $cmd .= "UID_WRAPPER_ROOT='1' ";
962 $cmd .= "$smbcontrol $ret->{CONFIGURATION} winbindd validate-cache";
963 if (system($cmd) != 0) {
964 warn("Validation of winbind credential cache failed\n$cmd");
965 teardown_env($self, $ret);
966 return undef;
969 # Shut down winbindd
970 teardown_env($self, $ret);
972 ### Change SOCKET_WRAPPER_DIR so it can't connect to AD
973 my $swrap_env = $ENV{SOCKET_WRAPPER_DIR};
974 $ENV{SOCKET_WRAPPER_DIR} = "$prefix_abs";
976 # Start winbindd in offline mode
977 if (not $self->check_or_start(
978 env_vars => $ret,
979 winbindd => "offline")) {
980 return undef;
983 # Set socket dir again
984 $ENV{SOCKET_WRAPPER_DIR} = $swrap_env;
986 } else {
987 if (defined($no_nss_winbind)) {
988 $ret->{NSS_WRAPPER_MODULE_SO_PATH} = "";
989 $ret->{NSS_WRAPPER_MODULE_FN_PREFIX} = "";
992 if (not $self->check_or_start(
993 env_vars => $ret,
994 samba_dcerpcd => "yes",
995 nmbd => "yes",
996 winbindd => "yes",
997 smbd => "yes")) {
998 return undef;
1002 $ret->{DC_SERVER} = $dcvars->{SERVER};
1003 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1004 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1005 $ret->{DC_SERVERCONFFILE} = $dcvars->{SERVERCONFFILE};
1006 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1007 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1008 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1010 # forest trust
1011 $ret->{TRUST_F_BOTH_SERVER} = $trustvars_f->{SERVER};
1012 $ret->{TRUST_F_BOTH_SERVER_IP} = $trustvars_f->{SERVER_IP};
1013 $ret->{TRUST_F_BOTH_SERVER_IPV6} = $trustvars_f->{SERVER_IPV6};
1014 $ret->{TRUST_F_BOTH_NETBIOSNAME} = $trustvars_f->{NETBIOSNAME};
1015 $ret->{TRUST_F_BOTH_USERNAME} = $trustvars_f->{USERNAME};
1016 $ret->{TRUST_F_BOTH_PASSWORD} = $trustvars_f->{PASSWORD};
1017 $ret->{TRUST_F_BOTH_DOMAIN} = $trustvars_f->{DOMAIN};
1018 $ret->{TRUST_F_BOTH_REALM} = $trustvars_f->{REALM};
1020 # external trust
1021 $ret->{TRUST_E_BOTH_SERVER} = $trustvars_e->{SERVER};
1022 $ret->{TRUST_E_BOTH_SERVER_IP} = $trustvars_e->{SERVER_IP};
1023 $ret->{TRUST_E_BOTH_SERVER_IPV6} = $trustvars_e->{SERVER_IPV6};
1024 $ret->{TRUST_E_BOTH_NETBIOSNAME} = $trustvars_e->{NETBIOSNAME};
1025 $ret->{TRUST_E_BOTH_USERNAME} = $trustvars_e->{USERNAME};
1026 $ret->{TRUST_E_BOTH_PASSWORD} = $trustvars_e->{PASSWORD};
1027 $ret->{TRUST_E_BOTH_DOMAIN} = $trustvars_e->{DOMAIN};
1028 $ret->{TRUST_E_BOTH_REALM} = $trustvars_e->{REALM};
1030 return $ret;
1033 sub setup_ad_member
1035 my ($self,
1036 $prefix,
1037 $dcvars,
1038 $trustvars_f,
1039 $trustvars_e) = @_;
1041 # If we didn't build with ADS, pretend this env was never available
1042 if (not $self->have_ads()) {
1043 return "UNKNOWN";
1046 print "PROVISIONING AD MEMBER...";
1048 return $self->provision_ad_member($prefix,
1049 "LOCALADMEMBER",
1050 $dcvars,
1051 $trustvars_f,
1052 $trustvars_e);
1055 sub setup_ad_member_s3_join
1057 my ($self,
1058 $prefix,
1059 $dcvars,
1060 $trustvars_f,
1061 $trustvars_e) = @_;
1063 # If we didn't build with ADS, pretend this env was never available
1064 if (not $self->have_ads()) {
1065 return "UNKNOWN";
1068 print "PROVISIONING AD MEMBER...";
1070 return $self->provision_ad_member($prefix,
1071 "LOCALADMEMBER2",
1072 $dcvars,
1073 $trustvars_f,
1074 $trustvars_e);
1077 sub setup_ad_member_rfc2307
1079 my ($self, $prefix, $dcvars) = @_;
1081 # If we didn't build with ADS, pretend this env was never available
1082 if (not $self->have_ads()) {
1083 return "UNKNOWN";
1086 print "PROVISIONING S3 AD MEMBER WITH idmap_rfc2307 config...";
1088 my $member_options = "
1089 security = ads
1090 workgroup = $dcvars->{DOMAIN}
1091 realm = $dcvars->{REALM}
1092 idmap cache time = 0
1093 idmap negative cache time = 0
1094 idmap config * : backend = autorid
1095 idmap config * : range = 1000000-1999999
1096 idmap config * : rangesize = 100000
1097 idmap config $dcvars->{DOMAIN} : backend = rfc2307
1098 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
1099 idmap config $dcvars->{DOMAIN} : ldap_server = ad
1100 idmap config $dcvars->{DOMAIN} : bind_path_user = ou=idmap,dc=samba,dc=example,dc=com
1101 idmap config $dcvars->{DOMAIN} : bind_path_group = ou=idmap,dc=samba,dc=example,dc=com
1103 password server = $dcvars->{SERVER}
1106 my $ret = $self->provision(
1107 prefix => $prefix,
1108 domain => $dcvars->{DOMAIN},
1109 realm => $dcvars->{REALM},
1110 server => "RFC2307MEMBER",
1111 password => "loCalMemberPass",
1112 extra_options => $member_options,
1113 resolv_conf => $dcvars->{RESOLV_CONF});
1115 $ret or return undef;
1117 $ret->{DOMAIN} = $dcvars->{DOMAIN};
1118 $ret->{REALM} = $dcvars->{REALM};
1119 $ret->{DOMSID} = $dcvars->{DOMSID};
1121 my $ctx;
1122 my $prefix_abs = abs_path($prefix);
1123 $ctx = {};
1124 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1125 $ctx->{domain} = $dcvars->{DOMAIN};
1126 $ctx->{realm} = $dcvars->{REALM};
1127 $ctx->{dnsname} = lc($dcvars->{REALM});
1128 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
1129 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
1130 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1131 Samba::mk_krb5_conf($ctx, "");
1133 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1135 my $net = Samba::bindir_path($self, "net");
1136 # Add hosts file for name lookups
1137 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
1138 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1139 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
1140 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
1141 } else {
1142 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
1144 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
1145 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1146 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
1147 $cmd .= "$net join $ret->{CONFIGURATION}";
1148 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
1150 if (system($cmd) != 0) {
1151 warn("Join failed\n$cmd");
1152 return undef;
1155 # We need world access to this share, as otherwise the domain
1156 # administrator from the AD domain provided by Samba4 can't
1157 # access the share for tests.
1158 chmod 0777, "$prefix/share";
1160 if (not $self->check_or_start(
1161 env_vars => $ret,
1162 nmbd => "yes",
1163 winbindd => "yes",
1164 smbd => "yes")) {
1165 return undef;
1168 $ret->{DC_SERVER} = $dcvars->{SERVER};
1169 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1170 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1171 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1172 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1173 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1175 return $ret;
1178 sub setup_admem_idmap_autorid
1180 my ($self, $prefix, $dcvars) = @_;
1182 # If we didn't build with ADS, pretend this env was never available
1183 if (not $self->have_ads()) {
1184 return "UNKNOWN";
1187 print "PROVISIONING S3 AD MEMBER WITH idmap_autorid config...";
1189 my $member_options = "
1190 security = ads
1191 workgroup = $dcvars->{DOMAIN}
1192 realm = $dcvars->{REALM}
1193 idmap config * : backend = autorid
1194 idmap config * : range = 1000000-19999999
1195 idmap config * : rangesize = 1000000
1197 # Prevent overriding the provisioned lib/krb5.conf which sets certain
1198 # values required for tests to succeed
1199 create krb5 conf = no
1202 my $ret = $self->provision(
1203 prefix => $prefix,
1204 domain => $dcvars->{DOMAIN},
1205 realm => $dcvars->{REALM},
1206 server => "ADMEMAUTORID",
1207 password => "loCalMemberPass",
1208 extra_options => $member_options,
1209 resolv_conf => $dcvars->{RESOLV_CONF});
1211 $ret or return undef;
1213 $ret->{DOMAIN} = $dcvars->{DOMAIN};
1214 $ret->{REALM} = $dcvars->{REALM};
1215 $ret->{DOMSID} = $dcvars->{DOMSID};
1217 my $ctx;
1218 my $prefix_abs = abs_path($prefix);
1219 $ctx = {};
1220 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1221 $ctx->{domain} = $dcvars->{DOMAIN};
1222 $ctx->{realm} = $dcvars->{REALM};
1223 $ctx->{dnsname} = lc($dcvars->{REALM});
1224 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
1225 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
1226 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1227 Samba::mk_krb5_conf($ctx, "");
1229 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1231 my $net = Samba::bindir_path($self, "net");
1232 # Add hosts file for name lookups
1233 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
1234 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1235 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
1236 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
1237 } else {
1238 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
1240 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
1241 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1242 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
1243 $cmd .= "$net join $ret->{CONFIGURATION}";
1244 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
1246 if (system($cmd) != 0) {
1247 warn("Join failed\n$cmd");
1248 return undef;
1251 # We need world access to this share, as otherwise the domain
1252 # administrator from the AD domain provided by Samba4 can't
1253 # access the share for tests.
1254 chmod 0777, "$prefix/share";
1256 if (not $self->check_or_start(
1257 env_vars => $ret,
1258 nmbd => "yes",
1259 winbindd => "yes",
1260 smbd => "yes")) {
1261 return undef;
1264 $ret->{DC_SERVER} = $dcvars->{SERVER};
1265 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1266 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1267 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1268 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1269 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1271 return $ret;
1274 sub setup_ad_member_idmap_rid
1276 my ($self, $prefix, $dcvars) = @_;
1278 # If we didn't build with ADS, pretend this env was never available
1279 if (not $self->have_ads()) {
1280 return "UNKNOWN";
1283 print "PROVISIONING S3 AD MEMBER WITH idmap_rid config...";
1285 my $member_options = "
1286 security = ads
1287 workgroup = $dcvars->{DOMAIN}
1288 realm = $dcvars->{REALM}
1289 idmap config * : backend = tdb
1290 idmap config * : range = 1000000-1999999
1291 idmap config $dcvars->{DOMAIN} : backend = rid
1292 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
1293 # Prevent overriding the provisioned lib/krb5.conf which sets certain
1294 # values required for tests to succeed
1295 create krb5 conf = no
1296 map to guest = bad user
1297 winbind expand groups = 10
1300 my $ret = $self->provision(
1301 prefix => $prefix,
1302 domain => $dcvars->{DOMAIN},
1303 realm => $dcvars->{REALM},
1304 server => "IDMAPRIDMEMBER",
1305 password => "loCalMemberPass",
1306 extra_options => $member_options,
1307 resolv_conf => $dcvars->{RESOLV_CONF});
1309 $ret or return undef;
1311 $ret->{DOMAIN} = $dcvars->{DOMAIN};
1312 $ret->{REALM} = $dcvars->{REALM};
1313 $ret->{DOMSID} = $dcvars->{DOMSID};
1315 my $ctx;
1316 my $prefix_abs = abs_path($prefix);
1317 $ctx = {};
1318 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1319 $ctx->{domain} = $dcvars->{DOMAIN};
1320 $ctx->{realm} = $dcvars->{REALM};
1321 $ctx->{dnsname} = lc($dcvars->{REALM});
1322 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
1323 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
1324 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1325 Samba::mk_krb5_conf($ctx, "");
1327 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1329 my $net = Samba::bindir_path($self, "net");
1330 # Add hosts file for name lookups
1331 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
1332 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1333 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
1334 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
1335 } else {
1336 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
1338 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
1339 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1340 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
1341 $cmd .= "$net join $ret->{CONFIGURATION}";
1342 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
1344 if (system($cmd) != 0) {
1345 warn("Join failed\n$cmd");
1346 return undef;
1349 # We need world access to this share, as otherwise the domain
1350 # administrator from the AD domain provided by Samba4 can't
1351 # access the share for tests.
1352 chmod 0777, "$prefix/share";
1354 if (not $self->check_or_start(
1355 env_vars => $ret,
1356 nmbd => "yes",
1357 winbindd => "yes",
1358 smbd => "yes")) {
1359 return undef;
1362 $ret->{DC_SERVER} = $dcvars->{SERVER};
1363 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1364 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1365 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1366 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1367 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1369 return $ret;
1372 sub setup_ad_member_idmap_ad
1374 my ($self, $prefix, $dcvars) = @_;
1376 # If we didn't build with ADS, pretend this env was never available
1377 if (not $self->have_ads()) {
1378 return "UNKNOWN";
1381 print "PROVISIONING S3 AD MEMBER WITH idmap_ad config...";
1383 my $member_options = "
1384 security = ads
1385 workgroup = $dcvars->{DOMAIN}
1386 realm = $dcvars->{REALM}
1387 password server = $dcvars->{SERVER}
1388 idmap config * : backend = tdb
1389 idmap config * : range = 1000000-1999999
1390 idmap config $dcvars->{DOMAIN} : backend = ad
1391 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
1392 idmap config $dcvars->{DOMAIN} : unix_primary_group = yes
1393 idmap config $dcvars->{DOMAIN} : unix_nss_info = yes
1394 idmap config $dcvars->{DOMAIN} : deny ous = \"ou=sub,DC=samba2008r2,DC=example,DC=com\"
1395 idmap config $dcvars->{TRUST_DOMAIN} : backend = ad
1396 idmap config $dcvars->{TRUST_DOMAIN} : range = 2000000-2999999
1397 gensec_gssapi:requested_life_time = 5
1400 my $ret = $self->provision(
1401 prefix => $prefix,
1402 domain => $dcvars->{DOMAIN},
1403 realm => $dcvars->{REALM},
1404 server => "IDMAPADMEMBER",
1405 password => "loCalMemberPass",
1406 extra_options => $member_options,
1407 resolv_conf => $dcvars->{RESOLV_CONF});
1409 $ret or return undef;
1411 $ret->{DOMAIN} = $dcvars->{DOMAIN};
1412 $ret->{REALM} = $dcvars->{REALM};
1413 $ret->{DOMSID} = $dcvars->{DOMSID};
1415 my $ctx;
1416 my $prefix_abs = abs_path($prefix);
1417 $ctx = {};
1418 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1419 $ctx->{domain} = $dcvars->{DOMAIN};
1420 $ctx->{realm} = $dcvars->{REALM};
1421 $ctx->{dnsname} = lc($dcvars->{REALM});
1422 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
1423 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
1424 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1425 Samba::mk_krb5_conf($ctx, "");
1427 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1429 my $net = Samba::bindir_path($self, "net");
1430 # Add hosts file for name lookups
1431 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
1432 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1433 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
1434 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
1435 } else {
1436 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
1438 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
1439 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1440 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
1441 $cmd .= "$net join $ret->{CONFIGURATION}";
1442 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
1444 if (system($cmd) != 0) {
1445 warn("Join failed\n$cmd");
1446 return undef;
1449 # We need world access to this share, as otherwise the domain
1450 # administrator from the AD domain provided by Samba4 can't
1451 # access the share for tests.
1452 chmod 0777, "$prefix/share";
1454 if (not $self->check_or_start(
1455 env_vars => $ret,
1456 nmbd => "yes",
1457 winbindd => "yes",
1458 smbd => "yes")) {
1459 return undef;
1462 $ret->{DC_SERVER} = $dcvars->{SERVER};
1463 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1464 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1465 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1466 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1467 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1469 $ret->{TRUST_SERVER} = $dcvars->{TRUST_SERVER};
1470 $ret->{TRUST_USERNAME} = $dcvars->{TRUST_USERNAME};
1471 $ret->{TRUST_PASSWORD} = $dcvars->{TRUST_PASSWORD};
1472 $ret->{TRUST_DOMAIN} = $dcvars->{TRUST_DOMAIN};
1473 $ret->{TRUST_REALM} = $dcvars->{TRUST_REALM};
1474 $ret->{TRUST_DOMSID} = $dcvars->{TRUST_DOMSID};
1476 return $ret;
1479 sub setup_ad_member_oneway
1481 my ($self, $prefix, $dcvars) = @_;
1483 # If we didn't build with ADS, pretend this env was never available
1484 if (not $self->have_ads()) {
1485 return "UNKNOWN";
1488 print "PROVISIONING S3 AD MEMBER WITH one-way trust...";
1490 my $member_options = "
1491 security = ads
1492 workgroup = $dcvars->{DOMAIN}
1493 realm = $dcvars->{REALM}
1494 password server = $dcvars->{SERVER}
1495 idmap config * : backend = tdb
1496 idmap config * : range = 1000000-1999999
1497 gensec_gssapi:requested_life_time = 5
1500 my $ret = $self->provision(
1501 prefix => $prefix,
1502 domain => $dcvars->{DOMAIN},
1503 server => "S2KMEMBER",
1504 password => "loCalS2KMemberPass",
1505 extra_options => $member_options,
1506 resolv_conf => $dcvars->{RESOLV_CONF});
1508 $ret or return undef;
1510 $ret->{DOMAIN} = $dcvars->{DOMAIN};
1511 $ret->{REALM} = $dcvars->{REALM};
1512 $ret->{DOMSID} = $dcvars->{DOMSID};
1514 my $ctx;
1515 my $prefix_abs = abs_path($prefix);
1516 $ctx = {};
1517 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1518 $ctx->{domain} = $dcvars->{DOMAIN};
1519 $ctx->{realm} = $dcvars->{REALM};
1520 $ctx->{dnsname} = lc($dcvars->{REALM});
1521 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
1522 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
1523 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1524 Samba::mk_krb5_conf($ctx, "");
1526 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1528 my $net = Samba::bindir_path($self, "net");
1529 # Add hosts file for name lookups
1530 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
1531 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1532 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
1533 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
1534 } else {
1535 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
1537 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
1538 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1539 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
1540 $cmd .= "$net join $ret->{CONFIGURATION}";
1541 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
1543 if (system($cmd) != 0) {
1544 warn("Join failed\n$cmd");
1545 return undef;
1548 if (not $self->check_or_start(
1549 env_vars => $ret,
1550 winbindd => "yes")) {
1551 return undef;
1554 $ret->{DC_SERVER} = $dcvars->{SERVER};
1555 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1556 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1557 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1558 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1559 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1561 $ret->{TRUST_SERVER} = $dcvars->{TRUST_SERVER};
1562 $ret->{TRUST_USERNAME} = $dcvars->{TRUST_USERNAME};
1563 $ret->{TRUST_PASSWORD} = $dcvars->{TRUST_PASSWORD};
1564 $ret->{TRUST_DOMAIN} = $dcvars->{TRUST_DOMAIN};
1565 $ret->{TRUST_REALM} = $dcvars->{TRUST_REALM};
1566 $ret->{TRUST_DOMSID} = $dcvars->{TRUST_DOMSID};
1568 return $ret;
1571 sub setup_ad_member_fips
1573 my ($self,
1574 $prefix,
1575 $dcvars,
1576 $trustvars_f,
1577 $trustvars_e) = @_;
1579 # If we didn't build with ADS, pretend this env was never available
1580 if (not $self->have_ads()) {
1581 return "UNKNOWN";
1584 print "PROVISIONING AD FIPS MEMBER...";
1586 return $self->provision_ad_member($prefix,
1587 "FIPSADMEMBER",
1588 $dcvars,
1589 $trustvars_f,
1590 $trustvars_e,
1591 undef,
1595 sub setup_ad_member_offlogon
1597 my ($self,
1598 $prefix,
1599 $dcvars,
1600 $trustvars_f,
1601 $trustvars_e) = @_;
1603 # If we didn't build with ADS, pretend this env was never available
1604 if (not $self->have_ads()) {
1605 return "UNKNOWN";
1608 print "PROVISIONING AD MEMBER OFFLINE LOGON...";
1610 return $self->provision_ad_member($prefix,
1611 "OFFLINEADMEM",
1612 $dcvars,
1613 $trustvars_f,
1614 $trustvars_e,
1615 undef,
1616 undef,
1620 sub setup_ad_member_idmap_nss
1622 my ($self,
1623 $prefix,
1624 $dcvars,
1625 $trustvars_f,
1626 $trustvars_e) = @_;
1628 # If we didn't build with ADS, pretend this env was never available
1629 if (not $self->have_ads()) {
1630 return "UNKNOWN";
1633 print "PROVISIONING AD MEMBER WITHOUT NSS WINBIND WITH idmap_nss config...";
1635 my $extra_member_options = "
1636 # bob:x:65521:65531:localbob gecos:/:/bin/false
1637 # jane:x:65520:65531:localjane gecos:/:/bin/false
1638 # jackthemapper:x:65519:65531:localjackthemaper gecos:/:/bin/false
1639 # jacknomapper:x:65518:65531:localjacknomaper gecos:/:/bin/false
1640 idmap config $dcvars->{DOMAIN} : backend = nss
1641 idmap config $dcvars->{DOMAIN} : range = 65518-65521
1643 # Support SMB1 so that we can use posix_whoami().
1644 client min protocol = CORE
1645 server min protocol = LANMAN1
1647 username map = $prefix/lib/username.map
1650 my $ret = $self->provision_ad_member($prefix,
1651 "ADMEMIDMAPNSS",
1652 $dcvars,
1653 $trustvars_f,
1654 $trustvars_e,
1655 $extra_member_options,
1656 undef,
1657 undef,
1660 open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map");
1661 print USERMAP "
1662 !jacknomapper = \@jackthemappergroup
1663 !root = jacknomappergroup
1664 root = $dcvars->{DOMAIN}/root
1665 bob = $dcvars->{DOMAIN}/bob
1667 close(USERMAP);
1669 return $ret;
1672 sub setup_simpleserver
1674 my ($self, $path) = @_;
1676 print "PROVISIONING simple server...";
1678 my $prefix_abs = abs_path($path);
1679 mkdir($prefix_abs, 0777);
1681 my $external_streams_depot="$prefix_abs/external_streams_depot";
1682 remove_tree($external_streams_depot);
1683 mkdir($external_streams_depot, 0777);
1685 my $simpleserver_options = "
1686 lanman auth = yes
1687 ntlm auth = yes
1688 vfs objects = xattr_tdb streams_depot
1689 change notify = no
1690 server smb encrypt = off
1692 [vfs_aio_pthread]
1693 path = $prefix_abs/share
1694 read only = no
1695 vfs objects = aio_pthread
1696 aio_pthread:aio open = yes
1697 smbd async dosmode = no
1699 [vfs_aio_pthread_async_dosmode_default1]
1700 path = $prefix_abs/share
1701 read only = no
1702 vfs objects = aio_pthread
1703 store dos attributes = yes
1704 aio_pthread:aio open = yes
1705 smbd async dosmode = yes
1707 [vfs_aio_pthread_async_dosmode_default2]
1708 path = $prefix_abs/share
1709 read only = no
1710 vfs objects = aio_pthread xattr_tdb
1711 store dos attributes = yes
1712 aio_pthread:aio open = yes
1713 smbd async dosmode = yes
1715 [async_dosmode_shadow_copy2]
1716 path = $prefix_abs/share
1717 read only = no
1718 vfs objects = shadow_copy2 xattr_tdb
1719 smbd async dosmode = yes
1721 [vfs_aio_fork]
1722 path = $prefix_abs/share
1723 vfs objects = aio_fork
1724 read only = no
1725 vfs_aio_fork:erratic_testing_mode=yes
1727 [dosmode]
1728 path = $prefix_abs/share
1729 vfs objects =
1730 store dos attributes = yes
1731 hide files = /hidefile/
1732 hide dot files = yes
1734 [hidenewfiles]
1735 path = $prefix_abs/share
1736 hide new files timeout = 5
1738 [external_streams_depot]
1739 path = $prefix_abs/share
1740 read only = no
1741 streams_depot:directory = $external_streams_depot
1744 my $vars = $self->provision(
1745 prefix => $path,
1746 domain => "WORKGROUP",
1747 server => "LOCALSHARE4",
1748 password => "local4pass",
1749 extra_options => $simpleserver_options);
1751 $vars or return undef;
1753 if (not $self->check_or_start(
1754 env_vars => $vars,
1755 nmbd => "yes",
1756 smbd => "yes")) {
1757 return undef;
1760 return $vars;
1763 sub create_file_chmod($$)
1765 my ($name, $mode) = @_;
1766 my $fh;
1768 unless (open($fh, '>', $name)) {
1769 warn("Unable to open $name");
1770 return undef;
1772 chmod($mode, $fh);
1775 sub setup_fileserver
1777 my ($self, $path, $more_conf, $server) = @_;
1778 my $prefix_abs = abs_path($path);
1779 my $srcdir_abs = abs_path($self->{srcdir});
1781 print "PROVISIONING file server ...\n";
1783 my @dirs = ();
1785 mkdir($prefix_abs, 0777);
1787 my $usershare_dir="$prefix_abs/lib/usershare";
1789 mkdir("$prefix_abs/lib", 0755);
1790 remove_tree($usershare_dir);
1791 mkdir($usershare_dir, 01770);
1793 my $share_dir="$prefix_abs/share";
1795 # Create share directory structure
1796 my $lower_case_share_dir="$share_dir/lower-case";
1797 push(@dirs, $lower_case_share_dir);
1799 my $lower_case_share_dir_30000="$share_dir/lower-case-30000";
1800 push(@dirs, $lower_case_share_dir_30000);
1802 my $dfree_share_dir="$share_dir/dfree";
1803 push(@dirs, $dfree_share_dir);
1804 push(@dirs, "$dfree_share_dir/subdir1");
1805 push(@dirs, "$dfree_share_dir/subdir2");
1806 push(@dirs, "$dfree_share_dir/subdir3");
1808 my $quotadir_dir="$share_dir/quota";
1809 push(@dirs, $quotadir_dir);
1811 my $valid_users_sharedir="$share_dir/valid_users";
1812 push(@dirs,$valid_users_sharedir);
1814 my $offline_sharedir="$share_dir/offline";
1815 push(@dirs,$offline_sharedir);
1817 my $force_user_valid_users_dir = "$share_dir/force_user_valid_users";
1818 push(@dirs, $force_user_valid_users_dir);
1820 my $tarmode_sharedir="$share_dir/tarmode";
1821 push(@dirs,$tarmode_sharedir);
1823 my $tarmode2_sharedir="$share_dir/tarmode2";
1824 push(@dirs,$tarmode2_sharedir);
1826 my $smbcacls_sharedir="$share_dir/smbcacls";
1827 push(@dirs,$smbcacls_sharedir);
1829 my $usershare_sharedir="$share_dir/usershares";
1830 push(@dirs,$usershare_sharedir);
1832 my $dropbox_sharedir="$share_dir/dropbox";
1833 push(@dirs,$dropbox_sharedir);
1835 my $bad_iconv_sharedir="$share_dir/bad_iconv";
1836 push(@dirs, $bad_iconv_sharedir);
1838 my $veto_sharedir="$share_dir/veto";
1839 push(@dirs,$veto_sharedir);
1841 my $virusfilter_sharedir="$share_dir/virusfilter";
1842 push(@dirs,$virusfilter_sharedir);
1844 my $delete_unwrite_sharedir="$share_dir/delete_unwrite";
1845 push(@dirs,$delete_unwrite_sharedir);
1846 push(@dirs, "$delete_unwrite_sharedir/delete_veto_yes");
1847 push(@dirs, "$delete_unwrite_sharedir/delete_veto_no");
1849 my $volume_serial_number_sharedir="$share_dir/volume_serial_number";
1850 push(@dirs, $volume_serial_number_sharedir);
1852 my $ip4 = Samba::get_ipv4_addr("FILESERVER");
1853 my $fileserver_options = "
1854 kernel change notify = yes
1855 spotlight backend = elasticsearch
1856 elasticsearch:address = $ip4
1857 elasticsearch:port = 8080
1858 elasticsearch:mappings = $srcdir_abs/source3/rpc_server/mdssvc/elasticsearch_mappings.json
1860 usershare path = $usershare_dir
1861 usershare max shares = 10
1862 usershare allow guests = yes
1863 usershare prefix allow list = $usershare_sharedir
1865 get quota command = $prefix_abs/getset_quota.py
1866 set quota command = $prefix_abs/getset_quota.py
1867 [tarmode]
1868 path = $tarmode_sharedir
1869 comment = tar test share
1870 xattr_tdb:file = $prefix_abs/tarmode-xattr.tdb
1871 [tarmode2]
1872 path = $tarmode2_sharedir
1873 comment = tar test share
1874 xattr_tdb:file = $prefix_abs/tarmode2-xattr.tdb
1875 [spotlight]
1876 path = $share_dir
1877 spotlight = yes
1878 read only = no
1879 [no_spotlight]
1880 path = $share_dir
1881 spotlight = no
1882 read only = no
1883 [lowercase]
1884 path = $lower_case_share_dir
1885 comment = smb username is [%U]
1886 case sensitive = True
1887 default case = lower
1888 preserve case = no
1889 short preserve case = no
1890 [lowercase-30000]
1891 path = $lower_case_share_dir_30000
1892 comment = smb username is [%U]
1893 case sensitive = True
1894 default case = lower
1895 preserve case = no
1896 short preserve case = no
1897 [dfree]
1898 path = $dfree_share_dir
1899 comment = smb username is [%U]
1900 dfree command = $srcdir_abs/testprogs/blackbox/dfree.sh
1901 [valid-users-access]
1902 path = $valid_users_sharedir
1903 valid users = +userdup
1904 [offline]
1905 path = $offline_sharedir
1906 vfs objects = offline
1908 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878
1909 # RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651
1910 [force_user_valid_users]
1911 path = $force_user_valid_users_dir
1912 comment = force user with valid users combination test share
1913 valid users = +force_user
1914 force user = force_user
1915 force group = everyone
1916 write list = force_user
1918 [ign_sysacls]
1919 path = $share_dir
1920 comment = ignore system acls
1921 acl_xattr:ignore system acls = yes
1922 [inherit_owner]
1923 path = $share_dir
1924 comment = inherit owner
1925 inherit owner = yes
1926 [inherit_owner_u]
1927 path = $share_dir
1928 comment = inherit only unix owner
1929 inherit owner = unix only
1930 acl_xattr:ignore system acls = yes
1931 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=13690
1932 [force_group_test]
1933 path = $share_dir
1934 comment = force group test
1935 # force group = everyone
1937 [create_mode_664]
1938 path = $share_dir
1939 comment = smb username is [%U]
1940 create mask = 0644
1941 force create mode = 0664
1942 vfs objects = dirsort
1944 [dropbox]
1945 path = $dropbox_sharedir
1946 comment = smb username is [%U]
1947 writeable = yes
1948 vfs objects =
1950 [bad_iconv]
1951 path = $bad_iconv_sharedir
1952 comment = smb username is [%U]
1953 vfs objects =
1955 [veto_files_nodelete]
1956 path = $veto_sharedir
1957 read only = no
1958 msdfs root = yes
1959 veto files = /veto_name*/
1960 delete veto files = no
1962 [veto_files_delete]
1963 path = $veto_sharedir
1964 msdfs root = yes
1965 veto files = /veto_name*/
1966 delete veto files = yes
1968 [delete_veto_files_only]
1969 path = $veto_sharedir
1970 delete veto files = yes
1972 [veto_files_nohidden]
1973 path = $veto_sharedir
1974 veto files = /.*/
1976 [veto_files]
1977 path = $veto_sharedir
1978 veto files = /veto_name*/
1980 [delete_yes_unwrite]
1981 read only = no
1982 path = $delete_unwrite_sharedir
1983 hide unwriteable files = yes
1984 delete veto files = yes
1986 [delete_no_unwrite]
1987 read only = no
1988 path = $delete_unwrite_sharedir
1989 hide unwriteable files = yes
1990 delete veto files = no
1992 [virusfilter]
1993 path = $virusfilter_sharedir
1994 vfs objects = acl_xattr virusfilter
1995 virusfilter:scanner = dummy
1996 virusfilter:min file size = 0
1997 virusfilter:infected files = *infected*
1998 virusfilter:infected file action = rename
1999 virusfilter:scan on close = yes
2000 vfs_default:VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS = no
2002 [volumeserialnumber]
2003 path = $volume_serial_number_sharedir
2004 volume serial number = 0xdeadbeef
2006 [ea_acl_xattr]
2007 path = $share_dir
2008 vfs objects = acl_xattr
2009 acl_xattr:security_acl_name = user.hackme
2010 read only = no
2012 [homes]
2013 comment = Home directories
2014 browseable = No
2015 read only = No
2018 if (defined($more_conf)) {
2019 $fileserver_options = $fileserver_options . $more_conf;
2021 if (!defined($server)) {
2022 $server = "FILESERVER";
2025 my $vars = $self->provision(
2026 prefix => $path,
2027 domain => "WORKGROUP",
2028 server => $server,
2029 password => "fileserver",
2030 extra_options => $fileserver_options,
2031 no_delete_prefix => 1);
2033 $vars or return undef;
2035 if (not $self->check_or_start(
2036 env_vars => $vars,
2037 nmbd => "yes",
2038 smbd => "yes")) {
2039 return undef;
2043 mkdir($_, 0777) foreach(@dirs);
2045 ## Create case sensitive lower case share dir
2046 foreach my $file ('a'..'z') {
2047 my $full_path = $lower_case_share_dir . '/' . $file;
2048 open my $fh, '>', $full_path;
2049 # Add some content to file
2050 print $fh $full_path;
2051 close $fh;
2054 for (my $file = 1; $file < 51; ++$file) {
2055 my $full_path = $lower_case_share_dir . '/' . $file;
2056 open my $fh, '>', $full_path;
2057 # Add some content to file
2058 print $fh $full_path;
2059 close $fh;
2062 # Create content for 30000 share
2063 foreach my $file ('a'..'z') {
2064 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
2065 open my $fh, '>', $full_path;
2066 # Add some content to file
2067 print $fh $full_path;
2068 close $fh;
2071 for (my $file = 1; $file < 30001; ++$file) {
2072 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
2073 open my $fh, '>', $full_path;
2074 # Add some content to file
2075 print $fh $full_path;
2076 close $fh;
2080 ## create a listable file in valid_users_share
2082 create_file_chmod("$valid_users_sharedir/foo", 0644) or return undef;
2085 ## create a valid utf8 filename which is invalid as a CP850 conversion
2087 create_file_chmod("$bad_iconv_sharedir/\xED\x9F\xBF", 0644) or return undef;
2090 ## create unwritable files inside inside the delete unwrite veto share dirs.
2092 unlink("$delete_unwrite_sharedir/delete_veto_yes/file_444");
2093 create_file_chmod("$delete_unwrite_sharedir/delete_veto_yes/file_444", 0444) or return undef;
2094 unlink("$delete_unwrite_sharedir/delete_veto_no/file_444");
2095 create_file_chmod("$delete_unwrite_sharedir/delete_veto_no/file_444", 0444) or return undef;
2097 return $vars;
2100 sub setup_fileserver_smb1
2102 my ($self, $path) = @_;
2103 my $prefix_abs = abs_path($path);
2104 my $conf = "
2105 [global]
2106 client min protocol = CORE
2107 server min protocol = LANMAN1
2108 check parent directory delete on close = yes
2110 [hidenewfiles]
2111 path = $prefix_abs/share
2112 hide new files timeout = 5
2113 [vfs_aio_pthread]
2114 path = $prefix_abs/share
2115 read only = no
2116 vfs objects = aio_pthread
2117 aio_pthread:aio open = yes
2118 smbd async dosmode = no
2120 [vfs_aio_pthread_async_dosmode_default1]
2121 path = $prefix_abs/share
2122 read only = no
2123 vfs objects = aio_pthread
2124 store dos attributes = yes
2125 aio_pthread:aio open = yes
2126 smbd async dosmode = yes
2128 [vfs_aio_pthread_async_dosmode_default2]
2129 path = $prefix_abs/share
2130 read only = no
2131 vfs objects = aio_pthread xattr_tdb
2132 store dos attributes = yes
2133 aio_pthread:aio open = yes
2134 smbd async dosmode = yes
2136 [vfs_aio_fork]
2137 path = $prefix_abs/share
2138 vfs objects = aio_fork
2139 read only = no
2140 vfs_aio_fork:erratic_testing_mode=yes
2142 return $self->setup_fileserver($path, $conf, "FILESERVERSMB1");
2145 sub setup_fileserver_smb1_done
2147 my ($self, $path, $dep_env) = @_;
2148 return $self->return_alias_env($path, $dep_env);
2151 sub setup_ktest
2153 my ($self, $prefix) = @_;
2155 # If we didn't build with ADS, pretend this env was never available
2156 if (not $self->have_ads()) {
2157 return "UNKNOWN";
2160 print "PROVISIONING server with security=ads...";
2162 my $ktest_options = "
2163 workgroup = KTEST
2164 realm = ktest.samba.example.com
2165 security = ads
2166 server signing = required
2167 server min protocol = SMB3_00
2168 client max protocol = SMB3
2170 # This disables NTLM auth against the local SAM, which
2171 # we use can then test this setting by.
2172 ntlm auth = disabled
2174 idmap config * : backend = autorid
2175 idmap config * : range = 1000000-1999999
2176 idmap config * : rangesize = 100000
2179 my $ret = $self->provision(
2180 prefix => $prefix,
2181 domain => "KTEST",
2182 server => "LOCALKTEST6",
2183 password => "localktest6pass",
2184 extra_options => $ktest_options);
2186 $ret or return undef;
2188 my $ctx;
2189 my $prefix_abs = abs_path($prefix);
2190 $ctx = {};
2191 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
2192 $ctx->{domain} = "KTEST";
2193 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
2194 $ctx->{dnsname} = lc($ctx->{realm});
2195 $ctx->{kdc_ipv4} = "0.0.0.0";
2196 $ctx->{kdc_ipv6} = "::";
2197 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
2198 Samba::mk_krb5_conf($ctx, "");
2200 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
2202 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
2203 #Samba4 DC with the same parameters as are being used here. The
2204 #domain SID is S-1-5-21-1071277805-689288055-3486227160
2205 $ret->{SAMSID} = "S-1-5-21-1911091480-1468226576-2729736297";
2206 $ret->{DOMSID} = "S-1-5-21-1071277805-689288055-3486227160";
2208 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
2209 chmod 0600, "$prefix/private/secrets.tdb";
2211 #Make sure there's no old ntdb file.
2212 system("rm -f $prefix/private/secrets.ntdb");
2214 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
2215 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
2217 #and having in krb5.conf:
2218 # ticket_lifetime = 799718400
2219 # renew_lifetime = 799718400
2221 # The commands for the -2 keytab where were:
2222 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
2223 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
2224 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
2225 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
2226 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
2228 # and then for the -3 keytab, I did
2230 # net changetrustpw; kdestroy and the same again.
2232 # This creates a credential cache with a very long lifetime (2036 at
2233 # at 2011-04), and shows that running 'net changetrustpw' does not
2234 # break existing logins (for the secrets.tdb method at least).
2237 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
2239 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
2240 chmod 0600, "$prefix/krb5_ccache-2";
2242 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
2243 chmod 0600, "$prefix/krb5_ccache-3";
2245 # We need world access to this share, as otherwise the domain
2246 # administrator from the AD domain provided by ktest can't
2247 # access the share for tests.
2248 chmod 0777, "$prefix/share";
2250 if (not $self->check_or_start(
2251 env_vars => $ret,
2252 nmbd => "yes",
2253 winbindd => "offline",
2254 smbd => "yes")) {
2255 return undef;
2257 return $ret;
2260 sub setup_maptoguest
2262 my ($self, $path) = @_;
2263 my $prefix_abs = abs_path($path);
2264 my $libdir="$prefix_abs/lib";
2265 my $share_dir="$prefix_abs/share";
2266 my $errorinjectconf="$libdir/error_inject.conf";
2268 print "PROVISIONING maptoguest...";
2270 my $options = "
2271 domain logons = yes
2272 map to guest = bad user
2273 ntlm auth = yes
2274 server min protocol = LANMAN1
2276 [force_user_error_inject]
2277 path = $share_dir
2278 vfs objects = acl_xattr fake_acls xattr_tdb error_inject
2279 force user = user1
2280 include = $errorinjectconf
2283 my $vars = $self->provision(
2284 prefix => $path,
2285 domain => "WORKGROUP",
2286 server => "maptoguest",
2287 password => "maptoguestpass",
2288 extra_options => $options);
2290 $vars or return undef;
2292 if (not $self->check_or_start(
2293 env_vars => $vars,
2294 nmbd => "yes",
2295 winbindd => "yes",
2296 smbd => "yes")) {
2297 return undef;
2300 return $vars;
2303 sub stop_sig_term($$) {
2304 my ($self, $pid) = @_;
2305 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
2308 sub stop_sig_kill($$) {
2309 my ($self, $pid) = @_;
2310 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
2313 sub write_pid($$$)
2315 my ($env_vars, $app, $pid) = @_;
2317 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
2318 print PID $pid;
2319 close(PID);
2322 sub read_pid($$)
2324 my ($env_vars, $app) = @_;
2326 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
2327 my $pid = <PID>;
2328 close(PID);
2329 return $pid;
2332 # builds up the cmd args to run an s3 binary (i.e. smbd, nmbd, etc)
2333 sub make_bin_cmd
2335 my ($self, $binary, $env_vars, $options, $valgrind, $dont_log_stdout) = @_;
2337 my @optargs = ();
2338 if (defined($options)) {
2339 @optargs = split(/ /, $options);
2341 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
2343 if (defined($valgrind)) {
2344 @preargs = split(/ /, $valgrind);
2346 my @args = ("-F", "--no-process-group",
2347 "--configfile=$env_vars->{SERVERCONFFILE}",
2348 "-l", $env_vars->{LOGDIR});
2350 if (not defined($dont_log_stdout)) {
2351 push(@args, "--debug-stdout");
2353 return (@preargs, $binary, @args, @optargs);
2356 sub check_or_start($$) {
2357 my ($self, %args) = @_;
2358 my $env_vars = $args{env_vars};
2359 my $nmbd = $args{nmbd} // "no";
2360 my $winbindd = $args{winbindd} // "no";
2361 my $smbd = $args{smbd} // "no";
2362 my $samba_dcerpcd = $args{samba_dcerpcd} // "no";
2363 my $child_cleanup = $args{child_cleanup};
2365 my $STDIN_READER;
2367 # use a pipe for stdin in the child processes. This allows
2368 # those processes to monitor the pipe for EOF to ensure they
2369 # exit when the test script exits
2370 pipe($STDIN_READER, $env_vars->{STDIN_PIPE});
2372 my $binary = Samba::bindir_path($self, "samba-dcerpcd");
2373 my @full_cmd = $self->make_bin_cmd(
2374 $binary,
2375 $env_vars,
2376 $ENV{SAMBA_DCERPCD_OPTIONS},
2377 $ENV{SAMBA_DCERPCD_VALGRIND},
2378 $ENV{SAMBA_DCERPCD_DONT_LOG_STDOUT});
2379 push(@full_cmd, '--libexec-rpcds');
2381 my $samba_dcerpcd_envs = Samba::get_env_for_process(
2382 "samba_dcerpcd", $env_vars);
2384 # fork and exec() samba_dcerpcd in the child process
2385 my $daemon_ctx = {
2386 NAME => "samba_dcerpcd",
2387 BINARY_PATH => $binary,
2388 FULL_CMD => [ @full_cmd ],
2389 LOG_FILE => $env_vars->{SAMBA_DCERPCD_TEST_LOG},
2390 PCAP_FILE => "env-$ENV{ENVNAME}-samba_dcerpcd",
2391 ENV_VARS => $samba_dcerpcd_envs,
2393 if ($samba_dcerpcd ne "yes") {
2394 $daemon_ctx->{SKIP_DAEMON} = 1;
2397 my $pid = Samba::fork_and_exec(
2398 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
2400 $env_vars->{SAMBA_DCERPCD_TL_PID} = $pid;
2401 write_pid($env_vars, "samba_dcerpcd", $pid);
2403 $binary = Samba::bindir_path($self, "nmbd");
2404 @full_cmd = $self->make_bin_cmd($binary, $env_vars,
2405 $ENV{NMBD_OPTIONS}, $ENV{NMBD_VALGRIND},
2406 $ENV{NMBD_DONT_LOG_STDOUT});
2407 my $nmbd_envs = Samba::get_env_for_process("nmbd", $env_vars);
2408 delete $nmbd_envs->{RESOLV_WRAPPER_CONF};
2409 delete $nmbd_envs->{RESOLV_WRAPPER_HOSTS};
2411 # fork and exec() nmbd in the child process
2412 $daemon_ctx = {
2413 NAME => "nmbd",
2414 BINARY_PATH => $binary,
2415 FULL_CMD => [ @full_cmd ],
2416 LOG_FILE => $env_vars->{NMBD_TEST_LOG},
2417 PCAP_FILE => "env-$ENV{ENVNAME}-nmbd",
2418 ENV_VARS => $nmbd_envs,
2420 if ($nmbd ne "yes") {
2421 $daemon_ctx->{SKIP_DAEMON} = 1;
2423 $pid = Samba::fork_and_exec(
2424 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
2426 $env_vars->{NMBD_TL_PID} = $pid;
2427 write_pid($env_vars, "nmbd", $pid);
2429 $binary = Samba::bindir_path($self, "winbindd");
2430 @full_cmd = $self->make_bin_cmd($binary, $env_vars,
2431 $ENV{WINBINDD_OPTIONS},
2432 $ENV{WINBINDD_VALGRIND},
2433 $ENV{WINBINDD_DONT_LOG_STDOUT});
2435 # fork and exec() winbindd in the child process
2436 $daemon_ctx = {
2437 NAME => "winbindd",
2438 BINARY_PATH => $binary,
2439 FULL_CMD => [ @full_cmd ],
2440 LOG_FILE => $env_vars->{WINBINDD_TEST_LOG},
2441 PCAP_FILE => "env-$ENV{ENVNAME}-winbindd",
2443 if ($winbindd ne "yes" and $winbindd ne "offline") {
2444 $daemon_ctx->{SKIP_DAEMON} = 1;
2447 $pid = Samba::fork_and_exec(
2448 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
2450 $env_vars->{WINBINDD_TL_PID} = $pid;
2451 write_pid($env_vars, "winbindd", $pid);
2453 $binary = Samba::bindir_path($self, "smbd");
2454 @full_cmd = $self->make_bin_cmd($binary, $env_vars,
2455 $ENV{SMBD_OPTIONS}, $ENV{SMBD_VALGRIND},
2456 $ENV{SMBD_DONT_LOG_STDOUT});
2458 # fork and exec() smbd in the child process
2459 $daemon_ctx = {
2460 NAME => "smbd",
2461 BINARY_PATH => $binary,
2462 FULL_CMD => [ @full_cmd ],
2463 LOG_FILE => $env_vars->{SMBD_TEST_LOG},
2464 PCAP_FILE => "env-$ENV{ENVNAME}-smbd",
2466 if ($smbd ne "yes") {
2467 $daemon_ctx->{SKIP_DAEMON} = 1;
2470 $pid = Samba::fork_and_exec(
2471 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
2473 $env_vars->{SMBD_TL_PID} = $pid;
2474 write_pid($env_vars, "smbd", $pid);
2476 # close the parent's read-end of the pipe
2477 close($STDIN_READER);
2479 return $self->wait_for_start($env_vars,
2480 $nmbd,
2481 $winbindd,
2482 $smbd,
2483 $samba_dcerpcd);
2486 sub createuser($$$$$)
2488 my ($self, $username, $password, $conffile, $env) = @_;
2489 my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $username > /dev/null";
2491 keys %$env;
2492 while(my($var, $val) = each %$env) {
2493 $cmd = "$var=\"$val\" $cmd";
2496 unless (open(PWD, "|$cmd")) {
2497 warn("Unable to set password for $username account\n$cmd");
2498 return undef;
2500 print PWD "$password\n$password\n";
2501 unless (close(PWD)) {
2502 warn("Unable to set password for $username account\n$cmd");
2503 return undef;
2507 sub provision($$)
2509 my ($self, %args) = @_;
2511 my $prefix = $args{prefix};
2512 my $domain = $args{domain};
2513 my $realm = $args{realm};
2514 my $server = $args{server};
2515 my $password = $args{password};
2516 my $extra_options = $args{extra_options};
2517 my $resolv_conf = $args{resolv_conf};
2518 my $no_delete_prefix= $args{no_delete_prefix};
2519 my $netbios_name = $args{netbios_name} // $server;
2520 my $server_log_level = $ENV{SERVER_LOG_LEVEL} || 1;
2523 ## setup the various environment variables we need
2526 my $samsid = Samba::random_domain_sid();
2527 my $swiface = Samba::get_interface($server);
2528 my %ret = ();
2529 my %createuser_env = ();
2530 my $server_ip = Samba::get_ipv4_addr($server);
2531 my $server_ipv6 = Samba::get_ipv6_addr($server);
2532 my $dns_domain;
2533 if (defined($realm)) {
2534 $dns_domain = lc($realm);
2535 } else {
2536 $dns_domain = "samba.example.com";
2539 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
2540 chomp $unix_name;
2541 my $unix_uid = $>;
2542 my $unix_gids_str = $);
2543 my @unix_gids = split(" ", $unix_gids_str);
2545 my $prefix_abs = abs_path($prefix);
2546 my $bindir_abs = abs_path($self->{bindir});
2548 my @dirs = ();
2550 my $shrdir=$args{share_dir} // "$prefix_abs/share";
2551 push(@dirs,$shrdir);
2553 my $libdir="$prefix_abs/lib";
2554 push(@dirs,$libdir);
2556 my $piddir="$prefix_abs/pid";
2557 push(@dirs,$piddir);
2559 my $privatedir="$prefix_abs/private";
2560 push(@dirs,$privatedir);
2562 my $cachedir = "$prefix_abs/cachedir";
2563 push(@dirs, $cachedir);
2565 my $binddnsdir = "$prefix_abs/bind-dns";
2566 push(@dirs, $binddnsdir);
2568 my $lockdir="$prefix_abs/lockdir";
2569 push(@dirs,$lockdir);
2571 my $eventlogdir="$prefix_abs/lockdir/eventlog";
2572 push(@dirs,$eventlogdir);
2574 my $logdir="$prefix_abs/logs";
2575 push(@dirs,$logdir);
2577 my $driver32dir="$shrdir/W32X86";
2578 push(@dirs,$driver32dir);
2580 my $driver64dir="$shrdir/x64";
2581 push(@dirs,$driver64dir);
2583 my $driver40dir="$shrdir/WIN40";
2584 push(@dirs,$driver40dir);
2586 my $ro_shrdir="$shrdir/root-tmp";
2587 push(@dirs,$ro_shrdir);
2589 my $noperm_shrdir="$shrdir/noperm-tmp";
2590 push(@dirs,$noperm_shrdir);
2592 my $msdfs_shrdir="$shrdir/msdfsshare";
2593 push(@dirs,$msdfs_shrdir);
2595 my $msdfs_shrdir2="$shrdir/msdfsshare2";
2596 push(@dirs,$msdfs_shrdir2);
2598 my $msdfs_pathname_share="$shrdir/msdfs_pathname_share";
2599 push(@dirs,$msdfs_pathname_share);
2601 my $non_msdfs_pathname_share="$shrdir/non_msdfs_pathname_share";
2602 push(@dirs,$non_msdfs_pathname_share);
2604 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
2605 push(@dirs,$msdfs_deeppath);
2607 my $smbcacls_sharedir_dfs="$shrdir/smbcacls_sharedir_dfs";
2608 push(@dirs,$smbcacls_sharedir_dfs);
2610 my $smbcacls_share="$shrdir/smbcacls_share";
2611 push(@dirs,$smbcacls_share);
2613 my $smbcacls_share_testdir="$shrdir/smbcacls_share/smbcacls";
2614 push(@dirs,$smbcacls_share_testdir);
2616 my $badnames_shrdir="$shrdir/badnames";
2617 push(@dirs,$badnames_shrdir);
2619 my $lease1_shrdir="$shrdir/dynamic";
2620 push(@dirs,$lease1_shrdir);
2622 my $manglenames_shrdir="$shrdir/manglenames";
2623 push(@dirs,$manglenames_shrdir);
2625 my $widelinks_shrdir="$shrdir/widelinks";
2626 push(@dirs,$widelinks_shrdir);
2628 my $widelinks_linkdir="$shrdir/widelinks_foo";
2629 push(@dirs,$widelinks_linkdir);
2631 my $fsrvp_shrdir="$shrdir/fsrvp";
2632 push(@dirs,$fsrvp_shrdir);
2634 my $shadow_tstdir="$shrdir/shadow";
2635 push(@dirs,$shadow_tstdir);
2636 my $shadow_mntdir="$shadow_tstdir/mount";
2637 push(@dirs,$shadow_mntdir);
2638 my $shadow_basedir="$shadow_mntdir/base";
2639 push(@dirs,$shadow_basedir);
2640 my $shadow_shrdir="$shadow_basedir/share";
2641 push(@dirs,$shadow_shrdir);
2643 my $nosymlinks_shrdir="$shrdir/nosymlinks";
2644 push(@dirs,$nosymlinks_shrdir);
2646 my $local_symlinks_shrdir="$shrdir/local_symlinks";
2647 push(@dirs,$local_symlinks_shrdir);
2649 my $fruit_resource_stream_shrdir="$shrdir/fruit_resource_stream";
2650 push(@dirs,$fruit_resource_stream_shrdir);
2652 my $smbget_sharedir="$shrdir/smbget";
2653 push(@dirs, $smbget_sharedir);
2655 # this gets autocreated by winbindd
2656 my $wbsockdir="$prefix_abs/wbsock";
2658 my $nmbdsockdir="$prefix_abs/nmbd";
2659 unlink($nmbdsockdir);
2662 ## create the test directory layout
2664 die ("prefix_abs = ''") if $prefix_abs eq "";
2665 die ("prefix_abs = '/'") if $prefix_abs eq "/";
2667 mkdir($prefix_abs, 0777);
2668 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
2669 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
2670 system("rm -rf $prefix_abs/*");
2672 mkdir($_, 0777) foreach(@dirs);
2674 my $fs_specific_conf = $self->get_fs_specific_conf($shrdir);
2677 ## lockdir and piddir must be 0755
2679 chmod 0755, $lockdir;
2680 chmod 0755, $piddir;
2684 ## Create a directory without permissions to enter
2686 chmod 0000, $noperm_shrdir;
2689 ## create ro and msdfs share layout
2692 chmod 0755, $ro_shrdir;
2694 create_file_chmod("$ro_shrdir/readable_file", 0644) or return undef;
2695 create_file_chmod("$ro_shrdir/unreadable_file", 0600) or return undef;
2697 create_file_chmod("$ro_shrdir/msdfs-target", 0600) or return undef;
2698 symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp",
2699 "$msdfs_shrdir/msdfs-src1";
2700 symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
2701 symlink "msdfs:$server_ip\\smbcacls_sharedir_dfs,$server_ipv6\\smbcacls_sharedir_dfs",
2702 "$msdfs_shrdir/smbcacls_sharedir_dfs";
2704 symlink "msdfs:$server_ip\\msdfs-share2,$server_ipv6\\msdfs-share2", "$msdfs_shrdir/dfshop1";
2705 symlink "msdfs:$server_ip\\tmp,$server_ipv6\\tmp", "$msdfs_shrdir2/dfshop2";
2707 ## create bad names in $badnames_shrdir
2709 ## (An invalid name, would be mangled to 8.3).
2710 create_file_chmod("$badnames_shrdir/\340|\231\216\377\177",
2711 0600) or return undef;
2713 ## (A bad name, would not be mangled to 8.3).
2714 create_file_chmod("$badnames_shrdir/\240\276\346\327\377\177",
2715 0666) or return undef;
2717 ## (A bad good name).
2718 create_file_chmod("$badnames_shrdir/blank.txt",
2719 0666) or return undef;
2722 ## create mangleable directory names in $manglenames_shrdir
2724 my $manglename_target = "$manglenames_shrdir/foo:bar";
2725 mkdir($manglename_target, 0777);
2728 ## create symlinks for widelinks tests.
2730 my $widelinks_target = "$widelinks_linkdir/target";
2731 create_file_chmod("$widelinks_target", 0666) or return undef;
2734 ## This link should get an error
2736 symlink "$widelinks_target", "$widelinks_shrdir/source";
2738 ## This link should be allowed
2740 symlink "$widelinks_shrdir", "$widelinks_shrdir/dot";
2742 my $conffile="$libdir/server.conf";
2743 my $dfqconffile="$libdir/dfq.conf";
2744 my $errorinjectconf="$libdir/error_inject.conf";
2745 my $delayinjectconf="$libdir/delay_inject.conf";
2746 my $globalinjectconf="$libdir/global_inject.conf";
2747 my $aliceconfdir="$libdir";
2748 my $aliceconffile="$libdir/alice.conf";
2750 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/third_party/nss_wrapper/nss_wrapper.pl";
2751 my $nss_wrapper_passwd = "$privatedir/passwd";
2752 my $nss_wrapper_group = "$privatedir/group";
2753 my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts";
2754 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
2756 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
2758 my $fake_snap_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/fake_snap.pl";
2760 my @eventlog_list = ("dns server", "application");
2763 ## calculate uids and gids
2766 my ($max_uid, $max_gid);
2767 my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
2768 my ($uid_pdbtest_wkn);
2769 my ($uid_smbget);
2770 my ($uid_force_user);
2771 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
2772 my ($gid_userdup, $gid_everyone);
2773 my ($gid_force_user);
2774 my ($gid_jackthemapper);
2775 my ($gid_jacknomapper);
2776 my ($uid_user1);
2777 my ($uid_user2);
2778 my ($uid_gooduser);
2779 my ($uid_eviluser);
2780 my ($uid_slashuser);
2781 my ($uid_localbob);
2782 my ($uid_localjane);
2783 my ($uid_localjackthemapper);
2784 my ($uid_localjacknomapper);
2786 if ($unix_uid < 0xffff - 13) {
2787 $max_uid = 0xffff;
2788 } else {
2789 $max_uid = $unix_uid;
2792 $uid_root = $max_uid - 1;
2793 $uid_nobody = $max_uid - 2;
2794 $uid_pdbtest = $max_uid - 3;
2795 $uid_pdbtest2 = $max_uid - 4;
2796 $uid_userdup = $max_uid - 5;
2797 $uid_pdbtest_wkn = $max_uid - 6;
2798 $uid_force_user = $max_uid - 7;
2799 $uid_smbget = $max_uid - 8;
2800 $uid_user1 = $max_uid - 9;
2801 $uid_user2 = $max_uid - 10;
2802 $uid_gooduser = $max_uid - 11;
2803 $uid_eviluser = $max_uid - 12;
2804 $uid_slashuser = $max_uid - 13;
2805 $uid_localbob = $max_uid - 14;
2806 $uid_localjane = $max_uid - 15;
2807 $uid_localjackthemapper = $max_uid - 16;
2808 $uid_localjacknomapper = $max_uid - 17;
2810 if ($unix_gids[0] < 0xffff - 8) {
2811 $max_gid = 0xffff;
2812 } else {
2813 $max_gid = $unix_gids[0];
2816 $gid_nobody = $max_gid - 1;
2817 $gid_nogroup = $max_gid - 2;
2818 $gid_root = $max_gid - 3;
2819 $gid_domusers = $max_gid - 4;
2820 $gid_domadmins = $max_gid - 5;
2821 $gid_userdup = $max_gid - 6;
2822 $gid_everyone = $max_gid - 7;
2823 $gid_force_user = $max_gid - 8;
2824 $gid_jackthemapper = $max_gid - 9;
2825 $gid_jacknomapper = $max_gid - 10;
2828 ## create conffile
2831 unless (open(CONF, ">$conffile")) {
2832 warn("Unable to open $conffile");
2833 return undef;
2836 my $interfaces = Samba::get_interfaces_config($server);
2838 print CONF "
2839 [global]
2840 dcesrv:fuzz directory = $cachedir/fuzz
2841 netbios name = $netbios_name
2842 interfaces = $interfaces
2843 bind interfaces only = yes
2844 panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
2845 smbd:suicide mode = yes
2846 smbd:FSCTL_SMBTORTURE = yes
2847 smbd:validate_oplock_types = yes
2849 client min protocol = SMB2_02
2850 server min protocol = SMB2_02
2852 server multi channel support = yes
2854 workgroup = $domain
2856 private dir = $privatedir
2857 binddns dir = $binddnsdir
2858 pid directory = $piddir
2859 lock directory = $lockdir
2860 log file = $logdir/log.\%m
2861 log level = $server_log_level
2862 winbind debug traceid = yes
2863 debug pid = yes
2864 max log size = 0
2866 debug syslog format = always
2867 debug hires timestamp = yes
2869 state directory = $lockdir
2870 cache directory = $lockdir
2872 passdb backend = tdbsam
2874 time server = yes
2876 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
2877 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
2878 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
2879 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
2880 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
2881 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
2882 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
2884 addprinter command = $mod_printer_pl -a -s $conffile --
2885 deleteprinter command = $mod_printer_pl -d -s $conffile --
2887 eventlog list = application \"dns server\"
2889 kernel oplocks = no
2890 kernel change notify = no
2892 logging = file
2893 printing = bsd
2894 printcap name = /dev/null
2896 winbindd socket directory = $wbsockdir
2897 nmbd:socket dir = $nmbdsockdir
2898 idmap config * : range = 100000-200000
2899 winbind enum users = yes
2900 winbind enum groups = yes
2901 winbind separator = /
2902 include system krb5 conf = no
2904 # min receivefile size = 4000
2906 read only = no
2908 smbd:sharedelay = 100000
2909 smbd:writetimeupdatedelay = 500000
2910 map hidden = no
2911 map system = no
2912 map readonly = no
2913 store dos attributes = yes
2914 create mask = 755
2915 dos filemode = yes
2916 strict rename = yes
2917 strict sync = yes
2918 mangled names = yes
2919 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot time_audit full_audit
2921 full_audit:syslog = no
2922 full_audit:success = none
2923 full_audit:failure = none
2925 printing = vlp
2926 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
2927 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
2928 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
2929 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
2930 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
2931 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
2932 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
2933 lpq cache time = 0
2934 print notify backchannel = yes
2936 ncalrpc dir = $prefix_abs/ncalrpc
2938 # The samba3.blackbox.smbclient_s3 test uses this to test that
2939 # sending messages works, and that the %m sub works.
2940 message command = mv %s $shrdir/message.%m
2942 # fsrvp server requires registry shares
2943 registry shares = yes
2945 # Used by RPC SRVSVC tests
2946 add share command = $bindir_abs/smbaddshare
2947 change share command = $bindir_abs/smbchangeshare
2948 delete share command = $bindir_abs/smbdeleteshare
2950 # fruit:copyfile is a global option
2951 fruit:copyfile = yes
2953 #this does not mean that we use non-secure test env,
2954 #it just means we ALLOW one to be configured.
2955 allow insecure wide links = yes
2957 include = $globalinjectconf
2959 # Begin extra options
2960 $extra_options
2961 # End extra options
2963 #Include user defined custom parameters if set
2966 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
2967 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
2970 print CONF "
2971 [smbcacls_share]
2972 path = $smbcacls_share
2973 comment = smb username is [%U]
2974 msdfs root = yes
2976 [smbcacls_sharedir_dfs]
2977 path = $smbcacls_sharedir_dfs
2978 comment = smb username is [%U]
2979 [tmp]
2980 path = $shrdir
2981 comment = smb username is [%U]
2982 [tmpsort]
2983 path = $shrdir
2984 comment = Load dirsort module
2985 vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot
2986 [tmpenc]
2987 path = $shrdir
2988 comment = encrypt smb username is [%U]
2989 server smb encrypt = required
2990 vfs objects = dirsort
2991 [tmpguest]
2992 path = $shrdir
2993 guest ok = yes
2994 [guestonly]
2995 path = $shrdir
2996 guest only = yes
2997 guest ok = yes
2998 [forceuser]
2999 path = $shrdir
3000 force user = $unix_name
3001 guest ok = yes
3002 [forceuser_unixonly]
3003 comment = force a user with unix user SID and group SID
3004 path = $shrdir
3005 force user = pdbtest
3006 guest ok = yes
3007 [forceuser_wkngroup]
3008 comment = force a user with well-known group SID
3009 path = $shrdir
3010 force user = pdbtest_wkn
3011 guest ok = yes
3012 [forcegroup]
3013 path = $shrdir
3014 force group = nogroup
3015 guest ok = yes
3016 [ro-tmp]
3017 path = $ro_shrdir
3018 guest ok = yes
3019 [noperm]
3020 path = $noperm_shrdir
3021 wide links = yes
3022 guest ok = yes
3023 [write-list-tmp]
3024 path = $shrdir
3025 read only = yes
3026 write list = $unix_name
3027 [valid-users-tmp]
3028 path = $shrdir
3029 valid users = $unix_name
3030 access based share enum = yes
3031 [msdfs-share]
3032 path = $msdfs_shrdir
3033 msdfs root = yes
3034 msdfs shuffle referrals = yes
3035 guest ok = yes
3036 [msdfs-share2]
3037 path = $msdfs_shrdir2
3038 msdfs root = yes
3039 guest ok = yes
3040 [msdfs-pathname-share]
3041 path = $msdfs_pathname_share
3042 msdfs root = yes
3043 guest ok = yes
3044 [non-msdfs-pathname-share]
3045 path = $non_msdfs_pathname_share
3046 msdfs root = no
3047 guest ok = yes
3048 [hideunread]
3049 copy = tmp
3050 hide unreadable = yes
3051 [tmpcase]
3052 copy = tmp
3053 case sensitive = yes
3054 [hideunwrite]
3055 copy = tmp
3056 hide unwriteable files = yes
3057 [durable]
3058 copy = tmp
3059 kernel share modes = no
3060 kernel oplocks = no
3061 posix locking = no
3062 [fs_specific]
3063 copy = tmp
3064 $fs_specific_conf
3065 [print1]
3066 copy = tmp
3067 printable = yes
3069 [print2]
3070 copy = print1
3071 [print3]
3072 copy = print1
3073 default devmode = no
3075 [print_var_exp]
3076 copy = print1
3077 print command = $self->{srcdir}/source3/script/tests/printing/printing_var_exp_lpr_cmd.sh \"Windows user: %U\" \"UNIX user: %u\" \"Domain: %D\"
3079 [lp]
3080 copy = print1
3082 [nfs4acl_simple_40]
3083 path = $shrdir
3084 comment = smb username is [%U]
3085 nfs4:mode = simple
3086 nfs4acl_xattr:version = 40
3087 vfs objects = nfs4acl_xattr xattr_tdb
3089 [nfs4acl_special_40]
3090 path = $shrdir
3091 comment = smb username is [%U]
3092 nfs4:mode = special
3093 nfs4acl_xattr:version = 40
3094 vfs objects = nfs4acl_xattr xattr_tdb
3096 [nfs4acl_simple_41]
3097 path = $shrdir
3098 comment = smb username is [%U]
3099 nfs4:mode = simple
3100 vfs objects = nfs4acl_xattr xattr_tdb
3102 [nfs4acl_xdr_40]
3103 path = $shrdir
3104 comment = smb username is [%U]
3105 vfs objects = nfs4acl_xattr xattr_tdb
3106 nfs4:mode = simple
3107 nfs4acl_xattr:encoding = xdr
3108 nfs4acl_xattr:version = 40
3110 [nfs4acl_xdr_41]
3111 path = $shrdir
3112 comment = smb username is [%U]
3113 vfs objects = nfs4acl_xattr xattr_tdb
3114 nfs4:mode = simple
3115 nfs4acl_xattr:encoding = xdr
3116 nfs4acl_xattr:version = 41
3118 [nfs4acl_nfs_40]
3119 path = $shrdir
3120 comment = smb username is [%U]
3121 vfs objects = nfs4acl_xattr xattr_tdb
3122 nfs4:mode = simple
3123 nfs4acl_xattr:encoding = nfs
3124 nfs4acl_xattr:version = 40
3125 nfs4acl_xattr:xattr_name = security.nfs4acl_xdr
3127 [nfs4acl_nfs_41]
3128 path = $shrdir
3129 comment = smb username is [%U]
3130 vfs objects = nfs4acl_xattr xattr_tdb
3131 nfs4:mode = simple
3132 nfs4acl_xattr:encoding = nfs
3133 nfs4acl_xattr:version = 41
3134 nfs4acl_xattr:xattr_name = security.nfs4acl_xdr
3136 [xcopy_share]
3137 path = $shrdir
3138 comment = smb username is [%U]
3139 create mask = 777
3140 force create mode = 777
3141 [posix_share]
3142 path = $shrdir
3143 comment = smb username is [%U]
3144 create mask = 0777
3145 force create mode = 0
3146 directory mask = 0777
3147 force directory mode = 0
3148 vfs objects = xattr_tdb streams_depot
3149 [smb3_posix_share]
3150 vfs objects = fake_acls xattr_tdb streams_depot time_audit full_audit
3151 create mask = 07777
3152 directory mask = 07777
3153 mangled names = no
3154 path = $shrdir
3155 read only = no
3156 guest ok = yes
3157 [aio]
3158 copy = durable
3159 aio read size = 1
3160 aio write size = 1
3162 [print\$]
3163 copy = tmp
3165 [vfs_fruit]
3166 path = $shrdir
3167 vfs objects = catia fruit streams_xattr acl_xattr xattr_tdb
3168 fruit:resource = file
3169 fruit:metadata = netatalk
3170 fruit:locking = netatalk
3171 fruit:encoding = native
3172 fruit:veto_appledouble = no
3174 [vfs_fruit_xattr]
3175 path = $shrdir
3176 # This is used by vfs.fruit tests that require real fs xattr
3177 vfs objects = catia fruit streams_xattr acl_xattr
3178 fruit:resource = file
3179 fruit:metadata = netatalk
3180 fruit:locking = netatalk
3181 fruit:encoding = native
3182 fruit:veto_appledouble = no
3184 [vfs_fruit_metadata_stream]
3185 path = $shrdir
3186 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3187 fruit:resource = file
3188 fruit:metadata = stream
3189 fruit:veto_appledouble = no
3191 [vfs_fruit_stream_depot]
3192 path = $shrdir
3193 vfs objects = fruit streams_depot acl_xattr xattr_tdb
3194 fruit:resource = stream
3195 fruit:metadata = stream
3196 fruit:veto_appledouble = no
3198 [vfs_wo_fruit]
3199 path = $shrdir
3200 vfs objects = streams_xattr acl_xattr xattr_tdb
3202 [vfs_wo_fruit_stream_depot]
3203 path = $shrdir
3204 vfs objects = streams_depot acl_xattr xattr_tdb
3206 [vfs_fruit_timemachine]
3207 path = $shrdir
3208 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3209 fruit:resource = file
3210 fruit:metadata = stream
3211 fruit:time machine = yes
3212 fruit:time machine max size = 32K
3214 [vfs_fruit_wipe_intentionally_left_blank_rfork]
3215 path = $shrdir
3216 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3217 fruit:resource = file
3218 fruit:metadata = stream
3219 fruit:wipe_intentionally_left_blank_rfork = true
3220 fruit:delete_empty_adfiles = false
3221 fruit:veto_appledouble = no
3223 [vfs_fruit_delete_empty_adfiles]
3224 path = $shrdir
3225 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3226 fruit:resource = file
3227 fruit:metadata = stream
3228 fruit:wipe_intentionally_left_blank_rfork = true
3229 fruit:delete_empty_adfiles = true
3230 fruit:veto_appledouble = no
3232 [vfs_fruit_zero_fileid]
3233 path = $shrdir
3234 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3235 fruit:resource = file
3236 fruit:metadata = stream
3237 fruit:zero_file_id=yes
3239 [fruit_resource_stream]
3240 path = $fruit_resource_stream_shrdir
3241 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3242 fruit:resource = stream
3243 fruit:metadata = stream
3245 [badname-tmp]
3246 path = $badnames_shrdir
3247 guest ok = yes
3249 [manglenames_share]
3250 path = $manglenames_shrdir
3251 guest ok = yes
3253 [dynamic_share]
3254 path = $shrdir/dynamic/%t
3255 guest ok = yes
3256 root preexec = mkdir %P
3258 [widelinks_share]
3259 path = $widelinks_shrdir
3260 wide links = no
3261 guest ok = yes
3263 [fsrvp_share]
3264 path = $fsrvp_shrdir
3265 comment = fake snapshots using rsync
3266 vfs objects = shell_snap shadow_copy2
3267 shell_snap:check path command = $fake_snap_pl --check
3268 shell_snap:create command = $fake_snap_pl --create
3269 shell_snap:delete command = $fake_snap_pl --delete
3270 # a relative path here fails, the snapshot dir is no longer found
3271 shadow:snapdir = $fsrvp_shrdir/.snapshots
3273 [shadow1]
3274 path = $shadow_shrdir
3275 comment = previous versions snapshots under mount point
3276 vfs objects = shadow_copy2
3277 shadow:mountpoint = $shadow_mntdir
3279 [shadow2]
3280 path = $shadow_shrdir
3281 comment = previous versions snapshots outside mount point
3282 vfs objects = shadow_copy2
3283 shadow:mountpoint = $shadow_mntdir
3284 shadow:snapdir = $shadow_tstdir/.snapshots
3286 [shadow3]
3287 path = $shadow_shrdir
3288 comment = previous versions with subvolume snapshots, snapshots under base dir
3289 vfs objects = shadow_copy2
3290 shadow:mountpoint = $shadow_mntdir
3291 shadow:basedir = $shadow_basedir
3292 shadow:snapdir = $shadow_basedir/.snapshots
3294 [shadow4]
3295 path = $shadow_shrdir
3296 comment = previous versions with subvolume snapshots, snapshots outside mount point
3297 vfs objects = shadow_copy2
3298 shadow:mountpoint = $shadow_mntdir
3299 shadow:basedir = $shadow_basedir
3300 shadow:snapdir = $shadow_tstdir/.snapshots
3302 [shadow5]
3303 path = $shadow_shrdir
3304 comment = previous versions at volume root snapshots under mount point
3305 vfs objects = shadow_copy2
3306 shadow:mountpoint = $shadow_shrdir
3308 [shadow6]
3309 path = $shadow_shrdir
3310 comment = previous versions at volume root snapshots outside mount point
3311 vfs objects = shadow_copy2
3312 shadow:mountpoint = $shadow_shrdir
3313 shadow:snapdir = $shadow_tstdir/.snapshots
3315 [shadow7]
3316 path = $shadow_shrdir
3317 comment = previous versions snapshots everywhere
3318 vfs objects = shadow_copy2
3319 shadow:mountpoint = $shadow_mntdir
3320 shadow:snapdirseverywhere = yes
3322 [shadow8]
3323 path = $shadow_shrdir
3324 comment = previous versions using snapsharepath
3325 vfs objects = shadow_copy2
3326 shadow:mountpoint = $shadow_mntdir
3327 shadow:snapdir = $shadow_tstdir/.snapshots
3328 shadow:snapsharepath = share
3330 [shadow_fmt0]
3331 comment = Testing shadow:format with default option
3332 vfs object = shadow_copy2
3333 path = $shadow_shrdir
3334 read only = no
3335 guest ok = yes
3336 shadow:mountpoint = $shadow_mntdir
3337 shadow:basedir = $shadow_basedir
3338 shadow:snapdir = $shadow_basedir/.snapshots
3339 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
3341 [shadow_fmt1]
3342 comment = Testing shadow:format with only date component
3343 vfs object = shadow_copy2
3344 path = $shadow_shrdir
3345 read only = no
3346 guest ok = yes
3347 shadow:mountpoint = $shadow_mntdir
3348 shadow:basedir = $shadow_basedir
3349 shadow:snapdir = $shadow_basedir/.snapshots
3350 shadow:format = \@GMT-%Y-%m-%d
3352 [shadow_fmt2]
3353 comment = Testing shadow:format with some hardcoded prefix
3354 vfs object = shadow_copy2
3355 path = $shadow_shrdir
3356 read only = no
3357 guest ok = yes
3358 shadow:mountpoint = $shadow_mntdir
3359 shadow:basedir = $shadow_basedir
3360 shadow:snapdir = $shadow_basedir/.snapshots
3361 shadow:format = snap\@GMT-%Y.%m.%d-%H.%M.%S
3363 [shadow_fmt3]
3364 comment = Testing shadow:format with modified format
3365 vfs object = shadow_copy2
3366 path = $shadow_shrdir
3367 read only = no
3368 guest ok = yes
3369 shadow:mountpoint = $shadow_mntdir
3370 shadow:basedir = $shadow_basedir
3371 shadow:snapdir = $shadow_basedir/.snapshots
3372 shadow:format = \@GMT-%Y.%m.%d-%H_%M_%S-snap
3374 [shadow_fmt4]
3375 comment = Testing shadow:snapprefix regex
3376 vfs object = shadow_copy2
3377 path = $shadow_shrdir
3378 read only = no
3379 guest ok = yes
3380 shadow:mountpoint = $shadow_mntdir
3381 shadow:basedir = $shadow_basedir
3382 shadow:snapdir = $shadow_basedir/.snapshots
3383 shadow:snapprefix = \^s[a-z]*p\$
3384 shadow:format = _GMT-%Y.%m.%d-%H.%M.%S
3386 [shadow_fmt5]
3387 comment = Testing shadow:snapprefix with delim regex
3388 vfs object = shadow_copy2
3389 path = $shadow_shrdir
3390 read only = no
3391 guest ok = yes
3392 shadow:mountpoint = $shadow_mntdir
3393 shadow:basedir = $shadow_basedir
3394 shadow:snapdir = $shadow_basedir/.snapshots
3395 shadow:delimiter = \@GMT
3396 shadow:snapprefix = [a-z]*
3397 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
3399 [shadow_wl]
3400 path = $shadow_shrdir
3401 comment = previous versions with wide links allowed
3402 vfs objects = shadow_copy2
3403 shadow:mountpoint = $shadow_mntdir
3404 wide links = yes
3406 [shadow_write]
3407 path = $shadow_tstdir
3408 comment = previous versions snapshots under mount point
3409 vfs objects = shadow_copy2 streams_xattr error_inject
3410 aio write size = 0
3411 error_inject:pwrite = EBADF
3412 shadow:mountpoint = $shadow_tstdir
3413 shadow:fixinodes = yes
3414 smbd async dosmode = yes
3416 [shadow_depot]
3417 path = $shadow_shrdir
3418 comment = previous versions with streams_depot
3419 vfs objects = streams_depot shadow_copy2
3421 [dfq]
3422 path = $shrdir/dfree
3423 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
3424 admin users = $unix_name
3425 include = $dfqconffile
3426 [dfq_cache]
3427 path = $shrdir/dfree
3428 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
3429 admin users = $unix_name
3430 include = $dfqconffile
3431 dfree cache time = 60
3432 [dfq_owner]
3433 path = $shrdir/dfree
3434 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
3435 inherit owner = yes
3436 include = $dfqconffile
3437 [quotadir]
3438 path = $shrdir/quota
3439 admin users = $unix_name
3441 [acl_xattr_ign_sysacl_posix]
3442 copy = tmp
3443 acl_xattr:ignore system acls = yes
3444 acl_xattr:default acl style = posix
3445 [acl_xattr_ign_sysacl_windows]
3446 copy = tmp
3447 acl_xattr:ignore system acls = yes
3448 acl_xattr:default acl style = windows
3450 [mangle_illegal]
3451 copy = tmp
3452 mangled names = illegal
3454 [nosymlinks]
3455 copy = tmp
3456 path = $nosymlinks_shrdir
3457 follow symlinks = no
3458 [nosymlinks_smb1allow]
3459 copy=nosymlinks
3460 follow symlinks = yes
3462 [local_symlinks]
3463 copy = tmp
3464 path = $local_symlinks_shrdir
3465 follow symlinks = yes
3467 [kernel_oplocks]
3468 copy = tmp
3469 kernel oplocks = yes
3470 vfs objects = streams_xattr xattr_tdb
3472 [streams_xattr]
3473 copy = tmp
3474 vfs objects = streams_xattr xattr_tdb
3476 [streams_xattr_nostrict]
3477 copy = tmp
3478 strict rename = no
3479 vfs objects = streams_xattr xattr_tdb
3481 [acl_streams_xattr]
3482 copy = tmp
3483 vfs objects = acl_xattr streams_xattr fake_acls xattr_tdb
3484 acl_xattr:ignore system acls = yes
3485 acl_xattr:security_acl_name = user.acl
3486 xattr_tdb:ignore_user_xattr = yes
3488 [compound_find]
3489 copy = tmp
3490 smbd:find async delay usec = 10000
3491 [error_inject]
3492 copy = tmp
3493 vfs objects = error_inject
3494 include = $errorinjectconf
3496 [delay_inject]
3497 copy = tmp
3498 vfs objects = delay_inject
3499 kernel share modes = no
3500 kernel oplocks = no
3501 posix locking = no
3502 include = $delayinjectconf
3504 [aio_delay_inject]
3505 copy = tmp
3506 vfs objects = delay_inject
3507 delay_inject:pread_send = 2000
3508 delay_inject:pwrite_send = 2000
3510 [brl_delay_inject1]
3511 copy = tmp
3512 vfs objects = delay_inject
3513 delay_inject:brl_lock_windows = 90
3514 delay_inject:brl_lock_windows_use_timer = yes
3516 [brl_delay_inject2]
3517 copy = tmp
3518 vfs objects = delay_inject
3519 delay_inject:brl_lock_windows = 90
3520 delay_inject:brl_lock_windows_use_timer = no
3522 [delete_readonly]
3523 path = $prefix_abs/share
3524 delete readonly = yes
3526 [enc_desired]
3527 path = $prefix_abs/share
3528 vfs objects =
3529 server smb encrypt = desired
3531 [enc_off]
3532 path = $prefix_abs/share
3533 vfs objects =
3534 server smb encrypt = off
3536 [notify_priv]
3537 copy = tmp
3538 honor change notify privilege = yes
3540 [acls_non_canonical]
3541 copy = tmp
3542 acl flag inherited canonicalization = no
3544 [full_audit_success_bad_name]
3545 copy = tmp
3546 full_audit:success = badname
3548 [full_audit_fail_bad_name]
3549 copy = tmp
3550 full_audit:failure = badname
3552 [only_ipv6]
3553 copy = tmpguest
3554 server addresses = $server_ipv6
3556 [smbget]
3557 path = $smbget_sharedir
3558 comment = smb username is [%U]
3559 guest ok = yes
3561 include = $aliceconfdir/%U.conf
3564 close(CONF);
3566 my $net = Samba::bindir_path($self, "net");
3567 my $cmd = "";
3568 $cmd .= "UID_WRAPPER_ROOT=1 ";
3569 $cmd .= "SMB_CONF_PATH=\"$conffile\" ";
3570 $cmd .= "$net setlocalsid $samsid";
3572 my $net_ret = system($cmd);
3573 if ($net_ret != 0) {
3574 warn("net setlocalsid failed: $net_ret\n$cmd");
3575 return undef;
3578 unless (open(ERRORCONF, ">$errorinjectconf")) {
3579 warn("Unable to open $errorinjectconf");
3580 return undef;
3582 close(ERRORCONF);
3584 unless (open(DELAYCONF, ">$delayinjectconf")) {
3585 warn("Unable to open $delayinjectconf");
3586 return undef;
3588 close(DELAYCONF);
3590 unless (open(DFQCONF, ">$dfqconffile")) {
3591 warn("Unable to open $dfqconffile");
3592 return undef;
3594 close(DFQCONF);
3596 unless (open(DELAYCONF, ">$globalinjectconf")) {
3597 warn("Unable to open $globalinjectconf");
3598 return undef;
3600 close(DELAYCONF);
3602 unless (open(ALICECONF, ">$aliceconffile")) {
3603 warn("Unable to open $aliceconffile");
3604 return undef;
3607 print ALICECONF "
3608 [alice_share]
3609 path = $shrdir
3610 comment = smb username is [%U]
3613 close(ALICECONF);
3616 ## create a test account
3619 unless (open(PASSWD, ">$nss_wrapper_passwd")) {
3620 warn("Unable to open $nss_wrapper_passwd");
3621 return undef;
3623 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
3624 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
3625 pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
3626 pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
3627 userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
3628 pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false
3629 force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false
3630 smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false
3631 user1:x:$uid_user1:$gid_nogroup:user1 gecos:$prefix_abs:/bin/false
3632 user2:x:$uid_user2:$gid_nogroup:user2 gecos:$prefix_abs:/bin/false
3633 gooduser:x:$uid_gooduser:$gid_domusers:gooduser gecos:$prefix_abs:/bin/false
3634 eviluser:x:$uid_eviluser:$gid_domusers:eviluser gecos::/bin/false
3635 slashuser:x:$uid_slashuser:$gid_domusers:slashuser gecos:/:/bin/false
3636 bob:x:$uid_localbob:$gid_domusers:localbob gecos:/:/bin/false
3637 jane:x:$uid_localjane:$gid_domusers:localjane gecos:/:/bin/false
3638 jackthemapper:x:$uid_localjackthemapper:$gid_domusers:localjackthemaper gecos:/:/bin/false
3639 jacknomapper:x:$uid_localjacknomapper:$gid_domusers:localjacknomaper gecos:/:/bin/false
3641 if ($unix_uid != 0) {
3642 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
3645 close(PASSWD);
3647 unless (open(GROUP, ">$nss_wrapper_group")) {
3648 warn("Unable to open $nss_wrapper_group");
3649 return undef;
3651 print GROUP "nobody:x:$gid_nobody:
3652 nogroup:x:$gid_nogroup:nobody
3653 $unix_name-group:x:$unix_gids[0]:
3654 domusers:X:$gid_domusers:
3655 domadmins:X:$gid_domadmins:
3656 userdup:x:$gid_userdup:$unix_name
3657 everyone:x:$gid_everyone:
3658 force_user:x:$gid_force_user:
3659 jackthemappergroup:x:$gid_jackthemapper:jackthemapper
3660 jacknomappergroup:x:$gid_jacknomapper:jacknomapper
3662 if ($unix_gids[0] != 0) {
3663 print GROUP "root:x:$gid_root:
3667 close(GROUP);
3669 ## hosts
3670 my $hostname = lc($server);
3671 unless (open(HOSTS, ">>$nss_wrapper_hosts")) {
3672 warn("Unable to open $nss_wrapper_hosts");
3673 return undef;
3675 print HOSTS "${server_ip} ${hostname}.${dns_domain} ${hostname}\n";
3676 print HOSTS "${server_ipv6} ${hostname}.${dns_domain} ${hostname}\n";
3677 close(HOSTS);
3679 $resolv_conf = "$privatedir/no_resolv.conf" unless defined($resolv_conf);
3681 foreach my $evlog (@eventlog_list) {
3682 my $evlogtdb = "$eventlogdir/$evlog.tdb";
3683 open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
3684 close(EVENTLOG);
3687 $createuser_env{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
3688 $createuser_env{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
3689 $createuser_env{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
3690 $createuser_env{NSS_WRAPPER_HOSTNAME} = "${hostname}.${dns_domain}";
3691 if ($ENV{SAMBA_DNS_FAKING}) {
3692 $createuser_env{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
3693 } else {
3694 $createuser_env{RESOLV_WRAPPER_CONF} = $resolv_conf;
3696 $createuser_env{RESOLV_CONF} = $resolv_conf;
3698 createuser($self, $unix_name, $password, $conffile, \%createuser_env) || die("Unable to create user");
3699 createuser($self, "force_user", $password, $conffile, \%createuser_env) || die("Unable to create force_user");
3700 createuser($self, "smbget_user", $password, $conffile, \%createuser_env) || die("Unable to create smbget_user");
3701 createuser($self, "user1", $password, $conffile, \%createuser_env) || die("Unable to create user1");
3702 createuser($self, "user2", $password, $conffile, \%createuser_env) || die("Unable to create user2");
3703 createuser($self, "gooduser", $password, $conffile, \%createuser_env) || die("Unable to create gooduser");
3704 createuser($self, "eviluser", $password, $conffile, \%createuser_env) || die("Unable to create eviluser");
3705 createuser($self, "slashuser", $password, $conffile, \%createuser_env) || die("Unable to create slashuser");
3706 createuser($self, "jackthemapper", "mApsEcrEt", $conffile, \%createuser_env) || die("Unable to create jackthemapper");
3707 createuser($self, "jacknomapper", "nOmApsEcrEt", $conffile, \%createuser_env) || die("Unable to create jacknomapper");
3709 open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
3710 print DNS_UPDATE_LIST "A $server. $server_ip\n";
3711 print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n";
3712 close(DNS_UPDATE_LIST);
3714 print "DONE\n";
3716 $ret{SERVER_IP} = $server_ip;
3717 $ret{SERVER_IPV6} = $server_ipv6;
3718 $ret{SAMBA_DCERPCD_TEST_LOG} = "$prefix/samba_dcerpcd_test.log";
3719 $ret{SAMBA_DCERPCD_LOG_POS} = 0;
3720 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
3721 $ret{NMBD_TEST_LOG_POS} = 0;
3722 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
3723 $ret{WINBINDD_TEST_LOG_POS} = 0;
3724 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
3725 $ret{SMBD_TEST_LOG_POS} = 0;
3726 $ret{SERVERCONFFILE} = $conffile;
3727 $ret{TESTENV_DIR} = $prefix_abs;
3728 $ret{CONFIGURATION} ="--configfile=$conffile";
3729 $ret{LOCK_DIR} = $lockdir;
3730 $ret{SERVER} = $server;
3731 $ret{USERNAME} = $unix_name;
3732 $ret{USERID} = $unix_uid;
3733 $ret{DOMAIN} = $domain;
3734 $ret{SAMSID} = $samsid;
3735 $ret{NETBIOSNAME} = $server;
3736 $ret{PASSWORD} = $password;
3737 $ret{PIDDIR} = $piddir;
3738 $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir;
3739 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
3740 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
3741 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
3742 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
3743 $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
3744 $ret{NSS_WRAPPER_HOSTNAME} = "${hostname}.${dns_domain}";
3745 $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
3746 $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind";
3747 if ($ENV{SAMBA_DNS_FAKING}) {
3748 $ret{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
3749 } else {
3750 $ret{RESOLV_WRAPPER_CONF} = $resolv_conf;
3752 $ret{RESOLV_CONF} = $resolv_conf;
3753 $ret{LOCAL_PATH} = "$shrdir";
3754 $ret{LOGDIR} = $logdir;
3757 # Avoid hitting system krb5.conf -
3758 # An env that needs Kerberos will reset this to the real
3759 # value.
3761 $ret{KRB5_CONFIG} = abs_path($prefix) . "/no_krb5.conf";
3763 # Define KRB5CCNAME for each environment we set up
3764 $ret{KRB5_CCACHE} = abs_path($prefix) . "/krb5ccache";
3765 $ENV{KRB5CCNAME} = $ret{KRB5_CCACHE};
3767 return \%ret;
3770 sub wait_for_start($$$$$)
3772 my ($self, $envvars, $nmbd, $winbindd, $smbd, $samba_dcerpcd) = @_;
3773 my $cmd;
3774 my $netcmd;
3775 my $ret;
3777 if ($samba_dcerpcd eq "yes") {
3778 my $count = 0;
3779 my $rpcclient = Samba::bindir_path($self, "rpcclient");
3781 print "checking for samba_dcerpcd\n";
3783 do {
3784 $ret = system("$rpcclient $envvars->{CONFIGURATION} ncalrpc: -c epmmap");
3786 if ($ret != 0) {
3787 sleep(1);
3789 $count++
3790 } while ($ret != 0 && $count < 10);
3792 if ($count == 10) {
3793 print "samba_dcerpcd not reachable after 10 retries\n";
3794 teardown_env($self, $envvars);
3795 return 0;
3799 if ($nmbd eq "yes") {
3800 my $count = 0;
3802 # give time for nbt server to register its names
3803 print "checking for nmbd\n";
3805 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
3806 my $nmblookup = Samba::bindir_path($self, "nmblookup");
3808 do {
3809 $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
3810 if ($ret != 0) {
3811 sleep(1);
3812 } else {
3813 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
3814 system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
3815 system("$nmblookup $envvars->{CONFIGURATION} -U 10.255.255.255 __SAMBA__");
3816 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
3818 $count++;
3819 } while ($ret != 0 && $count < 10);
3820 if ($count == 10) {
3821 print "NMBD not reachable after 10 retries\n";
3822 teardown_env($self, $envvars);
3823 return 0;
3827 if ($winbindd eq "yes" or $winbindd eq "offline") {
3828 print "checking for winbindd\n";
3829 my $count = 0;
3830 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
3831 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3832 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3833 if ($winbindd eq "yes") {
3834 $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping-dc";
3835 } elsif ($winbindd eq "offline") {
3836 $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping";
3839 do {
3840 $ret = system($cmd);
3841 if ($ret != 0) {
3842 sleep(1);
3844 $count++;
3845 } while ($ret != 0 && $count < 20);
3846 if ($count == 20) {
3847 print "WINBINDD not reachable after 20 seconds\n";
3848 teardown_env($self, $envvars);
3849 return 0;
3853 if ($smbd eq "yes") {
3854 # make sure smbd is also up set
3855 print "wait for smbd\n";
3857 my $count = 0;
3858 do {
3859 if (defined($envvars->{GNUTLS_FORCE_FIPS_MODE})) {
3860 # We don't have NTLM in FIPS mode, so lets use
3861 # smbcontrol instead of smbclient.
3862 $cmd = Samba::bindir_path($self, "smbcontrol");
3863 $cmd .= " $envvars->{CONFIGURATION}";
3864 $cmd .= " smbd ping";
3865 } else {
3866 # This uses NTLM which is not available in FIPS
3867 $cmd = Samba::bindir_path($self, "smbclient");
3868 $cmd .= " $envvars->{CONFIGURATION}";
3869 $cmd .= " -L $envvars->{SERVER}";
3870 $cmd .= " -U%";
3871 $cmd .= " -I $envvars->{SERVER_IP}";
3872 $cmd .= " -p 139";
3875 $ret = system($cmd);
3876 if ($ret != 0) {
3877 sleep(1);
3879 $count++
3880 } while ($ret != 0 && $count < 20);
3881 if ($count == 20) {
3882 print "SMBD failed to start up in a reasonable time (20sec)\n";
3883 teardown_env($self, $envvars);
3884 return 0;
3888 # Ensure we have domain users mapped.
3889 $netcmd = "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3890 $netcmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3891 $netcmd .= "UID_WRAPPER_ROOT='1' ";
3892 $netcmd .= Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} ";
3894 $cmd = $netcmd . "groupmap delete ntgroup=domusers";
3895 $ret = system($cmd);
3897 $cmd = $netcmd . "groupmap add rid=513 unixgroup=domusers type=domain";
3898 $ret = system($cmd);
3899 if ($ret != 0) {
3900 print("\"$cmd\" failed\n");
3901 return 1;
3904 $cmd = $netcmd . "groupmap delete ntgroup=domadmins";
3905 $ret = system($cmd);
3907 $cmd = $netcmd . "groupmap add rid=512 unixgroup=domadmins type=domain";
3908 $ret = system($cmd);
3909 if ($ret != 0) {
3910 print("\"$cmd\" failed\n");
3911 return 1;
3914 $cmd = $netcmd . "groupmap delete ntgroup=everyone";
3915 $ret = system($cmd);
3917 $cmd = $netcmd . "groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin";
3918 $ret = system($cmd);
3919 if ($ret != 0) {
3920 print("\"$cmd\" failed\n");
3921 return 1;
3924 # note: creating builtin groups requires winbindd for the
3925 # unix id allocator
3926 my $create_builtin_users = "no";
3927 if ($winbindd eq "yes") {
3928 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
3929 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3930 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3931 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
3932 my $wbinfo_out = qx($cmd 2>&1);
3933 if ($? != 0) {
3934 # wbinfo doesn't give us a better error code then
3935 # WBC_ERR_DOMAIN_NOT_FOUND, but at least that's
3936 # different then WBC_ERR_WINBIND_NOT_AVAILABLE
3937 if ($wbinfo_out !~ /WBC_ERR_DOMAIN_NOT_FOUND/) {
3938 print("Failed to run \"wbinfo --sid-to-gid=S-1-5-32-545\": $wbinfo_out");
3939 teardown_env($self, $envvars);
3940 return 0;
3942 $create_builtin_users = "yes";
3945 if ($create_builtin_users eq "yes") {
3946 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
3947 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3948 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3949 $cmd .= Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
3950 $cmd .= "sam createbuiltingroup Users";
3951 $ret = system($cmd);
3952 if ($ret != 0) {
3953 print "Failed to create BUILTIN\\Users group\n";
3954 teardown_env($self, $envvars);
3955 return 0;
3958 $cmd = Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
3959 $cmd .= "cache del IDMAP/SID2XID/S-1-5-32-545";
3960 system($cmd);
3962 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
3963 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3964 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3965 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
3966 $ret = system($cmd);
3967 if ($ret != 0) {
3968 print "Missing \"BUILTIN\\Users\", did net sam createbuiltingroup Users fail?\n";
3969 teardown_env($self, $envvars);
3970 return 0;
3974 print $self->getlog_env($envvars);
3976 return 1;
3980 ## provision and start of ctdb
3982 sub setup_ctdb($$)
3984 my ($self, $prefix) = @_;
3985 my $num_nodes = 3;
3987 my $data = $self->provision_ctdb($prefix, $num_nodes);
3988 $data or return undef;
3990 my $rc = $self->check_or_start_ctdb($data);
3991 if (not $rc) {
3992 print("check_or_start_ctdb() failed\n");
3993 return undef;
3996 $rc = $self->wait_for_start_ctdb($data);
3997 if (not $rc) {
3998 print "Cluster startup failed\n";
3999 return undef;
4002 return $data;
4005 sub provision_ctdb($$$$)
4007 my ($self, $prefix, $num_nodes, $no_delete_prefix) = @_;
4008 my $rc;
4010 print "PROVISIONING CTDB...\n";
4012 my $prefix_abs = abs_path($prefix);
4015 # check / create directories:
4017 die ("prefix_abs = ''") if $prefix_abs eq "";
4018 die ("prefix_abs = '/'") if $prefix_abs eq "/";
4020 mkdir ($prefix_abs, 0777);
4022 print "CREATE CTDB TEST ENVIRONMENT in '$prefix_abs'...\n";
4024 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
4025 system("rm -rf $prefix_abs/*");
4029 # Per-node data
4031 my @nodes = ();
4032 for (my $i = 0; $i < $num_nodes; $i++) {
4033 my %node = ();
4034 my $server_name = "ctdb${i}";
4035 my $pub_iface = Samba::get_interface($server_name);
4036 my $ip = Samba::get_ipv4_addr($server_name);
4038 $node{NODE_NUMBER} = "$i";
4039 $node{SERVER_NAME} = "$server_name";
4040 $node{SOCKET_WRAPPER_DEFAULT_IFACE} = "$pub_iface";
4041 $node{IP} = "$ip";
4043 push(@nodes, \%node);
4047 # nodes
4049 my $nodes_file = "$prefix/nodes.in";
4050 unless (open(NODES, ">$nodes_file")) {
4051 warn("Unable to open nodesfile '$nodes_file'");
4052 return undef;
4054 for (my $i = 0; $i < $num_nodes; $i++) {
4055 my $ip = $nodes[$i]->{IP};
4056 print NODES "${ip}\n";
4058 close(NODES);
4061 # local_daemons.sh setup
4063 # Socket wrapper setup is done by selftest.pl, so don't use
4064 # the CTDB-specific setup
4066 my $cmd;
4067 $cmd .= "ctdb/tests/local_daemons.sh " . $prefix_abs . " setup";
4068 $cmd .= " -n " . $num_nodes;
4069 $cmd .= " -N " . $nodes_file;
4070 # CTDB should not attempt to manage public addresses -
4071 # clients should just connect to CTDB private addresses
4072 $cmd .= " -P " . "/dev/null";
4074 my $ret = system($cmd);
4075 if ($ret != 0) {
4076 print("\"$cmd\" failed\n");
4077 return undef;
4081 # Unix domain socket and node directory for each daemon
4083 for (my $i = 0; $i < $num_nodes; $i++) {
4084 my ($cmd, $ret, $out);
4086 my $cmd_prefix = "ctdb/tests/local_daemons.sh ${prefix_abs}";
4089 # socket
4092 $cmd = "${cmd_prefix} print-socket ${i}";
4094 $out = `$cmd`;
4095 $ret = $?;
4096 if ($ret != 0) {
4097 print("\"$cmd\" failed\n");
4098 return undef;
4100 chomp $out;
4101 $nodes[$i]->{SOCKET_FILE} = "$out";
4104 # node directory
4107 $cmd = "${cmd_prefix} onnode ${i} 'echo \$CTDB_BASE'";
4109 $out = `$cmd`;
4110 $ret = $?;
4111 if ($ret != 0) {
4112 print("\"$cmd\" failed\n");
4113 return undef;
4115 chomp $out;
4116 $nodes[$i]->{NODE_PREFIX} = "$out";
4119 my %ret = ();
4121 $ret{CTDB_PREFIX} = "$prefix";
4122 $ret{NUM_NODES} = $num_nodes;
4123 $ret{CTDB_NODES} = \@nodes;
4124 $ret{CTDB_NODES_FILE} = $nodes_file;
4126 return \%ret;
4129 sub check_or_start_ctdb($$) {
4130 my ($self, $data) = @_;
4132 my $prefix = $data->{CTDB_PREFIX};
4133 my $num_nodes = $data->{NUM_NODES};
4134 my $nodes = $data->{CTDB_NODES};
4135 my $STDIN_READER;
4137 # Share a single stdin pipe for all nodes
4138 pipe($STDIN_READER, $data->{CTDB_STDIN_PIPE});
4140 for (my $i = 0; $i < $num_nodes; $i++) {
4141 my $node = $nodes->[$i];
4143 $node->{STDIN_PIPE} = $data->{CTDB_STDIN_PIPE};
4145 my $cmd = "ctdb/tests/local_daemons.sh";
4146 my @full_cmd = ("$cmd", "$prefix", "start", "$i");
4147 my $daemon_ctx = {
4148 NAME => "ctdbd",
4149 BINARY_PATH => $cmd,
4150 FULL_CMD => [ @full_cmd ],
4151 TEE_STDOUT => 1,
4152 LOG_FILE => "/dev/null",
4153 ENV_VARS => {},
4156 print "STARTING CTDBD (node ${i})\n";
4158 # This does magic with $STDIN_READER, so use it
4159 my $ret = Samba::fork_and_exec($self,
4160 $node,
4161 $daemon_ctx,
4162 $STDIN_READER);
4164 if ($ret == 0) {
4165 print("\"$cmd\" failed\n");
4166 teardown_env_ctdb($self, $data);
4167 return 0;
4171 close($STDIN_READER);
4173 return 1;
4176 sub wait_for_start_ctdb($$)
4178 my ($self, $data) = @_;
4180 my $prefix = $data->{CTDB_PREFIX};
4182 print "Wait for ctdbd...\n";
4184 my $ctdb = Samba::bindir_path($self, "ctdb");
4185 my $cmd;
4186 $cmd .= "ctdb/tests/local_daemons.sh ${prefix} onnode all";
4187 $cmd .= " ${ctdb} nodestatus all 2>&1";
4189 my $count = 0;
4190 my $wait_seconds = 60;
4191 my $out;
4193 until ($count > $wait_seconds) {
4194 $out = `$cmd`;
4195 my $ret = $?;
4196 if ($ret == 0) {
4197 print "\ncluster became healthy\n";
4198 last;
4200 print "Waiting for CTDB...\n";
4201 sleep(1);
4202 $count++;
4205 if ($count > $wait_seconds) {
4206 print "\nGiving up to wait for CTDB...\n";
4207 print "${out}\n\n";
4208 print "CTDB log:\n";
4209 $cmd = "ctdb/tests/local_daemons.sh ${prefix} print-log all >&2";
4210 system($cmd);
4211 teardown_env_ctdb($self, $data);
4212 return 0;
4215 print "\nCTDB initialized\n";
4217 return 1;