2 # Bootstrap Samba and run a number of tests against it.
3 # Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
4 # Published under the GNU GPL, v3 or later.
6 # NOTE: Refer to the README for more details about the various testenvs,
7 # and tips about adding new testenvs.
13 use FindBin qw($RealBin);
16 use File::Path 'remove_tree';
21 my $smbd_build_options = Samba::bindir_path($self, "smbd") . " -b|";
22 open(IN, $smbd_build_options) or die("Unable to run $smbd_build_options: $!");
31 # If we were not built with ADS support, pretend we were never even available
32 print "smbd does not have ADS support\n" unless $found_ads;
36 # return smb.conf parameters applicable to @path, based on the underlying
38 sub get_fs_specific_conf($$)
40 my ($self, $path) = @_;
42 my $stat_out = `stat --file-system $path` or return "";
44 if ($stat_out =~ m/Type:\s+btrfs/) {
45 $mods .= "streams_xattr btrfs";
49 return "vfs objects = $mods";
56 my ($classname, $bindir, $srcdir, $server_maxtime) = @_;
57 my $self = { vars => {},
60 server_maxtime => $server_maxtime
68 my ($self, $envvars) = @_;
71 # This should cause smbd to terminate gracefully
72 close($envvars->{STDIN_PIPE});
74 my $smbdpid = $envvars->{SMBD_TL_PID};
75 my $nmbdpid = $envvars->{NMBD_TL_PID};
76 my $winbinddpid = $envvars->{WINBINDD_TL_PID};
78 # This should give it time to write out the gcov data
80 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
81 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
82 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
85 && $winbinddchild == -1) {
92 if ($count <= 20 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
96 $self->stop_sig_term($smbdpid);
97 $self->stop_sig_term($nmbdpid);
98 $self->stop_sig_term($winbinddpid);
101 until ($count > 10) {
102 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
103 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
104 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
107 && $winbinddchild == -1) {
114 if ($count <= 10 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
118 warn("timelimit process did not quit on SIGTERM, sending SIGKILL");
119 $self->stop_sig_kill($smbdpid);
120 $self->stop_sig_kill($nmbdpid);
121 $self->stop_sig_kill($winbinddpid);
126 sub getlog_env_app($$$)
128 my ($self, $envvars, $name) = @_;
130 my $title = "$name LOG of: $envvars->{NETBIOSNAME}\n";
133 open(LOG, "<".$envvars->{$name."_TEST_LOG"});
135 seek(LOG, $envvars->{$name."_TEST_LOG_POS"}, SEEK_SET);
139 $envvars->{$name."_TEST_LOG_POS"} = tell(LOG);
142 return "" if $out eq $title;
149 my ($self, $envvars) = @_;
152 $ret .= $self->getlog_env_app($envvars, "SMBD");
153 $ret .= $self->getlog_env_app($envvars, "NMBD");
154 $ret .= $self->getlog_env_app($envvars, "WINBINDD");
161 my ($self, $envvars) = @_;
163 my $childpid = waitpid(-1, WNOHANG);
169 # Declare the environments Samba3 makes available.
170 # To be set up, they will be called as
171 # samba3->setup_$envname($self, $path, $dep_1_vars, $dep_2_vars, ...)
172 %Samba3::ENV_DEPS = (
173 # name => [dep_1, dep_2, ...],
175 nt4_dc_schannel => [],
182 nt4_member => ["nt4_dc"],
184 ad_member => ["ad_dc"],
185 ad_member_rfc2307 => ["ad_dc_ntvfs"],
186 ad_member_idmap_rid => ["ad_dc"],
187 ad_member_idmap_ad => ["fl2008r2dc"],
190 %Samba3::ENV_DEPS_POST = ();
194 my ($self, $path) = @_;
196 print "PROVISIONING NT4 DC...";
198 my $nt4_dc_options = "
203 raw NTLMv2 auth = yes
204 server schannel = auto
206 rpc_server:epmapper = external
207 rpc_server:spoolss = external
208 rpc_server:lsarpc = external
209 rpc_server:samr = external
210 rpc_server:netlogon = external
211 rpc_server:register_embedded_np = yes
212 rpc_server:FssagentRpc = external
214 rpc_daemon:epmd = fork
215 rpc_daemon:spoolssd = fork
216 rpc_daemon:lsasd = fork
217 rpc_daemon:fssd = fork
218 fss: sequence timeout = 1
219 check parent directory delete on close = yes
222 my $vars = $self->provision($path, "SAMBA-TEST",
227 $vars or return undef;
229 if (not $self->check_or_start($vars, "yes", "yes", "yes")) {
233 $vars->{DOMSID} = $vars->{SAMSID};
234 $vars->{DC_SERVER} = $vars->{SERVER};
235 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
236 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
237 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
238 $vars->{DC_USERNAME} = $vars->{USERNAME};
239 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
244 sub setup_nt4_dc_schannel
246 my ($self, $path) = @_;
248 print "PROVISIONING NT4 DC WITH SERVER SCHANNEL ...";
255 rpc_server:epmapper = external
256 rpc_server:spoolss = external
257 rpc_server:lsarpc = external
258 rpc_server:samr = external
259 rpc_server:netlogon = external
260 rpc_server:register_embedded_np = yes
262 rpc_daemon:epmd = fork
263 rpc_daemon:spoolssd = fork
264 rpc_daemon:lsasd = fork
266 server schannel = yes
267 # used to reproduce bug #12772
268 server max protocol = SMB2_02
271 my $vars = $self->provision($path, "NT4SCHANNEL",
276 $vars or return undef;
278 if (not $self->check_or_start($vars, "yes", "yes", "yes")) {
282 $vars->{DOMSID} = $vars->{SAMSID};
283 $vars->{DC_SERVER} = $vars->{SERVER};
284 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
285 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
286 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
287 $vars->{DC_USERNAME} = $vars->{USERNAME};
288 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
295 my ($self, $prefix, $nt4_dc_vars) = @_;
299 print "PROVISIONING MEMBER...";
301 my $require_mutexes = "dbwrap_tdb_require_mutexes:* = yes";
302 $require_mutexes = "" if ($ENV{SELFTEST_DONT_REQUIRE_TDB_MUTEX_SUPPORT} eq "1");
304 my $member_options = "
306 dbwrap_tdb_mutexes:* = yes
309 my $ret = $self->provision($prefix, $nt4_dc_vars->{DOMAIN},
311 "localnt4member3pass",
314 $ret or return undef;
316 my $nmblookup = Samba::bindir_path($self, "nmblookup");
318 print "Waiting for the LOGON SERVER registration ...\n";
319 $rc = system("$nmblookup $ret->{CONFIGURATION} $ret->{DOMAIN}\#1c");
324 } while ($rc != 0 && $count < 10);
326 print "NMBD not reachable after 10 retries\n";
327 teardown_env($self, $ret);
331 my $net = Samba::bindir_path($self, "net");
332 # Add hosts file for name lookups
333 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
334 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
335 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
336 $cmd .= "$net rpc join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
337 $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}";
339 if (system($cmd) != 0) {
340 warn("Join failed\n$cmd");
344 # Add hosts file for name lookups
345 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
346 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
347 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
348 $cmd .= "$net $ret->{CONFIGURATION} primarytrust dumpinfo | grep -q 'REDACTED SECRET VALUES'";
350 if (system($cmd) != 0) {
351 warn("check failed\n$cmd");
355 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
359 $ret->{DOMSID} = $nt4_dc_vars->{DOMSID};
360 $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
361 $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
362 $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
363 $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME};
364 $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME};
365 $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD};
372 my ($self, $prefix, $dcvars) = @_;
374 my $prefix_abs = abs_path($prefix);
377 # If we didn't build with ADS, pretend this env was never available
378 if (not $self->have_ads()) {
382 print "PROVISIONING S3 AD MEMBER...";
384 mkdir($prefix_abs, 0777);
386 my $share_dir="$prefix_abs/share";
387 push(@dirs, $share_dir);
389 my $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}";
390 push(@dirs, $substitution_path);
392 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice";
393 push(@dirs, $substitution_path);
395 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice/G_domain users";
396 push(@dirs, $substitution_path);
398 # Using '/' as the winbind separator is a bad idea ...
399 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}";
400 push(@dirs, $substitution_path);
402 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice";
403 push(@dirs, $substitution_path);
405 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}";
406 push(@dirs, $substitution_path);
408 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}/domain users";
409 push(@dirs, $substitution_path);
411 my $member_options = "
413 workgroup = $dcvars->{DOMAIN}
414 realm = $dcvars->{REALM}
415 netbios aliases = foo bar
416 template homedir = /home/%D/%G/%U
417 auth event notification = true
418 password server = $dcvars->{SERVER}
421 path = $share_dir/D_%D/U_%U/G_%G
425 path = $share_dir/D_%D/u_%u/g_%g
430 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
434 $dcvars->{SERVER_IP},
435 $dcvars->{SERVER_IPV6});
437 $ret or return undef;
439 mkdir($_, 0777) foreach(@dirs);
442 $ret->{DOMAIN} = $dcvars->{DOMAIN};
443 $ret->{REALM} = $dcvars->{REALM};
444 $ret->{DOMSID} = $dcvars->{DOMSID};
448 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
449 $ctx->{domain} = $dcvars->{DOMAIN};
450 $ctx->{realm} = $dcvars->{REALM};
451 $ctx->{dnsname} = lc($dcvars->{REALM});
452 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
453 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
454 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
455 Samba::mk_krb5_conf($ctx, "");
457 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
458 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
460 my $net = Samba::bindir_path($self, "net");
461 # Add hosts file for name lookups
462 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
463 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
464 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
465 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
467 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
469 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
470 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
471 $cmd .= "$net join $ret->{CONFIGURATION}";
472 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
474 if (system($cmd) != 0) {
475 warn("Join failed\n$cmd");
479 # We need world access to this share, as otherwise the domain
480 # administrator from the AD domain provided by Samba4 can't
481 # access the share for tests.
482 chmod 0777, "$prefix/share";
484 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
488 $ret->{DC_SERVER} = $dcvars->{SERVER};
489 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
490 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
491 $ret->{DC_SERVERCONFFILE} = $dcvars->{SERVERCONFFILE};
492 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
493 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
494 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
499 sub setup_ad_member_rfc2307
501 my ($self, $prefix, $dcvars) = @_;
503 # If we didn't build with ADS, pretend this env was never available
504 if (not $self->have_ads()) {
508 print "PROVISIONING S3 AD MEMBER WITH idmap_rfc2307 config...";
510 my $member_options = "
512 workgroup = $dcvars->{DOMAIN}
513 realm = $dcvars->{REALM}
515 idmap negative cache time = 0
516 idmap config * : backend = autorid
517 idmap config * : range = 1000000-1999999
518 idmap config * : rangesize = 100000
519 idmap config $dcvars->{DOMAIN} : backend = rfc2307
520 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
521 idmap config $dcvars->{DOMAIN} : ldap_server = ad
522 idmap config $dcvars->{DOMAIN} : bind_path_user = ou=idmap,dc=samba,dc=example,dc=com
523 idmap config $dcvars->{DOMAIN} : bind_path_group = ou=idmap,dc=samba,dc=example,dc=com
525 password server = $dcvars->{SERVER}
528 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
532 $dcvars->{SERVER_IP},
533 $dcvars->{SERVER_IPV6});
535 $ret or return undef;
538 $ret->{DOMAIN} = $dcvars->{DOMAIN};
539 $ret->{REALM} = $dcvars->{REALM};
540 $ret->{DOMSID} = $dcvars->{DOMSID};
543 my $prefix_abs = abs_path($prefix);
545 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
546 $ctx->{domain} = $dcvars->{DOMAIN};
547 $ctx->{realm} = $dcvars->{REALM};
548 $ctx->{dnsname} = lc($dcvars->{REALM});
549 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
550 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
551 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
552 Samba::mk_krb5_conf($ctx, "");
554 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
555 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
557 my $net = Samba::bindir_path($self, "net");
558 # Add hosts file for name lookups
559 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
560 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
561 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
562 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
564 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
566 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
567 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
568 $cmd .= "$net join $ret->{CONFIGURATION}";
569 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
571 if (system($cmd) != 0) {
572 warn("Join failed\n$cmd");
576 # We need world access to this share, as otherwise the domain
577 # administrator from the AD domain provided by Samba4 can't
578 # access the share for tests.
579 chmod 0777, "$prefix/share";
581 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
585 $ret->{DC_SERVER} = $dcvars->{SERVER};
586 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
587 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
588 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
589 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
590 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
595 sub setup_ad_member_idmap_rid
597 my ($self, $prefix, $dcvars) = @_;
599 # If we didn't build with ADS, pretend this env was never available
600 if (not $self->have_ads()) {
604 print "PROVISIONING S3 AD MEMBER WITH idmap_rid config...";
606 my $member_options = "
608 workgroup = $dcvars->{DOMAIN}
609 realm = $dcvars->{REALM}
610 idmap config * : backend = tdb
611 idmap config * : range = 1000000-1999999
612 idmap config $dcvars->{DOMAIN} : backend = rid
613 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
614 # Prevent overridding the provisioned lib/krb5.conf which sets certain
615 # values required for tests to succeed
616 create krb5 conf = no
619 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
623 $dcvars->{SERVER_IP},
624 $dcvars->{SERVER_IPV6});
626 $ret or return undef;
629 $ret->{DOMAIN} = $dcvars->{DOMAIN};
630 $ret->{REALM} = $dcvars->{REALM};
631 $ret->{DOMSID} = $dcvars->{DOMSID};
634 my $prefix_abs = abs_path($prefix);
636 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
637 $ctx->{domain} = $dcvars->{DOMAIN};
638 $ctx->{realm} = $dcvars->{REALM};
639 $ctx->{dnsname} = lc($dcvars->{REALM});
640 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
641 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
642 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
643 Samba::mk_krb5_conf($ctx, "");
645 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
646 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
648 my $net = Samba::bindir_path($self, "net");
649 # Add hosts file for name lookups
650 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
651 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
652 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
653 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
655 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
657 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
658 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
659 $cmd .= "$net join $ret->{CONFIGURATION}";
660 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
662 if (system($cmd) != 0) {
663 warn("Join failed\n$cmd");
667 # We need world access to this share, as otherwise the domain
668 # administrator from the AD domain provided by Samba4 can't
669 # access the share for tests.
670 chmod 0777, "$prefix/share";
672 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
676 $ret->{DC_SERVER} = $dcvars->{SERVER};
677 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
678 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
679 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
680 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
681 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
686 sub setup_ad_member_idmap_ad
688 my ($self, $prefix, $dcvars) = @_;
690 # If we didn't build with ADS, pretend this env was never available
691 if (not $self->have_ads()) {
695 print "PROVISIONING S3 AD MEMBER WITH idmap_ad config...";
697 my $member_options = "
699 workgroup = $dcvars->{DOMAIN}
700 realm = $dcvars->{REALM}
701 password server = $dcvars->{SERVER}
702 idmap config * : backend = tdb
703 idmap config * : range = 1000000-1999999
704 idmap config $dcvars->{DOMAIN} : backend = ad
705 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
706 idmap config $dcvars->{TRUST_DOMAIN} : backend = ad
707 idmap config $dcvars->{TRUST_DOMAIN} : range = 2000000-2999999
710 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
714 $dcvars->{SERVER_IP},
715 $dcvars->{SERVER_IPV6});
717 $ret or return undef;
720 $ret->{DOMAIN} = $dcvars->{DOMAIN};
721 $ret->{REALM} = $dcvars->{REALM};
722 $ret->{DOMSID} = $dcvars->{DOMSID};
725 my $prefix_abs = abs_path($prefix);
727 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
728 $ctx->{domain} = $dcvars->{DOMAIN};
729 $ctx->{realm} = $dcvars->{REALM};
730 $ctx->{dnsname} = lc($dcvars->{REALM});
731 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
732 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
733 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
734 Samba::mk_krb5_conf($ctx, "");
736 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
737 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
739 my $net = Samba::bindir_path($self, "net");
740 # Add hosts file for name lookups
741 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
742 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
743 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
744 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
746 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
748 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
749 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
750 $cmd .= "$net join $ret->{CONFIGURATION}";
751 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
753 if (system($cmd) != 0) {
754 warn("Join failed\n$cmd");
758 # We need world access to this share, as otherwise the domain
759 # administrator from the AD domain provided by Samba4 can't
760 # access the share for tests.
761 chmod 0777, "$prefix/share";
763 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
767 $ret->{DC_SERVER} = $dcvars->{SERVER};
768 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
769 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
770 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
771 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
772 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
774 $ret->{TRUST_SERVER} = $dcvars->{TRUST_SERVER};
775 $ret->{TRUST_USERNAME} = $dcvars->{TRUST_USERNAME};
776 $ret->{TRUST_PASSWORD} = $dcvars->{TRUST_PASSWORD};
777 $ret->{TRUST_DOMAIN} = $dcvars->{TRUST_DOMAIN};
778 $ret->{TRUST_REALM} = $dcvars->{TRUST_REALM};
779 $ret->{TRUST_DOMSID} = $dcvars->{TRUST_DOMSID};
784 sub setup_simpleserver
786 my ($self, $path) = @_;
788 print "PROVISIONING simple server...";
790 my $prefix_abs = abs_path($path);
792 my $simpleserver_options = "
795 vfs objects = xattr_tdb streams_depot
800 path = $prefix_abs/share
802 vfs objects = aio_pthread
803 aio_pthread:aio open = yes
804 smbd:async dosmode = no
806 [vfs_aio_pthread_async_dosmode_default1]
807 path = $prefix_abs/share
809 vfs objects = aio_pthread
810 store dos attributes = yes
811 aio_pthread:aio open = yes
812 smbd:async dosmode = yes
814 [vfs_aio_pthread_async_dosmode_default2]
815 path = $prefix_abs/share
817 vfs objects = aio_pthread xattr_tdb
818 store dos attributes = yes
819 aio_pthread:aio open = yes
820 smbd:async dosmode = yes
822 [vfs_aio_pthread_async_dosmode_force_sync1]
823 path = $prefix_abs/share
825 vfs objects = aio_pthread
826 store dos attributes = yes
827 aio_pthread:aio open = yes
828 smbd:async dosmode = yes
829 # This simulates non linux systems
830 smbd:force sync user path safe threadpool = yes
831 smbd:force sync user chdir safe threadpool = yes
832 smbd:force sync root path safe threadpool = yes
833 smbd:force sync root chdir safe threadpool = yes
835 [vfs_aio_pthread_async_dosmode_force_sync2]
836 path = $prefix_abs/share
838 vfs objects = aio_pthread xattr_tdb
839 store dos attributes = yes
840 aio_pthread:aio open = yes
841 smbd:async dosmode = yes
842 # This simulates non linux systems
843 smbd:force sync user path safe threadpool = yes
844 smbd:force sync user chdir safe threadpool = yes
845 smbd:force sync root path safe threadpool = yes
846 smbd:force sync root chdir safe threadpool = yes
849 path = $prefix_abs/share
850 vfs objects = aio_fork
852 vfs_aio_fork:erratic_testing_mode=yes
855 path = $prefix_abs/share
857 store dos attributes = yes
858 hide files = /hidefile/
862 path = $prefix_abs/share
864 smb encrypt = desired
867 path = $prefix_abs/share
868 hide new files timeout = 5
871 my $vars = $self->provision($path, "WORKGROUP",
874 $simpleserver_options);
876 $vars or return undef;
878 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
887 my ($self, $path) = @_;
888 my $prefix_abs = abs_path($path);
889 my $srcdir_abs = abs_path($self->{srcdir});
891 print "PROVISIONING file server ...\n";
895 mkdir($prefix_abs, 0777);
897 my $usershare_dir="$prefix_abs/lib/usershare";
899 mkdir("$prefix_abs/lib", 0755);
900 remove_tree($usershare_dir);
901 mkdir($usershare_dir, 01770);
903 my $share_dir="$prefix_abs/share";
905 # Create share directory structure
906 my $lower_case_share_dir="$share_dir/lower-case";
907 push(@dirs, $lower_case_share_dir);
909 my $lower_case_share_dir_30000="$share_dir/lower-case-30000";
910 push(@dirs, $lower_case_share_dir_30000);
912 my $dfree_share_dir="$share_dir/dfree";
913 push(@dirs, $dfree_share_dir);
914 push(@dirs, "$dfree_share_dir/subdir1");
915 push(@dirs, "$dfree_share_dir/subdir2");
916 push(@dirs, "$dfree_share_dir/subdir3");
918 my $quotadir_dir="$share_dir/quota";
919 push(@dirs, $quotadir_dir);
921 my $valid_users_sharedir="$share_dir/valid_users";
922 push(@dirs,$valid_users_sharedir);
924 my $offline_sharedir="$share_dir/offline";
925 push(@dirs,$offline_sharedir);
927 my $force_user_valid_users_dir = "$share_dir/force_user_valid_users";
928 push(@dirs, $force_user_valid_users_dir);
930 my $smbget_sharedir="$share_dir/smbget";
931 push(@dirs,$smbget_sharedir);
933 my $tarmode_sharedir="$share_dir/tarmode";
934 push(@dirs,$tarmode_sharedir);
936 my $usershare_sharedir="$share_dir/usershares";
937 push(@dirs,$usershare_sharedir);
939 my $fileserver_options = "
940 kernel change notify = yes
942 usershare path = $usershare_dir
943 usershare max shares = 10
944 usershare allow guests = yes
945 usershare prefix allow list = $usershare_sharedir
947 get quota command = $prefix_abs/getset_quota.py
948 set quota command = $prefix_abs/getset_quota.py
950 path = $lower_case_share_dir
951 comment = smb username is [%U]
952 case sensitive = True
955 short preserve case = no
957 path = $lower_case_share_dir_30000
958 comment = smb username is [%U]
959 case sensitive = True
962 short preserve case = no
964 path = $dfree_share_dir
965 comment = smb username is [%U]
966 dfree command = $srcdir_abs/testprogs/blackbox/dfree.sh
968 path = $valid_users_sharedir
969 valid users = +userdup
971 path = $offline_sharedir
972 vfs objects = offline
974 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878
975 # RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651
976 [force_user_valid_users]
977 path = $force_user_valid_users_dir
978 comment = force user with valid users combination test share
979 valid users = +force_user
980 force user = force_user
981 force group = everyone
982 write list = force_user
985 path = $smbget_sharedir
986 comment = smb username is [%U]
990 comment = ignore system acls
991 acl_xattr:ignore system acls = yes
994 comment = inherit owner
998 comment = inherit only unix owner
999 inherit owner = unix only
1000 acl_xattr:ignore system acls = yes
1001 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=13690
1004 comment = force group test
1005 # force group = everyone
1007 comment = Home directories
1012 my $vars = $self->provision($path, "WORKGROUP",
1015 $fileserver_options,
1020 $vars or return undef;
1022 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
1027 mkdir($_, 0777) foreach(@dirs);
1029 ## Create case sensitive lower case share dir
1030 foreach my $file ('a'..'z') {
1031 my $full_path = $lower_case_share_dir . '/' . $file;
1032 open my $fh, '>', $full_path;
1033 # Add some content to file
1034 print $fh $full_path;
1038 for (my $file = 1; $file < 51; ++$file) {
1039 my $full_path = $lower_case_share_dir . '/' . $file;
1040 open my $fh, '>', $full_path;
1041 # Add some content to file
1042 print $fh $full_path;
1046 # Create content for 30000 share
1047 foreach my $file ('a'..'z') {
1048 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1049 open my $fh, '>', $full_path;
1050 # Add some content to file
1051 print $fh $full_path;
1055 for (my $file = 1; $file < 30001; ++$file) {
1056 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1057 open my $fh, '>', $full_path;
1058 # Add some content to file
1059 print $fh $full_path;
1064 ## create a listable file in valid_users_share
1066 my $valid_users_target = "$valid_users_sharedir/foo";
1067 unless (open(VALID_USERS_TARGET, ">$valid_users_target")) {
1068 warn("Unable to open $valid_users_target");
1071 close(VALID_USERS_TARGET);
1072 chmod 0644, $valid_users_target;
1079 my ($self, $prefix) = @_;
1081 # If we didn't build with ADS, pretend this env was never available
1082 if (not $self->have_ads()) {
1086 print "PROVISIONING server with security=ads...";
1088 my $ktest_options = "
1090 realm = ktest.samba.example.com
1092 username map = $prefix/lib/username.map
1093 server signing = required
1094 server min protocol = SMB3_00
1095 client max protocol = SMB3
1097 # This disables NTLM auth against the local SAM, which
1098 # we use can then test this setting by.
1099 ntlm auth = disabled
1102 my $ret = $self->provision($prefix, "KTEST",
1107 $ret or return undef;
1110 my $prefix_abs = abs_path($prefix);
1112 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1113 $ctx->{domain} = "KTEST";
1114 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
1115 $ctx->{dnsname} = lc($ctx->{realm});
1116 $ctx->{kdc_ipv4} = "0.0.0.0";
1117 $ctx->{kdc_ipv6} = "::";
1118 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1119 Samba::mk_krb5_conf($ctx, "");
1121 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1123 open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map");
1125 $ret->{USERNAME} = KTEST\\Administrator
1129 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
1130 #Samba4 DC with the same parameters as are being used here. The
1131 #domain SID is S-1-5-21-1071277805-689288055-3486227160
1132 $ret->{SAMSID} = "S-1-5-21-1911091480-1468226576-2729736297";
1133 $ret->{DOMSID} = "S-1-5-21-1071277805-689288055-3486227160";
1135 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
1136 chmod 0600, "$prefix/private/secrets.tdb";
1138 #Make sure there's no old ntdb file.
1139 system("rm -f $prefix/private/secrets.ntdb");
1141 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
1142 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
1144 #and having in krb5.conf:
1145 # ticket_lifetime = 799718400
1146 # renew_lifetime = 799718400
1148 # The commands for the -2 keytab where were:
1149 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
1150 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
1151 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
1152 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1153 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1155 # and then for the -3 keytab, I did
1157 # net changetrustpw; kdestroy and the same again.
1159 # This creates a credential cache with a very long lifetime (2036 at
1160 # at 2011-04), and shows that running 'net changetrustpw' does not
1161 # break existing logins (for the secrets.tdb method at least).
1164 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
1166 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
1167 chmod 0600, "$prefix/krb5_ccache-2";
1169 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
1170 chmod 0600, "$prefix/krb5_ccache-3";
1172 # We need world access to this share, as otherwise the domain
1173 # administrator from the AD domain provided by ktest can't
1174 # access the share for tests.
1175 chmod 0777, "$prefix/share";
1177 if (not $self->check_or_start($ret, "yes", "no", "yes")) {
1183 sub setup_maptoguest
1185 my ($self, $path) = @_;
1187 print "PROVISIONING maptoguest...";
1190 map to guest = bad user
1194 my $vars = $self->provision($path, "WORKGROUP",
1199 $vars or return undef;
1201 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
1208 sub stop_sig_term($$) {
1209 my ($self, $pid) = @_;
1210 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1213 sub stop_sig_kill($$) {
1214 my ($self, $pid) = @_;
1215 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1220 my ($env_vars, $app, $pid) = @_;
1222 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
1229 my ($env_vars, $app) = @_;
1231 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
1237 sub check_or_start($$$$$) {
1238 my ($self, $env_vars, $nmbd, $winbindd, $smbd) = @_;
1240 # use a pipe for stdin in the child processes. This allows
1241 # those processes to monitor the pipe for EOF to ensure they
1242 # exit when the test script exits
1243 pipe(STDIN_READER, $env_vars->{STDIN_PIPE});
1245 unlink($env_vars->{NMBD_TEST_LOG});
1246 print "STARTING NMBD...";
1249 open STDOUT, ">$env_vars->{NMBD_TEST_LOG}";
1250 open STDERR, '>&STDOUT';
1252 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1254 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1255 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.nmbd";
1256 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1257 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1259 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1260 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1261 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1262 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1263 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1264 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1265 $ENV{UID_WRAPPER_ROOT} = "1";
1267 $ENV{ENVNAME} = "$ENV{ENVNAME}.nmbd";
1269 if ($nmbd ne "yes") {
1270 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1271 my $signame = shift;
1272 print("Skip nmbd received signal $signame");
1275 sleep($self->{server_maxtime});
1279 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "nmbd");
1280 my @optargs = ("-d0");
1281 if (defined($ENV{NMBD_OPTIONS})) {
1282 @optargs = split(/ /, $ENV{NMBD_OPTIONS});
1284 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1285 if(defined($ENV{NMBD_VALGRIND})) {
1286 @preargs = split(/ /, $ENV{NMBD_VALGRIND});
1288 my @args = ("-F", "--no-process-group",
1289 "-s", $env_vars->{SERVERCONFFILE},
1290 "-l", $env_vars->{LOGDIR});
1291 if (not defined($ENV{NMBD_DONT_LOG_STDOUT})) {
1292 push(@args, "--log-stdout");
1295 close($env_vars->{STDIN_PIPE});
1296 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1298 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1299 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1301 $env_vars->{NMBD_TL_PID} = $pid;
1302 write_pid($env_vars, "nmbd", $pid);
1305 unlink($env_vars->{WINBINDD_TEST_LOG});
1306 print "STARTING WINBINDD...";
1309 open STDOUT, ">$env_vars->{WINBINDD_TEST_LOG}";
1310 open STDERR, '>&STDOUT';
1312 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1314 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1315 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.winbindd";
1316 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1317 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1319 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1320 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1321 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1322 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1323 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1324 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1325 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
1326 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
1328 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
1330 $ENV{UID_WRAPPER_ROOT} = "1";
1332 $ENV{ENVNAME} = "$ENV{ENVNAME}.winbindd";
1334 if ($winbindd ne "yes") {
1335 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1336 my $signame = shift;
1337 print("Skip winbindd received signal $signame");
1340 sleep($self->{server_maxtime});
1344 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "winbindd");
1345 my @optargs = ("-d0");
1346 if (defined($ENV{WINBINDD_OPTIONS})) {
1347 @optargs = split(/ /, $ENV{WINBINDD_OPTIONS});
1349 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1350 if(defined($ENV{WINBINDD_VALGRIND})) {
1351 @preargs = split(/ /, $ENV{WINBINDD_VALGRIND});
1353 my @args = ("-F", "--no-process-group",
1354 "-s", $env_vars->{SERVERCONFFILE},
1355 "-l", $env_vars->{LOGDIR});
1356 if (not defined($ENV{WINBINDD_DONT_LOG_STDOUT})) {
1357 push(@args, "--stdout");
1360 close($env_vars->{STDIN_PIPE});
1361 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1363 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1364 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1366 $env_vars->{WINBINDD_TL_PID} = $pid;
1367 write_pid($env_vars, "winbindd", $pid);
1370 unlink($env_vars->{SMBD_TEST_LOG});
1371 print "STARTING SMBD...";
1374 open STDOUT, ">$env_vars->{SMBD_TEST_LOG}";
1375 open STDERR, '>&STDOUT';
1377 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1379 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1380 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.smbd";
1381 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1382 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1384 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1385 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1386 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1387 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1388 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1389 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1390 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
1391 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
1393 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
1395 $ENV{UID_WRAPPER_ROOT} = "1";
1397 $ENV{ENVNAME} = "$ENV{ENVNAME}.smbd";
1399 if ($smbd ne "yes") {
1400 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1401 my $signame = shift;
1402 print("Skip smbd received signal $signame");
1405 sleep($self->{server_maxtime});
1409 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "smbd");
1410 my @optargs = ("-d0");
1411 if (defined($ENV{SMBD_OPTIONS})) {
1412 @optargs = split(/ /, $ENV{SMBD_OPTIONS});
1414 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1415 if(defined($ENV{SMBD_VALGRIND})) {
1416 @preargs = split(/ /,$ENV{SMBD_VALGRIND});
1418 my @args = ("-F", "--no-process-group",
1419 "-s", $env_vars->{SERVERCONFFILE},
1420 "-l", $env_vars->{LOGDIR});
1421 if (not defined($ENV{SMBD_DONT_LOG_STDOUT})) {
1422 push(@args, "--log-stdout");
1425 close($env_vars->{STDIN_PIPE});
1426 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1428 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1429 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1431 $env_vars->{SMBD_TL_PID} = $pid;
1432 write_pid($env_vars, "smbd", $pid);
1435 close(STDIN_READER);
1437 return $self->wait_for_start($env_vars, $nmbd, $winbindd, $smbd);
1440 sub createuser($$$$$)
1442 my ($self, $username, $password, $conffile, $env) = @_;
1443 my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $username > /dev/null";
1446 while(my($var, $val) = each %$env) {
1447 $cmd = "$var=\"$val\" $cmd";
1450 unless (open(PWD, "|$cmd")) {
1451 warn("Unable to set password for $username account\n$cmd");
1454 print PWD "$password\n$password\n";
1455 unless (close(PWD)) {
1456 warn("Unable to set password for $username account\n$cmd");
1461 sub provision($$$$$$$$$)
1463 my ($self, $prefix, $domain, $server, $password, $extra_options, $dc_server_ip, $dc_server_ipv6, $no_delete_prefix) = @_;
1466 ## setup the various environment variables we need
1469 my $samsid = Samba::random_domain_sid();
1470 my $swiface = Samba::get_interface($server);
1472 my %createuser_env = ();
1473 my $server_ip = Samba::get_ipv4_addr($server);
1474 my $server_ipv6 = Samba::get_ipv6_addr($server);
1476 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
1479 my $unix_gids_str = $);
1480 my @unix_gids = split(" ", $unix_gids_str);
1482 my $prefix_abs = abs_path($prefix);
1483 my $bindir_abs = abs_path($self->{bindir});
1487 my $shrdir="$prefix_abs/share";
1488 push(@dirs,$shrdir);
1490 my $libdir="$prefix_abs/lib";
1491 push(@dirs,$libdir);
1493 my $piddir="$prefix_abs/pid";
1494 push(@dirs,$piddir);
1496 my $privatedir="$prefix_abs/private";
1497 push(@dirs,$privatedir);
1499 my $binddnsdir = "$prefix_abs/bind-dns";
1500 push(@dirs, $binddnsdir);
1502 my $lockdir="$prefix_abs/lockdir";
1503 push(@dirs,$lockdir);
1505 my $eventlogdir="$prefix_abs/lockdir/eventlog";
1506 push(@dirs,$eventlogdir);
1508 my $logdir="$prefix_abs/logs";
1509 push(@dirs,$logdir);
1511 my $driver32dir="$shrdir/W32X86";
1512 push(@dirs,$driver32dir);
1514 my $driver64dir="$shrdir/x64";
1515 push(@dirs,$driver64dir);
1517 my $driver40dir="$shrdir/WIN40";
1518 push(@dirs,$driver40dir);
1520 my $ro_shrdir="$shrdir/root-tmp";
1521 push(@dirs,$ro_shrdir);
1523 my $msdfs_shrdir="$shrdir/msdfsshare";
1524 push(@dirs,$msdfs_shrdir);
1526 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
1527 push(@dirs,$msdfs_deeppath);
1529 my $badnames_shrdir="$shrdir/badnames";
1530 push(@dirs,$badnames_shrdir);
1532 my $lease1_shrdir="$shrdir/SMB2_10";
1533 push(@dirs,$lease1_shrdir);
1535 my $lease2_shrdir="$shrdir/SMB3_00";
1536 push(@dirs,$lease2_shrdir);
1538 my $manglenames_shrdir="$shrdir/manglenames";
1539 push(@dirs,$manglenames_shrdir);
1541 my $widelinks_shrdir="$shrdir/widelinks";
1542 push(@dirs,$widelinks_shrdir);
1544 my $widelinks_linkdir="$shrdir/widelinks_foo";
1545 push(@dirs,$widelinks_linkdir);
1547 my $shadow_tstdir="$shrdir/shadow";
1548 push(@dirs,$shadow_tstdir);
1549 my $shadow_mntdir="$shadow_tstdir/mount";
1550 push(@dirs,$shadow_mntdir);
1551 my $shadow_basedir="$shadow_mntdir/base";
1552 push(@dirs,$shadow_basedir);
1553 my $shadow_shrdir="$shadow_basedir/share";
1554 push(@dirs,$shadow_shrdir);
1556 my $nosymlinks_shrdir="$shrdir/nosymlinks";
1557 push(@dirs,$nosymlinks_shrdir);
1559 my $local_symlinks_shrdir="$shrdir/local_symlinks";
1560 push(@dirs,$local_symlinks_shrdir);
1562 # this gets autocreated by winbindd
1563 my $wbsockdir="$prefix_abs/winbindd";
1565 my $nmbdsockdir="$prefix_abs/nmbd";
1566 unlink($nmbdsockdir);
1569 ## create the test directory layout
1571 die ("prefix_abs = ''") if $prefix_abs eq "";
1572 die ("prefix_abs = '/'") if $prefix_abs eq "/";
1574 mkdir($prefix_abs, 0777);
1575 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
1576 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
1577 system("rm -rf $prefix_abs/*");
1579 mkdir($_, 0777) foreach(@dirs);
1581 my $fs_specific_conf = $self->get_fs_specific_conf($shrdir);
1584 ## lockdir and piddir must be 0755
1586 chmod 0755, $lockdir;
1587 chmod 0755, $piddir;
1591 ## create ro and msdfs share layout
1594 chmod 0755, $ro_shrdir;
1595 my $unreadable_file = "$ro_shrdir/unreadable_file";
1596 unless (open(UNREADABLE_FILE, ">$unreadable_file")) {
1597 warn("Unable to open $unreadable_file");
1600 close(UNREADABLE_FILE);
1601 chmod 0600, $unreadable_file;
1603 my $msdfs_target = "$ro_shrdir/msdfs-target";
1604 unless (open(MSDFS_TARGET, ">$msdfs_target")) {
1605 warn("Unable to open $msdfs_target");
1608 close(MSDFS_TARGET);
1609 chmod 0666, $msdfs_target;
1610 symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp",
1611 "$msdfs_shrdir/msdfs-src1";
1612 symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
1615 ## create bad names in $badnames_shrdir
1617 ## (An invalid name, would be mangled to 8.3).
1618 my $badname_target = "$badnames_shrdir/\340|\231\216\377\177";
1619 unless (open(BADNAME_TARGET, ">$badname_target")) {
1620 warn("Unable to open $badname_target");
1623 close(BADNAME_TARGET);
1624 chmod 0666, $badname_target;
1626 ## (A bad name, would not be mangled to 8.3).
1627 my $badname_target = "$badnames_shrdir/\240\276\346\327\377\177";
1628 unless (open(BADNAME_TARGET, ">$badname_target")) {
1629 warn("Unable to open $badname_target");
1632 close(BADNAME_TARGET);
1633 chmod 0666, $badname_target;
1635 ## (A bad good name).
1636 my $badname_target = "$badnames_shrdir/blank.txt";
1637 unless (open(BADNAME_TARGET, ">$badname_target")) {
1638 warn("Unable to open $badname_target");
1641 close(BADNAME_TARGET);
1642 chmod 0666, $badname_target;
1645 ## create mangleable directory names in $manglenames_shrdir
1647 my $manglename_target = "$manglenames_shrdir/foo:bar";
1648 mkdir($manglename_target, 0777);
1651 ## create symlinks for widelinks tests.
1653 my $widelinks_target = "$widelinks_linkdir/target";
1654 unless (open(WIDELINKS_TARGET, ">$widelinks_target")) {
1655 warn("Unable to open $widelinks_target");
1658 close(WIDELINKS_TARGET);
1659 chmod 0666, $widelinks_target;
1661 ## This link should get ACCESS_DENIED
1663 symlink "$widelinks_target", "$widelinks_shrdir/source";
1665 ## This link should be allowed
1667 symlink "$widelinks_shrdir", "$widelinks_shrdir/dot";
1669 my $conffile="$libdir/server.conf";
1670 my $dfqconffile="$libdir/dfq.conf";
1671 my $errorinjectconf="$libdir/error_inject.conf";
1672 my $delayinjectconf="$libdir/delay_inject.conf";
1674 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/third_party/nss_wrapper/nss_wrapper.pl";
1675 my $nss_wrapper_passwd = "$privatedir/passwd";
1676 my $nss_wrapper_group = "$privatedir/group";
1677 my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts";
1678 my $resolv_conf = "$privatedir/resolv.conf";
1679 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
1681 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
1683 my $fake_snap_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/fake_snap.pl";
1685 my @eventlog_list = ("dns server", "application");
1688 ## calculate uids and gids
1691 my ($max_uid, $max_gid);
1692 my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
1693 my ($uid_pdbtest_wkn);
1695 my ($uid_force_user);
1696 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
1697 my ($gid_userdup, $gid_everyone);
1698 my ($gid_force_user);
1703 my ($uid_slashuser);
1705 if ($unix_uid < 0xffff - 13) {
1708 $max_uid = $unix_uid;
1711 $uid_root = $max_uid - 1;
1712 $uid_nobody = $max_uid - 2;
1713 $uid_pdbtest = $max_uid - 3;
1714 $uid_pdbtest2 = $max_uid - 4;
1715 $uid_userdup = $max_uid - 5;
1716 $uid_pdbtest_wkn = $max_uid - 6;
1717 $uid_force_user = $max_uid - 7;
1718 $uid_smbget = $max_uid - 8;
1719 $uid_user1 = $max_uid - 9;
1720 $uid_user2 = $max_uid - 10;
1721 $uid_gooduser = $max_uid - 11;
1722 $uid_eviluser = $max_uid - 12;
1723 $uid_slashuser = $max_uid - 13;
1725 if ($unix_gids[0] < 0xffff - 8) {
1728 $max_gid = $unix_gids[0];
1731 $gid_nobody = $max_gid - 1;
1732 $gid_nogroup = $max_gid - 2;
1733 $gid_root = $max_gid - 3;
1734 $gid_domusers = $max_gid - 4;
1735 $gid_domadmins = $max_gid - 5;
1736 $gid_userdup = $max_gid - 6;
1737 $gid_everyone = $max_gid - 7;
1738 $gid_force_user = $max_gid - 8;
1744 unless (open(CONF, ">$conffile")) {
1745 warn("Unable to open $conffile");
1749 my $interfaces = Samba::get_interfaces_config($server);
1753 netbios name = $server
1754 interfaces = $interfaces
1755 bind interfaces only = yes
1756 panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
1757 smbd:suicide mode = yes
1761 private dir = $privatedir
1762 binddns dir = $binddnsdir
1763 pid directory = $piddir
1764 lock directory = $lockdir
1765 log file = $logdir/log.\%m
1770 state directory = $lockdir
1771 cache directory = $lockdir
1773 passdb backend = tdbsam
1777 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1778 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
1779 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1780 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
1781 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
1782 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
1783 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
1785 addprinter command = $mod_printer_pl -a -s $conffile --
1786 deleteprinter command = $mod_printer_pl -d -s $conffile --
1788 eventlog list = application \"dns server\"
1791 kernel change notify = no
1795 printcap name = /dev/null
1797 winbindd socket directory = $wbsockdir
1798 nmbd:socket dir = $nmbdsockdir
1799 idmap config * : range = 100000-200000
1800 winbind enum users = yes
1801 winbind enum groups = yes
1802 winbind separator = /
1803 include system krb5 conf = no
1805 # min receivefile size = 4000
1809 smbd:sharedelay = 100000
1810 smbd:writetimeupdatedelay = 500000
1814 store dos attributes = yes
1819 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot time_audit full_audit
1821 full_audit:syslog = no
1822 full_audit:success = none
1823 full_audit:failure = none
1826 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
1827 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
1828 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
1829 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
1830 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
1831 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
1832 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
1834 print notify backchannel = yes
1836 ncalrpc dir = $prefix_abs/ncalrpc
1838 # The samba3.blackbox.smbclient_s3 test uses this to test that
1839 # sending messages works, and that the %m sub works.
1840 message command = mv %s $shrdir/message.%m
1842 # fsrvp server requires registry shares
1843 registry shares = yes
1845 # Used by RPC SRVSVC tests
1846 add share command = $bindir_abs/smbaddshare
1847 change share command = $bindir_abs/smbchangeshare
1848 delete share command = $bindir_abs/smbdeleteshare
1850 # fruit:copyfile is a global option
1851 fruit:copyfile = yes
1853 #this does not mean that we use non-secure test env,
1854 #it just means we ALLOW one to be configured.
1855 allow insecure wide links = yes
1857 # Begin extra options
1861 #Include user defined custom parameters if set
1864 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
1865 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
1871 comment = smb username is [%U]
1874 comment = Load dirsort module
1875 vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot
1878 comment = encrypt smb username is [%U]
1879 smb encrypt = required
1880 vfs objects = dirsort
1890 force user = $unix_name
1892 [forceuser_unixonly]
1893 comment = force a user with unix user SID and group SID
1895 force user = pdbtest
1897 [forceuser_wkngroup]
1898 comment = force a user with well-known group SID
1900 force user = pdbtest_wkn
1904 force group = nogroup
1912 write list = $unix_name
1915 valid users = $unix_name
1916 access based share enum = yes
1918 path = $msdfs_shrdir
1920 msdfs shuffle referrals = yes
1924 hide unreadable = yes
1927 case sensitive = yes
1930 hide unwriteable files = yes
1933 kernel share modes = no
1947 default devmode = no
1953 comment = smb username is [%U]
1955 nfs4acl_xattr:version = 40
1956 vfs objects = nfs4acl_xattr xattr_tdb
1958 [nfs4acl_special_40]
1960 comment = smb username is [%U]
1962 nfs4acl_xattr:version = 40
1963 vfs objects = nfs4acl_xattr xattr_tdb
1967 comment = smb username is [%U]
1969 vfs objects = nfs4acl_xattr xattr_tdb
1973 comment = smb username is [%U]
1974 vfs objects = nfs4acl_xattr xattr_tdb
1976 nfs4acl_xattr:encoding = xdr
1977 nfs4acl_xattr:version = 40
1981 comment = smb username is [%U]
1982 vfs objects = nfs4acl_xattr xattr_tdb
1984 nfs4acl_xattr:encoding = xdr
1985 nfs4acl_xattr:version = 41
1989 comment = smb username is [%U]
1990 vfs objects = nfs4acl_xattr xattr_tdb
1992 nfs4acl_xattr:encoding = nfs
1993 nfs4acl_xattr:version = 40
1994 nfs4acl_xattr:xattr_name = security.nfs4acl_xdr
1998 comment = smb username is [%U]
1999 vfs objects = nfs4acl_xattr xattr_tdb
2001 nfs4acl_xattr:encoding = nfs
2002 nfs4acl_xattr:version = 41
2003 nfs4acl_xattr:xattr_name = security.nfs4acl_xdr
2007 comment = smb username is [%U]
2009 force create mode = 777
2012 comment = smb username is [%U]
2014 force create mode = 0
2015 directory mask = 0777
2016 force directory mode = 0
2017 vfs objects = xattr_tdb streams_depot
2028 vfs objects = catia fruit streams_xattr acl_xattr xattr_tdb
2029 fruit:resource = file
2030 fruit:metadata = netatalk
2031 fruit:locking = netatalk
2032 fruit:encoding = native
2033 fruit:veto_appledouble = no
2037 # This is used by vfs.fruit tests that require real fs xattr
2038 vfs objects = catia fruit streams_xattr acl_xattr
2039 fruit:resource = file
2040 fruit:metadata = netatalk
2041 fruit:locking = netatalk
2042 fruit:encoding = native
2043 fruit:veto_appledouble = no
2045 [vfs_fruit_metadata_stream]
2047 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2048 fruit:resource = file
2049 fruit:metadata = stream
2050 fruit:veto_appledouble = no
2052 [vfs_fruit_stream_depot]
2054 vfs objects = fruit streams_depot acl_xattr xattr_tdb
2055 fruit:resource = stream
2056 fruit:metadata = stream
2057 fruit:veto_appledouble = no
2061 vfs objects = streams_xattr acl_xattr xattr_tdb
2063 [vfs_wo_fruit_stream_depot]
2065 vfs objects = streams_depot acl_xattr xattr_tdb
2067 [vfs_fruit_timemachine]
2069 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2070 fruit:resource = file
2071 fruit:metadata = stream
2072 fruit:time machine = yes
2073 fruit:time machine max size = 32K
2075 [vfs_fruit_wipe_intentionally_left_blank_rfork]
2077 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2078 fruit:resource = file
2079 fruit:metadata = stream
2080 fruit:wipe_intentionally_left_blank_rfork = true
2081 fruit:delete_empty_adfiles = false
2082 fruit:veto_appledouble = no
2084 [vfs_fruit_delete_empty_adfiles]
2086 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2087 fruit:resource = file
2088 fruit:metadata = stream
2089 fruit:wipe_intentionally_left_blank_rfork = true
2090 fruit:delete_empty_adfiles = true
2091 fruit:veto_appledouble = no
2094 path = $badnames_shrdir
2098 path = $manglenames_shrdir
2106 path = $widelinks_shrdir
2112 comment = fake shapshots using rsync
2113 vfs objects = shell_snap shadow_copy2
2114 shell_snap:check path command = $fake_snap_pl --check
2115 shell_snap:create command = $fake_snap_pl --create
2116 shell_snap:delete command = $fake_snap_pl --delete
2117 # a relative path here fails, the snapshot dir is no longer found
2118 shadow:snapdir = $shrdir/.snapshots
2121 path = $shadow_shrdir
2122 comment = previous versions snapshots under mount point
2123 vfs objects = shadow_copy2
2124 shadow:mountpoint = $shadow_mntdir
2127 path = $shadow_shrdir
2128 comment = previous versions snapshots outside mount point
2129 vfs objects = shadow_copy2
2130 shadow:mountpoint = $shadow_mntdir
2131 shadow:snapdir = $shadow_tstdir/.snapshots
2134 path = $shadow_shrdir
2135 comment = previous versions with subvolume snapshots, snapshots under base dir
2136 vfs objects = shadow_copy2
2137 shadow:mountpoint = $shadow_mntdir
2138 shadow:basedir = $shadow_basedir
2139 shadow:snapdir = $shadow_basedir/.snapshots
2142 path = $shadow_shrdir
2143 comment = previous versions with subvolume snapshots, snapshots outside mount point
2144 vfs objects = shadow_copy2
2145 shadow:mountpoint = $shadow_mntdir
2146 shadow:basedir = $shadow_basedir
2147 shadow:snapdir = $shadow_tstdir/.snapshots
2150 path = $shadow_shrdir
2151 comment = previous versions at volume root snapshots under mount point
2152 vfs objects = shadow_copy2
2153 shadow:mountpoint = $shadow_shrdir
2156 path = $shadow_shrdir
2157 comment = previous versions at volume root snapshots outside mount point
2158 vfs objects = shadow_copy2
2159 shadow:mountpoint = $shadow_shrdir
2160 shadow:snapdir = $shadow_tstdir/.snapshots
2163 path = $shadow_shrdir
2164 comment = previous versions snapshots everywhere
2165 vfs objects = shadow_copy2
2166 shadow:mountpoint = $shadow_mntdir
2167 shadow:snapdirseverywhere = yes
2170 path = $shadow_shrdir
2171 comment = previous versions using snapsharepath
2172 vfs objects = shadow_copy2
2173 shadow:mountpoint = $shadow_mntdir
2174 shadow:snapdir = $shadow_tstdir/.snapshots
2175 shadow:snapsharepath = share
2178 comment = Testing shadow:format with default option
2179 vfs object = shadow_copy2
2180 path = $shadow_shrdir
2183 shadow:mountpoint = $shadow_mntdir
2184 shadow:basedir = $shadow_basedir
2185 shadow:snapdir = $shadow_basedir/.snapshots
2186 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2189 comment = Testing shadow:format with only date component
2190 vfs object = shadow_copy2
2191 path = $shadow_shrdir
2194 shadow:mountpoint = $shadow_mntdir
2195 shadow:basedir = $shadow_basedir
2196 shadow:snapdir = $shadow_basedir/.snapshots
2197 shadow:format = \@GMT-%Y-%m-%d
2200 comment = Testing shadow:format with some hardcoded prefix
2201 vfs object = shadow_copy2
2202 path = $shadow_shrdir
2205 shadow:mountpoint = $shadow_mntdir
2206 shadow:basedir = $shadow_basedir
2207 shadow:snapdir = $shadow_basedir/.snapshots
2208 shadow:format = snap\@GMT-%Y.%m.%d-%H.%M.%S
2211 comment = Testing shadow:format with modified format
2212 vfs object = shadow_copy2
2213 path = $shadow_shrdir
2216 shadow:mountpoint = $shadow_mntdir
2217 shadow:basedir = $shadow_basedir
2218 shadow:snapdir = $shadow_basedir/.snapshots
2219 shadow:format = \@GMT-%Y.%m.%d-%H_%M_%S-snap
2222 comment = Testing shadow:snapprefix regex
2223 vfs object = shadow_copy2
2224 path = $shadow_shrdir
2227 shadow:mountpoint = $shadow_mntdir
2228 shadow:basedir = $shadow_basedir
2229 shadow:snapdir = $shadow_basedir/.snapshots
2230 shadow:snapprefix = \^s[a-z]*p\$
2231 shadow:format = _GMT-%Y.%m.%d-%H.%M.%S
2234 comment = Testing shadow:snapprefix with delim regex
2235 vfs object = shadow_copy2
2236 path = $shadow_shrdir
2239 shadow:mountpoint = $shadow_mntdir
2240 shadow:basedir = $shadow_basedir
2241 shadow:snapdir = $shadow_basedir/.snapshots
2242 shadow:delimiter = \@GMT
2243 shadow:snapprefix = [a-z]*
2244 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2247 path = $shadow_shrdir
2248 comment = previous versions with wide links allowed
2249 vfs objects = shadow_copy2
2250 shadow:mountpoint = $shadow_mntdir
2254 path = $shadow_tstdir
2255 comment = previous versions snapshots under mount point
2256 vfs objects = shadow_copy2 streams_xattr error_inject
2258 error_inject:pwrite = EBADF
2259 shadow:mountpoint = $shadow_tstdir
2262 path = $shrdir/dfree
2263 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2264 admin users = $unix_name
2265 include = $dfqconffile
2267 path = $shrdir/dfree
2268 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2269 admin users = $unix_name
2270 include = $dfqconffile
2271 dfree cache time = 60
2273 path = $shrdir/dfree
2274 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2276 include = $dfqconffile
2278 path = $shrdir/quota
2279 admin users = $unix_name
2281 [acl_xattr_ign_sysacl_posix]
2283 acl_xattr:ignore system acls = yes
2284 acl_xattr:default acl style = posix
2285 [acl_xattr_ign_sysacl_windows]
2287 acl_xattr:ignore system acls = yes
2288 acl_xattr:default acl style = windows
2292 mangled names = illegal
2296 path = $nosymlinks_shrdir
2297 follow symlinks = no
2301 path = $local_symlinks_shrdir
2302 follow symlinks = yes
2306 kernel oplocks = yes
2307 vfs objects = streams_xattr xattr_tdb
2311 vfs objects = streams_xattr xattr_tdb
2315 smbd:find async delay usec = 10000
2318 vfs objects = error_inject
2319 include = $errorinjectconf
2323 vfs objects = delay_inject
2324 kernel share modes = no
2327 include = $delayinjectconf
2331 vfs objects = delay_inject
2332 delay_inject:pread_send = 2000
2333 delay_inject:pwrite_send = 2000
2336 path = $prefix_abs/share
2337 delete readonly = yes
2341 my $net = Samba::bindir_path($self, "net");
2343 $cmd .= "SMB_CONF_PATH=\"$conffile\" ";
2344 $cmd .= "$net setlocalsid $samsid";
2346 if (system($cmd) != 0) {
2347 warn("Join failed\n$cmd");
2351 unless (open(ERRORCONF, ">$errorinjectconf")) {
2352 warn("Unable to open $errorinjectconf");
2357 unless (open(DELAYCONF, ">$delayinjectconf")) {
2358 warn("Unable to open $delayinjectconf");
2363 unless (open(DFQCONF, ">$dfqconffile")) {
2364 warn("Unable to open $dfqconffile");
2370 ## create a test account
2373 unless (open(PASSWD, ">$nss_wrapper_passwd")) {
2374 warn("Unable to open $nss_wrapper_passwd");
2377 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
2378 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
2379 pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2380 pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2381 userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
2382 pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false
2383 force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false
2384 smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false
2385 user1:x:$uid_user1:$gid_nogroup:user1 gecos:$prefix_abs:/bin/false
2386 user2:x:$uid_user2:$gid_nogroup:user2 gecos:$prefix_abs:/bin/false
2387 gooduser:x:$uid_gooduser:$gid_domusers:gooduser gecos:$prefix_abs:/bin/false
2388 eviluser:x:$uid_eviluser:$gid_domusers:eviluser gecos::/bin/false
2389 slashuser:x:$uid_slashuser:$gid_domusers:slashuser gecos:/:/bin/false
2391 if ($unix_uid != 0) {
2392 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
2397 unless (open(GROUP, ">$nss_wrapper_group")) {
2398 warn("Unable to open $nss_wrapper_group");
2401 print GROUP "nobody:x:$gid_nobody:
2402 nogroup:x:$gid_nogroup:nobody
2403 $unix_name-group:x:$unix_gids[0]:
2404 domusers:X:$gid_domusers:
2405 domadmins:X:$gid_domadmins:
2406 userdup:x:$gid_userdup:$unix_name
2407 everyone:x:$gid_everyone:
2408 force_user:x:$gid_force_user:
2410 if ($unix_gids[0] != 0) {
2411 print GROUP "root:x:$gid_root:
2418 my $hostname = lc($server);
2419 unless (open(HOSTS, ">>$nss_wrapper_hosts")) {
2420 warn("Unable to open $nss_wrapper_hosts");
2423 print HOSTS "${server_ip} ${hostname}.samba.example.com ${hostname}\n";
2424 print HOSTS "${server_ipv6} ${hostname}.samba.example.com ${hostname}\n";
2428 unless (open(RESOLV_CONF, ">$resolv_conf")) {
2429 warn("Unable to open $resolv_conf");
2432 if (defined($dc_server_ip) or defined($dc_server_ipv6)) {
2433 if (defined($dc_server_ip)) {
2434 print RESOLV_CONF "nameserver $dc_server_ip\n";
2436 if (defined($dc_server_ipv6)) {
2437 print RESOLV_CONF "nameserver $dc_server_ipv6\n";
2440 print RESOLV_CONF "nameserver ${server_ip}\n";
2441 print RESOLV_CONF "nameserver ${server_ipv6}\n";
2445 foreach my $evlog (@eventlog_list) {
2446 my $evlogtdb = "$eventlogdir/$evlog.tdb";
2447 open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
2451 $createuser_env{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2452 $createuser_env{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2453 $createuser_env{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2454 $createuser_env{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2455 if ($ENV{SAMBA_DNS_FAKING}) {
2456 $createuser_env{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2458 $createuser_env{RESOLV_WRAPPER_CONF} = $resolv_conf;
2461 createuser($self, $unix_name, $password, $conffile, \%createuser_env) || die("Unable to create user");
2462 createuser($self, "force_user", $password, $conffile, \%createuser_env) || die("Unable to create force_user");
2463 createuser($self, "smbget_user", $password, $conffile, \%createuser_env) || die("Unable to create smbget_user");
2464 createuser($self, "user1", $password, $conffile, \%createuser_env) || die("Unable to create user1");
2465 createuser($self, "user2", $password, $conffile, \%createuser_env) || die("Unable to create user2");
2466 createuser($self, "gooduser", $password, $conffile, \%createuser_env) || die("Unable to create gooduser");
2467 createuser($self, "eviluser", $password, $conffile, \%createuser_env) || die("Unable to create eviluser");
2468 createuser($self, "slashuser", $password, $conffile, \%createuser_env) || die("Unable to create slashuser");
2470 open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
2471 print DNS_UPDATE_LIST "A $server. $server_ip\n";
2472 print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n";
2473 close(DNS_UPDATE_LIST);
2477 $ret{SERVER_IP} = $server_ip;
2478 $ret{SERVER_IPV6} = $server_ipv6;
2479 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
2480 $ret{NMBD_TEST_LOG_POS} = 0;
2481 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
2482 $ret{WINBINDD_TEST_LOG_POS} = 0;
2483 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
2484 $ret{SMBD_TEST_LOG_POS} = 0;
2485 $ret{SERVERCONFFILE} = $conffile;
2486 $ret{CONFIGURATION} ="-s $conffile";
2487 $ret{LOCK_DIR} = $lockdir;
2488 $ret{SERVER} = $server;
2489 $ret{USERNAME} = $unix_name;
2490 $ret{USERID} = $unix_uid;
2491 $ret{DOMAIN} = $domain;
2492 $ret{SAMSID} = $samsid;
2493 $ret{NETBIOSNAME} = $server;
2494 $ret{PASSWORD} = $password;
2495 $ret{PIDDIR} = $piddir;
2496 $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir;
2497 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
2498 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
2499 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2500 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2501 $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2502 $ret{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2503 $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
2504 $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind";
2505 if ($ENV{SAMBA_DNS_FAKING}) {
2506 $ret{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2508 $ret{RESOLV_WRAPPER_CONF} = $resolv_conf;
2510 $ret{LOCAL_PATH} = "$shrdir";
2511 $ret{LOGDIR} = $logdir;
2514 # Avoid hitting system krb5.conf -
2515 # An env that needs Kerberos will reset this to the real
2518 $ret{KRB5_CONFIG} = abs_path($prefix) . "/no_krb5.conf";
2520 # Define KRB5CCNAME for each environment we set up
2521 $ret{KRB5_CCACHE} = abs_path($prefix) . "/krb5ccache";
2522 $ENV{KRB5CCNAME} = $ret{KRB5_CCACHE};
2527 sub wait_for_start($$$$$)
2529 my ($self, $envvars, $nmbd, $winbindd, $smbd) = @_;
2534 if ($nmbd eq "yes") {
2537 # give time for nbt server to register its names
2538 print "checking for nmbd\n";
2540 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
2541 my $nmblookup = Samba::bindir_path($self, "nmblookup");
2544 $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
2548 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
2549 system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
2550 system("$nmblookup $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
2551 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
2554 } while ($ret != 0 && $count < 10);
2556 print "NMBD not reachable after 10 retries\n";
2557 teardown_env($self, $envvars);
2562 if ($winbindd eq "yes") {
2563 print "checking for winbindd\n";
2565 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2566 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2567 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2568 $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping-dc";
2572 $ret = system($cmd);
2576 } while ($ret != 0 && $count < 20);
2578 print "WINBINDD not reachable after 20 seconds\n";
2579 teardown_env($self, $envvars);
2584 if ($smbd eq "yes") {
2585 # make sure smbd is also up set
2586 print "wait for smbd\n";
2590 $ret = system(Samba::bindir_path($self, "smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139");
2595 } while ($ret != 0 && $count < 20);
2597 print "SMBD failed to start up in a reasonable time (20sec)\n";
2598 teardown_env($self, $envvars);
2603 # Ensure we have domain users mapped.
2604 $netcmd = "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2605 $netcmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2606 $netcmd .= Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} ";
2608 $cmd = $netcmd . "groupmap delete ntgroup=domusers";
2609 $ret = system($cmd);
2611 $cmd = $netcmd . "groupmap add rid=513 unixgroup=domusers type=domain";
2612 $ret = system($cmd);
2614 print("\"$cmd\" failed\n");
2618 $cmd = $netcmd . "groupmap delete ntgroup=domadmins";
2619 $ret = system($cmd);
2621 $cmd = $netcmd . "groupmap add rid=512 unixgroup=domadmins type=domain";
2622 $ret = system($cmd);
2624 print("\"$cmd\" failed\n");
2628 $cmd = $netcmd . "groupmap delete ntgroup=everyone";
2629 $ret = system($cmd);
2631 $cmd = $netcmd . "groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin";
2632 $ret = system($cmd);
2634 print("\"$cmd\" failed\n");
2638 # note: creating builtin groups requires winbindd for the
2640 my $create_builtin_users = "no";
2641 if ($winbindd eq "yes") {
2642 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2643 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2644 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2645 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
2646 my $wbinfo_out = qx($cmd 2>&1);
2648 # wbinfo doesn't give us a better error code then
2649 # WBC_ERR_DOMAIN_NOT_FOUND, but at least that's
2650 # different then WBC_ERR_WINBIND_NOT_AVAILABLE
2651 if ($wbinfo_out !~ /WBC_ERR_DOMAIN_NOT_FOUND/) {
2652 print("Failed to run \"wbinfo --sid-to-gid=S-1-5-32-545\": $wbinfo_out");
2653 teardown_env($self, $envvars);
2656 $create_builtin_users = "yes";
2659 if ($create_builtin_users eq "yes") {
2660 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2661 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2662 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2663 $cmd .= Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
2664 $cmd .= "sam createbuiltingroup Users";
2665 $ret = system($cmd);
2667 print "Failed to create BUILTIN\\Users group\n";
2668 teardown_env($self, $envvars);
2672 $cmd = Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
2673 $cmd .= "cache del IDMAP/SID2XID/S-1-5-32-545";
2676 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2677 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2678 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2679 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
2680 $ret = system($cmd);
2682 print "Missing \"BUILTIN\\Users\", did net sam createbuiltingroup Users fail?\n";
2683 teardown_env($self, $envvars);
2688 print $self->getlog_env($envvars);