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};
454 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
456 my $net = Samba::bindir_path($self, "net");
457 # Add hosts file for name lookups
458 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
459 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
460 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
461 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
463 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
465 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
466 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
467 $cmd .= "$net join $ret->{CONFIGURATION}";
468 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
470 if (system($cmd) != 0) {
471 warn("Join failed\n$cmd");
475 # We need world access to this share, as otherwise the domain
476 # administrator from the AD domain provided by Samba4 can't
477 # access the share for tests.
478 chmod 0777, "$prefix/share";
480 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
484 $ret->{DC_SERVER} = $dcvars->{SERVER};
485 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
486 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
487 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
488 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
489 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
494 sub setup_ad_member_rfc2307
496 my ($self, $prefix, $dcvars) = @_;
498 # If we didn't build with ADS, pretend this env was never available
499 if (not $self->have_ads()) {
503 print "PROVISIONING S3 AD MEMBER WITH idmap_rfc2307 config...";
505 my $member_options = "
507 workgroup = $dcvars->{DOMAIN}
508 realm = $dcvars->{REALM}
510 idmap negative cache time = 0
511 idmap config * : backend = autorid
512 idmap config * : range = 1000000-1999999
513 idmap config * : rangesize = 100000
514 idmap config $dcvars->{DOMAIN} : backend = rfc2307
515 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
516 idmap config $dcvars->{DOMAIN} : ldap_server = ad
517 idmap config $dcvars->{DOMAIN} : bind_path_user = ou=idmap,dc=samba,dc=example,dc=com
518 idmap config $dcvars->{DOMAIN} : bind_path_group = ou=idmap,dc=samba,dc=example,dc=com
520 password server = $dcvars->{SERVER}
523 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
527 $dcvars->{SERVER_IP},
528 $dcvars->{SERVER_IPV6});
530 $ret or return undef;
533 $ret->{DOMAIN} = $dcvars->{DOMAIN};
534 $ret->{REALM} = $dcvars->{REALM};
535 $ret->{DOMSID} = $dcvars->{DOMSID};
538 my $prefix_abs = abs_path($prefix);
540 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
541 $ctx->{domain} = $dcvars->{DOMAIN};
542 $ctx->{realm} = $dcvars->{REALM};
543 $ctx->{dnsname} = lc($dcvars->{REALM});
544 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
545 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
546 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
547 Samba::mk_krb5_conf($ctx, "");
549 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
550 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
552 my $net = Samba::bindir_path($self, "net");
553 # Add hosts file for name lookups
554 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
555 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
556 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
557 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
559 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
561 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
562 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
563 $cmd .= "$net join $ret->{CONFIGURATION}";
564 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
566 if (system($cmd) != 0) {
567 warn("Join failed\n$cmd");
571 # We need world access to this share, as otherwise the domain
572 # administrator from the AD domain provided by Samba4 can't
573 # access the share for tests.
574 chmod 0777, "$prefix/share";
576 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
580 $ret->{DC_SERVER} = $dcvars->{SERVER};
581 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
582 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
583 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
584 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
585 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
590 sub setup_ad_member_idmap_rid
592 my ($self, $prefix, $dcvars) = @_;
594 # If we didn't build with ADS, pretend this env was never available
595 if (not $self->have_ads()) {
599 print "PROVISIONING S3 AD MEMBER WITH idmap_rid config...";
601 my $member_options = "
603 workgroup = $dcvars->{DOMAIN}
604 realm = $dcvars->{REALM}
605 idmap config * : backend = tdb
606 idmap config * : range = 1000000-1999999
607 idmap config $dcvars->{DOMAIN} : backend = rid
608 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
609 # Prevent overridding the provisioned lib/krb5.conf which sets certain
610 # values required for tests to succeed
611 create krb5 conf = no
614 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
618 $dcvars->{SERVER_IP},
619 $dcvars->{SERVER_IPV6});
621 $ret or return undef;
624 $ret->{DOMAIN} = $dcvars->{DOMAIN};
625 $ret->{REALM} = $dcvars->{REALM};
626 $ret->{DOMSID} = $dcvars->{DOMSID};
629 my $prefix_abs = abs_path($prefix);
631 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
632 $ctx->{domain} = $dcvars->{DOMAIN};
633 $ctx->{realm} = $dcvars->{REALM};
634 $ctx->{dnsname} = lc($dcvars->{REALM});
635 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
636 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
637 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
638 Samba::mk_krb5_conf($ctx, "");
640 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
641 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
643 my $net = Samba::bindir_path($self, "net");
644 # Add hosts file for name lookups
645 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
646 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
647 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
648 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
650 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
652 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
653 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
654 $cmd .= "$net join $ret->{CONFIGURATION}";
655 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
657 if (system($cmd) != 0) {
658 warn("Join failed\n$cmd");
662 # We need world access to this share, as otherwise the domain
663 # administrator from the AD domain provided by Samba4 can't
664 # access the share for tests.
665 chmod 0777, "$prefix/share";
667 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
671 $ret->{DC_SERVER} = $dcvars->{SERVER};
672 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
673 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
674 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
675 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
676 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
681 sub setup_ad_member_idmap_ad
683 my ($self, $prefix, $dcvars) = @_;
685 # If we didn't build with ADS, pretend this env was never available
686 if (not $self->have_ads()) {
690 print "PROVISIONING S3 AD MEMBER WITH idmap_ad config...";
692 my $member_options = "
694 workgroup = $dcvars->{DOMAIN}
695 realm = $dcvars->{REALM}
696 password server = $dcvars->{SERVER}
697 idmap config * : backend = tdb
698 idmap config * : range = 1000000-1999999
699 idmap config $dcvars->{DOMAIN} : backend = ad
700 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
703 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
707 $dcvars->{SERVER_IP},
708 $dcvars->{SERVER_IPV6});
710 $ret or return undef;
713 $ret->{DOMAIN} = $dcvars->{DOMAIN};
714 $ret->{REALM} = $dcvars->{REALM};
715 $ret->{DOMSID} = $dcvars->{DOMSID};
718 my $prefix_abs = abs_path($prefix);
720 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
721 $ctx->{domain} = $dcvars->{DOMAIN};
722 $ctx->{realm} = $dcvars->{REALM};
723 $ctx->{dnsname} = lc($dcvars->{REALM});
724 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
725 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
726 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
727 Samba::mk_krb5_conf($ctx, "");
729 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
730 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
732 my $net = Samba::bindir_path($self, "net");
733 # Add hosts file for name lookups
734 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
735 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
736 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
737 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
739 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
741 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
742 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
743 $cmd .= "$net join $ret->{CONFIGURATION}";
744 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
746 if (system($cmd) != 0) {
747 warn("Join failed\n$cmd");
751 # We need world access to this share, as otherwise the domain
752 # administrator from the AD domain provided by Samba4 can't
753 # access the share for tests.
754 chmod 0777, "$prefix/share";
756 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
760 $ret->{DC_SERVER} = $dcvars->{SERVER};
761 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
762 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
763 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
764 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
765 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
770 sub setup_simpleserver
772 my ($self, $path) = @_;
774 print "PROVISIONING simple server...";
776 my $prefix_abs = abs_path($path);
778 my $simpleserver_options = "
781 vfs objects = xattr_tdb streams_depot
786 path = $prefix_abs/share
788 vfs objects = aio_pthread
789 aio_pthread:aio open = yes
790 smbd:async dosmode = no
792 [vfs_aio_pthread_async_dosmode_default1]
793 path = $prefix_abs/share
795 vfs objects = aio_pthread
796 store dos attributes = yes
797 aio_pthread:aio open = yes
798 smbd:async dosmode = yes
800 [vfs_aio_pthread_async_dosmode_default2]
801 path = $prefix_abs/share
803 vfs objects = aio_pthread xattr_tdb
804 store dos attributes = yes
805 aio_pthread:aio open = yes
806 smbd:async dosmode = yes
808 [vfs_aio_pthread_async_dosmode_force_sync1]
809 path = $prefix_abs/share
811 vfs objects = aio_pthread
812 store dos attributes = yes
813 aio_pthread:aio open = yes
814 smbd:async dosmode = yes
815 # This simulates non linux systems
816 smbd:force sync user path safe threadpool = yes
817 smbd:force sync user chdir safe threadpool = yes
818 smbd:force sync root path safe threadpool = yes
819 smbd:force sync root chdir safe threadpool = yes
821 [vfs_aio_pthread_async_dosmode_force_sync2]
822 path = $prefix_abs/share
824 vfs objects = aio_pthread xattr_tdb
825 store dos attributes = yes
826 aio_pthread:aio open = yes
827 smbd:async dosmode = yes
828 # This simulates non linux systems
829 smbd:force sync user path safe threadpool = yes
830 smbd:force sync user chdir safe threadpool = yes
831 smbd:force sync root path safe threadpool = yes
832 smbd:force sync root chdir safe threadpool = yes
835 path = $prefix_abs/share
836 vfs objects = aio_fork
838 vfs_aio_fork:erratic_testing_mode=yes
841 path = $prefix_abs/share
843 store dos attributes = yes
844 hide files = /hidefile/
848 path = $prefix_abs/share
850 smb encrypt = desired
853 path = $prefix_abs/share
854 hide new files timeout = 5
857 my $vars = $self->provision($path, "WORKGROUP",
860 $simpleserver_options);
862 $vars or return undef;
864 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
873 my ($self, $path) = @_;
874 my $prefix_abs = abs_path($path);
875 my $srcdir_abs = abs_path($self->{srcdir});
877 print "PROVISIONING file server ...\n";
881 mkdir($prefix_abs, 0777);
883 my $usershare_dir="$prefix_abs/lib/usershare";
885 mkdir("$prefix_abs/lib", 0755);
886 remove_tree($usershare_dir);
887 mkdir($usershare_dir, 01770);
889 my $share_dir="$prefix_abs/share";
891 # Create share directory structure
892 my $lower_case_share_dir="$share_dir/lower-case";
893 push(@dirs, $lower_case_share_dir);
895 my $lower_case_share_dir_30000="$share_dir/lower-case-30000";
896 push(@dirs, $lower_case_share_dir_30000);
898 my $dfree_share_dir="$share_dir/dfree";
899 push(@dirs, $dfree_share_dir);
900 push(@dirs, "$dfree_share_dir/subdir1");
901 push(@dirs, "$dfree_share_dir/subdir2");
902 push(@dirs, "$dfree_share_dir/subdir3");
904 my $quotadir_dir="$share_dir/quota";
905 push(@dirs, $quotadir_dir);
907 my $valid_users_sharedir="$share_dir/valid_users";
908 push(@dirs,$valid_users_sharedir);
910 my $offline_sharedir="$share_dir/offline";
911 push(@dirs,$offline_sharedir);
913 my $force_user_valid_users_dir = "$share_dir/force_user_valid_users";
914 push(@dirs, $force_user_valid_users_dir);
916 my $smbget_sharedir="$share_dir/smbget";
917 push(@dirs,$smbget_sharedir);
919 my $tarmode_sharedir="$share_dir/tarmode";
920 push(@dirs,$tarmode_sharedir);
922 my $usershare_sharedir="$share_dir/usershares";
923 push(@dirs,$usershare_sharedir);
925 my $fileserver_options = "
926 kernel change notify = yes
928 usershare path = $usershare_dir
929 usershare max shares = 10
930 usershare allow guests = yes
931 usershare prefix allow list = $usershare_sharedir
933 get quota command = $prefix_abs/getset_quota.py
934 set quota command = $prefix_abs/getset_quota.py
936 path = $lower_case_share_dir
937 comment = smb username is [%U]
938 case sensitive = True
941 short preserve case = no
943 path = $lower_case_share_dir_30000
944 comment = smb username is [%U]
945 case sensitive = True
948 short preserve case = no
950 path = $dfree_share_dir
951 comment = smb username is [%U]
952 dfree command = $srcdir_abs/testprogs/blackbox/dfree.sh
954 path = $valid_users_sharedir
955 valid users = +userdup
957 path = $offline_sharedir
958 vfs objects = offline
960 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878
961 # RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651
962 [force_user_valid_users]
963 path = $force_user_valid_users_dir
964 comment = force user with valid users combination test share
965 valid users = +force_user
966 force user = force_user
967 force group = everyone
968 write list = force_user
971 path = $smbget_sharedir
972 comment = smb username is [%U]
976 comment = ignore system acls
977 acl_xattr:ignore system acls = yes
980 comment = inherit owner
984 comment = inherit only unix owner
985 inherit owner = unix only
986 acl_xattr:ignore system acls = yes
988 comment = Home directories
993 my $vars = $self->provision($path, "WORKGROUP",
1001 $vars or return undef;
1003 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
1008 mkdir($_, 0777) foreach(@dirs);
1010 ## Create case sensitive lower case share dir
1011 foreach my $file ('a'..'z') {
1012 my $full_path = $lower_case_share_dir . '/' . $file;
1013 open my $fh, '>', $full_path;
1014 # Add some content to file
1015 print $fh $full_path;
1019 for (my $file = 1; $file < 51; ++$file) {
1020 my $full_path = $lower_case_share_dir . '/' . $file;
1021 open my $fh, '>', $full_path;
1022 # Add some content to file
1023 print $fh $full_path;
1027 # Create content for 30000 share
1028 foreach my $file ('a'..'z') {
1029 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1030 open my $fh, '>', $full_path;
1031 # Add some content to file
1032 print $fh $full_path;
1036 for (my $file = 1; $file < 30001; ++$file) {
1037 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1038 open my $fh, '>', $full_path;
1039 # Add some content to file
1040 print $fh $full_path;
1045 ## create a listable file in valid_users_share
1047 my $valid_users_target = "$valid_users_sharedir/foo";
1048 unless (open(VALID_USERS_TARGET, ">$valid_users_target")) {
1049 warn("Unable to open $valid_users_target");
1052 close(VALID_USERS_TARGET);
1053 chmod 0644, $valid_users_target;
1060 my ($self, $prefix) = @_;
1062 # If we didn't build with ADS, pretend this env was never available
1063 if (not $self->have_ads()) {
1067 print "PROVISIONING server with security=ads...";
1069 my $ktest_options = "
1071 realm = ktest.samba.example.com
1073 username map = $prefix/lib/username.map
1074 server signing = required
1075 server min protocol = SMB3_00
1076 client max protocol = SMB3
1078 # This disables NTLM auth against the local SAM, which
1079 # we use can then test this setting by.
1080 ntlm auth = disabled
1083 my $ret = $self->provision($prefix, "KTEST",
1088 $ret or return undef;
1091 my $prefix_abs = abs_path($prefix);
1093 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1094 $ctx->{domain} = "KTEST";
1095 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
1096 $ctx->{dnsname} = lc($ctx->{realm});
1097 $ctx->{kdc_ipv4} = "0.0.0.0";
1098 $ctx->{kdc_ipv6} = "::";
1099 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1100 Samba::mk_krb5_conf($ctx, "");
1102 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1104 open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map");
1106 $ret->{USERNAME} = KTEST\\Administrator
1110 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
1111 #Samba4 DC with the same parameters as are being used here. The
1112 #domain SID is S-1-5-21-1071277805-689288055-3486227160
1113 $ret->{SAMSID} = "S-1-5-21-1911091480-1468226576-2729736297";
1114 $ret->{DOMSID} = "S-1-5-21-1071277805-689288055-3486227160";
1116 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
1117 chmod 0600, "$prefix/private/secrets.tdb";
1119 #Make sure there's no old ntdb file.
1120 system("rm -f $prefix/private/secrets.ntdb");
1122 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
1123 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
1125 #and having in krb5.conf:
1126 # ticket_lifetime = 799718400
1127 # renew_lifetime = 799718400
1129 # The commands for the -2 keytab where were:
1130 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
1131 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
1132 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
1133 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1134 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1136 # and then for the -3 keytab, I did
1138 # net changetrustpw; kdestroy and the same again.
1140 # This creates a credential cache with a very long lifetime (2036 at
1141 # at 2011-04), and shows that running 'net changetrustpw' does not
1142 # break existing logins (for the secrets.tdb method at least).
1145 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
1147 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
1148 chmod 0600, "$prefix/krb5_ccache-2";
1150 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
1151 chmod 0600, "$prefix/krb5_ccache-3";
1153 # We need world access to this share, as otherwise the domain
1154 # administrator from the AD domain provided by ktest can't
1155 # access the share for tests.
1156 chmod 0777, "$prefix/share";
1158 if (not $self->check_or_start($ret, "yes", "no", "yes")) {
1164 sub setup_maptoguest
1166 my ($self, $path) = @_;
1168 print "PROVISIONING maptoguest...";
1171 map to guest = bad user
1175 my $vars = $self->provision($path, "WORKGROUP",
1180 $vars or return undef;
1182 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
1189 sub stop_sig_term($$) {
1190 my ($self, $pid) = @_;
1191 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1194 sub stop_sig_kill($$) {
1195 my ($self, $pid) = @_;
1196 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1201 my ($env_vars, $app, $pid) = @_;
1203 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
1210 my ($env_vars, $app) = @_;
1212 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
1218 sub check_or_start($$$$$) {
1219 my ($self, $env_vars, $nmbd, $winbindd, $smbd) = @_;
1221 # use a pipe for stdin in the child processes. This allows
1222 # those processes to monitor the pipe for EOF to ensure they
1223 # exit when the test script exits
1224 pipe(STDIN_READER, $env_vars->{STDIN_PIPE});
1226 unlink($env_vars->{NMBD_TEST_LOG});
1227 print "STARTING NMBD...";
1230 open STDOUT, ">$env_vars->{NMBD_TEST_LOG}";
1231 open STDERR, '>&STDOUT';
1233 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1235 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1236 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.nmbd";
1237 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1238 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1240 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1241 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1242 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1243 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1244 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1245 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1246 $ENV{UID_WRAPPER_ROOT} = "1";
1248 $ENV{ENVNAME} = "$ENV{ENVNAME}.nmbd";
1250 if ($nmbd ne "yes") {
1251 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1252 my $signame = shift;
1253 print("Skip nmbd received signal $signame");
1256 sleep($self->{server_maxtime});
1260 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "nmbd");
1261 my @optargs = ("-d0");
1262 if (defined($ENV{NMBD_OPTIONS})) {
1263 @optargs = split(/ /, $ENV{NMBD_OPTIONS});
1265 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1266 if(defined($ENV{NMBD_VALGRIND})) {
1267 @preargs = split(/ /, $ENV{NMBD_VALGRIND});
1269 my @args = ("-F", "--no-process-group",
1270 "-s", $env_vars->{SERVERCONFFILE},
1271 "-l", $env_vars->{LOGDIR});
1272 if (not defined($ENV{NMBD_DONT_LOG_STDOUT})) {
1273 push(@args, "--log-stdout");
1276 close($env_vars->{STDIN_PIPE});
1277 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1279 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1280 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1282 $env_vars->{NMBD_TL_PID} = $pid;
1283 write_pid($env_vars, "nmbd", $pid);
1286 unlink($env_vars->{WINBINDD_TEST_LOG});
1287 print "STARTING WINBINDD...";
1290 open STDOUT, ">$env_vars->{WINBINDD_TEST_LOG}";
1291 open STDERR, '>&STDOUT';
1293 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1295 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1296 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.winbindd";
1297 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1298 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1300 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1301 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1302 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1303 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1304 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1305 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1306 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
1307 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
1309 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
1311 $ENV{UID_WRAPPER_ROOT} = "1";
1313 $ENV{ENVNAME} = "$ENV{ENVNAME}.winbindd";
1315 if ($winbindd ne "yes") {
1316 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1317 my $signame = shift;
1318 print("Skip winbindd received signal $signame");
1321 sleep($self->{server_maxtime});
1325 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "winbindd");
1326 my @optargs = ("-d0");
1327 if (defined($ENV{WINBINDD_OPTIONS})) {
1328 @optargs = split(/ /, $ENV{WINBINDD_OPTIONS});
1330 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1331 if(defined($ENV{WINBINDD_VALGRIND})) {
1332 @preargs = split(/ /, $ENV{WINBINDD_VALGRIND});
1334 my @args = ("-F", "--no-process-group",
1335 "-s", $env_vars->{SERVERCONFFILE},
1336 "-l", $env_vars->{LOGDIR});
1337 if (not defined($ENV{WINBINDD_DONT_LOG_STDOUT})) {
1338 push(@args, "--stdout");
1341 close($env_vars->{STDIN_PIPE});
1342 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1344 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1345 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1347 $env_vars->{WINBINDD_TL_PID} = $pid;
1348 write_pid($env_vars, "winbindd", $pid);
1351 unlink($env_vars->{SMBD_TEST_LOG});
1352 print "STARTING SMBD...";
1355 open STDOUT, ">$env_vars->{SMBD_TEST_LOG}";
1356 open STDERR, '>&STDOUT';
1358 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1360 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1361 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.smbd";
1362 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1363 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1365 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1366 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1367 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1368 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1369 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1370 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1371 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
1372 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
1374 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
1376 $ENV{UID_WRAPPER_ROOT} = "1";
1378 $ENV{ENVNAME} = "$ENV{ENVNAME}.smbd";
1380 if ($smbd ne "yes") {
1381 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1382 my $signame = shift;
1383 print("Skip smbd received signal $signame");
1386 sleep($self->{server_maxtime});
1390 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "smbd");
1391 my @optargs = ("-d0");
1392 if (defined($ENV{SMBD_OPTIONS})) {
1393 @optargs = split(/ /, $ENV{SMBD_OPTIONS});
1395 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1396 if(defined($ENV{SMBD_VALGRIND})) {
1397 @preargs = split(/ /,$ENV{SMBD_VALGRIND});
1399 my @args = ("-F", "--no-process-group",
1400 "-s", $env_vars->{SERVERCONFFILE},
1401 "-l", $env_vars->{LOGDIR});
1402 if (not defined($ENV{SMBD_DONT_LOG_STDOUT})) {
1403 push(@args, "--log-stdout");
1406 close($env_vars->{STDIN_PIPE});
1407 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1409 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1410 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1412 $env_vars->{SMBD_TL_PID} = $pid;
1413 write_pid($env_vars, "smbd", $pid);
1416 close(STDIN_READER);
1418 return $self->wait_for_start($env_vars, $nmbd, $winbindd, $smbd);
1421 sub createuser($$$$$)
1423 my ($self, $username, $password, $conffile, $env) = @_;
1424 my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $username > /dev/null";
1427 while(my($var, $val) = each %$env) {
1428 $cmd = "$var=\"$val\" $cmd";
1431 unless (open(PWD, "|$cmd")) {
1432 warn("Unable to set password for $username account\n$cmd");
1435 print PWD "$password\n$password\n";
1436 unless (close(PWD)) {
1437 warn("Unable to set password for $username account\n$cmd");
1442 sub provision($$$$$$$$$)
1444 my ($self, $prefix, $domain, $server, $password, $extra_options, $dc_server_ip, $dc_server_ipv6, $no_delete_prefix) = @_;
1447 ## setup the various environment variables we need
1450 my $samsid = Samba::random_domain_sid();
1451 my $swiface = Samba::get_interface($server);
1453 my %createuser_env = ();
1454 my $server_ip = "127.0.0.$swiface";
1455 my $server_ipv6 = sprintf("fd00:0000:0000:0000:0000:0000:5357:5f%02x", $swiface);
1457 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
1460 my $unix_gids_str = $);
1461 my @unix_gids = split(" ", $unix_gids_str);
1463 my $prefix_abs = abs_path($prefix);
1464 my $bindir_abs = abs_path($self->{bindir});
1468 my $shrdir="$prefix_abs/share";
1469 push(@dirs,$shrdir);
1471 my $libdir="$prefix_abs/lib";
1472 push(@dirs,$libdir);
1474 my $piddir="$prefix_abs/pid";
1475 push(@dirs,$piddir);
1477 my $privatedir="$prefix_abs/private";
1478 push(@dirs,$privatedir);
1480 my $binddnsdir = "$prefix_abs/bind-dns";
1481 push(@dirs, $binddnsdir);
1483 my $lockdir="$prefix_abs/lockdir";
1484 push(@dirs,$lockdir);
1486 my $eventlogdir="$prefix_abs/lockdir/eventlog";
1487 push(@dirs,$eventlogdir);
1489 my $logdir="$prefix_abs/logs";
1490 push(@dirs,$logdir);
1492 my $driver32dir="$shrdir/W32X86";
1493 push(@dirs,$driver32dir);
1495 my $driver64dir="$shrdir/x64";
1496 push(@dirs,$driver64dir);
1498 my $driver40dir="$shrdir/WIN40";
1499 push(@dirs,$driver40dir);
1501 my $ro_shrdir="$shrdir/root-tmp";
1502 push(@dirs,$ro_shrdir);
1504 my $msdfs_shrdir="$shrdir/msdfsshare";
1505 push(@dirs,$msdfs_shrdir);
1507 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
1508 push(@dirs,$msdfs_deeppath);
1510 my $badnames_shrdir="$shrdir/badnames";
1511 push(@dirs,$badnames_shrdir);
1513 my $lease1_shrdir="$shrdir/SMB2_10";
1514 push(@dirs,$lease1_shrdir);
1516 my $lease2_shrdir="$shrdir/SMB3_00";
1517 push(@dirs,$lease2_shrdir);
1519 my $manglenames_shrdir="$shrdir/manglenames";
1520 push(@dirs,$manglenames_shrdir);
1522 my $widelinks_shrdir="$shrdir/widelinks";
1523 push(@dirs,$widelinks_shrdir);
1525 my $widelinks_linkdir="$shrdir/widelinks_foo";
1526 push(@dirs,$widelinks_linkdir);
1528 my $shadow_tstdir="$shrdir/shadow";
1529 push(@dirs,$shadow_tstdir);
1530 my $shadow_mntdir="$shadow_tstdir/mount";
1531 push(@dirs,$shadow_mntdir);
1532 my $shadow_basedir="$shadow_mntdir/base";
1533 push(@dirs,$shadow_basedir);
1534 my $shadow_shrdir="$shadow_basedir/share";
1535 push(@dirs,$shadow_shrdir);
1537 my $nosymlinks_shrdir="$shrdir/nosymlinks";
1538 push(@dirs,$nosymlinks_shrdir);
1540 my $local_symlinks_shrdir="$shrdir/local_symlinks";
1541 push(@dirs,$local_symlinks_shrdir);
1543 # this gets autocreated by winbindd
1544 my $wbsockdir="$prefix_abs/winbindd";
1546 my $nmbdsockdir="$prefix_abs/nmbd";
1547 unlink($nmbdsockdir);
1550 ## create the test directory layout
1552 die ("prefix_abs = ''") if $prefix_abs eq "";
1553 die ("prefix_abs = '/'") if $prefix_abs eq "/";
1555 mkdir($prefix_abs, 0777);
1556 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
1557 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
1558 system("rm -rf $prefix_abs/*");
1560 mkdir($_, 0777) foreach(@dirs);
1562 my $fs_specific_conf = $self->get_fs_specific_conf($shrdir);
1565 ## lockdir and piddir must be 0755
1567 chmod 0755, $lockdir;
1568 chmod 0755, $piddir;
1572 ## create ro and msdfs share layout
1575 chmod 0755, $ro_shrdir;
1576 my $unreadable_file = "$ro_shrdir/unreadable_file";
1577 unless (open(UNREADABLE_FILE, ">$unreadable_file")) {
1578 warn("Unable to open $unreadable_file");
1581 close(UNREADABLE_FILE);
1582 chmod 0600, $unreadable_file;
1584 my $msdfs_target = "$ro_shrdir/msdfs-target";
1585 unless (open(MSDFS_TARGET, ">$msdfs_target")) {
1586 warn("Unable to open $msdfs_target");
1589 close(MSDFS_TARGET);
1590 chmod 0666, $msdfs_target;
1591 symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp",
1592 "$msdfs_shrdir/msdfs-src1";
1593 symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
1596 ## create bad names in $badnames_shrdir
1598 ## (An invalid name, would be mangled to 8.3).
1599 my $badname_target = "$badnames_shrdir/\340|\231\216\377\177";
1600 unless (open(BADNAME_TARGET, ">$badname_target")) {
1601 warn("Unable to open $badname_target");
1604 close(BADNAME_TARGET);
1605 chmod 0666, $badname_target;
1607 ## (A bad name, would not be mangled to 8.3).
1608 my $badname_target = "$badnames_shrdir/\240\276\346\327\377\177";
1609 unless (open(BADNAME_TARGET, ">$badname_target")) {
1610 warn("Unable to open $badname_target");
1613 close(BADNAME_TARGET);
1614 chmod 0666, $badname_target;
1616 ## (A bad good name).
1617 my $badname_target = "$badnames_shrdir/blank.txt";
1618 unless (open(BADNAME_TARGET, ">$badname_target")) {
1619 warn("Unable to open $badname_target");
1622 close(BADNAME_TARGET);
1623 chmod 0666, $badname_target;
1626 ## create mangleable directory names in $manglenames_shrdir
1628 my $manglename_target = "$manglenames_shrdir/foo:bar";
1629 mkdir($manglename_target, 0777);
1632 ## create symlinks for widelinks tests.
1634 my $widelinks_target = "$widelinks_linkdir/target";
1635 unless (open(WIDELINKS_TARGET, ">$widelinks_target")) {
1636 warn("Unable to open $widelinks_target");
1639 close(WIDELINKS_TARGET);
1640 chmod 0666, $widelinks_target;
1642 ## This link should get ACCESS_DENIED
1644 symlink "$widelinks_target", "$widelinks_shrdir/source";
1646 ## This link should be allowed
1648 symlink "$widelinks_shrdir", "$widelinks_shrdir/dot";
1650 my $conffile="$libdir/server.conf";
1651 my $dfqconffile="$libdir/dfq.conf";
1652 my $errorinjectconf="$libdir/error_inject.conf";
1653 my $delayinjectconf="$libdir/delay_inject.conf";
1655 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/third_party/nss_wrapper/nss_wrapper.pl";
1656 my $nss_wrapper_passwd = "$privatedir/passwd";
1657 my $nss_wrapper_group = "$privatedir/group";
1658 my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts";
1659 my $resolv_conf = "$privatedir/resolv.conf";
1660 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
1662 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
1664 my $fake_snap_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/fake_snap.pl";
1666 my @eventlog_list = ("dns server", "application");
1669 ## calculate uids and gids
1672 my ($max_uid, $max_gid);
1673 my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
1674 my ($uid_pdbtest_wkn);
1676 my ($uid_force_user);
1677 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
1678 my ($gid_userdup, $gid_everyone);
1679 my ($gid_force_user);
1684 my ($uid_slashuser);
1686 if ($unix_uid < 0xffff - 13) {
1689 $max_uid = $unix_uid;
1692 $uid_root = $max_uid - 1;
1693 $uid_nobody = $max_uid - 2;
1694 $uid_pdbtest = $max_uid - 3;
1695 $uid_pdbtest2 = $max_uid - 4;
1696 $uid_userdup = $max_uid - 5;
1697 $uid_pdbtest_wkn = $max_uid - 6;
1698 $uid_force_user = $max_uid - 7;
1699 $uid_smbget = $max_uid - 8;
1700 $uid_user1 = $max_uid - 9;
1701 $uid_user2 = $max_uid - 10;
1702 $uid_gooduser = $max_uid - 11;
1703 $uid_eviluser = $max_uid - 12;
1704 $uid_slashuser = $max_uid - 13;
1706 if ($unix_gids[0] < 0xffff - 8) {
1709 $max_gid = $unix_gids[0];
1712 $gid_nobody = $max_gid - 1;
1713 $gid_nogroup = $max_gid - 2;
1714 $gid_root = $max_gid - 3;
1715 $gid_domusers = $max_gid - 4;
1716 $gid_domadmins = $max_gid - 5;
1717 $gid_userdup = $max_gid - 6;
1718 $gid_everyone = $max_gid - 7;
1719 $gid_force_user = $max_gid - 8;
1725 unless (open(CONF, ">$conffile")) {
1726 warn("Unable to open $conffile");
1731 netbios name = $server
1732 interfaces = $server_ip/8 $server_ipv6/64
1733 bind interfaces only = yes
1734 panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
1735 smbd:suicide mode = yes
1739 private dir = $privatedir
1740 binddns dir = $binddnsdir
1741 pid directory = $piddir
1742 lock directory = $lockdir
1743 log file = $logdir/log.\%m
1748 state directory = $lockdir
1749 cache directory = $lockdir
1751 passdb backend = tdbsam
1755 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1756 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
1757 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1758 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
1759 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
1760 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
1761 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
1763 addprinter command = $mod_printer_pl -a -s $conffile --
1764 deleteprinter command = $mod_printer_pl -d -s $conffile --
1766 eventlog list = application \"dns server\"
1769 kernel change notify = no
1773 printcap name = /dev/null
1775 winbindd socket directory = $wbsockdir
1776 nmbd:socket dir = $nmbdsockdir
1777 idmap config * : range = 100000-200000
1778 winbind enum users = yes
1779 winbind enum groups = yes
1780 winbind separator = /
1781 include system krb5 conf = no
1783 # min receivefile size = 4000
1787 smbd:sharedelay = 100000
1788 smbd:writetimeupdatedelay = 500000
1792 store dos attributes = yes
1797 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot time_audit full_audit
1799 full_audit:syslog = no
1800 full_audit:success = none
1801 full_audit:failure = none
1804 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
1805 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
1806 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
1807 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
1808 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
1809 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
1810 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
1812 print notify backchannel = yes
1814 ncalrpc dir = $prefix_abs/ncalrpc
1816 # The samba3.blackbox.smbclient_s3 test uses this to test that
1817 # sending messages works, and that the %m sub works.
1818 message command = mv %s $shrdir/message.%m
1820 # fsrvp server requires registry shares
1821 registry shares = yes
1823 # Used by RPC SRVSVC tests
1824 add share command = $bindir_abs/smbaddshare
1825 change share command = $bindir_abs/smbchangeshare
1826 delete share command = $bindir_abs/smbdeleteshare
1828 # fruit:copyfile is a global option
1829 fruit:copyfile = yes
1831 #this does not mean that we use non-secure test env,
1832 #it just means we ALLOW one to be configured.
1833 allow insecure wide links = yes
1835 # Begin extra options
1839 #Include user defined custom parameters if set
1842 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
1843 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
1849 comment = smb username is [%U]
1852 comment = Load dirsort module
1853 vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot
1856 comment = encrypt smb username is [%U]
1857 smb encrypt = required
1858 vfs objects = dirsort
1868 force user = $unix_name
1870 [forceuser_unixonly]
1871 comment = force a user with unix user SID and group SID
1873 force user = pdbtest
1875 [forceuser_wkngroup]
1876 comment = force a user with well-known group SID
1878 force user = pdbtest_wkn
1882 force group = nogroup
1890 write list = $unix_name
1893 valid users = $unix_name
1894 access based share enum = yes
1896 path = $msdfs_shrdir
1898 msdfs shuffle referrals = yes
1902 hide unreadable = yes
1905 case sensitive = yes
1908 hide unwriteable files = yes
1911 kernel share modes = no
1925 default devmode = no
1931 comment = smb username is [%U]
1933 nfs4acl_xattr:version = 40
1934 vfs objects = nfs4acl_xattr xattr_tdb
1936 [nfs4acl_special_40]
1938 comment = smb username is [%U]
1940 nfs4acl_xattr:version = 40
1941 vfs objects = nfs4acl_xattr xattr_tdb
1945 comment = smb username is [%U]
1947 vfs objects = nfs4acl_xattr xattr_tdb
1951 comment = smb username is [%U]
1952 vfs objects = nfs4acl_xattr xattr_tdb
1954 nfs4acl_xattr:encoding = xdr
1955 nfs4acl_xattr:version = 40
1959 comment = smb username is [%U]
1960 vfs objects = nfs4acl_xattr xattr_tdb
1962 nfs4acl_xattr:encoding = xdr
1963 nfs4acl_xattr:version = 41
1967 comment = smb username is [%U]
1969 force create mode = 777
1972 comment = smb username is [%U]
1974 force create mode = 0
1975 directory mask = 0777
1976 force directory mode = 0
1977 vfs objects = xattr_tdb streams_depot
1988 vfs objects = catia fruit streams_xattr acl_xattr xattr_tdb
1989 fruit:resource = file
1990 fruit:metadata = netatalk
1991 fruit:locking = netatalk
1992 fruit:encoding = native
1993 fruit:veto_appledouble = no
1997 # This is used by vfs.fruit tests that require real fs xattr
1998 vfs objects = catia fruit streams_xattr acl_xattr
1999 fruit:resource = file
2000 fruit:metadata = netatalk
2001 fruit:locking = netatalk
2002 fruit:encoding = native
2003 fruit:veto_appledouble = no
2005 [vfs_fruit_metadata_stream]
2007 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2008 fruit:resource = file
2009 fruit:metadata = stream
2010 fruit:veto_appledouble = no
2012 [vfs_fruit_stream_depot]
2014 vfs objects = fruit streams_depot acl_xattr xattr_tdb
2015 fruit:resource = stream
2016 fruit:metadata = stream
2017 fruit:veto_appledouble = no
2021 vfs objects = streams_xattr acl_xattr xattr_tdb
2023 [vfs_wo_fruit_stream_depot]
2025 vfs objects = streams_depot acl_xattr xattr_tdb
2027 [vfs_fruit_timemachine]
2029 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2030 fruit:resource = file
2031 fruit:metadata = stream
2032 fruit:time machine = yes
2033 fruit:time machine max size = 32K
2035 [vfs_fruit_wipe_intentionally_left_blank_rfork]
2037 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2038 fruit:resource = file
2039 fruit:metadata = stream
2040 fruit:wipe_intentionally_left_blank_rfork = true
2041 fruit:delete_empty_adfiles = false
2042 fruit:veto_appledouble = no
2044 [vfs_fruit_delete_empty_adfiles]
2046 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2047 fruit:resource = file
2048 fruit:metadata = stream
2049 fruit:wipe_intentionally_left_blank_rfork = true
2050 fruit:delete_empty_adfiles = true
2051 fruit:veto_appledouble = no
2054 path = $badnames_shrdir
2058 path = $manglenames_shrdir
2066 path = $widelinks_shrdir
2072 comment = fake shapshots using rsync
2073 vfs objects = shell_snap shadow_copy2
2074 shell_snap:check path command = $fake_snap_pl --check
2075 shell_snap:create command = $fake_snap_pl --create
2076 shell_snap:delete command = $fake_snap_pl --delete
2077 # a relative path here fails, the snapshot dir is no longer found
2078 shadow:snapdir = $shrdir/.snapshots
2081 path = $shadow_shrdir
2082 comment = previous versions snapshots under mount point
2083 vfs objects = shadow_copy2
2084 shadow:mountpoint = $shadow_mntdir
2087 path = $shadow_shrdir
2088 comment = previous versions snapshots outside mount point
2089 vfs objects = shadow_copy2
2090 shadow:mountpoint = $shadow_mntdir
2091 shadow:snapdir = $shadow_tstdir/.snapshots
2094 path = $shadow_shrdir
2095 comment = previous versions with subvolume snapshots, snapshots under base dir
2096 vfs objects = shadow_copy2
2097 shadow:mountpoint = $shadow_mntdir
2098 shadow:basedir = $shadow_basedir
2099 shadow:snapdir = $shadow_basedir/.snapshots
2102 path = $shadow_shrdir
2103 comment = previous versions with subvolume snapshots, snapshots outside mount point
2104 vfs objects = shadow_copy2
2105 shadow:mountpoint = $shadow_mntdir
2106 shadow:basedir = $shadow_basedir
2107 shadow:snapdir = $shadow_tstdir/.snapshots
2110 path = $shadow_shrdir
2111 comment = previous versions at volume root snapshots under mount point
2112 vfs objects = shadow_copy2
2113 shadow:mountpoint = $shadow_shrdir
2116 path = $shadow_shrdir
2117 comment = previous versions at volume root snapshots outside mount point
2118 vfs objects = shadow_copy2
2119 shadow:mountpoint = $shadow_shrdir
2120 shadow:snapdir = $shadow_tstdir/.snapshots
2123 path = $shadow_shrdir
2124 comment = previous versions snapshots everywhere
2125 vfs objects = shadow_copy2
2126 shadow:mountpoint = $shadow_mntdir
2127 shadow:snapdirseverywhere = yes
2130 path = $shadow_shrdir
2131 comment = previous versions using snapsharepath
2132 vfs objects = shadow_copy2
2133 shadow:mountpoint = $shadow_mntdir
2134 shadow:snapdir = $shadow_tstdir/.snapshots
2135 shadow:snapsharepath = share
2138 comment = Testing shadow:format with default option
2139 vfs object = shadow_copy2
2140 path = $shadow_shrdir
2143 shadow:mountpoint = $shadow_mntdir
2144 shadow:basedir = $shadow_basedir
2145 shadow:snapdir = $shadow_basedir/.snapshots
2146 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2149 comment = Testing shadow:format with only date component
2150 vfs object = shadow_copy2
2151 path = $shadow_shrdir
2154 shadow:mountpoint = $shadow_mntdir
2155 shadow:basedir = $shadow_basedir
2156 shadow:snapdir = $shadow_basedir/.snapshots
2157 shadow:format = \@GMT-%Y-%m-%d
2160 comment = Testing shadow:format with some hardcoded prefix
2161 vfs object = shadow_copy2
2162 path = $shadow_shrdir
2165 shadow:mountpoint = $shadow_mntdir
2166 shadow:basedir = $shadow_basedir
2167 shadow:snapdir = $shadow_basedir/.snapshots
2168 shadow:format = snap\@GMT-%Y.%m.%d-%H.%M.%S
2171 comment = Testing shadow:format with modified format
2172 vfs object = shadow_copy2
2173 path = $shadow_shrdir
2176 shadow:mountpoint = $shadow_mntdir
2177 shadow:basedir = $shadow_basedir
2178 shadow:snapdir = $shadow_basedir/.snapshots
2179 shadow:format = \@GMT-%Y.%m.%d-%H_%M_%S-snap
2182 comment = Testing shadow:snapprefix regex
2183 vfs object = shadow_copy2
2184 path = $shadow_shrdir
2187 shadow:mountpoint = $shadow_mntdir
2188 shadow:basedir = $shadow_basedir
2189 shadow:snapdir = $shadow_basedir/.snapshots
2190 shadow:snapprefix = \^s[a-z]*p\$
2191 shadow:format = _GMT-%Y.%m.%d-%H.%M.%S
2194 comment = Testing shadow:snapprefix with delim regex
2195 vfs object = shadow_copy2
2196 path = $shadow_shrdir
2199 shadow:mountpoint = $shadow_mntdir
2200 shadow:basedir = $shadow_basedir
2201 shadow:snapdir = $shadow_basedir/.snapshots
2202 shadow:delimiter = \@GMT
2203 shadow:snapprefix = [a-z]*
2204 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2207 path = $shadow_shrdir
2208 comment = previous versions with wide links allowed
2209 vfs objects = shadow_copy2
2210 shadow:mountpoint = $shadow_mntdir
2214 path = $shadow_tstdir
2215 comment = previous versions snapshots under mount point
2216 vfs objects = shadow_copy2 streams_xattr error_inject
2218 error_inject:pwrite = EBADF
2219 shadow:mountpoint = $shadow_tstdir
2222 path = $shrdir/dfree
2223 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2224 admin users = $unix_name
2225 include = $dfqconffile
2227 path = $shrdir/dfree
2228 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2229 admin users = $unix_name
2230 include = $dfqconffile
2231 dfree cache time = 60
2233 path = $shrdir/dfree
2234 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2236 include = $dfqconffile
2238 path = $shrdir/quota
2239 admin users = $unix_name
2241 [acl_xattr_ign_sysacl_posix]
2243 acl_xattr:ignore system acls = yes
2244 acl_xattr:default acl style = posix
2245 [acl_xattr_ign_sysacl_windows]
2247 acl_xattr:ignore system acls = yes
2248 acl_xattr:default acl style = windows
2252 mangled names = illegal
2256 path = $nosymlinks_shrdir
2257 follow symlinks = no
2261 path = $local_symlinks_shrdir
2262 follow symlinks = yes
2266 kernel oplocks = yes
2267 vfs objects = streams_xattr xattr_tdb
2271 vfs objects = streams_xattr xattr_tdb
2275 smbd:find async delay usec = 10000
2278 vfs objects = error_inject
2279 include = $errorinjectconf
2283 vfs objects = delay_inject
2284 kernel share modes = no
2287 include = $delayinjectconf
2291 vfs objects = delay_inject
2292 delay_inject:pread_send = 2000
2293 delay_inject:pwrite_send = 2000
2296 path = $prefix_abs/share
2297 delete readonly = yes
2301 my $net = Samba::bindir_path($self, "net");
2303 $cmd .= "SMB_CONF_PATH=\"$conffile\" ";
2304 $cmd .= "$net setlocalsid $samsid";
2306 if (system($cmd) != 0) {
2307 warn("Join failed\n$cmd");
2311 unless (open(ERRORCONF, ">$errorinjectconf")) {
2312 warn("Unable to open $errorinjectconf");
2317 unless (open(DELAYCONF, ">$delayinjectconf")) {
2318 warn("Unable to open $delayinjectconf");
2323 unless (open(DFQCONF, ">$dfqconffile")) {
2324 warn("Unable to open $dfqconffile");
2330 ## create a test account
2333 unless (open(PASSWD, ">$nss_wrapper_passwd")) {
2334 warn("Unable to open $nss_wrapper_passwd");
2337 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
2338 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
2339 pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2340 pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2341 userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
2342 pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false
2343 force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false
2344 smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false
2345 user1:x:$uid_user1:$gid_nogroup:user1 gecos:$prefix_abs:/bin/false
2346 user2:x:$uid_user2:$gid_nogroup:user2 gecos:$prefix_abs:/bin/false
2347 gooduser:x:$uid_gooduser:$gid_domusers:gooduser gecos:$prefix_abs:/bin/false
2348 eviluser:x:$uid_eviluser:$gid_domusers:eviluser gecos::/bin/false
2349 slashuser:x:$uid_slashuser:$gid_domusers:slashuser gecos:/:/bin/false
2351 if ($unix_uid != 0) {
2352 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
2357 unless (open(GROUP, ">$nss_wrapper_group")) {
2358 warn("Unable to open $nss_wrapper_group");
2361 print GROUP "nobody:x:$gid_nobody:
2362 nogroup:x:$gid_nogroup:nobody
2363 $unix_name-group:x:$unix_gids[0]:
2364 domusers:X:$gid_domusers:
2365 domadmins:X:$gid_domadmins:
2366 userdup:x:$gid_userdup:$unix_name
2367 everyone:x:$gid_everyone:
2368 force_user:x:$gid_force_user:
2370 if ($unix_gids[0] != 0) {
2371 print GROUP "root:x:$gid_root:
2378 my $hostname = lc($server);
2379 unless (open(HOSTS, ">>$nss_wrapper_hosts")) {
2380 warn("Unable to open $nss_wrapper_hosts");
2383 print HOSTS "${server_ip} ${hostname}.samba.example.com ${hostname}\n";
2384 print HOSTS "${server_ipv6} ${hostname}.samba.example.com ${hostname}\n";
2388 unless (open(RESOLV_CONF, ">$resolv_conf")) {
2389 warn("Unable to open $resolv_conf");
2392 if (defined($dc_server_ip) or defined($dc_server_ipv6)) {
2393 if (defined($dc_server_ip)) {
2394 print RESOLV_CONF "nameserver $dc_server_ip\n";
2396 if (defined($dc_server_ipv6)) {
2397 print RESOLV_CONF "nameserver $dc_server_ipv6\n";
2400 print RESOLV_CONF "nameserver ${server_ip}\n";
2401 print RESOLV_CONF "nameserver ${server_ipv6}\n";
2405 foreach my $evlog (@eventlog_list) {
2406 my $evlogtdb = "$eventlogdir/$evlog.tdb";
2407 open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
2411 $createuser_env{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2412 $createuser_env{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2413 $createuser_env{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2414 $createuser_env{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2415 if ($ENV{SAMBA_DNS_FAKING}) {
2416 $createuser_env{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2418 $createuser_env{RESOLV_WRAPPER_CONF} = $resolv_conf;
2421 createuser($self, $unix_name, $password, $conffile, \%createuser_env) || die("Unable to create user");
2422 createuser($self, "force_user", $password, $conffile, \%createuser_env) || die("Unable to create force_user");
2423 createuser($self, "smbget_user", $password, $conffile, \%createuser_env) || die("Unable to create smbget_user");
2424 createuser($self, "user1", $password, $conffile, \%createuser_env) || die("Unable to create user1");
2425 createuser($self, "user2", $password, $conffile, \%createuser_env) || die("Unable to create user2");
2426 createuser($self, "gooduser", $password, $conffile, \%createuser_env) || die("Unable to create gooduser");
2427 createuser($self, "eviluser", $password, $conffile, \%createuser_env) || die("Unable to create eviluser");
2428 createuser($self, "slashuser", $password, $conffile, \%createuser_env) || die("Unable to create slashuser");
2430 open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
2431 print DNS_UPDATE_LIST "A $server. $server_ip\n";
2432 print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n";
2433 close(DNS_UPDATE_LIST);
2437 $ret{SERVER_IP} = $server_ip;
2438 $ret{SERVER_IPV6} = $server_ipv6;
2439 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
2440 $ret{NMBD_TEST_LOG_POS} = 0;
2441 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
2442 $ret{WINBINDD_TEST_LOG_POS} = 0;
2443 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
2444 $ret{SMBD_TEST_LOG_POS} = 0;
2445 $ret{SERVERCONFFILE} = $conffile;
2446 $ret{CONFIGURATION} ="-s $conffile";
2447 $ret{LOCK_DIR} = $lockdir;
2448 $ret{SERVER} = $server;
2449 $ret{USERNAME} = $unix_name;
2450 $ret{USERID} = $unix_uid;
2451 $ret{DOMAIN} = $domain;
2452 $ret{SAMSID} = $samsid;
2453 $ret{NETBIOSNAME} = $server;
2454 $ret{PASSWORD} = $password;
2455 $ret{PIDDIR} = $piddir;
2456 $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir;
2457 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
2458 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
2459 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2460 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2461 $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2462 $ret{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2463 $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
2464 $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind";
2465 if ($ENV{SAMBA_DNS_FAKING}) {
2466 $ret{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2468 $ret{RESOLV_WRAPPER_CONF} = $resolv_conf;
2470 $ret{LOCAL_PATH} = "$shrdir";
2471 $ret{LOGDIR} = $logdir;
2474 # Avoid hitting system krb5.conf -
2475 # An env that needs Kerberos will reset this to the real
2478 $ret{KRB5_CONFIG} = abs_path($prefix) . "/no_krb5.conf";
2480 # Define KRB5CCNAME for each environment we set up
2481 $ret{KRB5_CCACHE} = abs_path($prefix) . "/krb5ccache";
2482 $ENV{KRB5CCNAME} = $ret{KRB5_CCACHE};
2487 sub wait_for_start($$$$$)
2489 my ($self, $envvars, $nmbd, $winbindd, $smbd) = @_;
2494 if ($nmbd eq "yes") {
2497 # give time for nbt server to register its names
2498 print "checking for nmbd\n";
2500 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
2501 my $nmblookup = Samba::bindir_path($self, "nmblookup");
2504 $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
2508 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
2509 system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
2510 system("$nmblookup $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
2511 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
2514 } while ($ret != 0 && $count < 10);
2516 print "NMBD not reachable after 10 retries\n";
2517 teardown_env($self, $envvars);
2522 if ($winbindd eq "yes") {
2523 print "checking for winbindd\n";
2525 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2526 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2527 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2528 $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping-dc";
2532 $ret = system($cmd);
2536 } while ($ret != 0 && $count < 20);
2538 print "WINBINDD not reachable after 20 seconds\n";
2539 teardown_env($self, $envvars);
2544 if ($smbd eq "yes") {
2545 # make sure smbd is also up set
2546 print "wait for smbd\n";
2550 $ret = system(Samba::bindir_path($self, "smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139");
2555 } while ($ret != 0 && $count < 20);
2557 print "SMBD failed to start up in a reasonable time (20sec)\n";
2558 teardown_env($self, $envvars);
2563 # Ensure we have domain users mapped.
2564 $netcmd = "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2565 $netcmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2566 $netcmd .= Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} ";
2568 $cmd = $netcmd . "groupmap delete ntgroup=domusers";
2569 $ret = system($cmd);
2571 $cmd = $netcmd . "groupmap add rid=513 unixgroup=domusers type=domain";
2572 $ret = system($cmd);
2574 print("\"$cmd\" failed\n");
2578 $cmd = $netcmd . "groupmap delete ntgroup=domadmins";
2579 $ret = system($cmd);
2581 $cmd = $netcmd . "groupmap add rid=512 unixgroup=domadmins type=domain";
2582 $ret = system($cmd);
2584 print("\"$cmd\" failed\n");
2588 $cmd = $netcmd . "groupmap delete ntgroup=everyone";
2589 $ret = system($cmd);
2591 $cmd = $netcmd . "groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin";
2592 $ret = system($cmd);
2594 print("\"$cmd\" failed\n");
2598 # note: creating builtin groups requires winbindd for the
2600 my $create_builtin_users = "no";
2601 if ($winbindd eq "yes") {
2602 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2603 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2604 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2605 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
2606 my $wbinfo_out = qx($cmd 2>&1);
2608 # wbinfo doesn't give us a better error code then
2609 # WBC_ERR_DOMAIN_NOT_FOUND, but at least that's
2610 # different then WBC_ERR_WINBIND_NOT_AVAILABLE
2611 if ($wbinfo_out !~ /WBC_ERR_DOMAIN_NOT_FOUND/) {
2612 print("Failed to run \"wbinfo --sid-to-gid=S-1-5-32-545\": $wbinfo_out");
2613 teardown_env($self, $envvars);
2616 $create_builtin_users = "yes";
2619 if ($create_builtin_users eq "yes") {
2620 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2621 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2622 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2623 $cmd .= Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
2624 $cmd .= "sam createbuiltingroup Users";
2625 $ret = system($cmd);
2627 print "Failed to create BUILTIN\\Users group\n";
2628 teardown_env($self, $envvars);
2632 $cmd = Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
2633 $cmd .= "cache del IDMAP/SID2XID/S-1-5-32-545";
2636 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2637 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2638 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2639 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
2640 $ret = system($cmd);
2642 print "Missing \"BUILTIN\\Users\", did net sam createbuiltingroup Users fail?\n";
2643 teardown_env($self, $envvars);
2648 print $self->getlog_env($envvars);