pidl/lib: Add recursion detection logic to prevent looping.
[Samba.git] / selftest / target / Samba3.pm
blob39831afc599db05fc8f6c22090746d4643ff9150
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
1298 server signing = required
1301 my $ret = $self->provision(
1302 prefix => $prefix,
1303 domain => $dcvars->{DOMAIN},
1304 realm => $dcvars->{REALM},
1305 server => "IDMAPRIDMEMBER",
1306 password => "loCalMemberPass",
1307 extra_options => $member_options,
1308 resolv_conf => $dcvars->{RESOLV_CONF});
1310 $ret or return undef;
1312 $ret->{DOMAIN} = $dcvars->{DOMAIN};
1313 $ret->{REALM} = $dcvars->{REALM};
1314 $ret->{DOMSID} = $dcvars->{DOMSID};
1316 my $ctx;
1317 my $prefix_abs = abs_path($prefix);
1318 $ctx = {};
1319 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1320 $ctx->{domain} = $dcvars->{DOMAIN};
1321 $ctx->{realm} = $dcvars->{REALM};
1322 $ctx->{dnsname} = lc($dcvars->{REALM});
1323 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
1324 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
1325 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1326 Samba::mk_krb5_conf($ctx, "");
1328 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1330 my $net = Samba::bindir_path($self, "net");
1331 # Add hosts file for name lookups
1332 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
1333 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1334 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
1335 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
1336 } else {
1337 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
1339 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
1340 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1341 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
1342 $cmd .= "$net join $ret->{CONFIGURATION}";
1343 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
1345 if (system($cmd) != 0) {
1346 warn("Join failed\n$cmd");
1347 return undef;
1350 # We need world access to this share, as otherwise the domain
1351 # administrator from the AD domain provided by Samba4 can't
1352 # access the share for tests.
1353 chmod 0777, "$prefix/share";
1355 if (not $self->check_or_start(
1356 env_vars => $ret,
1357 nmbd => "yes",
1358 winbindd => "yes",
1359 smbd => "yes")) {
1360 return undef;
1363 $ret->{DC_SERVER} = $dcvars->{SERVER};
1364 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1365 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1366 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1367 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1368 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1370 return $ret;
1373 sub setup_ad_member_idmap_ad
1375 my ($self, $prefix, $dcvars) = @_;
1377 # If we didn't build with ADS, pretend this env was never available
1378 if (not $self->have_ads()) {
1379 return "UNKNOWN";
1382 print "PROVISIONING S3 AD MEMBER WITH idmap_ad config...";
1384 my $member_options = "
1385 security = ads
1386 workgroup = $dcvars->{DOMAIN}
1387 realm = $dcvars->{REALM}
1388 password server = $dcvars->{SERVER}
1389 idmap config * : backend = tdb
1390 idmap config * : range = 1000000-1999999
1391 idmap config $dcvars->{DOMAIN} : backend = ad
1392 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
1393 idmap config $dcvars->{DOMAIN} : unix_primary_group = yes
1394 idmap config $dcvars->{DOMAIN} : unix_nss_info = yes
1395 idmap config $dcvars->{DOMAIN} : deny ous = \"ou=sub,DC=samba2008r2,DC=example,DC=com\"
1396 idmap config $dcvars->{TRUST_DOMAIN} : backend = ad
1397 idmap config $dcvars->{TRUST_DOMAIN} : range = 2000000-2999999
1398 gensec_gssapi:requested_life_time = 5
1401 my $ret = $self->provision(
1402 prefix => $prefix,
1403 domain => $dcvars->{DOMAIN},
1404 realm => $dcvars->{REALM},
1405 server => "IDMAPADMEMBER",
1406 password => "loCalMemberPass",
1407 extra_options => $member_options,
1408 resolv_conf => $dcvars->{RESOLV_CONF});
1410 $ret or return undef;
1412 $ret->{DOMAIN} = $dcvars->{DOMAIN};
1413 $ret->{REALM} = $dcvars->{REALM};
1414 $ret->{DOMSID} = $dcvars->{DOMSID};
1416 my $ctx;
1417 my $prefix_abs = abs_path($prefix);
1418 $ctx = {};
1419 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1420 $ctx->{domain} = $dcvars->{DOMAIN};
1421 $ctx->{realm} = $dcvars->{REALM};
1422 $ctx->{dnsname} = lc($dcvars->{REALM});
1423 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
1424 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
1425 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1426 Samba::mk_krb5_conf($ctx, "");
1428 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1430 my $net = Samba::bindir_path($self, "net");
1431 # Add hosts file for name lookups
1432 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
1433 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1434 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
1435 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
1436 } else {
1437 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
1439 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
1440 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1441 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
1442 $cmd .= "$net join $ret->{CONFIGURATION}";
1443 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
1445 if (system($cmd) != 0) {
1446 warn("Join failed\n$cmd");
1447 return undef;
1450 # We need world access to this share, as otherwise the domain
1451 # administrator from the AD domain provided by Samba4 can't
1452 # access the share for tests.
1453 chmod 0777, "$prefix/share";
1455 if (not $self->check_or_start(
1456 env_vars => $ret,
1457 nmbd => "yes",
1458 winbindd => "yes",
1459 smbd => "yes")) {
1460 return undef;
1463 $ret->{DC_SERVER} = $dcvars->{SERVER};
1464 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1465 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1466 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1467 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1468 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1470 $ret->{TRUST_SERVER} = $dcvars->{TRUST_SERVER};
1471 $ret->{TRUST_USERNAME} = $dcvars->{TRUST_USERNAME};
1472 $ret->{TRUST_PASSWORD} = $dcvars->{TRUST_PASSWORD};
1473 $ret->{TRUST_DOMAIN} = $dcvars->{TRUST_DOMAIN};
1474 $ret->{TRUST_REALM} = $dcvars->{TRUST_REALM};
1475 $ret->{TRUST_DOMSID} = $dcvars->{TRUST_DOMSID};
1477 return $ret;
1480 sub setup_ad_member_oneway
1482 my ($self, $prefix, $dcvars) = @_;
1484 # If we didn't build with ADS, pretend this env was never available
1485 if (not $self->have_ads()) {
1486 return "UNKNOWN";
1489 print "PROVISIONING S3 AD MEMBER WITH one-way trust...";
1491 my $member_options = "
1492 security = ads
1493 workgroup = $dcvars->{DOMAIN}
1494 realm = $dcvars->{REALM}
1495 password server = $dcvars->{SERVER}
1496 idmap config * : backend = tdb
1497 idmap config * : range = 1000000-1999999
1498 gensec_gssapi:requested_life_time = 5
1501 my $ret = $self->provision(
1502 prefix => $prefix,
1503 domain => $dcvars->{DOMAIN},
1504 server => "S2KMEMBER",
1505 password => "loCalS2KMemberPass",
1506 extra_options => $member_options,
1507 resolv_conf => $dcvars->{RESOLV_CONF});
1509 $ret or return undef;
1511 $ret->{DOMAIN} = $dcvars->{DOMAIN};
1512 $ret->{REALM} = $dcvars->{REALM};
1513 $ret->{DOMSID} = $dcvars->{DOMSID};
1515 my $ctx;
1516 my $prefix_abs = abs_path($prefix);
1517 $ctx = {};
1518 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1519 $ctx->{domain} = $dcvars->{DOMAIN};
1520 $ctx->{realm} = $dcvars->{REALM};
1521 $ctx->{dnsname} = lc($dcvars->{REALM});
1522 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
1523 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
1524 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1525 Samba::mk_krb5_conf($ctx, "");
1527 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1529 my $net = Samba::bindir_path($self, "net");
1530 # Add hosts file for name lookups
1531 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
1532 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1533 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
1534 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
1535 } else {
1536 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
1538 $cmd .= "RESOLV_CONF=\"$ret->{RESOLV_CONF}\" ";
1539 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1540 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
1541 $cmd .= "$net join $ret->{CONFIGURATION}";
1542 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
1544 if (system($cmd) != 0) {
1545 warn("Join failed\n$cmd");
1546 return undef;
1549 if (not $self->check_or_start(
1550 env_vars => $ret,
1551 winbindd => "yes")) {
1552 return undef;
1555 $ret->{DC_SERVER} = $dcvars->{SERVER};
1556 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
1557 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
1558 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
1559 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
1560 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
1562 $ret->{TRUST_SERVER} = $dcvars->{TRUST_SERVER};
1563 $ret->{TRUST_USERNAME} = $dcvars->{TRUST_USERNAME};
1564 $ret->{TRUST_PASSWORD} = $dcvars->{TRUST_PASSWORD};
1565 $ret->{TRUST_DOMAIN} = $dcvars->{TRUST_DOMAIN};
1566 $ret->{TRUST_REALM} = $dcvars->{TRUST_REALM};
1567 $ret->{TRUST_DOMSID} = $dcvars->{TRUST_DOMSID};
1569 return $ret;
1572 sub setup_ad_member_fips
1574 my ($self,
1575 $prefix,
1576 $dcvars,
1577 $trustvars_f,
1578 $trustvars_e) = @_;
1580 # If we didn't build with ADS, pretend this env was never available
1581 if (not $self->have_ads()) {
1582 return "UNKNOWN";
1585 print "PROVISIONING AD FIPS MEMBER...";
1587 return $self->provision_ad_member($prefix,
1588 "FIPSADMEMBER",
1589 $dcvars,
1590 $trustvars_f,
1591 $trustvars_e,
1592 undef,
1596 sub setup_ad_member_offlogon
1598 my ($self,
1599 $prefix,
1600 $dcvars,
1601 $trustvars_f,
1602 $trustvars_e) = @_;
1604 # If we didn't build with ADS, pretend this env was never available
1605 if (not $self->have_ads()) {
1606 return "UNKNOWN";
1609 print "PROVISIONING AD MEMBER OFFLINE LOGON...";
1611 return $self->provision_ad_member($prefix,
1612 "OFFLINEADMEM",
1613 $dcvars,
1614 $trustvars_f,
1615 $trustvars_e,
1616 undef,
1617 undef,
1621 sub setup_ad_member_idmap_nss
1623 my ($self,
1624 $prefix,
1625 $dcvars,
1626 $trustvars_f,
1627 $trustvars_e) = @_;
1629 # If we didn't build with ADS, pretend this env was never available
1630 if (not $self->have_ads()) {
1631 return "UNKNOWN";
1634 print "PROVISIONING AD MEMBER WITHOUT NSS WINBIND WITH idmap_nss config...";
1636 my $extra_member_options = "
1637 # bob:x:65521:65531:localbob gecos:/:/bin/false
1638 # jane:x:65520:65531:localjane gecos:/:/bin/false
1639 # jackthemapper:x:65519:65531:localjackthemaper gecos:/:/bin/false
1640 # jacknomapper:x:65518:65531:localjacknomaper gecos:/:/bin/false
1641 idmap config $dcvars->{DOMAIN} : backend = nss
1642 idmap config $dcvars->{DOMAIN} : range = 65518-65521
1644 # Support SMB1 so that we can use posix_whoami().
1645 client min protocol = CORE
1646 server min protocol = LANMAN1
1648 username map = $prefix/lib/username.map
1651 my $ret = $self->provision_ad_member($prefix,
1652 "ADMEMIDMAPNSS",
1653 $dcvars,
1654 $trustvars_f,
1655 $trustvars_e,
1656 $extra_member_options,
1657 undef,
1658 undef,
1661 open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map");
1662 print USERMAP "
1663 !jacknomapper = \@jackthemappergroup
1664 !root = jacknomappergroup
1665 root = $dcvars->{DOMAIN}/root
1666 bob = $dcvars->{DOMAIN}/bob
1668 close(USERMAP);
1670 return $ret;
1673 sub setup_simpleserver
1675 my ($self, $path) = @_;
1677 print "PROVISIONING simple server...";
1679 my $prefix_abs = abs_path($path);
1680 mkdir($prefix_abs, 0777);
1682 my $external_streams_depot="$prefix_abs/external_streams_depot";
1683 remove_tree($external_streams_depot);
1684 mkdir($external_streams_depot, 0777);
1686 my $simpleserver_options = "
1687 lanman auth = yes
1688 ntlm auth = yes
1689 vfs objects = xattr_tdb streams_depot
1690 change notify = no
1691 server smb encrypt = off
1693 [vfs_aio_pthread]
1694 path = $prefix_abs/share
1695 read only = no
1696 vfs objects = aio_pthread
1697 aio_pthread:aio open = yes
1698 smbd async dosmode = no
1700 [vfs_aio_pthread_async_dosmode_default1]
1701 path = $prefix_abs/share
1702 read only = no
1703 vfs objects = aio_pthread
1704 store dos attributes = yes
1705 aio_pthread:aio open = yes
1706 smbd async dosmode = yes
1708 [vfs_aio_pthread_async_dosmode_default2]
1709 path = $prefix_abs/share
1710 read only = no
1711 vfs objects = aio_pthread xattr_tdb
1712 store dos attributes = yes
1713 aio_pthread:aio open = yes
1714 smbd async dosmode = yes
1716 [async_dosmode_shadow_copy2]
1717 path = $prefix_abs/share
1718 read only = no
1719 vfs objects = shadow_copy2 xattr_tdb
1720 smbd async dosmode = yes
1722 [vfs_aio_fork]
1723 path = $prefix_abs/share
1724 vfs objects = aio_fork
1725 read only = no
1726 vfs_aio_fork:erratic_testing_mode=yes
1728 [dosmode]
1729 path = $prefix_abs/share
1730 vfs objects =
1731 store dos attributes = yes
1732 hide files = /hidefile/
1733 hide dot files = yes
1735 [hidenewfiles]
1736 path = $prefix_abs/share
1737 hide new files timeout = 5
1739 [external_streams_depot]
1740 path = $prefix_abs/share
1741 read only = no
1742 streams_depot:directory = $external_streams_depot
1745 my $vars = $self->provision(
1746 prefix => $path,
1747 domain => "WORKGROUP",
1748 server => "LOCALSHARE4",
1749 password => "local4pass",
1750 extra_options => $simpleserver_options);
1752 $vars or return undef;
1754 if (not $self->check_or_start(
1755 env_vars => $vars,
1756 nmbd => "yes",
1757 smbd => "yes")) {
1758 return undef;
1761 return $vars;
1764 sub create_file_chmod($$)
1766 my ($name, $mode) = @_;
1767 my $fh;
1769 unless (open($fh, '>', $name)) {
1770 warn("Unable to open $name");
1771 return undef;
1773 chmod($mode, $fh);
1776 sub setup_fileserver
1778 my ($self, $path, $more_conf, $server) = @_;
1779 my $prefix_abs = abs_path($path);
1780 my $srcdir_abs = abs_path($self->{srcdir});
1782 print "PROVISIONING file server ...\n";
1784 my @dirs = ();
1786 mkdir($prefix_abs, 0777);
1788 my $usershare_dir="$prefix_abs/lib/usershare";
1790 mkdir("$prefix_abs/lib", 0755);
1791 remove_tree($usershare_dir);
1792 mkdir($usershare_dir, 01770);
1794 my $share_dir="$prefix_abs/share";
1796 # Create share directory structure
1797 my $lower_case_share_dir="$share_dir/lower-case";
1798 push(@dirs, $lower_case_share_dir);
1800 my $lower_case_share_dir_30000="$share_dir/lower-case-30000";
1801 push(@dirs, $lower_case_share_dir_30000);
1803 my $dfree_share_dir="$share_dir/dfree";
1804 push(@dirs, $dfree_share_dir);
1805 push(@dirs, "$dfree_share_dir/subdir1");
1806 push(@dirs, "$dfree_share_dir/subdir2");
1807 push(@dirs, "$dfree_share_dir/subdir3");
1809 my $quotadir_dir="$share_dir/quota";
1810 push(@dirs, $quotadir_dir);
1812 my $valid_users_sharedir="$share_dir/valid_users";
1813 push(@dirs,$valid_users_sharedir);
1815 my $offline_sharedir="$share_dir/offline";
1816 push(@dirs,$offline_sharedir);
1818 my $force_user_valid_users_dir = "$share_dir/force_user_valid_users";
1819 push(@dirs, $force_user_valid_users_dir);
1821 my $tarmode_sharedir="$share_dir/tarmode";
1822 push(@dirs,$tarmode_sharedir);
1824 my $tarmode2_sharedir="$share_dir/tarmode2";
1825 push(@dirs,$tarmode2_sharedir);
1827 my $smbcacls_sharedir="$share_dir/smbcacls";
1828 push(@dirs,$smbcacls_sharedir);
1830 my $usershare_sharedir="$share_dir/usershares";
1831 push(@dirs,$usershare_sharedir);
1833 my $dropbox_sharedir="$share_dir/dropbox";
1834 push(@dirs,$dropbox_sharedir);
1836 my $bad_iconv_sharedir="$share_dir/bad_iconv";
1837 push(@dirs, $bad_iconv_sharedir);
1839 my $veto_sharedir="$share_dir/veto";
1840 push(@dirs,$veto_sharedir);
1842 my $virusfilter_sharedir="$share_dir/virusfilter";
1843 push(@dirs,$virusfilter_sharedir);
1845 my $delete_unwrite_sharedir="$share_dir/delete_unwrite";
1846 push(@dirs,$delete_unwrite_sharedir);
1847 push(@dirs, "$delete_unwrite_sharedir/delete_veto_yes");
1848 push(@dirs, "$delete_unwrite_sharedir/delete_veto_no");
1850 my $volume_serial_number_sharedir="$share_dir/volume_serial_number";
1851 push(@dirs, $volume_serial_number_sharedir);
1853 my $ip4 = Samba::get_ipv4_addr("FILESERVER");
1854 my $fileserver_options = "
1855 kernel change notify = yes
1856 spotlight backend = elasticsearch
1857 elasticsearch:address = $ip4
1858 elasticsearch:port = 8080
1859 elasticsearch:mappings = $srcdir_abs/source3/rpc_server/mdssvc/elasticsearch_mappings.json
1861 usershare path = $usershare_dir
1862 usershare max shares = 10
1863 usershare allow guests = yes
1864 usershare prefix allow list = $usershare_sharedir
1866 get quota command = $prefix_abs/getset_quota.py
1867 set quota command = $prefix_abs/getset_quota.py
1868 [tarmode]
1869 path = $tarmode_sharedir
1870 comment = tar test share
1871 xattr_tdb:file = $prefix_abs/tarmode-xattr.tdb
1872 [tarmode2]
1873 path = $tarmode2_sharedir
1874 comment = tar test share
1875 xattr_tdb:file = $prefix_abs/tarmode2-xattr.tdb
1876 [spotlight]
1877 path = $share_dir
1878 spotlight = yes
1879 read only = no
1880 [no_spotlight]
1881 path = $share_dir
1882 spotlight = no
1883 read only = no
1884 [lowercase]
1885 path = $lower_case_share_dir
1886 comment = smb username is [%U]
1887 case sensitive = True
1888 default case = lower
1889 preserve case = no
1890 short preserve case = no
1891 [lowercase-30000]
1892 path = $lower_case_share_dir_30000
1893 comment = smb username is [%U]
1894 case sensitive = True
1895 default case = lower
1896 preserve case = no
1897 short preserve case = no
1898 [dfree]
1899 path = $dfree_share_dir
1900 comment = smb username is [%U]
1901 dfree command = $srcdir_abs/testprogs/blackbox/dfree.sh
1902 [valid-users-access]
1903 path = $valid_users_sharedir
1904 valid users = +userdup
1905 [offline]
1906 path = $offline_sharedir
1907 vfs objects = offline
1909 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878
1910 # RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651
1911 [force_user_valid_users]
1912 path = $force_user_valid_users_dir
1913 comment = force user with valid users combination test share
1914 valid users = +force_user
1915 force user = force_user
1916 force group = everyone
1917 write list = force_user
1919 [ign_sysacls]
1920 path = $share_dir
1921 comment = ignore system acls
1922 acl_xattr:ignore system acls = yes
1923 [inherit_owner]
1924 path = $share_dir
1925 comment = inherit owner
1926 inherit owner = yes
1927 [inherit_owner_u]
1928 path = $share_dir
1929 comment = inherit only unix owner
1930 inherit owner = unix only
1931 acl_xattr:ignore system acls = yes
1932 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=13690
1933 [force_group_test]
1934 path = $share_dir
1935 comment = force group test
1936 # force group = everyone
1938 [create_mode_664]
1939 path = $share_dir
1940 comment = smb username is [%U]
1941 create mask = 0644
1942 force create mode = 0664
1943 vfs objects = dirsort
1945 [dropbox]
1946 path = $dropbox_sharedir
1947 comment = smb username is [%U]
1948 writeable = yes
1949 vfs objects =
1951 [bad_iconv]
1952 path = $bad_iconv_sharedir
1953 comment = smb username is [%U]
1954 vfs objects =
1956 [veto_files_nodelete]
1957 path = $veto_sharedir
1958 read only = no
1959 msdfs root = yes
1960 veto files = /veto_name*/
1961 delete veto files = no
1963 [veto_files_delete]
1964 path = $veto_sharedir
1965 msdfs root = yes
1966 veto files = /veto_name*/
1967 delete veto files = yes
1969 [delete_veto_files_only]
1970 path = $veto_sharedir
1971 delete veto files = yes
1973 [veto_files_nohidden]
1974 path = $veto_sharedir
1975 veto files = /.*/
1977 [veto_files]
1978 path = $veto_sharedir
1979 veto files = /veto_name*/
1981 [delete_yes_unwrite]
1982 read only = no
1983 path = $delete_unwrite_sharedir
1984 hide unwriteable files = yes
1985 delete veto files = yes
1987 [delete_no_unwrite]
1988 read only = no
1989 path = $delete_unwrite_sharedir
1990 hide unwriteable files = yes
1991 delete veto files = no
1993 [virusfilter]
1994 path = $virusfilter_sharedir
1995 vfs objects = acl_xattr virusfilter
1996 virusfilter:scanner = dummy
1997 virusfilter:min file size = 0
1998 virusfilter:infected files = *infected*
1999 virusfilter:infected file action = rename
2000 virusfilter:scan on close = yes
2001 vfs_default:VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS = no
2003 [volumeserialnumber]
2004 path = $volume_serial_number_sharedir
2005 volume serial number = 0xdeadbeef
2007 [ea_acl_xattr]
2008 path = $share_dir
2009 vfs objects = acl_xattr
2010 acl_xattr:security_acl_name = user.hackme
2011 read only = no
2013 [homes]
2014 comment = Home directories
2015 browseable = No
2016 read only = No
2019 if (defined($more_conf)) {
2020 $fileserver_options = $fileserver_options . $more_conf;
2022 if (!defined($server)) {
2023 $server = "FILESERVER";
2026 my $vars = $self->provision(
2027 prefix => $path,
2028 domain => "WORKGROUP",
2029 server => $server,
2030 password => "fileserver",
2031 extra_options => $fileserver_options,
2032 no_delete_prefix => 1);
2034 $vars or return undef;
2036 if (not $self->check_or_start(
2037 env_vars => $vars,
2038 nmbd => "yes",
2039 smbd => "yes")) {
2040 return undef;
2044 mkdir($_, 0777) foreach(@dirs);
2046 ## Create case sensitive lower case share dir
2047 foreach my $file ('a'..'z') {
2048 my $full_path = $lower_case_share_dir . '/' . $file;
2049 open my $fh, '>', $full_path;
2050 # Add some content to file
2051 print $fh $full_path;
2052 close $fh;
2055 for (my $file = 1; $file < 51; ++$file) {
2056 my $full_path = $lower_case_share_dir . '/' . $file;
2057 open my $fh, '>', $full_path;
2058 # Add some content to file
2059 print $fh $full_path;
2060 close $fh;
2063 # Create content for 30000 share
2064 foreach my $file ('a'..'z') {
2065 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
2066 open my $fh, '>', $full_path;
2067 # Add some content to file
2068 print $fh $full_path;
2069 close $fh;
2072 for (my $file = 1; $file < 30001; ++$file) {
2073 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
2074 open my $fh, '>', $full_path;
2075 # Add some content to file
2076 print $fh $full_path;
2077 close $fh;
2081 ## create a listable file in valid_users_share
2083 create_file_chmod("$valid_users_sharedir/foo", 0644) or return undef;
2086 ## create a valid utf8 filename which is invalid as a CP850 conversion
2088 create_file_chmod("$bad_iconv_sharedir/\xED\x9F\xBF", 0644) or return undef;
2091 ## create unwritable files inside inside the delete unwrite veto share dirs.
2093 unlink("$delete_unwrite_sharedir/delete_veto_yes/file_444");
2094 create_file_chmod("$delete_unwrite_sharedir/delete_veto_yes/file_444", 0444) or return undef;
2095 unlink("$delete_unwrite_sharedir/delete_veto_no/file_444");
2096 create_file_chmod("$delete_unwrite_sharedir/delete_veto_no/file_444", 0444) or return undef;
2098 return $vars;
2101 sub setup_fileserver_smb1
2103 my ($self, $path) = @_;
2104 my $prefix_abs = abs_path($path);
2105 my $conf = "
2106 [global]
2107 client min protocol = CORE
2108 server min protocol = LANMAN1
2109 check parent directory delete on close = yes
2111 [hidenewfiles]
2112 path = $prefix_abs/share
2113 hide new files timeout = 5
2114 [vfs_aio_pthread]
2115 path = $prefix_abs/share
2116 read only = no
2117 vfs objects = aio_pthread
2118 aio_pthread:aio open = yes
2119 smbd async dosmode = no
2121 [vfs_aio_pthread_async_dosmode_default1]
2122 path = $prefix_abs/share
2123 read only = no
2124 vfs objects = aio_pthread
2125 store dos attributes = yes
2126 aio_pthread:aio open = yes
2127 smbd async dosmode = yes
2129 [vfs_aio_pthread_async_dosmode_default2]
2130 path = $prefix_abs/share
2131 read only = no
2132 vfs objects = aio_pthread xattr_tdb
2133 store dos attributes = yes
2134 aio_pthread:aio open = yes
2135 smbd async dosmode = yes
2137 [vfs_aio_fork]
2138 path = $prefix_abs/share
2139 vfs objects = aio_fork
2140 read only = no
2141 vfs_aio_fork:erratic_testing_mode=yes
2143 return $self->setup_fileserver($path, $conf, "FILESERVERSMB1");
2146 sub setup_fileserver_smb1_done
2148 my ($self, $path, $dep_env) = @_;
2149 return $self->return_alias_env($path, $dep_env);
2152 sub setup_ktest
2154 my ($self, $prefix) = @_;
2156 # If we didn't build with ADS, pretend this env was never available
2157 if (not $self->have_ads()) {
2158 return "UNKNOWN";
2161 print "PROVISIONING server with security=ads...";
2163 my $ktest_options = "
2164 workgroup = KTEST
2165 realm = ktest.samba.example.com
2166 security = ads
2167 server signing = required
2168 server min protocol = SMB3_00
2169 client max protocol = SMB3
2171 # This disables NTLM auth against the local SAM, which
2172 # we use can then test this setting by.
2173 ntlm auth = disabled
2175 idmap config * : backend = autorid
2176 idmap config * : range = 1000000-1999999
2177 idmap config * : rangesize = 100000
2180 my $ret = $self->provision(
2181 prefix => $prefix,
2182 domain => "KTEST",
2183 server => "LOCALKTEST6",
2184 password => "localktest6pass",
2185 extra_options => $ktest_options);
2187 $ret or return undef;
2189 my $ctx;
2190 my $prefix_abs = abs_path($prefix);
2191 $ctx = {};
2192 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
2193 $ctx->{domain} = "KTEST";
2194 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
2195 $ctx->{dnsname} = lc($ctx->{realm});
2196 $ctx->{kdc_ipv4} = "0.0.0.0";
2197 $ctx->{kdc_ipv6} = "::";
2198 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
2199 Samba::mk_krb5_conf($ctx, "");
2201 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
2203 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
2204 #Samba4 DC with the same parameters as are being used here. The
2205 #domain SID is S-1-5-21-1071277805-689288055-3486227160
2206 $ret->{SAMSID} = "S-1-5-21-1911091480-1468226576-2729736297";
2207 $ret->{DOMSID} = "S-1-5-21-1071277805-689288055-3486227160";
2209 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
2210 chmod 0600, "$prefix/private/secrets.tdb";
2212 #Make sure there's no old ntdb file.
2213 system("rm -f $prefix/private/secrets.ntdb");
2215 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
2216 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
2218 #and having in krb5.conf:
2219 # ticket_lifetime = 799718400
2220 # renew_lifetime = 799718400
2222 # The commands for the -2 keytab where were:
2223 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
2224 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
2225 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
2226 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
2227 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
2229 # and then for the -3 keytab, I did
2231 # net changetrustpw; kdestroy and the same again.
2233 # This creates a credential cache with a very long lifetime (2036 at
2234 # at 2011-04), and shows that running 'net changetrustpw' does not
2235 # break existing logins (for the secrets.tdb method at least).
2238 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
2240 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
2241 chmod 0600, "$prefix/krb5_ccache-2";
2243 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
2244 chmod 0600, "$prefix/krb5_ccache-3";
2246 # We need world access to this share, as otherwise the domain
2247 # administrator from the AD domain provided by ktest can't
2248 # access the share for tests.
2249 chmod 0777, "$prefix/share";
2251 if (not $self->check_or_start(
2252 env_vars => $ret,
2253 nmbd => "yes",
2254 winbindd => "offline",
2255 smbd => "yes")) {
2256 return undef;
2258 return $ret;
2261 sub setup_maptoguest
2263 my ($self, $path) = @_;
2264 my $prefix_abs = abs_path($path);
2265 my $libdir="$prefix_abs/lib";
2266 my $share_dir="$prefix_abs/share";
2267 my $errorinjectconf="$libdir/error_inject.conf";
2269 print "PROVISIONING maptoguest...";
2271 my $options = "
2272 domain logons = yes
2273 map to guest = bad user
2274 ntlm auth = yes
2275 server min protocol = LANMAN1
2277 [force_user_error_inject]
2278 path = $share_dir
2279 vfs objects = acl_xattr fake_acls xattr_tdb error_inject
2280 force user = user1
2281 include = $errorinjectconf
2284 my $vars = $self->provision(
2285 prefix => $path,
2286 domain => "WORKGROUP",
2287 server => "maptoguest",
2288 password => "maptoguestpass",
2289 extra_options => $options);
2291 $vars or return undef;
2293 if (not $self->check_or_start(
2294 env_vars => $vars,
2295 nmbd => "yes",
2296 winbindd => "yes",
2297 smbd => "yes")) {
2298 return undef;
2301 return $vars;
2304 sub stop_sig_term($$) {
2305 my ($self, $pid) = @_;
2306 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
2309 sub stop_sig_kill($$) {
2310 my ($self, $pid) = @_;
2311 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
2314 sub write_pid($$$)
2316 my ($env_vars, $app, $pid) = @_;
2318 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
2319 print PID $pid;
2320 close(PID);
2323 sub read_pid($$)
2325 my ($env_vars, $app) = @_;
2327 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
2328 my $pid = <PID>;
2329 close(PID);
2330 return $pid;
2333 # builds up the cmd args to run an s3 binary (i.e. smbd, nmbd, etc)
2334 sub make_bin_cmd
2336 my ($self, $binary, $env_vars, $options, $valgrind, $dont_log_stdout) = @_;
2338 my @optargs = ();
2339 if (defined($options)) {
2340 @optargs = split(/ /, $options);
2342 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
2344 if (defined($valgrind)) {
2345 @preargs = split(/ /, $valgrind);
2347 my @args = ("-F", "--no-process-group",
2348 "--configfile=$env_vars->{SERVERCONFFILE}",
2349 "-l", $env_vars->{LOGDIR});
2351 if (not defined($dont_log_stdout)) {
2352 push(@args, "--debug-stdout");
2354 return (@preargs, $binary, @args, @optargs);
2357 sub check_or_start($$) {
2358 my ($self, %args) = @_;
2359 my $env_vars = $args{env_vars};
2360 my $nmbd = $args{nmbd} // "no";
2361 my $winbindd = $args{winbindd} // "no";
2362 my $smbd = $args{smbd} // "no";
2363 my $samba_dcerpcd = $args{samba_dcerpcd} // "no";
2364 my $child_cleanup = $args{child_cleanup};
2366 my $STDIN_READER;
2368 # use a pipe for stdin in the child processes. This allows
2369 # those processes to monitor the pipe for EOF to ensure they
2370 # exit when the test script exits
2371 pipe($STDIN_READER, $env_vars->{STDIN_PIPE});
2373 my $binary = Samba::bindir_path($self, "samba-dcerpcd");
2374 my @full_cmd = $self->make_bin_cmd(
2375 $binary,
2376 $env_vars,
2377 $ENV{SAMBA_DCERPCD_OPTIONS},
2378 $ENV{SAMBA_DCERPCD_VALGRIND},
2379 $ENV{SAMBA_DCERPCD_DONT_LOG_STDOUT});
2380 push(@full_cmd, '--libexec-rpcds');
2382 my $samba_dcerpcd_envs = Samba::get_env_for_process(
2383 "samba_dcerpcd", $env_vars);
2385 # fork and exec() samba_dcerpcd in the child process
2386 my $daemon_ctx = {
2387 NAME => "samba_dcerpcd",
2388 BINARY_PATH => $binary,
2389 FULL_CMD => [ @full_cmd ],
2390 LOG_FILE => $env_vars->{SAMBA_DCERPCD_TEST_LOG},
2391 PCAP_FILE => "env-$ENV{ENVNAME}-samba_dcerpcd",
2392 ENV_VARS => $samba_dcerpcd_envs,
2394 if ($samba_dcerpcd ne "yes") {
2395 $daemon_ctx->{SKIP_DAEMON} = 1;
2398 my $pid = Samba::fork_and_exec(
2399 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
2401 $env_vars->{SAMBA_DCERPCD_TL_PID} = $pid;
2402 write_pid($env_vars, "samba_dcerpcd", $pid);
2404 $binary = Samba::bindir_path($self, "nmbd");
2405 @full_cmd = $self->make_bin_cmd($binary, $env_vars,
2406 $ENV{NMBD_OPTIONS}, $ENV{NMBD_VALGRIND},
2407 $ENV{NMBD_DONT_LOG_STDOUT});
2408 my $nmbd_envs = Samba::get_env_for_process("nmbd", $env_vars);
2409 delete $nmbd_envs->{RESOLV_WRAPPER_CONF};
2410 delete $nmbd_envs->{RESOLV_WRAPPER_HOSTS};
2412 # fork and exec() nmbd in the child process
2413 $daemon_ctx = {
2414 NAME => "nmbd",
2415 BINARY_PATH => $binary,
2416 FULL_CMD => [ @full_cmd ],
2417 LOG_FILE => $env_vars->{NMBD_TEST_LOG},
2418 PCAP_FILE => "env-$ENV{ENVNAME}-nmbd",
2419 ENV_VARS => $nmbd_envs,
2421 if ($nmbd ne "yes") {
2422 $daemon_ctx->{SKIP_DAEMON} = 1;
2424 $pid = Samba::fork_and_exec(
2425 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
2427 $env_vars->{NMBD_TL_PID} = $pid;
2428 write_pid($env_vars, "nmbd", $pid);
2430 $binary = Samba::bindir_path($self, "winbindd");
2431 @full_cmd = $self->make_bin_cmd($binary, $env_vars,
2432 $ENV{WINBINDD_OPTIONS},
2433 $ENV{WINBINDD_VALGRIND},
2434 $ENV{WINBINDD_DONT_LOG_STDOUT});
2436 # fork and exec() winbindd in the child process
2437 $daemon_ctx = {
2438 NAME => "winbindd",
2439 BINARY_PATH => $binary,
2440 FULL_CMD => [ @full_cmd ],
2441 LOG_FILE => $env_vars->{WINBINDD_TEST_LOG},
2442 PCAP_FILE => "env-$ENV{ENVNAME}-winbindd",
2444 if ($winbindd ne "yes" and $winbindd ne "offline") {
2445 $daemon_ctx->{SKIP_DAEMON} = 1;
2448 $pid = Samba::fork_and_exec(
2449 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
2451 $env_vars->{WINBINDD_TL_PID} = $pid;
2452 write_pid($env_vars, "winbindd", $pid);
2454 $binary = Samba::bindir_path($self, "smbd");
2455 @full_cmd = $self->make_bin_cmd($binary, $env_vars,
2456 $ENV{SMBD_OPTIONS}, $ENV{SMBD_VALGRIND},
2457 $ENV{SMBD_DONT_LOG_STDOUT});
2459 # fork and exec() smbd in the child process
2460 $daemon_ctx = {
2461 NAME => "smbd",
2462 BINARY_PATH => $binary,
2463 FULL_CMD => [ @full_cmd ],
2464 LOG_FILE => $env_vars->{SMBD_TEST_LOG},
2465 PCAP_FILE => "env-$ENV{ENVNAME}-smbd",
2467 if ($smbd ne "yes") {
2468 $daemon_ctx->{SKIP_DAEMON} = 1;
2471 $pid = Samba::fork_and_exec(
2472 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
2474 $env_vars->{SMBD_TL_PID} = $pid;
2475 write_pid($env_vars, "smbd", $pid);
2477 # close the parent's read-end of the pipe
2478 close($STDIN_READER);
2480 return $self->wait_for_start($env_vars,
2481 $nmbd,
2482 $winbindd,
2483 $smbd,
2484 $samba_dcerpcd);
2487 sub createuser($$$$$)
2489 my ($self, $username, $password, $conffile, $env) = @_;
2490 my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $username > /dev/null";
2492 keys %$env;
2493 while(my($var, $val) = each %$env) {
2494 $cmd = "$var=\"$val\" $cmd";
2497 unless (open(PWD, "|$cmd")) {
2498 warn("Unable to set password for $username account\n$cmd");
2499 return undef;
2501 print PWD "$password\n$password\n";
2502 unless (close(PWD)) {
2503 warn("Unable to set password for $username account\n$cmd");
2504 return undef;
2508 sub provision($$)
2510 my ($self, %args) = @_;
2512 my $prefix = $args{prefix};
2513 my $domain = $args{domain};
2514 my $realm = $args{realm};
2515 my $server = $args{server};
2516 my $password = $args{password};
2517 my $extra_options = $args{extra_options};
2518 my $resolv_conf = $args{resolv_conf};
2519 my $no_delete_prefix= $args{no_delete_prefix};
2520 my $netbios_name = $args{netbios_name} // $server;
2521 my $server_log_level = $ENV{SERVER_LOG_LEVEL} || 1;
2524 ## setup the various environment variables we need
2527 my $samsid = Samba::random_domain_sid();
2528 my $swiface = Samba::get_interface($server);
2529 my %ret = ();
2530 my %createuser_env = ();
2531 my $server_ip = Samba::get_ipv4_addr($server);
2532 my $server_ipv6 = Samba::get_ipv6_addr($server);
2533 my $dns_domain;
2534 if (defined($realm)) {
2535 $dns_domain = lc($realm);
2536 } else {
2537 $dns_domain = "samba.example.com";
2540 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
2541 chomp $unix_name;
2542 my $unix_uid = $>;
2543 my $unix_gids_str = $);
2544 my @unix_gids = split(" ", $unix_gids_str);
2546 my $prefix_abs = abs_path($prefix);
2547 my $bindir_abs = abs_path($self->{bindir});
2549 my @dirs = ();
2551 my $shrdir=$args{share_dir} // "$prefix_abs/share";
2552 push(@dirs,$shrdir);
2554 my $libdir="$prefix_abs/lib";
2555 push(@dirs,$libdir);
2557 my $piddir="$prefix_abs/pid";
2558 push(@dirs,$piddir);
2560 my $privatedir="$prefix_abs/private";
2561 push(@dirs,$privatedir);
2563 my $cachedir = "$prefix_abs/cachedir";
2564 push(@dirs, $cachedir);
2566 my $binddnsdir = "$prefix_abs/bind-dns";
2567 push(@dirs, $binddnsdir);
2569 my $lockdir="$prefix_abs/lockdir";
2570 push(@dirs,$lockdir);
2572 my $eventlogdir="$prefix_abs/lockdir/eventlog";
2573 push(@dirs,$eventlogdir);
2575 my $logdir="$prefix_abs/logs";
2576 push(@dirs,$logdir);
2578 my $driver32dir="$shrdir/W32X86";
2579 push(@dirs,$driver32dir);
2581 my $driver64dir="$shrdir/x64";
2582 push(@dirs,$driver64dir);
2584 my $driver40dir="$shrdir/WIN40";
2585 push(@dirs,$driver40dir);
2587 my $ro_shrdir="$shrdir/root-tmp";
2588 push(@dirs,$ro_shrdir);
2590 my $noperm_shrdir="$shrdir/noperm-tmp";
2591 push(@dirs,$noperm_shrdir);
2593 my $msdfs_shrdir="$shrdir/msdfsshare";
2594 push(@dirs,$msdfs_shrdir);
2596 my $msdfs_shrdir2="$shrdir/msdfsshare2";
2597 push(@dirs,$msdfs_shrdir2);
2599 my $msdfs_pathname_share="$shrdir/msdfs_pathname_share";
2600 push(@dirs,$msdfs_pathname_share);
2602 my $non_msdfs_pathname_share="$shrdir/non_msdfs_pathname_share";
2603 push(@dirs,$non_msdfs_pathname_share);
2605 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
2606 push(@dirs,$msdfs_deeppath);
2608 my $smbcacls_sharedir_dfs="$shrdir/smbcacls_sharedir_dfs";
2609 push(@dirs,$smbcacls_sharedir_dfs);
2611 my $smbcacls_share="$shrdir/smbcacls_share";
2612 push(@dirs,$smbcacls_share);
2614 my $smbcacls_share_testdir="$shrdir/smbcacls_share/smbcacls";
2615 push(@dirs,$smbcacls_share_testdir);
2617 my $badnames_shrdir="$shrdir/badnames";
2618 push(@dirs,$badnames_shrdir);
2620 my $lease1_shrdir="$shrdir/dynamic";
2621 push(@dirs,$lease1_shrdir);
2623 my $manglenames_shrdir="$shrdir/manglenames";
2624 push(@dirs,$manglenames_shrdir);
2626 my $widelinks_shrdir="$shrdir/widelinks";
2627 push(@dirs,$widelinks_shrdir);
2629 my $widelinks_linkdir="$shrdir/widelinks_foo";
2630 push(@dirs,$widelinks_linkdir);
2632 my $fsrvp_shrdir="$shrdir/fsrvp";
2633 push(@dirs,$fsrvp_shrdir);
2635 my $shadow_tstdir="$shrdir/shadow";
2636 push(@dirs,$shadow_tstdir);
2637 my $shadow_mntdir="$shadow_tstdir/mount";
2638 push(@dirs,$shadow_mntdir);
2639 my $shadow_basedir="$shadow_mntdir/base";
2640 push(@dirs,$shadow_basedir);
2641 my $shadow_shrdir="$shadow_basedir/share";
2642 push(@dirs,$shadow_shrdir);
2644 my $nosymlinks_shrdir="$shrdir/nosymlinks";
2645 push(@dirs,$nosymlinks_shrdir);
2647 my $local_symlinks_shrdir="$shrdir/local_symlinks";
2648 push(@dirs,$local_symlinks_shrdir);
2650 my $fruit_resource_stream_shrdir="$shrdir/fruit_resource_stream";
2651 push(@dirs,$fruit_resource_stream_shrdir);
2653 my $smbget_sharedir="$shrdir/smbget";
2654 push(@dirs, $smbget_sharedir);
2656 # this gets autocreated by winbindd
2657 my $wbsockdir="$prefix_abs/wbsock";
2659 my $nmbdsockdir="$prefix_abs/nmbd";
2660 unlink($nmbdsockdir);
2663 ## create the test directory layout
2665 die ("prefix_abs = ''") if $prefix_abs eq "";
2666 die ("prefix_abs = '/'") if $prefix_abs eq "/";
2668 mkdir($prefix_abs, 0777);
2669 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
2670 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
2671 system("rm -rf $prefix_abs/*");
2673 mkdir($_, 0777) foreach(@dirs);
2675 my $fs_specific_conf = $self->get_fs_specific_conf($shrdir);
2678 ## lockdir and piddir must be 0755
2680 chmod 0755, $lockdir;
2681 chmod 0755, $piddir;
2685 ## Create a directory without permissions to enter
2687 chmod 0000, $noperm_shrdir;
2690 ## create ro and msdfs share layout
2693 chmod 0755, $ro_shrdir;
2695 create_file_chmod("$ro_shrdir/readable_file", 0644) or return undef;
2696 create_file_chmod("$ro_shrdir/unreadable_file", 0600) or return undef;
2698 create_file_chmod("$ro_shrdir/msdfs-target", 0600) or return undef;
2699 symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp",
2700 "$msdfs_shrdir/msdfs-src1";
2701 symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
2702 symlink "msdfs:$server_ip\\smbcacls_sharedir_dfs,$server_ipv6\\smbcacls_sharedir_dfs",
2703 "$msdfs_shrdir/smbcacls_sharedir_dfs";
2705 symlink "msdfs:$server_ip\\msdfs-share2,$server_ipv6\\msdfs-share2", "$msdfs_shrdir/dfshop1";
2706 symlink "msdfs:$server_ip\\tmp,$server_ipv6\\tmp", "$msdfs_shrdir2/dfshop2";
2708 ## create bad names in $badnames_shrdir
2710 ## (An invalid name, would be mangled to 8.3).
2711 create_file_chmod("$badnames_shrdir/\340|\231\216\377\177",
2712 0600) or return undef;
2714 ## (A bad name, would not be mangled to 8.3).
2715 create_file_chmod("$badnames_shrdir/\240\276\346\327\377\177",
2716 0666) or return undef;
2718 ## (A bad good name).
2719 create_file_chmod("$badnames_shrdir/blank.txt",
2720 0666) or return undef;
2723 ## create mangleable directory names in $manglenames_shrdir
2725 my $manglename_target = "$manglenames_shrdir/foo:bar";
2726 mkdir($manglename_target, 0777);
2729 ## create symlinks for widelinks tests.
2731 my $widelinks_target = "$widelinks_linkdir/target";
2732 create_file_chmod("$widelinks_target", 0666) or return undef;
2735 ## This link should get an error
2737 symlink "$widelinks_target", "$widelinks_shrdir/source";
2739 ## This link should be allowed
2741 symlink "$widelinks_shrdir", "$widelinks_shrdir/dot";
2743 my $conffile="$libdir/server.conf";
2744 my $dfqconffile="$libdir/dfq.conf";
2745 my $errorinjectconf="$libdir/error_inject.conf";
2746 my $delayinjectconf="$libdir/delay_inject.conf";
2747 my $globalinjectconf="$libdir/global_inject.conf";
2748 my $aliceconfdir="$libdir";
2749 my $aliceconffile="$libdir/alice.conf";
2751 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/third_party/nss_wrapper/nss_wrapper.pl";
2752 my $nss_wrapper_passwd = "$privatedir/passwd";
2753 my $nss_wrapper_group = "$privatedir/group";
2754 my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts";
2755 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
2757 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
2759 my $fake_snap_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/fake_snap.pl";
2761 my @eventlog_list = ("dns server", "application");
2764 ## calculate uids and gids
2767 my ($max_uid, $max_gid);
2768 my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
2769 my ($uid_pdbtest_wkn);
2770 my ($uid_smbget);
2771 my ($uid_force_user);
2772 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
2773 my ($gid_userdup, $gid_everyone);
2774 my ($gid_force_user);
2775 my ($gid_jackthemapper);
2776 my ($gid_jacknomapper);
2777 my ($uid_user1);
2778 my ($uid_user2);
2779 my ($uid_gooduser);
2780 my ($uid_eviluser);
2781 my ($uid_slashuser);
2782 my ($uid_localbob);
2783 my ($uid_localjane);
2784 my ($uid_localjackthemapper);
2785 my ($uid_localjacknomapper);
2787 if ($unix_uid < 0xffff - 13) {
2788 $max_uid = 0xffff;
2789 } else {
2790 $max_uid = $unix_uid;
2793 $uid_root = $max_uid - 1;
2794 $uid_nobody = $max_uid - 2;
2795 $uid_pdbtest = $max_uid - 3;
2796 $uid_pdbtest2 = $max_uid - 4;
2797 $uid_userdup = $max_uid - 5;
2798 $uid_pdbtest_wkn = $max_uid - 6;
2799 $uid_force_user = $max_uid - 7;
2800 $uid_smbget = $max_uid - 8;
2801 $uid_user1 = $max_uid - 9;
2802 $uid_user2 = $max_uid - 10;
2803 $uid_gooduser = $max_uid - 11;
2804 $uid_eviluser = $max_uid - 12;
2805 $uid_slashuser = $max_uid - 13;
2806 $uid_localbob = $max_uid - 14;
2807 $uid_localjane = $max_uid - 15;
2808 $uid_localjackthemapper = $max_uid - 16;
2809 $uid_localjacknomapper = $max_uid - 17;
2811 if ($unix_gids[0] < 0xffff - 8) {
2812 $max_gid = 0xffff;
2813 } else {
2814 $max_gid = $unix_gids[0];
2817 $gid_nobody = $max_gid - 1;
2818 $gid_nogroup = $max_gid - 2;
2819 $gid_root = $max_gid - 3;
2820 $gid_domusers = $max_gid - 4;
2821 $gid_domadmins = $max_gid - 5;
2822 $gid_userdup = $max_gid - 6;
2823 $gid_everyone = $max_gid - 7;
2824 $gid_force_user = $max_gid - 8;
2825 $gid_jackthemapper = $max_gid - 9;
2826 $gid_jacknomapper = $max_gid - 10;
2829 ## create conffile
2832 unless (open(CONF, ">$conffile")) {
2833 warn("Unable to open $conffile");
2834 return undef;
2837 my $interfaces = Samba::get_interfaces_config($server);
2839 print CONF "
2840 [global]
2841 dcesrv:fuzz directory = $cachedir/fuzz
2842 netbios name = $netbios_name
2843 interfaces = $interfaces
2844 bind interfaces only = yes
2845 panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
2846 smbd:suicide mode = yes
2847 smbd:FSCTL_SMBTORTURE = yes
2848 smbd:validate_oplock_types = yes
2850 client min protocol = SMB2_02
2851 server min protocol = SMB2_02
2853 server multi channel support = yes
2855 workgroup = $domain
2857 private dir = $privatedir
2858 binddns dir = $binddnsdir
2859 pid directory = $piddir
2860 lock directory = $lockdir
2861 log file = $logdir/log.\%m
2862 log level = $server_log_level
2863 winbind debug traceid = yes
2864 debug pid = yes
2865 max log size = 0
2867 debug syslog format = always
2868 debug hires timestamp = yes
2870 state directory = $lockdir
2871 cache directory = $lockdir
2873 passdb backend = tdbsam
2875 time server = yes
2877 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
2878 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
2879 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
2880 add user to group script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type member --action add --member %u --name %g --group_path $nss_wrapper_group
2881 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
2882 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
2883 delete user from group script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type member --action delete --member %u --name %g --group_path $nss_wrapper_group
2885 addprinter command = $mod_printer_pl -a -s $conffile --
2886 deleteprinter command = $mod_printer_pl -d -s $conffile --
2888 eventlog list = application \"dns server\"
2890 kernel oplocks = no
2891 kernel change notify = no
2893 logging = file
2894 printing = bsd
2895 printcap name = /dev/null
2897 winbindd socket directory = $wbsockdir
2898 nmbd:socket dir = $nmbdsockdir
2899 idmap config * : range = 100000-200000
2900 winbind enum users = yes
2901 winbind enum groups = yes
2902 winbind separator = /
2903 include system krb5 conf = no
2905 # min receivefile size = 4000
2907 read only = no
2909 smbd:sharedelay = 100000
2910 smbd:writetimeupdatedelay = 500000
2911 map hidden = no
2912 map system = no
2913 map readonly = no
2914 store dos attributes = yes
2915 create mask = 755
2916 dos filemode = yes
2917 strict rename = yes
2918 strict sync = yes
2919 mangled names = yes
2920 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot time_audit full_audit
2922 full_audit:syslog = no
2923 full_audit:success = none
2924 full_audit:failure = none
2926 printing = vlp
2927 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
2928 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
2929 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
2930 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
2931 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
2932 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
2933 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
2934 lpq cache time = 0
2935 print notify backchannel = yes
2937 ncalrpc dir = $prefix_abs/ncalrpc
2939 # The samba3.blackbox.smbclient_s3 test uses this to test that
2940 # sending messages works, and that the %m sub works.
2941 message command = mv %s $shrdir/message.%m
2943 # fsrvp server requires registry shares
2944 registry shares = yes
2946 # Used by RPC SRVSVC tests
2947 add share command = $bindir_abs/smbaddshare
2948 change share command = $bindir_abs/smbchangeshare
2949 delete share command = $bindir_abs/smbdeleteshare
2951 # fruit:copyfile is a global option
2952 fruit:copyfile = yes
2954 #this does not mean that we use non-secure test env,
2955 #it just means we ALLOW one to be configured.
2956 allow insecure wide links = yes
2958 include = $globalinjectconf
2960 # Begin extra options
2961 $extra_options
2962 # End extra options
2964 #Include user defined custom parameters if set
2967 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
2968 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
2971 print CONF "
2972 [smbcacls_share]
2973 path = $smbcacls_share
2974 comment = smb username is [%U]
2975 msdfs root = yes
2977 [smbcacls_sharedir_dfs]
2978 path = $smbcacls_sharedir_dfs
2979 comment = smb username is [%U]
2980 [tmp]
2981 path = $shrdir
2982 comment = smb username is [%U]
2983 [tmpsort]
2984 path = $shrdir
2985 comment = Load dirsort module
2986 vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot
2987 [tmpenc]
2988 path = $shrdir
2989 comment = encrypt smb username is [%U]
2990 server smb encrypt = required
2991 vfs objects = dirsort
2992 [tmpguest]
2993 path = $shrdir
2994 guest ok = yes
2995 [guestonly]
2996 path = $shrdir
2997 guest only = yes
2998 guest ok = yes
2999 [forceuser]
3000 path = $shrdir
3001 force user = $unix_name
3002 guest ok = yes
3003 [forceuser_unixonly]
3004 comment = force a user with unix user SID and group SID
3005 path = $shrdir
3006 force user = pdbtest
3007 guest ok = yes
3008 [forceuser_wkngroup]
3009 comment = force a user with well-known group SID
3010 path = $shrdir
3011 force user = pdbtest_wkn
3012 guest ok = yes
3013 [forcegroup]
3014 path = $shrdir
3015 force group = nogroup
3016 guest ok = yes
3017 [ro-tmp]
3018 path = $ro_shrdir
3019 guest ok = yes
3020 [noperm]
3021 path = $noperm_shrdir
3022 wide links = yes
3023 guest ok = yes
3024 [write-list-tmp]
3025 path = $shrdir
3026 read only = yes
3027 write list = $unix_name
3028 [valid-users-tmp]
3029 path = $shrdir
3030 valid users = $unix_name
3031 access based share enum = yes
3032 [msdfs-share]
3033 path = $msdfs_shrdir
3034 msdfs root = yes
3035 msdfs shuffle referrals = yes
3036 guest ok = yes
3037 [msdfs-share-wl]
3038 path = $msdfs_shrdir
3039 msdfs root = yes
3040 wide links = yes
3041 guest ok = yes
3042 [msdfs-share2]
3043 path = $msdfs_shrdir2
3044 msdfs root = yes
3045 guest ok = yes
3046 [msdfs-pathname-share]
3047 path = $msdfs_pathname_share
3048 msdfs root = yes
3049 guest ok = yes
3050 [non-msdfs-pathname-share]
3051 path = $non_msdfs_pathname_share
3052 msdfs root = no
3053 guest ok = yes
3054 [hideunread]
3055 copy = tmp
3056 hide unreadable = yes
3057 [tmpcase]
3058 copy = tmp
3059 case sensitive = yes
3060 [hideunwrite]
3061 copy = tmp
3062 hide unwriteable files = yes
3063 [durable]
3064 copy = tmp
3065 kernel share modes = no
3066 kernel oplocks = no
3067 posix locking = no
3068 [fs_specific]
3069 copy = tmp
3070 $fs_specific_conf
3071 [print1]
3072 copy = tmp
3073 printable = yes
3075 [print2]
3076 copy = print1
3077 [print3]
3078 copy = print1
3079 default devmode = no
3081 [print_var_exp]
3082 copy = print1
3083 print command = $self->{srcdir}/source3/script/tests/printing/printing_var_exp_lpr_cmd.sh \"Windows user: %U\" \"UNIX user: %u\" \"Domain: %D\"
3085 [lp]
3086 copy = print1
3088 [nfs4acl_simple_40]
3089 path = $shrdir
3090 comment = smb username is [%U]
3091 nfs4:mode = simple
3092 nfs4acl_xattr:version = 40
3093 vfs objects = nfs4acl_xattr xattr_tdb
3095 [nfs4acl_special_40]
3096 path = $shrdir
3097 comment = smb username is [%U]
3098 nfs4:mode = special
3099 nfs4acl_xattr:version = 40
3100 vfs objects = nfs4acl_xattr xattr_tdb
3102 [nfs4acl_simple_41]
3103 path = $shrdir
3104 comment = smb username is [%U]
3105 nfs4:mode = simple
3106 vfs objects = nfs4acl_xattr xattr_tdb
3108 [nfs4acl_xdr_40]
3109 path = $shrdir
3110 comment = smb username is [%U]
3111 vfs objects = nfs4acl_xattr xattr_tdb
3112 nfs4:mode = simple
3113 nfs4acl_xattr:encoding = xdr
3114 nfs4acl_xattr:version = 40
3116 [nfs4acl_xdr_41]
3117 path = $shrdir
3118 comment = smb username is [%U]
3119 vfs objects = nfs4acl_xattr xattr_tdb
3120 nfs4:mode = simple
3121 nfs4acl_xattr:encoding = xdr
3122 nfs4acl_xattr:version = 41
3124 [nfs4acl_nfs_40]
3125 path = $shrdir
3126 comment = smb username is [%U]
3127 vfs objects = nfs4acl_xattr xattr_tdb
3128 nfs4:mode = simple
3129 nfs4acl_xattr:encoding = nfs
3130 nfs4acl_xattr:version = 40
3131 nfs4acl_xattr:xattr_name = security.nfs4acl_xdr
3133 [nfs4acl_nfs_41]
3134 path = $shrdir
3135 comment = smb username is [%U]
3136 vfs objects = nfs4acl_xattr xattr_tdb
3137 nfs4:mode = simple
3138 nfs4acl_xattr:encoding = nfs
3139 nfs4acl_xattr:version = 41
3140 nfs4acl_xattr:xattr_name = security.nfs4acl_xdr
3142 [xcopy_share]
3143 path = $shrdir
3144 comment = smb username is [%U]
3145 create mask = 777
3146 force create mode = 777
3147 [posix_share]
3148 path = $shrdir
3149 comment = smb username is [%U]
3150 create mask = 0777
3151 force create mode = 0
3152 directory mask = 0777
3153 force directory mode = 0
3154 vfs objects = xattr_tdb streams_depot
3155 [smb3_posix_share]
3156 vfs objects = fake_acls xattr_tdb streams_depot time_audit full_audit
3157 create mask = 07777
3158 directory mask = 07777
3159 mangled names = no
3160 path = $shrdir
3161 read only = no
3162 guest ok = yes
3163 [aio]
3164 copy = durable
3165 aio read size = 1
3166 aio write size = 1
3168 [print\$]
3169 copy = tmp
3171 [vfs_fruit]
3172 path = $shrdir
3173 vfs objects = catia fruit streams_xattr acl_xattr xattr_tdb
3174 fruit:resource = file
3175 fruit:metadata = netatalk
3176 fruit:locking = netatalk
3177 fruit:encoding = native
3178 fruit:veto_appledouble = no
3180 [vfs_fruit_xattr]
3181 path = $shrdir
3182 # This is used by vfs.fruit tests that require real fs xattr
3183 vfs objects = catia fruit streams_xattr acl_xattr
3184 fruit:resource = file
3185 fruit:metadata = netatalk
3186 fruit:locking = netatalk
3187 fruit:encoding = native
3188 fruit:veto_appledouble = no
3190 [vfs_fruit_metadata_stream]
3191 path = $shrdir
3192 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3193 fruit:resource = file
3194 fruit:metadata = stream
3195 fruit:veto_appledouble = no
3197 [vfs_fruit_stream_depot]
3198 path = $shrdir
3199 vfs objects = fruit streams_depot acl_xattr xattr_tdb
3200 fruit:resource = stream
3201 fruit:metadata = stream
3202 fruit:veto_appledouble = no
3204 [vfs_wo_fruit]
3205 path = $shrdir
3206 vfs objects = streams_xattr acl_xattr xattr_tdb
3208 [vfs_wo_fruit_stream_depot]
3209 path = $shrdir
3210 vfs objects = streams_depot acl_xattr xattr_tdb
3212 [vfs_fruit_timemachine]
3213 path = $shrdir
3214 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3215 fruit:resource = file
3216 fruit:metadata = stream
3217 fruit:time machine = yes
3218 fruit:time machine max size = 32K
3220 [vfs_fruit_wipe_intentionally_left_blank_rfork]
3221 path = $shrdir
3222 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3223 fruit:resource = file
3224 fruit:metadata = stream
3225 fruit:wipe_intentionally_left_blank_rfork = true
3226 fruit:delete_empty_adfiles = false
3227 fruit:veto_appledouble = no
3229 [vfs_fruit_delete_empty_adfiles]
3230 path = $shrdir
3231 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3232 fruit:resource = file
3233 fruit:metadata = stream
3234 fruit:wipe_intentionally_left_blank_rfork = true
3235 fruit:delete_empty_adfiles = true
3236 fruit:veto_appledouble = no
3238 [vfs_fruit_zero_fileid]
3239 path = $shrdir
3240 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3241 fruit:resource = file
3242 fruit:metadata = stream
3243 fruit:zero_file_id=yes
3245 [fruit_resource_stream]
3246 path = $fruit_resource_stream_shrdir
3247 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3248 fruit:resource = stream
3249 fruit:metadata = stream
3251 [badname-tmp]
3252 path = $badnames_shrdir
3253 guest ok = yes
3255 [manglenames_share]
3256 path = $manglenames_shrdir
3257 guest ok = yes
3259 [dynamic_share]
3260 path = $shrdir/dynamic/%t
3261 guest ok = yes
3262 root preexec = mkdir %P
3264 [widelinks_share]
3265 path = $widelinks_shrdir
3266 wide links = no
3267 guest ok = yes
3269 [fsrvp_share]
3270 path = $fsrvp_shrdir
3271 comment = fake snapshots using rsync
3272 vfs objects = shell_snap shadow_copy2
3273 shell_snap:check path command = $fake_snap_pl --check
3274 shell_snap:create command = $fake_snap_pl --create
3275 shell_snap:delete command = $fake_snap_pl --delete
3276 # a relative path here fails, the snapshot dir is no longer found
3277 shadow:snapdir = $fsrvp_shrdir/.snapshots
3279 [shadow1]
3280 path = $shadow_shrdir
3281 comment = previous versions snapshots under mount point
3282 vfs objects = shadow_copy2
3283 shadow:mountpoint = $shadow_mntdir
3285 [shadow2]
3286 path = $shadow_shrdir
3287 comment = previous versions snapshots outside mount point
3288 vfs objects = shadow_copy2
3289 shadow:mountpoint = $shadow_mntdir
3290 shadow:snapdir = $shadow_tstdir/.snapshots
3292 [shadow3]
3293 path = $shadow_shrdir
3294 comment = previous versions with subvolume snapshots, snapshots under base dir
3295 vfs objects = shadow_copy2
3296 shadow:mountpoint = $shadow_mntdir
3297 shadow:basedir = $shadow_basedir
3298 shadow:snapdir = $shadow_basedir/.snapshots
3300 [shadow4]
3301 path = $shadow_shrdir
3302 comment = previous versions with subvolume snapshots, snapshots outside mount point
3303 vfs objects = shadow_copy2
3304 shadow:mountpoint = $shadow_mntdir
3305 shadow:basedir = $shadow_basedir
3306 shadow:snapdir = $shadow_tstdir/.snapshots
3308 [shadow5]
3309 path = $shadow_shrdir
3310 comment = previous versions at volume root snapshots under mount point
3311 vfs objects = shadow_copy2
3312 shadow:mountpoint = $shadow_shrdir
3314 [shadow6]
3315 path = $shadow_shrdir
3316 comment = previous versions at volume root snapshots outside mount point
3317 vfs objects = shadow_copy2
3318 shadow:mountpoint = $shadow_shrdir
3319 shadow:snapdir = $shadow_tstdir/.snapshots
3321 [shadow7]
3322 path = $shadow_shrdir
3323 comment = previous versions snapshots everywhere
3324 vfs objects = shadow_copy2
3325 shadow:mountpoint = $shadow_mntdir
3326 shadow:snapdirseverywhere = yes
3328 [shadow8]
3329 path = $shadow_shrdir
3330 comment = previous versions using snapsharepath
3331 vfs objects = shadow_copy2
3332 shadow:mountpoint = $shadow_mntdir
3333 shadow:snapdir = $shadow_tstdir/.snapshots
3334 shadow:snapsharepath = share
3336 [shadow_fmt0]
3337 comment = Testing shadow:format with default option
3338 vfs object = shadow_copy2
3339 path = $shadow_shrdir
3340 read only = no
3341 guest ok = yes
3342 shadow:mountpoint = $shadow_mntdir
3343 shadow:basedir = $shadow_basedir
3344 shadow:snapdir = $shadow_basedir/.snapshots
3345 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
3347 [shadow_fmt1]
3348 comment = Testing shadow:format with only date component
3349 vfs object = shadow_copy2
3350 path = $shadow_shrdir
3351 read only = no
3352 guest ok = yes
3353 shadow:mountpoint = $shadow_mntdir
3354 shadow:basedir = $shadow_basedir
3355 shadow:snapdir = $shadow_basedir/.snapshots
3356 shadow:format = \@GMT-%Y-%m-%d
3358 [shadow_fmt2]
3359 comment = Testing shadow:format with some hardcoded prefix
3360 vfs object = shadow_copy2
3361 path = $shadow_shrdir
3362 read only = no
3363 guest ok = yes
3364 shadow:mountpoint = $shadow_mntdir
3365 shadow:basedir = $shadow_basedir
3366 shadow:snapdir = $shadow_basedir/.snapshots
3367 shadow:format = snap\@GMT-%Y.%m.%d-%H.%M.%S
3369 [shadow_fmt3]
3370 comment = Testing shadow:format with modified format
3371 vfs object = shadow_copy2
3372 path = $shadow_shrdir
3373 read only = no
3374 guest ok = yes
3375 shadow:mountpoint = $shadow_mntdir
3376 shadow:basedir = $shadow_basedir
3377 shadow:snapdir = $shadow_basedir/.snapshots
3378 shadow:format = \@GMT-%Y.%m.%d-%H_%M_%S-snap
3380 [shadow_fmt4]
3381 comment = Testing shadow:snapprefix regex
3382 vfs object = shadow_copy2
3383 path = $shadow_shrdir
3384 read only = no
3385 guest ok = yes
3386 shadow:mountpoint = $shadow_mntdir
3387 shadow:basedir = $shadow_basedir
3388 shadow:snapdir = $shadow_basedir/.snapshots
3389 shadow:snapprefix = \^s[a-z]*p\$
3390 shadow:format = _GMT-%Y.%m.%d-%H.%M.%S
3392 [shadow_fmt5]
3393 comment = Testing shadow:snapprefix with delim regex
3394 vfs object = shadow_copy2
3395 path = $shadow_shrdir
3396 read only = no
3397 guest ok = yes
3398 shadow:mountpoint = $shadow_mntdir
3399 shadow:basedir = $shadow_basedir
3400 shadow:snapdir = $shadow_basedir/.snapshots
3401 shadow:delimiter = \@GMT
3402 shadow:snapprefix = [a-z]*
3403 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
3405 [shadow_wl]
3406 path = $shadow_shrdir
3407 comment = previous versions with wide links allowed
3408 vfs objects = shadow_copy2
3409 shadow:mountpoint = $shadow_mntdir
3410 wide links = yes
3412 [shadow_write]
3413 path = $shadow_tstdir
3414 comment = previous versions snapshots under mount point
3415 vfs objects = shadow_copy2 streams_xattr error_inject
3416 aio write size = 0
3417 error_inject:pwrite = EBADF
3418 shadow:mountpoint = $shadow_tstdir
3419 shadow:fixinodes = yes
3420 smbd async dosmode = yes
3422 [shadow_depot]
3423 path = $shadow_shrdir
3424 comment = previous versions with streams_depot
3425 vfs objects = streams_depot shadow_copy2
3427 [dfq]
3428 path = $shrdir/dfree
3429 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
3430 admin users = $unix_name
3431 include = $dfqconffile
3432 [dfq_cache]
3433 path = $shrdir/dfree
3434 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
3435 admin users = $unix_name
3436 include = $dfqconffile
3437 dfree cache time = 60
3438 [dfq_owner]
3439 path = $shrdir/dfree
3440 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
3441 inherit owner = yes
3442 include = $dfqconffile
3443 [quotadir]
3444 path = $shrdir/quota
3445 admin users = $unix_name
3447 [acl_xattr_ign_sysacl_posix]
3448 copy = tmp
3449 acl_xattr:ignore system acls = yes
3450 acl_xattr:default acl style = posix
3451 [acl_xattr_ign_sysacl_windows]
3452 copy = tmp
3453 acl_xattr:ignore system acls = yes
3454 acl_xattr:default acl style = windows
3456 [mangle_illegal]
3457 copy = tmp
3458 mangled names = illegal
3460 [nosymlinks]
3461 copy = tmp
3462 path = $nosymlinks_shrdir
3463 follow symlinks = no
3464 [nosymlinks_smb1allow]
3465 copy=nosymlinks
3466 follow symlinks = yes
3468 [local_symlinks]
3469 copy = tmp
3470 path = $local_symlinks_shrdir
3471 follow symlinks = yes
3473 [kernel_oplocks]
3474 copy = tmp
3475 kernel oplocks = yes
3476 vfs objects = streams_xattr xattr_tdb
3478 [streams_xattr]
3479 copy = tmp
3480 vfs objects = streams_xattr xattr_tdb
3482 [streams_xattr_nostrict]
3483 copy = tmp
3484 strict rename = no
3485 vfs objects = streams_xattr xattr_tdb
3487 [acl_streams_xattr]
3488 copy = tmp
3489 vfs objects = acl_xattr streams_xattr fake_acls xattr_tdb
3490 acl_xattr:ignore system acls = yes
3491 acl_xattr:security_acl_name = user.acl
3492 xattr_tdb:ignore_user_xattr = yes
3494 [compound_find]
3495 copy = tmp
3496 smbd:find async delay usec = 10000
3497 [error_inject]
3498 copy = tmp
3499 vfs objects = error_inject
3500 include = $errorinjectconf
3502 [delay_inject]
3503 copy = tmp
3504 vfs objects = delay_inject
3505 kernel share modes = no
3506 kernel oplocks = no
3507 posix locking = no
3508 include = $delayinjectconf
3510 [aio_delay_inject]
3511 copy = tmp
3512 vfs objects = delay_inject
3513 delay_inject:pread_send = 2000
3514 delay_inject:pwrite_send = 2000
3516 [brl_delay_inject1]
3517 copy = tmp
3518 vfs objects = delay_inject
3519 delay_inject:brl_lock_windows = 90
3520 delay_inject:brl_lock_windows_use_timer = yes
3522 [brl_delay_inject2]
3523 copy = tmp
3524 vfs objects = delay_inject
3525 delay_inject:brl_lock_windows = 90
3526 delay_inject:brl_lock_windows_use_timer = no
3528 [delete_readonly]
3529 path = $prefix_abs/share
3530 delete readonly = yes
3532 [enc_desired]
3533 path = $prefix_abs/share
3534 vfs objects =
3535 server smb encrypt = desired
3537 [enc_off]
3538 path = $prefix_abs/share
3539 vfs objects =
3540 server smb encrypt = off
3542 [notify_priv]
3543 copy = tmp
3544 honor change notify privilege = yes
3546 [acls_non_canonical]
3547 copy = tmp
3548 acl flag inherited canonicalization = no
3550 [full_audit_success_bad_name]
3551 copy = tmp
3552 full_audit:success = badname
3554 [full_audit_fail_bad_name]
3555 copy = tmp
3556 full_audit:failure = badname
3558 [only_ipv6]
3559 copy = tmpguest
3560 server addresses = $server_ipv6
3562 [smbget]
3563 path = $smbget_sharedir
3564 comment = smb username is [%U]
3565 guest ok = yes
3567 include = $aliceconfdir/%U.conf
3570 close(CONF);
3572 my $net = Samba::bindir_path($self, "net");
3573 my $cmd = "";
3574 $cmd .= "UID_WRAPPER_ROOT=1 ";
3575 $cmd .= "SMB_CONF_PATH=\"$conffile\" ";
3576 $cmd .= "$net setlocalsid $samsid";
3578 my $net_ret = system($cmd);
3579 if ($net_ret != 0) {
3580 warn("net setlocalsid failed: $net_ret\n$cmd");
3581 return undef;
3584 unless (open(ERRORCONF, ">$errorinjectconf")) {
3585 warn("Unable to open $errorinjectconf");
3586 return undef;
3588 close(ERRORCONF);
3590 unless (open(DELAYCONF, ">$delayinjectconf")) {
3591 warn("Unable to open $delayinjectconf");
3592 return undef;
3594 close(DELAYCONF);
3596 unless (open(DFQCONF, ">$dfqconffile")) {
3597 warn("Unable to open $dfqconffile");
3598 return undef;
3600 close(DFQCONF);
3602 unless (open(DELAYCONF, ">$globalinjectconf")) {
3603 warn("Unable to open $globalinjectconf");
3604 return undef;
3606 close(DELAYCONF);
3608 unless (open(ALICECONF, ">$aliceconffile")) {
3609 warn("Unable to open $aliceconffile");
3610 return undef;
3613 print ALICECONF "
3614 [alice_share]
3615 path = $shrdir
3616 comment = smb username is [%U]
3619 close(ALICECONF);
3622 ## create a test account
3625 unless (open(PASSWD, ">$nss_wrapper_passwd")) {
3626 warn("Unable to open $nss_wrapper_passwd");
3627 return undef;
3629 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
3630 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
3631 pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
3632 pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
3633 userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
3634 pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false
3635 force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false
3636 smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false
3637 user1:x:$uid_user1:$gid_nogroup:user1 gecos:$prefix_abs:/bin/false
3638 user2:x:$uid_user2:$gid_nogroup:user2 gecos:$prefix_abs:/bin/false
3639 gooduser:x:$uid_gooduser:$gid_domusers:gooduser gecos:$prefix_abs:/bin/false
3640 eviluser:x:$uid_eviluser:$gid_domusers:eviluser gecos::/bin/false
3641 slashuser:x:$uid_slashuser:$gid_domusers:slashuser gecos:/:/bin/false
3642 bob:x:$uid_localbob:$gid_domusers:localbob gecos:/:/bin/false
3643 jane:x:$uid_localjane:$gid_domusers:localjane gecos:/:/bin/false
3644 jackthemapper:x:$uid_localjackthemapper:$gid_domusers:localjackthemaper gecos:/:/bin/false
3645 jacknomapper:x:$uid_localjacknomapper:$gid_domusers:localjacknomaper gecos:/:/bin/false
3647 if ($unix_uid != 0) {
3648 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
3651 close(PASSWD);
3653 unless (open(GROUP, ">$nss_wrapper_group")) {
3654 warn("Unable to open $nss_wrapper_group");
3655 return undef;
3657 print GROUP "nobody:x:$gid_nobody:
3658 nogroup:x:$gid_nogroup:nobody
3659 $unix_name-group:x:$unix_gids[0]:
3660 domusers:X:$gid_domusers:
3661 domadmins:X:$gid_domadmins:
3662 userdup:x:$gid_userdup:$unix_name
3663 everyone:x:$gid_everyone:
3664 force_user:x:$gid_force_user:
3665 jackthemappergroup:x:$gid_jackthemapper:jackthemapper
3666 jacknomappergroup:x:$gid_jacknomapper:jacknomapper
3668 if ($unix_gids[0] != 0) {
3669 print GROUP "root:x:$gid_root:
3673 close(GROUP);
3675 ## hosts
3676 my $hostname = lc($server);
3677 unless (open(HOSTS, ">>$nss_wrapper_hosts")) {
3678 warn("Unable to open $nss_wrapper_hosts");
3679 return undef;
3681 print HOSTS "${server_ip} ${hostname}.${dns_domain} ${hostname}\n";
3682 print HOSTS "${server_ipv6} ${hostname}.${dns_domain} ${hostname}\n";
3683 close(HOSTS);
3685 $resolv_conf = "$privatedir/no_resolv.conf" unless defined($resolv_conf);
3687 foreach my $evlog (@eventlog_list) {
3688 my $evlogtdb = "$eventlogdir/$evlog.tdb";
3689 open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
3690 close(EVENTLOG);
3693 $createuser_env{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
3694 $createuser_env{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
3695 $createuser_env{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
3696 $createuser_env{NSS_WRAPPER_HOSTNAME} = "${hostname}.${dns_domain}";
3697 if ($ENV{SAMBA_DNS_FAKING}) {
3698 $createuser_env{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
3699 } else {
3700 $createuser_env{RESOLV_WRAPPER_CONF} = $resolv_conf;
3702 $createuser_env{RESOLV_CONF} = $resolv_conf;
3704 createuser($self, $unix_name, $password, $conffile, \%createuser_env) || die("Unable to create user");
3705 createuser($self, "force_user", $password, $conffile, \%createuser_env) || die("Unable to create force_user");
3706 createuser($self, "smbget_user", $password, $conffile, \%createuser_env) || die("Unable to create smbget_user");
3707 createuser($self, "user1", $password, $conffile, \%createuser_env) || die("Unable to create user1");
3708 createuser($self, "user2", $password, $conffile, \%createuser_env) || die("Unable to create user2");
3709 createuser($self, "gooduser", $password, $conffile, \%createuser_env) || die("Unable to create gooduser");
3710 createuser($self, "eviluser", $password, $conffile, \%createuser_env) || die("Unable to create eviluser");
3711 createuser($self, "slashuser", $password, $conffile, \%createuser_env) || die("Unable to create slashuser");
3712 createuser($self, "jackthemapper", "mApsEcrEt", $conffile, \%createuser_env) || die("Unable to create jackthemapper");
3713 createuser($self, "jacknomapper", "nOmApsEcrEt", $conffile, \%createuser_env) || die("Unable to create jacknomapper");
3715 open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
3716 print DNS_UPDATE_LIST "A $server. $server_ip\n";
3717 print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n";
3718 close(DNS_UPDATE_LIST);
3720 print "DONE\n";
3722 $ret{SERVER_IP} = $server_ip;
3723 $ret{SERVER_IPV6} = $server_ipv6;
3724 $ret{SAMBA_DCERPCD_TEST_LOG} = "$prefix/samba_dcerpcd_test.log";
3725 $ret{SAMBA_DCERPCD_LOG_POS} = 0;
3726 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
3727 $ret{NMBD_TEST_LOG_POS} = 0;
3728 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
3729 $ret{WINBINDD_TEST_LOG_POS} = 0;
3730 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
3731 $ret{SMBD_TEST_LOG_POS} = 0;
3732 $ret{SERVERCONFFILE} = $conffile;
3733 $ret{TESTENV_DIR} = $prefix_abs;
3734 $ret{CONFIGURATION} ="--configfile=$conffile";
3735 $ret{LOCK_DIR} = $lockdir;
3736 $ret{SERVER} = $server;
3737 $ret{USERNAME} = $unix_name;
3738 $ret{USERID} = $unix_uid;
3739 $ret{DOMAIN} = $domain;
3740 $ret{SAMSID} = $samsid;
3741 $ret{NETBIOSNAME} = $server;
3742 $ret{PASSWORD} = $password;
3743 $ret{PIDDIR} = $piddir;
3744 $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir;
3745 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
3746 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
3747 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
3748 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
3749 $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
3750 $ret{NSS_WRAPPER_HOSTNAME} = "${hostname}.${dns_domain}";
3751 $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
3752 $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind";
3753 if ($ENV{SAMBA_DNS_FAKING}) {
3754 $ret{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
3755 } else {
3756 $ret{RESOLV_WRAPPER_CONF} = $resolv_conf;
3758 $ret{RESOLV_CONF} = $resolv_conf;
3759 $ret{LOCAL_PATH} = "$shrdir";
3760 $ret{LOGDIR} = $logdir;
3763 # Avoid hitting system krb5.conf -
3764 # An env that needs Kerberos will reset this to the real
3765 # value.
3767 $ret{KRB5_CONFIG} = abs_path($prefix) . "/no_krb5.conf";
3769 # Define KRB5CCNAME for each environment we set up
3770 $ret{KRB5_CCACHE} = abs_path($prefix) . "/krb5ccache";
3771 $ENV{KRB5CCNAME} = $ret{KRB5_CCACHE};
3773 return \%ret;
3776 sub wait_for_start($$$$$)
3778 my ($self, $envvars, $nmbd, $winbindd, $smbd, $samba_dcerpcd) = @_;
3779 my $cmd;
3780 my $netcmd;
3781 my $ret;
3783 if ($samba_dcerpcd eq "yes") {
3784 my $count = 0;
3785 my $rpcclient = Samba::bindir_path($self, "rpcclient");
3787 print "checking for samba_dcerpcd\n";
3789 do {
3790 $ret = system("$rpcclient $envvars->{CONFIGURATION} ncalrpc: -c epmmap");
3792 if ($ret != 0) {
3793 sleep(1);
3795 $count++
3796 } while ($ret != 0 && $count < 10);
3798 if ($count == 10) {
3799 print "samba_dcerpcd not reachable after 10 retries\n";
3800 teardown_env($self, $envvars);
3801 return 0;
3805 if ($nmbd eq "yes") {
3806 my $count = 0;
3808 # give time for nbt server to register its names
3809 print "checking for nmbd\n";
3811 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
3812 my $nmblookup = Samba::bindir_path($self, "nmblookup");
3814 do {
3815 $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
3816 if ($ret != 0) {
3817 sleep(1);
3818 } else {
3819 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
3820 system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
3821 system("$nmblookup $envvars->{CONFIGURATION} -U 10.255.255.255 __SAMBA__");
3822 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
3824 $count++;
3825 } while ($ret != 0 && $count < 10);
3826 if ($count == 10) {
3827 print "NMBD not reachable after 10 retries\n";
3828 teardown_env($self, $envvars);
3829 return 0;
3833 if ($winbindd eq "yes" or $winbindd eq "offline") {
3834 print "checking for winbindd\n";
3835 my $count = 0;
3836 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
3837 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3838 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3839 if ($winbindd eq "yes") {
3840 $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping-dc";
3841 } elsif ($winbindd eq "offline") {
3842 $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping";
3845 do {
3846 $ret = system($cmd);
3847 if ($ret != 0) {
3848 sleep(1);
3850 $count++;
3851 } while ($ret != 0 && $count < 20);
3852 if ($count == 20) {
3853 print "WINBINDD not reachable after 20 seconds\n";
3854 teardown_env($self, $envvars);
3855 return 0;
3859 if ($smbd eq "yes") {
3860 # make sure smbd is also up set
3861 print "wait for smbd\n";
3863 my $count = 0;
3864 do {
3865 if (defined($envvars->{GNUTLS_FORCE_FIPS_MODE})) {
3866 # We don't have NTLM in FIPS mode, so lets use
3867 # smbcontrol instead of smbclient.
3868 $cmd = Samba::bindir_path($self, "smbcontrol");
3869 $cmd .= " $envvars->{CONFIGURATION}";
3870 $cmd .= " smbd ping";
3871 } else {
3872 # This uses NTLM which is not available in FIPS
3873 $cmd = Samba::bindir_path($self, "smbclient");
3874 $cmd .= " $envvars->{CONFIGURATION}";
3875 $cmd .= " -L $envvars->{SERVER}";
3876 $cmd .= " -U%";
3877 $cmd .= " -I $envvars->{SERVER_IP}";
3878 $cmd .= " -p 139";
3881 $ret = system($cmd);
3882 if ($ret != 0) {
3883 sleep(1);
3885 $count++
3886 } while ($ret != 0 && $count < 20);
3887 if ($count == 20) {
3888 print "SMBD failed to start up in a reasonable time (20sec)\n";
3889 teardown_env($self, $envvars);
3890 return 0;
3894 # Ensure we have domain users mapped.
3895 $netcmd = "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3896 $netcmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3897 $netcmd .= "UID_WRAPPER_ROOT='1' ";
3898 $netcmd .= Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} ";
3900 $cmd = $netcmd . "groupmap delete ntgroup=domusers";
3901 $ret = system($cmd);
3903 $cmd = $netcmd . "groupmap add rid=513 unixgroup=domusers type=domain";
3904 $ret = system($cmd);
3905 if ($ret != 0) {
3906 print("\"$cmd\" failed\n");
3907 return 1;
3910 $cmd = $netcmd . "groupmap delete ntgroup=domadmins";
3911 $ret = system($cmd);
3913 $cmd = $netcmd . "groupmap add rid=512 unixgroup=domadmins type=domain";
3914 $ret = system($cmd);
3915 if ($ret != 0) {
3916 print("\"$cmd\" failed\n");
3917 return 1;
3920 $cmd = $netcmd . "groupmap delete ntgroup=everyone";
3921 $ret = system($cmd);
3923 $cmd = $netcmd . "groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin";
3924 $ret = system($cmd);
3925 if ($ret != 0) {
3926 print("\"$cmd\" failed\n");
3927 return 1;
3930 # note: creating builtin groups requires winbindd for the
3931 # unix id allocator
3932 my $create_builtin_users = "no";
3933 if ($winbindd eq "yes") {
3934 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
3935 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3936 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3937 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
3938 my $wbinfo_out = qx($cmd 2>&1);
3939 if ($? != 0) {
3940 # wbinfo doesn't give us a better error code then
3941 # WBC_ERR_DOMAIN_NOT_FOUND, but at least that's
3942 # different then WBC_ERR_WINBIND_NOT_AVAILABLE
3943 if ($wbinfo_out !~ /WBC_ERR_DOMAIN_NOT_FOUND/) {
3944 print("Failed to run \"wbinfo --sid-to-gid=S-1-5-32-545\": $wbinfo_out");
3945 teardown_env($self, $envvars);
3946 return 0;
3948 $create_builtin_users = "yes";
3951 if ($create_builtin_users eq "yes") {
3952 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
3953 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3954 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3955 $cmd .= Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
3956 $cmd .= "sam createbuiltingroup Users";
3957 $ret = system($cmd);
3958 if ($ret != 0) {
3959 print "Failed to create BUILTIN\\Users group\n";
3960 teardown_env($self, $envvars);
3961 return 0;
3964 $cmd = Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
3965 $cmd .= "cache del IDMAP/SID2XID/S-1-5-32-545";
3966 system($cmd);
3968 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
3969 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3970 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3971 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
3972 $ret = system($cmd);
3973 if ($ret != 0) {
3974 print "Missing \"BUILTIN\\Users\", did net sam createbuiltingroup Users fail?\n";
3975 teardown_env($self, $envvars);
3976 return 0;
3980 print $self->getlog_env($envvars);
3982 return 1;
3986 ## provision and start of ctdb
3988 sub setup_ctdb($$)
3990 my ($self, $prefix) = @_;
3991 my $num_nodes = 3;
3993 my $data = $self->provision_ctdb($prefix, $num_nodes);
3994 $data or return undef;
3996 my $rc = $self->check_or_start_ctdb($data);
3997 if (not $rc) {
3998 print("check_or_start_ctdb() failed\n");
3999 return undef;
4002 $rc = $self->wait_for_start_ctdb($data);
4003 if (not $rc) {
4004 print "Cluster startup failed\n";
4005 return undef;
4008 return $data;
4011 sub provision_ctdb($$$$)
4013 my ($self, $prefix, $num_nodes, $no_delete_prefix) = @_;
4014 my $rc;
4016 print "PROVISIONING CTDB...\n";
4018 my $prefix_abs = abs_path($prefix);
4021 # check / create directories:
4023 die ("prefix_abs = ''") if $prefix_abs eq "";
4024 die ("prefix_abs = '/'") if $prefix_abs eq "/";
4026 mkdir ($prefix_abs, 0777);
4028 print "CREATE CTDB TEST ENVIRONMENT in '$prefix_abs'...\n";
4030 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
4031 system("rm -rf $prefix_abs/*");
4035 # Per-node data
4037 my @nodes = ();
4038 for (my $i = 0; $i < $num_nodes; $i++) {
4039 my %node = ();
4040 my $server_name = "ctdb${i}";
4041 my $pub_iface = Samba::get_interface($server_name);
4042 my $ip = Samba::get_ipv4_addr($server_name);
4044 $node{NODE_NUMBER} = "$i";
4045 $node{SERVER_NAME} = "$server_name";
4046 $node{SOCKET_WRAPPER_DEFAULT_IFACE} = "$pub_iface";
4047 $node{IP} = "$ip";
4049 push(@nodes, \%node);
4053 # nodes
4055 my $nodes_file = "$prefix/nodes.in";
4056 unless (open(NODES, ">$nodes_file")) {
4057 warn("Unable to open nodesfile '$nodes_file'");
4058 return undef;
4060 for (my $i = 0; $i < $num_nodes; $i++) {
4061 my $ip = $nodes[$i]->{IP};
4062 print NODES "${ip}\n";
4064 close(NODES);
4067 # local_daemons.sh setup
4069 # Socket wrapper setup is done by selftest.pl, so don't use
4070 # the CTDB-specific setup
4072 my $cmd;
4073 $cmd .= "ctdb/tests/local_daemons.sh " . $prefix_abs . " setup";
4074 $cmd .= " -n " . $num_nodes;
4075 $cmd .= " -N " . $nodes_file;
4076 # CTDB should not attempt to manage public addresses -
4077 # clients should just connect to CTDB private addresses
4078 $cmd .= " -P " . "/dev/null";
4080 my $ret = system($cmd);
4081 if ($ret != 0) {
4082 print("\"$cmd\" failed\n");
4083 return undef;
4087 # Unix domain socket and node directory for each daemon
4089 for (my $i = 0; $i < $num_nodes; $i++) {
4090 my ($cmd, $ret, $out);
4092 my $cmd_prefix = "ctdb/tests/local_daemons.sh ${prefix_abs}";
4095 # socket
4098 $cmd = "${cmd_prefix} print-socket ${i}";
4100 $out = `$cmd`;
4101 $ret = $?;
4102 if ($ret != 0) {
4103 print("\"$cmd\" failed\n");
4104 return undef;
4106 chomp $out;
4107 $nodes[$i]->{SOCKET_FILE} = "$out";
4110 # node directory
4113 $cmd = "${cmd_prefix} onnode ${i} 'echo \$CTDB_BASE'";
4115 $out = `$cmd`;
4116 $ret = $?;
4117 if ($ret != 0) {
4118 print("\"$cmd\" failed\n");
4119 return undef;
4121 chomp $out;
4122 $nodes[$i]->{NODE_PREFIX} = "$out";
4125 my %ret = ();
4127 $ret{CTDB_PREFIX} = "$prefix";
4128 $ret{NUM_NODES} = $num_nodes;
4129 $ret{CTDB_NODES} = \@nodes;
4130 $ret{CTDB_NODES_FILE} = $nodes_file;
4132 return \%ret;
4135 sub check_or_start_ctdb($$) {
4136 my ($self, $data) = @_;
4138 my $prefix = $data->{CTDB_PREFIX};
4139 my $num_nodes = $data->{NUM_NODES};
4140 my $nodes = $data->{CTDB_NODES};
4141 my $STDIN_READER;
4143 # Share a single stdin pipe for all nodes
4144 pipe($STDIN_READER, $data->{CTDB_STDIN_PIPE});
4146 for (my $i = 0; $i < $num_nodes; $i++) {
4147 my $node = $nodes->[$i];
4149 $node->{STDIN_PIPE} = $data->{CTDB_STDIN_PIPE};
4151 my $cmd = "ctdb/tests/local_daemons.sh";
4152 my @full_cmd = ("$cmd", "$prefix", "start", "$i");
4153 my $daemon_ctx = {
4154 NAME => "ctdbd",
4155 BINARY_PATH => $cmd,
4156 FULL_CMD => [ @full_cmd ],
4157 TEE_STDOUT => 1,
4158 LOG_FILE => "/dev/null",
4159 ENV_VARS => {},
4162 print "STARTING CTDBD (node ${i})\n";
4164 # This does magic with $STDIN_READER, so use it
4165 my $ret = Samba::fork_and_exec($self,
4166 $node,
4167 $daemon_ctx,
4168 $STDIN_READER);
4170 if ($ret == 0) {
4171 print("\"$cmd\" failed\n");
4172 teardown_env_ctdb($self, $data);
4173 return 0;
4177 close($STDIN_READER);
4179 return 1;
4182 sub wait_for_start_ctdb($$)
4184 my ($self, $data) = @_;
4186 my $prefix = $data->{CTDB_PREFIX};
4188 print "Wait for ctdbd...\n";
4190 my $ctdb = Samba::bindir_path($self, "ctdb");
4191 my $cmd;
4192 $cmd .= "ctdb/tests/local_daemons.sh ${prefix} onnode all";
4193 $cmd .= " ${ctdb} nodestatus all 2>&1";
4195 my $count = 0;
4196 my $wait_seconds = 60;
4197 my $out;
4199 until ($count > $wait_seconds) {
4200 $out = `$cmd`;
4201 my $ret = $?;
4202 if ($ret == 0) {
4203 print "\ncluster became healthy\n";
4204 last;
4206 print "Waiting for CTDB...\n";
4207 sleep(1);
4208 $count++;
4211 if ($count > $wait_seconds) {
4212 print "\nGiving up to wait for CTDB...\n";
4213 print "${out}\n\n";
4214 print "CTDB log:\n";
4215 $cmd = "ctdb/tests/local_daemons.sh ${prefix} print-log all >&2";
4216 system($cmd);
4217 teardown_env_ctdb($self, $data);
4218 return 0;
4221 print "\nCTDB initialized\n";
4223 return 1;