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 server max protocol = SMB3_02
305 dbwrap_tdb_mutexes:* = yes
308 my $ret = $self->provision($prefix, $nt4_dc_vars->{DOMAIN},
310 "localnt4member3pass",
313 $ret or return undef;
315 my $nmblookup = Samba::bindir_path($self, "nmblookup");
317 print "Waiting for the LOGON SERVER registration ...\n";
318 $rc = system("$nmblookup $ret->{CONFIGURATION} $ret->{DOMAIN}\#1c");
323 } while ($rc != 0 && $count < 10);
325 print "NMBD not reachable after 10 retries\n";
326 teardown_env($self, $ret);
330 my $net = Samba::bindir_path($self, "net");
331 # Add hosts file for name lookups
332 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
333 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
334 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
335 $cmd .= "$net rpc join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
336 $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}";
338 if (system($cmd) != 0) {
339 warn("Join failed\n$cmd");
343 # Add hosts file for name lookups
344 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
345 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
346 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
347 $cmd .= "$net $ret->{CONFIGURATION} primarytrust dumpinfo | grep -q 'REDACTED SECRET VALUES'";
349 if (system($cmd) != 0) {
350 warn("check failed\n$cmd");
354 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
358 $ret->{DOMSID} = $nt4_dc_vars->{DOMSID};
359 $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
360 $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
361 $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
362 $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME};
363 $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME};
364 $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD};
371 my ($self, $prefix, $dcvars) = @_;
373 my $prefix_abs = abs_path($prefix);
376 # If we didn't build with ADS, pretend this env was never available
377 if (not $self->have_ads()) {
381 print "PROVISIONING S3 AD MEMBER...";
383 mkdir($prefix_abs, 0777);
385 my $share_dir="$prefix_abs/share";
386 push(@dirs, $share_dir);
388 my $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}";
389 push(@dirs, $substitution_path);
391 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice";
392 push(@dirs, $substitution_path);
394 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice/G_domain users";
395 push(@dirs, $substitution_path);
397 # Using '/' as the winbind separator is a bad idea ...
398 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}";
399 push(@dirs, $substitution_path);
401 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice";
402 push(@dirs, $substitution_path);
404 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}";
405 push(@dirs, $substitution_path);
407 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}/domain users";
408 push(@dirs, $substitution_path);
410 my $member_options = "
412 workgroup = $dcvars->{DOMAIN}
413 realm = $dcvars->{REALM}
414 netbios aliases = foo bar
415 template homedir = /home/%D/%G/%U
418 path = $share_dir/D_%D/U_%U/G_%G
422 path = $share_dir/D_%D/u_%u/g_%g
427 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
431 $dcvars->{SERVER_IP},
432 $dcvars->{SERVER_IPV6});
434 $ret or return undef;
436 mkdir($_, 0777) foreach(@dirs);
439 $ret->{DOMAIN} = $dcvars->{DOMAIN};
440 $ret->{REALM} = $dcvars->{REALM};
441 $ret->{DOMSID} = $dcvars->{DOMSID};
445 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
446 $ctx->{domain} = $dcvars->{DOMAIN};
447 $ctx->{realm} = $dcvars->{REALM};
448 $ctx->{dnsname} = lc($dcvars->{REALM});
449 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
450 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
451 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
452 Samba::mk_krb5_conf($ctx, "");
454 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
455 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
457 my $net = Samba::bindir_path($self, "net");
458 # Add hosts file for name lookups
459 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
460 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
461 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
462 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
464 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
466 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
467 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
468 $cmd .= "$net join $ret->{CONFIGURATION}";
469 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
471 if (system($cmd) != 0) {
472 warn("Join failed\n$cmd");
476 # We need world access to this share, as otherwise the domain
477 # administrator from the AD domain provided by Samba4 can't
478 # access the share for tests.
479 chmod 0777, "$prefix/share";
481 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
485 $ret->{DC_SERVER} = $dcvars->{SERVER};
486 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
487 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
488 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
489 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
490 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
495 sub setup_ad_member_rfc2307
497 my ($self, $prefix, $dcvars) = @_;
499 # If we didn't build with ADS, pretend this env was never available
500 if (not $self->have_ads()) {
504 print "PROVISIONING S3 AD MEMBER WITH idmap_rfc2307 config...";
506 my $member_options = "
508 workgroup = $dcvars->{DOMAIN}
509 realm = $dcvars->{REALM}
511 idmap negative cache time = 0
512 idmap config * : backend = autorid
513 idmap config * : range = 1000000-1999999
514 idmap config * : rangesize = 100000
515 idmap config $dcvars->{DOMAIN} : backend = rfc2307
516 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
517 idmap config $dcvars->{DOMAIN} : ldap_server = ad
518 idmap config $dcvars->{DOMAIN} : bind_path_user = ou=idmap,dc=samba,dc=example,dc=com
519 idmap config $dcvars->{DOMAIN} : bind_path_group = ou=idmap,dc=samba,dc=example,dc=com
521 password server = $dcvars->{SERVER}
524 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
528 $dcvars->{SERVER_IP},
529 $dcvars->{SERVER_IPV6});
531 $ret or return undef;
534 $ret->{DOMAIN} = $dcvars->{DOMAIN};
535 $ret->{REALM} = $dcvars->{REALM};
536 $ret->{DOMSID} = $dcvars->{DOMSID};
539 my $prefix_abs = abs_path($prefix);
541 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
542 $ctx->{domain} = $dcvars->{DOMAIN};
543 $ctx->{realm} = $dcvars->{REALM};
544 $ctx->{dnsname} = lc($dcvars->{REALM});
545 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
546 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
547 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
548 Samba::mk_krb5_conf($ctx, "");
550 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
551 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
553 my $net = Samba::bindir_path($self, "net");
554 # Add hosts file for name lookups
555 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
556 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
557 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
558 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
560 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
562 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
563 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
564 $cmd .= "$net join $ret->{CONFIGURATION}";
565 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
567 if (system($cmd) != 0) {
568 warn("Join failed\n$cmd");
572 # We need world access to this share, as otherwise the domain
573 # administrator from the AD domain provided by Samba4 can't
574 # access the share for tests.
575 chmod 0777, "$prefix/share";
577 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
581 $ret->{DC_SERVER} = $dcvars->{SERVER};
582 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
583 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
584 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
585 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
586 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
591 sub setup_ad_member_idmap_rid
593 my ($self, $prefix, $dcvars) = @_;
595 # If we didn't build with ADS, pretend this env was never available
596 if (not $self->have_ads()) {
600 print "PROVISIONING S3 AD MEMBER WITH idmap_rid config...";
602 my $member_options = "
604 workgroup = $dcvars->{DOMAIN}
605 realm = $dcvars->{REALM}
606 idmap config * : backend = tdb
607 idmap config * : range = 1000000-1999999
608 idmap config $dcvars->{DOMAIN} : backend = rid
609 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
610 # Prevent overridding the provisioned lib/krb5.conf which sets certain
611 # values required for tests to succeed
612 create krb5 conf = no
615 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
619 $dcvars->{SERVER_IP},
620 $dcvars->{SERVER_IPV6});
622 $ret or return undef;
625 $ret->{DOMAIN} = $dcvars->{DOMAIN};
626 $ret->{REALM} = $dcvars->{REALM};
627 $ret->{DOMSID} = $dcvars->{DOMSID};
630 my $prefix_abs = abs_path($prefix);
632 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
633 $ctx->{domain} = $dcvars->{DOMAIN};
634 $ctx->{realm} = $dcvars->{REALM};
635 $ctx->{dnsname} = lc($dcvars->{REALM});
636 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
637 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
638 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
639 Samba::mk_krb5_conf($ctx, "");
641 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
642 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
644 my $net = Samba::bindir_path($self, "net");
645 # Add hosts file for name lookups
646 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
647 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
648 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
649 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
651 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
653 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
654 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
655 $cmd .= "$net join $ret->{CONFIGURATION}";
656 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
658 if (system($cmd) != 0) {
659 warn("Join failed\n$cmd");
663 # We need world access to this share, as otherwise the domain
664 # administrator from the AD domain provided by Samba4 can't
665 # access the share for tests.
666 chmod 0777, "$prefix/share";
668 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
672 $ret->{DC_SERVER} = $dcvars->{SERVER};
673 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
674 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
675 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
676 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
677 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
682 sub setup_ad_member_idmap_ad
684 my ($self, $prefix, $dcvars) = @_;
686 # If we didn't build with ADS, pretend this env was never available
687 if (not $self->have_ads()) {
691 print "PROVISIONING S3 AD MEMBER WITH idmap_ad config...";
693 my $member_options = "
695 workgroup = $dcvars->{DOMAIN}
696 realm = $dcvars->{REALM}
697 password server = $dcvars->{SERVER}
698 idmap config * : backend = tdb
699 idmap config * : range = 1000000-1999999
700 idmap config $dcvars->{DOMAIN} : backend = ad
701 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
704 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
708 $dcvars->{SERVER_IP},
709 $dcvars->{SERVER_IPV6});
711 $ret or return undef;
714 $ret->{DOMAIN} = $dcvars->{DOMAIN};
715 $ret->{REALM} = $dcvars->{REALM};
716 $ret->{DOMSID} = $dcvars->{DOMSID};
719 my $prefix_abs = abs_path($prefix);
721 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
722 $ctx->{domain} = $dcvars->{DOMAIN};
723 $ctx->{realm} = $dcvars->{REALM};
724 $ctx->{dnsname} = lc($dcvars->{REALM});
725 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
726 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
727 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
728 Samba::mk_krb5_conf($ctx, "");
730 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
731 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
733 my $net = Samba::bindir_path($self, "net");
734 # Add hosts file for name lookups
735 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
736 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
737 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
738 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
740 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
742 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
743 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
744 $cmd .= "$net join $ret->{CONFIGURATION}";
745 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
747 if (system($cmd) != 0) {
748 warn("Join failed\n$cmd");
752 # We need world access to this share, as otherwise the domain
753 # administrator from the AD domain provided by Samba4 can't
754 # access the share for tests.
755 chmod 0777, "$prefix/share";
757 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
761 $ret->{DC_SERVER} = $dcvars->{SERVER};
762 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
763 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
764 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
765 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
766 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
771 sub setup_simpleserver
773 my ($self, $path) = @_;
775 print "PROVISIONING simple server...";
777 my $prefix_abs = abs_path($path);
779 my $simpleserver_options = "
782 vfs objects = xattr_tdb streams_depot
787 path = $prefix_abs/share
789 vfs objects = aio_pthread
790 aio_pthread:aio open = yes
791 smbd:async dosmode = no
793 [vfs_aio_pthread_async_dosmode_default1]
794 path = $prefix_abs/share
796 vfs objects = aio_pthread
797 store dos attributes = yes
798 aio_pthread:aio open = yes
799 smbd:async dosmode = yes
801 [vfs_aio_pthread_async_dosmode_default2]
802 path = $prefix_abs/share
804 vfs objects = aio_pthread xattr_tdb
805 store dos attributes = yes
806 aio_pthread:aio open = yes
807 smbd:async dosmode = yes
809 [vfs_aio_pthread_async_dosmode_force_sync1]
810 path = $prefix_abs/share
812 vfs objects = aio_pthread
813 store dos attributes = yes
814 aio_pthread:aio open = yes
815 smbd:async dosmode = yes
816 # This simulates non linux systems
817 smbd:force sync user path safe threadpool = yes
818 smbd:force sync user chdir safe threadpool = yes
819 smbd:force sync root path safe threadpool = yes
820 smbd:force sync root chdir safe threadpool = yes
822 [vfs_aio_pthread_async_dosmode_force_sync2]
823 path = $prefix_abs/share
825 vfs objects = aio_pthread xattr_tdb
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
836 path = $prefix_abs/share
837 vfs objects = aio_fork
839 vfs_aio_fork:erratic_testing_mode=yes
842 path = $prefix_abs/share
844 store dos attributes = yes
845 hide files = /hidefile/
849 path = $prefix_abs/share
851 smb encrypt = desired
854 path = $prefix_abs/share
855 hide new files timeout = 5
858 my $vars = $self->provision($path, "WORKGROUP",
861 $simpleserver_options);
863 $vars or return undef;
865 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
874 my ($self, $path) = @_;
875 my $prefix_abs = abs_path($path);
876 my $srcdir_abs = abs_path($self->{srcdir});
878 print "PROVISIONING file server ...\n";
882 mkdir($prefix_abs, 0777);
884 my $usershare_dir="$prefix_abs/lib/usershare";
886 mkdir("$prefix_abs/lib", 0755);
887 remove_tree($usershare_dir);
888 mkdir($usershare_dir, 01770);
890 my $share_dir="$prefix_abs/share";
892 # Create share directory structure
893 my $lower_case_share_dir="$share_dir/lower-case";
894 push(@dirs, $lower_case_share_dir);
896 my $lower_case_share_dir_30000="$share_dir/lower-case-30000";
897 push(@dirs, $lower_case_share_dir_30000);
899 my $dfree_share_dir="$share_dir/dfree";
900 push(@dirs, $dfree_share_dir);
901 push(@dirs, "$dfree_share_dir/subdir1");
902 push(@dirs, "$dfree_share_dir/subdir2");
903 push(@dirs, "$dfree_share_dir/subdir3");
905 my $quotadir_dir="$share_dir/quota";
906 push(@dirs, $quotadir_dir);
908 my $valid_users_sharedir="$share_dir/valid_users";
909 push(@dirs,$valid_users_sharedir);
911 my $offline_sharedir="$share_dir/offline";
912 push(@dirs,$offline_sharedir);
914 my $force_user_valid_users_dir = "$share_dir/force_user_valid_users";
915 push(@dirs, $force_user_valid_users_dir);
917 my $smbget_sharedir="$share_dir/smbget";
918 push(@dirs,$smbget_sharedir);
920 my $tarmode_sharedir="$share_dir/tarmode";
921 push(@dirs,$tarmode_sharedir);
923 my $usershare_sharedir="$share_dir/usershares";
924 push(@dirs,$usershare_sharedir);
926 my $fileserver_options = "
927 kernel change notify = yes
929 usershare path = $usershare_dir
930 usershare max shares = 10
931 usershare allow guests = yes
932 usershare prefix allow list = $usershare_sharedir
934 get quota command = $prefix_abs/getset_quota.py
935 set quota command = $prefix_abs/getset_quota.py
937 path = $lower_case_share_dir
938 comment = smb username is [%U]
939 case sensitive = True
942 short preserve case = no
944 path = $lower_case_share_dir_30000
945 comment = smb username is [%U]
946 case sensitive = True
949 short preserve case = no
951 path = $dfree_share_dir
952 comment = smb username is [%U]
953 dfree command = $srcdir_abs/testprogs/blackbox/dfree.sh
955 path = $valid_users_sharedir
956 valid users = +userdup
958 path = $offline_sharedir
959 vfs objects = offline
961 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878
962 # RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651
963 [force_user_valid_users]
964 path = $force_user_valid_users_dir
965 comment = force user with valid users combination test share
966 valid users = +force_user
967 force user = force_user
968 force group = everyone
969 write list = force_user
972 path = $smbget_sharedir
973 comment = smb username is [%U]
977 comment = ignore system acls
978 acl_xattr:ignore system acls = yes
981 comment = inherit owner
985 comment = inherit only unix owner
986 inherit owner = unix only
987 acl_xattr:ignore system acls = yes
988 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=13690
991 comment = force group test
992 # force group = everyone
994 comment = Home directories
999 my $vars = $self->provision($path, "WORKGROUP",
1002 $fileserver_options,
1007 $vars or return undef;
1009 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
1014 mkdir($_, 0777) foreach(@dirs);
1016 ## Create case sensitive lower case share dir
1017 foreach my $file ('a'..'z') {
1018 my $full_path = $lower_case_share_dir . '/' . $file;
1019 open my $fh, '>', $full_path;
1020 # Add some content to file
1021 print $fh $full_path;
1025 for (my $file = 1; $file < 51; ++$file) {
1026 my $full_path = $lower_case_share_dir . '/' . $file;
1027 open my $fh, '>', $full_path;
1028 # Add some content to file
1029 print $fh $full_path;
1033 # Create content for 30000 share
1034 foreach my $file ('a'..'z') {
1035 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1036 open my $fh, '>', $full_path;
1037 # Add some content to file
1038 print $fh $full_path;
1042 for (my $file = 1; $file < 30001; ++$file) {
1043 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1044 open my $fh, '>', $full_path;
1045 # Add some content to file
1046 print $fh $full_path;
1051 ## create a listable file in valid_users_share
1053 my $valid_users_target = "$valid_users_sharedir/foo";
1054 unless (open(VALID_USERS_TARGET, ">$valid_users_target")) {
1055 warn("Unable to open $valid_users_target");
1058 close(VALID_USERS_TARGET);
1059 chmod 0644, $valid_users_target;
1066 my ($self, $prefix) = @_;
1068 # If we didn't build with ADS, pretend this env was never available
1069 if (not $self->have_ads()) {
1073 print "PROVISIONING server with security=ads...";
1075 my $ktest_options = "
1077 realm = ktest.samba.example.com
1079 username map = $prefix/lib/username.map
1080 server signing = required
1081 server min protocol = SMB3_00
1082 client max protocol = SMB3
1084 # This disables NTLM auth against the local SAM, which
1085 # we use can then test this setting by.
1086 ntlm auth = disabled
1089 my $ret = $self->provision($prefix, "KTEST",
1094 $ret or return undef;
1097 my $prefix_abs = abs_path($prefix);
1099 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1100 $ctx->{domain} = "KTEST";
1101 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
1102 $ctx->{dnsname} = lc($ctx->{realm});
1103 $ctx->{kdc_ipv4} = "0.0.0.0";
1104 $ctx->{kdc_ipv6} = "::";
1105 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1106 Samba::mk_krb5_conf($ctx, "");
1108 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1110 open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map");
1112 $ret->{USERNAME} = KTEST\\Administrator
1116 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
1117 #Samba4 DC with the same parameters as are being used here. The
1118 #domain SID is S-1-5-21-1071277805-689288055-3486227160
1119 $ret->{SAMSID} = "S-1-5-21-1911091480-1468226576-2729736297";
1120 $ret->{DOMSID} = "S-1-5-21-1071277805-689288055-3486227160";
1122 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
1123 chmod 0600, "$prefix/private/secrets.tdb";
1125 #Make sure there's no old ntdb file.
1126 system("rm -f $prefix/private/secrets.ntdb");
1128 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
1129 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
1131 #and having in krb5.conf:
1132 # ticket_lifetime = 799718400
1133 # renew_lifetime = 799718400
1135 # The commands for the -2 keytab where were:
1136 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
1137 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
1138 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
1139 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1140 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1142 # and then for the -3 keytab, I did
1144 # net changetrustpw; kdestroy and the same again.
1146 # This creates a credential cache with a very long lifetime (2036 at
1147 # at 2011-04), and shows that running 'net changetrustpw' does not
1148 # break existing logins (for the secrets.tdb method at least).
1151 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
1153 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
1154 chmod 0600, "$prefix/krb5_ccache-2";
1156 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
1157 chmod 0600, "$prefix/krb5_ccache-3";
1159 # We need world access to this share, as otherwise the domain
1160 # administrator from the AD domain provided by ktest can't
1161 # access the share for tests.
1162 chmod 0777, "$prefix/share";
1164 if (not $self->check_or_start($ret, "yes", "no", "yes")) {
1170 sub setup_maptoguest
1172 my ($self, $path) = @_;
1174 print "PROVISIONING maptoguest...";
1177 map to guest = bad user
1181 my $vars = $self->provision($path, "WORKGROUP",
1186 $vars or return undef;
1188 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
1195 sub stop_sig_term($$) {
1196 my ($self, $pid) = @_;
1197 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1200 sub stop_sig_kill($$) {
1201 my ($self, $pid) = @_;
1202 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1207 my ($env_vars, $app, $pid) = @_;
1209 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
1216 my ($env_vars, $app) = @_;
1218 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
1224 sub check_or_start($$$$$) {
1225 my ($self, $env_vars, $nmbd, $winbindd, $smbd) = @_;
1227 # use a pipe for stdin in the child processes. This allows
1228 # those processes to monitor the pipe for EOF to ensure they
1229 # exit when the test script exits
1230 pipe(STDIN_READER, $env_vars->{STDIN_PIPE});
1232 unlink($env_vars->{NMBD_TEST_LOG});
1233 print "STARTING NMBD...";
1236 open STDOUT, ">$env_vars->{NMBD_TEST_LOG}";
1237 open STDERR, '>&STDOUT';
1239 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1241 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1242 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.nmbd";
1243 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1244 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1246 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1247 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1248 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1249 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1250 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1251 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1252 $ENV{UID_WRAPPER_ROOT} = "1";
1254 $ENV{ENVNAME} = "$ENV{ENVNAME}.nmbd";
1256 if ($nmbd ne "yes") {
1257 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1258 my $signame = shift;
1259 print("Skip nmbd received signal $signame");
1262 sleep($self->{server_maxtime});
1266 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "nmbd");
1267 my @optargs = ("-d0");
1268 if (defined($ENV{NMBD_OPTIONS})) {
1269 @optargs = split(/ /, $ENV{NMBD_OPTIONS});
1271 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1272 if(defined($ENV{NMBD_VALGRIND})) {
1273 @preargs = split(/ /, $ENV{NMBD_VALGRIND});
1275 my @args = ("-F", "--no-process-group",
1276 "-s", $env_vars->{SERVERCONFFILE},
1277 "-l", $env_vars->{LOGDIR});
1278 if (not defined($ENV{NMBD_DONT_LOG_STDOUT})) {
1279 push(@args, "--log-stdout");
1282 close($env_vars->{STDIN_PIPE});
1283 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1285 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1286 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1288 $env_vars->{NMBD_TL_PID} = $pid;
1289 write_pid($env_vars, "nmbd", $pid);
1292 unlink($env_vars->{WINBINDD_TEST_LOG});
1293 print "STARTING WINBINDD...";
1296 open STDOUT, ">$env_vars->{WINBINDD_TEST_LOG}";
1297 open STDERR, '>&STDOUT';
1299 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1301 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1302 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.winbindd";
1303 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1304 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1306 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1307 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1308 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1309 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1310 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1311 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1312 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
1313 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
1315 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
1317 $ENV{UID_WRAPPER_ROOT} = "1";
1319 $ENV{ENVNAME} = "$ENV{ENVNAME}.winbindd";
1321 if ($winbindd ne "yes") {
1322 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1323 my $signame = shift;
1324 print("Skip winbindd received signal $signame");
1327 sleep($self->{server_maxtime});
1331 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "winbindd");
1332 my @optargs = ("-d0");
1333 if (defined($ENV{WINBINDD_OPTIONS})) {
1334 @optargs = split(/ /, $ENV{WINBINDD_OPTIONS});
1336 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1337 if(defined($ENV{WINBINDD_VALGRIND})) {
1338 @preargs = split(/ /, $ENV{WINBINDD_VALGRIND});
1340 my @args = ("-F", "--no-process-group",
1341 "-s", $env_vars->{SERVERCONFFILE},
1342 "-l", $env_vars->{LOGDIR});
1343 if (not defined($ENV{WINBINDD_DONT_LOG_STDOUT})) {
1344 push(@args, "--stdout");
1347 close($env_vars->{STDIN_PIPE});
1348 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1350 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1351 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1353 $env_vars->{WINBINDD_TL_PID} = $pid;
1354 write_pid($env_vars, "winbindd", $pid);
1357 unlink($env_vars->{SMBD_TEST_LOG});
1358 print "STARTING SMBD...";
1361 open STDOUT, ">$env_vars->{SMBD_TEST_LOG}";
1362 open STDERR, '>&STDOUT';
1364 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1366 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1367 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.smbd";
1368 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1369 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1371 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1372 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1373 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1374 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1375 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1376 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1377 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
1378 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
1380 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
1382 $ENV{UID_WRAPPER_ROOT} = "1";
1384 $ENV{ENVNAME} = "$ENV{ENVNAME}.smbd";
1386 if ($smbd ne "yes") {
1387 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1388 my $signame = shift;
1389 print("Skip smbd received signal $signame");
1392 sleep($self->{server_maxtime});
1396 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "smbd");
1397 my @optargs = ("-d0");
1398 if (defined($ENV{SMBD_OPTIONS})) {
1399 @optargs = split(/ /, $ENV{SMBD_OPTIONS});
1401 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1402 if(defined($ENV{SMBD_VALGRIND})) {
1403 @preargs = split(/ /,$ENV{SMBD_VALGRIND});
1405 my @args = ("-F", "--no-process-group",
1406 "-s", $env_vars->{SERVERCONFFILE},
1407 "-l", $env_vars->{LOGDIR});
1408 if (not defined($ENV{SMBD_DONT_LOG_STDOUT})) {
1409 push(@args, "--log-stdout");
1412 close($env_vars->{STDIN_PIPE});
1413 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1415 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1416 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1418 $env_vars->{SMBD_TL_PID} = $pid;
1419 write_pid($env_vars, "smbd", $pid);
1422 close(STDIN_READER);
1424 return $self->wait_for_start($env_vars, $nmbd, $winbindd, $smbd);
1427 sub createuser($$$$$)
1429 my ($self, $username, $password, $conffile, $env) = @_;
1430 my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $username > /dev/null";
1433 while(my($var, $val) = each %$env) {
1434 $cmd = "$var=\"$val\" $cmd";
1437 unless (open(PWD, "|$cmd")) {
1438 warn("Unable to set password for $username account\n$cmd");
1441 print PWD "$password\n$password\n";
1442 unless (close(PWD)) {
1443 warn("Unable to set password for $username account\n$cmd");
1448 sub provision($$$$$$$$$)
1450 my ($self, $prefix, $domain, $server, $password, $extra_options, $dc_server_ip, $dc_server_ipv6, $no_delete_prefix) = @_;
1453 ## setup the various environment variables we need
1456 my $samsid = Samba::random_domain_sid();
1457 my $swiface = Samba::get_interface($server);
1459 my %createuser_env = ();
1460 my $server_ip = "127.0.0.$swiface";
1461 my $server_ipv6 = sprintf("fd00:0000:0000:0000:0000:0000:5357:5f%02x", $swiface);
1463 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
1466 my $unix_gids_str = $);
1467 my @unix_gids = split(" ", $unix_gids_str);
1469 my $prefix_abs = abs_path($prefix);
1470 my $bindir_abs = abs_path($self->{bindir});
1474 my $shrdir="$prefix_abs/share";
1475 push(@dirs,$shrdir);
1477 my $libdir="$prefix_abs/lib";
1478 push(@dirs,$libdir);
1480 my $piddir="$prefix_abs/pid";
1481 push(@dirs,$piddir);
1483 my $privatedir="$prefix_abs/private";
1484 push(@dirs,$privatedir);
1486 my $binddnsdir = "$prefix_abs/bind-dns";
1487 push(@dirs, $binddnsdir);
1489 my $lockdir="$prefix_abs/lockdir";
1490 push(@dirs,$lockdir);
1492 my $eventlogdir="$prefix_abs/lockdir/eventlog";
1493 push(@dirs,$eventlogdir);
1495 my $logdir="$prefix_abs/logs";
1496 push(@dirs,$logdir);
1498 my $driver32dir="$shrdir/W32X86";
1499 push(@dirs,$driver32dir);
1501 my $driver64dir="$shrdir/x64";
1502 push(@dirs,$driver64dir);
1504 my $driver40dir="$shrdir/WIN40";
1505 push(@dirs,$driver40dir);
1507 my $ro_shrdir="$shrdir/root-tmp";
1508 push(@dirs,$ro_shrdir);
1510 my $msdfs_shrdir="$shrdir/msdfsshare";
1511 push(@dirs,$msdfs_shrdir);
1513 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
1514 push(@dirs,$msdfs_deeppath);
1516 my $badnames_shrdir="$shrdir/badnames";
1517 push(@dirs,$badnames_shrdir);
1519 my $lease1_shrdir="$shrdir/SMB2_10";
1520 push(@dirs,$lease1_shrdir);
1522 my $lease2_shrdir="$shrdir/SMB3_00";
1523 push(@dirs,$lease2_shrdir);
1525 my $manglenames_shrdir="$shrdir/manglenames";
1526 push(@dirs,$manglenames_shrdir);
1528 my $widelinks_shrdir="$shrdir/widelinks";
1529 push(@dirs,$widelinks_shrdir);
1531 my $widelinks_linkdir="$shrdir/widelinks_foo";
1532 push(@dirs,$widelinks_linkdir);
1534 my $shadow_tstdir="$shrdir/shadow";
1535 push(@dirs,$shadow_tstdir);
1536 my $shadow_mntdir="$shadow_tstdir/mount";
1537 push(@dirs,$shadow_mntdir);
1538 my $shadow_basedir="$shadow_mntdir/base";
1539 push(@dirs,$shadow_basedir);
1540 my $shadow_shrdir="$shadow_basedir/share";
1541 push(@dirs,$shadow_shrdir);
1543 my $nosymlinks_shrdir="$shrdir/nosymlinks";
1544 push(@dirs,$nosymlinks_shrdir);
1546 my $local_symlinks_shrdir="$shrdir/local_symlinks";
1547 push(@dirs,$local_symlinks_shrdir);
1549 # this gets autocreated by winbindd
1550 my $wbsockdir="$prefix_abs/winbindd";
1552 my $nmbdsockdir="$prefix_abs/nmbd";
1553 unlink($nmbdsockdir);
1556 ## create the test directory layout
1558 die ("prefix_abs = ''") if $prefix_abs eq "";
1559 die ("prefix_abs = '/'") if $prefix_abs eq "/";
1561 mkdir($prefix_abs, 0777);
1562 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
1563 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
1564 system("rm -rf $prefix_abs/*");
1566 mkdir($_, 0777) foreach(@dirs);
1568 my $fs_specific_conf = $self->get_fs_specific_conf($shrdir);
1571 ## lockdir and piddir must be 0755
1573 chmod 0755, $lockdir;
1574 chmod 0755, $piddir;
1578 ## create ro and msdfs share layout
1581 chmod 0755, $ro_shrdir;
1582 my $unreadable_file = "$ro_shrdir/unreadable_file";
1583 unless (open(UNREADABLE_FILE, ">$unreadable_file")) {
1584 warn("Unable to open $unreadable_file");
1587 close(UNREADABLE_FILE);
1588 chmod 0600, $unreadable_file;
1590 my $msdfs_target = "$ro_shrdir/msdfs-target";
1591 unless (open(MSDFS_TARGET, ">$msdfs_target")) {
1592 warn("Unable to open $msdfs_target");
1595 close(MSDFS_TARGET);
1596 chmod 0666, $msdfs_target;
1597 symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp",
1598 "$msdfs_shrdir/msdfs-src1";
1599 symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
1602 ## create bad names in $badnames_shrdir
1604 ## (An invalid name, would be mangled to 8.3).
1605 my $badname_target = "$badnames_shrdir/\340|\231\216\377\177";
1606 unless (open(BADNAME_TARGET, ">$badname_target")) {
1607 warn("Unable to open $badname_target");
1610 close(BADNAME_TARGET);
1611 chmod 0666, $badname_target;
1613 ## (A bad name, would not be mangled to 8.3).
1614 my $badname_target = "$badnames_shrdir/\240\276\346\327\377\177";
1615 unless (open(BADNAME_TARGET, ">$badname_target")) {
1616 warn("Unable to open $badname_target");
1619 close(BADNAME_TARGET);
1620 chmod 0666, $badname_target;
1622 ## (A bad good name).
1623 my $badname_target = "$badnames_shrdir/blank.txt";
1624 unless (open(BADNAME_TARGET, ">$badname_target")) {
1625 warn("Unable to open $badname_target");
1628 close(BADNAME_TARGET);
1629 chmod 0666, $badname_target;
1632 ## create mangleable directory names in $manglenames_shrdir
1634 my $manglename_target = "$manglenames_shrdir/foo:bar";
1635 mkdir($manglename_target, 0777);
1638 ## create symlinks for widelinks tests.
1640 my $widelinks_target = "$widelinks_linkdir/target";
1641 unless (open(WIDELINKS_TARGET, ">$widelinks_target")) {
1642 warn("Unable to open $widelinks_target");
1645 close(WIDELINKS_TARGET);
1646 chmod 0666, $widelinks_target;
1648 ## This link should get ACCESS_DENIED
1650 symlink "$widelinks_target", "$widelinks_shrdir/source";
1652 ## This link should be allowed
1654 symlink "$widelinks_shrdir", "$widelinks_shrdir/dot";
1656 my $conffile="$libdir/server.conf";
1657 my $dfqconffile="$libdir/dfq.conf";
1658 my $errorinjectconf="$libdir/error_inject.conf";
1659 my $delayinjectconf="$libdir/delay_inject.conf";
1661 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/third_party/nss_wrapper/nss_wrapper.pl";
1662 my $nss_wrapper_passwd = "$privatedir/passwd";
1663 my $nss_wrapper_group = "$privatedir/group";
1664 my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts";
1665 my $resolv_conf = "$privatedir/resolv.conf";
1666 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
1668 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
1670 my $fake_snap_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/fake_snap.pl";
1672 my @eventlog_list = ("dns server", "application");
1675 ## calculate uids and gids
1678 my ($max_uid, $max_gid);
1679 my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
1680 my ($uid_pdbtest_wkn);
1682 my ($uid_force_user);
1683 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
1684 my ($gid_userdup, $gid_everyone);
1685 my ($gid_force_user);
1690 my ($uid_slashuser);
1692 if ($unix_uid < 0xffff - 13) {
1695 $max_uid = $unix_uid;
1698 $uid_root = $max_uid - 1;
1699 $uid_nobody = $max_uid - 2;
1700 $uid_pdbtest = $max_uid - 3;
1701 $uid_pdbtest2 = $max_uid - 4;
1702 $uid_userdup = $max_uid - 5;
1703 $uid_pdbtest_wkn = $max_uid - 6;
1704 $uid_force_user = $max_uid - 7;
1705 $uid_smbget = $max_uid - 8;
1706 $uid_user1 = $max_uid - 9;
1707 $uid_user2 = $max_uid - 10;
1708 $uid_gooduser = $max_uid - 11;
1709 $uid_eviluser = $max_uid - 12;
1710 $uid_slashuser = $max_uid - 13;
1712 if ($unix_gids[0] < 0xffff - 8) {
1715 $max_gid = $unix_gids[0];
1718 $gid_nobody = $max_gid - 1;
1719 $gid_nogroup = $max_gid - 2;
1720 $gid_root = $max_gid - 3;
1721 $gid_domusers = $max_gid - 4;
1722 $gid_domadmins = $max_gid - 5;
1723 $gid_userdup = $max_gid - 6;
1724 $gid_everyone = $max_gid - 7;
1725 $gid_force_user = $max_gid - 8;
1731 unless (open(CONF, ">$conffile")) {
1732 warn("Unable to open $conffile");
1737 netbios name = $server
1738 interfaces = $server_ip/8 $server_ipv6/64
1739 bind interfaces only = yes
1740 panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
1741 smbd:suicide mode = yes
1745 private dir = $privatedir
1746 binddns dir = $binddnsdir
1747 pid directory = $piddir
1748 lock directory = $lockdir
1749 log file = $logdir/log.\%m
1754 state directory = $lockdir
1755 cache directory = $lockdir
1757 passdb backend = tdbsam
1761 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1762 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
1763 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1764 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
1765 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
1766 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
1767 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
1769 addprinter command = $mod_printer_pl -a -s $conffile --
1770 deleteprinter command = $mod_printer_pl -d -s $conffile --
1772 eventlog list = application \"dns server\"
1775 kernel change notify = no
1779 printcap name = /dev/null
1781 winbindd socket directory = $wbsockdir
1782 nmbd:socket dir = $nmbdsockdir
1783 idmap config * : range = 100000-200000
1784 winbind enum users = yes
1785 winbind enum groups = yes
1786 winbind separator = /
1787 include system krb5 conf = no
1789 # min receivefile size = 4000
1793 smbd:sharedelay = 100000
1794 smbd:writetimeupdatedelay = 500000
1798 store dos attributes = yes
1803 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot time_audit full_audit
1805 full_audit:syslog = no
1806 full_audit:success = none
1807 full_audit:failure = none
1810 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
1811 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
1812 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
1813 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
1814 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
1815 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
1816 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
1818 print notify backchannel = yes
1820 ncalrpc dir = $prefix_abs/ncalrpc
1822 # The samba3.blackbox.smbclient_s3 test uses this to test that
1823 # sending messages works, and that the %m sub works.
1824 message command = mv %s $shrdir/message.%m
1826 # fsrvp server requires registry shares
1827 registry shares = yes
1829 # Used by RPC SRVSVC tests
1830 add share command = $bindir_abs/smbaddshare
1831 change share command = $bindir_abs/smbchangeshare
1832 delete share command = $bindir_abs/smbdeleteshare
1834 # fruit:copyfile is a global option
1835 fruit:copyfile = yes
1837 #this does not mean that we use non-secure test env,
1838 #it just means we ALLOW one to be configured.
1839 allow insecure wide links = yes
1841 # Begin extra options
1845 #Include user defined custom parameters if set
1848 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
1849 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
1855 comment = smb username is [%U]
1858 comment = Load dirsort module
1859 vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot
1862 comment = encrypt smb username is [%U]
1863 smb encrypt = required
1864 vfs objects = dirsort
1874 force user = $unix_name
1876 [forceuser_unixonly]
1877 comment = force a user with unix user SID and group SID
1879 force user = pdbtest
1881 [forceuser_wkngroup]
1882 comment = force a user with well-known group SID
1884 force user = pdbtest_wkn
1888 force group = nogroup
1896 write list = $unix_name
1899 valid users = $unix_name
1900 access based share enum = yes
1902 path = $msdfs_shrdir
1904 msdfs shuffle referrals = yes
1908 hide unreadable = yes
1911 case sensitive = yes
1914 hide unwriteable files = yes
1917 kernel share modes = no
1931 default devmode = no
1937 comment = smb username is [%U]
1939 nfs4acl_xattr:version = 40
1940 vfs objects = nfs4acl_xattr xattr_tdb
1942 [nfs4acl_special_40]
1944 comment = smb username is [%U]
1946 nfs4acl_xattr:version = 40
1947 vfs objects = nfs4acl_xattr xattr_tdb
1951 comment = smb username is [%U]
1953 vfs objects = nfs4acl_xattr xattr_tdb
1957 comment = smb username is [%U]
1958 vfs objects = nfs4acl_xattr xattr_tdb
1960 nfs4acl_xattr:encoding = xdr
1961 nfs4acl_xattr:version = 40
1965 comment = smb username is [%U]
1966 vfs objects = nfs4acl_xattr xattr_tdb
1968 nfs4acl_xattr:encoding = xdr
1969 nfs4acl_xattr:version = 41
1973 comment = smb username is [%U]
1975 force create mode = 777
1978 comment = smb username is [%U]
1980 force create mode = 0
1981 directory mask = 0777
1982 force directory mode = 0
1983 vfs objects = xattr_tdb streams_depot
1994 vfs objects = catia fruit streams_xattr acl_xattr xattr_tdb
1995 fruit:resource = file
1996 fruit:metadata = netatalk
1997 fruit:locking = netatalk
1998 fruit:encoding = native
1999 fruit:veto_appledouble = no
2003 # This is used by vfs.fruit tests that require real fs xattr
2004 vfs objects = catia fruit streams_xattr acl_xattr
2005 fruit:resource = file
2006 fruit:metadata = netatalk
2007 fruit:locking = netatalk
2008 fruit:encoding = native
2009 fruit:veto_appledouble = no
2011 [vfs_fruit_metadata_stream]
2013 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2014 fruit:resource = file
2015 fruit:metadata = stream
2016 fruit:veto_appledouble = no
2018 [vfs_fruit_stream_depot]
2020 vfs objects = fruit streams_depot acl_xattr xattr_tdb
2021 fruit:resource = stream
2022 fruit:metadata = stream
2023 fruit:veto_appledouble = no
2027 vfs objects = streams_xattr acl_xattr xattr_tdb
2029 [vfs_wo_fruit_stream_depot]
2031 vfs objects = streams_depot acl_xattr xattr_tdb
2033 [vfs_fruit_timemachine]
2035 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2036 fruit:resource = file
2037 fruit:metadata = stream
2038 fruit:time machine = yes
2039 fruit:time machine max size = 32K
2041 [vfs_fruit_wipe_intentionally_left_blank_rfork]
2043 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2044 fruit:resource = file
2045 fruit:metadata = stream
2046 fruit:wipe_intentionally_left_blank_rfork = true
2047 fruit:delete_empty_adfiles = false
2048 fruit:veto_appledouble = no
2050 [vfs_fruit_delete_empty_adfiles]
2052 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2053 fruit:resource = file
2054 fruit:metadata = stream
2055 fruit:wipe_intentionally_left_blank_rfork = true
2056 fruit:delete_empty_adfiles = true
2057 fruit:veto_appledouble = no
2060 path = $badnames_shrdir
2064 path = $manglenames_shrdir
2072 path = $widelinks_shrdir
2078 comment = fake shapshots using rsync
2079 vfs objects = shell_snap shadow_copy2
2080 shell_snap:check path command = $fake_snap_pl --check
2081 shell_snap:create command = $fake_snap_pl --create
2082 shell_snap:delete command = $fake_snap_pl --delete
2083 # a relative path here fails, the snapshot dir is no longer found
2084 shadow:snapdir = $shrdir/.snapshots
2087 path = $shadow_shrdir
2088 comment = previous versions snapshots under mount point
2089 vfs objects = shadow_copy2
2090 shadow:mountpoint = $shadow_mntdir
2093 path = $shadow_shrdir
2094 comment = previous versions snapshots outside mount point
2095 vfs objects = shadow_copy2
2096 shadow:mountpoint = $shadow_mntdir
2097 shadow:snapdir = $shadow_tstdir/.snapshots
2100 path = $shadow_shrdir
2101 comment = previous versions with subvolume snapshots, snapshots under base dir
2102 vfs objects = shadow_copy2
2103 shadow:mountpoint = $shadow_mntdir
2104 shadow:basedir = $shadow_basedir
2105 shadow:snapdir = $shadow_basedir/.snapshots
2108 path = $shadow_shrdir
2109 comment = previous versions with subvolume snapshots, snapshots outside mount point
2110 vfs objects = shadow_copy2
2111 shadow:mountpoint = $shadow_mntdir
2112 shadow:basedir = $shadow_basedir
2113 shadow:snapdir = $shadow_tstdir/.snapshots
2116 path = $shadow_shrdir
2117 comment = previous versions at volume root snapshots under mount point
2118 vfs objects = shadow_copy2
2119 shadow:mountpoint = $shadow_shrdir
2122 path = $shadow_shrdir
2123 comment = previous versions at volume root snapshots outside mount point
2124 vfs objects = shadow_copy2
2125 shadow:mountpoint = $shadow_shrdir
2126 shadow:snapdir = $shadow_tstdir/.snapshots
2129 path = $shadow_shrdir
2130 comment = previous versions snapshots everywhere
2131 vfs objects = shadow_copy2
2132 shadow:mountpoint = $shadow_mntdir
2133 shadow:snapdirseverywhere = yes
2136 path = $shadow_shrdir
2137 comment = previous versions using snapsharepath
2138 vfs objects = shadow_copy2
2139 shadow:mountpoint = $shadow_mntdir
2140 shadow:snapdir = $shadow_tstdir/.snapshots
2141 shadow:snapsharepath = share
2144 comment = Testing shadow:format with default option
2145 vfs object = shadow_copy2
2146 path = $shadow_shrdir
2149 shadow:mountpoint = $shadow_mntdir
2150 shadow:basedir = $shadow_basedir
2151 shadow:snapdir = $shadow_basedir/.snapshots
2152 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2155 comment = Testing shadow:format with only date component
2156 vfs object = shadow_copy2
2157 path = $shadow_shrdir
2160 shadow:mountpoint = $shadow_mntdir
2161 shadow:basedir = $shadow_basedir
2162 shadow:snapdir = $shadow_basedir/.snapshots
2163 shadow:format = \@GMT-%Y-%m-%d
2166 comment = Testing shadow:format with some hardcoded prefix
2167 vfs object = shadow_copy2
2168 path = $shadow_shrdir
2171 shadow:mountpoint = $shadow_mntdir
2172 shadow:basedir = $shadow_basedir
2173 shadow:snapdir = $shadow_basedir/.snapshots
2174 shadow:format = snap\@GMT-%Y.%m.%d-%H.%M.%S
2177 comment = Testing shadow:format with modified format
2178 vfs object = shadow_copy2
2179 path = $shadow_shrdir
2182 shadow:mountpoint = $shadow_mntdir
2183 shadow:basedir = $shadow_basedir
2184 shadow:snapdir = $shadow_basedir/.snapshots
2185 shadow:format = \@GMT-%Y.%m.%d-%H_%M_%S-snap
2188 comment = Testing shadow:snapprefix regex
2189 vfs object = shadow_copy2
2190 path = $shadow_shrdir
2193 shadow:mountpoint = $shadow_mntdir
2194 shadow:basedir = $shadow_basedir
2195 shadow:snapdir = $shadow_basedir/.snapshots
2196 shadow:snapprefix = \^s[a-z]*p\$
2197 shadow:format = _GMT-%Y.%m.%d-%H.%M.%S
2200 comment = Testing shadow:snapprefix with delim regex
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:delimiter = \@GMT
2209 shadow:snapprefix = [a-z]*
2210 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2213 path = $shadow_shrdir
2214 comment = previous versions with wide links allowed
2215 vfs objects = shadow_copy2
2216 shadow:mountpoint = $shadow_mntdir
2220 path = $shadow_tstdir
2221 comment = previous versions snapshots under mount point
2222 vfs objects = shadow_copy2 streams_xattr error_inject
2224 error_inject:pwrite = EBADF
2225 shadow:mountpoint = $shadow_tstdir
2228 path = $shrdir/dfree
2229 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2230 admin users = $unix_name
2231 include = $dfqconffile
2233 path = $shrdir/dfree
2234 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2235 admin users = $unix_name
2236 include = $dfqconffile
2237 dfree cache time = 60
2239 path = $shrdir/dfree
2240 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2242 include = $dfqconffile
2244 path = $shrdir/quota
2245 admin users = $unix_name
2247 [acl_xattr_ign_sysacl_posix]
2249 acl_xattr:ignore system acls = yes
2250 acl_xattr:default acl style = posix
2251 [acl_xattr_ign_sysacl_windows]
2253 acl_xattr:ignore system acls = yes
2254 acl_xattr:default acl style = windows
2258 mangled names = illegal
2262 path = $nosymlinks_shrdir
2263 follow symlinks = no
2267 path = $local_symlinks_shrdir
2268 follow symlinks = yes
2272 kernel oplocks = yes
2273 vfs objects = streams_xattr xattr_tdb
2277 vfs objects = streams_xattr xattr_tdb
2281 smbd:find async delay usec = 10000
2284 vfs objects = error_inject
2285 include = $errorinjectconf
2289 vfs objects = delay_inject
2290 kernel share modes = no
2293 include = $delayinjectconf
2297 vfs objects = delay_inject
2298 delay_inject:pread_send = 2000
2299 delay_inject:pwrite_send = 2000
2302 path = $prefix_abs/share
2303 delete readonly = yes
2307 my $net = Samba::bindir_path($self, "net");
2309 $cmd .= "SMB_CONF_PATH=\"$conffile\" ";
2310 $cmd .= "$net setlocalsid $samsid";
2312 if (system($cmd) != 0) {
2313 warn("Join failed\n$cmd");
2317 unless (open(ERRORCONF, ">$errorinjectconf")) {
2318 warn("Unable to open $errorinjectconf");
2323 unless (open(DELAYCONF, ">$delayinjectconf")) {
2324 warn("Unable to open $delayinjectconf");
2329 unless (open(DFQCONF, ">$dfqconffile")) {
2330 warn("Unable to open $dfqconffile");
2336 ## create a test account
2339 unless (open(PASSWD, ">$nss_wrapper_passwd")) {
2340 warn("Unable to open $nss_wrapper_passwd");
2343 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
2344 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
2345 pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2346 pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2347 userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
2348 pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false
2349 force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false
2350 smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false
2351 user1:x:$uid_user1:$gid_nogroup:user1 gecos:$prefix_abs:/bin/false
2352 user2:x:$uid_user2:$gid_nogroup:user2 gecos:$prefix_abs:/bin/false
2353 gooduser:x:$uid_gooduser:$gid_domusers:gooduser gecos:$prefix_abs:/bin/false
2354 eviluser:x:$uid_eviluser:$gid_domusers:eviluser gecos::/bin/false
2355 slashuser:x:$uid_slashuser:$gid_domusers:slashuser gecos:/:/bin/false
2357 if ($unix_uid != 0) {
2358 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
2363 unless (open(GROUP, ">$nss_wrapper_group")) {
2364 warn("Unable to open $nss_wrapper_group");
2367 print GROUP "nobody:x:$gid_nobody:
2368 nogroup:x:$gid_nogroup:nobody
2369 $unix_name-group:x:$unix_gids[0]:
2370 domusers:X:$gid_domusers:
2371 domadmins:X:$gid_domadmins:
2372 userdup:x:$gid_userdup:$unix_name
2373 everyone:x:$gid_everyone:
2374 force_user:x:$gid_force_user:
2376 if ($unix_gids[0] != 0) {
2377 print GROUP "root:x:$gid_root:
2384 my $hostname = lc($server);
2385 unless (open(HOSTS, ">>$nss_wrapper_hosts")) {
2386 warn("Unable to open $nss_wrapper_hosts");
2389 print HOSTS "${server_ip} ${hostname}.samba.example.com ${hostname}\n";
2390 print HOSTS "${server_ipv6} ${hostname}.samba.example.com ${hostname}\n";
2394 unless (open(RESOLV_CONF, ">$resolv_conf")) {
2395 warn("Unable to open $resolv_conf");
2398 if (defined($dc_server_ip) or defined($dc_server_ipv6)) {
2399 if (defined($dc_server_ip)) {
2400 print RESOLV_CONF "nameserver $dc_server_ip\n";
2402 if (defined($dc_server_ipv6)) {
2403 print RESOLV_CONF "nameserver $dc_server_ipv6\n";
2406 print RESOLV_CONF "nameserver ${server_ip}\n";
2407 print RESOLV_CONF "nameserver ${server_ipv6}\n";
2411 foreach my $evlog (@eventlog_list) {
2412 my $evlogtdb = "$eventlogdir/$evlog.tdb";
2413 open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
2417 $createuser_env{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2418 $createuser_env{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2419 $createuser_env{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2420 $createuser_env{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2421 if ($ENV{SAMBA_DNS_FAKING}) {
2422 $createuser_env{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2424 $createuser_env{RESOLV_WRAPPER_CONF} = $resolv_conf;
2427 createuser($self, $unix_name, $password, $conffile, \%createuser_env) || die("Unable to create user");
2428 createuser($self, "force_user", $password, $conffile, \%createuser_env) || die("Unable to create force_user");
2429 createuser($self, "smbget_user", $password, $conffile, \%createuser_env) || die("Unable to create smbget_user");
2430 createuser($self, "user1", $password, $conffile, \%createuser_env) || die("Unable to create user1");
2431 createuser($self, "user2", $password, $conffile, \%createuser_env) || die("Unable to create user2");
2432 createuser($self, "gooduser", $password, $conffile, \%createuser_env) || die("Unable to create gooduser");
2433 createuser($self, "eviluser", $password, $conffile, \%createuser_env) || die("Unable to create eviluser");
2434 createuser($self, "slashuser", $password, $conffile, \%createuser_env) || die("Unable to create slashuser");
2436 open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
2437 print DNS_UPDATE_LIST "A $server. $server_ip\n";
2438 print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n";
2439 close(DNS_UPDATE_LIST);
2443 $ret{SERVER_IP} = $server_ip;
2444 $ret{SERVER_IPV6} = $server_ipv6;
2445 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
2446 $ret{NMBD_TEST_LOG_POS} = 0;
2447 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
2448 $ret{WINBINDD_TEST_LOG_POS} = 0;
2449 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
2450 $ret{SMBD_TEST_LOG_POS} = 0;
2451 $ret{SERVERCONFFILE} = $conffile;
2452 $ret{CONFIGURATION} ="-s $conffile";
2453 $ret{LOCK_DIR} = $lockdir;
2454 $ret{SERVER} = $server;
2455 $ret{USERNAME} = $unix_name;
2456 $ret{USERID} = $unix_uid;
2457 $ret{DOMAIN} = $domain;
2458 $ret{SAMSID} = $samsid;
2459 $ret{NETBIOSNAME} = $server;
2460 $ret{PASSWORD} = $password;
2461 $ret{PIDDIR} = $piddir;
2462 $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir;
2463 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
2464 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
2465 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2466 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2467 $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2468 $ret{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2469 $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
2470 $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind";
2471 if ($ENV{SAMBA_DNS_FAKING}) {
2472 $ret{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2474 $ret{RESOLV_WRAPPER_CONF} = $resolv_conf;
2476 $ret{LOCAL_PATH} = "$shrdir";
2477 $ret{LOGDIR} = $logdir;
2480 # Avoid hitting system krb5.conf -
2481 # An env that needs Kerberos will reset this to the real
2484 $ret{KRB5_CONFIG} = abs_path($prefix) . "/no_krb5.conf";
2486 # Define KRB5CCNAME for each environment we set up
2487 $ret{KRB5_CCACHE} = abs_path($prefix) . "/krb5ccache";
2488 $ENV{KRB5CCNAME} = $ret{KRB5_CCACHE};
2493 sub wait_for_start($$$$$)
2495 my ($self, $envvars, $nmbd, $winbindd, $smbd) = @_;
2500 if ($nmbd eq "yes") {
2503 # give time for nbt server to register its names
2504 print "checking for nmbd\n";
2506 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
2507 my $nmblookup = Samba::bindir_path($self, "nmblookup");
2510 $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
2514 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
2515 system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
2516 system("$nmblookup $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
2517 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
2520 } while ($ret != 0 && $count < 10);
2522 print "NMBD not reachable after 10 retries\n";
2523 teardown_env($self, $envvars);
2528 if ($winbindd eq "yes") {
2529 print "checking for winbindd\n";
2531 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2532 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2533 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2534 $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping-dc";
2538 $ret = system($cmd);
2542 } while ($ret != 0 && $count < 20);
2544 print "WINBINDD not reachable after 20 seconds\n";
2545 teardown_env($self, $envvars);
2550 if ($smbd eq "yes") {
2551 # make sure smbd is also up set
2552 print "wait for smbd\n";
2556 $ret = system(Samba::bindir_path($self, "smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139");
2561 } while ($ret != 0 && $count < 20);
2563 print "SMBD failed to start up in a reasonable time (20sec)\n";
2564 teardown_env($self, $envvars);
2569 # Ensure we have domain users mapped.
2570 $netcmd = "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2571 $netcmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2572 $netcmd .= Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} ";
2574 $cmd = $netcmd . "groupmap delete ntgroup=domusers";
2575 $ret = system($cmd);
2577 $cmd = $netcmd . "groupmap add rid=513 unixgroup=domusers type=domain";
2578 $ret = system($cmd);
2580 print("\"$cmd\" failed\n");
2584 $cmd = $netcmd . "groupmap delete ntgroup=domadmins";
2585 $ret = system($cmd);
2587 $cmd = $netcmd . "groupmap add rid=512 unixgroup=domadmins type=domain";
2588 $ret = system($cmd);
2590 print("\"$cmd\" failed\n");
2594 $cmd = $netcmd . "groupmap delete ntgroup=everyone";
2595 $ret = system($cmd);
2597 $cmd = $netcmd . "groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin";
2598 $ret = system($cmd);
2600 print("\"$cmd\" failed\n");
2604 # note: creating builtin groups requires winbindd for the
2606 my $create_builtin_users = "no";
2607 if ($winbindd eq "yes") {
2608 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2609 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2610 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2611 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
2612 my $wbinfo_out = qx($cmd 2>&1);
2614 # wbinfo doesn't give us a better error code then
2615 # WBC_ERR_DOMAIN_NOT_FOUND, but at least that's
2616 # different then WBC_ERR_WINBIND_NOT_AVAILABLE
2617 if ($wbinfo_out !~ /WBC_ERR_DOMAIN_NOT_FOUND/) {
2618 print("Failed to run \"wbinfo --sid-to-gid=S-1-5-32-545\": $wbinfo_out");
2619 teardown_env($self, $envvars);
2622 $create_builtin_users = "yes";
2625 if ($create_builtin_users eq "yes") {
2626 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2627 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2628 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2629 $cmd .= Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
2630 $cmd .= "sam createbuiltingroup Users";
2631 $ret = system($cmd);
2633 print "Failed to create BUILTIN\\Users group\n";
2634 teardown_env($self, $envvars);
2638 $cmd = Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
2639 $cmd .= "cache del IDMAP/SID2XID/S-1-5-32-545";
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 $ret = system($cmd);
2648 print "Missing \"BUILTIN\\Users\", did net sam createbuiltingroup Users fail?\n";
2649 teardown_env($self, $envvars);
2654 print $self->getlog_env($envvars);