smbd: in file_set_dosmode() do an early exit if smb_fname->fsp is NULL
[Samba.git] / selftest / target / Samba3.pm
blobef68f63e3481cf44fd000431216d3d65504af3a7
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 [io_uring]
2014 path = $share_dir
2015 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot time_audit full_audit io_uring
2016 read only = no
2018 [homes]
2019 comment = Home directories
2020 browseable = No
2021 read only = No
2024 if (defined($more_conf)) {
2025 $fileserver_options = $fileserver_options . $more_conf;
2027 if (!defined($server)) {
2028 $server = "FILESERVER";
2031 my $vars = $self->provision(
2032 prefix => $path,
2033 domain => "WORKGROUP",
2034 server => $server,
2035 password => "fileserver",
2036 extra_options => $fileserver_options,
2037 no_delete_prefix => 1);
2039 $vars or return undef;
2041 if (not $self->check_or_start(
2042 env_vars => $vars,
2043 nmbd => "yes",
2044 smbd => "yes")) {
2045 return undef;
2049 mkdir($_, 0777) foreach(@dirs);
2051 ## Create case sensitive lower case share dir
2052 foreach my $file ('a'..'z') {
2053 my $full_path = $lower_case_share_dir . '/' . $file;
2054 open my $fh, '>', $full_path;
2055 # Add some content to file
2056 print $fh $full_path;
2057 close $fh;
2060 for (my $file = 1; $file < 51; ++$file) {
2061 my $full_path = $lower_case_share_dir . '/' . $file;
2062 open my $fh, '>', $full_path;
2063 # Add some content to file
2064 print $fh $full_path;
2065 close $fh;
2068 # Create content for 30000 share
2069 foreach my $file ('a'..'z') {
2070 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
2071 open my $fh, '>', $full_path;
2072 # Add some content to file
2073 print $fh $full_path;
2074 close $fh;
2077 for (my $file = 1; $file < 30001; ++$file) {
2078 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
2079 open my $fh, '>', $full_path;
2080 # Add some content to file
2081 print $fh $full_path;
2082 close $fh;
2086 ## create a listable file in valid_users_share
2088 create_file_chmod("$valid_users_sharedir/foo", 0644) or return undef;
2091 ## create a valid utf8 filename which is invalid as a CP850 conversion
2093 create_file_chmod("$bad_iconv_sharedir/\xED\x9F\xBF", 0644) or return undef;
2096 ## create unwritable files inside inside the delete unwrite veto share dirs.
2098 unlink("$delete_unwrite_sharedir/delete_veto_yes/file_444");
2099 create_file_chmod("$delete_unwrite_sharedir/delete_veto_yes/file_444", 0444) or return undef;
2100 unlink("$delete_unwrite_sharedir/delete_veto_no/file_444");
2101 create_file_chmod("$delete_unwrite_sharedir/delete_veto_no/file_444", 0444) or return undef;
2103 return $vars;
2106 sub setup_fileserver_smb1
2108 my ($self, $path) = @_;
2109 my $prefix_abs = abs_path($path);
2110 my $conf = "
2111 [global]
2112 client min protocol = CORE
2113 server min protocol = LANMAN1
2114 check parent directory delete on close = yes
2116 [hidenewfiles]
2117 path = $prefix_abs/share
2118 hide new files timeout = 5
2119 [vfs_aio_pthread]
2120 path = $prefix_abs/share
2121 read only = no
2122 vfs objects = aio_pthread
2123 aio_pthread:aio open = yes
2124 smbd async dosmode = no
2126 [vfs_aio_pthread_async_dosmode_default1]
2127 path = $prefix_abs/share
2128 read only = no
2129 vfs objects = aio_pthread
2130 store dos attributes = yes
2131 aio_pthread:aio open = yes
2132 smbd async dosmode = yes
2134 [vfs_aio_pthread_async_dosmode_default2]
2135 path = $prefix_abs/share
2136 read only = no
2137 vfs objects = aio_pthread xattr_tdb
2138 store dos attributes = yes
2139 aio_pthread:aio open = yes
2140 smbd async dosmode = yes
2142 [vfs_aio_fork]
2143 path = $prefix_abs/share
2144 vfs objects = aio_fork
2145 read only = no
2146 vfs_aio_fork:erratic_testing_mode=yes
2148 return $self->setup_fileserver($path, $conf, "FILESERVERSMB1");
2151 sub setup_fileserver_smb1_done
2153 my ($self, $path, $dep_env) = @_;
2154 return $self->return_alias_env($path, $dep_env);
2157 sub setup_ktest
2159 my ($self, $prefix) = @_;
2161 # If we didn't build with ADS, pretend this env was never available
2162 if (not $self->have_ads()) {
2163 return "UNKNOWN";
2166 print "PROVISIONING server with security=ads...";
2168 my $ktest_options = "
2169 workgroup = KTEST
2170 realm = ktest.samba.example.com
2171 security = ads
2172 server signing = required
2173 server min protocol = SMB3_00
2174 client max protocol = SMB3
2176 # This disables NTLM auth against the local SAM, which
2177 # we use can then test this setting by.
2178 ntlm auth = disabled
2180 idmap config * : backend = autorid
2181 idmap config * : range = 1000000-1999999
2182 idmap config * : rangesize = 100000
2185 my $ret = $self->provision(
2186 prefix => $prefix,
2187 domain => "KTEST",
2188 server => "LOCALKTEST6",
2189 password => "localktest6pass",
2190 extra_options => $ktest_options);
2192 $ret or return undef;
2194 my $ctx;
2195 my $prefix_abs = abs_path($prefix);
2196 $ctx = {};
2197 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
2198 $ctx->{domain} = "KTEST";
2199 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
2200 $ctx->{dnsname} = lc($ctx->{realm});
2201 $ctx->{kdc_ipv4} = "0.0.0.0";
2202 $ctx->{kdc_ipv6} = "::";
2203 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
2204 Samba::mk_krb5_conf($ctx, "");
2206 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
2208 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
2209 #Samba4 DC with the same parameters as are being used here. The
2210 #domain SID is S-1-5-21-1071277805-689288055-3486227160
2211 $ret->{SAMSID} = "S-1-5-21-1911091480-1468226576-2729736297";
2212 $ret->{DOMSID} = "S-1-5-21-1071277805-689288055-3486227160";
2214 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
2215 chmod 0600, "$prefix/private/secrets.tdb";
2217 #Make sure there's no old ntdb file.
2218 system("rm -f $prefix/private/secrets.ntdb");
2220 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
2221 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
2223 #and having in krb5.conf:
2224 # ticket_lifetime = 799718400
2225 # renew_lifetime = 799718400
2227 # The commands for the -2 keytab where were:
2228 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
2229 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
2230 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
2231 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
2232 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
2234 # and then for the -3 keytab, I did
2236 # net changetrustpw; kdestroy and the same again.
2238 # This creates a credential cache with a very long lifetime (2036 at
2239 # at 2011-04), and shows that running 'net changetrustpw' does not
2240 # break existing logins (for the secrets.tdb method at least).
2243 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
2245 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
2246 chmod 0600, "$prefix/krb5_ccache-2";
2248 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
2249 chmod 0600, "$prefix/krb5_ccache-3";
2251 # We need world access to this share, as otherwise the domain
2252 # administrator from the AD domain provided by ktest can't
2253 # access the share for tests.
2254 chmod 0777, "$prefix/share";
2256 if (not $self->check_or_start(
2257 env_vars => $ret,
2258 nmbd => "yes",
2259 winbindd => "offline",
2260 smbd => "yes")) {
2261 return undef;
2263 return $ret;
2266 sub setup_maptoguest
2268 my ($self, $path) = @_;
2269 my $prefix_abs = abs_path($path);
2270 my $libdir="$prefix_abs/lib";
2271 my $share_dir="$prefix_abs/share";
2272 my $errorinjectconf="$libdir/error_inject.conf";
2274 print "PROVISIONING maptoguest...";
2276 my $options = "
2277 domain logons = yes
2278 map to guest = bad user
2279 ntlm auth = yes
2280 server min protocol = LANMAN1
2282 [force_user_error_inject]
2283 path = $share_dir
2284 vfs objects = acl_xattr fake_acls xattr_tdb error_inject
2285 force user = user1
2286 include = $errorinjectconf
2289 my $vars = $self->provision(
2290 prefix => $path,
2291 domain => "WORKGROUP",
2292 server => "maptoguest",
2293 password => "maptoguestpass",
2294 extra_options => $options);
2296 $vars or return undef;
2298 if (not $self->check_or_start(
2299 env_vars => $vars,
2300 nmbd => "yes",
2301 winbindd => "yes",
2302 smbd => "yes")) {
2303 return undef;
2306 return $vars;
2309 sub stop_sig_term($$) {
2310 my ($self, $pid) = @_;
2311 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
2314 sub stop_sig_kill($$) {
2315 my ($self, $pid) = @_;
2316 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
2319 sub write_pid($$$)
2321 my ($env_vars, $app, $pid) = @_;
2323 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
2324 print PID $pid;
2325 close(PID);
2328 sub read_pid($$)
2330 my ($env_vars, $app) = @_;
2332 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
2333 my $pid = <PID>;
2334 close(PID);
2335 return $pid;
2338 # builds up the cmd args to run an s3 binary (i.e. smbd, nmbd, etc)
2339 sub make_bin_cmd
2341 my ($self, $binary, $env_vars, $options, $valgrind, $dont_log_stdout) = @_;
2343 my @optargs = ();
2344 if (defined($options)) {
2345 @optargs = split(/ /, $options);
2347 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
2349 if (defined($valgrind)) {
2350 @preargs = split(/ /, $valgrind);
2352 my @args = ("-F", "--no-process-group",
2353 "--configfile=$env_vars->{SERVERCONFFILE}",
2354 "-l", $env_vars->{LOGDIR});
2356 if (not defined($dont_log_stdout)) {
2357 push(@args, "--debug-stdout");
2359 return (@preargs, $binary, @args, @optargs);
2362 sub check_or_start($$) {
2363 my ($self, %args) = @_;
2364 my $env_vars = $args{env_vars};
2365 my $nmbd = $args{nmbd} // "no";
2366 my $winbindd = $args{winbindd} // "no";
2367 my $smbd = $args{smbd} // "no";
2368 my $samba_dcerpcd = $args{samba_dcerpcd} // "no";
2369 my $child_cleanup = $args{child_cleanup};
2371 my $STDIN_READER;
2373 # use a pipe for stdin in the child processes. This allows
2374 # those processes to monitor the pipe for EOF to ensure they
2375 # exit when the test script exits
2376 pipe($STDIN_READER, $env_vars->{STDIN_PIPE});
2378 my $binary = Samba::bindir_path($self, "samba-dcerpcd");
2379 my @full_cmd = $self->make_bin_cmd(
2380 $binary,
2381 $env_vars,
2382 $ENV{SAMBA_DCERPCD_OPTIONS},
2383 $ENV{SAMBA_DCERPCD_VALGRIND},
2384 $ENV{SAMBA_DCERPCD_DONT_LOG_STDOUT});
2385 push(@full_cmd, '--libexec-rpcds');
2387 my $samba_dcerpcd_envs = Samba::get_env_for_process(
2388 "samba_dcerpcd", $env_vars);
2390 # fork and exec() samba_dcerpcd in the child process
2391 my $daemon_ctx = {
2392 NAME => "samba_dcerpcd",
2393 BINARY_PATH => $binary,
2394 FULL_CMD => [ @full_cmd ],
2395 LOG_FILE => $env_vars->{SAMBA_DCERPCD_TEST_LOG},
2396 PCAP_FILE => "env-$ENV{ENVNAME}-samba_dcerpcd",
2397 ENV_VARS => $samba_dcerpcd_envs,
2399 if ($samba_dcerpcd ne "yes") {
2400 $daemon_ctx->{SKIP_DAEMON} = 1;
2403 my $pid = Samba::fork_and_exec(
2404 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
2406 $env_vars->{SAMBA_DCERPCD_TL_PID} = $pid;
2407 write_pid($env_vars, "samba_dcerpcd", $pid);
2409 $binary = Samba::bindir_path($self, "nmbd");
2410 @full_cmd = $self->make_bin_cmd($binary, $env_vars,
2411 $ENV{NMBD_OPTIONS}, $ENV{NMBD_VALGRIND},
2412 $ENV{NMBD_DONT_LOG_STDOUT});
2413 my $nmbd_envs = Samba::get_env_for_process("nmbd", $env_vars);
2414 delete $nmbd_envs->{RESOLV_WRAPPER_CONF};
2415 delete $nmbd_envs->{RESOLV_WRAPPER_HOSTS};
2417 # fork and exec() nmbd in the child process
2418 $daemon_ctx = {
2419 NAME => "nmbd",
2420 BINARY_PATH => $binary,
2421 FULL_CMD => [ @full_cmd ],
2422 LOG_FILE => $env_vars->{NMBD_TEST_LOG},
2423 PCAP_FILE => "env-$ENV{ENVNAME}-nmbd",
2424 ENV_VARS => $nmbd_envs,
2426 if ($nmbd ne "yes") {
2427 $daemon_ctx->{SKIP_DAEMON} = 1;
2429 $pid = Samba::fork_and_exec(
2430 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
2432 $env_vars->{NMBD_TL_PID} = $pid;
2433 write_pid($env_vars, "nmbd", $pid);
2435 $binary = Samba::bindir_path($self, "winbindd");
2436 @full_cmd = $self->make_bin_cmd($binary, $env_vars,
2437 $ENV{WINBINDD_OPTIONS},
2438 $ENV{WINBINDD_VALGRIND},
2439 $ENV{WINBINDD_DONT_LOG_STDOUT});
2441 # fork and exec() winbindd in the child process
2442 $daemon_ctx = {
2443 NAME => "winbindd",
2444 BINARY_PATH => $binary,
2445 FULL_CMD => [ @full_cmd ],
2446 LOG_FILE => $env_vars->{WINBINDD_TEST_LOG},
2447 PCAP_FILE => "env-$ENV{ENVNAME}-winbindd",
2449 if ($winbindd ne "yes" and $winbindd ne "offline") {
2450 $daemon_ctx->{SKIP_DAEMON} = 1;
2453 $pid = Samba::fork_and_exec(
2454 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
2456 $env_vars->{WINBINDD_TL_PID} = $pid;
2457 write_pid($env_vars, "winbindd", $pid);
2459 $binary = Samba::bindir_path($self, "smbd");
2460 @full_cmd = $self->make_bin_cmd($binary, $env_vars,
2461 $ENV{SMBD_OPTIONS}, $ENV{SMBD_VALGRIND},
2462 $ENV{SMBD_DONT_LOG_STDOUT});
2464 # fork and exec() smbd in the child process
2465 $daemon_ctx = {
2466 NAME => "smbd",
2467 BINARY_PATH => $binary,
2468 FULL_CMD => [ @full_cmd ],
2469 LOG_FILE => $env_vars->{SMBD_TEST_LOG},
2470 PCAP_FILE => "env-$ENV{ENVNAME}-smbd",
2472 if ($smbd ne "yes") {
2473 $daemon_ctx->{SKIP_DAEMON} = 1;
2476 $pid = Samba::fork_and_exec(
2477 $self, $env_vars, $daemon_ctx, $STDIN_READER, $child_cleanup);
2479 $env_vars->{SMBD_TL_PID} = $pid;
2480 write_pid($env_vars, "smbd", $pid);
2482 # close the parent's read-end of the pipe
2483 close($STDIN_READER);
2485 return $self->wait_for_start($env_vars,
2486 $nmbd,
2487 $winbindd,
2488 $smbd,
2489 $samba_dcerpcd);
2492 sub createuser($$$$$)
2494 my ($self, $username, $password, $conffile, $env) = @_;
2495 my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $username > /dev/null";
2497 keys %$env;
2498 while(my($var, $val) = each %$env) {
2499 $cmd = "$var=\"$val\" $cmd";
2502 unless (open(PWD, "|$cmd")) {
2503 warn("Unable to set password for $username account\n$cmd");
2504 return undef;
2506 print PWD "$password\n$password\n";
2507 unless (close(PWD)) {
2508 warn("Unable to set password for $username account\n$cmd");
2509 return undef;
2513 sub provision($$)
2515 my ($self, %args) = @_;
2517 my $prefix = $args{prefix};
2518 my $domain = $args{domain};
2519 my $realm = $args{realm};
2520 my $server = $args{server};
2521 my $password = $args{password};
2522 my $extra_options = $args{extra_options};
2523 my $resolv_conf = $args{resolv_conf};
2524 my $no_delete_prefix= $args{no_delete_prefix};
2525 my $netbios_name = $args{netbios_name} // $server;
2526 my $server_log_level = $ENV{SERVER_LOG_LEVEL} || 1;
2529 ## setup the various environment variables we need
2532 my $samsid = Samba::random_domain_sid();
2533 my $swiface = Samba::get_interface($server);
2534 my %ret = ();
2535 my %createuser_env = ();
2536 my $server_ip = Samba::get_ipv4_addr($server);
2537 my $server_ipv6 = Samba::get_ipv6_addr($server);
2538 my $dns_domain;
2539 if (defined($realm)) {
2540 $dns_domain = lc($realm);
2541 } else {
2542 $dns_domain = "samba.example.com";
2545 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
2546 chomp $unix_name;
2547 my $unix_uid = $>;
2548 my $unix_gids_str = $);
2549 my @unix_gids = split(" ", $unix_gids_str);
2551 my $prefix_abs = abs_path($prefix);
2552 my $bindir_abs = abs_path($self->{bindir});
2554 my @dirs = ();
2556 my $shrdir=$args{share_dir} // "$prefix_abs/share";
2557 push(@dirs,$shrdir);
2559 my $libdir="$prefix_abs/lib";
2560 push(@dirs,$libdir);
2562 my $piddir="$prefix_abs/pid";
2563 push(@dirs,$piddir);
2565 my $privatedir="$prefix_abs/private";
2566 push(@dirs,$privatedir);
2568 my $cachedir = "$prefix_abs/cachedir";
2569 push(@dirs, $cachedir);
2571 my $binddnsdir = "$prefix_abs/bind-dns";
2572 push(@dirs, $binddnsdir);
2574 my $lockdir="$prefix_abs/lockdir";
2575 push(@dirs,$lockdir);
2577 my $eventlogdir="$prefix_abs/lockdir/eventlog";
2578 push(@dirs,$eventlogdir);
2580 my $logdir="$prefix_abs/logs";
2581 push(@dirs,$logdir);
2583 my $driver32dir="$shrdir/W32X86";
2584 push(@dirs,$driver32dir);
2586 my $driver64dir="$shrdir/x64";
2587 push(@dirs,$driver64dir);
2589 my $driver40dir="$shrdir/WIN40";
2590 push(@dirs,$driver40dir);
2592 my $ro_shrdir="$shrdir/root-tmp";
2593 push(@dirs,$ro_shrdir);
2595 my $noperm_shrdir="$shrdir/noperm-tmp";
2596 push(@dirs,$noperm_shrdir);
2598 my $msdfs_shrdir="$shrdir/msdfsshare";
2599 push(@dirs,$msdfs_shrdir);
2601 my $msdfs_shrdir2="$shrdir/msdfsshare2";
2602 push(@dirs,$msdfs_shrdir2);
2604 my $msdfs_pathname_share="$shrdir/msdfs_pathname_share";
2605 push(@dirs,$msdfs_pathname_share);
2607 my $non_msdfs_pathname_share="$shrdir/non_msdfs_pathname_share";
2608 push(@dirs,$non_msdfs_pathname_share);
2610 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
2611 push(@dirs,$msdfs_deeppath);
2613 my $smbcacls_sharedir_dfs="$shrdir/smbcacls_sharedir_dfs";
2614 push(@dirs,$smbcacls_sharedir_dfs);
2616 my $smbcacls_share="$shrdir/smbcacls_share";
2617 push(@dirs,$smbcacls_share);
2619 my $smbcacls_share_testdir="$shrdir/smbcacls_share/smbcacls";
2620 push(@dirs,$smbcacls_share_testdir);
2622 my $badnames_shrdir="$shrdir/badnames";
2623 push(@dirs,$badnames_shrdir);
2625 my $lease1_shrdir="$shrdir/dynamic";
2626 push(@dirs,$lease1_shrdir);
2628 my $manglenames_shrdir="$shrdir/manglenames";
2629 push(@dirs,$manglenames_shrdir);
2631 my $widelinks_shrdir="$shrdir/widelinks";
2632 push(@dirs,$widelinks_shrdir);
2634 my $widelinks_linkdir="$shrdir/widelinks_foo";
2635 push(@dirs,$widelinks_linkdir);
2637 my $fsrvp_shrdir="$shrdir/fsrvp";
2638 push(@dirs,$fsrvp_shrdir);
2640 my $shadow_tstdir="$shrdir/shadow";
2641 push(@dirs,$shadow_tstdir);
2642 my $shadow_mntdir="$shadow_tstdir/mount";
2643 push(@dirs,$shadow_mntdir);
2644 my $shadow_basedir="$shadow_mntdir/base";
2645 push(@dirs,$shadow_basedir);
2646 my $shadow_shrdir="$shadow_basedir/share";
2647 push(@dirs,$shadow_shrdir);
2649 my $nosymlinks_shrdir="$shrdir/nosymlinks";
2650 push(@dirs,$nosymlinks_shrdir);
2652 my $local_symlinks_shrdir="$shrdir/local_symlinks";
2653 push(@dirs,$local_symlinks_shrdir);
2655 my $fruit_resource_stream_shrdir="$shrdir/fruit_resource_stream";
2656 push(@dirs,$fruit_resource_stream_shrdir);
2658 my $smbget_sharedir="$shrdir/smbget";
2659 push(@dirs, $smbget_sharedir);
2661 # this gets autocreated by winbindd
2662 my $wbsockdir="$prefix_abs/wbsock";
2664 my $nmbdsockdir="$prefix_abs/nmbd";
2665 unlink($nmbdsockdir);
2668 ## create the test directory layout
2670 die ("prefix_abs = ''") if $prefix_abs eq "";
2671 die ("prefix_abs = '/'") if $prefix_abs eq "/";
2673 mkdir($prefix_abs, 0777);
2674 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
2675 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
2676 system("rm -rf $prefix_abs/*");
2678 mkdir($_, 0777) foreach(@dirs);
2680 my $fs_specific_conf = $self->get_fs_specific_conf($shrdir);
2683 ## lockdir and piddir must be 0755
2685 chmod 0755, $lockdir;
2686 chmod 0755, $piddir;
2690 ## Create a directory without permissions to enter
2692 chmod 0000, $noperm_shrdir;
2695 ## create ro and msdfs share layout
2698 chmod 0755, $ro_shrdir;
2700 create_file_chmod("$ro_shrdir/readable_file", 0644) or return undef;
2701 create_file_chmod("$ro_shrdir/unreadable_file", 0600) or return undef;
2703 create_file_chmod("$ro_shrdir/msdfs-target", 0600) or return undef;
2704 symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp",
2705 "$msdfs_shrdir/msdfs-src1";
2706 symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
2707 symlink "msdfs:$server_ip\\smbcacls_sharedir_dfs,$server_ipv6\\smbcacls_sharedir_dfs",
2708 "$msdfs_shrdir/smbcacls_sharedir_dfs";
2710 symlink "msdfs:$server_ip\\msdfs-share2,$server_ipv6\\msdfs-share2", "$msdfs_shrdir/dfshop1";
2711 symlink "msdfs:$server_ip\\tmp,$server_ipv6\\tmp", "$msdfs_shrdir2/dfshop2";
2713 ## create bad names in $badnames_shrdir
2715 ## (An invalid name, would be mangled to 8.3).
2716 create_file_chmod("$badnames_shrdir/\340|\231\216\377\177",
2717 0600) or return undef;
2719 ## (A bad name, would not be mangled to 8.3).
2720 create_file_chmod("$badnames_shrdir/\240\276\346\327\377\177",
2721 0666) or return undef;
2723 ## (A bad good name).
2724 create_file_chmod("$badnames_shrdir/blank.txt",
2725 0666) or return undef;
2728 ## create mangleable directory names in $manglenames_shrdir
2730 my $manglename_target = "$manglenames_shrdir/foo:bar";
2731 mkdir($manglename_target, 0777);
2734 ## create symlinks for widelinks tests.
2736 my $widelinks_target = "$widelinks_linkdir/target";
2737 create_file_chmod("$widelinks_target", 0666) or return undef;
2740 ## This link should get an error
2742 symlink "$widelinks_target", "$widelinks_shrdir/source";
2744 ## This link should be allowed
2746 symlink "$widelinks_shrdir", "$widelinks_shrdir/dot";
2748 my $conffile="$libdir/server.conf";
2749 my $dfqconffile="$libdir/dfq.conf";
2750 my $errorinjectconf="$libdir/error_inject.conf";
2751 my $delayinjectconf="$libdir/delay_inject.conf";
2752 my $globalinjectconf="$libdir/global_inject.conf";
2753 my $aliceconfdir="$libdir";
2754 my $aliceconffile="$libdir/alice.conf";
2756 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/third_party/nss_wrapper/nss_wrapper.pl";
2757 my $nss_wrapper_passwd = "$privatedir/passwd";
2758 my $nss_wrapper_group = "$privatedir/group";
2759 my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts";
2760 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
2762 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
2764 my $fake_snap_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/fake_snap.pl";
2766 my @eventlog_list = ("dns server", "application");
2769 ## calculate uids and gids
2772 my ($max_uid, $max_gid);
2773 my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
2774 my ($uid_pdbtest_wkn);
2775 my ($uid_smbget);
2776 my ($uid_force_user);
2777 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
2778 my ($gid_userdup, $gid_everyone);
2779 my ($gid_force_user);
2780 my ($gid_jackthemapper);
2781 my ($gid_jacknomapper);
2782 my ($uid_user1);
2783 my ($uid_user2);
2784 my ($uid_gooduser);
2785 my ($uid_eviluser);
2786 my ($uid_slashuser);
2787 my ($uid_localbob);
2788 my ($uid_localjane);
2789 my ($uid_localjackthemapper);
2790 my ($uid_localjacknomapper);
2792 if ($unix_uid < 0xffff - 13) {
2793 $max_uid = 0xffff;
2794 } else {
2795 $max_uid = $unix_uid;
2798 $uid_root = $max_uid - 1;
2799 $uid_nobody = $max_uid - 2;
2800 $uid_pdbtest = $max_uid - 3;
2801 $uid_pdbtest2 = $max_uid - 4;
2802 $uid_userdup = $max_uid - 5;
2803 $uid_pdbtest_wkn = $max_uid - 6;
2804 $uid_force_user = $max_uid - 7;
2805 $uid_smbget = $max_uid - 8;
2806 $uid_user1 = $max_uid - 9;
2807 $uid_user2 = $max_uid - 10;
2808 $uid_gooduser = $max_uid - 11;
2809 $uid_eviluser = $max_uid - 12;
2810 $uid_slashuser = $max_uid - 13;
2811 $uid_localbob = $max_uid - 14;
2812 $uid_localjane = $max_uid - 15;
2813 $uid_localjackthemapper = $max_uid - 16;
2814 $uid_localjacknomapper = $max_uid - 17;
2816 if ($unix_gids[0] < 0xffff - 8) {
2817 $max_gid = 0xffff;
2818 } else {
2819 $max_gid = $unix_gids[0];
2822 $gid_nobody = $max_gid - 1;
2823 $gid_nogroup = $max_gid - 2;
2824 $gid_root = $max_gid - 3;
2825 $gid_domusers = $max_gid - 4;
2826 $gid_domadmins = $max_gid - 5;
2827 $gid_userdup = $max_gid - 6;
2828 $gid_everyone = $max_gid - 7;
2829 $gid_force_user = $max_gid - 8;
2830 $gid_jackthemapper = $max_gid - 9;
2831 $gid_jacknomapper = $max_gid - 10;
2834 ## create conffile
2837 unless (open(CONF, ">$conffile")) {
2838 warn("Unable to open $conffile");
2839 return undef;
2842 my $interfaces = Samba::get_interfaces_config($server);
2844 print CONF "
2845 [global]
2846 dcesrv:fuzz directory = $cachedir/fuzz
2847 netbios name = $netbios_name
2848 interfaces = $interfaces
2849 bind interfaces only = yes
2850 panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
2851 smbd:suicide mode = yes
2852 smbd:FSCTL_SMBTORTURE = yes
2853 smbd:validate_oplock_types = yes
2855 client min protocol = SMB2_02
2856 server min protocol = SMB2_02
2858 server multi channel support = yes
2860 workgroup = $domain
2862 private dir = $privatedir
2863 binddns dir = $binddnsdir
2864 pid directory = $piddir
2865 lock directory = $lockdir
2866 log file = $logdir/log.\%m
2867 log level = $server_log_level
2868 winbind debug traceid = yes
2869 debug pid = yes
2870 max log size = 0
2872 debug syslog format = always
2873 debug hires timestamp = yes
2875 state directory = $lockdir
2876 cache directory = $lockdir
2878 passdb backend = tdbsam
2880 time server = yes
2882 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
2883 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
2884 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
2885 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
2886 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
2887 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
2888 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
2890 addprinter command = $mod_printer_pl -a -s $conffile --
2891 deleteprinter command = $mod_printer_pl -d -s $conffile --
2893 eventlog list = application \"dns server\"
2895 kernel oplocks = no
2896 kernel change notify = no
2898 logging = file
2899 printing = bsd
2900 printcap name = /dev/null
2902 winbindd socket directory = $wbsockdir
2903 nmbd:socket dir = $nmbdsockdir
2904 idmap config * : range = 100000-200000
2905 winbind enum users = yes
2906 winbind enum groups = yes
2907 winbind separator = /
2908 include system krb5 conf = no
2910 # min receivefile size = 4000
2912 read only = no
2914 smbd:sharedelay = 100000
2915 smbd:writetimeupdatedelay = 500000
2916 map hidden = no
2917 map system = no
2918 map readonly = no
2919 store dos attributes = yes
2920 create mask = 755
2921 dos filemode = yes
2922 strict rename = yes
2923 strict sync = yes
2924 mangled names = yes
2925 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot time_audit full_audit
2927 full_audit:syslog = no
2928 full_audit:success = none
2929 full_audit:failure = none
2931 printing = vlp
2932 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
2933 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
2934 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
2935 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
2936 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
2937 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
2938 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
2939 lpq cache time = 0
2940 print notify backchannel = yes
2942 ncalrpc dir = $prefix_abs/ncalrpc
2944 # The samba3.blackbox.smbclient_s3 test uses this to test that
2945 # sending messages works, and that the %m sub works.
2946 message command = mv %s $shrdir/message.%m
2948 # fsrvp server requires registry shares
2949 registry shares = yes
2951 # Used by RPC SRVSVC tests
2952 add share command = $bindir_abs/smbaddshare
2953 change share command = $bindir_abs/smbchangeshare
2954 delete share command = $bindir_abs/smbdeleteshare
2956 # fruit:copyfile is a global option
2957 fruit:copyfile = yes
2959 #this does not mean that we use non-secure test env,
2960 #it just means we ALLOW one to be configured.
2961 allow insecure wide links = yes
2963 include = $globalinjectconf
2965 # Begin extra options
2966 $extra_options
2967 # End extra options
2969 #Include user defined custom parameters if set
2972 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
2973 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
2976 print CONF "
2977 [smbcacls_share]
2978 path = $smbcacls_share
2979 comment = smb username is [%U]
2980 msdfs root = yes
2982 [smbcacls_sharedir_dfs]
2983 path = $smbcacls_sharedir_dfs
2984 comment = smb username is [%U]
2985 [tmp]
2986 path = $shrdir
2987 comment = smb username is [%U]
2988 [tmpsort]
2989 path = $shrdir
2990 comment = Load dirsort module
2991 vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot
2992 [tmpenc]
2993 path = $shrdir
2994 comment = encrypt smb username is [%U]
2995 server smb encrypt = required
2996 vfs objects = dirsort
2997 [tmpguest]
2998 path = $shrdir
2999 guest ok = yes
3000 [guestonly]
3001 path = $shrdir
3002 guest only = yes
3003 guest ok = yes
3004 [forceuser]
3005 path = $shrdir
3006 force user = $unix_name
3007 guest ok = yes
3008 [forceuser_unixonly]
3009 comment = force a user with unix user SID and group SID
3010 path = $shrdir
3011 force user = pdbtest
3012 guest ok = yes
3013 [forceuser_wkngroup]
3014 comment = force a user with well-known group SID
3015 path = $shrdir
3016 force user = pdbtest_wkn
3017 guest ok = yes
3018 [forcegroup]
3019 path = $shrdir
3020 force group = nogroup
3021 guest ok = yes
3022 [ro-tmp]
3023 path = $ro_shrdir
3024 guest ok = yes
3025 [noperm]
3026 path = $noperm_shrdir
3027 wide links = yes
3028 guest ok = yes
3029 [write-list-tmp]
3030 path = $shrdir
3031 read only = yes
3032 write list = $unix_name
3033 [valid-users-tmp]
3034 path = $shrdir
3035 valid users = $unix_name
3036 access based share enum = yes
3037 [msdfs-share]
3038 path = $msdfs_shrdir
3039 msdfs root = yes
3040 msdfs shuffle referrals = yes
3041 guest ok = yes
3042 [msdfs-share-wl]
3043 path = $msdfs_shrdir
3044 msdfs root = yes
3045 wide links = yes
3046 guest ok = yes
3047 [msdfs-share2]
3048 path = $msdfs_shrdir2
3049 msdfs root = yes
3050 guest ok = yes
3051 [msdfs-pathname-share]
3052 path = $msdfs_pathname_share
3053 msdfs root = yes
3054 guest ok = yes
3055 [non-msdfs-pathname-share]
3056 path = $non_msdfs_pathname_share
3057 msdfs root = no
3058 guest ok = yes
3059 [hideunread]
3060 copy = tmp
3061 hide unreadable = yes
3062 [tmpcase]
3063 copy = tmp
3064 case sensitive = yes
3065 [hideunwrite]
3066 copy = tmp
3067 hide unwriteable files = yes
3068 [durable]
3069 copy = tmp
3070 kernel share modes = no
3071 kernel oplocks = no
3072 posix locking = no
3073 [fs_specific]
3074 copy = tmp
3075 $fs_specific_conf
3076 [print1]
3077 copy = tmp
3078 printable = yes
3080 [print2]
3081 copy = print1
3082 [print3]
3083 copy = print1
3084 default devmode = no
3086 [print_var_exp]
3087 copy = print1
3088 print command = $self->{srcdir}/source3/script/tests/printing/printing_var_exp_lpr_cmd.sh \"Windows user: %U\" \"UNIX user: %u\" \"Domain: %D\"
3090 [lp]
3091 copy = print1
3093 [nfs4acl_simple_40]
3094 path = $shrdir
3095 comment = smb username is [%U]
3096 nfs4:mode = simple
3097 nfs4acl_xattr:version = 40
3098 vfs objects = nfs4acl_xattr xattr_tdb
3100 [nfs4acl_special_40]
3101 path = $shrdir
3102 comment = smb username is [%U]
3103 nfs4:mode = special
3104 nfs4acl_xattr:version = 40
3105 vfs objects = nfs4acl_xattr xattr_tdb
3107 [nfs4acl_simple_41]
3108 path = $shrdir
3109 comment = smb username is [%U]
3110 nfs4:mode = simple
3111 vfs objects = nfs4acl_xattr xattr_tdb
3113 [nfs4acl_xdr_40]
3114 path = $shrdir
3115 comment = smb username is [%U]
3116 vfs objects = nfs4acl_xattr xattr_tdb
3117 nfs4:mode = simple
3118 nfs4acl_xattr:encoding = xdr
3119 nfs4acl_xattr:version = 40
3121 [nfs4acl_xdr_41]
3122 path = $shrdir
3123 comment = smb username is [%U]
3124 vfs objects = nfs4acl_xattr xattr_tdb
3125 nfs4:mode = simple
3126 nfs4acl_xattr:encoding = xdr
3127 nfs4acl_xattr:version = 41
3129 [nfs4acl_nfs_40]
3130 path = $shrdir
3131 comment = smb username is [%U]
3132 vfs objects = nfs4acl_xattr xattr_tdb
3133 nfs4:mode = simple
3134 nfs4acl_xattr:encoding = nfs
3135 nfs4acl_xattr:version = 40
3136 nfs4acl_xattr:xattr_name = security.nfs4acl_xdr
3138 [nfs4acl_nfs_41]
3139 path = $shrdir
3140 comment = smb username is [%U]
3141 vfs objects = nfs4acl_xattr xattr_tdb
3142 nfs4:mode = simple
3143 nfs4acl_xattr:encoding = nfs
3144 nfs4acl_xattr:version = 41
3145 nfs4acl_xattr:xattr_name = security.nfs4acl_xdr
3147 [xcopy_share]
3148 path = $shrdir
3149 comment = smb username is [%U]
3150 create mask = 777
3151 force create mode = 777
3152 [posix_share]
3153 path = $shrdir
3154 comment = smb username is [%U]
3155 create mask = 0777
3156 force create mode = 0
3157 directory mask = 0777
3158 force directory mode = 0
3159 vfs objects = xattr_tdb streams_depot
3160 [smb3_posix_share]
3161 vfs objects = fake_acls xattr_tdb streams_depot time_audit full_audit
3162 create mask = 07777
3163 directory mask = 07777
3164 mangled names = no
3165 path = $shrdir
3166 read only = no
3167 guest ok = yes
3168 [aio]
3169 copy = durable
3170 aio read size = 1
3171 aio write size = 1
3173 [print\$]
3174 copy = tmp
3176 [vfs_fruit]
3177 path = $shrdir
3178 vfs objects = catia fruit streams_xattr acl_xattr xattr_tdb
3179 fruit:resource = file
3180 fruit:metadata = netatalk
3181 fruit:locking = netatalk
3182 fruit:encoding = native
3183 fruit:veto_appledouble = no
3185 [vfs_fruit_xattr]
3186 path = $shrdir
3187 # This is used by vfs.fruit tests that require real fs xattr
3188 vfs objects = catia fruit streams_xattr acl_xattr
3189 fruit:resource = file
3190 fruit:metadata = netatalk
3191 fruit:locking = netatalk
3192 fruit:encoding = native
3193 fruit:veto_appledouble = no
3195 [vfs_fruit_metadata_stream]
3196 path = $shrdir
3197 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3198 fruit:resource = file
3199 fruit:metadata = stream
3200 fruit:veto_appledouble = no
3202 [vfs_fruit_stream_depot]
3203 path = $shrdir
3204 vfs objects = fruit streams_depot acl_xattr xattr_tdb
3205 fruit:resource = stream
3206 fruit:metadata = stream
3207 fruit:veto_appledouble = no
3209 [vfs_wo_fruit]
3210 path = $shrdir
3211 vfs objects = streams_xattr acl_xattr xattr_tdb
3213 [vfs_wo_fruit_stream_depot]
3214 path = $shrdir
3215 vfs objects = streams_depot acl_xattr xattr_tdb
3217 [vfs_fruit_timemachine]
3218 path = $shrdir
3219 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3220 fruit:resource = file
3221 fruit:metadata = stream
3222 fruit:time machine = yes
3223 fruit:time machine max size = 32K
3225 [vfs_fruit_wipe_intentionally_left_blank_rfork]
3226 path = $shrdir
3227 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3228 fruit:resource = file
3229 fruit:metadata = stream
3230 fruit:wipe_intentionally_left_blank_rfork = true
3231 fruit:delete_empty_adfiles = false
3232 fruit:veto_appledouble = no
3234 [vfs_fruit_delete_empty_adfiles]
3235 path = $shrdir
3236 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3237 fruit:resource = file
3238 fruit:metadata = stream
3239 fruit:wipe_intentionally_left_blank_rfork = true
3240 fruit:delete_empty_adfiles = true
3241 fruit:veto_appledouble = no
3243 [vfs_fruit_zero_fileid]
3244 path = $shrdir
3245 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3246 fruit:resource = file
3247 fruit:metadata = stream
3248 fruit:zero_file_id=yes
3249 fruit:validate_afpinfo = no
3251 [fruit_resource_stream]
3252 path = $fruit_resource_stream_shrdir
3253 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
3254 fruit:resource = stream
3255 fruit:metadata = stream
3257 [badname-tmp]
3258 path = $badnames_shrdir
3259 guest ok = yes
3261 [manglenames_share]
3262 path = $manglenames_shrdir
3263 guest ok = yes
3265 [dynamic_share]
3266 path = $shrdir/dynamic/%t
3267 guest ok = yes
3268 root preexec = mkdir %P
3270 [widelinks_share]
3271 path = $widelinks_shrdir
3272 wide links = no
3273 guest ok = yes
3275 [fsrvp_share]
3276 path = $fsrvp_shrdir
3277 comment = fake snapshots using rsync
3278 vfs objects = shell_snap shadow_copy2
3279 shell_snap:check path command = $fake_snap_pl --check
3280 shell_snap:create command = $fake_snap_pl --create
3281 shell_snap:delete command = $fake_snap_pl --delete
3282 # a relative path here fails, the snapshot dir is no longer found
3283 shadow:snapdir = $fsrvp_shrdir/.snapshots
3285 [shadow1]
3286 path = $shadow_shrdir
3287 comment = previous versions snapshots under mount point
3288 vfs objects = shadow_copy2
3289 shadow:mountpoint = $shadow_mntdir
3291 [shadow2]
3292 path = $shadow_shrdir
3293 comment = previous versions snapshots outside mount point
3294 vfs objects = shadow_copy2
3295 shadow:mountpoint = $shadow_mntdir
3296 shadow:snapdir = $shadow_tstdir/.snapshots
3298 [shadow3]
3299 path = $shadow_shrdir
3300 comment = previous versions with subvolume snapshots, snapshots under base dir
3301 vfs objects = shadow_copy2
3302 shadow:mountpoint = $shadow_mntdir
3303 shadow:basedir = $shadow_basedir
3304 shadow:snapdir = $shadow_basedir/.snapshots
3306 [shadow4]
3307 path = $shadow_shrdir
3308 comment = previous versions with subvolume snapshots, snapshots outside mount point
3309 vfs objects = shadow_copy2
3310 shadow:mountpoint = $shadow_mntdir
3311 shadow:basedir = $shadow_basedir
3312 shadow:snapdir = $shadow_tstdir/.snapshots
3314 [shadow5]
3315 path = $shadow_shrdir
3316 comment = previous versions at volume root snapshots under mount point
3317 vfs objects = shadow_copy2
3318 shadow:mountpoint = $shadow_shrdir
3320 [shadow6]
3321 path = $shadow_shrdir
3322 comment = previous versions at volume root snapshots outside mount point
3323 vfs objects = shadow_copy2
3324 shadow:mountpoint = $shadow_shrdir
3325 shadow:snapdir = $shadow_tstdir/.snapshots
3327 [shadow7]
3328 path = $shadow_shrdir
3329 comment = previous versions snapshots everywhere
3330 vfs objects = shadow_copy2
3331 shadow:mountpoint = $shadow_mntdir
3332 shadow:snapdirseverywhere = yes
3334 [shadow8]
3335 path = $shadow_shrdir
3336 comment = previous versions using snapsharepath
3337 vfs objects = shadow_copy2
3338 shadow:mountpoint = $shadow_mntdir
3339 shadow:snapdir = $shadow_tstdir/.snapshots
3340 shadow:snapsharepath = share
3342 [shadow_fmt0]
3343 comment = Testing shadow:format with default option
3344 vfs object = shadow_copy2
3345 path = $shadow_shrdir
3346 read only = no
3347 guest ok = yes
3348 shadow:mountpoint = $shadow_mntdir
3349 shadow:basedir = $shadow_basedir
3350 shadow:snapdir = $shadow_basedir/.snapshots
3351 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
3353 [shadow_fmt1]
3354 comment = Testing shadow:format with only date component
3355 vfs object = shadow_copy2
3356 path = $shadow_shrdir
3357 read only = no
3358 guest ok = yes
3359 shadow:mountpoint = $shadow_mntdir
3360 shadow:basedir = $shadow_basedir
3361 shadow:snapdir = $shadow_basedir/.snapshots
3362 shadow:format = \@GMT-%Y-%m-%d
3364 [shadow_fmt2]
3365 comment = Testing shadow:format with some hardcoded prefix
3366 vfs object = shadow_copy2
3367 path = $shadow_shrdir
3368 read only = no
3369 guest ok = yes
3370 shadow:mountpoint = $shadow_mntdir
3371 shadow:basedir = $shadow_basedir
3372 shadow:snapdir = $shadow_basedir/.snapshots
3373 shadow:format = snap\@GMT-%Y.%m.%d-%H.%M.%S
3375 [shadow_fmt3]
3376 comment = Testing shadow:format with modified format
3377 vfs object = shadow_copy2
3378 path = $shadow_shrdir
3379 read only = no
3380 guest ok = yes
3381 shadow:mountpoint = $shadow_mntdir
3382 shadow:basedir = $shadow_basedir
3383 shadow:snapdir = $shadow_basedir/.snapshots
3384 shadow:format = \@GMT-%Y.%m.%d-%H_%M_%S-snap
3386 [shadow_fmt4]
3387 comment = Testing shadow:snapprefix regex
3388 vfs object = shadow_copy2
3389 path = $shadow_shrdir
3390 read only = no
3391 guest ok = yes
3392 shadow:mountpoint = $shadow_mntdir
3393 shadow:basedir = $shadow_basedir
3394 shadow:snapdir = $shadow_basedir/.snapshots
3395 shadow:snapprefix = \^s[a-z]*p\$
3396 shadow:format = _GMT-%Y.%m.%d-%H.%M.%S
3398 [shadow_fmt5]
3399 comment = Testing shadow:snapprefix with delim regex
3400 vfs object = shadow_copy2
3401 path = $shadow_shrdir
3402 read only = no
3403 guest ok = yes
3404 shadow:mountpoint = $shadow_mntdir
3405 shadow:basedir = $shadow_basedir
3406 shadow:snapdir = $shadow_basedir/.snapshots
3407 shadow:delimiter = \@GMT
3408 shadow:snapprefix = [a-z]*
3409 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
3411 [shadow_wl]
3412 path = $shadow_shrdir
3413 comment = previous versions with wide links allowed
3414 vfs objects = shadow_copy2
3415 shadow:mountpoint = $shadow_mntdir
3416 wide links = yes
3418 [shadow_write]
3419 path = $shadow_tstdir
3420 comment = previous versions snapshots under mount point
3421 vfs objects = shadow_copy2 streams_xattr error_inject
3422 aio write size = 0
3423 error_inject:pwrite = EBADF
3424 shadow:mountpoint = $shadow_tstdir
3425 shadow:fixinodes = yes
3426 smbd async dosmode = yes
3428 [shadow_depot]
3429 path = $shadow_shrdir
3430 comment = previous versions with streams_depot
3431 vfs objects = streams_depot shadow_copy2
3433 [dfq]
3434 path = $shrdir/dfree
3435 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
3436 admin users = $unix_name
3437 include = $dfqconffile
3438 [dfq_cache]
3439 path = $shrdir/dfree
3440 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
3441 admin users = $unix_name
3442 include = $dfqconffile
3443 dfree cache time = 60
3444 [dfq_owner]
3445 path = $shrdir/dfree
3446 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
3447 inherit owner = yes
3448 include = $dfqconffile
3449 [quotadir]
3450 path = $shrdir/quota
3451 admin users = $unix_name
3453 [acl_xattr_ign_sysacl_posix]
3454 copy = tmp
3455 acl_xattr:ignore system acls = yes
3456 acl_xattr:default acl style = posix
3457 [acl_xattr_ign_sysacl_windows]
3458 copy = tmp
3459 acl_xattr:ignore system acls = yes
3460 acl_xattr:default acl style = windows
3462 [mangle_illegal]
3463 copy = tmp
3464 mangled names = illegal
3466 [nosymlinks]
3467 copy = tmp
3468 path = $nosymlinks_shrdir
3469 follow symlinks = no
3470 [nosymlinks_smb1allow]
3471 copy=nosymlinks
3472 follow symlinks = yes
3474 [local_symlinks]
3475 copy = tmp
3476 path = $local_symlinks_shrdir
3477 follow symlinks = yes
3479 [kernel_oplocks]
3480 copy = tmp
3481 kernel oplocks = yes
3482 vfs objects = streams_xattr xattr_tdb
3484 [streams_xattr]
3485 copy = tmp
3486 vfs objects = streams_xattr xattr_tdb
3488 [streams_xattr_nostrict]
3489 copy = tmp
3490 strict rename = no
3491 vfs objects = streams_xattr xattr_tdb
3493 [acl_streams_xattr]
3494 copy = tmp
3495 vfs objects = acl_xattr streams_xattr fake_acls xattr_tdb
3496 acl_xattr:ignore system acls = yes
3497 acl_xattr:security_acl_name = user.acl
3498 xattr_tdb:ignore_user_xattr = yes
3500 [compound_find]
3501 copy = tmp
3502 smbd:find async delay usec = 10000
3503 [error_inject]
3504 copy = tmp
3505 vfs objects = error_inject
3506 include = $errorinjectconf
3508 [delay_inject]
3509 copy = tmp
3510 vfs objects = delay_inject
3511 kernel share modes = no
3512 kernel oplocks = no
3513 posix locking = no
3514 include = $delayinjectconf
3516 [aio_delay_inject]
3517 copy = tmp
3518 vfs objects = delay_inject
3519 delay_inject:pread_send = 2000
3520 delay_inject:pwrite_send = 2000
3522 [brl_delay_inject1]
3523 copy = tmp
3524 vfs objects = delay_inject
3525 delay_inject:brl_lock_windows = 90
3526 delay_inject:brl_lock_windows_use_timer = yes
3528 [brl_delay_inject2]
3529 copy = tmp
3530 vfs objects = delay_inject
3531 delay_inject:brl_lock_windows = 90
3532 delay_inject:brl_lock_windows_use_timer = no
3534 [delete_readonly]
3535 path = $prefix_abs/share
3536 delete readonly = yes
3538 [enc_desired]
3539 path = $prefix_abs/share
3540 vfs objects =
3541 server smb encrypt = desired
3543 [enc_off]
3544 path = $prefix_abs/share
3545 vfs objects =
3546 server smb encrypt = off
3548 [notify_priv]
3549 copy = tmp
3550 honor change notify privilege = yes
3552 [acls_non_canonical]
3553 copy = tmp
3554 acl flag inherited canonicalization = no
3556 [full_audit_success_bad_name]
3557 copy = tmp
3558 full_audit:success = badname
3560 [full_audit_fail_bad_name]
3561 copy = tmp
3562 full_audit:failure = badname
3564 [only_ipv6]
3565 copy = tmpguest
3566 server addresses = $server_ipv6
3568 [smbget]
3569 path = $smbget_sharedir
3570 comment = smb username is [%U]
3571 guest ok = yes
3573 include = $aliceconfdir/%U.conf
3576 close(CONF);
3578 my $net = Samba::bindir_path($self, "net");
3579 my $cmd = "";
3580 $cmd .= "UID_WRAPPER_ROOT=1 ";
3581 $cmd .= "SMB_CONF_PATH=\"$conffile\" ";
3582 $cmd .= "$net setlocalsid $samsid";
3584 my $net_ret = system($cmd);
3585 if ($net_ret != 0) {
3586 warn("net setlocalsid failed: $net_ret\n$cmd");
3587 return undef;
3590 unless (open(ERRORCONF, ">$errorinjectconf")) {
3591 warn("Unable to open $errorinjectconf");
3592 return undef;
3594 close(ERRORCONF);
3596 unless (open(DELAYCONF, ">$delayinjectconf")) {
3597 warn("Unable to open $delayinjectconf");
3598 return undef;
3600 close(DELAYCONF);
3602 unless (open(DFQCONF, ">$dfqconffile")) {
3603 warn("Unable to open $dfqconffile");
3604 return undef;
3606 close(DFQCONF);
3608 unless (open(DELAYCONF, ">$globalinjectconf")) {
3609 warn("Unable to open $globalinjectconf");
3610 return undef;
3612 close(DELAYCONF);
3614 unless (open(ALICECONF, ">$aliceconffile")) {
3615 warn("Unable to open $aliceconffile");
3616 return undef;
3619 print ALICECONF "
3620 [alice_share]
3621 path = $shrdir
3622 comment = smb username is [%U]
3625 close(ALICECONF);
3628 ## create a test account
3631 unless (open(PASSWD, ">$nss_wrapper_passwd")) {
3632 warn("Unable to open $nss_wrapper_passwd");
3633 return undef;
3635 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
3636 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
3637 pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
3638 pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
3639 userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
3640 pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false
3641 force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false
3642 smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false
3643 user1:x:$uid_user1:$gid_nogroup:user1 gecos:$prefix_abs:/bin/false
3644 user2:x:$uid_user2:$gid_nogroup:user2 gecos:$prefix_abs:/bin/false
3645 gooduser:x:$uid_gooduser:$gid_domusers:gooduser gecos:$prefix_abs:/bin/false
3646 eviluser:x:$uid_eviluser:$gid_domusers:eviluser gecos::/bin/false
3647 slashuser:x:$uid_slashuser:$gid_domusers:slashuser gecos:/:/bin/false
3648 bob:x:$uid_localbob:$gid_domusers:localbob gecos:/:/bin/false
3649 jane:x:$uid_localjane:$gid_domusers:localjane gecos:/:/bin/false
3650 jackthemapper:x:$uid_localjackthemapper:$gid_domusers:localjackthemaper gecos:/:/bin/false
3651 jacknomapper:x:$uid_localjacknomapper:$gid_domusers:localjacknomaper gecos:/:/bin/false
3653 if ($unix_uid != 0) {
3654 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
3657 close(PASSWD);
3659 unless (open(GROUP, ">$nss_wrapper_group")) {
3660 warn("Unable to open $nss_wrapper_group");
3661 return undef;
3663 print GROUP "nobody:x:$gid_nobody:
3664 nogroup:x:$gid_nogroup:nobody
3665 $unix_name-group:x:$unix_gids[0]:
3666 domusers:X:$gid_domusers:
3667 domadmins:X:$gid_domadmins:
3668 userdup:x:$gid_userdup:$unix_name
3669 everyone:x:$gid_everyone:
3670 force_user:x:$gid_force_user:
3671 jackthemappergroup:x:$gid_jackthemapper:jackthemapper
3672 jacknomappergroup:x:$gid_jacknomapper:jacknomapper
3674 if ($unix_gids[0] != 0) {
3675 print GROUP "root:x:$gid_root:
3679 close(GROUP);
3681 ## hosts
3682 my $hostname = lc($server);
3683 unless (open(HOSTS, ">>$nss_wrapper_hosts")) {
3684 warn("Unable to open $nss_wrapper_hosts");
3685 return undef;
3687 print HOSTS "${server_ip} ${hostname}.${dns_domain} ${hostname}\n";
3688 print HOSTS "${server_ipv6} ${hostname}.${dns_domain} ${hostname}\n";
3689 close(HOSTS);
3691 $resolv_conf = "$privatedir/no_resolv.conf" unless defined($resolv_conf);
3693 foreach my $evlog (@eventlog_list) {
3694 my $evlogtdb = "$eventlogdir/$evlog.tdb";
3695 open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
3696 close(EVENTLOG);
3699 $createuser_env{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
3700 $createuser_env{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
3701 $createuser_env{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
3702 $createuser_env{NSS_WRAPPER_HOSTNAME} = "${hostname}.${dns_domain}";
3703 if ($ENV{SAMBA_DNS_FAKING}) {
3704 $createuser_env{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
3705 } else {
3706 $createuser_env{RESOLV_WRAPPER_CONF} = $resolv_conf;
3708 $createuser_env{RESOLV_CONF} = $resolv_conf;
3710 createuser($self, $unix_name, $password, $conffile, \%createuser_env) || die("Unable to create user");
3711 createuser($self, "force_user", $password, $conffile, \%createuser_env) || die("Unable to create force_user");
3712 createuser($self, "smbget_user", $password, $conffile, \%createuser_env) || die("Unable to create smbget_user");
3713 createuser($self, "user1", $password, $conffile, \%createuser_env) || die("Unable to create user1");
3714 createuser($self, "user2", $password, $conffile, \%createuser_env) || die("Unable to create user2");
3715 createuser($self, "gooduser", $password, $conffile, \%createuser_env) || die("Unable to create gooduser");
3716 createuser($self, "eviluser", $password, $conffile, \%createuser_env) || die("Unable to create eviluser");
3717 createuser($self, "slashuser", $password, $conffile, \%createuser_env) || die("Unable to create slashuser");
3718 createuser($self, "jackthemapper", "mApsEcrEt", $conffile, \%createuser_env) || die("Unable to create jackthemapper");
3719 createuser($self, "jacknomapper", "nOmApsEcrEt", $conffile, \%createuser_env) || die("Unable to create jacknomapper");
3721 open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
3722 print DNS_UPDATE_LIST "A $server. $server_ip\n";
3723 print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n";
3724 close(DNS_UPDATE_LIST);
3726 print "DONE\n";
3728 $ret{SERVER_IP} = $server_ip;
3729 $ret{SERVER_IPV6} = $server_ipv6;
3730 $ret{SAMBA_DCERPCD_TEST_LOG} = "$prefix/samba_dcerpcd_test.log";
3731 $ret{SAMBA_DCERPCD_LOG_POS} = 0;
3732 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
3733 $ret{NMBD_TEST_LOG_POS} = 0;
3734 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
3735 $ret{WINBINDD_TEST_LOG_POS} = 0;
3736 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
3737 $ret{SMBD_TEST_LOG_POS} = 0;
3738 $ret{SERVERCONFFILE} = $conffile;
3739 $ret{TESTENV_DIR} = $prefix_abs;
3740 $ret{CONFIGURATION} ="--configfile=$conffile";
3741 $ret{LOCK_DIR} = $lockdir;
3742 $ret{SERVER} = $server;
3743 $ret{USERNAME} = $unix_name;
3744 $ret{USERID} = $unix_uid;
3745 $ret{DOMAIN} = $domain;
3746 $ret{SAMSID} = $samsid;
3747 $ret{NETBIOSNAME} = $server;
3748 $ret{PASSWORD} = $password;
3749 $ret{PIDDIR} = $piddir;
3750 $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir;
3751 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
3752 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
3753 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
3754 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
3755 $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
3756 $ret{NSS_WRAPPER_HOSTNAME} = "${hostname}.${dns_domain}";
3757 $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
3758 $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind";
3759 if ($ENV{SAMBA_DNS_FAKING}) {
3760 $ret{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
3761 } else {
3762 $ret{RESOLV_WRAPPER_CONF} = $resolv_conf;
3764 $ret{RESOLV_CONF} = $resolv_conf;
3765 $ret{LOCAL_PATH} = "$shrdir";
3766 $ret{LOGDIR} = $logdir;
3769 # Avoid hitting system krb5.conf -
3770 # An env that needs Kerberos will reset this to the real
3771 # value.
3773 $ret{KRB5_CONFIG} = abs_path($prefix) . "/no_krb5.conf";
3775 # Define KRB5CCNAME for each environment we set up
3776 $ret{KRB5_CCACHE} = abs_path($prefix) . "/krb5ccache";
3777 $ENV{KRB5CCNAME} = $ret{KRB5_CCACHE};
3779 return \%ret;
3782 sub wait_for_start($$$$$)
3784 my ($self, $envvars, $nmbd, $winbindd, $smbd, $samba_dcerpcd) = @_;
3785 my $cmd;
3786 my $netcmd;
3787 my $ret;
3789 if ($samba_dcerpcd eq "yes") {
3790 my $count = 0;
3791 my $rpcclient = Samba::bindir_path($self, "rpcclient");
3793 print "checking for samba_dcerpcd\n";
3795 do {
3796 $ret = system("$rpcclient $envvars->{CONFIGURATION} ncalrpc: -c epmmap");
3798 if ($ret != 0) {
3799 sleep(1);
3801 $count++
3802 } while ($ret != 0 && $count < 10);
3804 if ($count == 10) {
3805 print "samba_dcerpcd not reachable after 10 retries\n";
3806 teardown_env($self, $envvars);
3807 return 0;
3811 if ($nmbd eq "yes") {
3812 my $count = 0;
3814 # give time for nbt server to register its names
3815 print "checking for nmbd\n";
3817 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
3818 my $nmblookup = Samba::bindir_path($self, "nmblookup");
3820 do {
3821 $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
3822 if ($ret != 0) {
3823 sleep(1);
3824 } else {
3825 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
3826 system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
3827 system("$nmblookup $envvars->{CONFIGURATION} -U 10.255.255.255 __SAMBA__");
3828 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
3830 $count++;
3831 } while ($ret != 0 && $count < 10);
3832 if ($count == 10) {
3833 print "NMBD not reachable after 10 retries\n";
3834 teardown_env($self, $envvars);
3835 return 0;
3839 if ($winbindd eq "yes" or $winbindd eq "offline") {
3840 print "checking for winbindd\n";
3841 my $count = 0;
3842 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
3843 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3844 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3845 if ($winbindd eq "yes") {
3846 $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping-dc";
3847 } elsif ($winbindd eq "offline") {
3848 $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping";
3851 do {
3852 $ret = system($cmd);
3853 if ($ret != 0) {
3854 sleep(1);
3856 $count++;
3857 } while ($ret != 0 && $count < 20);
3858 if ($count == 20) {
3859 print "WINBINDD not reachable after 20 seconds\n";
3860 teardown_env($self, $envvars);
3861 return 0;
3865 if ($smbd eq "yes") {
3866 # make sure smbd is also up set
3867 print "wait for smbd\n";
3869 my $count = 0;
3870 do {
3871 if (defined($envvars->{GNUTLS_FORCE_FIPS_MODE})) {
3872 # We don't have NTLM in FIPS mode, so lets use
3873 # smbcontrol instead of smbclient.
3874 $cmd = Samba::bindir_path($self, "smbcontrol");
3875 $cmd .= " $envvars->{CONFIGURATION}";
3876 $cmd .= " smbd ping";
3877 } else {
3878 # This uses NTLM which is not available in FIPS
3879 $cmd = Samba::bindir_path($self, "smbclient");
3880 $cmd .= " $envvars->{CONFIGURATION}";
3881 $cmd .= " -L $envvars->{SERVER}";
3882 $cmd .= " -U%";
3883 $cmd .= " -I $envvars->{SERVER_IP}";
3884 $cmd .= " -p 139";
3887 $ret = system($cmd);
3888 if ($ret != 0) {
3889 sleep(1);
3891 $count++
3892 } while ($ret != 0 && $count < 20);
3893 if ($count == 20) {
3894 print "SMBD failed to start up in a reasonable time (20sec)\n";
3895 teardown_env($self, $envvars);
3896 return 0;
3900 # Ensure we have domain users mapped.
3901 $netcmd = "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3902 $netcmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3903 $netcmd .= "UID_WRAPPER_ROOT='1' ";
3904 $netcmd .= Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} ";
3906 $cmd = $netcmd . "groupmap delete ntgroup=domusers";
3907 $ret = system($cmd);
3909 $cmd = $netcmd . "groupmap add rid=513 unixgroup=domusers type=domain";
3910 $ret = system($cmd);
3911 if ($ret != 0) {
3912 print("\"$cmd\" failed\n");
3913 return 1;
3916 $cmd = $netcmd . "groupmap delete ntgroup=domadmins";
3917 $ret = system($cmd);
3919 $cmd = $netcmd . "groupmap add rid=512 unixgroup=domadmins type=domain";
3920 $ret = system($cmd);
3921 if ($ret != 0) {
3922 print("\"$cmd\" failed\n");
3923 return 1;
3926 $cmd = $netcmd . "groupmap delete ntgroup=everyone";
3927 $ret = system($cmd);
3929 $cmd = $netcmd . "groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin";
3930 $ret = system($cmd);
3931 if ($ret != 0) {
3932 print("\"$cmd\" failed\n");
3933 return 1;
3936 # note: creating builtin groups requires winbindd for the
3937 # unix id allocator
3938 my $create_builtin_users = "no";
3939 if ($winbindd eq "yes") {
3940 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
3941 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3942 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3943 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
3944 my $wbinfo_out = qx($cmd 2>&1);
3945 if ($? != 0) {
3946 # wbinfo doesn't give us a better error code then
3947 # WBC_ERR_DOMAIN_NOT_FOUND, but at least that's
3948 # different then WBC_ERR_WINBIND_NOT_AVAILABLE
3949 if ($wbinfo_out !~ /WBC_ERR_DOMAIN_NOT_FOUND/) {
3950 print("Failed to run \"wbinfo --sid-to-gid=S-1-5-32-545\": $wbinfo_out");
3951 teardown_env($self, $envvars);
3952 return 0;
3954 $create_builtin_users = "yes";
3957 if ($create_builtin_users eq "yes") {
3958 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
3959 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3960 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3961 $cmd .= Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
3962 $cmd .= "sam createbuiltingroup Users";
3963 $ret = system($cmd);
3964 if ($ret != 0) {
3965 print "Failed to create BUILTIN\\Users group\n";
3966 teardown_env($self, $envvars);
3967 return 0;
3970 $cmd = Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
3971 $cmd .= "cache del IDMAP/SID2XID/S-1-5-32-545";
3972 system($cmd);
3974 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
3975 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
3976 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
3977 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
3978 $ret = system($cmd);
3979 if ($ret != 0) {
3980 print "Missing \"BUILTIN\\Users\", did net sam createbuiltingroup Users fail?\n";
3981 teardown_env($self, $envvars);
3982 return 0;
3986 print $self->getlog_env($envvars);
3988 return 1;
3992 ## provision and start of ctdb
3994 sub setup_ctdb($$)
3996 my ($self, $prefix) = @_;
3997 my $num_nodes = 3;
3999 my $data = $self->provision_ctdb($prefix, $num_nodes);
4000 $data or return undef;
4002 my $rc = $self->check_or_start_ctdb($data);
4003 if (not $rc) {
4004 print("check_or_start_ctdb() failed\n");
4005 return undef;
4008 $rc = $self->wait_for_start_ctdb($data);
4009 if (not $rc) {
4010 print "Cluster startup failed\n";
4011 return undef;
4014 return $data;
4017 sub provision_ctdb($$$$)
4019 my ($self, $prefix, $num_nodes, $no_delete_prefix) = @_;
4020 my $rc;
4022 print "PROVISIONING CTDB...\n";
4024 my $prefix_abs = abs_path($prefix);
4027 # check / create directories:
4029 die ("prefix_abs = ''") if $prefix_abs eq "";
4030 die ("prefix_abs = '/'") if $prefix_abs eq "/";
4032 mkdir ($prefix_abs, 0777);
4034 print "CREATE CTDB TEST ENVIRONMENT in '$prefix_abs'...\n";
4036 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
4037 system("rm -rf $prefix_abs/*");
4041 # Per-node data
4043 my @nodes = ();
4044 for (my $i = 0; $i < $num_nodes; $i++) {
4045 my %node = ();
4046 my $server_name = "ctdb${i}";
4047 my $pub_iface = Samba::get_interface($server_name);
4048 my $ip = Samba::get_ipv4_addr($server_name);
4050 $node{NODE_NUMBER} = "$i";
4051 $node{SERVER_NAME} = "$server_name";
4052 $node{SOCKET_WRAPPER_DEFAULT_IFACE} = "$pub_iface";
4053 $node{IP} = "$ip";
4055 push(@nodes, \%node);
4059 # nodes
4061 my $nodes_file = "$prefix/nodes.in";
4062 unless (open(NODES, ">$nodes_file")) {
4063 warn("Unable to open nodesfile '$nodes_file'");
4064 return undef;
4066 for (my $i = 0; $i < $num_nodes; $i++) {
4067 my $ip = $nodes[$i]->{IP};
4068 print NODES "${ip}\n";
4070 close(NODES);
4073 # local_daemons.sh setup
4075 # Socket wrapper setup is done by selftest.pl, so don't use
4076 # the CTDB-specific setup
4078 my $cmd;
4079 $cmd .= "ctdb/tests/local_daemons.sh " . $prefix_abs . " setup";
4080 $cmd .= " -n " . $num_nodes;
4081 $cmd .= " -N " . $nodes_file;
4082 # CTDB should not attempt to manage public addresses -
4083 # clients should just connect to CTDB private addresses
4084 $cmd .= " -P " . "/dev/null";
4086 my $ret = system($cmd);
4087 if ($ret != 0) {
4088 print("\"$cmd\" failed\n");
4089 return undef;
4093 # Unix domain socket and node directory for each daemon
4095 for (my $i = 0; $i < $num_nodes; $i++) {
4096 my ($cmd, $ret, $out);
4098 my $cmd_prefix = "ctdb/tests/local_daemons.sh ${prefix_abs}";
4101 # socket
4104 $cmd = "${cmd_prefix} print-socket ${i}";
4106 $out = `$cmd`;
4107 $ret = $?;
4108 if ($ret != 0) {
4109 print("\"$cmd\" failed\n");
4110 return undef;
4112 chomp $out;
4113 $nodes[$i]->{SOCKET_FILE} = "$out";
4116 # node directory
4119 $cmd = "${cmd_prefix} onnode ${i} 'echo \$CTDB_BASE'";
4121 $out = `$cmd`;
4122 $ret = $?;
4123 if ($ret != 0) {
4124 print("\"$cmd\" failed\n");
4125 return undef;
4127 chomp $out;
4128 $nodes[$i]->{NODE_PREFIX} = "$out";
4131 my %ret = ();
4133 $ret{CTDB_PREFIX} = "$prefix";
4134 $ret{NUM_NODES} = $num_nodes;
4135 $ret{CTDB_NODES} = \@nodes;
4136 $ret{CTDB_NODES_FILE} = $nodes_file;
4138 return \%ret;
4141 sub check_or_start_ctdb($$) {
4142 my ($self, $data) = @_;
4144 my $prefix = $data->{CTDB_PREFIX};
4145 my $num_nodes = $data->{NUM_NODES};
4146 my $nodes = $data->{CTDB_NODES};
4147 my $STDIN_READER;
4149 # Share a single stdin pipe for all nodes
4150 pipe($STDIN_READER, $data->{CTDB_STDIN_PIPE});
4152 for (my $i = 0; $i < $num_nodes; $i++) {
4153 my $node = $nodes->[$i];
4155 $node->{STDIN_PIPE} = $data->{CTDB_STDIN_PIPE};
4157 my $cmd = "ctdb/tests/local_daemons.sh";
4158 my @full_cmd = ("$cmd", "$prefix", "start", "$i");
4159 my $daemon_ctx = {
4160 NAME => "ctdbd",
4161 BINARY_PATH => $cmd,
4162 FULL_CMD => [ @full_cmd ],
4163 TEE_STDOUT => 1,
4164 LOG_FILE => "/dev/null",
4165 ENV_VARS => {},
4168 print "STARTING CTDBD (node ${i})\n";
4170 # This does magic with $STDIN_READER, so use it
4171 my $ret = Samba::fork_and_exec($self,
4172 $node,
4173 $daemon_ctx,
4174 $STDIN_READER);
4176 if ($ret == 0) {
4177 print("\"$cmd\" failed\n");
4178 teardown_env_ctdb($self, $data);
4179 return 0;
4183 close($STDIN_READER);
4185 return 1;
4188 sub wait_for_start_ctdb($$)
4190 my ($self, $data) = @_;
4192 my $prefix = $data->{CTDB_PREFIX};
4194 print "Wait for ctdbd...\n";
4196 my $ctdb = Samba::bindir_path($self, "ctdb");
4197 my $cmd;
4198 $cmd .= "ctdb/tests/local_daemons.sh ${prefix} onnode all";
4199 $cmd .= " ${ctdb} nodestatus all 2>&1";
4201 my $count = 0;
4202 my $wait_seconds = 60;
4203 my $out;
4205 until ($count > $wait_seconds) {
4206 $out = `$cmd`;
4207 my $ret = $?;
4208 if ($ret == 0) {
4209 print "\ncluster became healthy\n";
4210 last;
4212 print "Waiting for CTDB...\n";
4213 sleep(1);
4214 $count++;
4217 if ($count > $wait_seconds) {
4218 print "\nGiving up to wait for CTDB...\n";
4219 print "${out}\n\n";
4220 print "CTDB log:\n";
4221 $cmd = "ctdb/tests/local_daemons.sh ${prefix} print-log all >&2";
4222 system($cmd);
4223 teardown_env_ctdb($self, $data);
4224 return 0;
4227 print "\nCTDB initialized\n";
4229 return 1;