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.
13 use FindBin qw($RealBin);
16 use File::Path 'remove_tree';
21 my $smbd_build_options = Samba::bindir_path($self, "smbd") . " -b|";
22 open(IN, $smbd_build_options) or die("Unable to run $smbd_build_options: $!");
31 # If we were not built with ADS support, pretend we were never even available
32 print "smbd does not have ADS support\n" unless $found_ads;
36 # return smb.conf parameters applicable to @path, based on the underlying
38 sub get_fs_specific_conf($$)
40 my ($self, $path) = @_;
42 my $stat_out = `stat --file-system $path` or return "";
44 if ($stat_out =~ m/Type:\s+btrfs/) {
45 $mods .= "streams_xattr btrfs";
49 return "vfs objects = $mods";
56 my ($classname, $bindir, $srcdir, $server_maxtime) = @_;
57 my $self = { vars => {},
60 server_maxtime => $server_maxtime
68 my ($self, $envvars) = @_;
71 # This should cause smbd to terminate gracefully
72 close($envvars->{STDIN_PIPE});
74 my $smbdpid = $envvars->{SMBD_TL_PID};
75 my $nmbdpid = $envvars->{NMBD_TL_PID};
76 my $winbinddpid = $envvars->{WINBINDD_TL_PID};
78 # This should give it time to write out the gcov data
80 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
81 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
82 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
85 && $winbinddchild == -1) {
92 if ($count <= 20 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
96 $self->stop_sig_term($smbdpid);
97 $self->stop_sig_term($nmbdpid);
98 $self->stop_sig_term($winbinddpid);
101 until ($count > 10) {
102 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
103 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
104 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
107 && $winbinddchild == -1) {
114 if ($count <= 10 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
118 warn("timelimit process did not quit on SIGTERM, sending SIGKILL");
119 $self->stop_sig_kill($smbdpid);
120 $self->stop_sig_kill($nmbdpid);
121 $self->stop_sig_kill($winbinddpid);
126 sub getlog_env_app($$$)
128 my ($self, $envvars, $name) = @_;
130 my $title = "$name LOG of: $envvars->{NETBIOSNAME}\n";
133 open(LOG, "<".$envvars->{$name."_TEST_LOG"});
135 seek(LOG, $envvars->{$name."_TEST_LOG_POS"}, SEEK_SET);
139 $envvars->{$name."_TEST_LOG_POS"} = tell(LOG);
142 return "" if $out eq $title;
149 my ($self, $envvars) = @_;
152 $ret .= $self->getlog_env_app($envvars, "SMBD");
153 $ret .= $self->getlog_env_app($envvars, "NMBD");
154 $ret .= $self->getlog_env_app($envvars, "WINBINDD");
161 my ($self, $envvars) = @_;
163 my $childpid = waitpid(-1, WNOHANG);
169 # Declare the environments Samba3 makes available.
170 # To be set up, they will be called as
171 # samba3->setup_$envname($self, $path, $dep_1_vars, $dep_2_vars, ...)
172 %Samba3::ENV_DEPS = (
173 # name => [dep_1, dep_2, ...],
175 nt4_dc_schannel => [],
182 nt4_member => ["nt4_dc"],
184 ad_member => ["ad_dc"],
185 ad_member_rfc2307 => ["ad_dc_ntvfs"],
186 ad_member_idmap_rid => ["ad_dc"],
187 ad_member_idmap_ad => ["ad_dc"],
192 my ($self, $path) = @_;
194 print "PROVISIONING NT4 DC...";
196 my $nt4_dc_options = "
201 raw NTLMv2 auth = yes
202 server schannel = auto
204 rpc_server:epmapper = external
205 rpc_server:spoolss = external
206 rpc_server:lsarpc = external
207 rpc_server:samr = external
208 rpc_server:netlogon = external
209 rpc_server:register_embedded_np = yes
210 rpc_server:FssagentRpc = external
212 rpc_daemon:epmd = fork
213 rpc_daemon:spoolssd = fork
214 rpc_daemon:lsasd = fork
215 rpc_daemon:fssd = fork
216 fss: sequence timeout = 1
217 check parent directory delete on close = yes
220 my $vars = $self->provision($path, "SAMBA-TEST",
225 $vars or return undef;
227 if (not $self->check_or_start($vars, "yes", "yes", "yes")) {
231 $vars->{DOMSID} = $vars->{SAMSID};
232 $vars->{DC_SERVER} = $vars->{SERVER};
233 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
234 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
235 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
236 $vars->{DC_USERNAME} = $vars->{USERNAME};
237 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
242 sub setup_nt4_dc_schannel
244 my ($self, $path) = @_;
246 print "PROVISIONING NT4 DC WITH SERVER SCHANNEL ...";
253 rpc_server:epmapper = external
254 rpc_server:spoolss = external
255 rpc_server:lsarpc = external
256 rpc_server:samr = external
257 rpc_server:netlogon = external
258 rpc_server:register_embedded_np = yes
260 rpc_daemon:epmd = fork
261 rpc_daemon:spoolssd = fork
262 rpc_daemon:lsasd = fork
264 server schannel = yes
265 # used to reproduce bug #12772
266 server max protocol = SMB2_02
269 my $vars = $self->provision($path, "NT4SCHANNEL",
274 $vars or return undef;
276 if (not $self->check_or_start($vars, "yes", "yes", "yes")) {
280 $vars->{DOMSID} = $vars->{SAMSID};
281 $vars->{DC_SERVER} = $vars->{SERVER};
282 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
283 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
284 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
285 $vars->{DC_USERNAME} = $vars->{USERNAME};
286 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
293 my ($self, $prefix, $nt4_dc_vars) = @_;
297 print "PROVISIONING MEMBER...";
299 my $require_mutexes = "dbwrap_tdb_require_mutexes:* = yes";
300 $require_mutexes = "" if ($ENV{SELFTEST_DONT_REQUIRE_TDB_MUTEX_SUPPORT} eq "1");
302 my $member_options = "
304 dbwrap_tdb_mutexes:* = yes
307 my $ret = $self->provision($prefix, $nt4_dc_vars->{DOMAIN},
309 "localnt4member3pass",
312 $ret or return undef;
314 my $nmblookup = Samba::bindir_path($self, "nmblookup");
316 print "Waiting for the LOGON SERVER registration ...\n";
317 $rc = system("$nmblookup $ret->{CONFIGURATION} $ret->{DOMAIN}\#1c");
322 } while ($rc != 0 && $count < 10);
324 print "NMBD not reachable after 10 retries\n";
325 teardown_env($self, $ret);
329 my $net = Samba::bindir_path($self, "net");
330 # Add hosts file for name lookups
331 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
332 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
333 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
334 $cmd .= "$net rpc join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
335 $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}";
337 if (system($cmd) != 0) {
338 warn("Join failed\n$cmd");
342 # Add hosts file for name lookups
343 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
344 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
345 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
346 $cmd .= "$net $ret->{CONFIGURATION} primarytrust dumpinfo | grep -q 'REDACTED SECRET VALUES'";
348 if (system($cmd) != 0) {
349 warn("check failed\n$cmd");
353 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
357 $ret->{DOMSID} = $nt4_dc_vars->{DOMSID};
358 $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
359 $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
360 $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
361 $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME};
362 $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME};
363 $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD};
370 my ($self, $prefix, $dcvars) = @_;
372 my $prefix_abs = abs_path($prefix);
375 # If we didn't build with ADS, pretend this env was never available
376 if (not $self->have_ads()) {
380 print "PROVISIONING S3 AD MEMBER...";
382 mkdir($prefix_abs, 0777);
384 my $share_dir="$prefix_abs/share";
385 push(@dirs, $share_dir);
387 my $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}";
388 push(@dirs, $substitution_path);
390 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice";
391 push(@dirs, $substitution_path);
393 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice/G_domain users";
394 push(@dirs, $substitution_path);
396 # Using '/' as the winbind separator is a bad idea ...
397 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}";
398 push(@dirs, $substitution_path);
400 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice";
401 push(@dirs, $substitution_path);
403 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}";
404 push(@dirs, $substitution_path);
406 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}/domain users";
407 push(@dirs, $substitution_path);
409 my $member_options = "
411 workgroup = $dcvars->{DOMAIN}
412 realm = $dcvars->{REALM}
413 netbios aliases = foo bar
414 template homedir = /home/%D/%G/%U
417 path = $share_dir/D_%D/U_%U/G_%G
421 path = $share_dir/D_%D/u_%u/g_%g
426 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
430 $dcvars->{SERVER_IP},
431 $dcvars->{SERVER_IPV6});
433 $ret or return undef;
435 mkdir($_, 0777) foreach(@dirs);
438 $ret->{DOMAIN} = $dcvars->{DOMAIN};
439 $ret->{REALM} = $dcvars->{REALM};
440 $ret->{DOMSID} = $dcvars->{DOMSID};
444 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
445 $ctx->{domain} = $dcvars->{DOMAIN};
446 $ctx->{realm} = $dcvars->{REALM};
447 $ctx->{dnsname} = lc($dcvars->{REALM});
448 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
449 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
450 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
451 Samba::mk_krb5_conf($ctx, "");
453 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
455 my $net = Samba::bindir_path($self, "net");
456 # Add hosts file for name lookups
457 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
458 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
459 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
460 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
462 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
464 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
465 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
466 $cmd .= "$net join $ret->{CONFIGURATION}";
467 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
469 if (system($cmd) != 0) {
470 warn("Join failed\n$cmd");
474 # We need world access to this share, as otherwise the domain
475 # administrator from the AD domain provided by Samba4 can't
476 # access the share for tests.
477 chmod 0777, "$prefix/share";
479 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
483 $ret->{DC_SERVER} = $dcvars->{SERVER};
484 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
485 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
486 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
487 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
488 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
493 sub setup_ad_member_rfc2307
495 my ($self, $prefix, $dcvars) = @_;
497 # If we didn't build with ADS, pretend this env was never available
498 if (not $self->have_ads()) {
502 print "PROVISIONING S3 AD MEMBER WITH idmap_rfc2307 config...";
504 my $member_options = "
506 workgroup = $dcvars->{DOMAIN}
507 realm = $dcvars->{REALM}
509 idmap negative cache time = 0
510 idmap config * : backend = autorid
511 idmap config * : range = 1000000-1999999
512 idmap config * : rangesize = 100000
513 idmap config $dcvars->{DOMAIN} : backend = rfc2307
514 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
515 idmap config $dcvars->{DOMAIN} : ldap_server = ad
516 idmap config $dcvars->{DOMAIN} : bind_path_user = ou=idmap,dc=samba,dc=example,dc=com
517 idmap config $dcvars->{DOMAIN} : bind_path_group = ou=idmap,dc=samba,dc=example,dc=com
519 password server = $dcvars->{SERVER}
522 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
526 $dcvars->{SERVER_IP},
527 $dcvars->{SERVER_IPV6});
529 $ret or return undef;
532 $ret->{DOMAIN} = $dcvars->{DOMAIN};
533 $ret->{REALM} = $dcvars->{REALM};
534 $ret->{DOMSID} = $dcvars->{DOMSID};
537 my $prefix_abs = abs_path($prefix);
539 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
540 $ctx->{domain} = $dcvars->{DOMAIN};
541 $ctx->{realm} = $dcvars->{REALM};
542 $ctx->{dnsname} = lc($dcvars->{REALM});
543 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
544 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
545 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
546 Samba::mk_krb5_conf($ctx, "");
548 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
550 my $net = Samba::bindir_path($self, "net");
551 # Add hosts file for name lookups
552 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
553 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
554 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
555 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
557 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
559 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
560 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
561 $cmd .= "$net join $ret->{CONFIGURATION}";
562 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
564 if (system($cmd) != 0) {
565 warn("Join failed\n$cmd");
569 # We need world access to this share, as otherwise the domain
570 # administrator from the AD domain provided by Samba4 can't
571 # access the share for tests.
572 chmod 0777, "$prefix/share";
574 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
578 $ret->{DC_SERVER} = $dcvars->{SERVER};
579 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
580 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
581 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
582 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
583 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
588 sub setup_ad_member_idmap_rid
590 my ($self, $prefix, $dcvars) = @_;
592 # If we didn't build with ADS, pretend this env was never available
593 if (not $self->have_ads()) {
597 print "PROVISIONING S3 AD MEMBER WITH idmap_rid config...";
599 my $member_options = "
601 workgroup = $dcvars->{DOMAIN}
602 realm = $dcvars->{REALM}
603 idmap config * : backend = tdb
604 idmap config * : range = 1000000-1999999
605 idmap config $dcvars->{DOMAIN} : backend = rid
606 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
609 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
613 $dcvars->{SERVER_IP},
614 $dcvars->{SERVER_IPV6});
616 $ret or return undef;
619 $ret->{DOMAIN} = $dcvars->{DOMAIN};
620 $ret->{REALM} = $dcvars->{REALM};
621 $ret->{DOMSID} = $dcvars->{DOMSID};
624 my $prefix_abs = abs_path($prefix);
626 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
627 $ctx->{domain} = $dcvars->{DOMAIN};
628 $ctx->{realm} = $dcvars->{REALM};
629 $ctx->{dnsname} = lc($dcvars->{REALM});
630 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
631 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
632 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
633 Samba::mk_krb5_conf($ctx, "");
635 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
637 my $net = Samba::bindir_path($self, "net");
638 # Add hosts file for name lookups
639 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
640 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
641 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
642 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
644 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
646 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
647 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
648 $cmd .= "$net join $ret->{CONFIGURATION}";
649 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
651 if (system($cmd) != 0) {
652 warn("Join failed\n$cmd");
656 # We need world access to this share, as otherwise the domain
657 # administrator from the AD domain provided by Samba4 can't
658 # access the share for tests.
659 chmod 0777, "$prefix/share";
661 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
665 $ret->{DC_SERVER} = $dcvars->{SERVER};
666 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
667 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
668 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
669 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
670 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
675 sub setup_ad_member_idmap_ad
677 my ($self, $prefix, $dcvars) = @_;
679 # If we didn't build with ADS, pretend this env was never available
680 if (not $self->have_ads()) {
684 print "PROVISIONING S3 AD MEMBER WITH idmap_ad config...";
686 my $member_options = "
688 workgroup = $dcvars->{DOMAIN}
689 realm = $dcvars->{REALM}
690 password server = $dcvars->{SERVER}
691 idmap config * : backend = tdb
692 idmap config * : range = 1000000-1999999
693 idmap config $dcvars->{DOMAIN} : backend = ad
694 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
697 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
701 $dcvars->{SERVER_IP},
702 $dcvars->{SERVER_IPV6});
704 $ret or return undef;
707 $ret->{DOMAIN} = $dcvars->{DOMAIN};
708 $ret->{REALM} = $dcvars->{REALM};
709 $ret->{DOMSID} = $dcvars->{DOMSID};
712 my $prefix_abs = abs_path($prefix);
714 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
715 $ctx->{domain} = $dcvars->{DOMAIN};
716 $ctx->{realm} = $dcvars->{REALM};
717 $ctx->{dnsname} = lc($dcvars->{REALM});
718 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
719 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
720 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
721 Samba::mk_krb5_conf($ctx, "");
723 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
725 my $net = Samba::bindir_path($self, "net");
726 # Add hosts file for name lookups
727 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
728 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
729 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
730 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
732 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
734 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
735 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
736 $cmd .= "$net join $ret->{CONFIGURATION}";
737 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
739 if (system($cmd) != 0) {
740 warn("Join failed\n$cmd");
744 # We need world access to this share, as otherwise the domain
745 # administrator from the AD domain provided by Samba4 can't
746 # access the share for tests.
747 chmod 0777, "$prefix/share";
749 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
753 $ret->{DC_SERVER} = $dcvars->{SERVER};
754 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
755 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
756 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
757 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
758 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
763 sub setup_simpleserver
765 my ($self, $path) = @_;
767 print "PROVISIONING simple server...";
769 my $prefix_abs = abs_path($path);
771 my $simpleserver_options = "
774 vfs objects = xattr_tdb streams_depot
779 path = $prefix_abs/share
781 vfs objects = aio_pthread
782 aio_pthread:aio open = yes
783 smbd:async dosmode = no
785 [vfs_aio_pthread_async_dosmode_default1]
786 path = $prefix_abs/share
788 vfs objects = aio_pthread
789 store dos attributes = yes
790 aio_pthread:aio open = yes
791 smbd:async dosmode = yes
793 [vfs_aio_pthread_async_dosmode_default2]
794 path = $prefix_abs/share
796 vfs objects = aio_pthread xattr_tdb
797 store dos attributes = yes
798 aio_pthread:aio open = yes
799 smbd:async dosmode = yes
801 [vfs_aio_pthread_async_dosmode_force_sync1]
802 path = $prefix_abs/share
804 vfs objects = aio_pthread
805 store dos attributes = yes
806 aio_pthread:aio open = yes
807 smbd:async dosmode = yes
808 # This simulates non linux systems
809 smbd:force sync user path safe threadpool = yes
810 smbd:force sync user chdir safe threadpool = yes
811 smbd:force sync root path safe threadpool = yes
812 smbd:force sync root chdir safe threadpool = yes
814 [vfs_aio_pthread_async_dosmode_force_sync2]
815 path = $prefix_abs/share
817 vfs objects = aio_pthread xattr_tdb
818 store dos attributes = yes
819 aio_pthread:aio open = yes
820 smbd:async dosmode = yes
821 # This simulates non linux systems
822 smbd:force sync user path safe threadpool = yes
823 smbd:force sync user chdir safe threadpool = yes
824 smbd:force sync root path safe threadpool = yes
825 smbd:force sync root chdir safe threadpool = yes
828 path = $prefix_abs/share
829 vfs objects = aio_fork
831 vfs_aio_fork:erratic_testing_mode=yes
834 path = $prefix_abs/share
836 store dos attributes = yes
837 hide files = /hidefile/
841 path = $prefix_abs/share
843 smb encrypt = desired
846 path = $prefix_abs/share
847 hide new files timeout = 5
850 my $vars = $self->provision($path, "WORKGROUP",
853 $simpleserver_options);
855 $vars or return undef;
857 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
866 my ($self, $path) = @_;
867 my $prefix_abs = abs_path($path);
868 my $srcdir_abs = abs_path($self->{srcdir});
870 print "PROVISIONING file server ...\n";
874 mkdir($prefix_abs, 0777);
876 my $usershare_dir="$prefix_abs/lib/usershare";
878 mkdir("$prefix_abs/lib", 0755);
879 remove_tree($usershare_dir);
880 mkdir($usershare_dir, 01770);
882 my $share_dir="$prefix_abs/share";
884 # Create share directory structure
885 my $lower_case_share_dir="$share_dir/lower-case";
886 push(@dirs, $lower_case_share_dir);
888 my $lower_case_share_dir_30000="$share_dir/lower-case-30000";
889 push(@dirs, $lower_case_share_dir_30000);
891 my $dfree_share_dir="$share_dir/dfree";
892 push(@dirs, $dfree_share_dir);
893 push(@dirs, "$dfree_share_dir/subdir1");
894 push(@dirs, "$dfree_share_dir/subdir2");
895 push(@dirs, "$dfree_share_dir/subdir3");
897 my $quotadir_dir="$share_dir/quota";
898 push(@dirs, $quotadir_dir);
900 my $valid_users_sharedir="$share_dir/valid_users";
901 push(@dirs,$valid_users_sharedir);
903 my $offline_sharedir="$share_dir/offline";
904 push(@dirs,$offline_sharedir);
906 my $force_user_valid_users_dir = "$share_dir/force_user_valid_users";
907 push(@dirs, $force_user_valid_users_dir);
909 my $smbget_sharedir="$share_dir/smbget";
910 push(@dirs,$smbget_sharedir);
912 my $tarmode_sharedir="$share_dir/tarmode";
913 push(@dirs,$tarmode_sharedir);
915 my $usershare_sharedir="$share_dir/usershares";
916 push(@dirs,$usershare_sharedir);
918 my $fileserver_options = "
919 kernel change notify = yes
921 usershare path = $usershare_dir
922 usershare max shares = 10
923 usershare allow guests = yes
924 usershare prefix allow list = $usershare_sharedir
926 get quota command = $prefix_abs/getset_quota.py
927 set quota command = $prefix_abs/getset_quota.py
929 path = $lower_case_share_dir
930 comment = smb username is [%U]
931 case sensitive = True
934 short preserve case = no
936 path = $lower_case_share_dir_30000
937 comment = smb username is [%U]
938 case sensitive = True
941 short preserve case = no
943 path = $dfree_share_dir
944 comment = smb username is [%U]
945 dfree command = $srcdir_abs/testprogs/blackbox/dfree.sh
947 path = $valid_users_sharedir
948 valid users = +userdup
950 path = $offline_sharedir
951 vfs objects = offline
953 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878
954 # RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651
955 [force_user_valid_users]
956 path = $force_user_valid_users_dir
957 comment = force user with valid users combination test share
958 valid users = +force_user
959 force user = force_user
960 force group = everyone
961 write list = force_user
964 path = $smbget_sharedir
965 comment = smb username is [%U]
969 comment = ignore system acls
970 acl_xattr:ignore system acls = yes
973 comment = inherit owner
977 comment = inherit only unix owner
978 inherit owner = unix only
979 acl_xattr:ignore system acls = yes
982 my $vars = $self->provision($path, "WORKGROUP",
990 $vars or return undef;
992 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
997 mkdir($_, 0777) foreach(@dirs);
999 ## Create case sensitive lower case share dir
1000 foreach my $file ('a'..'z') {
1001 my $full_path = $lower_case_share_dir . '/' . $file;
1002 open my $fh, '>', $full_path;
1003 # Add some content to file
1004 print $fh $full_path;
1008 for (my $file = 1; $file < 51; ++$file) {
1009 my $full_path = $lower_case_share_dir . '/' . $file;
1010 open my $fh, '>', $full_path;
1011 # Add some content to file
1012 print $fh $full_path;
1016 # Create content for 30000 share
1017 foreach my $file ('a'..'z') {
1018 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1019 open my $fh, '>', $full_path;
1020 # Add some content to file
1021 print $fh $full_path;
1025 for (my $file = 1; $file < 30001; ++$file) {
1026 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1027 open my $fh, '>', $full_path;
1028 # Add some content to file
1029 print $fh $full_path;
1034 ## create a listable file in valid_users_share
1036 my $valid_users_target = "$valid_users_sharedir/foo";
1037 unless (open(VALID_USERS_TARGET, ">$valid_users_target")) {
1038 warn("Unable to open $valid_users_target");
1041 close(VALID_USERS_TARGET);
1042 chmod 0644, $valid_users_target;
1049 my ($self, $prefix) = @_;
1051 # If we didn't build with ADS, pretend this env was never available
1052 if (not $self->have_ads()) {
1056 print "PROVISIONING server with security=ads...";
1058 my $ktest_options = "
1060 realm = ktest.samba.example.com
1062 username map = $prefix/lib/username.map
1063 server signing = required
1064 server min protocol = SMB3_00
1065 client max protocol = SMB3
1067 # This disables NTLM auth against the local SAM, which
1068 # we use can then test this setting by.
1069 ntlm auth = disabled
1072 my $ret = $self->provision($prefix, "KTEST",
1077 $ret or return undef;
1080 my $prefix_abs = abs_path($prefix);
1082 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1083 $ctx->{domain} = "KTEST";
1084 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
1085 $ctx->{dnsname} = lc($ctx->{realm});
1086 $ctx->{kdc_ipv4} = "0.0.0.0";
1087 $ctx->{kdc_ipv6} = "::";
1088 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1089 Samba::mk_krb5_conf($ctx, "");
1091 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1093 open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map");
1095 $ret->{USERNAME} = KTEST\\Administrator
1099 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
1100 #Samba4 DC with the same parameters as are being used here. The
1101 #domain SID is S-1-5-21-1071277805-689288055-3486227160
1102 $ret->{SAMSID} = "S-1-5-21-1911091480-1468226576-2729736297";
1103 $ret->{DOMSID} = "S-1-5-21-1071277805-689288055-3486227160";
1105 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
1106 chmod 0600, "$prefix/private/secrets.tdb";
1108 #Make sure there's no old ntdb file.
1109 system("rm -f $prefix/private/secrets.ntdb");
1111 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
1112 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
1114 #and having in krb5.conf:
1115 # ticket_lifetime = 799718400
1116 # renew_lifetime = 799718400
1118 # The commands for the -2 keytab where were:
1119 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
1120 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
1121 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
1122 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1123 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1125 # and then for the -3 keytab, I did
1127 # net changetrustpw; kdestroy and the same again.
1129 # This creates a credential cache with a very long lifetime (2036 at
1130 # at 2011-04), and shows that running 'net changetrustpw' does not
1131 # break existing logins (for the secrets.tdb method at least).
1134 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
1136 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
1137 chmod 0600, "$prefix/krb5_ccache-2";
1139 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
1140 chmod 0600, "$prefix/krb5_ccache-3";
1142 # We need world access to this share, as otherwise the domain
1143 # administrator from the AD domain provided by ktest can't
1144 # access the share for tests.
1145 chmod 0777, "$prefix/share";
1147 if (not $self->check_or_start($ret, "yes", "no", "yes")) {
1153 sub setup_maptoguest
1155 my ($self, $path) = @_;
1157 print "PROVISIONING maptoguest...";
1160 map to guest = bad user
1164 my $vars = $self->provision($path, "WORKGROUP",
1169 $vars or return undef;
1171 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
1178 sub stop_sig_term($$) {
1179 my ($self, $pid) = @_;
1180 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1183 sub stop_sig_kill($$) {
1184 my ($self, $pid) = @_;
1185 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1190 my ($env_vars, $app, $pid) = @_;
1192 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
1199 my ($env_vars, $app) = @_;
1201 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
1207 sub check_or_start($$$$$) {
1208 my ($self, $env_vars, $nmbd, $winbindd, $smbd) = @_;
1210 # use a pipe for stdin in the child processes. This allows
1211 # those processes to monitor the pipe for EOF to ensure they
1212 # exit when the test script exits
1213 pipe(STDIN_READER, $env_vars->{STDIN_PIPE});
1215 unlink($env_vars->{NMBD_TEST_LOG});
1216 print "STARTING NMBD...";
1219 open STDOUT, ">$env_vars->{NMBD_TEST_LOG}";
1220 open STDERR, '>&STDOUT';
1222 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1224 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1225 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.nmbd";
1226 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1227 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1229 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1230 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1231 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1232 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1233 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1234 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1235 $ENV{UID_WRAPPER_ROOT} = "1";
1237 $ENV{ENVNAME} = "$ENV{ENVNAME}.nmbd";
1239 if ($nmbd ne "yes") {
1240 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1241 my $signame = shift;
1242 print("Skip nmbd received signal $signame");
1245 sleep($self->{server_maxtime});
1249 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "nmbd");
1250 my @optargs = ("-d0");
1251 if (defined($ENV{NMBD_OPTIONS})) {
1252 @optargs = split(/ /, $ENV{NMBD_OPTIONS});
1254 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1255 if(defined($ENV{NMBD_VALGRIND})) {
1256 @preargs = split(/ /, $ENV{NMBD_VALGRIND});
1258 my @args = ("-F", "--no-process-group",
1259 "-s", $env_vars->{SERVERCONFFILE},
1260 "-l", $env_vars->{LOGDIR});
1261 if (not defined($ENV{NMBD_DONT_LOG_STDOUT})) {
1262 push(@args, "--log-stdout");
1265 close($env_vars->{STDIN_PIPE});
1266 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1268 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1269 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1271 $env_vars->{NMBD_TL_PID} = $pid;
1272 write_pid($env_vars, "nmbd", $pid);
1275 unlink($env_vars->{WINBINDD_TEST_LOG});
1276 print "STARTING WINBINDD...";
1279 open STDOUT, ">$env_vars->{WINBINDD_TEST_LOG}";
1280 open STDERR, '>&STDOUT';
1282 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1284 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1285 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.winbindd";
1286 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1287 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1289 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1290 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1291 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1292 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1293 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1294 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1295 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
1296 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
1298 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
1300 $ENV{UID_WRAPPER_ROOT} = "1";
1302 $ENV{ENVNAME} = "$ENV{ENVNAME}.winbindd";
1304 if ($winbindd ne "yes") {
1305 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1306 my $signame = shift;
1307 print("Skip winbindd received signal $signame");
1310 sleep($self->{server_maxtime});
1314 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "winbindd");
1315 my @optargs = ("-d0");
1316 if (defined($ENV{WINBINDD_OPTIONS})) {
1317 @optargs = split(/ /, $ENV{WINBINDD_OPTIONS});
1319 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1320 if(defined($ENV{WINBINDD_VALGRIND})) {
1321 @preargs = split(/ /, $ENV{WINBINDD_VALGRIND});
1323 my @args = ("-F", "--no-process-group",
1324 "-s", $env_vars->{SERVERCONFFILE},
1325 "-l", $env_vars->{LOGDIR});
1326 if (not defined($ENV{WINBINDD_DONT_LOG_STDOUT})) {
1327 push(@args, "--stdout");
1330 close($env_vars->{STDIN_PIPE});
1331 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1333 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1334 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1336 $env_vars->{WINBINDD_TL_PID} = $pid;
1337 write_pid($env_vars, "winbindd", $pid);
1340 unlink($env_vars->{SMBD_TEST_LOG});
1341 print "STARTING SMBD...";
1344 open STDOUT, ">$env_vars->{SMBD_TEST_LOG}";
1345 open STDERR, '>&STDOUT';
1347 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1349 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1350 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.smbd";
1351 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1352 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1354 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1355 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1356 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1357 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1358 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1359 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1360 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
1361 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
1363 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
1365 $ENV{UID_WRAPPER_ROOT} = "1";
1367 $ENV{ENVNAME} = "$ENV{ENVNAME}.smbd";
1369 if ($smbd ne "yes") {
1370 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1371 my $signame = shift;
1372 print("Skip smbd received signal $signame");
1375 sleep($self->{server_maxtime});
1379 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "smbd");
1380 my @optargs = ("-d0");
1381 if (defined($ENV{SMBD_OPTIONS})) {
1382 @optargs = split(/ /, $ENV{SMBD_OPTIONS});
1384 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1385 if(defined($ENV{SMBD_VALGRIND})) {
1386 @preargs = split(/ /,$ENV{SMBD_VALGRIND});
1388 my @args = ("-F", "--no-process-group",
1389 "-s", $env_vars->{SERVERCONFFILE},
1390 "-l", $env_vars->{LOGDIR});
1391 if (not defined($ENV{SMBD_DONT_LOG_STDOUT})) {
1392 push(@args, "--log-stdout");
1395 close($env_vars->{STDIN_PIPE});
1396 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1398 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1399 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1401 $env_vars->{SMBD_TL_PID} = $pid;
1402 write_pid($env_vars, "smbd", $pid);
1405 close(STDIN_READER);
1407 return $self->wait_for_start($env_vars, $nmbd, $winbindd, $smbd);
1410 sub createuser($$$$$)
1412 my ($self, $username, $password, $conffile, $env) = @_;
1413 my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $username > /dev/null";
1416 while(my($var, $val) = each %$env) {
1417 $cmd = "$var=\"$val\" $cmd";
1420 unless (open(PWD, "|$cmd")) {
1421 warn("Unable to set password for $username account\n$cmd");
1424 print PWD "$password\n$password\n";
1425 unless (close(PWD)) {
1426 warn("Unable to set password for $username account\n$cmd");
1431 sub provision($$$$$$$$$)
1433 my ($self, $prefix, $domain, $server, $password, $extra_options, $dc_server_ip, $dc_server_ipv6, $no_delete_prefix) = @_;
1436 ## setup the various environment variables we need
1439 my $samsid = Samba::random_domain_sid();
1440 my $swiface = Samba::get_interface($server);
1442 my %createuser_env = ();
1443 my $server_ip = "127.0.0.$swiface";
1444 my $server_ipv6 = sprintf("fd00:0000:0000:0000:0000:0000:5357:5f%02x", $swiface);
1446 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
1449 my $unix_gids_str = $);
1450 my @unix_gids = split(" ", $unix_gids_str);
1452 my $prefix_abs = abs_path($prefix);
1453 my $bindir_abs = abs_path($self->{bindir});
1457 my $shrdir="$prefix_abs/share";
1458 push(@dirs,$shrdir);
1460 my $libdir="$prefix_abs/lib";
1461 push(@dirs,$libdir);
1463 my $piddir="$prefix_abs/pid";
1464 push(@dirs,$piddir);
1466 my $privatedir="$prefix_abs/private";
1467 push(@dirs,$privatedir);
1469 my $binddnsdir = "$prefix_abs/bind-dns";
1470 push(@dirs, $binddnsdir);
1472 my $lockdir="$prefix_abs/lockdir";
1473 push(@dirs,$lockdir);
1475 my $eventlogdir="$prefix_abs/lockdir/eventlog";
1476 push(@dirs,$eventlogdir);
1478 my $logdir="$prefix_abs/logs";
1479 push(@dirs,$logdir);
1481 my $driver32dir="$shrdir/W32X86";
1482 push(@dirs,$driver32dir);
1484 my $driver64dir="$shrdir/x64";
1485 push(@dirs,$driver64dir);
1487 my $driver40dir="$shrdir/WIN40";
1488 push(@dirs,$driver40dir);
1490 my $ro_shrdir="$shrdir/root-tmp";
1491 push(@dirs,$ro_shrdir);
1493 my $msdfs_shrdir="$shrdir/msdfsshare";
1494 push(@dirs,$msdfs_shrdir);
1496 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
1497 push(@dirs,$msdfs_deeppath);
1499 my $badnames_shrdir="$shrdir/badnames";
1500 push(@dirs,$badnames_shrdir);
1502 my $lease1_shrdir="$shrdir/SMB2_10";
1503 push(@dirs,$lease1_shrdir);
1505 my $lease2_shrdir="$shrdir/SMB3_00";
1506 push(@dirs,$lease2_shrdir);
1508 my $manglenames_shrdir="$shrdir/manglenames";
1509 push(@dirs,$manglenames_shrdir);
1511 my $widelinks_shrdir="$shrdir/widelinks";
1512 push(@dirs,$widelinks_shrdir);
1514 my $widelinks_linkdir="$shrdir/widelinks_foo";
1515 push(@dirs,$widelinks_linkdir);
1517 my $shadow_tstdir="$shrdir/shadow";
1518 push(@dirs,$shadow_tstdir);
1519 my $shadow_mntdir="$shadow_tstdir/mount";
1520 push(@dirs,$shadow_mntdir);
1521 my $shadow_basedir="$shadow_mntdir/base";
1522 push(@dirs,$shadow_basedir);
1523 my $shadow_shrdir="$shadow_basedir/share";
1524 push(@dirs,$shadow_shrdir);
1526 my $nosymlinks_shrdir="$shrdir/nosymlinks";
1527 push(@dirs,$nosymlinks_shrdir);
1529 my $local_symlinks_shrdir="$shrdir/local_symlinks";
1530 push(@dirs,$local_symlinks_shrdir);
1532 # this gets autocreated by winbindd
1533 my $wbsockdir="$prefix_abs/winbindd";
1535 my $nmbdsockdir="$prefix_abs/nmbd";
1536 unlink($nmbdsockdir);
1539 ## create the test directory layout
1541 die ("prefix_abs = ''") if $prefix_abs eq "";
1542 die ("prefix_abs = '/'") if $prefix_abs eq "/";
1544 mkdir($prefix_abs, 0777);
1545 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
1546 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
1547 system("rm -rf $prefix_abs/*");
1549 mkdir($_, 0777) foreach(@dirs);
1551 my $fs_specific_conf = $self->get_fs_specific_conf($shrdir);
1554 ## lockdir and piddir must be 0755
1556 chmod 0755, $lockdir;
1557 chmod 0755, $piddir;
1561 ## create ro and msdfs share layout
1564 chmod 0755, $ro_shrdir;
1565 my $unreadable_file = "$ro_shrdir/unreadable_file";
1566 unless (open(UNREADABLE_FILE, ">$unreadable_file")) {
1567 warn("Unable to open $unreadable_file");
1570 close(UNREADABLE_FILE);
1571 chmod 0600, $unreadable_file;
1573 my $msdfs_target = "$ro_shrdir/msdfs-target";
1574 unless (open(MSDFS_TARGET, ">$msdfs_target")) {
1575 warn("Unable to open $msdfs_target");
1578 close(MSDFS_TARGET);
1579 chmod 0666, $msdfs_target;
1580 symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp",
1581 "$msdfs_shrdir/msdfs-src1";
1582 symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
1585 ## create bad names in $badnames_shrdir
1587 ## (An invalid name, would be mangled to 8.3).
1588 my $badname_target = "$badnames_shrdir/\340|\231\216\377\177";
1589 unless (open(BADNAME_TARGET, ">$badname_target")) {
1590 warn("Unable to open $badname_target");
1593 close(BADNAME_TARGET);
1594 chmod 0666, $badname_target;
1596 ## (A bad name, would not be mangled to 8.3).
1597 my $badname_target = "$badnames_shrdir/\240\276\346\327\377\177";
1598 unless (open(BADNAME_TARGET, ">$badname_target")) {
1599 warn("Unable to open $badname_target");
1602 close(BADNAME_TARGET);
1603 chmod 0666, $badname_target;
1605 ## (A bad good name).
1606 my $badname_target = "$badnames_shrdir/blank.txt";
1607 unless (open(BADNAME_TARGET, ">$badname_target")) {
1608 warn("Unable to open $badname_target");
1611 close(BADNAME_TARGET);
1612 chmod 0666, $badname_target;
1615 ## create mangleable directory names in $manglenames_shrdir
1617 my $manglename_target = "$manglenames_shrdir/foo:bar";
1618 mkdir($manglename_target, 0777);
1621 ## create symlinks for widelinks tests.
1623 my $widelinks_target = "$widelinks_linkdir/target";
1624 unless (open(WIDELINKS_TARGET, ">$widelinks_target")) {
1625 warn("Unable to open $widelinks_target");
1628 close(WIDELINKS_TARGET);
1629 chmod 0666, $widelinks_target;
1631 ## This link should get ACCESS_DENIED
1633 symlink "$widelinks_target", "$widelinks_shrdir/source";
1635 ## This link should be allowed
1637 symlink "$widelinks_shrdir", "$widelinks_shrdir/dot";
1639 my $conffile="$libdir/server.conf";
1640 my $dfqconffile="$libdir/dfq.conf";
1642 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/third_party/nss_wrapper/nss_wrapper.pl";
1643 my $nss_wrapper_passwd = "$privatedir/passwd";
1644 my $nss_wrapper_group = "$privatedir/group";
1645 my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts";
1646 my $resolv_conf = "$privatedir/resolv.conf";
1647 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
1649 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
1651 my $fake_snap_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/fake_snap.pl";
1653 my @eventlog_list = ("dns server", "application");
1656 ## calculate uids and gids
1659 my ($max_uid, $max_gid);
1660 my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
1661 my ($uid_pdbtest_wkn);
1663 my ($uid_force_user);
1664 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
1665 my ($gid_userdup, $gid_everyone);
1666 my ($gid_force_user);
1670 if ($unix_uid < 0xffff - 10) {
1673 $max_uid = $unix_uid;
1676 $uid_root = $max_uid - 1;
1677 $uid_nobody = $max_uid - 2;
1678 $uid_pdbtest = $max_uid - 3;
1679 $uid_pdbtest2 = $max_uid - 4;
1680 $uid_userdup = $max_uid - 5;
1681 $uid_pdbtest_wkn = $max_uid - 6;
1682 $uid_force_user = $max_uid - 7;
1683 $uid_smbget = $max_uid - 8;
1684 $uid_user1 = $max_uid - 9;
1685 $uid_user2 = $max_uid - 10;
1687 if ($unix_gids[0] < 0xffff - 8) {
1690 $max_gid = $unix_gids[0];
1693 $gid_nobody = $max_gid - 1;
1694 $gid_nogroup = $max_gid - 2;
1695 $gid_root = $max_gid - 3;
1696 $gid_domusers = $max_gid - 4;
1697 $gid_domadmins = $max_gid - 5;
1698 $gid_userdup = $max_gid - 6;
1699 $gid_everyone = $max_gid - 7;
1700 $gid_force_user = $max_gid - 8;
1706 unless (open(CONF, ">$conffile")) {
1707 warn("Unable to open $conffile");
1712 netbios name = $server
1713 interfaces = $server_ip/8 $server_ipv6/64
1714 bind interfaces only = yes
1715 panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
1716 smbd:suicide mode = yes
1720 private dir = $privatedir
1721 binddns dir = $binddnsdir
1722 pid directory = $piddir
1723 lock directory = $lockdir
1724 log file = $logdir/log.\%m
1729 state directory = $lockdir
1730 cache directory = $lockdir
1732 passdb backend = tdbsam
1736 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1737 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
1738 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1739 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
1740 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
1741 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
1742 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
1744 addprinter command = $mod_printer_pl -a -s $conffile --
1745 deleteprinter command = $mod_printer_pl -d -s $conffile --
1747 eventlog list = application \"dns server\"
1750 kernel change notify = no
1754 printcap name = /dev/null
1756 winbindd socket directory = $wbsockdir
1757 nmbd:socket dir = $nmbdsockdir
1758 idmap config * : range = 100000-200000
1759 winbind enum users = yes
1760 winbind enum groups = yes
1761 winbind separator = /
1762 include system krb5 conf = no
1764 # min receivefile size = 4000
1768 smbd:sharedelay = 100000
1769 smbd:writetimeupdatedelay = 500000
1773 store dos attributes = yes
1778 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot time_audit full_audit
1780 full_audit:syslog = no
1781 full_audit:success = none
1782 full_audit:failure = none
1785 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
1786 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
1787 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
1788 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
1789 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
1790 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
1791 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
1793 print notify backchannel = yes
1795 ncalrpc dir = $prefix_abs/ncalrpc
1797 # The samba3.blackbox.smbclient_s3 test uses this to test that
1798 # sending messages works, and that the %m sub works.
1799 message command = mv %s $shrdir/message.%m
1801 # fsrvp server requires registry shares
1802 registry shares = yes
1804 # Used by RPC SRVSVC tests
1805 add share command = $bindir_abs/smbaddshare
1806 change share command = $bindir_abs/smbchangeshare
1807 delete share command = $bindir_abs/smbdeleteshare
1809 # fruit:copyfile is a global option
1810 fruit:copyfile = yes
1812 #this does not mean that we use non-secure test env,
1813 #it just means we ALLOW one to be configured.
1814 allow insecure wide links = yes
1816 # Begin extra options
1820 #Include user defined custom parameters if set
1823 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
1824 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
1830 comment = smb username is [%U]
1833 comment = Load dirsort module
1834 vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot
1837 comment = encrypt smb username is [%U]
1838 smb encrypt = required
1839 vfs objects = dirsort
1849 force user = $unix_name
1851 [forceuser_unixonly]
1852 comment = force a user with unix user SID and group SID
1854 force user = pdbtest
1856 [forceuser_wkngroup]
1857 comment = force a user with well-known group SID
1859 force user = pdbtest_wkn
1863 force group = nogroup
1871 write list = $unix_name
1874 valid users = $unix_name
1875 access based share enum = yes
1877 path = $msdfs_shrdir
1879 msdfs shuffle referrals = yes
1883 hide unreadable = yes
1886 case sensitive = yes
1889 hide unwriteable files = yes
1892 kernel share modes = no
1906 default devmode = no
1912 comment = smb username is [%U]
1914 nfs4acl_xattr:version = 40
1915 vfs objects = nfs4acl_xattr xattr_tdb
1917 [nfs4acl_special_40]
1919 comment = smb username is [%U]
1921 nfs4acl_xattr:version = 40
1922 vfs objects = nfs4acl_xattr xattr_tdb
1926 comment = smb username is [%U]
1928 vfs objects = nfs4acl_xattr xattr_tdb
1932 comment = smb username is [%U]
1933 vfs objects = nfs4acl_xattr xattr_tdb
1935 nfs4acl_xattr:encoding = xdr
1936 nfs4acl_xattr:version = 40
1940 comment = smb username is [%U]
1941 vfs objects = nfs4acl_xattr xattr_tdb
1943 nfs4acl_xattr:encoding = xdr
1944 nfs4acl_xattr:version = 41
1948 comment = smb username is [%U]
1950 force create mode = 777
1953 comment = smb username is [%U]
1955 force create mode = 0
1956 directory mask = 0777
1957 force directory mode = 0
1958 vfs objects = xattr_tdb streams_depot
1969 vfs objects = catia fruit streams_xattr acl_xattr xattr_tdb
1970 fruit:resource = file
1971 fruit:metadata = netatalk
1972 fruit:locking = netatalk
1973 fruit:encoding = native
1974 fruit:veto_appledouble = no
1978 # This is used by vfs.fruit tests that require real fs xattr
1979 vfs objects = catia fruit streams_xattr acl_xattr
1980 fruit:resource = file
1981 fruit:metadata = netatalk
1982 fruit:locking = netatalk
1983 fruit:encoding = native
1984 fruit:veto_appledouble = no
1986 [vfs_fruit_metadata_stream]
1988 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
1989 fruit:resource = file
1990 fruit:metadata = stream
1991 fruit:veto_appledouble = no
1993 [vfs_fruit_stream_depot]
1995 vfs objects = fruit streams_depot acl_xattr xattr_tdb
1996 fruit:resource = stream
1997 fruit:metadata = stream
1998 fruit:veto_appledouble = no
2002 vfs objects = streams_xattr acl_xattr xattr_tdb
2004 [vfs_wo_fruit_stream_depot]
2006 vfs objects = streams_depot acl_xattr xattr_tdb
2008 [vfs_fruit_timemachine]
2010 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2011 fruit:resource = file
2012 fruit:metadata = stream
2013 fruit:time machine = yes
2014 fruit:time machine max size = 32K
2016 [vfs_fruit_wipe_intentionally_left_blank_rfork]
2018 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2019 fruit:resource = file
2020 fruit:metadata = stream
2021 fruit:wipe_intentionally_left_blank_rfork = true
2022 fruit:delete_empty_adfiles = false
2023 fruit:veto_appledouble = no
2025 [vfs_fruit_delete_empty_adfiles]
2027 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2028 fruit:resource = file
2029 fruit:metadata = stream
2030 fruit:wipe_intentionally_left_blank_rfork = true
2031 fruit:delete_empty_adfiles = true
2032 fruit:veto_appledouble = no
2035 path = $badnames_shrdir
2039 path = $manglenames_shrdir
2047 path = $widelinks_shrdir
2053 comment = fake shapshots using rsync
2054 vfs objects = shell_snap shadow_copy2
2055 shell_snap:check path command = $fake_snap_pl --check
2056 shell_snap:create command = $fake_snap_pl --create
2057 shell_snap:delete command = $fake_snap_pl --delete
2058 # a relative path here fails, the snapshot dir is no longer found
2059 shadow:snapdir = $shrdir/.snapshots
2062 path = $shadow_shrdir
2063 comment = previous versions snapshots under mount point
2064 vfs objects = shadow_copy2
2065 shadow:mountpoint = $shadow_mntdir
2068 path = $shadow_shrdir
2069 comment = previous versions snapshots outside mount point
2070 vfs objects = shadow_copy2
2071 shadow:mountpoint = $shadow_mntdir
2072 shadow:snapdir = $shadow_tstdir/.snapshots
2075 path = $shadow_shrdir
2076 comment = previous versions with subvolume snapshots, snapshots under base dir
2077 vfs objects = shadow_copy2
2078 shadow:mountpoint = $shadow_mntdir
2079 shadow:basedir = $shadow_basedir
2080 shadow:snapdir = $shadow_basedir/.snapshots
2083 path = $shadow_shrdir
2084 comment = previous versions with subvolume snapshots, snapshots outside mount point
2085 vfs objects = shadow_copy2
2086 shadow:mountpoint = $shadow_mntdir
2087 shadow:basedir = $shadow_basedir
2088 shadow:snapdir = $shadow_tstdir/.snapshots
2091 path = $shadow_shrdir
2092 comment = previous versions at volume root snapshots under mount point
2093 vfs objects = shadow_copy2
2094 shadow:mountpoint = $shadow_shrdir
2097 path = $shadow_shrdir
2098 comment = previous versions at volume root snapshots outside mount point
2099 vfs objects = shadow_copy2
2100 shadow:mountpoint = $shadow_shrdir
2101 shadow:snapdir = $shadow_tstdir/.snapshots
2104 path = $shadow_shrdir
2105 comment = previous versions snapshots everywhere
2106 vfs objects = shadow_copy2
2107 shadow:mountpoint = $shadow_mntdir
2108 shadow:snapdirseverywhere = yes
2111 path = $shadow_shrdir
2112 comment = previous versions using snapsharepath
2113 vfs objects = shadow_copy2
2114 shadow:mountpoint = $shadow_mntdir
2115 shadow:snapdir = $shadow_tstdir/.snapshots
2116 shadow:snapsharepath = share
2119 comment = Testing shadow:format with default option
2120 vfs object = shadow_copy2
2121 path = $shadow_shrdir
2124 shadow:mountpoint = $shadow_mntdir
2125 shadow:basedir = $shadow_basedir
2126 shadow:snapdir = $shadow_basedir/.snapshots
2127 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2130 comment = Testing shadow:format with only date component
2131 vfs object = shadow_copy2
2132 path = $shadow_shrdir
2135 shadow:mountpoint = $shadow_mntdir
2136 shadow:basedir = $shadow_basedir
2137 shadow:snapdir = $shadow_basedir/.snapshots
2138 shadow:format = \@GMT-%Y-%m-%d
2141 comment = Testing shadow:format with some hardcoded prefix
2142 vfs object = shadow_copy2
2143 path = $shadow_shrdir
2146 shadow:mountpoint = $shadow_mntdir
2147 shadow:basedir = $shadow_basedir
2148 shadow:snapdir = $shadow_basedir/.snapshots
2149 shadow:format = snap\@GMT-%Y.%m.%d-%H.%M.%S
2152 comment = Testing shadow:format with modified format
2153 vfs object = shadow_copy2
2154 path = $shadow_shrdir
2157 shadow:mountpoint = $shadow_mntdir
2158 shadow:basedir = $shadow_basedir
2159 shadow:snapdir = $shadow_basedir/.snapshots
2160 shadow:format = \@GMT-%Y.%m.%d-%H_%M_%S-snap
2163 comment = Testing shadow:snapprefix regex
2164 vfs object = shadow_copy2
2165 path = $shadow_shrdir
2168 shadow:mountpoint = $shadow_mntdir
2169 shadow:basedir = $shadow_basedir
2170 shadow:snapdir = $shadow_basedir/.snapshots
2171 shadow:snapprefix = \^s[a-z]*p\$
2172 shadow:format = _GMT-%Y.%m.%d-%H.%M.%S
2175 comment = Testing shadow:snapprefix with delim regex
2176 vfs object = shadow_copy2
2177 path = $shadow_shrdir
2180 shadow:mountpoint = $shadow_mntdir
2181 shadow:basedir = $shadow_basedir
2182 shadow:snapdir = $shadow_basedir/.snapshots
2183 shadow:delimiter = \@GMT
2184 shadow:snapprefix = [a-z]*
2185 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2188 path = $shadow_shrdir
2189 comment = previous versions with wide links allowed
2190 vfs objects = shadow_copy2
2191 shadow:mountpoint = $shadow_mntdir
2195 path = $shadow_tstdir
2196 comment = previous versions snapshots under mount point
2197 vfs objects = shadow_copy2 error_inject
2199 error_inject:pwrite = EBADF
2200 shadow:mountpoint = $shadow_tstdir
2203 path = $shrdir/dfree
2204 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2205 admin users = $unix_name
2206 include = $dfqconffile
2208 path = $shrdir/dfree
2209 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2210 admin users = $unix_name
2211 include = $dfqconffile
2212 dfree cache time = 60
2214 path = $shrdir/dfree
2215 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2217 include = $dfqconffile
2219 path = $shrdir/quota
2220 admin users = $unix_name
2222 [acl_xattr_ign_sysacl_posix]
2224 acl_xattr:ignore system acls = yes
2225 acl_xattr:default acl style = posix
2226 [acl_xattr_ign_sysacl_windows]
2228 acl_xattr:ignore system acls = yes
2229 acl_xattr:default acl style = windows
2233 mangled names = illegal
2237 path = $nosymlinks_shrdir
2238 follow symlinks = no
2242 path = $local_symlinks_shrdir
2243 follow symlinks = yes
2247 kernel oplocks = yes
2248 vfs objects = streams_xattr xattr_tdb
2252 vfs objects = streams_xattr xattr_tdb
2256 smbd:find async delay usec = 10000
2259 vfs objects = error_inject
2260 include = $libdir/error_inject.conf
2264 vfs objects = delay_inject
2265 kernel share modes = no
2268 include = $libdir/delay_inject.conf
2272 vfs objects = delay_inject
2273 delay_inject:pread_send = 2000
2274 delay_inject:pwrite_send = 2000
2277 path = $prefix_abs/share
2278 delete readonly = yes
2282 my $net = Samba::bindir_path($self, "net");
2284 $cmd .= "SMB_CONF_PATH=\"$conffile\" ";
2285 $cmd .= "$net setlocalsid $samsid";
2287 if (system($cmd) != 0) {
2288 warn("Join failed\n$cmd");
2292 unless (open(DFQCONF, ">$dfqconffile")) {
2293 warn("Unable to open $dfqconffile");
2299 ## create a test account
2302 unless (open(PASSWD, ">$nss_wrapper_passwd")) {
2303 warn("Unable to open $nss_wrapper_passwd");
2306 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
2307 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
2308 pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2309 pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2310 userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
2311 pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false
2312 force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false
2313 smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false
2314 user1:x:$uid_user1:$gid_nogroup:user1 gecos:$prefix_abs:/bin/false
2315 user2:x:$uid_user2:$gid_nogroup:user2 gecos:$prefix_abs:/bin/false
2317 if ($unix_uid != 0) {
2318 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
2323 unless (open(GROUP, ">$nss_wrapper_group")) {
2324 warn("Unable to open $nss_wrapper_group");
2327 print GROUP "nobody:x:$gid_nobody:
2328 nogroup:x:$gid_nogroup:nobody
2329 $unix_name-group:x:$unix_gids[0]:
2330 domusers:X:$gid_domusers:
2331 domadmins:X:$gid_domadmins:
2332 userdup:x:$gid_userdup:$unix_name
2333 everyone:x:$gid_everyone:
2334 force_user:x:$gid_force_user:
2336 if ($unix_gids[0] != 0) {
2337 print GROUP "root:x:$gid_root:
2344 my $hostname = lc($server);
2345 unless (open(HOSTS, ">>$nss_wrapper_hosts")) {
2346 warn("Unable to open $nss_wrapper_hosts");
2349 print HOSTS "${server_ip} ${hostname}.samba.example.com ${hostname}\n";
2350 print HOSTS "${server_ipv6} ${hostname}.samba.example.com ${hostname}\n";
2354 unless (open(RESOLV_CONF, ">$resolv_conf")) {
2355 warn("Unable to open $resolv_conf");
2358 if (defined($dc_server_ip) or defined($dc_server_ipv6)) {
2359 if (defined($dc_server_ip)) {
2360 print RESOLV_CONF "nameserver $dc_server_ip\n";
2362 if (defined($dc_server_ipv6)) {
2363 print RESOLV_CONF "nameserver $dc_server_ipv6\n";
2366 print RESOLV_CONF "nameserver ${server_ip}\n";
2367 print RESOLV_CONF "nameserver ${server_ipv6}\n";
2371 foreach my $evlog (@eventlog_list) {
2372 my $evlogtdb = "$eventlogdir/$evlog.tdb";
2373 open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
2377 $createuser_env{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2378 $createuser_env{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2379 $createuser_env{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2380 $createuser_env{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2381 if ($ENV{SAMBA_DNS_FAKING}) {
2382 $createuser_env{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2384 $createuser_env{RESOLV_WRAPPER_CONF} = $resolv_conf;
2387 createuser($self, $unix_name, $password, $conffile, \%createuser_env) || die("Unable to create user");
2388 createuser($self, "force_user", $password, $conffile, \%createuser_env) || die("Unable to create force_user");
2389 createuser($self, "smbget_user", $password, $conffile, \%createuser_env) || die("Unable to create smbget_user");
2390 createuser($self, "user1", $password, $conffile, \%createuser_env) || die("Unable to create user1");
2391 createuser($self, "user2", $password, $conffile, \%createuser_env) || die("Unable to create user2");
2393 open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
2394 print DNS_UPDATE_LIST "A $server. $server_ip\n";
2395 print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n";
2396 close(DNS_UPDATE_LIST);
2400 $ret{SERVER_IP} = $server_ip;
2401 $ret{SERVER_IPV6} = $server_ipv6;
2402 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
2403 $ret{NMBD_TEST_LOG_POS} = 0;
2404 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
2405 $ret{WINBINDD_TEST_LOG_POS} = 0;
2406 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
2407 $ret{SMBD_TEST_LOG_POS} = 0;
2408 $ret{SERVERCONFFILE} = $conffile;
2409 $ret{CONFIGURATION} ="-s $conffile";
2410 $ret{LOCK_DIR} = $lockdir;
2411 $ret{SERVER} = $server;
2412 $ret{USERNAME} = $unix_name;
2413 $ret{USERID} = $unix_uid;
2414 $ret{DOMAIN} = $domain;
2415 $ret{SAMSID} = $samsid;
2416 $ret{NETBIOSNAME} = $server;
2417 $ret{PASSWORD} = $password;
2418 $ret{PIDDIR} = $piddir;
2419 $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir;
2420 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
2421 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
2422 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2423 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2424 $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2425 $ret{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2426 $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
2427 $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind";
2428 if ($ENV{SAMBA_DNS_FAKING}) {
2429 $ret{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2431 $ret{RESOLV_WRAPPER_CONF} = $resolv_conf;
2433 $ret{LOCAL_PATH} = "$shrdir";
2434 $ret{LOGDIR} = $logdir;
2437 # Avoid hitting system krb5.conf -
2438 # An env that needs Kerberos will reset this to the real
2441 $ret{KRB5_CONFIG} = abs_path($prefix) . "/no_krb5.conf";
2443 # Define KRB5CCNAME for each environment we set up
2444 $ret{KRB5_CCACHE} = abs_path($prefix) . "/krb5ccache";
2445 $ENV{KRB5CCNAME} = $ret{KRB5_CCACHE};
2450 sub wait_for_start($$$$$)
2452 my ($self, $envvars, $nmbd, $winbindd, $smbd) = @_;
2457 if ($nmbd eq "yes") {
2460 # give time for nbt server to register its names
2461 print "checking for nmbd\n";
2463 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
2464 my $nmblookup = Samba::bindir_path($self, "nmblookup");
2467 $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
2471 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
2472 system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
2473 system("$nmblookup $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
2474 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
2477 } while ($ret != 0 && $count < 10);
2479 print "NMBD not reachable after 10 retries\n";
2480 teardown_env($self, $envvars);
2485 if ($winbindd eq "yes") {
2486 print "checking for winbindd\n";
2488 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2489 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2490 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2491 $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping-dc";
2495 $ret = system($cmd);
2499 } while ($ret != 0 && $count < 20);
2501 print "WINBINDD not reachable after 20 seconds\n";
2502 teardown_env($self, $envvars);
2507 if ($smbd eq "yes") {
2508 # make sure smbd is also up set
2509 print "wait for smbd\n";
2513 $ret = system(Samba::bindir_path($self, "smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139");
2518 } while ($ret != 0 && $count < 20);
2520 print "SMBD failed to start up in a reasonable time (20sec)\n";
2521 teardown_env($self, $envvars);
2526 # Ensure we have domain users mapped.
2527 $netcmd = "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2528 $netcmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2529 $netcmd .= Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} ";
2531 $cmd = $netcmd . "groupmap delete ntgroup=domusers";
2532 $ret = system($cmd);
2534 $cmd = $netcmd . "groupmap add rid=513 unixgroup=domusers type=domain";
2535 $ret = system($cmd);
2537 print("\"$cmd\" failed\n");
2541 $cmd = $netcmd . "groupmap delete ntgroup=domadmins";
2542 $ret = system($cmd);
2544 $cmd = $netcmd . "groupmap add rid=512 unixgroup=domadmins type=domain";
2545 $ret = system($cmd);
2547 print("\"$cmd\" failed\n");
2551 $cmd = $netcmd . "groupmap delete ntgroup=everyone";
2552 $ret = system($cmd);
2554 $cmd = $netcmd . "groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin";
2555 $ret = system($cmd);
2557 print("\"$cmd\" failed\n");
2561 # note: creating builtin groups requires winbindd for the
2563 my $create_builtin_users = "no";
2564 if ($winbindd eq "yes") {
2565 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2566 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2567 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2568 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
2569 my $wbinfo_out = qx($cmd 2>&1);
2571 # wbinfo doesn't give us a better error code then
2572 # WBC_ERR_DOMAIN_NOT_FOUND, but at least that's
2573 # different then WBC_ERR_WINBIND_NOT_AVAILABLE
2574 if ($wbinfo_out !~ /WBC_ERR_DOMAIN_NOT_FOUND/) {
2575 print("Failed to run \"wbinfo --sid-to-gid=S-1-5-32-545\": $wbinfo_out");
2576 teardown_env($self, $envvars);
2579 $create_builtin_users = "yes";
2582 if ($create_builtin_users eq "yes") {
2583 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2584 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2585 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2586 $cmd .= Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
2587 $cmd .= "sam createbuiltingroup Users";
2588 $ret = system($cmd);
2590 print "Failed to create BUILTIN\\Users group\n";
2591 teardown_env($self, $envvars);
2595 $cmd = Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
2596 $cmd .= "cache del IDMAP/SID2XID/S-1-5-32-545";
2599 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2600 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2601 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2602 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
2603 $ret = system($cmd);
2605 print "Missing \"BUILTIN\\Users\", did net sam createbuiltingroup Users fail?\n";
2606 teardown_env($self, $envvars);
2611 print $self->getlog_env($envvars);