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 path = $prefix_abs/share
844 hide new files timeout = 5
847 my $vars = $self->provision($path, "WORKGROUP",
850 $simpleserver_options);
852 $vars or return undef;
854 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
863 my ($self, $path) = @_;
864 my $prefix_abs = abs_path($path);
865 my $srcdir_abs = abs_path($self->{srcdir});
867 print "PROVISIONING file server ...\n";
871 mkdir($prefix_abs, 0777);
873 my $usershare_dir="$prefix_abs/lib/usershare";
875 mkdir("$prefix_abs/lib", 0755);
876 remove_tree($usershare_dir);
877 mkdir($usershare_dir, 01770);
879 my $share_dir="$prefix_abs/share";
881 # Create share directory structure
882 my $lower_case_share_dir="$share_dir/lower-case";
883 push(@dirs, $lower_case_share_dir);
885 my $lower_case_share_dir_30000="$share_dir/lower-case-30000";
886 push(@dirs, $lower_case_share_dir_30000);
888 my $dfree_share_dir="$share_dir/dfree";
889 push(@dirs, $dfree_share_dir);
890 push(@dirs, "$dfree_share_dir/subdir1");
891 push(@dirs, "$dfree_share_dir/subdir2");
892 push(@dirs, "$dfree_share_dir/subdir3");
894 my $quotadir_dir="$share_dir/quota";
895 push(@dirs, $quotadir_dir);
897 my $valid_users_sharedir="$share_dir/valid_users";
898 push(@dirs,$valid_users_sharedir);
900 my $offline_sharedir="$share_dir/offline";
901 push(@dirs,$offline_sharedir);
903 my $force_user_valid_users_dir = "$share_dir/force_user_valid_users";
904 push(@dirs, $force_user_valid_users_dir);
906 my $smbget_sharedir="$share_dir/smbget";
907 push(@dirs,$smbget_sharedir);
909 my $tarmode_sharedir="$share_dir/tarmode";
910 push(@dirs,$tarmode_sharedir);
912 my $usershare_sharedir="$share_dir/usershares";
913 push(@dirs,$usershare_sharedir);
915 my $fileserver_options = "
916 kernel change notify = yes
918 usershare path = $usershare_dir
919 usershare max shares = 10
920 usershare allow guests = yes
921 usershare prefix allow list = $usershare_sharedir
923 get quota command = $prefix_abs/getset_quota.py
924 set quota command = $prefix_abs/getset_quota.py
926 path = $lower_case_share_dir
927 comment = smb username is [%U]
928 case sensitive = True
931 short preserve case = no
933 path = $lower_case_share_dir_30000
934 comment = smb username is [%U]
935 case sensitive = True
938 short preserve case = no
940 path = $dfree_share_dir
941 comment = smb username is [%U]
942 dfree command = $srcdir_abs/testprogs/blackbox/dfree.sh
944 path = $valid_users_sharedir
945 valid users = +userdup
947 path = $offline_sharedir
948 vfs objects = offline
950 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878
951 # RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651
952 [force_user_valid_users]
953 path = $force_user_valid_users_dir
954 comment = force user with valid users combination test share
955 valid users = +force_user
956 force user = force_user
957 force group = everyone
958 write list = force_user
961 path = $smbget_sharedir
962 comment = smb username is [%U]
966 comment = ignore system acls
967 acl_xattr:ignore system acls = yes
970 comment = inherit owner
974 comment = inherit only unix owner
975 inherit owner = unix only
976 acl_xattr:ignore system acls = yes
979 my $vars = $self->provision($path, "WORKGROUP",
987 $vars or return undef;
989 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
994 mkdir($_, 0777) foreach(@dirs);
996 ## Create case sensitive lower case share dir
997 foreach my $file ('a'..'z') {
998 my $full_path = $lower_case_share_dir . '/' . $file;
999 open my $fh, '>', $full_path;
1000 # Add some content to file
1001 print $fh $full_path;
1005 for (my $file = 1; $file < 51; ++$file) {
1006 my $full_path = $lower_case_share_dir . '/' . $file;
1007 open my $fh, '>', $full_path;
1008 # Add some content to file
1009 print $fh $full_path;
1013 # Create content for 30000 share
1014 foreach my $file ('a'..'z') {
1015 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1016 open my $fh, '>', $full_path;
1017 # Add some content to file
1018 print $fh $full_path;
1022 for (my $file = 1; $file < 30001; ++$file) {
1023 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1024 open my $fh, '>', $full_path;
1025 # Add some content to file
1026 print $fh $full_path;
1031 ## create a listable file in valid_users_share
1033 my $valid_users_target = "$valid_users_sharedir/foo";
1034 unless (open(VALID_USERS_TARGET, ">$valid_users_target")) {
1035 warn("Unable to open $valid_users_target");
1038 close(VALID_USERS_TARGET);
1039 chmod 0644, $valid_users_target;
1046 my ($self, $prefix) = @_;
1048 # If we didn't build with ADS, pretend this env was never available
1049 if (not $self->have_ads()) {
1053 print "PROVISIONING server with security=ads...";
1055 my $ktest_options = "
1057 realm = ktest.samba.example.com
1059 username map = $prefix/lib/username.map
1060 server signing = required
1061 server min protocol = SMB3_00
1062 client max protocol = SMB3
1064 # This disables NTLM auth against the local SAM, which
1065 # we use can then test this setting by.
1066 ntlm auth = disabled
1069 my $ret = $self->provision($prefix, "KTEST",
1074 $ret or return undef;
1077 my $prefix_abs = abs_path($prefix);
1079 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1080 $ctx->{domain} = "KTEST";
1081 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
1082 $ctx->{dnsname} = lc($ctx->{realm});
1083 $ctx->{kdc_ipv4} = "0.0.0.0";
1084 $ctx->{kdc_ipv6} = "::";
1085 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1086 Samba::mk_krb5_conf($ctx, "");
1088 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1090 open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map");
1092 $ret->{USERNAME} = KTEST\\Administrator
1096 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
1097 #Samba4 DC with the same parameters as are being used here. The
1098 #domain SID is S-1-5-21-1071277805-689288055-3486227160
1099 $ret->{SAMSID} = "S-1-5-21-1911091480-1468226576-2729736297";
1100 $ret->{DOMSID} = "S-1-5-21-1071277805-689288055-3486227160";
1102 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
1103 chmod 0600, "$prefix/private/secrets.tdb";
1105 #Make sure there's no old ntdb file.
1106 system("rm -f $prefix/private/secrets.ntdb");
1108 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
1109 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
1111 #and having in krb5.conf:
1112 # ticket_lifetime = 799718400
1113 # renew_lifetime = 799718400
1115 # The commands for the -2 keytab where were:
1116 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
1117 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
1118 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
1119 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1120 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1122 # and then for the -3 keytab, I did
1124 # net changetrustpw; kdestroy and the same again.
1126 # This creates a credential cache with a very long lifetime (2036 at
1127 # at 2011-04), and shows that running 'net changetrustpw' does not
1128 # break existing logins (for the secrets.tdb method at least).
1131 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
1133 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
1134 chmod 0600, "$prefix/krb5_ccache-2";
1136 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
1137 chmod 0600, "$prefix/krb5_ccache-3";
1139 # We need world access to this share, as otherwise the domain
1140 # administrator from the AD domain provided by ktest can't
1141 # access the share for tests.
1142 chmod 0777, "$prefix/share";
1144 if (not $self->check_or_start($ret, "yes", "no", "yes")) {
1150 sub setup_maptoguest
1152 my ($self, $path) = @_;
1154 print "PROVISIONING maptoguest...";
1157 map to guest = bad user
1161 my $vars = $self->provision($path, "WORKGROUP",
1166 $vars or return undef;
1168 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
1175 sub stop_sig_term($$) {
1176 my ($self, $pid) = @_;
1177 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1180 sub stop_sig_kill($$) {
1181 my ($self, $pid) = @_;
1182 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1187 my ($env_vars, $app, $pid) = @_;
1189 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
1196 my ($env_vars, $app) = @_;
1198 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
1204 sub check_or_start($$$$$) {
1205 my ($self, $env_vars, $nmbd, $winbindd, $smbd) = @_;
1207 # use a pipe for stdin in the child processes. This allows
1208 # those processes to monitor the pipe for EOF to ensure they
1209 # exit when the test script exits
1210 pipe(STDIN_READER, $env_vars->{STDIN_PIPE});
1212 unlink($env_vars->{NMBD_TEST_LOG});
1213 print "STARTING NMBD...";
1216 open STDOUT, ">$env_vars->{NMBD_TEST_LOG}";
1217 open STDERR, '>&STDOUT';
1219 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1221 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1222 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.nmbd";
1223 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1224 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1226 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1227 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1228 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1229 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1230 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1231 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1232 $ENV{UID_WRAPPER_ROOT} = "1";
1234 $ENV{ENVNAME} = "$ENV{ENVNAME}.nmbd";
1236 if ($nmbd ne "yes") {
1237 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1238 my $signame = shift;
1239 print("Skip nmbd received signal $signame");
1242 sleep($self->{server_maxtime});
1246 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "nmbd");
1247 my @optargs = ("-d0");
1248 if (defined($ENV{NMBD_OPTIONS})) {
1249 @optargs = split(/ /, $ENV{NMBD_OPTIONS});
1251 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1252 if(defined($ENV{NMBD_VALGRIND})) {
1253 @preargs = split(/ /, $ENV{NMBD_VALGRIND});
1255 my @args = ("-F", "--no-process-group",
1256 "-s", $env_vars->{SERVERCONFFILE},
1257 "-l", $env_vars->{LOGDIR});
1258 if (not defined($ENV{NMBD_DONT_LOG_STDOUT})) {
1259 push(@args, "--log-stdout");
1262 close($env_vars->{STDIN_PIPE});
1263 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1265 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1266 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1268 $env_vars->{NMBD_TL_PID} = $pid;
1269 write_pid($env_vars, "nmbd", $pid);
1272 unlink($env_vars->{WINBINDD_TEST_LOG});
1273 print "STARTING WINBINDD...";
1276 open STDOUT, ">$env_vars->{WINBINDD_TEST_LOG}";
1277 open STDERR, '>&STDOUT';
1279 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1281 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1282 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.winbindd";
1283 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1284 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1286 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1287 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1288 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1289 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1290 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1291 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1292 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
1293 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
1295 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
1297 $ENV{UID_WRAPPER_ROOT} = "1";
1299 $ENV{ENVNAME} = "$ENV{ENVNAME}.winbindd";
1301 if ($winbindd ne "yes") {
1302 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1303 my $signame = shift;
1304 print("Skip winbindd received signal $signame");
1307 sleep($self->{server_maxtime});
1311 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "winbindd");
1312 my @optargs = ("-d0");
1313 if (defined($ENV{WINBINDD_OPTIONS})) {
1314 @optargs = split(/ /, $ENV{WINBINDD_OPTIONS});
1316 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1317 if(defined($ENV{WINBINDD_VALGRIND})) {
1318 @preargs = split(/ /, $ENV{WINBINDD_VALGRIND});
1320 my @args = ("-F", "--no-process-group",
1321 "-s", $env_vars->{SERVERCONFFILE},
1322 "-l", $env_vars->{LOGDIR});
1323 if (not defined($ENV{WINBINDD_DONT_LOG_STDOUT})) {
1324 push(@args, "--stdout");
1327 close($env_vars->{STDIN_PIPE});
1328 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1330 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1331 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1333 $env_vars->{WINBINDD_TL_PID} = $pid;
1334 write_pid($env_vars, "winbindd", $pid);
1337 unlink($env_vars->{SMBD_TEST_LOG});
1338 print "STARTING SMBD...";
1341 open STDOUT, ">$env_vars->{SMBD_TEST_LOG}";
1342 open STDERR, '>&STDOUT';
1344 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1346 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1347 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.smbd";
1348 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1349 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1351 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1352 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1353 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1354 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1355 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1356 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1357 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
1358 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
1360 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
1362 $ENV{UID_WRAPPER_ROOT} = "1";
1364 $ENV{ENVNAME} = "$ENV{ENVNAME}.smbd";
1366 if ($smbd ne "yes") {
1367 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1368 my $signame = shift;
1369 print("Skip smbd received signal $signame");
1372 sleep($self->{server_maxtime});
1376 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "smbd");
1377 my @optargs = ("-d0");
1378 if (defined($ENV{SMBD_OPTIONS})) {
1379 @optargs = split(/ /, $ENV{SMBD_OPTIONS});
1381 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1382 if(defined($ENV{SMBD_VALGRIND})) {
1383 @preargs = split(/ /,$ENV{SMBD_VALGRIND});
1385 my @args = ("-F", "--no-process-group",
1386 "-s", $env_vars->{SERVERCONFFILE},
1387 "-l", $env_vars->{LOGDIR});
1388 if (not defined($ENV{SMBD_DONT_LOG_STDOUT})) {
1389 push(@args, "--log-stdout");
1392 close($env_vars->{STDIN_PIPE});
1393 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1395 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1396 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1398 $env_vars->{SMBD_TL_PID} = $pid;
1399 write_pid($env_vars, "smbd", $pid);
1402 close(STDIN_READER);
1404 return $self->wait_for_start($env_vars, $nmbd, $winbindd, $smbd);
1407 sub createuser($$$$$)
1409 my ($self, $username, $password, $conffile, $env) = @_;
1410 my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $username > /dev/null";
1413 while(my($var, $val) = each %$env) {
1414 $cmd = "$var=\"$val\" $cmd";
1417 unless (open(PWD, "|$cmd")) {
1418 warn("Unable to set password for $username account\n$cmd");
1421 print PWD "$password\n$password\n";
1422 unless (close(PWD)) {
1423 warn("Unable to set password for $username account\n$cmd");
1428 sub provision($$$$$$$$$)
1430 my ($self, $prefix, $domain, $server, $password, $extra_options, $dc_server_ip, $dc_server_ipv6, $no_delete_prefix) = @_;
1433 ## setup the various environment variables we need
1436 my $samsid = Samba::random_domain_sid();
1437 my $swiface = Samba::get_interface($server);
1439 my %createuser_env = ();
1440 my $server_ip = "127.0.0.$swiface";
1441 my $server_ipv6 = sprintf("fd00:0000:0000:0000:0000:0000:5357:5f%02x", $swiface);
1443 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
1446 my $unix_gids_str = $);
1447 my @unix_gids = split(" ", $unix_gids_str);
1449 my $prefix_abs = abs_path($prefix);
1450 my $bindir_abs = abs_path($self->{bindir});
1454 my $shrdir="$prefix_abs/share";
1455 push(@dirs,$shrdir);
1457 my $libdir="$prefix_abs/lib";
1458 push(@dirs,$libdir);
1460 my $piddir="$prefix_abs/pid";
1461 push(@dirs,$piddir);
1463 my $privatedir="$prefix_abs/private";
1464 push(@dirs,$privatedir);
1466 my $binddnsdir = "$prefix_abs/bind-dns";
1467 push(@dirs, $binddnsdir);
1469 my $lockdir="$prefix_abs/lockdir";
1470 push(@dirs,$lockdir);
1472 my $eventlogdir="$prefix_abs/lockdir/eventlog";
1473 push(@dirs,$eventlogdir);
1475 my $logdir="$prefix_abs/logs";
1476 push(@dirs,$logdir);
1478 my $driver32dir="$shrdir/W32X86";
1479 push(@dirs,$driver32dir);
1481 my $driver64dir="$shrdir/x64";
1482 push(@dirs,$driver64dir);
1484 my $driver40dir="$shrdir/WIN40";
1485 push(@dirs,$driver40dir);
1487 my $ro_shrdir="$shrdir/root-tmp";
1488 push(@dirs,$ro_shrdir);
1490 my $msdfs_shrdir="$shrdir/msdfsshare";
1491 push(@dirs,$msdfs_shrdir);
1493 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
1494 push(@dirs,$msdfs_deeppath);
1496 my $badnames_shrdir="$shrdir/badnames";
1497 push(@dirs,$badnames_shrdir);
1499 my $lease1_shrdir="$shrdir/SMB2_10";
1500 push(@dirs,$lease1_shrdir);
1502 my $lease2_shrdir="$shrdir/SMB3_00";
1503 push(@dirs,$lease2_shrdir);
1505 my $manglenames_shrdir="$shrdir/manglenames";
1506 push(@dirs,$manglenames_shrdir);
1508 my $widelinks_shrdir="$shrdir/widelinks";
1509 push(@dirs,$widelinks_shrdir);
1511 my $widelinks_linkdir="$shrdir/widelinks_foo";
1512 push(@dirs,$widelinks_linkdir);
1514 my $shadow_tstdir="$shrdir/shadow";
1515 push(@dirs,$shadow_tstdir);
1516 my $shadow_mntdir="$shadow_tstdir/mount";
1517 push(@dirs,$shadow_mntdir);
1518 my $shadow_basedir="$shadow_mntdir/base";
1519 push(@dirs,$shadow_basedir);
1520 my $shadow_shrdir="$shadow_basedir/share";
1521 push(@dirs,$shadow_shrdir);
1523 my $nosymlinks_shrdir="$shrdir/nosymlinks";
1524 push(@dirs,$nosymlinks_shrdir);
1526 my $local_symlinks_shrdir="$shrdir/local_symlinks";
1527 push(@dirs,$local_symlinks_shrdir);
1529 # this gets autocreated by winbindd
1530 my $wbsockdir="$prefix_abs/winbindd";
1532 my $nmbdsockdir="$prefix_abs/nmbd";
1533 unlink($nmbdsockdir);
1536 ## create the test directory layout
1538 die ("prefix_abs = ''") if $prefix_abs eq "";
1539 die ("prefix_abs = '/'") if $prefix_abs eq "/";
1541 mkdir($prefix_abs, 0777);
1542 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
1543 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
1544 system("rm -rf $prefix_abs/*");
1546 mkdir($_, 0777) foreach(@dirs);
1548 my $fs_specific_conf = $self->get_fs_specific_conf($shrdir);
1551 ## lockdir and piddir must be 0755
1553 chmod 0755, $lockdir;
1554 chmod 0755, $piddir;
1558 ## create ro and msdfs share layout
1561 chmod 0755, $ro_shrdir;
1562 my $unreadable_file = "$ro_shrdir/unreadable_file";
1563 unless (open(UNREADABLE_FILE, ">$unreadable_file")) {
1564 warn("Unable to open $unreadable_file");
1567 close(UNREADABLE_FILE);
1568 chmod 0600, $unreadable_file;
1570 my $msdfs_target = "$ro_shrdir/msdfs-target";
1571 unless (open(MSDFS_TARGET, ">$msdfs_target")) {
1572 warn("Unable to open $msdfs_target");
1575 close(MSDFS_TARGET);
1576 chmod 0666, $msdfs_target;
1577 symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp",
1578 "$msdfs_shrdir/msdfs-src1";
1579 symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
1582 ## create bad names in $badnames_shrdir
1584 ## (An invalid name, would be mangled to 8.3).
1585 my $badname_target = "$badnames_shrdir/\340|\231\216\377\177";
1586 unless (open(BADNAME_TARGET, ">$badname_target")) {
1587 warn("Unable to open $badname_target");
1590 close(BADNAME_TARGET);
1591 chmod 0666, $badname_target;
1593 ## (A bad name, would not be mangled to 8.3).
1594 my $badname_target = "$badnames_shrdir/\240\276\346\327\377\177";
1595 unless (open(BADNAME_TARGET, ">$badname_target")) {
1596 warn("Unable to open $badname_target");
1599 close(BADNAME_TARGET);
1600 chmod 0666, $badname_target;
1602 ## (A bad good name).
1603 my $badname_target = "$badnames_shrdir/blank.txt";
1604 unless (open(BADNAME_TARGET, ">$badname_target")) {
1605 warn("Unable to open $badname_target");
1608 close(BADNAME_TARGET);
1609 chmod 0666, $badname_target;
1612 ## create mangleable directory names in $manglenames_shrdir
1614 my $manglename_target = "$manglenames_shrdir/foo:bar";
1615 mkdir($manglename_target, 0777);
1618 ## create symlinks for widelinks tests.
1620 my $widelinks_target = "$widelinks_linkdir/target";
1621 unless (open(WIDELINKS_TARGET, ">$widelinks_target")) {
1622 warn("Unable to open $widelinks_target");
1625 close(WIDELINKS_TARGET);
1626 chmod 0666, $widelinks_target;
1628 ## This link should get ACCESS_DENIED
1630 symlink "$widelinks_target", "$widelinks_shrdir/source";
1632 ## This link should be allowed
1634 symlink "$widelinks_shrdir", "$widelinks_shrdir/dot";
1636 my $conffile="$libdir/server.conf";
1637 my $dfqconffile="$libdir/dfq.conf";
1639 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/third_party/nss_wrapper/nss_wrapper.pl";
1640 my $nss_wrapper_passwd = "$privatedir/passwd";
1641 my $nss_wrapper_group = "$privatedir/group";
1642 my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts";
1643 my $resolv_conf = "$privatedir/resolv.conf";
1644 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
1646 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
1648 my $fake_snap_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/fake_snap.pl";
1650 my @eventlog_list = ("dns server", "application");
1653 ## calculate uids and gids
1656 my ($max_uid, $max_gid);
1657 my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
1658 my ($uid_pdbtest_wkn);
1660 my ($uid_force_user);
1661 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
1662 my ($gid_userdup, $gid_everyone);
1663 my ($gid_force_user);
1667 if ($unix_uid < 0xffff - 10) {
1670 $max_uid = $unix_uid;
1673 $uid_root = $max_uid - 1;
1674 $uid_nobody = $max_uid - 2;
1675 $uid_pdbtest = $max_uid - 3;
1676 $uid_pdbtest2 = $max_uid - 4;
1677 $uid_userdup = $max_uid - 5;
1678 $uid_pdbtest_wkn = $max_uid - 6;
1679 $uid_force_user = $max_uid - 7;
1680 $uid_smbget = $max_uid - 8;
1681 $uid_user1 = $max_uid - 9;
1682 $uid_user2 = $max_uid - 10;
1684 if ($unix_gids[0] < 0xffff - 8) {
1687 $max_gid = $unix_gids[0];
1690 $gid_nobody = $max_gid - 1;
1691 $gid_nogroup = $max_gid - 2;
1692 $gid_root = $max_gid - 3;
1693 $gid_domusers = $max_gid - 4;
1694 $gid_domadmins = $max_gid - 5;
1695 $gid_userdup = $max_gid - 6;
1696 $gid_everyone = $max_gid - 7;
1697 $gid_force_user = $max_gid - 8;
1703 unless (open(CONF, ">$conffile")) {
1704 warn("Unable to open $conffile");
1709 netbios name = $server
1710 interfaces = $server_ip/8 $server_ipv6/64
1711 bind interfaces only = yes
1712 panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
1713 smbd:suicide mode = yes
1717 private dir = $privatedir
1718 binddns dir = $binddnsdir
1719 pid directory = $piddir
1720 lock directory = $lockdir
1721 log file = $logdir/log.\%m
1726 state directory = $lockdir
1727 cache directory = $lockdir
1729 passdb backend = tdbsam
1733 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1734 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
1735 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1736 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
1737 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
1738 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
1739 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
1741 addprinter command = $mod_printer_pl -a -s $conffile --
1742 deleteprinter command = $mod_printer_pl -d -s $conffile --
1744 eventlog list = application \"dns server\"
1747 kernel change notify = no
1751 printcap name = /dev/null
1753 winbindd socket directory = $wbsockdir
1754 nmbd:socket dir = $nmbdsockdir
1755 idmap config * : range = 100000-200000
1756 winbind enum users = yes
1757 winbind enum groups = yes
1758 winbind separator = /
1759 include system krb5 conf = no
1761 # min receivefile size = 4000
1765 smbd:sharedelay = 100000
1766 smbd:writetimeupdatedelay = 500000
1770 store dos attributes = yes
1775 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot time_audit full_audit
1777 full_audit:syslog = no
1778 full_audit:success = none
1779 full_audit:failure = none
1782 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
1783 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
1784 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
1785 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
1786 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
1787 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
1788 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
1790 print notify backchannel = yes
1792 ncalrpc dir = $prefix_abs/ncalrpc
1794 # The samba3.blackbox.smbclient_s3 test uses this to test that
1795 # sending messages works, and that the %m sub works.
1796 message command = mv %s $shrdir/message.%m
1798 # fsrvp server requires registry shares
1799 registry shares = yes
1801 # Used by RPC SRVSVC tests
1802 add share command = $bindir_abs/smbaddshare
1803 change share command = $bindir_abs/smbchangeshare
1804 delete share command = $bindir_abs/smbdeleteshare
1806 # fruit:copyfile is a global option
1807 fruit:copyfile = yes
1809 #this does not mean that we use non-secure test env,
1810 #it just means we ALLOW one to be configured.
1811 allow insecure wide links = yes
1813 # Begin extra options
1817 #Include user defined custom parameters if set
1820 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
1821 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
1827 comment = smb username is [%U]
1830 comment = Load dirsort module
1831 vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot
1834 comment = encrypt smb username is [%U]
1835 smb encrypt = required
1836 vfs objects = dirsort
1846 force user = $unix_name
1848 [forceuser_unixonly]
1849 comment = force a user with unix user SID and group SID
1851 force user = pdbtest
1853 [forceuser_wkngroup]
1854 comment = force a user with well-known group SID
1856 force user = pdbtest_wkn
1860 force group = nogroup
1868 write list = $unix_name
1871 valid users = $unix_name
1872 access based share enum = yes
1874 path = $msdfs_shrdir
1876 msdfs shuffle referrals = yes
1880 hide unreadable = yes
1883 case sensitive = yes
1886 hide unwriteable files = yes
1889 kernel share modes = no
1903 default devmode = no
1909 comment = smb username is [%U]
1911 nfs4acl_xattr:version = 40
1912 vfs objects = nfs4acl_xattr xattr_tdb
1914 [nfs4acl_special_40]
1916 comment = smb username is [%U]
1918 nfs4acl_xattr:version = 40
1919 vfs objects = nfs4acl_xattr xattr_tdb
1923 comment = smb username is [%U]
1925 vfs objects = nfs4acl_xattr xattr_tdb
1929 comment = smb username is [%U]
1930 vfs objects = nfs4acl_xattr xattr_tdb
1932 nfs4acl_xattr:encoding = xdr
1933 nfs4acl_xattr:version = 40
1937 comment = smb username is [%U]
1938 vfs objects = nfs4acl_xattr xattr_tdb
1940 nfs4acl_xattr:encoding = xdr
1941 nfs4acl_xattr:version = 41
1945 comment = smb username is [%U]
1947 force create mode = 777
1950 comment = smb username is [%U]
1952 force create mode = 0
1953 directory mask = 0777
1954 force directory mode = 0
1955 vfs objects = xattr_tdb streams_depot
1966 vfs objects = catia fruit streams_xattr acl_xattr xattr_tdb
1967 fruit:resource = file
1968 fruit:metadata = netatalk
1969 fruit:locking = netatalk
1970 fruit:encoding = native
1971 fruit:veto_appledouble = no
1975 # This is used by vfs.fruit tests that require real fs xattr
1976 vfs objects = catia fruit streams_xattr acl_xattr
1977 fruit:resource = file
1978 fruit:metadata = netatalk
1979 fruit:locking = netatalk
1980 fruit:encoding = native
1981 fruit:veto_appledouble = no
1983 [vfs_fruit_metadata_stream]
1985 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
1986 fruit:resource = file
1987 fruit:metadata = stream
1988 fruit:veto_appledouble = no
1990 [vfs_fruit_stream_depot]
1992 vfs objects = fruit streams_depot acl_xattr xattr_tdb
1993 fruit:resource = stream
1994 fruit:metadata = stream
1995 fruit:veto_appledouble = no
1999 vfs objects = streams_xattr acl_xattr xattr_tdb
2001 [vfs_wo_fruit_stream_depot]
2003 vfs objects = streams_depot acl_xattr xattr_tdb
2005 [vfs_fruit_timemachine]
2007 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2008 fruit:resource = file
2009 fruit:metadata = stream
2010 fruit:time machine = yes
2011 fruit:time machine max size = 32K
2013 [vfs_fruit_wipe_intentionally_left_blank_rfork]
2015 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2016 fruit:resource = file
2017 fruit:metadata = stream
2018 fruit:wipe_intentionally_left_blank_rfork = true
2019 fruit:delete_empty_adfiles = false
2020 fruit:veto_appledouble = no
2022 [vfs_fruit_delete_empty_adfiles]
2024 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2025 fruit:resource = file
2026 fruit:metadata = stream
2027 fruit:wipe_intentionally_left_blank_rfork = true
2028 fruit:delete_empty_adfiles = true
2029 fruit:veto_appledouble = no
2032 path = $badnames_shrdir
2036 path = $manglenames_shrdir
2044 path = $widelinks_shrdir
2050 comment = fake shapshots using rsync
2051 vfs objects = shell_snap shadow_copy2
2052 shell_snap:check path command = $fake_snap_pl --check
2053 shell_snap:create command = $fake_snap_pl --create
2054 shell_snap:delete command = $fake_snap_pl --delete
2055 # a relative path here fails, the snapshot dir is no longer found
2056 shadow:snapdir = $shrdir/.snapshots
2059 path = $shadow_shrdir
2060 comment = previous versions snapshots under mount point
2061 vfs objects = shadow_copy2
2062 shadow:mountpoint = $shadow_mntdir
2065 path = $shadow_shrdir
2066 comment = previous versions snapshots outside mount point
2067 vfs objects = shadow_copy2
2068 shadow:mountpoint = $shadow_mntdir
2069 shadow:snapdir = $shadow_tstdir/.snapshots
2072 path = $shadow_shrdir
2073 comment = previous versions with subvolume snapshots, snapshots under base dir
2074 vfs objects = shadow_copy2
2075 shadow:mountpoint = $shadow_mntdir
2076 shadow:basedir = $shadow_basedir
2077 shadow:snapdir = $shadow_basedir/.snapshots
2080 path = $shadow_shrdir
2081 comment = previous versions with subvolume snapshots, snapshots outside mount point
2082 vfs objects = shadow_copy2
2083 shadow:mountpoint = $shadow_mntdir
2084 shadow:basedir = $shadow_basedir
2085 shadow:snapdir = $shadow_tstdir/.snapshots
2088 path = $shadow_shrdir
2089 comment = previous versions at volume root snapshots under mount point
2090 vfs objects = shadow_copy2
2091 shadow:mountpoint = $shadow_shrdir
2094 path = $shadow_shrdir
2095 comment = previous versions at volume root snapshots outside mount point
2096 vfs objects = shadow_copy2
2097 shadow:mountpoint = $shadow_shrdir
2098 shadow:snapdir = $shadow_tstdir/.snapshots
2101 path = $shadow_shrdir
2102 comment = previous versions snapshots everywhere
2103 vfs objects = shadow_copy2
2104 shadow:mountpoint = $shadow_mntdir
2105 shadow:snapdirseverywhere = yes
2108 path = $shadow_shrdir
2109 comment = previous versions using snapsharepath
2110 vfs objects = shadow_copy2
2111 shadow:mountpoint = $shadow_mntdir
2112 shadow:snapdir = $shadow_tstdir/.snapshots
2113 shadow:snapsharepath = share
2116 comment = Testing shadow:format with default option
2117 vfs object = shadow_copy2
2118 path = $shadow_shrdir
2121 shadow:mountpoint = $shadow_mntdir
2122 shadow:basedir = $shadow_basedir
2123 shadow:snapdir = $shadow_basedir/.snapshots
2124 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2127 comment = Testing shadow:format with only date component
2128 vfs object = shadow_copy2
2129 path = $shadow_shrdir
2132 shadow:mountpoint = $shadow_mntdir
2133 shadow:basedir = $shadow_basedir
2134 shadow:snapdir = $shadow_basedir/.snapshots
2135 shadow:format = \@GMT-%Y-%m-%d
2138 comment = Testing shadow:format with some hardcoded prefix
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 = snap\@GMT-%Y.%m.%d-%H.%M.%S
2149 comment = Testing shadow:format with modified format
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-%H_%M_%S-snap
2160 comment = Testing shadow:snapprefix regex
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:snapprefix = \^s[a-z]*p\$
2169 shadow:format = _GMT-%Y.%m.%d-%H.%M.%S
2172 comment = Testing shadow:snapprefix with delim regex
2173 vfs object = shadow_copy2
2174 path = $shadow_shrdir
2177 shadow:mountpoint = $shadow_mntdir
2178 shadow:basedir = $shadow_basedir
2179 shadow:snapdir = $shadow_basedir/.snapshots
2180 shadow:delimiter = \@GMT
2181 shadow:snapprefix = [a-z]*
2182 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2185 path = $shadow_shrdir
2186 comment = previous versions with wide links allowed
2187 vfs objects = shadow_copy2
2188 shadow:mountpoint = $shadow_mntdir
2191 path = $shrdir/dfree
2192 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2193 admin users = $unix_name
2194 include = $dfqconffile
2196 path = $shrdir/dfree
2197 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2198 admin users = $unix_name
2199 include = $dfqconffile
2200 dfree cache time = 60
2202 path = $shrdir/dfree
2203 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2205 include = $dfqconffile
2207 path = $shrdir/quota
2208 admin users = $unix_name
2210 [acl_xattr_ign_sysacl_posix]
2212 acl_xattr:ignore system acls = yes
2213 acl_xattr:default acl style = posix
2214 [acl_xattr_ign_sysacl_windows]
2216 acl_xattr:ignore system acls = yes
2217 acl_xattr:default acl style = windows
2221 mangled names = illegal
2225 path = $nosymlinks_shrdir
2226 follow symlinks = no
2230 path = $local_symlinks_shrdir
2231 follow symlinks = yes
2235 kernel oplocks = yes
2236 vfs objects = streams_xattr xattr_tdb
2240 vfs objects = streams_xattr xattr_tdb
2244 smbd:find async delay usec = 10000
2247 vfs objects = error_inject
2248 include = $libdir/error_inject.conf
2252 vfs objects = delay_inject
2253 kernel share modes = no
2256 include = $libdir/delay_inject.conf
2260 vfs objects = delay_inject
2261 delay_inject:pread_send = 2000
2262 delay_inject:pwrite_send = 2000
2265 path = $prefix_abs/share
2266 delete readonly = yes
2270 my $net = Samba::bindir_path($self, "net");
2272 $cmd .= "SMB_CONF_PATH=\"$conffile\" ";
2273 $cmd .= "$net setlocalsid $samsid";
2275 if (system($cmd) != 0) {
2276 warn("Join failed\n$cmd");
2280 unless (open(DFQCONF, ">$dfqconffile")) {
2281 warn("Unable to open $dfqconffile");
2287 ## create a test account
2290 unless (open(PASSWD, ">$nss_wrapper_passwd")) {
2291 warn("Unable to open $nss_wrapper_passwd");
2294 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
2295 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
2296 pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2297 pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2298 userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
2299 pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false
2300 force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false
2301 smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false
2302 user1:x:$uid_user1:$gid_nogroup:user1 gecos:$prefix_abs:/bin/false
2303 user2:x:$uid_user2:$gid_nogroup:user2 gecos:$prefix_abs:/bin/false
2305 if ($unix_uid != 0) {
2306 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
2311 unless (open(GROUP, ">$nss_wrapper_group")) {
2312 warn("Unable to open $nss_wrapper_group");
2315 print GROUP "nobody:x:$gid_nobody:
2316 nogroup:x:$gid_nogroup:nobody
2317 $unix_name-group:x:$unix_gids[0]:
2318 domusers:X:$gid_domusers:
2319 domadmins:X:$gid_domadmins:
2320 userdup:x:$gid_userdup:$unix_name
2321 everyone:x:$gid_everyone:
2322 force_user:x:$gid_force_user:
2324 if ($unix_gids[0] != 0) {
2325 print GROUP "root:x:$gid_root:
2332 my $hostname = lc($server);
2333 unless (open(HOSTS, ">>$nss_wrapper_hosts")) {
2334 warn("Unable to open $nss_wrapper_hosts");
2337 print HOSTS "${server_ip} ${hostname}.samba.example.com ${hostname}\n";
2338 print HOSTS "${server_ipv6} ${hostname}.samba.example.com ${hostname}\n";
2342 unless (open(RESOLV_CONF, ">$resolv_conf")) {
2343 warn("Unable to open $resolv_conf");
2346 if (defined($dc_server_ip) or defined($dc_server_ipv6)) {
2347 if (defined($dc_server_ip)) {
2348 print RESOLV_CONF "nameserver $dc_server_ip\n";
2350 if (defined($dc_server_ipv6)) {
2351 print RESOLV_CONF "nameserver $dc_server_ipv6\n";
2354 print RESOLV_CONF "nameserver ${server_ip}\n";
2355 print RESOLV_CONF "nameserver ${server_ipv6}\n";
2359 foreach my $evlog (@eventlog_list) {
2360 my $evlogtdb = "$eventlogdir/$evlog.tdb";
2361 open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
2365 $createuser_env{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2366 $createuser_env{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2367 $createuser_env{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2368 $createuser_env{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2369 if ($ENV{SAMBA_DNS_FAKING}) {
2370 $createuser_env{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2372 $createuser_env{RESOLV_WRAPPER_CONF} = $resolv_conf;
2375 createuser($self, $unix_name, $password, $conffile, \%createuser_env) || die("Unable to create user");
2376 createuser($self, "force_user", $password, $conffile, \%createuser_env) || die("Unable to create force_user");
2377 createuser($self, "smbget_user", $password, $conffile, \%createuser_env) || die("Unable to create smbget_user");
2378 createuser($self, "user1", $password, $conffile, \%createuser_env) || die("Unable to create user1");
2379 createuser($self, "user2", $password, $conffile, \%createuser_env) || die("Unable to create user2");
2381 open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
2382 print DNS_UPDATE_LIST "A $server. $server_ip\n";
2383 print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n";
2384 close(DNS_UPDATE_LIST);
2388 $ret{SERVER_IP} = $server_ip;
2389 $ret{SERVER_IPV6} = $server_ipv6;
2390 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
2391 $ret{NMBD_TEST_LOG_POS} = 0;
2392 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
2393 $ret{WINBINDD_TEST_LOG_POS} = 0;
2394 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
2395 $ret{SMBD_TEST_LOG_POS} = 0;
2396 $ret{SERVERCONFFILE} = $conffile;
2397 $ret{CONFIGURATION} ="-s $conffile";
2398 $ret{LOCK_DIR} = $lockdir;
2399 $ret{SERVER} = $server;
2400 $ret{USERNAME} = $unix_name;
2401 $ret{USERID} = $unix_uid;
2402 $ret{DOMAIN} = $domain;
2403 $ret{SAMSID} = $samsid;
2404 $ret{NETBIOSNAME} = $server;
2405 $ret{PASSWORD} = $password;
2406 $ret{PIDDIR} = $piddir;
2407 $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir;
2408 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
2409 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
2410 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2411 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2412 $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2413 $ret{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2414 $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
2415 $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind";
2416 if ($ENV{SAMBA_DNS_FAKING}) {
2417 $ret{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2419 $ret{RESOLV_WRAPPER_CONF} = $resolv_conf;
2421 $ret{LOCAL_PATH} = "$shrdir";
2422 $ret{LOGDIR} = $logdir;
2425 # Avoid hitting system krb5.conf -
2426 # An env that needs Kerberos will reset this to the real
2429 $ret{KRB5_CONFIG} = abs_path($prefix) . "/no_krb5.conf";
2431 # Define KRB5CCNAME for each environment we set up
2432 $ret{KRB5_CCACHE} = abs_path($prefix) . "/krb5ccache";
2433 $ENV{KRB5CCNAME} = $ret{KRB5_CCACHE};
2438 sub wait_for_start($$$$$)
2440 my ($self, $envvars, $nmbd, $winbindd, $smbd) = @_;
2445 if ($nmbd eq "yes") {
2448 # give time for nbt server to register its names
2449 print "checking for nmbd\n";
2451 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
2452 my $nmblookup = Samba::bindir_path($self, "nmblookup");
2455 $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
2459 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
2460 system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
2461 system("$nmblookup $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
2462 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
2465 } while ($ret != 0 && $count < 10);
2467 print "NMBD not reachable after 10 retries\n";
2468 teardown_env($self, $envvars);
2473 if ($winbindd eq "yes") {
2474 print "checking for winbindd\n";
2476 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2477 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2478 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2479 $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping-dc";
2483 $ret = system($cmd);
2487 } while ($ret != 0 && $count < 20);
2489 print "WINBINDD not reachable after 20 seconds\n";
2490 teardown_env($self, $envvars);
2495 if ($smbd eq "yes") {
2496 # make sure smbd is also up set
2497 print "wait for smbd\n";
2501 $ret = system(Samba::bindir_path($self, "smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139");
2506 } while ($ret != 0 && $count < 20);
2508 print "SMBD failed to start up in a reasonable time (20sec)\n";
2509 teardown_env($self, $envvars);
2514 # Ensure we have domain users mapped.
2515 $netcmd = "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2516 $netcmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2517 $netcmd .= Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} ";
2519 $cmd = $netcmd . "groupmap delete ntgroup=domusers";
2520 $ret = system($cmd);
2522 $cmd = $netcmd . "groupmap add rid=513 unixgroup=domusers type=domain";
2523 $ret = system($cmd);
2525 print("\"$cmd\" failed\n");
2529 $cmd = $netcmd . "groupmap delete ntgroup=domadmins";
2530 $ret = system($cmd);
2532 $cmd = $netcmd . "groupmap add rid=512 unixgroup=domadmins type=domain";
2533 $ret = system($cmd);
2535 print("\"$cmd\" failed\n");
2539 $cmd = $netcmd . "groupmap delete ntgroup=everyone";
2540 $ret = system($cmd);
2542 $cmd = $netcmd . "groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin";
2543 $ret = system($cmd);
2545 print("\"$cmd\" failed\n");
2549 # note: creating builtin groups requires winbindd for the
2551 my $create_builtin_users = "no";
2552 if ($winbindd eq "yes") {
2553 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2554 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2555 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2556 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
2557 my $wbinfo_out = qx($cmd 2>&1);
2559 # wbinfo doesn't give us a better error code then
2560 # WBC_ERR_DOMAIN_NOT_FOUND, but at least that's
2561 # different then WBC_ERR_WINBIND_NOT_AVAILABLE
2562 if ($wbinfo_out !~ /WBC_ERR_DOMAIN_NOT_FOUND/) {
2563 print("Failed to run \"wbinfo --sid-to-gid=S-1-5-32-545\": $wbinfo_out");
2564 teardown_env($self, $envvars);
2567 $create_builtin_users = "yes";
2570 if ($create_builtin_users eq "yes") {
2571 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2572 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2573 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2574 $cmd .= Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
2575 $cmd .= "sam createbuiltingroup Users";
2576 $ret = system($cmd);
2578 print "Failed to create BUILTIN\\Users group\n";
2579 teardown_env($self, $envvars);
2583 $cmd = Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
2584 $cmd .= "cache del IDMAP/SID2XID/S-1-5-32-545";
2587 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2588 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2589 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2590 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
2591 $ret = system($cmd);
2593 print "Missing \"BUILTIN\\Users\", did net sam createbuiltingroup Users fail?\n";
2594 teardown_env($self, $envvars);
2599 print $self->getlog_env($envvars);