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.
10 use FindBin qw($RealBin);
13 use File::Path 'remove_tree';
18 my $smbd_build_options = Samba::bindir_path($self, "smbd") . " -b|";
19 open(IN, $smbd_build_options) or die("Unable to run $smbd_build_options: $!");
28 # If we were not built with ADS support, pretend we were never even available
29 print "smbd does not have ADS support\n" unless $found_ads;
33 # return smb.conf parameters applicable to @path, based on the underlying
35 sub get_fs_specific_conf($$)
37 my ($self, $path) = @_;
39 my $stat_out = `stat --file-system $path` or return "";
41 if ($stat_out =~ m/Type:\s+btrfs/) {
42 $mods .= "streams_xattr btrfs";
46 return "vfs objects = $mods";
53 my ($classname, $bindir, $srcdir, $server_maxtime) = @_;
54 my $self = { vars => {},
57 server_maxtime => $server_maxtime
65 my ($self, $envvars) = @_;
68 # This should cause smbd to terminate gracefully
69 close($envvars->{STDIN_PIPE});
71 my $smbdpid = $envvars->{SMBD_TL_PID};
72 my $nmbdpid = $envvars->{NMBD_TL_PID};
73 my $winbinddpid = $envvars->{WINBINDD_TL_PID};
75 # This should give it time to write out the gcov data
77 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
78 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
79 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
82 && $winbinddchild == -1) {
89 if ($count <= 20 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
93 $self->stop_sig_term($smbdpid);
94 $self->stop_sig_term($nmbdpid);
95 $self->stop_sig_term($winbinddpid);
99 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
100 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
101 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
104 && $winbinddchild == -1) {
111 if ($count <= 10 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
115 warn("timelimit process did not quit on SIGTERM, sending SIGKILL");
116 $self->stop_sig_kill($smbdpid);
117 $self->stop_sig_kill($nmbdpid);
118 $self->stop_sig_kill($winbinddpid);
123 sub getlog_env_app($$$)
125 my ($self, $envvars, $name) = @_;
127 my $title = "$name LOG of: $envvars->{NETBIOSNAME}\n";
130 open(LOG, "<".$envvars->{$name."_TEST_LOG"});
132 seek(LOG, $envvars->{$name."_TEST_LOG_POS"}, SEEK_SET);
136 $envvars->{$name."_TEST_LOG_POS"} = tell(LOG);
139 return "" if $out eq $title;
146 my ($self, $envvars) = @_;
149 $ret .= $self->getlog_env_app($envvars, "SMBD");
150 $ret .= $self->getlog_env_app($envvars, "NMBD");
151 $ret .= $self->getlog_env_app($envvars, "WINBINDD");
158 my ($self, $envvars) = @_;
160 my $childpid = waitpid(-1, WNOHANG);
166 # Declare the environments Samba3 makes available.
167 # To be set up, they will be called as
168 # samba3->setup_$envname($self, $path, $dep_1_vars, $dep_2_vars, ...)
169 %Samba3::ENV_DEPS = (
170 # name => [dep_1, dep_2, ...],
172 nt4_dc_schannel => [],
179 nt4_member => ["nt4_dc"],
181 ad_member => ["ad_dc"],
182 ad_member_rfc2307 => ["ad_dc_ntvfs"],
183 ad_member_idmap_rid => ["ad_dc"],
184 ad_member_idmap_ad => ["ad_dc"],
189 my ($self, $path) = @_;
191 print "PROVISIONING NT4 DC...";
193 my $nt4_dc_options = "
198 raw NTLMv2 auth = yes
199 server schannel = auto
201 rpc_server:epmapper = external
202 rpc_server:spoolss = external
203 rpc_server:lsarpc = external
204 rpc_server:samr = external
205 rpc_server:netlogon = external
206 rpc_server:register_embedded_np = yes
207 rpc_server:FssagentRpc = external
209 rpc_daemon:epmd = fork
210 rpc_daemon:spoolssd = fork
211 rpc_daemon:lsasd = fork
212 rpc_daemon:fssd = fork
213 fss: sequence timeout = 1
214 check parent directory delete on close = yes
217 my $vars = $self->provision($path, "SAMBA-TEST",
222 $vars or return undef;
224 if (not $self->check_or_start($vars, "yes", "yes", "yes")) {
228 $vars->{DOMSID} = $vars->{SAMSID};
229 $vars->{DC_SERVER} = $vars->{SERVER};
230 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
231 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
232 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
233 $vars->{DC_USERNAME} = $vars->{USERNAME};
234 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
239 sub setup_nt4_dc_schannel
241 my ($self, $path) = @_;
243 print "PROVISIONING NT4 DC WITH SERVER SCHANNEL ...";
250 rpc_server:epmapper = external
251 rpc_server:spoolss = external
252 rpc_server:lsarpc = external
253 rpc_server:samr = external
254 rpc_server:netlogon = external
255 rpc_server:register_embedded_np = yes
257 rpc_daemon:epmd = fork
258 rpc_daemon:spoolssd = fork
259 rpc_daemon:lsasd = fork
261 server schannel = yes
262 # used to reproduce bug #12772
263 server max protocol = SMB2_02
266 my $vars = $self->provision($path, "NT4SCHANNEL",
271 $vars or return undef;
273 if (not $self->check_or_start($vars, "yes", "yes", "yes")) {
277 $vars->{DOMSID} = $vars->{SAMSID};
278 $vars->{DC_SERVER} = $vars->{SERVER};
279 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
280 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
281 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
282 $vars->{DC_USERNAME} = $vars->{USERNAME};
283 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
290 my ($self, $prefix, $nt4_dc_vars) = @_;
294 print "PROVISIONING MEMBER...";
296 my $require_mutexes = "dbwrap_tdb_require_mutexes:* = yes";
297 $require_mutexes = "" if ($ENV{SELFTEST_DONT_REQUIRE_TDB_MUTEX_SUPPORT} eq "1");
299 my $member_options = "
301 dbwrap_tdb_mutexes:* = yes
304 my $ret = $self->provision($prefix, $nt4_dc_vars->{DOMAIN},
306 "localnt4member3pass",
309 $ret or return undef;
311 my $nmblookup = Samba::bindir_path($self, "nmblookup");
313 print "Waiting for the LOGON SERVER registration ...\n";
314 $rc = system("$nmblookup $ret->{CONFIGURATION} $ret->{DOMAIN}\#1c");
319 } while ($rc != 0 && $count < 10);
321 print "NMBD not reachable after 10 retries\n";
322 teardown_env($self, $ret);
326 my $net = Samba::bindir_path($self, "net");
327 # Add hosts file for name lookups
328 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
329 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
330 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
331 $cmd .= "$net rpc join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
332 $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}";
334 if (system($cmd) != 0) {
335 warn("Join failed\n$cmd");
339 # Add hosts file for name lookups
340 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
341 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
342 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
343 $cmd .= "$net $ret->{CONFIGURATION} primarytrust dumpinfo | grep -q 'REDACTED SECRET VALUES'";
345 if (system($cmd) != 0) {
346 warn("check failed\n$cmd");
350 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
354 $ret->{DOMSID} = $nt4_dc_vars->{DOMSID};
355 $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
356 $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
357 $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
358 $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME};
359 $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME};
360 $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD};
367 my ($self, $prefix, $dcvars) = @_;
369 my $prefix_abs = abs_path($prefix);
372 # If we didn't build with ADS, pretend this env was never available
373 if (not $self->have_ads()) {
377 print "PROVISIONING S3 AD MEMBER...";
379 mkdir($prefix_abs, 0777);
381 my $share_dir="$prefix_abs/share";
382 push(@dirs, $share_dir);
384 my $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}";
385 push(@dirs, $substitution_path);
387 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice";
388 push(@dirs, $substitution_path);
390 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice/G_domain users";
391 push(@dirs, $substitution_path);
393 # Using '/' as the winbind separator is a bad idea ...
394 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}";
395 push(@dirs, $substitution_path);
397 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice";
398 push(@dirs, $substitution_path);
400 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}";
401 push(@dirs, $substitution_path);
403 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}/domain users";
404 push(@dirs, $substitution_path);
406 my $member_options = "
408 workgroup = $dcvars->{DOMAIN}
409 realm = $dcvars->{REALM}
410 netbios aliases = foo bar
411 template homedir = /home/%D/%G/%U
414 path = $share_dir/D_%D/U_%U/G_%G
418 path = $share_dir/D_%D/u_%u/g_%g
423 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
427 $dcvars->{SERVER_IP},
428 $dcvars->{SERVER_IPV6});
430 $ret or return undef;
432 mkdir($_, 0777) foreach(@dirs);
435 $ret->{DOMAIN} = $dcvars->{DOMAIN};
436 $ret->{REALM} = $dcvars->{REALM};
437 $ret->{DOMSID} = $dcvars->{DOMSID};
441 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
442 $ctx->{domain} = $dcvars->{DOMAIN};
443 $ctx->{realm} = $dcvars->{REALM};
444 $ctx->{dnsname} = lc($dcvars->{REALM});
445 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
446 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
447 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
448 Samba::mk_krb5_conf($ctx, "");
450 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
452 my $net = Samba::bindir_path($self, "net");
453 # Add hosts file for name lookups
454 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
455 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
456 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
457 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
459 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
461 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
462 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
463 $cmd .= "$net join $ret->{CONFIGURATION}";
464 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
466 if (system($cmd) != 0) {
467 warn("Join failed\n$cmd");
471 # We need world access to this share, as otherwise the domain
472 # administrator from the AD domain provided by Samba4 can't
473 # access the share for tests.
474 chmod 0777, "$prefix/share";
476 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
480 $ret->{DC_SERVER} = $dcvars->{SERVER};
481 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
482 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
483 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
484 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
485 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
490 sub setup_ad_member_rfc2307
492 my ($self, $prefix, $dcvars) = @_;
494 # If we didn't build with ADS, pretend this env was never available
495 if (not $self->have_ads()) {
499 print "PROVISIONING S3 AD MEMBER WITH idmap_rfc2307 config...";
501 my $member_options = "
503 workgroup = $dcvars->{DOMAIN}
504 realm = $dcvars->{REALM}
506 idmap negative cache time = 0
507 idmap config * : backend = autorid
508 idmap config * : range = 1000000-1999999
509 idmap config * : rangesize = 100000
510 idmap config $dcvars->{DOMAIN} : backend = rfc2307
511 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
512 idmap config $dcvars->{DOMAIN} : ldap_server = ad
513 idmap config $dcvars->{DOMAIN} : bind_path_user = ou=idmap,dc=samba,dc=example,dc=com
514 idmap config $dcvars->{DOMAIN} : bind_path_group = ou=idmap,dc=samba,dc=example,dc=com
516 password server = $dcvars->{SERVER}
519 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
523 $dcvars->{SERVER_IP},
524 $dcvars->{SERVER_IPV6});
526 $ret or return undef;
529 $ret->{DOMAIN} = $dcvars->{DOMAIN};
530 $ret->{REALM} = $dcvars->{REALM};
531 $ret->{DOMSID} = $dcvars->{DOMSID};
534 my $prefix_abs = abs_path($prefix);
536 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
537 $ctx->{domain} = $dcvars->{DOMAIN};
538 $ctx->{realm} = $dcvars->{REALM};
539 $ctx->{dnsname} = lc($dcvars->{REALM});
540 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
541 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
542 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
543 Samba::mk_krb5_conf($ctx, "");
545 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
547 my $net = Samba::bindir_path($self, "net");
548 # Add hosts file for name lookups
549 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
550 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
551 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
552 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
554 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
556 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
557 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
558 $cmd .= "$net join $ret->{CONFIGURATION}";
559 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
561 if (system($cmd) != 0) {
562 warn("Join failed\n$cmd");
566 # We need world access to this share, as otherwise the domain
567 # administrator from the AD domain provided by Samba4 can't
568 # access the share for tests.
569 chmod 0777, "$prefix/share";
571 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
575 $ret->{DC_SERVER} = $dcvars->{SERVER};
576 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
577 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
578 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
579 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
580 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
585 sub setup_ad_member_idmap_rid
587 my ($self, $prefix, $dcvars) = @_;
589 # If we didn't build with ADS, pretend this env was never available
590 if (not $self->have_ads()) {
594 print "PROVISIONING S3 AD MEMBER WITH idmap_rid config...";
596 my $member_options = "
598 workgroup = $dcvars->{DOMAIN}
599 realm = $dcvars->{REALM}
600 idmap config * : backend = tdb
601 idmap config * : range = 1000000-1999999
602 idmap config $dcvars->{DOMAIN} : backend = rid
603 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
606 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
610 $dcvars->{SERVER_IP},
611 $dcvars->{SERVER_IPV6});
613 $ret or return undef;
616 $ret->{DOMAIN} = $dcvars->{DOMAIN};
617 $ret->{REALM} = $dcvars->{REALM};
618 $ret->{DOMSID} = $dcvars->{DOMSID};
621 my $prefix_abs = abs_path($prefix);
623 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
624 $ctx->{domain} = $dcvars->{DOMAIN};
625 $ctx->{realm} = $dcvars->{REALM};
626 $ctx->{dnsname} = lc($dcvars->{REALM});
627 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
628 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
629 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
630 Samba::mk_krb5_conf($ctx, "");
632 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
634 my $net = Samba::bindir_path($self, "net");
635 # Add hosts file for name lookups
636 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
637 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
638 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
639 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
641 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
643 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
644 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
645 $cmd .= "$net join $ret->{CONFIGURATION}";
646 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
648 if (system($cmd) != 0) {
649 warn("Join failed\n$cmd");
653 # We need world access to this share, as otherwise the domain
654 # administrator from the AD domain provided by Samba4 can't
655 # access the share for tests.
656 chmod 0777, "$prefix/share";
658 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
662 $ret->{DC_SERVER} = $dcvars->{SERVER};
663 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
664 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
665 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
666 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
667 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
672 sub setup_ad_member_idmap_ad
674 my ($self, $prefix, $dcvars) = @_;
676 # If we didn't build with ADS, pretend this env was never available
677 if (not $self->have_ads()) {
681 print "PROVISIONING S3 AD MEMBER WITH idmap_ad config...";
683 my $member_options = "
685 workgroup = $dcvars->{DOMAIN}
686 realm = $dcvars->{REALM}
687 password server = $dcvars->{SERVER}
688 idmap config * : backend = tdb
689 idmap config * : range = 1000000-1999999
690 idmap config $dcvars->{DOMAIN} : backend = ad
691 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
694 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
698 $dcvars->{SERVER_IP},
699 $dcvars->{SERVER_IPV6});
701 $ret or return undef;
704 $ret->{DOMAIN} = $dcvars->{DOMAIN};
705 $ret->{REALM} = $dcvars->{REALM};
706 $ret->{DOMSID} = $dcvars->{DOMSID};
709 my $prefix_abs = abs_path($prefix);
711 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
712 $ctx->{domain} = $dcvars->{DOMAIN};
713 $ctx->{realm} = $dcvars->{REALM};
714 $ctx->{dnsname} = lc($dcvars->{REALM});
715 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
716 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
717 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
718 Samba::mk_krb5_conf($ctx, "");
720 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
722 my $net = Samba::bindir_path($self, "net");
723 # Add hosts file for name lookups
724 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
725 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
726 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
727 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
729 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
731 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
732 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
733 $cmd .= "$net join $ret->{CONFIGURATION}";
734 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
736 if (system($cmd) != 0) {
737 warn("Join failed\n$cmd");
741 # We need world access to this share, as otherwise the domain
742 # administrator from the AD domain provided by Samba4 can't
743 # access the share for tests.
744 chmod 0777, "$prefix/share";
746 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
750 $ret->{DC_SERVER} = $dcvars->{SERVER};
751 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
752 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
753 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
754 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
755 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
760 sub setup_simpleserver
762 my ($self, $path) = @_;
764 print "PROVISIONING simple server...";
766 my $prefix_abs = abs_path($path);
768 my $simpleserver_options = "
771 vfs objects = xattr_tdb streams_depot
776 path = $prefix_abs/share
778 vfs objects = aio_pthread
779 aio_pthread:aio open = yes
780 smbd:async dosmode = no
782 [vfs_aio_pthread_async_dosmode_default1]
783 path = $prefix_abs/share
785 vfs objects = aio_pthread
786 store dos attributes = yes
787 aio_pthread:aio open = yes
788 smbd:async dosmode = yes
790 [vfs_aio_pthread_async_dosmode_default2]
791 path = $prefix_abs/share
793 vfs objects = aio_pthread xattr_tdb
794 store dos attributes = yes
795 aio_pthread:aio open = yes
796 smbd:async dosmode = yes
798 [vfs_aio_pthread_async_dosmode_force_sync1]
799 path = $prefix_abs/share
801 vfs objects = aio_pthread
802 store dos attributes = yes
803 aio_pthread:aio open = yes
804 smbd:async dosmode = yes
805 # This simulates non linux systems
806 smbd:force sync user path safe threadpool = yes
807 smbd:force sync user chdir safe threadpool = yes
808 smbd:force sync root path safe threadpool = yes
809 smbd:force sync root chdir safe threadpool = yes
811 [vfs_aio_pthread_async_dosmode_force_sync2]
812 path = $prefix_abs/share
814 vfs objects = aio_pthread xattr_tdb
815 store dos attributes = yes
816 aio_pthread:aio open = yes
817 smbd:async dosmode = yes
818 # This simulates non linux systems
819 smbd:force sync user path safe threadpool = yes
820 smbd:force sync user chdir safe threadpool = yes
821 smbd:force sync root path safe threadpool = yes
822 smbd:force sync root chdir safe threadpool = yes
825 path = $prefix_abs/share
826 vfs objects = aio_fork
828 vfs_aio_fork:erratic_testing_mode=yes
831 path = $prefix_abs/share
833 store dos attributes = yes
834 hide files = /hidefile/
838 path = $prefix_abs/share
840 smb encrypt = desired
843 my $vars = $self->provision($path, "WORKGROUP",
846 $simpleserver_options);
848 $vars or return undef;
850 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
859 my ($self, $path) = @_;
860 my $prefix_abs = abs_path($path);
861 my $srcdir_abs = abs_path($self->{srcdir});
863 print "PROVISIONING file server ...\n";
867 mkdir($prefix_abs, 0777);
869 my $usershare_dir="$prefix_abs/lib/usershare";
871 mkdir("$prefix_abs/lib", 0755);
872 remove_tree($usershare_dir);
873 mkdir($usershare_dir, 01770);
875 my $share_dir="$prefix_abs/share";
877 # Create share directory structure
878 my $lower_case_share_dir="$share_dir/lower-case";
879 push(@dirs, $lower_case_share_dir);
881 my $lower_case_share_dir_30000="$share_dir/lower-case-30000";
882 push(@dirs, $lower_case_share_dir_30000);
884 my $dfree_share_dir="$share_dir/dfree";
885 push(@dirs, $dfree_share_dir);
886 push(@dirs, "$dfree_share_dir/subdir1");
887 push(@dirs, "$dfree_share_dir/subdir2");
888 push(@dirs, "$dfree_share_dir/subdir3");
890 my $quotadir_dir="$share_dir/quota";
891 push(@dirs, $quotadir_dir);
893 my $valid_users_sharedir="$share_dir/valid_users";
894 push(@dirs,$valid_users_sharedir);
896 my $offline_sharedir="$share_dir/offline";
897 push(@dirs,$offline_sharedir);
899 my $force_user_valid_users_dir = "$share_dir/force_user_valid_users";
900 push(@dirs, $force_user_valid_users_dir);
902 my $smbget_sharedir="$share_dir/smbget";
903 push(@dirs,$smbget_sharedir);
905 my $tarmode_sharedir="$share_dir/tarmode";
906 push(@dirs,$tarmode_sharedir);
908 my $usershare_sharedir="$share_dir/usershares";
909 push(@dirs,$usershare_sharedir);
911 my $fileserver_options = "
912 kernel change notify = yes
914 usershare path = $usershare_dir
915 usershare max shares = 10
916 usershare allow guests = yes
917 usershare prefix allow list = $usershare_sharedir
919 get quota command = $prefix_abs/getset_quota.py
920 set quota command = $prefix_abs/getset_quota.py
922 path = $lower_case_share_dir
923 comment = smb username is [%U]
924 case sensitive = True
927 short preserve case = no
929 path = $lower_case_share_dir_30000
930 comment = smb username is [%U]
931 case sensitive = True
934 short preserve case = no
936 path = $dfree_share_dir
937 comment = smb username is [%U]
938 dfree command = $srcdir_abs/testprogs/blackbox/dfree.sh
940 path = $valid_users_sharedir
941 valid users = +userdup
943 path = $offline_sharedir
944 vfs objects = offline
946 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878
947 # RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651
948 [force_user_valid_users]
949 path = $force_user_valid_users_dir
950 comment = force user with valid users combination test share
951 valid users = +force_user
952 force user = force_user
953 force group = everyone
954 write list = force_user
957 path = $smbget_sharedir
958 comment = smb username is [%U]
962 comment = ignore system acls
963 acl_xattr:ignore system acls = yes
966 comment = inherit owner
970 comment = inherit only unix owner
971 inherit owner = unix only
972 acl_xattr:ignore system acls = yes
975 my $vars = $self->provision($path, "WORKGROUP",
983 $vars or return undef;
985 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
990 mkdir($_, 0777) foreach(@dirs);
992 ## Create case sensitive lower case share dir
993 foreach my $file ('a'..'z') {
994 my $full_path = $lower_case_share_dir . '/' . $file;
995 open my $fh, '>', $full_path;
996 # Add some content to file
997 print $fh $full_path;
1001 for (my $file = 1; $file < 51; ++$file) {
1002 my $full_path = $lower_case_share_dir . '/' . $file;
1003 open my $fh, '>', $full_path;
1004 # Add some content to file
1005 print $fh $full_path;
1009 # Create content for 30000 share
1010 foreach my $file ('a'..'z') {
1011 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1012 open my $fh, '>', $full_path;
1013 # Add some content to file
1014 print $fh $full_path;
1018 for (my $file = 1; $file < 30001; ++$file) {
1019 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1020 open my $fh, '>', $full_path;
1021 # Add some content to file
1022 print $fh $full_path;
1027 ## create a listable file in valid_users_share
1029 my $valid_users_target = "$valid_users_sharedir/foo";
1030 unless (open(VALID_USERS_TARGET, ">$valid_users_target")) {
1031 warn("Unable to open $valid_users_target");
1034 close(VALID_USERS_TARGET);
1035 chmod 0644, $valid_users_target;
1042 my ($self, $prefix) = @_;
1044 # If we didn't build with ADS, pretend this env was never available
1045 if (not $self->have_ads()) {
1049 print "PROVISIONING server with security=ads...";
1051 my $ktest_options = "
1053 realm = ktest.samba.example.com
1055 username map = $prefix/lib/username.map
1056 server signing = required
1057 server min protocol = SMB3_00
1058 client max protocol = SMB3
1060 # This disables NTLM auth against the local SAM, which
1061 # we use can then test this setting by.
1062 ntlm auth = disabled
1065 my $ret = $self->provision($prefix, "KTEST",
1070 $ret or return undef;
1073 my $prefix_abs = abs_path($prefix);
1075 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1076 $ctx->{domain} = "KTEST";
1077 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
1078 $ctx->{dnsname} = lc($ctx->{realm});
1079 $ctx->{kdc_ipv4} = "0.0.0.0";
1080 $ctx->{kdc_ipv6} = "::";
1081 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1082 Samba::mk_krb5_conf($ctx, "");
1084 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1086 open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map");
1088 $ret->{USERNAME} = KTEST\\Administrator
1092 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
1093 #Samba4 DC with the same parameters as are being used here. The
1094 #domain SID is S-1-5-21-1071277805-689288055-3486227160
1095 $ret->{SAMSID} = "S-1-5-21-1911091480-1468226576-2729736297";
1096 $ret->{DOMSID} = "S-1-5-21-1071277805-689288055-3486227160";
1098 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
1099 chmod 0600, "$prefix/private/secrets.tdb";
1101 #Make sure there's no old ntdb file.
1102 system("rm -f $prefix/private/secrets.ntdb");
1104 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
1105 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
1107 #and having in krb5.conf:
1108 # ticket_lifetime = 799718400
1109 # renew_lifetime = 799718400
1111 # The commands for the -2 keytab where were:
1112 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
1113 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
1114 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
1115 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1116 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1118 # and then for the -3 keytab, I did
1120 # net changetrustpw; kdestroy and the same again.
1122 # This creates a credential cache with a very long lifetime (2036 at
1123 # at 2011-04), and shows that running 'net changetrustpw' does not
1124 # break existing logins (for the secrets.tdb method at least).
1127 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
1129 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
1130 chmod 0600, "$prefix/krb5_ccache-2";
1132 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
1133 chmod 0600, "$prefix/krb5_ccache-3";
1135 # We need world access to this share, as otherwise the domain
1136 # administrator from the AD domain provided by ktest can't
1137 # access the share for tests.
1138 chmod 0777, "$prefix/share";
1140 if (not $self->check_or_start($ret, "yes", "no", "yes")) {
1146 sub setup_maptoguest
1148 my ($self, $path) = @_;
1150 print "PROVISIONING maptoguest...";
1153 map to guest = bad user
1157 my $vars = $self->provision($path, "WORKGROUP",
1162 $vars or return undef;
1164 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
1171 sub stop_sig_term($$) {
1172 my ($self, $pid) = @_;
1173 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1176 sub stop_sig_kill($$) {
1177 my ($self, $pid) = @_;
1178 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1183 my ($env_vars, $app, $pid) = @_;
1185 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
1192 my ($env_vars, $app) = @_;
1194 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
1200 sub check_or_start($$$$$) {
1201 my ($self, $env_vars, $nmbd, $winbindd, $smbd) = @_;
1203 # use a pipe for stdin in the child processes. This allows
1204 # those processes to monitor the pipe for EOF to ensure they
1205 # exit when the test script exits
1206 pipe(STDIN_READER, $env_vars->{STDIN_PIPE});
1208 unlink($env_vars->{NMBD_TEST_LOG});
1209 print "STARTING NMBD...";
1212 open STDOUT, ">$env_vars->{NMBD_TEST_LOG}";
1213 open STDERR, '>&STDOUT';
1215 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1217 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1218 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.nmbd";
1219 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1220 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1222 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1223 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1224 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1225 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1226 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1227 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1228 $ENV{UID_WRAPPER_ROOT} = "1";
1230 $ENV{ENVNAME} = "$ENV{ENVNAME}.nmbd";
1232 if ($nmbd ne "yes") {
1233 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1234 my $signame = shift;
1235 print("Skip nmbd received signal $signame");
1238 sleep($self->{server_maxtime});
1242 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "nmbd");
1243 my @optargs = ("-d0");
1244 if (defined($ENV{NMBD_OPTIONS})) {
1245 @optargs = split(/ /, $ENV{NMBD_OPTIONS});
1247 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1248 if(defined($ENV{NMBD_VALGRIND})) {
1249 @preargs = split(/ /, $ENV{NMBD_VALGRIND});
1251 my @args = ("-F", "--no-process-group",
1252 "-s", $env_vars->{SERVERCONFFILE},
1253 "-l", $env_vars->{LOGDIR});
1254 if (not defined($ENV{NMBD_DONT_LOG_STDOUT})) {
1255 push(@args, "--log-stdout");
1258 close($env_vars->{STDIN_PIPE});
1259 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1261 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1262 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1264 $env_vars->{NMBD_TL_PID} = $pid;
1265 write_pid($env_vars, "nmbd", $pid);
1268 unlink($env_vars->{WINBINDD_TEST_LOG});
1269 print "STARTING WINBINDD...";
1272 open STDOUT, ">$env_vars->{WINBINDD_TEST_LOG}";
1273 open STDERR, '>&STDOUT';
1275 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1277 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1278 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.winbindd";
1279 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1280 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1282 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1283 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1284 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1285 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1286 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1287 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1288 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
1289 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
1291 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
1293 $ENV{UID_WRAPPER_ROOT} = "1";
1295 $ENV{ENVNAME} = "$ENV{ENVNAME}.winbindd";
1297 if ($winbindd ne "yes") {
1298 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1299 my $signame = shift;
1300 print("Skip winbindd received signal $signame");
1303 sleep($self->{server_maxtime});
1307 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "winbindd");
1308 my @optargs = ("-d0");
1309 if (defined($ENV{WINBINDD_OPTIONS})) {
1310 @optargs = split(/ /, $ENV{WINBINDD_OPTIONS});
1312 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1313 if(defined($ENV{WINBINDD_VALGRIND})) {
1314 @preargs = split(/ /, $ENV{WINBINDD_VALGRIND});
1316 my @args = ("-F", "--no-process-group",
1317 "-s", $env_vars->{SERVERCONFFILE},
1318 "-l", $env_vars->{LOGDIR});
1319 if (not defined($ENV{WINBINDD_DONT_LOG_STDOUT})) {
1320 push(@args, "--stdout");
1323 close($env_vars->{STDIN_PIPE});
1324 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1326 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1327 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1329 $env_vars->{WINBINDD_TL_PID} = $pid;
1330 write_pid($env_vars, "winbindd", $pid);
1333 unlink($env_vars->{SMBD_TEST_LOG});
1334 print "STARTING SMBD...";
1337 open STDOUT, ">$env_vars->{SMBD_TEST_LOG}";
1338 open STDERR, '>&STDOUT';
1340 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1342 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1343 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.smbd";
1344 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1345 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1347 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1348 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1349 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1350 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1351 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1352 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1353 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
1354 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
1356 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
1358 $ENV{UID_WRAPPER_ROOT} = "1";
1360 $ENV{ENVNAME} = "$ENV{ENVNAME}.smbd";
1362 if ($smbd ne "yes") {
1363 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1364 my $signame = shift;
1365 print("Skip smbd received signal $signame");
1368 sleep($self->{server_maxtime});
1372 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "smbd");
1373 my @optargs = ("-d0");
1374 if (defined($ENV{SMBD_OPTIONS})) {
1375 @optargs = split(/ /, $ENV{SMBD_OPTIONS});
1377 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1378 if(defined($ENV{SMBD_VALGRIND})) {
1379 @preargs = split(/ /,$ENV{SMBD_VALGRIND});
1381 my @args = ("-F", "--no-process-group",
1382 "-s", $env_vars->{SERVERCONFFILE},
1383 "-l", $env_vars->{LOGDIR});
1384 if (not defined($ENV{SMBD_DONT_LOG_STDOUT})) {
1385 push(@args, "--log-stdout");
1388 close($env_vars->{STDIN_PIPE});
1389 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1391 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1392 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1394 $env_vars->{SMBD_TL_PID} = $pid;
1395 write_pid($env_vars, "smbd", $pid);
1398 close(STDIN_READER);
1400 return $self->wait_for_start($env_vars, $nmbd, $winbindd, $smbd);
1403 sub createuser($$$$$)
1405 my ($self, $username, $password, $conffile, $env) = @_;
1406 my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $username > /dev/null";
1409 while(my($var, $val) = each %$env) {
1410 $cmd = "$var=\"$val\" $cmd";
1413 unless (open(PWD, "|$cmd")) {
1414 warn("Unable to set password for $username account\n$cmd");
1417 print PWD "$password\n$password\n";
1418 unless (close(PWD)) {
1419 warn("Unable to set password for $username account\n$cmd");
1424 sub provision($$$$$$$$$)
1426 my ($self, $prefix, $domain, $server, $password, $extra_options, $dc_server_ip, $dc_server_ipv6, $no_delete_prefix) = @_;
1429 ## setup the various environment variables we need
1432 my $samsid = Samba::random_domain_sid();
1433 my $swiface = Samba::get_interface($server);
1435 my %createuser_env = ();
1436 my $server_ip = "127.0.0.$swiface";
1437 my $server_ipv6 = sprintf("fd00:0000:0000:0000:0000:0000:5357:5f%02x", $swiface);
1439 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
1442 my $unix_gids_str = $);
1443 my @unix_gids = split(" ", $unix_gids_str);
1445 my $prefix_abs = abs_path($prefix);
1446 my $bindir_abs = abs_path($self->{bindir});
1450 my $shrdir="$prefix_abs/share";
1451 push(@dirs,$shrdir);
1453 my $libdir="$prefix_abs/lib";
1454 push(@dirs,$libdir);
1456 my $piddir="$prefix_abs/pid";
1457 push(@dirs,$piddir);
1459 my $privatedir="$prefix_abs/private";
1460 push(@dirs,$privatedir);
1462 my $binddnsdir = "$prefix_abs/bind-dns";
1463 push(@dirs, $binddnsdir);
1465 my $lockdir="$prefix_abs/lockdir";
1466 push(@dirs,$lockdir);
1468 my $eventlogdir="$prefix_abs/lockdir/eventlog";
1469 push(@dirs,$eventlogdir);
1471 my $logdir="$prefix_abs/logs";
1472 push(@dirs,$logdir);
1474 my $driver32dir="$shrdir/W32X86";
1475 push(@dirs,$driver32dir);
1477 my $driver64dir="$shrdir/x64";
1478 push(@dirs,$driver64dir);
1480 my $driver40dir="$shrdir/WIN40";
1481 push(@dirs,$driver40dir);
1483 my $ro_shrdir="$shrdir/root-tmp";
1484 push(@dirs,$ro_shrdir);
1486 my $msdfs_shrdir="$shrdir/msdfsshare";
1487 push(@dirs,$msdfs_shrdir);
1489 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
1490 push(@dirs,$msdfs_deeppath);
1492 my $badnames_shrdir="$shrdir/badnames";
1493 push(@dirs,$badnames_shrdir);
1495 my $lease1_shrdir="$shrdir/SMB2_10";
1496 push(@dirs,$lease1_shrdir);
1498 my $lease2_shrdir="$shrdir/SMB3_00";
1499 push(@dirs,$lease2_shrdir);
1501 my $manglenames_shrdir="$shrdir/manglenames";
1502 push(@dirs,$manglenames_shrdir);
1504 my $widelinks_shrdir="$shrdir/widelinks";
1505 push(@dirs,$widelinks_shrdir);
1507 my $widelinks_linkdir="$shrdir/widelinks_foo";
1508 push(@dirs,$widelinks_linkdir);
1510 my $shadow_tstdir="$shrdir/shadow";
1511 push(@dirs,$shadow_tstdir);
1512 my $shadow_mntdir="$shadow_tstdir/mount";
1513 push(@dirs,$shadow_mntdir);
1514 my $shadow_basedir="$shadow_mntdir/base";
1515 push(@dirs,$shadow_basedir);
1516 my $shadow_shrdir="$shadow_basedir/share";
1517 push(@dirs,$shadow_shrdir);
1519 my $nosymlinks_shrdir="$shrdir/nosymlinks";
1520 push(@dirs,$nosymlinks_shrdir);
1522 my $local_symlinks_shrdir="$shrdir/local_symlinks";
1523 push(@dirs,$local_symlinks_shrdir);
1525 # this gets autocreated by winbindd
1526 my $wbsockdir="$prefix_abs/winbindd";
1528 my $nmbdsockdir="$prefix_abs/nmbd";
1529 unlink($nmbdsockdir);
1532 ## create the test directory layout
1534 die ("prefix_abs = ''") if $prefix_abs eq "";
1535 die ("prefix_abs = '/'") if $prefix_abs eq "/";
1537 mkdir($prefix_abs, 0777);
1538 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
1539 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
1540 system("rm -rf $prefix_abs/*");
1542 mkdir($_, 0777) foreach(@dirs);
1544 my $fs_specific_conf = $self->get_fs_specific_conf($shrdir);
1547 ## lockdir and piddir must be 0755
1549 chmod 0755, $lockdir;
1550 chmod 0755, $piddir;
1554 ## create ro and msdfs share layout
1557 chmod 0755, $ro_shrdir;
1558 my $unreadable_file = "$ro_shrdir/unreadable_file";
1559 unless (open(UNREADABLE_FILE, ">$unreadable_file")) {
1560 warn("Unable to open $unreadable_file");
1563 close(UNREADABLE_FILE);
1564 chmod 0600, $unreadable_file;
1566 my $msdfs_target = "$ro_shrdir/msdfs-target";
1567 unless (open(MSDFS_TARGET, ">$msdfs_target")) {
1568 warn("Unable to open $msdfs_target");
1571 close(MSDFS_TARGET);
1572 chmod 0666, $msdfs_target;
1573 symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp",
1574 "$msdfs_shrdir/msdfs-src1";
1575 symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
1578 ## create bad names in $badnames_shrdir
1580 ## (An invalid name, would be mangled to 8.3).
1581 my $badname_target = "$badnames_shrdir/\340|\231\216\377\177";
1582 unless (open(BADNAME_TARGET, ">$badname_target")) {
1583 warn("Unable to open $badname_target");
1586 close(BADNAME_TARGET);
1587 chmod 0666, $badname_target;
1589 ## (A bad name, would not be mangled to 8.3).
1590 my $badname_target = "$badnames_shrdir/\240\276\346\327\377\177";
1591 unless (open(BADNAME_TARGET, ">$badname_target")) {
1592 warn("Unable to open $badname_target");
1595 close(BADNAME_TARGET);
1596 chmod 0666, $badname_target;
1598 ## (A bad good name).
1599 my $badname_target = "$badnames_shrdir/blank.txt";
1600 unless (open(BADNAME_TARGET, ">$badname_target")) {
1601 warn("Unable to open $badname_target");
1604 close(BADNAME_TARGET);
1605 chmod 0666, $badname_target;
1608 ## create mangleable directory names in $manglenames_shrdir
1610 my $manglename_target = "$manglenames_shrdir/foo:bar";
1611 mkdir($manglename_target, 0777);
1614 ## create symlinks for widelinks tests.
1616 my $widelinks_target = "$widelinks_linkdir/target";
1617 unless (open(WIDELINKS_TARGET, ">$widelinks_target")) {
1618 warn("Unable to open $widelinks_target");
1621 close(WIDELINKS_TARGET);
1622 chmod 0666, $widelinks_target;
1624 ## This link should get ACCESS_DENIED
1626 symlink "$widelinks_target", "$widelinks_shrdir/source";
1628 ## This link should be allowed
1630 symlink "$widelinks_shrdir", "$widelinks_shrdir/dot";
1632 my $conffile="$libdir/server.conf";
1633 my $dfqconffile="$libdir/dfq.conf";
1635 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/third_party/nss_wrapper/nss_wrapper.pl";
1636 my $nss_wrapper_passwd = "$privatedir/passwd";
1637 my $nss_wrapper_group = "$privatedir/group";
1638 my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts";
1639 my $resolv_conf = "$privatedir/resolv.conf";
1640 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
1642 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
1644 my $fake_snap_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/fake_snap.pl";
1646 my @eventlog_list = ("dns server", "application");
1649 ## calculate uids and gids
1652 my ($max_uid, $max_gid);
1653 my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
1654 my ($uid_pdbtest_wkn);
1656 my ($uid_force_user);
1657 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
1658 my ($gid_userdup, $gid_everyone);
1659 my ($gid_force_user);
1663 if ($unix_uid < 0xffff - 10) {
1666 $max_uid = $unix_uid;
1669 $uid_root = $max_uid - 1;
1670 $uid_nobody = $max_uid - 2;
1671 $uid_pdbtest = $max_uid - 3;
1672 $uid_pdbtest2 = $max_uid - 4;
1673 $uid_userdup = $max_uid - 5;
1674 $uid_pdbtest_wkn = $max_uid - 6;
1675 $uid_force_user = $max_uid - 7;
1676 $uid_smbget = $max_uid - 8;
1677 $uid_user1 = $max_uid - 9;
1678 $uid_user2 = $max_uid - 10;
1680 if ($unix_gids[0] < 0xffff - 8) {
1683 $max_gid = $unix_gids[0];
1686 $gid_nobody = $max_gid - 1;
1687 $gid_nogroup = $max_gid - 2;
1688 $gid_root = $max_gid - 3;
1689 $gid_domusers = $max_gid - 4;
1690 $gid_domadmins = $max_gid - 5;
1691 $gid_userdup = $max_gid - 6;
1692 $gid_everyone = $max_gid - 7;
1693 $gid_force_user = $max_gid - 8;
1699 unless (open(CONF, ">$conffile")) {
1700 warn("Unable to open $conffile");
1705 netbios name = $server
1706 interfaces = $server_ip/8 $server_ipv6/64
1707 bind interfaces only = yes
1708 panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
1709 smbd:suicide mode = yes
1713 private dir = $privatedir
1714 binddns dir = $binddnsdir
1715 pid directory = $piddir
1716 lock directory = $lockdir
1717 log file = $logdir/log.\%m
1722 state directory = $lockdir
1723 cache directory = $lockdir
1725 passdb backend = tdbsam
1729 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1730 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
1731 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1732 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
1733 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
1734 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
1735 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
1737 addprinter command = $mod_printer_pl -a -s $conffile --
1738 deleteprinter command = $mod_printer_pl -d -s $conffile --
1740 eventlog list = application \"dns server\"
1743 kernel change notify = no
1747 printcap name = /dev/null
1749 winbindd socket directory = $wbsockdir
1750 nmbd:socket dir = $nmbdsockdir
1751 idmap config * : range = 100000-200000
1752 winbind enum users = yes
1753 winbind enum groups = yes
1754 winbind separator = /
1755 include system krb5 conf = no
1757 # min receivefile size = 4000
1761 smbd:sharedelay = 100000
1762 smbd:writetimeupdatedelay = 500000
1766 store dos attributes = yes
1771 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot time_audit full_audit
1773 full_audit:syslog = no
1774 full_audit:success = none
1775 full_audit:failure = none
1778 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
1779 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
1780 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
1781 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
1782 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
1783 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
1784 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
1786 print notify backchannel = yes
1788 ncalrpc dir = $prefix_abs/ncalrpc
1790 # The samba3.blackbox.smbclient_s3 test uses this to test that
1791 # sending messages works, and that the %m sub works.
1792 message command = mv %s $shrdir/message.%m
1794 # fsrvp server requires registry shares
1795 registry shares = yes
1797 # Used by RPC SRVSVC tests
1798 add share command = $bindir_abs/smbaddshare
1799 change share command = $bindir_abs/smbchangeshare
1800 delete share command = $bindir_abs/smbdeleteshare
1802 # fruit:copyfile is a global option
1803 fruit:copyfile = yes
1805 #this does not mean that we use non-secure test env,
1806 #it just means we ALLOW one to be configured.
1807 allow insecure wide links = yes
1809 # Begin extra options
1813 #Include user defined custom parameters if set
1816 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
1817 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
1823 comment = smb username is [%U]
1826 comment = Load dirsort module
1827 vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot
1830 comment = encrypt smb username is [%U]
1831 smb encrypt = required
1832 vfs objects = dirsort
1842 force user = $unix_name
1844 [forceuser_unixonly]
1845 comment = force a user with unix user SID and group SID
1847 force user = pdbtest
1849 [forceuser_wkngroup]
1850 comment = force a user with well-known group SID
1852 force user = pdbtest_wkn
1856 force group = nogroup
1864 write list = $unix_name
1867 valid users = $unix_name
1868 access based share enum = yes
1870 path = $msdfs_shrdir
1872 msdfs shuffle referrals = yes
1876 hide unreadable = yes
1879 case sensitive = yes
1882 hide unwriteable files = yes
1885 kernel share modes = no
1899 default devmode = no
1905 comment = smb username is [%U]
1907 nfs4acl_xattr:version = 40
1908 vfs objects = nfs4acl_xattr xattr_tdb
1910 [nfs4acl_special_40]
1912 comment = smb username is [%U]
1914 nfs4acl_xattr:version = 40
1915 vfs objects = nfs4acl_xattr xattr_tdb
1919 comment = smb username is [%U]
1921 vfs objects = nfs4acl_xattr xattr_tdb
1925 comment = smb username is [%U]
1926 vfs objects = nfs4acl_xattr xattr_tdb
1928 nfs4acl_xattr:encoding = xdr
1929 nfs4acl_xattr:version = 40
1933 comment = smb username is [%U]
1934 vfs objects = nfs4acl_xattr xattr_tdb
1936 nfs4acl_xattr:encoding = xdr
1937 nfs4acl_xattr:version = 41
1941 comment = smb username is [%U]
1943 force create mode = 777
1946 comment = smb username is [%U]
1948 force create mode = 0
1949 directory mask = 0777
1950 force directory mode = 0
1951 vfs objects = xattr_tdb streams_depot
1962 vfs objects = catia fruit streams_xattr acl_xattr xattr_tdb
1963 fruit:resource = file
1964 fruit:metadata = netatalk
1965 fruit:locking = netatalk
1966 fruit:encoding = native
1967 fruit:veto_appledouble = no
1971 # This is used by vfs.fruit tests that require real fs xattr
1972 vfs objects = catia fruit streams_xattr acl_xattr
1973 fruit:resource = file
1974 fruit:metadata = netatalk
1975 fruit:locking = netatalk
1976 fruit:encoding = native
1977 fruit:veto_appledouble = no
1979 [vfs_fruit_metadata_stream]
1981 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
1982 fruit:resource = file
1983 fruit:metadata = stream
1984 fruit:veto_appledouble = no
1986 [vfs_fruit_stream_depot]
1988 vfs objects = fruit streams_depot acl_xattr xattr_tdb
1989 fruit:resource = stream
1990 fruit:metadata = stream
1991 fruit:veto_appledouble = no
1995 vfs objects = streams_xattr acl_xattr xattr_tdb
1997 [vfs_wo_fruit_stream_depot]
1999 vfs objects = streams_depot acl_xattr xattr_tdb
2001 [vfs_fruit_timemachine]
2003 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2004 fruit:resource = file
2005 fruit:metadata = stream
2006 fruit:time machine = yes
2007 fruit:time machine max size = 32K
2009 [vfs_fruit_wipe_intentionally_left_blank_rfork]
2011 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2012 fruit:resource = file
2013 fruit:metadata = stream
2014 fruit:wipe_intentionally_left_blank_rfork = true
2015 fruit:delete_empty_adfiles = false
2016 fruit:veto_appledouble = no
2018 [vfs_fruit_delete_empty_adfiles]
2020 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2021 fruit:resource = file
2022 fruit:metadata = stream
2023 fruit:wipe_intentionally_left_blank_rfork = true
2024 fruit:delete_empty_adfiles = true
2025 fruit:veto_appledouble = no
2028 path = $badnames_shrdir
2032 path = $manglenames_shrdir
2040 path = $widelinks_shrdir
2046 comment = fake shapshots using rsync
2047 vfs objects = shell_snap shadow_copy2
2048 shell_snap:check path command = $fake_snap_pl --check
2049 shell_snap:create command = $fake_snap_pl --create
2050 shell_snap:delete command = $fake_snap_pl --delete
2051 # a relative path here fails, the snapshot dir is no longer found
2052 shadow:snapdir = $shrdir/.snapshots
2055 path = $shadow_shrdir
2056 comment = previous versions snapshots under mount point
2057 vfs objects = shadow_copy2
2058 shadow:mountpoint = $shadow_mntdir
2061 path = $shadow_shrdir
2062 comment = previous versions snapshots outside mount point
2063 vfs objects = shadow_copy2
2064 shadow:mountpoint = $shadow_mntdir
2065 shadow:snapdir = $shadow_tstdir/.snapshots
2068 path = $shadow_shrdir
2069 comment = previous versions with subvolume snapshots, snapshots under base dir
2070 vfs objects = shadow_copy2
2071 shadow:mountpoint = $shadow_mntdir
2072 shadow:basedir = $shadow_basedir
2073 shadow:snapdir = $shadow_basedir/.snapshots
2076 path = $shadow_shrdir
2077 comment = previous versions with subvolume snapshots, snapshots outside mount point
2078 vfs objects = shadow_copy2
2079 shadow:mountpoint = $shadow_mntdir
2080 shadow:basedir = $shadow_basedir
2081 shadow:snapdir = $shadow_tstdir/.snapshots
2084 path = $shadow_shrdir
2085 comment = previous versions at volume root snapshots under mount point
2086 vfs objects = shadow_copy2
2087 shadow:mountpoint = $shadow_shrdir
2090 path = $shadow_shrdir
2091 comment = previous versions at volume root snapshots outside mount point
2092 vfs objects = shadow_copy2
2093 shadow:mountpoint = $shadow_shrdir
2094 shadow:snapdir = $shadow_tstdir/.snapshots
2097 path = $shadow_shrdir
2098 comment = previous versions snapshots everywhere
2099 vfs objects = shadow_copy2
2100 shadow:mountpoint = $shadow_mntdir
2101 shadow:snapdirseverywhere = yes
2104 path = $shadow_shrdir
2105 comment = previous versions using snapsharepath
2106 vfs objects = shadow_copy2
2107 shadow:mountpoint = $shadow_mntdir
2108 shadow:snapdir = $shadow_tstdir/.snapshots
2109 shadow:snapsharepath = share
2112 comment = Testing shadow:format with default option
2113 vfs object = shadow_copy2
2114 path = $shadow_shrdir
2117 shadow:mountpoint = $shadow_mntdir
2118 shadow:basedir = $shadow_basedir
2119 shadow:snapdir = $shadow_basedir/.snapshots
2120 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2123 comment = Testing shadow:format with only date component
2124 vfs object = shadow_copy2
2125 path = $shadow_shrdir
2128 shadow:mountpoint = $shadow_mntdir
2129 shadow:basedir = $shadow_basedir
2130 shadow:snapdir = $shadow_basedir/.snapshots
2131 shadow:format = \@GMT-%Y-%m-%d
2134 comment = Testing shadow:format with some hardcoded prefix
2135 vfs object = shadow_copy2
2136 path = $shadow_shrdir
2139 shadow:mountpoint = $shadow_mntdir
2140 shadow:basedir = $shadow_basedir
2141 shadow:snapdir = $shadow_basedir/.snapshots
2142 shadow:format = snap\@GMT-%Y.%m.%d-%H.%M.%S
2145 comment = Testing shadow:format with modified format
2146 vfs object = shadow_copy2
2147 path = $shadow_shrdir
2150 shadow:mountpoint = $shadow_mntdir
2151 shadow:basedir = $shadow_basedir
2152 shadow:snapdir = $shadow_basedir/.snapshots
2153 shadow:format = \@GMT-%Y.%m.%d-%H_%M_%S-snap
2156 comment = Testing shadow:snapprefix regex
2157 vfs object = shadow_copy2
2158 path = $shadow_shrdir
2161 shadow:mountpoint = $shadow_mntdir
2162 shadow:basedir = $shadow_basedir
2163 shadow:snapdir = $shadow_basedir/.snapshots
2164 shadow:snapprefix = \^s[a-z]*p\$
2165 shadow:format = _GMT-%Y.%m.%d-%H.%M.%S
2168 comment = Testing shadow:snapprefix with delim regex
2169 vfs object = shadow_copy2
2170 path = $shadow_shrdir
2173 shadow:mountpoint = $shadow_mntdir
2174 shadow:basedir = $shadow_basedir
2175 shadow:snapdir = $shadow_basedir/.snapshots
2176 shadow:delimiter = \@GMT
2177 shadow:snapprefix = [a-z]*
2178 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2181 path = $shadow_shrdir
2182 comment = previous versions with wide links allowed
2183 vfs objects = shadow_copy2
2184 shadow:mountpoint = $shadow_mntdir
2187 path = $shrdir/dfree
2188 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2189 admin users = $unix_name
2190 include = $dfqconffile
2192 path = $shrdir/dfree
2193 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2194 admin users = $unix_name
2195 include = $dfqconffile
2196 dfree cache time = 60
2198 path = $shrdir/dfree
2199 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2201 include = $dfqconffile
2203 path = $shrdir/quota
2204 admin users = $unix_name
2206 [acl_xattr_ign_sysacl_posix]
2208 acl_xattr:ignore system acls = yes
2209 acl_xattr:default acl style = posix
2210 [acl_xattr_ign_sysacl_windows]
2212 acl_xattr:ignore system acls = yes
2213 acl_xattr:default acl style = windows
2217 mangled names = illegal
2221 path = $nosymlinks_shrdir
2222 follow symlinks = no
2226 path = $local_symlinks_shrdir
2227 follow symlinks = yes
2231 kernel oplocks = yes
2232 vfs objects = streams_xattr xattr_tdb
2236 vfs objects = streams_xattr xattr_tdb
2240 smbd:find async delay usec = 10000
2243 vfs objects = error_inject
2244 include = $libdir/error_inject.conf
2248 vfs objects = delay_inject
2249 kernel share modes = no
2252 include = $libdir/delay_inject.conf
2256 vfs objects = delay_inject
2257 delay_inject:pread_send = 2000
2258 delay_inject:pwrite_send = 2000
2261 path = $prefix_abs/share
2262 delete readonly = yes
2266 my $net = Samba::bindir_path($self, "net");
2268 $cmd .= "SMB_CONF_PATH=\"$conffile\" ";
2269 $cmd .= "$net setlocalsid $samsid";
2271 if (system($cmd) != 0) {
2272 warn("Join failed\n$cmd");
2276 unless (open(DFQCONF, ">$dfqconffile")) {
2277 warn("Unable to open $dfqconffile");
2283 ## create a test account
2286 unless (open(PASSWD, ">$nss_wrapper_passwd")) {
2287 warn("Unable to open $nss_wrapper_passwd");
2290 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
2291 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
2292 pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2293 pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2294 userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
2295 pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false
2296 force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false
2297 smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false
2298 user1:x:$uid_user1:$gid_nogroup:user1 gecos:$prefix_abs:/bin/false
2299 user2:x:$uid_user2:$gid_nogroup:user2 gecos:$prefix_abs:/bin/false
2301 if ($unix_uid != 0) {
2302 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
2307 unless (open(GROUP, ">$nss_wrapper_group")) {
2308 warn("Unable to open $nss_wrapper_group");
2311 print GROUP "nobody:x:$gid_nobody:
2312 nogroup:x:$gid_nogroup:nobody
2313 $unix_name-group:x:$unix_gids[0]:
2314 domusers:X:$gid_domusers:
2315 domadmins:X:$gid_domadmins:
2316 userdup:x:$gid_userdup:$unix_name
2317 everyone:x:$gid_everyone:
2318 force_user:x:$gid_force_user:
2320 if ($unix_gids[0] != 0) {
2321 print GROUP "root:x:$gid_root:
2328 my $hostname = lc($server);
2329 unless (open(HOSTS, ">>$nss_wrapper_hosts")) {
2330 warn("Unable to open $nss_wrapper_hosts");
2333 print HOSTS "${server_ip} ${hostname}.samba.example.com ${hostname}\n";
2334 print HOSTS "${server_ipv6} ${hostname}.samba.example.com ${hostname}\n";
2338 unless (open(RESOLV_CONF, ">$resolv_conf")) {
2339 warn("Unable to open $resolv_conf");
2342 if (defined($dc_server_ip) or defined($dc_server_ipv6)) {
2343 if (defined($dc_server_ip)) {
2344 print RESOLV_CONF "nameserver $dc_server_ip\n";
2346 if (defined($dc_server_ipv6)) {
2347 print RESOLV_CONF "nameserver $dc_server_ipv6\n";
2350 print RESOLV_CONF "nameserver ${server_ip}\n";
2351 print RESOLV_CONF "nameserver ${server_ipv6}\n";
2355 foreach my $evlog (@eventlog_list) {
2356 my $evlogtdb = "$eventlogdir/$evlog.tdb";
2357 open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
2361 $createuser_env{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2362 $createuser_env{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2363 $createuser_env{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2364 $createuser_env{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2365 if ($ENV{SAMBA_DNS_FAKING}) {
2366 $createuser_env{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2368 $createuser_env{RESOLV_WRAPPER_CONF} = $resolv_conf;
2371 createuser($self, $unix_name, $password, $conffile, \%createuser_env) || die("Unable to create user");
2372 createuser($self, "force_user", $password, $conffile, \%createuser_env) || die("Unable to create force_user");
2373 createuser($self, "smbget_user", $password, $conffile, \%createuser_env) || die("Unable to create smbget_user");
2374 createuser($self, "user1", $password, $conffile, \%createuser_env) || die("Unable to create user1");
2375 createuser($self, "user2", $password, $conffile, \%createuser_env) || die("Unable to create user2");
2377 open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
2378 print DNS_UPDATE_LIST "A $server. $server_ip\n";
2379 print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n";
2380 close(DNS_UPDATE_LIST);
2384 $ret{SERVER_IP} = $server_ip;
2385 $ret{SERVER_IPV6} = $server_ipv6;
2386 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
2387 $ret{NMBD_TEST_LOG_POS} = 0;
2388 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
2389 $ret{WINBINDD_TEST_LOG_POS} = 0;
2390 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
2391 $ret{SMBD_TEST_LOG_POS} = 0;
2392 $ret{SERVERCONFFILE} = $conffile;
2393 $ret{CONFIGURATION} ="-s $conffile";
2394 $ret{LOCK_DIR} = $lockdir;
2395 $ret{SERVER} = $server;
2396 $ret{USERNAME} = $unix_name;
2397 $ret{USERID} = $unix_uid;
2398 $ret{DOMAIN} = $domain;
2399 $ret{SAMSID} = $samsid;
2400 $ret{NETBIOSNAME} = $server;
2401 $ret{PASSWORD} = $password;
2402 $ret{PIDDIR} = $piddir;
2403 $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir;
2404 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
2405 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
2406 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2407 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2408 $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2409 $ret{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2410 $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
2411 $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind";
2412 if ($ENV{SAMBA_DNS_FAKING}) {
2413 $ret{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2415 $ret{RESOLV_WRAPPER_CONF} = $resolv_conf;
2417 $ret{LOCAL_PATH} = "$shrdir";
2418 $ret{LOGDIR} = $logdir;
2421 # Avoid hitting system krb5.conf -
2422 # An env that needs Kerberos will reset this to the real
2425 $ret{KRB5_CONFIG} = abs_path($prefix) . "/no_krb5.conf";
2427 # Define KRB5CCNAME for each environment we set up
2428 $ret{KRB5_CCACHE} = abs_path($prefix) . "/krb5ccache";
2429 $ENV{KRB5CCNAME} = $ret{KRB5_CCACHE};
2434 sub wait_for_start($$$$$)
2436 my ($self, $envvars, $nmbd, $winbindd, $smbd) = @_;
2441 if ($nmbd eq "yes") {
2444 # give time for nbt server to register its names
2445 print "checking for nmbd\n";
2447 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
2448 my $nmblookup = Samba::bindir_path($self, "nmblookup");
2451 $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
2455 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
2456 system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
2457 system("$nmblookup $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
2458 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
2461 } while ($ret != 0 && $count < 10);
2463 print "NMBD not reachable after 10 retries\n";
2464 teardown_env($self, $envvars);
2469 if ($winbindd eq "yes") {
2470 print "checking for winbindd\n";
2472 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2473 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2474 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2475 $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping-dc";
2479 $ret = system($cmd);
2483 } while ($ret != 0 && $count < 20);
2485 print "WINBINDD not reachable after 20 seconds\n";
2486 teardown_env($self, $envvars);
2491 if ($smbd eq "yes") {
2492 # make sure smbd is also up set
2493 print "wait for smbd\n";
2497 $ret = system(Samba::bindir_path($self, "smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139");
2502 } while ($ret != 0 && $count < 20);
2504 print "SMBD failed to start up in a reasonable time (20sec)\n";
2505 teardown_env($self, $envvars);
2510 # Ensure we have domain users mapped.
2511 $netcmd = "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2512 $netcmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2513 $netcmd .= Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} ";
2515 $cmd = $netcmd . "groupmap delete ntgroup=domusers";
2516 $ret = system($cmd);
2518 $cmd = $netcmd . "groupmap add rid=513 unixgroup=domusers type=domain";
2519 $ret = system($cmd);
2521 print("\"$cmd\" failed\n");
2525 $cmd = $netcmd . "groupmap delete ntgroup=domadmins";
2526 $ret = system($cmd);
2528 $cmd = $netcmd . "groupmap add rid=512 unixgroup=domadmins type=domain";
2529 $ret = system($cmd);
2531 print("\"$cmd\" failed\n");
2535 $cmd = $netcmd . "groupmap delete ntgroup=everyone";
2536 $ret = system($cmd);
2538 $cmd = $netcmd . "groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin";
2539 $ret = system($cmd);
2541 print("\"$cmd\" failed\n");
2545 # note: creating builtin groups requires winbindd for the
2547 my $create_builtin_users = "no";
2548 if ($winbindd eq "yes") {
2549 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2550 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2551 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2552 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
2553 my $wbinfo_out = qx($cmd 2>&1);
2555 # wbinfo doesn't give us a better error code then
2556 # WBC_ERR_DOMAIN_NOT_FOUND, but at least that's
2557 # different then WBC_ERR_WINBIND_NOT_AVAILABLE
2558 if ($wbinfo_out !~ /WBC_ERR_DOMAIN_NOT_FOUND/) {
2559 print("Failed to run \"wbinfo --sid-to-gid=S-1-5-32-545\": $wbinfo_out");
2560 teardown_env($self, $envvars);
2563 $create_builtin_users = "yes";
2566 if ($create_builtin_users eq "yes") {
2567 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2568 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2569 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2570 $cmd .= Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
2571 $cmd .= "sam createbuiltingroup Users";
2572 $ret = system($cmd);
2574 print "Failed to create BUILTIN\\Users group\n";
2575 teardown_env($self, $envvars);
2579 $cmd = Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
2580 $cmd .= "cache del IDMAP/SID2XID/S-1-5-32-545";
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, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
2587 $ret = system($cmd);
2589 print "Missing \"BUILTIN\\Users\", did net sam createbuiltingroup Users fail?\n";
2590 teardown_env($self, $envvars);
2595 print $self->getlog_env($envvars);