2 # Bootstrap Samba and run a number of tests against it.
3 # Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
4 # Published under the GNU GPL, v3 or later.
6 # NOTE: Refer to the README for more details about the various testenvs,
7 # and tips about adding new testenvs.
13 use FindBin qw($RealBin);
16 use File::Path 'remove_tree';
21 my $smbd_build_options = Samba::bindir_path($self, "smbd") . " -b|";
22 open(IN, $smbd_build_options) or die("Unable to run $smbd_build_options: $!");
31 # If we were not built with ADS support, pretend we were never even available
32 print "smbd does not have ADS support\n" unless $found_ads;
36 # return smb.conf parameters applicable to @path, based on the underlying
38 sub get_fs_specific_conf($$)
40 my ($self, $path) = @_;
42 my $stat_out = `stat --file-system $path` or return "";
44 if ($stat_out =~ m/Type:\s+btrfs/) {
45 $mods .= "streams_xattr btrfs";
49 return "vfs objects = $mods";
56 my ($classname, $bindir, $srcdir, $server_maxtime) = @_;
57 my $self = { vars => {},
60 server_maxtime => $server_maxtime
68 my ($self, $envvars) = @_;
71 # This should cause smbd to terminate gracefully
72 close($envvars->{STDIN_PIPE});
74 my $smbdpid = $envvars->{SMBD_TL_PID};
75 my $nmbdpid = $envvars->{NMBD_TL_PID};
76 my $winbinddpid = $envvars->{WINBINDD_TL_PID};
78 # This should give it time to write out the gcov data
80 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
81 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
82 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
85 && $winbinddchild == -1) {
92 if ($count <= 20 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
96 $self->stop_sig_term($smbdpid);
97 $self->stop_sig_term($nmbdpid);
98 $self->stop_sig_term($winbinddpid);
101 until ($count > 10) {
102 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
103 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
104 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
107 && $winbinddchild == -1) {
114 if ($count <= 10 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
118 warn("timelimit process did not quit on SIGTERM, sending SIGKILL");
119 $self->stop_sig_kill($smbdpid);
120 $self->stop_sig_kill($nmbdpid);
121 $self->stop_sig_kill($winbinddpid);
126 sub getlog_env_app($$$)
128 my ($self, $envvars, $name) = @_;
130 my $title = "$name LOG of: $envvars->{NETBIOSNAME}\n";
133 open(LOG, "<".$envvars->{$name."_TEST_LOG"});
135 seek(LOG, $envvars->{$name."_TEST_LOG_POS"}, SEEK_SET);
139 $envvars->{$name."_TEST_LOG_POS"} = tell(LOG);
142 return "" if $out eq $title;
149 my ($self, $envvars) = @_;
152 $ret .= $self->getlog_env_app($envvars, "SMBD");
153 $ret .= $self->getlog_env_app($envvars, "NMBD");
154 $ret .= $self->getlog_env_app($envvars, "WINBINDD");
161 my ($self, $envvars) = @_;
163 my $childpid = waitpid(-1, WNOHANG);
169 # Declare the environments Samba3 makes available.
170 # To be set up, they will be called as
171 # samba3->setup_$envname($self, $path, $dep_1_vars, $dep_2_vars, ...)
172 %Samba3::ENV_DEPS = (
173 # name => [dep_1, dep_2, ...],
175 nt4_dc_schannel => [],
182 nt4_member => ["nt4_dc"],
184 ad_member => ["ad_dc"],
185 ad_member_rfc2307 => ["ad_dc_ntvfs"],
186 ad_member_idmap_rid => ["ad_dc"],
187 ad_member_idmap_ad => ["ad_dc"],
192 my ($self, $path) = @_;
194 print "PROVISIONING NT4 DC...";
196 my $nt4_dc_options = "
201 raw NTLMv2 auth = yes
202 server schannel = auto
204 rpc_server:epmapper = external
205 rpc_server:spoolss = external
206 rpc_server:lsarpc = external
207 rpc_server:samr = external
208 rpc_server:netlogon = external
209 rpc_server:register_embedded_np = yes
210 rpc_server:FssagentRpc = external
212 rpc_daemon:epmd = fork
213 rpc_daemon:spoolssd = fork
214 rpc_daemon:lsasd = fork
215 rpc_daemon:fssd = fork
216 fss: sequence timeout = 1
217 check parent directory delete on close = yes
220 my $vars = $self->provision($path, "SAMBA-TEST",
225 $vars or return undef;
227 if (not $self->check_or_start($vars, "yes", "yes", "yes")) {
231 $vars->{DOMSID} = $vars->{SAMSID};
232 $vars->{DC_SERVER} = $vars->{SERVER};
233 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
234 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
235 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
236 $vars->{DC_USERNAME} = $vars->{USERNAME};
237 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
242 sub setup_nt4_dc_schannel
244 my ($self, $path) = @_;
246 print "PROVISIONING NT4 DC WITH SERVER SCHANNEL ...";
253 rpc_server:epmapper = external
254 rpc_server:spoolss = external
255 rpc_server:lsarpc = external
256 rpc_server:samr = external
257 rpc_server:netlogon = external
258 rpc_server:register_embedded_np = yes
260 rpc_daemon:epmd = fork
261 rpc_daemon:spoolssd = fork
262 rpc_daemon:lsasd = fork
264 server schannel = yes
265 # used to reproduce bug #12772
266 server max protocol = SMB2_02
269 my $vars = $self->provision($path, "NT4SCHANNEL",
274 $vars or return undef;
276 if (not $self->check_or_start($vars, "yes", "yes", "yes")) {
280 $vars->{DOMSID} = $vars->{SAMSID};
281 $vars->{DC_SERVER} = $vars->{SERVER};
282 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
283 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
284 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
285 $vars->{DC_USERNAME} = $vars->{USERNAME};
286 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
293 my ($self, $prefix, $nt4_dc_vars) = @_;
297 print "PROVISIONING MEMBER...";
299 my $require_mutexes = "dbwrap_tdb_require_mutexes:* = yes";
300 $require_mutexes = "" if ($ENV{SELFTEST_DONT_REQUIRE_TDB_MUTEX_SUPPORT} eq "1");
302 my $member_options = "
304 dbwrap_tdb_mutexes:* = yes
307 my $ret = $self->provision($prefix, $nt4_dc_vars->{DOMAIN},
309 "localnt4member3pass",
312 $ret or return undef;
314 my $nmblookup = Samba::bindir_path($self, "nmblookup");
316 print "Waiting for the LOGON SERVER registration ...\n";
317 $rc = system("$nmblookup $ret->{CONFIGURATION} $ret->{DOMAIN}\#1c");
322 } while ($rc != 0 && $count < 10);
324 print "NMBD not reachable after 10 retries\n";
325 teardown_env($self, $ret);
329 my $net = Samba::bindir_path($self, "net");
330 # Add hosts file for name lookups
331 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
332 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
333 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
334 $cmd .= "$net rpc join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
335 $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}";
337 if (system($cmd) != 0) {
338 warn("Join failed\n$cmd");
342 # Add hosts file for name lookups
343 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
344 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
345 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
346 $cmd .= "$net $ret->{CONFIGURATION} primarytrust dumpinfo | grep -q 'REDACTED SECRET VALUES'";
348 if (system($cmd) != 0) {
349 warn("check failed\n$cmd");
353 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
357 $ret->{DOMSID} = $nt4_dc_vars->{DOMSID};
358 $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
359 $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
360 $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
361 $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME};
362 $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME};
363 $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD};
370 my ($self, $prefix, $dcvars) = @_;
372 my $prefix_abs = abs_path($prefix);
375 # If we didn't build with ADS, pretend this env was never available
376 if (not $self->have_ads()) {
380 print "PROVISIONING S3 AD MEMBER...";
382 mkdir($prefix_abs, 0777);
384 my $share_dir="$prefix_abs/share";
385 push(@dirs, $share_dir);
387 my $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}";
388 push(@dirs, $substitution_path);
390 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice";
391 push(@dirs, $substitution_path);
393 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice/G_domain users";
394 push(@dirs, $substitution_path);
396 # Using '/' as the winbind separator is a bad idea ...
397 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}";
398 push(@dirs, $substitution_path);
400 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice";
401 push(@dirs, $substitution_path);
403 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}";
404 push(@dirs, $substitution_path);
406 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}/domain users";
407 push(@dirs, $substitution_path);
409 my $member_options = "
411 workgroup = $dcvars->{DOMAIN}
412 realm = $dcvars->{REALM}
413 netbios aliases = foo bar
414 template homedir = /home/%D/%G/%U
415 auth event notification = true
416 password server = $dcvars->{SERVER}
419 path = $share_dir/D_%D/U_%U/G_%G
423 path = $share_dir/D_%D/u_%u/g_%g
428 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
432 $dcvars->{SERVER_IP},
433 $dcvars->{SERVER_IPV6});
435 $ret or return undef;
437 mkdir($_, 0777) foreach(@dirs);
440 $ret->{DOMAIN} = $dcvars->{DOMAIN};
441 $ret->{REALM} = $dcvars->{REALM};
442 $ret->{DOMSID} = $dcvars->{DOMSID};
446 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
447 $ctx->{domain} = $dcvars->{DOMAIN};
448 $ctx->{realm} = $dcvars->{REALM};
449 $ctx->{dnsname} = lc($dcvars->{REALM});
450 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
451 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
452 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
453 Samba::mk_krb5_conf($ctx, "");
455 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
456 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
458 my $net = Samba::bindir_path($self, "net");
459 # Add hosts file for name lookups
460 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
461 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
462 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
463 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
465 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
467 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
468 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
469 $cmd .= "$net join $ret->{CONFIGURATION}";
470 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
472 if (system($cmd) != 0) {
473 warn("Join failed\n$cmd");
477 # We need world access to this share, as otherwise the domain
478 # administrator from the AD domain provided by Samba4 can't
479 # access the share for tests.
480 chmod 0777, "$prefix/share";
482 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
486 $ret->{DC_SERVER} = $dcvars->{SERVER};
487 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
488 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
489 $ret->{DC_SERVERCONFFILE} = $dcvars->{SERVERCONFFILE};
490 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
491 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
492 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
497 sub setup_ad_member_rfc2307
499 my ($self, $prefix, $dcvars) = @_;
501 # If we didn't build with ADS, pretend this env was never available
502 if (not $self->have_ads()) {
506 print "PROVISIONING S3 AD MEMBER WITH idmap_rfc2307 config...";
508 my $member_options = "
510 workgroup = $dcvars->{DOMAIN}
511 realm = $dcvars->{REALM}
513 idmap negative cache time = 0
514 idmap config * : backend = autorid
515 idmap config * : range = 1000000-1999999
516 idmap config * : rangesize = 100000
517 idmap config $dcvars->{DOMAIN} : backend = rfc2307
518 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
519 idmap config $dcvars->{DOMAIN} : ldap_server = ad
520 idmap config $dcvars->{DOMAIN} : bind_path_user = ou=idmap,dc=samba,dc=example,dc=com
521 idmap config $dcvars->{DOMAIN} : bind_path_group = ou=idmap,dc=samba,dc=example,dc=com
523 password server = $dcvars->{SERVER}
526 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
530 $dcvars->{SERVER_IP},
531 $dcvars->{SERVER_IPV6});
533 $ret or return undef;
536 $ret->{DOMAIN} = $dcvars->{DOMAIN};
537 $ret->{REALM} = $dcvars->{REALM};
538 $ret->{DOMSID} = $dcvars->{DOMSID};
541 my $prefix_abs = abs_path($prefix);
543 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
544 $ctx->{domain} = $dcvars->{DOMAIN};
545 $ctx->{realm} = $dcvars->{REALM};
546 $ctx->{dnsname} = lc($dcvars->{REALM});
547 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
548 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
549 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
550 Samba::mk_krb5_conf($ctx, "");
552 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
553 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
555 my $net = Samba::bindir_path($self, "net");
556 # Add hosts file for name lookups
557 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
558 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
559 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
560 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
562 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
564 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
565 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
566 $cmd .= "$net join $ret->{CONFIGURATION}";
567 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
569 if (system($cmd) != 0) {
570 warn("Join failed\n$cmd");
574 # We need world access to this share, as otherwise the domain
575 # administrator from the AD domain provided by Samba4 can't
576 # access the share for tests.
577 chmod 0777, "$prefix/share";
579 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
583 $ret->{DC_SERVER} = $dcvars->{SERVER};
584 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
585 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
586 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
587 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
588 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
593 sub setup_ad_member_idmap_rid
595 my ($self, $prefix, $dcvars) = @_;
597 # If we didn't build with ADS, pretend this env was never available
598 if (not $self->have_ads()) {
602 print "PROVISIONING S3 AD MEMBER WITH idmap_rid config...";
604 my $member_options = "
606 workgroup = $dcvars->{DOMAIN}
607 realm = $dcvars->{REALM}
608 idmap config * : backend = tdb
609 idmap config * : range = 1000000-1999999
610 idmap config $dcvars->{DOMAIN} : backend = rid
611 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
612 # Prevent overridding the provisioned lib/krb5.conf which sets certain
613 # values required for tests to succeed
614 create krb5 conf = no
617 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
621 $dcvars->{SERVER_IP},
622 $dcvars->{SERVER_IPV6});
624 $ret or return undef;
627 $ret->{DOMAIN} = $dcvars->{DOMAIN};
628 $ret->{REALM} = $dcvars->{REALM};
629 $ret->{DOMSID} = $dcvars->{DOMSID};
632 my $prefix_abs = abs_path($prefix);
634 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
635 $ctx->{domain} = $dcvars->{DOMAIN};
636 $ctx->{realm} = $dcvars->{REALM};
637 $ctx->{dnsname} = lc($dcvars->{REALM});
638 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
639 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
640 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
641 Samba::mk_krb5_conf($ctx, "");
643 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
644 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
646 my $net = Samba::bindir_path($self, "net");
647 # Add hosts file for name lookups
648 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
649 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
650 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
651 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
653 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
655 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
656 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
657 $cmd .= "$net join $ret->{CONFIGURATION}";
658 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
660 if (system($cmd) != 0) {
661 warn("Join failed\n$cmd");
665 # We need world access to this share, as otherwise the domain
666 # administrator from the AD domain provided by Samba4 can't
667 # access the share for tests.
668 chmod 0777, "$prefix/share";
670 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
674 $ret->{DC_SERVER} = $dcvars->{SERVER};
675 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
676 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
677 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
678 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
679 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
684 sub setup_ad_member_idmap_ad
686 my ($self, $prefix, $dcvars) = @_;
688 # If we didn't build with ADS, pretend this env was never available
689 if (not $self->have_ads()) {
693 print "PROVISIONING S3 AD MEMBER WITH idmap_ad config...";
695 my $member_options = "
697 workgroup = $dcvars->{DOMAIN}
698 realm = $dcvars->{REALM}
699 password server = $dcvars->{SERVER}
700 idmap config * : backend = tdb
701 idmap config * : range = 1000000-1999999
702 idmap config $dcvars->{DOMAIN} : backend = ad
703 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
706 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
710 $dcvars->{SERVER_IP},
711 $dcvars->{SERVER_IPV6});
713 $ret or return undef;
716 $ret->{DOMAIN} = $dcvars->{DOMAIN};
717 $ret->{REALM} = $dcvars->{REALM};
718 $ret->{DOMSID} = $dcvars->{DOMSID};
721 my $prefix_abs = abs_path($prefix);
723 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
724 $ctx->{domain} = $dcvars->{DOMAIN};
725 $ctx->{realm} = $dcvars->{REALM};
726 $ctx->{dnsname} = lc($dcvars->{REALM});
727 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
728 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
729 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
730 Samba::mk_krb5_conf($ctx, "");
732 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
733 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
735 my $net = Samba::bindir_path($self, "net");
736 # Add hosts file for name lookups
737 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
738 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
739 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
740 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
742 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
744 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
745 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
746 $cmd .= "$net join $ret->{CONFIGURATION}";
747 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
749 if (system($cmd) != 0) {
750 warn("Join failed\n$cmd");
754 # We need world access to this share, as otherwise the domain
755 # administrator from the AD domain provided by Samba4 can't
756 # access the share for tests.
757 chmod 0777, "$prefix/share";
759 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
763 $ret->{DC_SERVER} = $dcvars->{SERVER};
764 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
765 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
766 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
767 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
768 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
773 sub setup_simpleserver
775 my ($self, $path) = @_;
777 print "PROVISIONING simple server...";
779 my $prefix_abs = abs_path($path);
781 my $simpleserver_options = "
784 vfs objects = xattr_tdb streams_depot
789 path = $prefix_abs/share
791 vfs objects = aio_pthread
792 aio_pthread:aio open = yes
793 smbd:async dosmode = no
795 [vfs_aio_pthread_async_dosmode_default1]
796 path = $prefix_abs/share
798 vfs objects = aio_pthread
799 store dos attributes = yes
800 aio_pthread:aio open = yes
801 smbd:async dosmode = yes
803 [vfs_aio_pthread_async_dosmode_default2]
804 path = $prefix_abs/share
806 vfs objects = aio_pthread xattr_tdb
807 store dos attributes = yes
808 aio_pthread:aio open = yes
809 smbd:async dosmode = yes
811 [vfs_aio_pthread_async_dosmode_force_sync1]
812 path = $prefix_abs/share
814 vfs objects = aio_pthread
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
824 [vfs_aio_pthread_async_dosmode_force_sync2]
825 path = $prefix_abs/share
827 vfs objects = aio_pthread xattr_tdb
828 store dos attributes = yes
829 aio_pthread:aio open = yes
830 smbd:async dosmode = yes
831 # This simulates non linux systems
832 smbd:force sync user path safe threadpool = yes
833 smbd:force sync user chdir safe threadpool = yes
834 smbd:force sync root path safe threadpool = yes
835 smbd:force sync root chdir safe threadpool = yes
838 path = $prefix_abs/share
839 vfs objects = aio_fork
841 vfs_aio_fork:erratic_testing_mode=yes
844 path = $prefix_abs/share
846 store dos attributes = yes
847 hide files = /hidefile/
851 path = $prefix_abs/share
853 smb encrypt = desired
856 path = $prefix_abs/share
857 hide new files timeout = 5
860 my $vars = $self->provision($path, "WORKGROUP",
863 $simpleserver_options);
865 $vars or return undef;
867 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
876 my ($self, $path) = @_;
877 my $prefix_abs = abs_path($path);
878 my $srcdir_abs = abs_path($self->{srcdir});
880 print "PROVISIONING file server ...\n";
884 mkdir($prefix_abs, 0777);
886 my $usershare_dir="$prefix_abs/lib/usershare";
888 mkdir("$prefix_abs/lib", 0755);
889 remove_tree($usershare_dir);
890 mkdir($usershare_dir, 01770);
892 my $share_dir="$prefix_abs/share";
894 # Create share directory structure
895 my $lower_case_share_dir="$share_dir/lower-case";
896 push(@dirs, $lower_case_share_dir);
898 my $lower_case_share_dir_30000="$share_dir/lower-case-30000";
899 push(@dirs, $lower_case_share_dir_30000);
901 my $dfree_share_dir="$share_dir/dfree";
902 push(@dirs, $dfree_share_dir);
903 push(@dirs, "$dfree_share_dir/subdir1");
904 push(@dirs, "$dfree_share_dir/subdir2");
905 push(@dirs, "$dfree_share_dir/subdir3");
907 my $quotadir_dir="$share_dir/quota";
908 push(@dirs, $quotadir_dir);
910 my $valid_users_sharedir="$share_dir/valid_users";
911 push(@dirs,$valid_users_sharedir);
913 my $offline_sharedir="$share_dir/offline";
914 push(@dirs,$offline_sharedir);
916 my $force_user_valid_users_dir = "$share_dir/force_user_valid_users";
917 push(@dirs, $force_user_valid_users_dir);
919 my $smbget_sharedir="$share_dir/smbget";
920 push(@dirs,$smbget_sharedir);
922 my $tarmode_sharedir="$share_dir/tarmode";
923 push(@dirs,$tarmode_sharedir);
925 my $usershare_sharedir="$share_dir/usershares";
926 push(@dirs,$usershare_sharedir);
928 my $fileserver_options = "
929 kernel change notify = yes
931 usershare path = $usershare_dir
932 usershare max shares = 10
933 usershare allow guests = yes
934 usershare prefix allow list = $usershare_sharedir
936 get quota command = $prefix_abs/getset_quota.py
937 set quota command = $prefix_abs/getset_quota.py
939 path = $lower_case_share_dir
940 comment = smb username is [%U]
941 case sensitive = True
944 short preserve case = no
946 path = $lower_case_share_dir_30000
947 comment = smb username is [%U]
948 case sensitive = True
951 short preserve case = no
953 path = $dfree_share_dir
954 comment = smb username is [%U]
955 dfree command = $srcdir_abs/testprogs/blackbox/dfree.sh
957 path = $valid_users_sharedir
958 valid users = +userdup
960 path = $offline_sharedir
961 vfs objects = offline
963 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878
964 # RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651
965 [force_user_valid_users]
966 path = $force_user_valid_users_dir
967 comment = force user with valid users combination test share
968 valid users = +force_user
969 force user = force_user
970 force group = everyone
971 write list = force_user
974 path = $smbget_sharedir
975 comment = smb username is [%U]
979 comment = ignore system acls
980 acl_xattr:ignore system acls = yes
983 comment = inherit owner
987 comment = inherit only unix owner
988 inherit owner = unix only
989 acl_xattr:ignore system acls = yes
990 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=13690
993 comment = force group test
994 # force group = everyone
996 comment = Home directories
1001 my $vars = $self->provision($path, "WORKGROUP",
1004 $fileserver_options,
1009 $vars or return undef;
1011 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
1016 mkdir($_, 0777) foreach(@dirs);
1018 ## Create case sensitive lower case share dir
1019 foreach my $file ('a'..'z') {
1020 my $full_path = $lower_case_share_dir . '/' . $file;
1021 open my $fh, '>', $full_path;
1022 # Add some content to file
1023 print $fh $full_path;
1027 for (my $file = 1; $file < 51; ++$file) {
1028 my $full_path = $lower_case_share_dir . '/' . $file;
1029 open my $fh, '>', $full_path;
1030 # Add some content to file
1031 print $fh $full_path;
1035 # Create content for 30000 share
1036 foreach my $file ('a'..'z') {
1037 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1038 open my $fh, '>', $full_path;
1039 # Add some content to file
1040 print $fh $full_path;
1044 for (my $file = 1; $file < 30001; ++$file) {
1045 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1046 open my $fh, '>', $full_path;
1047 # Add some content to file
1048 print $fh $full_path;
1053 ## create a listable file in valid_users_share
1055 my $valid_users_target = "$valid_users_sharedir/foo";
1056 unless (open(VALID_USERS_TARGET, ">$valid_users_target")) {
1057 warn("Unable to open $valid_users_target");
1060 close(VALID_USERS_TARGET);
1061 chmod 0644, $valid_users_target;
1068 my ($self, $prefix) = @_;
1070 # If we didn't build with ADS, pretend this env was never available
1071 if (not $self->have_ads()) {
1075 print "PROVISIONING server with security=ads...";
1077 my $ktest_options = "
1079 realm = ktest.samba.example.com
1081 username map = $prefix/lib/username.map
1082 server signing = required
1083 server min protocol = SMB3_00
1084 client max protocol = SMB3
1086 # This disables NTLM auth against the local SAM, which
1087 # we use can then test this setting by.
1088 ntlm auth = disabled
1091 my $ret = $self->provision($prefix, "KTEST",
1096 $ret or return undef;
1099 my $prefix_abs = abs_path($prefix);
1101 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1102 $ctx->{domain} = "KTEST";
1103 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
1104 $ctx->{dnsname} = lc($ctx->{realm});
1105 $ctx->{kdc_ipv4} = "0.0.0.0";
1106 $ctx->{kdc_ipv6} = "::";
1107 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1108 Samba::mk_krb5_conf($ctx, "");
1110 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1112 open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map");
1114 $ret->{USERNAME} = KTEST\\Administrator
1118 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
1119 #Samba4 DC with the same parameters as are being used here. The
1120 #domain SID is S-1-5-21-1071277805-689288055-3486227160
1121 $ret->{SAMSID} = "S-1-5-21-1911091480-1468226576-2729736297";
1122 $ret->{DOMSID} = "S-1-5-21-1071277805-689288055-3486227160";
1124 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
1125 chmod 0600, "$prefix/private/secrets.tdb";
1127 #Make sure there's no old ntdb file.
1128 system("rm -f $prefix/private/secrets.ntdb");
1130 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
1131 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
1133 #and having in krb5.conf:
1134 # ticket_lifetime = 799718400
1135 # renew_lifetime = 799718400
1137 # The commands for the -2 keytab where were:
1138 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
1139 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
1140 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
1141 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1142 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1144 # and then for the -3 keytab, I did
1146 # net changetrustpw; kdestroy and the same again.
1148 # This creates a credential cache with a very long lifetime (2036 at
1149 # at 2011-04), and shows that running 'net changetrustpw' does not
1150 # break existing logins (for the secrets.tdb method at least).
1153 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
1155 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
1156 chmod 0600, "$prefix/krb5_ccache-2";
1158 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
1159 chmod 0600, "$prefix/krb5_ccache-3";
1161 # We need world access to this share, as otherwise the domain
1162 # administrator from the AD domain provided by ktest can't
1163 # access the share for tests.
1164 chmod 0777, "$prefix/share";
1166 if (not $self->check_or_start($ret, "yes", "no", "yes")) {
1172 sub setup_maptoguest
1174 my ($self, $path) = @_;
1176 print "PROVISIONING maptoguest...";
1179 map to guest = bad user
1183 my $vars = $self->provision($path, "WORKGROUP",
1188 $vars or return undef;
1190 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
1197 sub stop_sig_term($$) {
1198 my ($self, $pid) = @_;
1199 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1202 sub stop_sig_kill($$) {
1203 my ($self, $pid) = @_;
1204 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1209 my ($env_vars, $app, $pid) = @_;
1211 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
1218 my ($env_vars, $app) = @_;
1220 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
1226 sub check_or_start($$$$$) {
1227 my ($self, $env_vars, $nmbd, $winbindd, $smbd) = @_;
1229 # use a pipe for stdin in the child processes. This allows
1230 # those processes to monitor the pipe for EOF to ensure they
1231 # exit when the test script exits
1232 pipe(STDIN_READER, $env_vars->{STDIN_PIPE});
1234 unlink($env_vars->{NMBD_TEST_LOG});
1235 print "STARTING NMBD...";
1238 open STDOUT, ">$env_vars->{NMBD_TEST_LOG}";
1239 open STDERR, '>&STDOUT';
1241 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1243 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1244 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.nmbd";
1245 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1246 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1248 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1249 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1250 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1251 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1252 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1253 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1254 $ENV{UID_WRAPPER_ROOT} = "1";
1256 $ENV{ENVNAME} = "$ENV{ENVNAME}.nmbd";
1258 if ($nmbd ne "yes") {
1259 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1260 my $signame = shift;
1261 print("Skip nmbd received signal $signame");
1264 sleep($self->{server_maxtime});
1268 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "nmbd");
1269 my @optargs = ("-d0");
1270 if (defined($ENV{NMBD_OPTIONS})) {
1271 @optargs = split(/ /, $ENV{NMBD_OPTIONS});
1273 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1274 if(defined($ENV{NMBD_VALGRIND})) {
1275 @preargs = split(/ /, $ENV{NMBD_VALGRIND});
1277 my @args = ("-F", "--no-process-group",
1278 "-s", $env_vars->{SERVERCONFFILE},
1279 "-l", $env_vars->{LOGDIR});
1280 if (not defined($ENV{NMBD_DONT_LOG_STDOUT})) {
1281 push(@args, "--log-stdout");
1284 close($env_vars->{STDIN_PIPE});
1285 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1287 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1288 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1290 $env_vars->{NMBD_TL_PID} = $pid;
1291 write_pid($env_vars, "nmbd", $pid);
1294 unlink($env_vars->{WINBINDD_TEST_LOG});
1295 print "STARTING WINBINDD...";
1298 open STDOUT, ">$env_vars->{WINBINDD_TEST_LOG}";
1299 open STDERR, '>&STDOUT';
1301 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1303 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1304 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.winbindd";
1305 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1306 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1308 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1309 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1310 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1311 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1312 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1313 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1314 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
1315 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
1317 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
1319 $ENV{UID_WRAPPER_ROOT} = "1";
1321 $ENV{ENVNAME} = "$ENV{ENVNAME}.winbindd";
1323 if ($winbindd ne "yes") {
1324 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1325 my $signame = shift;
1326 print("Skip winbindd received signal $signame");
1329 sleep($self->{server_maxtime});
1333 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "winbindd");
1334 my @optargs = ("-d0");
1335 if (defined($ENV{WINBINDD_OPTIONS})) {
1336 @optargs = split(/ /, $ENV{WINBINDD_OPTIONS});
1338 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1339 if(defined($ENV{WINBINDD_VALGRIND})) {
1340 @preargs = split(/ /, $ENV{WINBINDD_VALGRIND});
1342 my @args = ("-F", "--no-process-group",
1343 "-s", $env_vars->{SERVERCONFFILE},
1344 "-l", $env_vars->{LOGDIR});
1345 if (not defined($ENV{WINBINDD_DONT_LOG_STDOUT})) {
1346 push(@args, "--stdout");
1349 close($env_vars->{STDIN_PIPE});
1350 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1352 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1353 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1355 $env_vars->{WINBINDD_TL_PID} = $pid;
1356 write_pid($env_vars, "winbindd", $pid);
1359 unlink($env_vars->{SMBD_TEST_LOG});
1360 print "STARTING SMBD...";
1363 open STDOUT, ">$env_vars->{SMBD_TEST_LOG}";
1364 open STDERR, '>&STDOUT';
1366 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1368 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1369 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.smbd";
1370 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1371 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1373 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1374 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1375 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1376 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1377 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1378 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1379 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
1380 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
1382 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
1384 $ENV{UID_WRAPPER_ROOT} = "1";
1386 $ENV{ENVNAME} = "$ENV{ENVNAME}.smbd";
1388 if ($smbd ne "yes") {
1389 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1390 my $signame = shift;
1391 print("Skip smbd received signal $signame");
1394 sleep($self->{server_maxtime});
1398 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "smbd");
1399 my @optargs = ("-d0");
1400 if (defined($ENV{SMBD_OPTIONS})) {
1401 @optargs = split(/ /, $ENV{SMBD_OPTIONS});
1403 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1404 if(defined($ENV{SMBD_VALGRIND})) {
1405 @preargs = split(/ /,$ENV{SMBD_VALGRIND});
1407 my @args = ("-F", "--no-process-group",
1408 "-s", $env_vars->{SERVERCONFFILE},
1409 "-l", $env_vars->{LOGDIR});
1410 if (not defined($ENV{SMBD_DONT_LOG_STDOUT})) {
1411 push(@args, "--log-stdout");
1414 close($env_vars->{STDIN_PIPE});
1415 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1417 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1418 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1420 $env_vars->{SMBD_TL_PID} = $pid;
1421 write_pid($env_vars, "smbd", $pid);
1424 close(STDIN_READER);
1426 return $self->wait_for_start($env_vars, $nmbd, $winbindd, $smbd);
1429 sub createuser($$$$$)
1431 my ($self, $username, $password, $conffile, $env) = @_;
1432 my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $username > /dev/null";
1435 while(my($var, $val) = each %$env) {
1436 $cmd = "$var=\"$val\" $cmd";
1439 unless (open(PWD, "|$cmd")) {
1440 warn("Unable to set password for $username account\n$cmd");
1443 print PWD "$password\n$password\n";
1444 unless (close(PWD)) {
1445 warn("Unable to set password for $username account\n$cmd");
1450 sub provision($$$$$$$$$)
1452 my ($self, $prefix, $domain, $server, $password, $extra_options, $dc_server_ip, $dc_server_ipv6, $no_delete_prefix) = @_;
1455 ## setup the various environment variables we need
1458 my $samsid = Samba::random_domain_sid();
1459 my $swiface = Samba::get_interface($server);
1461 my %createuser_env = ();
1462 my $server_ip = "127.0.0.$swiface";
1463 my $server_ipv6 = sprintf("fd00:0000:0000:0000:0000:0000:5357:5f%02x", $swiface);
1465 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
1468 my $unix_gids_str = $);
1469 my @unix_gids = split(" ", $unix_gids_str);
1471 my $prefix_abs = abs_path($prefix);
1472 my $bindir_abs = abs_path($self->{bindir});
1476 my $shrdir="$prefix_abs/share";
1477 push(@dirs,$shrdir);
1479 my $libdir="$prefix_abs/lib";
1480 push(@dirs,$libdir);
1482 my $piddir="$prefix_abs/pid";
1483 push(@dirs,$piddir);
1485 my $privatedir="$prefix_abs/private";
1486 push(@dirs,$privatedir);
1488 my $binddnsdir = "$prefix_abs/bind-dns";
1489 push(@dirs, $binddnsdir);
1491 my $lockdir="$prefix_abs/lockdir";
1492 push(@dirs,$lockdir);
1494 my $eventlogdir="$prefix_abs/lockdir/eventlog";
1495 push(@dirs,$eventlogdir);
1497 my $logdir="$prefix_abs/logs";
1498 push(@dirs,$logdir);
1500 my $driver32dir="$shrdir/W32X86";
1501 push(@dirs,$driver32dir);
1503 my $driver64dir="$shrdir/x64";
1504 push(@dirs,$driver64dir);
1506 my $driver40dir="$shrdir/WIN40";
1507 push(@dirs,$driver40dir);
1509 my $ro_shrdir="$shrdir/root-tmp";
1510 push(@dirs,$ro_shrdir);
1512 my $msdfs_shrdir="$shrdir/msdfsshare";
1513 push(@dirs,$msdfs_shrdir);
1515 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
1516 push(@dirs,$msdfs_deeppath);
1518 my $badnames_shrdir="$shrdir/badnames";
1519 push(@dirs,$badnames_shrdir);
1521 my $lease1_shrdir="$shrdir/SMB2_10";
1522 push(@dirs,$lease1_shrdir);
1524 my $lease2_shrdir="$shrdir/SMB3_00";
1525 push(@dirs,$lease2_shrdir);
1527 my $manglenames_shrdir="$shrdir/manglenames";
1528 push(@dirs,$manglenames_shrdir);
1530 my $widelinks_shrdir="$shrdir/widelinks";
1531 push(@dirs,$widelinks_shrdir);
1533 my $widelinks_linkdir="$shrdir/widelinks_foo";
1534 push(@dirs,$widelinks_linkdir);
1536 my $shadow_tstdir="$shrdir/shadow";
1537 push(@dirs,$shadow_tstdir);
1538 my $shadow_mntdir="$shadow_tstdir/mount";
1539 push(@dirs,$shadow_mntdir);
1540 my $shadow_basedir="$shadow_mntdir/base";
1541 push(@dirs,$shadow_basedir);
1542 my $shadow_shrdir="$shadow_basedir/share";
1543 push(@dirs,$shadow_shrdir);
1545 my $nosymlinks_shrdir="$shrdir/nosymlinks";
1546 push(@dirs,$nosymlinks_shrdir);
1548 my $local_symlinks_shrdir="$shrdir/local_symlinks";
1549 push(@dirs,$local_symlinks_shrdir);
1551 # this gets autocreated by winbindd
1552 my $wbsockdir="$prefix_abs/winbindd";
1554 my $nmbdsockdir="$prefix_abs/nmbd";
1555 unlink($nmbdsockdir);
1558 ## create the test directory layout
1560 die ("prefix_abs = ''") if $prefix_abs eq "";
1561 die ("prefix_abs = '/'") if $prefix_abs eq "/";
1563 mkdir($prefix_abs, 0777);
1564 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
1565 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
1566 system("rm -rf $prefix_abs/*");
1568 mkdir($_, 0777) foreach(@dirs);
1570 my $fs_specific_conf = $self->get_fs_specific_conf($shrdir);
1573 ## lockdir and piddir must be 0755
1575 chmod 0755, $lockdir;
1576 chmod 0755, $piddir;
1580 ## create ro and msdfs share layout
1583 chmod 0755, $ro_shrdir;
1584 my $unreadable_file = "$ro_shrdir/unreadable_file";
1585 unless (open(UNREADABLE_FILE, ">$unreadable_file")) {
1586 warn("Unable to open $unreadable_file");
1589 close(UNREADABLE_FILE);
1590 chmod 0600, $unreadable_file;
1592 my $msdfs_target = "$ro_shrdir/msdfs-target";
1593 unless (open(MSDFS_TARGET, ">$msdfs_target")) {
1594 warn("Unable to open $msdfs_target");
1597 close(MSDFS_TARGET);
1598 chmod 0666, $msdfs_target;
1599 symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp",
1600 "$msdfs_shrdir/msdfs-src1";
1601 symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
1604 ## create bad names in $badnames_shrdir
1606 ## (An invalid name, would be mangled to 8.3).
1607 my $badname_target = "$badnames_shrdir/\340|\231\216\377\177";
1608 unless (open(BADNAME_TARGET, ">$badname_target")) {
1609 warn("Unable to open $badname_target");
1612 close(BADNAME_TARGET);
1613 chmod 0666, $badname_target;
1615 ## (A bad name, would not be mangled to 8.3).
1616 my $badname_target = "$badnames_shrdir/\240\276\346\327\377\177";
1617 unless (open(BADNAME_TARGET, ">$badname_target")) {
1618 warn("Unable to open $badname_target");
1621 close(BADNAME_TARGET);
1622 chmod 0666, $badname_target;
1624 ## (A bad good name).
1625 my $badname_target = "$badnames_shrdir/blank.txt";
1626 unless (open(BADNAME_TARGET, ">$badname_target")) {
1627 warn("Unable to open $badname_target");
1630 close(BADNAME_TARGET);
1631 chmod 0666, $badname_target;
1634 ## create mangleable directory names in $manglenames_shrdir
1636 my $manglename_target = "$manglenames_shrdir/foo:bar";
1637 mkdir($manglename_target, 0777);
1640 ## create symlinks for widelinks tests.
1642 my $widelinks_target = "$widelinks_linkdir/target";
1643 unless (open(WIDELINKS_TARGET, ">$widelinks_target")) {
1644 warn("Unable to open $widelinks_target");
1647 close(WIDELINKS_TARGET);
1648 chmod 0666, $widelinks_target;
1650 ## This link should get ACCESS_DENIED
1652 symlink "$widelinks_target", "$widelinks_shrdir/source";
1654 ## This link should be allowed
1656 symlink "$widelinks_shrdir", "$widelinks_shrdir/dot";
1658 my $conffile="$libdir/server.conf";
1659 my $dfqconffile="$libdir/dfq.conf";
1660 my $errorinjectconf="$libdir/error_inject.conf";
1661 my $delayinjectconf="$libdir/delay_inject.conf";
1663 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/third_party/nss_wrapper/nss_wrapper.pl";
1664 my $nss_wrapper_passwd = "$privatedir/passwd";
1665 my $nss_wrapper_group = "$privatedir/group";
1666 my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts";
1667 my $resolv_conf = "$privatedir/resolv.conf";
1668 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
1670 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
1672 my $fake_snap_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/fake_snap.pl";
1674 my @eventlog_list = ("dns server", "application");
1677 ## calculate uids and gids
1680 my ($max_uid, $max_gid);
1681 my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
1682 my ($uid_pdbtest_wkn);
1684 my ($uid_force_user);
1685 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
1686 my ($gid_userdup, $gid_everyone);
1687 my ($gid_force_user);
1692 my ($uid_slashuser);
1694 if ($unix_uid < 0xffff - 13) {
1697 $max_uid = $unix_uid;
1700 $uid_root = $max_uid - 1;
1701 $uid_nobody = $max_uid - 2;
1702 $uid_pdbtest = $max_uid - 3;
1703 $uid_pdbtest2 = $max_uid - 4;
1704 $uid_userdup = $max_uid - 5;
1705 $uid_pdbtest_wkn = $max_uid - 6;
1706 $uid_force_user = $max_uid - 7;
1707 $uid_smbget = $max_uid - 8;
1708 $uid_user1 = $max_uid - 9;
1709 $uid_user2 = $max_uid - 10;
1710 $uid_gooduser = $max_uid - 11;
1711 $uid_eviluser = $max_uid - 12;
1712 $uid_slashuser = $max_uid - 13;
1714 if ($unix_gids[0] < 0xffff - 8) {
1717 $max_gid = $unix_gids[0];
1720 $gid_nobody = $max_gid - 1;
1721 $gid_nogroup = $max_gid - 2;
1722 $gid_root = $max_gid - 3;
1723 $gid_domusers = $max_gid - 4;
1724 $gid_domadmins = $max_gid - 5;
1725 $gid_userdup = $max_gid - 6;
1726 $gid_everyone = $max_gid - 7;
1727 $gid_force_user = $max_gid - 8;
1733 unless (open(CONF, ">$conffile")) {
1734 warn("Unable to open $conffile");
1739 netbios name = $server
1740 interfaces = $server_ip/8 $server_ipv6/64
1741 bind interfaces only = yes
1742 panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
1743 smbd:suicide mode = yes
1747 private dir = $privatedir
1748 binddns dir = $binddnsdir
1749 pid directory = $piddir
1750 lock directory = $lockdir
1751 log file = $logdir/log.\%m
1756 state directory = $lockdir
1757 cache directory = $lockdir
1759 passdb backend = tdbsam
1763 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1764 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
1765 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1766 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
1767 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
1768 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
1769 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
1771 addprinter command = $mod_printer_pl -a -s $conffile --
1772 deleteprinter command = $mod_printer_pl -d -s $conffile --
1774 eventlog list = application \"dns server\"
1777 kernel change notify = no
1781 printcap name = /dev/null
1783 winbindd socket directory = $wbsockdir
1784 nmbd:socket dir = $nmbdsockdir
1785 idmap config * : range = 100000-200000
1786 winbind enum users = yes
1787 winbind enum groups = yes
1788 winbind separator = /
1789 include system krb5 conf = no
1791 # min receivefile size = 4000
1795 smbd:sharedelay = 100000
1796 smbd:writetimeupdatedelay = 500000
1800 store dos attributes = yes
1805 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot time_audit full_audit
1807 full_audit:syslog = no
1808 full_audit:success = none
1809 full_audit:failure = none
1812 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
1813 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
1814 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
1815 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
1816 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
1817 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
1818 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
1820 print notify backchannel = yes
1822 ncalrpc dir = $prefix_abs/ncalrpc
1824 # The samba3.blackbox.smbclient_s3 test uses this to test that
1825 # sending messages works, and that the %m sub works.
1826 message command = mv %s $shrdir/message.%m
1828 # fsrvp server requires registry shares
1829 registry shares = yes
1831 # Used by RPC SRVSVC tests
1832 add share command = $bindir_abs/smbaddshare
1833 change share command = $bindir_abs/smbchangeshare
1834 delete share command = $bindir_abs/smbdeleteshare
1836 # fruit:copyfile is a global option
1837 fruit:copyfile = yes
1839 #this does not mean that we use non-secure test env,
1840 #it just means we ALLOW one to be configured.
1841 allow insecure wide links = yes
1843 # Begin extra options
1847 #Include user defined custom parameters if set
1850 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
1851 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
1857 comment = smb username is [%U]
1860 comment = Load dirsort module
1861 vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot
1864 comment = encrypt smb username is [%U]
1865 smb encrypt = required
1866 vfs objects = dirsort
1876 force user = $unix_name
1878 [forceuser_unixonly]
1879 comment = force a user with unix user SID and group SID
1881 force user = pdbtest
1883 [forceuser_wkngroup]
1884 comment = force a user with well-known group SID
1886 force user = pdbtest_wkn
1890 force group = nogroup
1898 write list = $unix_name
1901 valid users = $unix_name
1902 access based share enum = yes
1904 path = $msdfs_shrdir
1906 msdfs shuffle referrals = yes
1910 hide unreadable = yes
1913 case sensitive = yes
1916 hide unwriteable files = yes
1919 kernel share modes = no
1933 default devmode = no
1939 comment = smb username is [%U]
1941 nfs4acl_xattr:version = 40
1942 vfs objects = nfs4acl_xattr xattr_tdb
1944 [nfs4acl_special_40]
1946 comment = smb username is [%U]
1948 nfs4acl_xattr:version = 40
1949 vfs objects = nfs4acl_xattr xattr_tdb
1953 comment = smb username is [%U]
1955 vfs objects = nfs4acl_xattr xattr_tdb
1959 comment = smb username is [%U]
1960 vfs objects = nfs4acl_xattr xattr_tdb
1962 nfs4acl_xattr:encoding = xdr
1963 nfs4acl_xattr:version = 40
1967 comment = smb username is [%U]
1968 vfs objects = nfs4acl_xattr xattr_tdb
1970 nfs4acl_xattr:encoding = xdr
1971 nfs4acl_xattr:version = 41
1975 comment = smb username is [%U]
1977 force create mode = 777
1980 comment = smb username is [%U]
1982 force create mode = 0
1983 directory mask = 0777
1984 force directory mode = 0
1985 vfs objects = xattr_tdb streams_depot
1996 vfs objects = catia fruit streams_xattr acl_xattr xattr_tdb
1997 fruit:resource = file
1998 fruit:metadata = netatalk
1999 fruit:locking = netatalk
2000 fruit:encoding = native
2001 fruit:veto_appledouble = no
2005 # This is used by vfs.fruit tests that require real fs xattr
2006 vfs objects = catia fruit streams_xattr acl_xattr
2007 fruit:resource = file
2008 fruit:metadata = netatalk
2009 fruit:locking = netatalk
2010 fruit:encoding = native
2011 fruit:veto_appledouble = no
2013 [vfs_fruit_metadata_stream]
2015 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2016 fruit:resource = file
2017 fruit:metadata = stream
2018 fruit:veto_appledouble = no
2020 [vfs_fruit_stream_depot]
2022 vfs objects = fruit streams_depot acl_xattr xattr_tdb
2023 fruit:resource = stream
2024 fruit:metadata = stream
2025 fruit:veto_appledouble = no
2029 vfs objects = streams_xattr acl_xattr xattr_tdb
2031 [vfs_wo_fruit_stream_depot]
2033 vfs objects = streams_depot acl_xattr xattr_tdb
2035 [vfs_fruit_timemachine]
2037 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2038 fruit:resource = file
2039 fruit:metadata = stream
2040 fruit:time machine = yes
2041 fruit:time machine max size = 32K
2043 [vfs_fruit_wipe_intentionally_left_blank_rfork]
2045 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2046 fruit:resource = file
2047 fruit:metadata = stream
2048 fruit:wipe_intentionally_left_blank_rfork = true
2049 fruit:delete_empty_adfiles = false
2050 fruit:veto_appledouble = no
2052 [vfs_fruit_delete_empty_adfiles]
2054 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2055 fruit:resource = file
2056 fruit:metadata = stream
2057 fruit:wipe_intentionally_left_blank_rfork = true
2058 fruit:delete_empty_adfiles = true
2059 fruit:veto_appledouble = no
2062 path = $badnames_shrdir
2066 path = $manglenames_shrdir
2074 path = $widelinks_shrdir
2080 comment = fake shapshots using rsync
2081 vfs objects = shell_snap shadow_copy2
2082 shell_snap:check path command = $fake_snap_pl --check
2083 shell_snap:create command = $fake_snap_pl --create
2084 shell_snap:delete command = $fake_snap_pl --delete
2085 # a relative path here fails, the snapshot dir is no longer found
2086 shadow:snapdir = $shrdir/.snapshots
2089 path = $shadow_shrdir
2090 comment = previous versions snapshots under mount point
2091 vfs objects = shadow_copy2
2092 shadow:mountpoint = $shadow_mntdir
2095 path = $shadow_shrdir
2096 comment = previous versions snapshots outside mount point
2097 vfs objects = shadow_copy2
2098 shadow:mountpoint = $shadow_mntdir
2099 shadow:snapdir = $shadow_tstdir/.snapshots
2102 path = $shadow_shrdir
2103 comment = previous versions with subvolume snapshots, snapshots under base dir
2104 vfs objects = shadow_copy2
2105 shadow:mountpoint = $shadow_mntdir
2106 shadow:basedir = $shadow_basedir
2107 shadow:snapdir = $shadow_basedir/.snapshots
2110 path = $shadow_shrdir
2111 comment = previous versions with subvolume snapshots, snapshots outside mount point
2112 vfs objects = shadow_copy2
2113 shadow:mountpoint = $shadow_mntdir
2114 shadow:basedir = $shadow_basedir
2115 shadow:snapdir = $shadow_tstdir/.snapshots
2118 path = $shadow_shrdir
2119 comment = previous versions at volume root snapshots under mount point
2120 vfs objects = shadow_copy2
2121 shadow:mountpoint = $shadow_shrdir
2124 path = $shadow_shrdir
2125 comment = previous versions at volume root snapshots outside mount point
2126 vfs objects = shadow_copy2
2127 shadow:mountpoint = $shadow_shrdir
2128 shadow:snapdir = $shadow_tstdir/.snapshots
2131 path = $shadow_shrdir
2132 comment = previous versions snapshots everywhere
2133 vfs objects = shadow_copy2
2134 shadow:mountpoint = $shadow_mntdir
2135 shadow:snapdirseverywhere = yes
2138 path = $shadow_shrdir
2139 comment = previous versions using snapsharepath
2140 vfs objects = shadow_copy2
2141 shadow:mountpoint = $shadow_mntdir
2142 shadow:snapdir = $shadow_tstdir/.snapshots
2143 shadow:snapsharepath = share
2146 comment = Testing shadow:format with default option
2147 vfs object = shadow_copy2
2148 path = $shadow_shrdir
2151 shadow:mountpoint = $shadow_mntdir
2152 shadow:basedir = $shadow_basedir
2153 shadow:snapdir = $shadow_basedir/.snapshots
2154 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2157 comment = Testing shadow:format with only date component
2158 vfs object = shadow_copy2
2159 path = $shadow_shrdir
2162 shadow:mountpoint = $shadow_mntdir
2163 shadow:basedir = $shadow_basedir
2164 shadow:snapdir = $shadow_basedir/.snapshots
2165 shadow:format = \@GMT-%Y-%m-%d
2168 comment = Testing shadow:format with some hardcoded prefix
2169 vfs object = shadow_copy2
2170 path = $shadow_shrdir
2173 shadow:mountpoint = $shadow_mntdir
2174 shadow:basedir = $shadow_basedir
2175 shadow:snapdir = $shadow_basedir/.snapshots
2176 shadow:format = snap\@GMT-%Y.%m.%d-%H.%M.%S
2179 comment = Testing shadow:format with modified format
2180 vfs object = shadow_copy2
2181 path = $shadow_shrdir
2184 shadow:mountpoint = $shadow_mntdir
2185 shadow:basedir = $shadow_basedir
2186 shadow:snapdir = $shadow_basedir/.snapshots
2187 shadow:format = \@GMT-%Y.%m.%d-%H_%M_%S-snap
2190 comment = Testing shadow:snapprefix regex
2191 vfs object = shadow_copy2
2192 path = $shadow_shrdir
2195 shadow:mountpoint = $shadow_mntdir
2196 shadow:basedir = $shadow_basedir
2197 shadow:snapdir = $shadow_basedir/.snapshots
2198 shadow:snapprefix = \^s[a-z]*p\$
2199 shadow:format = _GMT-%Y.%m.%d-%H.%M.%S
2202 comment = Testing shadow:snapprefix with delim regex
2203 vfs object = shadow_copy2
2204 path = $shadow_shrdir
2207 shadow:mountpoint = $shadow_mntdir
2208 shadow:basedir = $shadow_basedir
2209 shadow:snapdir = $shadow_basedir/.snapshots
2210 shadow:delimiter = \@GMT
2211 shadow:snapprefix = [a-z]*
2212 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2215 path = $shadow_shrdir
2216 comment = previous versions with wide links allowed
2217 vfs objects = shadow_copy2
2218 shadow:mountpoint = $shadow_mntdir
2222 path = $shadow_tstdir
2223 comment = previous versions snapshots under mount point
2224 vfs objects = shadow_copy2 streams_xattr error_inject
2226 error_inject:pwrite = EBADF
2227 shadow:mountpoint = $shadow_tstdir
2230 path = $shrdir/dfree
2231 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2232 admin users = $unix_name
2233 include = $dfqconffile
2235 path = $shrdir/dfree
2236 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2237 admin users = $unix_name
2238 include = $dfqconffile
2239 dfree cache time = 60
2241 path = $shrdir/dfree
2242 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2244 include = $dfqconffile
2246 path = $shrdir/quota
2247 admin users = $unix_name
2249 [acl_xattr_ign_sysacl_posix]
2251 acl_xattr:ignore system acls = yes
2252 acl_xattr:default acl style = posix
2253 [acl_xattr_ign_sysacl_windows]
2255 acl_xattr:ignore system acls = yes
2256 acl_xattr:default acl style = windows
2260 mangled names = illegal
2264 path = $nosymlinks_shrdir
2265 follow symlinks = no
2269 path = $local_symlinks_shrdir
2270 follow symlinks = yes
2274 kernel oplocks = yes
2275 vfs objects = streams_xattr xattr_tdb
2279 vfs objects = streams_xattr xattr_tdb
2283 smbd:find async delay usec = 10000
2286 vfs objects = error_inject
2287 include = $errorinjectconf
2291 vfs objects = delay_inject
2292 kernel share modes = no
2295 include = $delayinjectconf
2299 vfs objects = delay_inject
2300 delay_inject:pread_send = 2000
2301 delay_inject:pwrite_send = 2000
2304 path = $prefix_abs/share
2305 delete readonly = yes
2309 my $net = Samba::bindir_path($self, "net");
2311 $cmd .= "SMB_CONF_PATH=\"$conffile\" ";
2312 $cmd .= "$net setlocalsid $samsid";
2314 if (system($cmd) != 0) {
2315 warn("Join failed\n$cmd");
2319 unless (open(ERRORCONF, ">$errorinjectconf")) {
2320 warn("Unable to open $errorinjectconf");
2325 unless (open(DELAYCONF, ">$delayinjectconf")) {
2326 warn("Unable to open $delayinjectconf");
2331 unless (open(DFQCONF, ">$dfqconffile")) {
2332 warn("Unable to open $dfqconffile");
2338 ## create a test account
2341 unless (open(PASSWD, ">$nss_wrapper_passwd")) {
2342 warn("Unable to open $nss_wrapper_passwd");
2345 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
2346 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
2347 pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2348 pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2349 userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
2350 pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false
2351 force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false
2352 smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false
2353 user1:x:$uid_user1:$gid_nogroup:user1 gecos:$prefix_abs:/bin/false
2354 user2:x:$uid_user2:$gid_nogroup:user2 gecos:$prefix_abs:/bin/false
2355 gooduser:x:$uid_gooduser:$gid_domusers:gooduser gecos:$prefix_abs:/bin/false
2356 eviluser:x:$uid_eviluser:$gid_domusers:eviluser gecos::/bin/false
2357 slashuser:x:$uid_slashuser:$gid_domusers:slashuser gecos:/:/bin/false
2359 if ($unix_uid != 0) {
2360 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
2365 unless (open(GROUP, ">$nss_wrapper_group")) {
2366 warn("Unable to open $nss_wrapper_group");
2369 print GROUP "nobody:x:$gid_nobody:
2370 nogroup:x:$gid_nogroup:nobody
2371 $unix_name-group:x:$unix_gids[0]:
2372 domusers:X:$gid_domusers:
2373 domadmins:X:$gid_domadmins:
2374 userdup:x:$gid_userdup:$unix_name
2375 everyone:x:$gid_everyone:
2376 force_user:x:$gid_force_user:
2378 if ($unix_gids[0] != 0) {
2379 print GROUP "root:x:$gid_root:
2386 my $hostname = lc($server);
2387 unless (open(HOSTS, ">>$nss_wrapper_hosts")) {
2388 warn("Unable to open $nss_wrapper_hosts");
2391 print HOSTS "${server_ip} ${hostname}.samba.example.com ${hostname}\n";
2392 print HOSTS "${server_ipv6} ${hostname}.samba.example.com ${hostname}\n";
2396 unless (open(RESOLV_CONF, ">$resolv_conf")) {
2397 warn("Unable to open $resolv_conf");
2400 if (defined($dc_server_ip) or defined($dc_server_ipv6)) {
2401 if (defined($dc_server_ip)) {
2402 print RESOLV_CONF "nameserver $dc_server_ip\n";
2404 if (defined($dc_server_ipv6)) {
2405 print RESOLV_CONF "nameserver $dc_server_ipv6\n";
2408 print RESOLV_CONF "nameserver ${server_ip}\n";
2409 print RESOLV_CONF "nameserver ${server_ipv6}\n";
2413 foreach my $evlog (@eventlog_list) {
2414 my $evlogtdb = "$eventlogdir/$evlog.tdb";
2415 open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
2419 $createuser_env{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2420 $createuser_env{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2421 $createuser_env{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2422 $createuser_env{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2423 if ($ENV{SAMBA_DNS_FAKING}) {
2424 $createuser_env{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2426 $createuser_env{RESOLV_WRAPPER_CONF} = $resolv_conf;
2429 createuser($self, $unix_name, $password, $conffile, \%createuser_env) || die("Unable to create user");
2430 createuser($self, "force_user", $password, $conffile, \%createuser_env) || die("Unable to create force_user");
2431 createuser($self, "smbget_user", $password, $conffile, \%createuser_env) || die("Unable to create smbget_user");
2432 createuser($self, "user1", $password, $conffile, \%createuser_env) || die("Unable to create user1");
2433 createuser($self, "user2", $password, $conffile, \%createuser_env) || die("Unable to create user2");
2434 createuser($self, "gooduser", $password, $conffile, \%createuser_env) || die("Unable to create gooduser");
2435 createuser($self, "eviluser", $password, $conffile, \%createuser_env) || die("Unable to create eviluser");
2436 createuser($self, "slashuser", $password, $conffile, \%createuser_env) || die("Unable to create slashuser");
2438 open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
2439 print DNS_UPDATE_LIST "A $server. $server_ip\n";
2440 print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n";
2441 close(DNS_UPDATE_LIST);
2445 $ret{SERVER_IP} = $server_ip;
2446 $ret{SERVER_IPV6} = $server_ipv6;
2447 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
2448 $ret{NMBD_TEST_LOG_POS} = 0;
2449 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
2450 $ret{WINBINDD_TEST_LOG_POS} = 0;
2451 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
2452 $ret{SMBD_TEST_LOG_POS} = 0;
2453 $ret{SERVERCONFFILE} = $conffile;
2454 $ret{CONFIGURATION} ="-s $conffile";
2455 $ret{LOCK_DIR} = $lockdir;
2456 $ret{SERVER} = $server;
2457 $ret{USERNAME} = $unix_name;
2458 $ret{USERID} = $unix_uid;
2459 $ret{DOMAIN} = $domain;
2460 $ret{SAMSID} = $samsid;
2461 $ret{NETBIOSNAME} = $server;
2462 $ret{PASSWORD} = $password;
2463 $ret{PIDDIR} = $piddir;
2464 $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir;
2465 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
2466 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
2467 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2468 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2469 $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2470 $ret{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2471 $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
2472 $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind";
2473 if ($ENV{SAMBA_DNS_FAKING}) {
2474 $ret{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2476 $ret{RESOLV_WRAPPER_CONF} = $resolv_conf;
2478 $ret{LOCAL_PATH} = "$shrdir";
2479 $ret{LOGDIR} = $logdir;
2482 # Avoid hitting system krb5.conf -
2483 # An env that needs Kerberos will reset this to the real
2486 $ret{KRB5_CONFIG} = abs_path($prefix) . "/no_krb5.conf";
2488 # Define KRB5CCNAME for each environment we set up
2489 $ret{KRB5_CCACHE} = abs_path($prefix) . "/krb5ccache";
2490 $ENV{KRB5CCNAME} = $ret{KRB5_CCACHE};
2495 sub wait_for_start($$$$$)
2497 my ($self, $envvars, $nmbd, $winbindd, $smbd) = @_;
2502 if ($nmbd eq "yes") {
2505 # give time for nbt server to register its names
2506 print "checking for nmbd\n";
2508 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
2509 my $nmblookup = Samba::bindir_path($self, "nmblookup");
2512 $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
2516 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
2517 system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
2518 system("$nmblookup $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
2519 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
2522 } while ($ret != 0 && $count < 10);
2524 print "NMBD not reachable after 10 retries\n";
2525 teardown_env($self, $envvars);
2530 if ($winbindd eq "yes") {
2531 print "checking for winbindd\n";
2533 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2534 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2535 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2536 $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping-dc";
2540 $ret = system($cmd);
2544 } while ($ret != 0 && $count < 20);
2546 print "WINBINDD not reachable after 20 seconds\n";
2547 teardown_env($self, $envvars);
2552 if ($smbd eq "yes") {
2553 # make sure smbd is also up set
2554 print "wait for smbd\n";
2558 $ret = system(Samba::bindir_path($self, "smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139");
2563 } while ($ret != 0 && $count < 20);
2565 print "SMBD failed to start up in a reasonable time (20sec)\n";
2566 teardown_env($self, $envvars);
2571 # Ensure we have domain users mapped.
2572 $netcmd = "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2573 $netcmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2574 $netcmd .= Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} ";
2576 $cmd = $netcmd . "groupmap delete ntgroup=domusers";
2577 $ret = system($cmd);
2579 $cmd = $netcmd . "groupmap add rid=513 unixgroup=domusers type=domain";
2580 $ret = system($cmd);
2582 print("\"$cmd\" failed\n");
2586 $cmd = $netcmd . "groupmap delete ntgroup=domadmins";
2587 $ret = system($cmd);
2589 $cmd = $netcmd . "groupmap add rid=512 unixgroup=domadmins type=domain";
2590 $ret = system($cmd);
2592 print("\"$cmd\" failed\n");
2596 $cmd = $netcmd . "groupmap delete ntgroup=everyone";
2597 $ret = system($cmd);
2599 $cmd = $netcmd . "groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin";
2600 $ret = system($cmd);
2602 print("\"$cmd\" failed\n");
2606 # note: creating builtin groups requires winbindd for the
2608 my $create_builtin_users = "no";
2609 if ($winbindd eq "yes") {
2610 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2611 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2612 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2613 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
2614 my $wbinfo_out = qx($cmd 2>&1);
2616 # wbinfo doesn't give us a better error code then
2617 # WBC_ERR_DOMAIN_NOT_FOUND, but at least that's
2618 # different then WBC_ERR_WINBIND_NOT_AVAILABLE
2619 if ($wbinfo_out !~ /WBC_ERR_DOMAIN_NOT_FOUND/) {
2620 print("Failed to run \"wbinfo --sid-to-gid=S-1-5-32-545\": $wbinfo_out");
2621 teardown_env($self, $envvars);
2624 $create_builtin_users = "yes";
2627 if ($create_builtin_users eq "yes") {
2628 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2629 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2630 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2631 $cmd .= Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
2632 $cmd .= "sam createbuiltingroup Users";
2633 $ret = system($cmd);
2635 print "Failed to create BUILTIN\\Users group\n";
2636 teardown_env($self, $envvars);
2640 $cmd = Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
2641 $cmd .= "cache del IDMAP/SID2XID/S-1-5-32-545";
2644 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2645 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2646 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2647 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
2648 $ret = system($cmd);
2650 print "Missing \"BUILTIN\\Users\", did net sam createbuiltingroup Users fail?\n";
2651 teardown_env($self, $envvars);
2656 print $self->getlog_env($envvars);