2 # Bootstrap Samba and run a number of tests against it.
3 # Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
4 # Published under the GNU GPL, v3 or later.
6 # NOTE: Refer to the README for more details about the various testenvs,
7 # and tips about adding new testenvs.
13 use FindBin qw($RealBin);
16 use File::Path 'remove_tree';
21 my $smbd_build_options = Samba::bindir_path($self, "smbd") . " -b|";
22 open(IN, $smbd_build_options) or die("Unable to run $smbd_build_options: $!");
31 # If we were not built with ADS support, pretend we were never even available
32 print "smbd does not have ADS support\n" unless $found_ads;
36 # return smb.conf parameters applicable to @path, based on the underlying
38 sub get_fs_specific_conf($$)
40 my ($self, $path) = @_;
42 my $stat_out = `stat --file-system $path` or return "";
44 if ($stat_out =~ m/Type:\s+btrfs/) {
45 $mods .= "streams_xattr btrfs";
49 return "vfs objects = $mods";
56 my ($classname, $bindir, $srcdir, $server_maxtime) = @_;
57 my $self = { vars => {},
60 server_maxtime => $server_maxtime
68 my ($self, $envvars) = @_;
71 # This should cause smbd to terminate gracefully
72 close($envvars->{STDIN_PIPE});
74 my $smbdpid = $envvars->{SMBD_TL_PID};
75 my $nmbdpid = $envvars->{NMBD_TL_PID};
76 my $winbinddpid = $envvars->{WINBINDD_TL_PID};
78 # This should give it time to write out the gcov data
80 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
81 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
82 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
85 && $winbinddchild == -1) {
92 if ($count <= 20 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
96 $self->stop_sig_term($smbdpid);
97 $self->stop_sig_term($nmbdpid);
98 $self->stop_sig_term($winbinddpid);
101 until ($count > 10) {
102 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
103 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
104 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
107 && $winbinddchild == -1) {
114 if ($count <= 10 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
118 warn("timelimit process did not quit on SIGTERM, sending SIGKILL");
119 $self->stop_sig_kill($smbdpid);
120 $self->stop_sig_kill($nmbdpid);
121 $self->stop_sig_kill($winbinddpid);
126 sub getlog_env_app($$$)
128 my ($self, $envvars, $name) = @_;
130 my $title = "$name LOG of: $envvars->{NETBIOSNAME}\n";
133 open(LOG, "<".$envvars->{$name."_TEST_LOG"});
135 seek(LOG, $envvars->{$name."_TEST_LOG_POS"}, SEEK_SET);
139 $envvars->{$name."_TEST_LOG_POS"} = tell(LOG);
142 return "" if $out eq $title;
149 my ($self, $envvars) = @_;
152 $ret .= $self->getlog_env_app($envvars, "SMBD");
153 $ret .= $self->getlog_env_app($envvars, "NMBD");
154 $ret .= $self->getlog_env_app($envvars, "WINBINDD");
161 my ($self, $envvars) = @_;
163 my $childpid = waitpid(-1, WNOHANG);
169 # Declare the environments Samba3 makes available.
170 # To be set up, they will be called as
171 # samba3->setup_$envname($self, $path, $dep_1_vars, $dep_2_vars, ...)
172 %Samba3::ENV_DEPS = (
173 # name => [dep_1, dep_2, ...],
175 nt4_dc_schannel => [],
182 nt4_member => ["nt4_dc"],
184 ad_member => ["ad_dc"],
185 ad_member_rfc2307 => ["ad_dc_ntvfs"],
186 ad_member_idmap_rid => ["ad_dc"],
187 ad_member_idmap_ad => ["fl2008r2dc"],
190 %Samba3::ENV_DEPS_POST = ();
194 my ($self, $path) = @_;
196 print "PROVISIONING NT4 DC...";
198 my $nt4_dc_options = "
203 raw NTLMv2 auth = yes
204 server schannel = auto
206 rpc_server:epmapper = external
207 rpc_server:spoolss = external
208 rpc_server:lsarpc = external
209 rpc_server:samr = external
210 rpc_server:netlogon = external
211 rpc_server:register_embedded_np = yes
212 rpc_server:FssagentRpc = external
214 rpc_daemon:epmd = fork
215 rpc_daemon:spoolssd = fork
216 rpc_daemon:lsasd = fork
217 rpc_daemon:fssd = fork
218 fss: sequence timeout = 1
219 check parent directory delete on close = yes
222 my $vars = $self->provision($path, "SAMBA-TEST",
227 $vars or return undef;
229 if (not $self->check_or_start($vars, "yes", "yes", "yes")) {
233 $vars->{DOMSID} = $vars->{SAMSID};
234 $vars->{DC_SERVER} = $vars->{SERVER};
235 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
236 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
237 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
238 $vars->{DC_USERNAME} = $vars->{USERNAME};
239 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
244 sub setup_nt4_dc_schannel
246 my ($self, $path) = @_;
248 print "PROVISIONING NT4 DC WITH SERVER SCHANNEL ...";
255 rpc_server:epmapper = external
256 rpc_server:spoolss = external
257 rpc_server:lsarpc = external
258 rpc_server:samr = external
259 rpc_server:netlogon = external
260 rpc_server:register_embedded_np = yes
262 rpc_daemon:epmd = fork
263 rpc_daemon:spoolssd = fork
264 rpc_daemon:lsasd = fork
266 server schannel = yes
267 # used to reproduce bug #12772
268 server max protocol = SMB2_02
271 my $vars = $self->provision($path, "NT4SCHANNEL",
276 $vars or return undef;
278 if (not $self->check_or_start($vars, "yes", "yes", "yes")) {
282 $vars->{DOMSID} = $vars->{SAMSID};
283 $vars->{DC_SERVER} = $vars->{SERVER};
284 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
285 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
286 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
287 $vars->{DC_USERNAME} = $vars->{USERNAME};
288 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
295 my ($self, $prefix, $nt4_dc_vars) = @_;
299 print "PROVISIONING MEMBER...";
301 my $require_mutexes = "dbwrap_tdb_require_mutexes:* = yes";
302 $require_mutexes = "" if ($ENV{SELFTEST_DONT_REQUIRE_TDB_MUTEX_SUPPORT} eq "1");
304 my $member_options = "
306 dbwrap_tdb_mutexes:* = yes
309 my $ret = $self->provision($prefix, $nt4_dc_vars->{DOMAIN},
311 "localnt4member3pass",
314 $ret or return undef;
316 my $nmblookup = Samba::bindir_path($self, "nmblookup");
318 print "Waiting for the LOGON SERVER registration ...\n";
319 $rc = system("$nmblookup $ret->{CONFIGURATION} $ret->{DOMAIN}\#1c");
324 } while ($rc != 0 && $count < 10);
326 print "NMBD not reachable after 10 retries\n";
327 teardown_env($self, $ret);
331 my $net = Samba::bindir_path($self, "net");
332 # Add hosts file for name lookups
333 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
334 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
335 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
336 $cmd .= "$net rpc join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
337 $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}";
339 if (system($cmd) != 0) {
340 warn("Join failed\n$cmd");
344 # Add hosts file for name lookups
345 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
346 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
347 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
348 $cmd .= "$net $ret->{CONFIGURATION} primarytrust dumpinfo | grep -q 'REDACTED SECRET VALUES'";
350 if (system($cmd) != 0) {
351 warn("check failed\n$cmd");
355 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
359 $ret->{DOMSID} = $nt4_dc_vars->{DOMSID};
360 $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
361 $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
362 $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
363 $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME};
364 $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME};
365 $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD};
372 my ($self, $prefix, $dcvars) = @_;
374 my $prefix_abs = abs_path($prefix);
377 # If we didn't build with ADS, pretend this env was never available
378 if (not $self->have_ads()) {
382 print "PROVISIONING S3 AD MEMBER...";
384 mkdir($prefix_abs, 0777);
386 my $share_dir="$prefix_abs/share";
387 push(@dirs, $share_dir);
389 my $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}";
390 push(@dirs, $substitution_path);
392 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice";
393 push(@dirs, $substitution_path);
395 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice/G_domain users";
396 push(@dirs, $substitution_path);
398 # Using '/' as the winbind separator is a bad idea ...
399 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}";
400 push(@dirs, $substitution_path);
402 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice";
403 push(@dirs, $substitution_path);
405 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}";
406 push(@dirs, $substitution_path);
408 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}/domain users";
409 push(@dirs, $substitution_path);
411 my $member_options = "
413 workgroup = $dcvars->{DOMAIN}
414 realm = $dcvars->{REALM}
415 netbios aliases = foo bar
416 template homedir = /home/%D/%G/%U
417 auth event notification = true
418 password server = $dcvars->{SERVER}
421 path = $share_dir/D_%D/U_%U/G_%G
425 path = $share_dir/D_%D/u_%u/g_%g
430 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
434 $dcvars->{SERVER_IP},
435 $dcvars->{SERVER_IPV6});
437 $ret or return undef;
439 mkdir($_, 0777) foreach(@dirs);
442 $ret->{DOMAIN} = $dcvars->{DOMAIN};
443 $ret->{REALM} = $dcvars->{REALM};
444 $ret->{DOMSID} = $dcvars->{DOMSID};
448 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
449 $ctx->{domain} = $dcvars->{DOMAIN};
450 $ctx->{realm} = $dcvars->{REALM};
451 $ctx->{dnsname} = lc($dcvars->{REALM});
452 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
453 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
454 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
455 Samba::mk_krb5_conf($ctx, "");
457 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
458 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
460 my $net = Samba::bindir_path($self, "net");
461 # Add hosts file for name lookups
462 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
463 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
464 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
465 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
467 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
469 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
470 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
471 $cmd .= "$net join $ret->{CONFIGURATION}";
472 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
474 if (system($cmd) != 0) {
475 warn("Join failed\n$cmd");
479 # We need world access to this share, as otherwise the domain
480 # administrator from the AD domain provided by Samba4 can't
481 # access the share for tests.
482 chmod 0777, "$prefix/share";
484 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
488 $ret->{DC_SERVER} = $dcvars->{SERVER};
489 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
490 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
491 $ret->{DC_SERVERCONFFILE} = $dcvars->{SERVERCONFFILE};
492 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
493 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
494 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
499 sub setup_ad_member_rfc2307
501 my ($self, $prefix, $dcvars) = @_;
503 # If we didn't build with ADS, pretend this env was never available
504 if (not $self->have_ads()) {
508 print "PROVISIONING S3 AD MEMBER WITH idmap_rfc2307 config...";
510 my $member_options = "
512 workgroup = $dcvars->{DOMAIN}
513 realm = $dcvars->{REALM}
515 idmap negative cache time = 0
516 idmap config * : backend = autorid
517 idmap config * : range = 1000000-1999999
518 idmap config * : rangesize = 100000
519 idmap config $dcvars->{DOMAIN} : backend = rfc2307
520 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
521 idmap config $dcvars->{DOMAIN} : ldap_server = ad
522 idmap config $dcvars->{DOMAIN} : bind_path_user = ou=idmap,dc=samba,dc=example,dc=com
523 idmap config $dcvars->{DOMAIN} : bind_path_group = ou=idmap,dc=samba,dc=example,dc=com
525 password server = $dcvars->{SERVER}
528 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
532 $dcvars->{SERVER_IP},
533 $dcvars->{SERVER_IPV6});
535 $ret or return undef;
538 $ret->{DOMAIN} = $dcvars->{DOMAIN};
539 $ret->{REALM} = $dcvars->{REALM};
540 $ret->{DOMSID} = $dcvars->{DOMSID};
543 my $prefix_abs = abs_path($prefix);
545 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
546 $ctx->{domain} = $dcvars->{DOMAIN};
547 $ctx->{realm} = $dcvars->{REALM};
548 $ctx->{dnsname} = lc($dcvars->{REALM});
549 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
550 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
551 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
552 Samba::mk_krb5_conf($ctx, "");
554 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
555 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
557 my $net = Samba::bindir_path($self, "net");
558 # Add hosts file for name lookups
559 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
560 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
561 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
562 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
564 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
566 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
567 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
568 $cmd .= "$net join $ret->{CONFIGURATION}";
569 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
571 if (system($cmd) != 0) {
572 warn("Join failed\n$cmd");
576 # We need world access to this share, as otherwise the domain
577 # administrator from the AD domain provided by Samba4 can't
578 # access the share for tests.
579 chmod 0777, "$prefix/share";
581 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
585 $ret->{DC_SERVER} = $dcvars->{SERVER};
586 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
587 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
588 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
589 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
590 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
595 sub setup_ad_member_idmap_rid
597 my ($self, $prefix, $dcvars) = @_;
599 # If we didn't build with ADS, pretend this env was never available
600 if (not $self->have_ads()) {
604 print "PROVISIONING S3 AD MEMBER WITH idmap_rid config...";
606 my $member_options = "
608 workgroup = $dcvars->{DOMAIN}
609 realm = $dcvars->{REALM}
610 idmap config * : backend = tdb
611 idmap config * : range = 1000000-1999999
612 idmap config $dcvars->{DOMAIN} : backend = rid
613 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
614 # Prevent overridding the provisioned lib/krb5.conf which sets certain
615 # values required for tests to succeed
616 create krb5 conf = no
617 map to guest = bad user
620 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
624 $dcvars->{SERVER_IP},
625 $dcvars->{SERVER_IPV6});
627 $ret or return undef;
630 $ret->{DOMAIN} = $dcvars->{DOMAIN};
631 $ret->{REALM} = $dcvars->{REALM};
632 $ret->{DOMSID} = $dcvars->{DOMSID};
635 my $prefix_abs = abs_path($prefix);
637 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
638 $ctx->{domain} = $dcvars->{DOMAIN};
639 $ctx->{realm} = $dcvars->{REALM};
640 $ctx->{dnsname} = lc($dcvars->{REALM});
641 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
642 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
643 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
644 Samba::mk_krb5_conf($ctx, "");
646 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
647 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
649 my $net = Samba::bindir_path($self, "net");
650 # Add hosts file for name lookups
651 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
652 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
653 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
654 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
656 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
658 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
659 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
660 $cmd .= "$net join $ret->{CONFIGURATION}";
661 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
663 if (system($cmd) != 0) {
664 warn("Join failed\n$cmd");
668 # We need world access to this share, as otherwise the domain
669 # administrator from the AD domain provided by Samba4 can't
670 # access the share for tests.
671 chmod 0777, "$prefix/share";
673 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
677 $ret->{DC_SERVER} = $dcvars->{SERVER};
678 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
679 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
680 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
681 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
682 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
687 sub setup_ad_member_idmap_ad
689 my ($self, $prefix, $dcvars) = @_;
691 # If we didn't build with ADS, pretend this env was never available
692 if (not $self->have_ads()) {
696 print "PROVISIONING S3 AD MEMBER WITH idmap_ad config...";
698 my $member_options = "
700 workgroup = $dcvars->{DOMAIN}
701 realm = $dcvars->{REALM}
702 password server = $dcvars->{SERVER}
703 idmap config * : backend = tdb
704 idmap config * : range = 1000000-1999999
705 idmap config $dcvars->{DOMAIN} : backend = ad
706 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
707 idmap config $dcvars->{TRUST_DOMAIN} : backend = ad
708 idmap config $dcvars->{TRUST_DOMAIN} : range = 2000000-2999999
711 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
715 $dcvars->{SERVER_IP},
716 $dcvars->{SERVER_IPV6});
718 $ret or return undef;
721 $ret->{DOMAIN} = $dcvars->{DOMAIN};
722 $ret->{REALM} = $dcvars->{REALM};
723 $ret->{DOMSID} = $dcvars->{DOMSID};
726 my $prefix_abs = abs_path($prefix);
728 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
729 $ctx->{domain} = $dcvars->{DOMAIN};
730 $ctx->{realm} = $dcvars->{REALM};
731 $ctx->{dnsname} = lc($dcvars->{REALM});
732 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
733 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
734 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
735 Samba::mk_krb5_conf($ctx, "");
737 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
738 $ret->{RESOLV_CONF} = $dcvars->{RESOLV_CONF};
740 my $net = Samba::bindir_path($self, "net");
741 # Add hosts file for name lookups
742 my $cmd = "NSS_WRAPPER_HOSTS='$ret->{NSS_WRAPPER_HOSTS}' ";
743 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
744 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
745 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
747 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
749 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
750 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
751 $cmd .= "$net join $ret->{CONFIGURATION}";
752 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
754 if (system($cmd) != 0) {
755 warn("Join failed\n$cmd");
759 # We need world access to this share, as otherwise the domain
760 # administrator from the AD domain provided by Samba4 can't
761 # access the share for tests.
762 chmod 0777, "$prefix/share";
764 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
768 $ret->{DC_SERVER} = $dcvars->{SERVER};
769 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
770 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
771 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
772 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
773 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
775 $ret->{TRUST_SERVER} = $dcvars->{TRUST_SERVER};
776 $ret->{TRUST_USERNAME} = $dcvars->{TRUST_USERNAME};
777 $ret->{TRUST_PASSWORD} = $dcvars->{TRUST_PASSWORD};
778 $ret->{TRUST_DOMAIN} = $dcvars->{TRUST_DOMAIN};
779 $ret->{TRUST_REALM} = $dcvars->{TRUST_REALM};
780 $ret->{TRUST_DOMSID} = $dcvars->{TRUST_DOMSID};
785 sub setup_simpleserver
787 my ($self, $path) = @_;
789 print "PROVISIONING simple server...";
791 my $prefix_abs = abs_path($path);
793 my $simpleserver_options = "
796 vfs objects = xattr_tdb streams_depot
801 path = $prefix_abs/share
803 vfs objects = aio_pthread
804 aio_pthread:aio open = yes
805 smbd:async dosmode = no
807 [vfs_aio_pthread_async_dosmode_default1]
808 path = $prefix_abs/share
810 vfs objects = aio_pthread
811 store dos attributes = yes
812 aio_pthread:aio open = yes
813 smbd:async dosmode = yes
815 [vfs_aio_pthread_async_dosmode_default2]
816 path = $prefix_abs/share
818 vfs objects = aio_pthread xattr_tdb
819 store dos attributes = yes
820 aio_pthread:aio open = yes
821 smbd:async dosmode = yes
823 [vfs_aio_pthread_async_dosmode_force_sync1]
824 path = $prefix_abs/share
826 vfs objects = aio_pthread
827 store dos attributes = yes
828 aio_pthread:aio open = yes
829 smbd:async dosmode = yes
830 # This simulates non linux systems
831 smbd:force sync user path safe threadpool = yes
832 smbd:force sync user chdir safe threadpool = yes
833 smbd:force sync root path safe threadpool = yes
834 smbd:force sync root chdir safe threadpool = yes
836 [vfs_aio_pthread_async_dosmode_force_sync2]
837 path = $prefix_abs/share
839 vfs objects = aio_pthread xattr_tdb
840 store dos attributes = yes
841 aio_pthread:aio open = yes
842 smbd:async dosmode = yes
843 # This simulates non linux systems
844 smbd:force sync user path safe threadpool = yes
845 smbd:force sync user chdir safe threadpool = yes
846 smbd:force sync root path safe threadpool = yes
847 smbd:force sync root chdir safe threadpool = yes
850 path = $prefix_abs/share
851 vfs objects = aio_fork
853 vfs_aio_fork:erratic_testing_mode=yes
856 path = $prefix_abs/share
858 store dos attributes = yes
859 hide files = /hidefile/
863 path = $prefix_abs/share
865 smb encrypt = desired
868 path = $prefix_abs/share
869 hide new files timeout = 5
872 my $vars = $self->provision($path, "WORKGROUP",
875 $simpleserver_options);
877 $vars or return undef;
879 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
888 my ($self, $path) = @_;
889 my $prefix_abs = abs_path($path);
890 my $srcdir_abs = abs_path($self->{srcdir});
892 print "PROVISIONING file server ...\n";
896 mkdir($prefix_abs, 0777);
898 my $usershare_dir="$prefix_abs/lib/usershare";
900 mkdir("$prefix_abs/lib", 0755);
901 remove_tree($usershare_dir);
902 mkdir($usershare_dir, 01770);
904 my $share_dir="$prefix_abs/share";
906 # Create share directory structure
907 my $lower_case_share_dir="$share_dir/lower-case";
908 push(@dirs, $lower_case_share_dir);
910 my $lower_case_share_dir_30000="$share_dir/lower-case-30000";
911 push(@dirs, $lower_case_share_dir_30000);
913 my $dfree_share_dir="$share_dir/dfree";
914 push(@dirs, $dfree_share_dir);
915 push(@dirs, "$dfree_share_dir/subdir1");
916 push(@dirs, "$dfree_share_dir/subdir2");
917 push(@dirs, "$dfree_share_dir/subdir3");
919 my $quotadir_dir="$share_dir/quota";
920 push(@dirs, $quotadir_dir);
922 my $valid_users_sharedir="$share_dir/valid_users";
923 push(@dirs,$valid_users_sharedir);
925 my $offline_sharedir="$share_dir/offline";
926 push(@dirs,$offline_sharedir);
928 my $force_user_valid_users_dir = "$share_dir/force_user_valid_users";
929 push(@dirs, $force_user_valid_users_dir);
931 my $smbget_sharedir="$share_dir/smbget";
932 push(@dirs,$smbget_sharedir);
934 my $tarmode_sharedir="$share_dir/tarmode";
935 push(@dirs,$tarmode_sharedir);
937 my $usershare_sharedir="$share_dir/usershares";
938 push(@dirs,$usershare_sharedir);
940 my $fileserver_options = "
941 kernel change notify = yes
942 rpc_server:mdssvc = embedded
944 usershare path = $usershare_dir
945 usershare max shares = 10
946 usershare allow guests = yes
947 usershare prefix allow list = $usershare_sharedir
949 get quota command = $prefix_abs/getset_quota.py
950 set quota command = $prefix_abs/getset_quota.py
960 path = $lower_case_share_dir
961 comment = smb username is [%U]
962 case sensitive = True
965 short preserve case = no
967 path = $lower_case_share_dir_30000
968 comment = smb username is [%U]
969 case sensitive = True
972 short preserve case = no
974 path = $dfree_share_dir
975 comment = smb username is [%U]
976 dfree command = $srcdir_abs/testprogs/blackbox/dfree.sh
978 path = $valid_users_sharedir
979 valid users = +userdup
981 path = $offline_sharedir
982 vfs objects = offline
984 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878
985 # RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651
986 [force_user_valid_users]
987 path = $force_user_valid_users_dir
988 comment = force user with valid users combination test share
989 valid users = +force_user
990 force user = force_user
991 force group = everyone
992 write list = force_user
995 path = $smbget_sharedir
996 comment = smb username is [%U]
1000 comment = ignore system acls
1001 acl_xattr:ignore system acls = yes
1004 comment = inherit owner
1008 comment = inherit only unix owner
1009 inherit owner = unix only
1010 acl_xattr:ignore system acls = yes
1011 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=13690
1014 comment = force group test
1015 # force group = everyone
1017 comment = Home directories
1022 my $vars = $self->provision($path, "WORKGROUP",
1025 $fileserver_options,
1030 $vars or return undef;
1032 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
1037 mkdir($_, 0777) foreach(@dirs);
1039 ## Create case sensitive lower case share dir
1040 foreach my $file ('a'..'z') {
1041 my $full_path = $lower_case_share_dir . '/' . $file;
1042 open my $fh, '>', $full_path;
1043 # Add some content to file
1044 print $fh $full_path;
1048 for (my $file = 1; $file < 51; ++$file) {
1049 my $full_path = $lower_case_share_dir . '/' . $file;
1050 open my $fh, '>', $full_path;
1051 # Add some content to file
1052 print $fh $full_path;
1056 # Create content for 30000 share
1057 foreach my $file ('a'..'z') {
1058 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1059 open my $fh, '>', $full_path;
1060 # Add some content to file
1061 print $fh $full_path;
1065 for (my $file = 1; $file < 30001; ++$file) {
1066 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1067 open my $fh, '>', $full_path;
1068 # Add some content to file
1069 print $fh $full_path;
1074 ## create a listable file in valid_users_share
1076 my $valid_users_target = "$valid_users_sharedir/foo";
1077 unless (open(VALID_USERS_TARGET, ">$valid_users_target")) {
1078 warn("Unable to open $valid_users_target");
1081 close(VALID_USERS_TARGET);
1082 chmod 0644, $valid_users_target;
1089 my ($self, $prefix) = @_;
1091 # If we didn't build with ADS, pretend this env was never available
1092 if (not $self->have_ads()) {
1096 print "PROVISIONING server with security=ads...";
1098 my $ktest_options = "
1100 realm = ktest.samba.example.com
1102 username map = $prefix/lib/username.map
1103 server signing = required
1104 server min protocol = SMB3_00
1105 client max protocol = SMB3
1107 # This disables NTLM auth against the local SAM, which
1108 # we use can then test this setting by.
1109 ntlm auth = disabled
1112 my $ret = $self->provision($prefix, "KTEST",
1117 $ret or return undef;
1120 my $prefix_abs = abs_path($prefix);
1122 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1123 $ctx->{domain} = "KTEST";
1124 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
1125 $ctx->{dnsname} = lc($ctx->{realm});
1126 $ctx->{kdc_ipv4} = "0.0.0.0";
1127 $ctx->{kdc_ipv6} = "::";
1128 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1129 Samba::mk_krb5_conf($ctx, "");
1131 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1133 open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map");
1135 $ret->{USERNAME} = KTEST\\Administrator
1139 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
1140 #Samba4 DC with the same parameters as are being used here. The
1141 #domain SID is S-1-5-21-1071277805-689288055-3486227160
1142 $ret->{SAMSID} = "S-1-5-21-1911091480-1468226576-2729736297";
1143 $ret->{DOMSID} = "S-1-5-21-1071277805-689288055-3486227160";
1145 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
1146 chmod 0600, "$prefix/private/secrets.tdb";
1148 #Make sure there's no old ntdb file.
1149 system("rm -f $prefix/private/secrets.ntdb");
1151 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
1152 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
1154 #and having in krb5.conf:
1155 # ticket_lifetime = 799718400
1156 # renew_lifetime = 799718400
1158 # The commands for the -2 keytab where were:
1159 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
1160 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
1161 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
1162 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1163 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1165 # and then for the -3 keytab, I did
1167 # net changetrustpw; kdestroy and the same again.
1169 # This creates a credential cache with a very long lifetime (2036 at
1170 # at 2011-04), and shows that running 'net changetrustpw' does not
1171 # break existing logins (for the secrets.tdb method at least).
1174 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
1176 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
1177 chmod 0600, "$prefix/krb5_ccache-2";
1179 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
1180 chmod 0600, "$prefix/krb5_ccache-3";
1182 # We need world access to this share, as otherwise the domain
1183 # administrator from the AD domain provided by ktest can't
1184 # access the share for tests.
1185 chmod 0777, "$prefix/share";
1187 if (not $self->check_or_start($ret, "yes", "no", "yes")) {
1193 sub setup_maptoguest
1195 my ($self, $path) = @_;
1197 print "PROVISIONING maptoguest...";
1200 map to guest = bad user
1204 my $vars = $self->provision($path, "WORKGROUP",
1209 $vars or return undef;
1211 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
1218 sub stop_sig_term($$) {
1219 my ($self, $pid) = @_;
1220 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1223 sub stop_sig_kill($$) {
1224 my ($self, $pid) = @_;
1225 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1230 my ($env_vars, $app, $pid) = @_;
1232 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
1239 my ($env_vars, $app) = @_;
1241 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
1247 # builds up the cmd args to run an s3 binary (i.e. smbd, nmbd, etc)
1250 my ($self, $binary, $env_vars, $options, $valgrind, $dont_log_stdout) = @_;
1252 my @optargs = ("-d0");
1253 if (defined($options)) {
1254 @optargs = split(/ /, $options);
1256 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1258 if (defined($valgrind)) {
1259 @preargs = split(/ /, $valgrind);
1261 my @args = ("-F", "--no-process-group",
1262 "-s", $env_vars->{SERVERCONFFILE},
1263 "-l", $env_vars->{LOGDIR});
1265 if (not defined($dont_log_stdout)) {
1266 push(@args, "--log-stdout");
1268 return (@preargs, $binary, @args, @optargs);
1271 sub check_or_start($$$$$) {
1272 my ($self, $env_vars, $nmbd, $winbindd, $smbd) = @_;
1275 # use a pipe for stdin in the child processes. This allows
1276 # those processes to monitor the pipe for EOF to ensure they
1277 # exit when the test script exits
1278 pipe($STDIN_READER, $env_vars->{STDIN_PIPE});
1280 my $binary = Samba::bindir_path($self, "nmbd");
1281 my @full_cmd = $self->make_bin_cmd($binary, $env_vars,
1282 $ENV{NMBD_OPTIONS}, $ENV{NMBD_VALGRIND},
1283 $ENV{NMBD_DONT_LOG_STDOUT});
1284 my $nmbd_envs = Samba::get_env_for_process("nmbd", $env_vars);
1285 delete $nmbd_envs->{RESOLV_WRAPPER_CONF};
1286 delete $nmbd_envs->{RESOLV_WRAPPER_HOSTS};
1288 # fork and exec() nmbd in the child process
1291 BINARY_PATH => $binary,
1292 FULL_CMD => [ @full_cmd ],
1293 LOG_FILE => $env_vars->{NMBD_TEST_LOG},
1294 ENV_VARS => $nmbd_envs,
1296 if ($nmbd ne "yes") {
1297 $daemon_ctx->{SKIP_DAEMON} = 1;
1299 my $pid = Samba::fork_and_exec($self, $env_vars, $daemon_ctx, $STDIN_READER);
1301 $env_vars->{NMBD_TL_PID} = $pid;
1302 write_pid($env_vars, "nmbd", $pid);
1304 $binary = Samba::bindir_path($self, "winbindd");
1305 @full_cmd = $self->make_bin_cmd($binary, $env_vars,
1306 $ENV{WINBINDD_OPTIONS}, $ENV{WINBINDD_VALGRIND}, "N/A");
1308 if (not defined($ENV{WINBINDD_DONT_LOG_STDOUT})) {
1309 push(@full_cmd, "--stdout");
1312 # fork and exec() winbindd in the child process
1315 BINARY_PATH => $binary,
1316 FULL_CMD => [ @full_cmd ],
1317 LOG_FILE => $env_vars->{WINBINDD_TEST_LOG},
1319 if ($winbindd ne "yes") {
1320 $daemon_ctx->{SKIP_DAEMON} = 1;
1322 my $pid = Samba::fork_and_exec($self, $env_vars, $daemon_ctx, $STDIN_READER);
1324 $env_vars->{WINBINDD_TL_PID} = $pid;
1325 write_pid($env_vars, "winbindd", $pid);
1327 $binary = Samba::bindir_path($self, "smbd");
1328 @full_cmd = $self->make_bin_cmd($binary, $env_vars,
1329 $ENV{SMBD_OPTIONS}, $ENV{SMBD_VALGRIND},
1330 $ENV{SMBD_DONT_LOG_STDOUT});
1332 # fork and exec() smbd in the child process
1335 BINARY_PATH => $binary,
1336 FULL_CMD => [ @full_cmd ],
1337 LOG_FILE => $env_vars->{SMBD_TEST_LOG},
1339 if ($smbd ne "yes") {
1340 $daemon_ctx->{SKIP_DAEMON} = 1;
1343 my $pid = Samba::fork_and_exec($self, $env_vars, $daemon_ctx, $STDIN_READER);
1345 $env_vars->{SMBD_TL_PID} = $pid;
1346 write_pid($env_vars, "smbd", $pid);
1348 # close the parent's read-end of the pipe
1349 close(STDIN_READER);
1351 return $self->wait_for_start($env_vars, $nmbd, $winbindd, $smbd);
1354 sub createuser($$$$$)
1356 my ($self, $username, $password, $conffile, $env) = @_;
1357 my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $username > /dev/null";
1360 while(my($var, $val) = each %$env) {
1361 $cmd = "$var=\"$val\" $cmd";
1364 unless (open(PWD, "|$cmd")) {
1365 warn("Unable to set password for $username account\n$cmd");
1368 print PWD "$password\n$password\n";
1369 unless (close(PWD)) {
1370 warn("Unable to set password for $username account\n$cmd");
1375 sub provision($$$$$$$$$)
1377 my ($self, $prefix, $domain, $server, $password, $extra_options, $dc_server_ip, $dc_server_ipv6, $no_delete_prefix) = @_;
1380 ## setup the various environment variables we need
1383 my $samsid = Samba::random_domain_sid();
1384 my $swiface = Samba::get_interface($server);
1386 my %createuser_env = ();
1387 my $server_ip = Samba::get_ipv4_addr($server);
1388 my $server_ipv6 = Samba::get_ipv6_addr($server);
1390 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
1393 my $unix_gids_str = $);
1394 my @unix_gids = split(" ", $unix_gids_str);
1396 my $prefix_abs = abs_path($prefix);
1397 my $bindir_abs = abs_path($self->{bindir});
1401 my $shrdir="$prefix_abs/share";
1402 push(@dirs,$shrdir);
1404 my $libdir="$prefix_abs/lib";
1405 push(@dirs,$libdir);
1407 my $piddir="$prefix_abs/pid";
1408 push(@dirs,$piddir);
1410 my $privatedir="$prefix_abs/private";
1411 push(@dirs,$privatedir);
1413 my $binddnsdir = "$prefix_abs/bind-dns";
1414 push(@dirs, $binddnsdir);
1416 my $lockdir="$prefix_abs/lockdir";
1417 push(@dirs,$lockdir);
1419 my $eventlogdir="$prefix_abs/lockdir/eventlog";
1420 push(@dirs,$eventlogdir);
1422 my $logdir="$prefix_abs/logs";
1423 push(@dirs,$logdir);
1425 my $driver32dir="$shrdir/W32X86";
1426 push(@dirs,$driver32dir);
1428 my $driver64dir="$shrdir/x64";
1429 push(@dirs,$driver64dir);
1431 my $driver40dir="$shrdir/WIN40";
1432 push(@dirs,$driver40dir);
1434 my $ro_shrdir="$shrdir/root-tmp";
1435 push(@dirs,$ro_shrdir);
1437 my $msdfs_shrdir="$shrdir/msdfsshare";
1438 push(@dirs,$msdfs_shrdir);
1440 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
1441 push(@dirs,$msdfs_deeppath);
1443 my $badnames_shrdir="$shrdir/badnames";
1444 push(@dirs,$badnames_shrdir);
1446 my $lease1_shrdir="$shrdir/SMB2_10";
1447 push(@dirs,$lease1_shrdir);
1449 my $lease2_shrdir="$shrdir/SMB3_00";
1450 push(@dirs,$lease2_shrdir);
1452 my $manglenames_shrdir="$shrdir/manglenames";
1453 push(@dirs,$manglenames_shrdir);
1455 my $widelinks_shrdir="$shrdir/widelinks";
1456 push(@dirs,$widelinks_shrdir);
1458 my $widelinks_linkdir="$shrdir/widelinks_foo";
1459 push(@dirs,$widelinks_linkdir);
1461 my $fsrvp_shrdir="$shrdir/fsrvp";
1462 push(@dirs,$fsrvp_shrdir);
1464 my $shadow_tstdir="$shrdir/shadow";
1465 push(@dirs,$shadow_tstdir);
1466 my $shadow_mntdir="$shadow_tstdir/mount";
1467 push(@dirs,$shadow_mntdir);
1468 my $shadow_basedir="$shadow_mntdir/base";
1469 push(@dirs,$shadow_basedir);
1470 my $shadow_shrdir="$shadow_basedir/share";
1471 push(@dirs,$shadow_shrdir);
1473 my $nosymlinks_shrdir="$shrdir/nosymlinks";
1474 push(@dirs,$nosymlinks_shrdir);
1476 my $local_symlinks_shrdir="$shrdir/local_symlinks";
1477 push(@dirs,$local_symlinks_shrdir);
1479 # this gets autocreated by winbindd
1480 my $wbsockdir="$prefix_abs/winbindd";
1482 my $nmbdsockdir="$prefix_abs/nmbd";
1483 unlink($nmbdsockdir);
1486 ## create the test directory layout
1488 die ("prefix_abs = ''") if $prefix_abs eq "";
1489 die ("prefix_abs = '/'") if $prefix_abs eq "/";
1491 mkdir($prefix_abs, 0777);
1492 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
1493 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
1494 system("rm -rf $prefix_abs/*");
1496 mkdir($_, 0777) foreach(@dirs);
1498 my $fs_specific_conf = $self->get_fs_specific_conf($shrdir);
1501 ## lockdir and piddir must be 0755
1503 chmod 0755, $lockdir;
1504 chmod 0755, $piddir;
1508 ## create ro and msdfs share layout
1511 chmod 0755, $ro_shrdir;
1512 my $unreadable_file = "$ro_shrdir/unreadable_file";
1513 unless (open(UNREADABLE_FILE, ">$unreadable_file")) {
1514 warn("Unable to open $unreadable_file");
1517 close(UNREADABLE_FILE);
1518 chmod 0600, $unreadable_file;
1520 my $msdfs_target = "$ro_shrdir/msdfs-target";
1521 unless (open(MSDFS_TARGET, ">$msdfs_target")) {
1522 warn("Unable to open $msdfs_target");
1525 close(MSDFS_TARGET);
1526 chmod 0666, $msdfs_target;
1527 symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp",
1528 "$msdfs_shrdir/msdfs-src1";
1529 symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
1532 ## create bad names in $badnames_shrdir
1534 ## (An invalid name, would be mangled to 8.3).
1535 my $badname_target = "$badnames_shrdir/\340|\231\216\377\177";
1536 unless (open(BADNAME_TARGET, ">$badname_target")) {
1537 warn("Unable to open $badname_target");
1540 close(BADNAME_TARGET);
1541 chmod 0666, $badname_target;
1543 ## (A bad name, would not be mangled to 8.3).
1544 my $badname_target = "$badnames_shrdir/\240\276\346\327\377\177";
1545 unless (open(BADNAME_TARGET, ">$badname_target")) {
1546 warn("Unable to open $badname_target");
1549 close(BADNAME_TARGET);
1550 chmod 0666, $badname_target;
1552 ## (A bad good name).
1553 my $badname_target = "$badnames_shrdir/blank.txt";
1554 unless (open(BADNAME_TARGET, ">$badname_target")) {
1555 warn("Unable to open $badname_target");
1558 close(BADNAME_TARGET);
1559 chmod 0666, $badname_target;
1562 ## create mangleable directory names in $manglenames_shrdir
1564 my $manglename_target = "$manglenames_shrdir/foo:bar";
1565 mkdir($manglename_target, 0777);
1568 ## create symlinks for widelinks tests.
1570 my $widelinks_target = "$widelinks_linkdir/target";
1571 unless (open(WIDELINKS_TARGET, ">$widelinks_target")) {
1572 warn("Unable to open $widelinks_target");
1575 close(WIDELINKS_TARGET);
1576 chmod 0666, $widelinks_target;
1578 ## This link should get ACCESS_DENIED
1580 symlink "$widelinks_target", "$widelinks_shrdir/source";
1582 ## This link should be allowed
1584 symlink "$widelinks_shrdir", "$widelinks_shrdir/dot";
1586 my $conffile="$libdir/server.conf";
1587 my $dfqconffile="$libdir/dfq.conf";
1588 my $errorinjectconf="$libdir/error_inject.conf";
1589 my $delayinjectconf="$libdir/delay_inject.conf";
1591 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/third_party/nss_wrapper/nss_wrapper.pl";
1592 my $nss_wrapper_passwd = "$privatedir/passwd";
1593 my $nss_wrapper_group = "$privatedir/group";
1594 my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts";
1595 my $resolv_conf = "$privatedir/resolv.conf";
1596 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
1598 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
1600 my $fake_snap_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/fake_snap.pl";
1602 my @eventlog_list = ("dns server", "application");
1605 ## calculate uids and gids
1608 my ($max_uid, $max_gid);
1609 my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
1610 my ($uid_pdbtest_wkn);
1612 my ($uid_force_user);
1613 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
1614 my ($gid_userdup, $gid_everyone);
1615 my ($gid_force_user);
1620 my ($uid_slashuser);
1622 if ($unix_uid < 0xffff - 13) {
1625 $max_uid = $unix_uid;
1628 $uid_root = $max_uid - 1;
1629 $uid_nobody = $max_uid - 2;
1630 $uid_pdbtest = $max_uid - 3;
1631 $uid_pdbtest2 = $max_uid - 4;
1632 $uid_userdup = $max_uid - 5;
1633 $uid_pdbtest_wkn = $max_uid - 6;
1634 $uid_force_user = $max_uid - 7;
1635 $uid_smbget = $max_uid - 8;
1636 $uid_user1 = $max_uid - 9;
1637 $uid_user2 = $max_uid - 10;
1638 $uid_gooduser = $max_uid - 11;
1639 $uid_eviluser = $max_uid - 12;
1640 $uid_slashuser = $max_uid - 13;
1642 if ($unix_gids[0] < 0xffff - 8) {
1645 $max_gid = $unix_gids[0];
1648 $gid_nobody = $max_gid - 1;
1649 $gid_nogroup = $max_gid - 2;
1650 $gid_root = $max_gid - 3;
1651 $gid_domusers = $max_gid - 4;
1652 $gid_domadmins = $max_gid - 5;
1653 $gid_userdup = $max_gid - 6;
1654 $gid_everyone = $max_gid - 7;
1655 $gid_force_user = $max_gid - 8;
1661 unless (open(CONF, ">$conffile")) {
1662 warn("Unable to open $conffile");
1666 my $interfaces = Samba::get_interfaces_config($server);
1670 netbios name = $server
1671 interfaces = $interfaces
1672 bind interfaces only = yes
1673 panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
1674 smbd:suicide mode = yes
1676 client min protocol = CORE
1677 server min protocol = LANMAN1
1681 private dir = $privatedir
1682 binddns dir = $binddnsdir
1683 pid directory = $piddir
1684 lock directory = $lockdir
1685 log file = $logdir/log.\%m
1690 state directory = $lockdir
1691 cache directory = $lockdir
1693 passdb backend = tdbsam
1697 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1698 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
1699 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1700 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
1701 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
1702 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
1703 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
1705 addprinter command = $mod_printer_pl -a -s $conffile --
1706 deleteprinter command = $mod_printer_pl -d -s $conffile --
1708 eventlog list = application \"dns server\"
1711 kernel change notify = no
1715 printcap name = /dev/null
1717 winbindd socket directory = $wbsockdir
1718 nmbd:socket dir = $nmbdsockdir
1719 idmap config * : range = 100000-200000
1720 winbind enum users = yes
1721 winbind enum groups = yes
1722 winbind separator = /
1723 include system krb5 conf = no
1725 # min receivefile size = 4000
1729 smbd:sharedelay = 100000
1730 smbd:writetimeupdatedelay = 500000
1734 store dos attributes = yes
1740 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot time_audit full_audit
1742 full_audit:syslog = no
1743 full_audit:success = none
1744 full_audit:failure = none
1747 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
1748 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
1749 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
1750 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
1751 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
1752 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
1753 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
1755 print notify backchannel = yes
1757 ncalrpc dir = $prefix_abs/ncalrpc
1759 # The samba3.blackbox.smbclient_s3 test uses this to test that
1760 # sending messages works, and that the %m sub works.
1761 message command = mv %s $shrdir/message.%m
1763 # fsrvp server requires registry shares
1764 registry shares = yes
1766 # Used by RPC SRVSVC tests
1767 add share command = $bindir_abs/smbaddshare
1768 change share command = $bindir_abs/smbchangeshare
1769 delete share command = $bindir_abs/smbdeleteshare
1771 # fruit:copyfile is a global option
1772 fruit:copyfile = yes
1774 #this does not mean that we use non-secure test env,
1775 #it just means we ALLOW one to be configured.
1776 allow insecure wide links = yes
1778 # Begin extra options
1782 #Include user defined custom parameters if set
1785 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
1786 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
1792 comment = smb username is [%U]
1795 comment = Load dirsort module
1796 vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot
1799 comment = encrypt smb username is [%U]
1800 smb encrypt = required
1801 vfs objects = dirsort
1811 force user = $unix_name
1813 [forceuser_unixonly]
1814 comment = force a user with unix user SID and group SID
1816 force user = pdbtest
1818 [forceuser_wkngroup]
1819 comment = force a user with well-known group SID
1821 force user = pdbtest_wkn
1825 force group = nogroup
1833 write list = $unix_name
1836 valid users = $unix_name
1837 access based share enum = yes
1839 path = $msdfs_shrdir
1841 msdfs shuffle referrals = yes
1845 hide unreadable = yes
1848 case sensitive = yes
1851 hide unwriteable files = yes
1854 kernel share modes = no
1868 default devmode = no
1874 comment = smb username is [%U]
1876 nfs4acl_xattr:version = 40
1877 vfs objects = nfs4acl_xattr xattr_tdb
1879 [nfs4acl_special_40]
1881 comment = smb username is [%U]
1883 nfs4acl_xattr:version = 40
1884 vfs objects = nfs4acl_xattr xattr_tdb
1888 comment = smb username is [%U]
1890 vfs objects = nfs4acl_xattr xattr_tdb
1894 comment = smb username is [%U]
1895 vfs objects = nfs4acl_xattr xattr_tdb
1897 nfs4acl_xattr:encoding = xdr
1898 nfs4acl_xattr:version = 40
1902 comment = smb username is [%U]
1903 vfs objects = nfs4acl_xattr xattr_tdb
1905 nfs4acl_xattr:encoding = xdr
1906 nfs4acl_xattr:version = 41
1910 comment = smb username is [%U]
1911 vfs objects = nfs4acl_xattr xattr_tdb
1913 nfs4acl_xattr:encoding = nfs
1914 nfs4acl_xattr:version = 40
1915 nfs4acl_xattr:xattr_name = security.nfs4acl_xdr
1919 comment = smb username is [%U]
1920 vfs objects = nfs4acl_xattr xattr_tdb
1922 nfs4acl_xattr:encoding = nfs
1923 nfs4acl_xattr:version = 41
1924 nfs4acl_xattr:xattr_name = security.nfs4acl_xdr
1928 comment = smb username is [%U]
1930 force create mode = 777
1933 comment = smb username is [%U]
1935 force create mode = 0
1936 directory mask = 0777
1937 force directory mode = 0
1938 vfs objects = xattr_tdb streams_depot
1949 vfs objects = catia fruit streams_xattr acl_xattr xattr_tdb
1950 fruit:resource = file
1951 fruit:metadata = netatalk
1952 fruit:locking = netatalk
1953 fruit:encoding = native
1954 fruit:veto_appledouble = no
1958 # This is used by vfs.fruit tests that require real fs xattr
1959 vfs objects = catia fruit streams_xattr acl_xattr
1960 fruit:resource = file
1961 fruit:metadata = netatalk
1962 fruit:locking = netatalk
1963 fruit:encoding = native
1964 fruit:veto_appledouble = no
1966 [vfs_fruit_metadata_stream]
1968 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
1969 fruit:resource = file
1970 fruit:metadata = stream
1971 fruit:veto_appledouble = no
1973 [vfs_fruit_stream_depot]
1975 vfs objects = fruit streams_depot acl_xattr xattr_tdb
1976 fruit:resource = stream
1977 fruit:metadata = stream
1978 fruit:veto_appledouble = no
1982 vfs objects = streams_xattr acl_xattr xattr_tdb
1984 [vfs_wo_fruit_stream_depot]
1986 vfs objects = streams_depot acl_xattr xattr_tdb
1988 [vfs_fruit_timemachine]
1990 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
1991 fruit:resource = file
1992 fruit:metadata = stream
1993 fruit:time machine = yes
1994 fruit:time machine max size = 32K
1996 [vfs_fruit_wipe_intentionally_left_blank_rfork]
1998 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
1999 fruit:resource = file
2000 fruit:metadata = stream
2001 fruit:wipe_intentionally_left_blank_rfork = true
2002 fruit:delete_empty_adfiles = false
2003 fruit:veto_appledouble = no
2005 [vfs_fruit_delete_empty_adfiles]
2007 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2008 fruit:resource = file
2009 fruit:metadata = stream
2010 fruit:wipe_intentionally_left_blank_rfork = true
2011 fruit:delete_empty_adfiles = true
2012 fruit:veto_appledouble = no
2014 [vfs_fruit_zero_fileid]
2016 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
2017 fruit:resource = file
2018 fruit:metadata = stream
2019 fruit:zero_file_id=yes
2022 path = $badnames_shrdir
2026 path = $manglenames_shrdir
2034 path = $widelinks_shrdir
2039 path = $fsrvp_shrdir
2040 comment = fake shapshots using rsync
2041 vfs objects = shell_snap shadow_copy2
2042 shell_snap:check path command = $fake_snap_pl --check
2043 shell_snap:create command = $fake_snap_pl --create
2044 shell_snap:delete command = $fake_snap_pl --delete
2045 # a relative path here fails, the snapshot dir is no longer found
2046 shadow:snapdir = $fsrvp_shrdir/.snapshots
2049 path = $shadow_shrdir
2050 comment = previous versions snapshots under mount point
2051 vfs objects = shadow_copy2
2052 shadow:mountpoint = $shadow_mntdir
2055 path = $shadow_shrdir
2056 comment = previous versions snapshots outside mount point
2057 vfs objects = shadow_copy2
2058 shadow:mountpoint = $shadow_mntdir
2059 shadow:snapdir = $shadow_tstdir/.snapshots
2062 path = $shadow_shrdir
2063 comment = previous versions with subvolume snapshots, snapshots under base dir
2064 vfs objects = shadow_copy2
2065 shadow:mountpoint = $shadow_mntdir
2066 shadow:basedir = $shadow_basedir
2067 shadow:snapdir = $shadow_basedir/.snapshots
2070 path = $shadow_shrdir
2071 comment = previous versions with subvolume snapshots, snapshots outside mount point
2072 vfs objects = shadow_copy2
2073 shadow:mountpoint = $shadow_mntdir
2074 shadow:basedir = $shadow_basedir
2075 shadow:snapdir = $shadow_tstdir/.snapshots
2078 path = $shadow_shrdir
2079 comment = previous versions at volume root snapshots under mount point
2080 vfs objects = shadow_copy2
2081 shadow:mountpoint = $shadow_shrdir
2084 path = $shadow_shrdir
2085 comment = previous versions at volume root snapshots outside mount point
2086 vfs objects = shadow_copy2
2087 shadow:mountpoint = $shadow_shrdir
2088 shadow:snapdir = $shadow_tstdir/.snapshots
2091 path = $shadow_shrdir
2092 comment = previous versions snapshots everywhere
2093 vfs objects = shadow_copy2
2094 shadow:mountpoint = $shadow_mntdir
2095 shadow:snapdirseverywhere = yes
2098 path = $shadow_shrdir
2099 comment = previous versions using snapsharepath
2100 vfs objects = shadow_copy2
2101 shadow:mountpoint = $shadow_mntdir
2102 shadow:snapdir = $shadow_tstdir/.snapshots
2103 shadow:snapsharepath = share
2106 comment = Testing shadow:format with default option
2107 vfs object = shadow_copy2
2108 path = $shadow_shrdir
2111 shadow:mountpoint = $shadow_mntdir
2112 shadow:basedir = $shadow_basedir
2113 shadow:snapdir = $shadow_basedir/.snapshots
2114 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2117 comment = Testing shadow:format with only date component
2118 vfs object = shadow_copy2
2119 path = $shadow_shrdir
2122 shadow:mountpoint = $shadow_mntdir
2123 shadow:basedir = $shadow_basedir
2124 shadow:snapdir = $shadow_basedir/.snapshots
2125 shadow:format = \@GMT-%Y-%m-%d
2128 comment = Testing shadow:format with some hardcoded prefix
2129 vfs object = shadow_copy2
2130 path = $shadow_shrdir
2133 shadow:mountpoint = $shadow_mntdir
2134 shadow:basedir = $shadow_basedir
2135 shadow:snapdir = $shadow_basedir/.snapshots
2136 shadow:format = snap\@GMT-%Y.%m.%d-%H.%M.%S
2139 comment = Testing shadow:format with modified format
2140 vfs object = shadow_copy2
2141 path = $shadow_shrdir
2144 shadow:mountpoint = $shadow_mntdir
2145 shadow:basedir = $shadow_basedir
2146 shadow:snapdir = $shadow_basedir/.snapshots
2147 shadow:format = \@GMT-%Y.%m.%d-%H_%M_%S-snap
2150 comment = Testing shadow:snapprefix regex
2151 vfs object = shadow_copy2
2152 path = $shadow_shrdir
2155 shadow:mountpoint = $shadow_mntdir
2156 shadow:basedir = $shadow_basedir
2157 shadow:snapdir = $shadow_basedir/.snapshots
2158 shadow:snapprefix = \^s[a-z]*p\$
2159 shadow:format = _GMT-%Y.%m.%d-%H.%M.%S
2162 comment = Testing shadow:snapprefix with delim regex
2163 vfs object = shadow_copy2
2164 path = $shadow_shrdir
2167 shadow:mountpoint = $shadow_mntdir
2168 shadow:basedir = $shadow_basedir
2169 shadow:snapdir = $shadow_basedir/.snapshots
2170 shadow:delimiter = \@GMT
2171 shadow:snapprefix = [a-z]*
2172 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2175 path = $shadow_shrdir
2176 comment = previous versions with wide links allowed
2177 vfs objects = shadow_copy2
2178 shadow:mountpoint = $shadow_mntdir
2182 path = $shadow_tstdir
2183 comment = previous versions snapshots under mount point
2184 vfs objects = shadow_copy2 streams_xattr error_inject
2186 error_inject:pwrite = EBADF
2187 shadow:mountpoint = $shadow_tstdir
2190 path = $shrdir/dfree
2191 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2192 admin users = $unix_name
2193 include = $dfqconffile
2195 path = $shrdir/dfree
2196 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2197 admin users = $unix_name
2198 include = $dfqconffile
2199 dfree cache time = 60
2201 path = $shrdir/dfree
2202 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2204 include = $dfqconffile
2206 path = $shrdir/quota
2207 admin users = $unix_name
2209 [acl_xattr_ign_sysacl_posix]
2211 acl_xattr:ignore system acls = yes
2212 acl_xattr:default acl style = posix
2213 [acl_xattr_ign_sysacl_windows]
2215 acl_xattr:ignore system acls = yes
2216 acl_xattr:default acl style = windows
2220 mangled names = illegal
2224 path = $nosymlinks_shrdir
2225 follow symlinks = no
2229 path = $local_symlinks_shrdir
2230 follow symlinks = yes
2234 kernel oplocks = yes
2235 vfs objects = streams_xattr xattr_tdb
2239 vfs objects = streams_xattr xattr_tdb
2243 smbd:find async delay usec = 10000
2246 vfs objects = error_inject
2247 include = $errorinjectconf
2251 vfs objects = delay_inject
2252 kernel share modes = no
2255 include = $delayinjectconf
2259 vfs objects = delay_inject
2260 delay_inject:pread_send = 2000
2261 delay_inject:pwrite_send = 2000
2264 path = $prefix_abs/share
2265 delete readonly = yes
2269 my $net = Samba::bindir_path($self, "net");
2271 $cmd .= "SMB_CONF_PATH=\"$conffile\" ";
2272 $cmd .= "$net setlocalsid $samsid";
2274 if (system($cmd) != 0) {
2275 warn("Join failed\n$cmd");
2279 unless (open(ERRORCONF, ">$errorinjectconf")) {
2280 warn("Unable to open $errorinjectconf");
2285 unless (open(DELAYCONF, ">$delayinjectconf")) {
2286 warn("Unable to open $delayinjectconf");
2291 unless (open(DFQCONF, ">$dfqconffile")) {
2292 warn("Unable to open $dfqconffile");
2298 ## create a test account
2301 unless (open(PASSWD, ">$nss_wrapper_passwd")) {
2302 warn("Unable to open $nss_wrapper_passwd");
2305 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
2306 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
2307 pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2308 pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2309 userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
2310 pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false
2311 force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false
2312 smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false
2313 user1:x:$uid_user1:$gid_nogroup:user1 gecos:$prefix_abs:/bin/false
2314 user2:x:$uid_user2:$gid_nogroup:user2 gecos:$prefix_abs:/bin/false
2315 gooduser:x:$uid_gooduser:$gid_domusers:gooduser gecos:$prefix_abs:/bin/false
2316 eviluser:x:$uid_eviluser:$gid_domusers:eviluser gecos::/bin/false
2317 slashuser:x:$uid_slashuser:$gid_domusers:slashuser gecos:/:/bin/false
2319 if ($unix_uid != 0) {
2320 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
2325 unless (open(GROUP, ">$nss_wrapper_group")) {
2326 warn("Unable to open $nss_wrapper_group");
2329 print GROUP "nobody:x:$gid_nobody:
2330 nogroup:x:$gid_nogroup:nobody
2331 $unix_name-group:x:$unix_gids[0]:
2332 domusers:X:$gid_domusers:
2333 domadmins:X:$gid_domadmins:
2334 userdup:x:$gid_userdup:$unix_name
2335 everyone:x:$gid_everyone:
2336 force_user:x:$gid_force_user:
2338 if ($unix_gids[0] != 0) {
2339 print GROUP "root:x:$gid_root:
2346 my $hostname = lc($server);
2347 unless (open(HOSTS, ">>$nss_wrapper_hosts")) {
2348 warn("Unable to open $nss_wrapper_hosts");
2351 print HOSTS "${server_ip} ${hostname}.samba.example.com ${hostname}\n";
2352 print HOSTS "${server_ipv6} ${hostname}.samba.example.com ${hostname}\n";
2356 unless (open(RESOLV_CONF, ">$resolv_conf")) {
2357 warn("Unable to open $resolv_conf");
2360 if (defined($dc_server_ip) or defined($dc_server_ipv6)) {
2361 if (defined($dc_server_ip)) {
2362 print RESOLV_CONF "nameserver $dc_server_ip\n";
2364 if (defined($dc_server_ipv6)) {
2365 print RESOLV_CONF "nameserver $dc_server_ipv6\n";
2368 print RESOLV_CONF "nameserver ${server_ip}\n";
2369 print RESOLV_CONF "nameserver ${server_ipv6}\n";
2373 foreach my $evlog (@eventlog_list) {
2374 my $evlogtdb = "$eventlogdir/$evlog.tdb";
2375 open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
2379 $createuser_env{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2380 $createuser_env{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2381 $createuser_env{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2382 $createuser_env{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2383 if ($ENV{SAMBA_DNS_FAKING}) {
2384 $createuser_env{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2386 $createuser_env{RESOLV_WRAPPER_CONF} = $resolv_conf;
2389 createuser($self, $unix_name, $password, $conffile, \%createuser_env) || die("Unable to create user");
2390 createuser($self, "force_user", $password, $conffile, \%createuser_env) || die("Unable to create force_user");
2391 createuser($self, "smbget_user", $password, $conffile, \%createuser_env) || die("Unable to create smbget_user");
2392 createuser($self, "user1", $password, $conffile, \%createuser_env) || die("Unable to create user1");
2393 createuser($self, "user2", $password, $conffile, \%createuser_env) || die("Unable to create user2");
2394 createuser($self, "gooduser", $password, $conffile, \%createuser_env) || die("Unable to create gooduser");
2395 createuser($self, "eviluser", $password, $conffile, \%createuser_env) || die("Unable to create eviluser");
2396 createuser($self, "slashuser", $password, $conffile, \%createuser_env) || die("Unable to create slashuser");
2398 open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
2399 print DNS_UPDATE_LIST "A $server. $server_ip\n";
2400 print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n";
2401 close(DNS_UPDATE_LIST);
2405 $ret{SERVER_IP} = $server_ip;
2406 $ret{SERVER_IPV6} = $server_ipv6;
2407 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
2408 $ret{NMBD_TEST_LOG_POS} = 0;
2409 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
2410 $ret{WINBINDD_TEST_LOG_POS} = 0;
2411 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
2412 $ret{SMBD_TEST_LOG_POS} = 0;
2413 $ret{SERVERCONFFILE} = $conffile;
2414 $ret{TESTENV_DIR} = $prefix_abs;
2415 $ret{CONFIGURATION} ="-s $conffile";
2416 $ret{LOCK_DIR} = $lockdir;
2417 $ret{SERVER} = $server;
2418 $ret{USERNAME} = $unix_name;
2419 $ret{USERID} = $unix_uid;
2420 $ret{DOMAIN} = $domain;
2421 $ret{SAMSID} = $samsid;
2422 $ret{NETBIOSNAME} = $server;
2423 $ret{PASSWORD} = $password;
2424 $ret{PIDDIR} = $piddir;
2425 $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir;
2426 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
2427 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
2428 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2429 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2430 $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2431 $ret{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2432 $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
2433 $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind";
2434 if ($ENV{SAMBA_DNS_FAKING}) {
2435 $ret{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2437 $ret{RESOLV_WRAPPER_CONF} = $resolv_conf;
2439 $ret{LOCAL_PATH} = "$shrdir";
2440 $ret{LOGDIR} = $logdir;
2443 # Avoid hitting system krb5.conf -
2444 # An env that needs Kerberos will reset this to the real
2447 $ret{KRB5_CONFIG} = abs_path($prefix) . "/no_krb5.conf";
2449 # Define KRB5CCNAME for each environment we set up
2450 $ret{KRB5_CCACHE} = abs_path($prefix) . "/krb5ccache";
2451 $ENV{KRB5CCNAME} = $ret{KRB5_CCACHE};
2456 sub wait_for_start($$$$$)
2458 my ($self, $envvars, $nmbd, $winbindd, $smbd) = @_;
2463 if ($nmbd eq "yes") {
2466 # give time for nbt server to register its names
2467 print "checking for nmbd\n";
2469 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
2470 my $nmblookup = Samba::bindir_path($self, "nmblookup");
2473 $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
2477 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
2478 system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
2479 system("$nmblookup $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
2480 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
2483 } while ($ret != 0 && $count < 10);
2485 print "NMBD not reachable after 10 retries\n";
2486 teardown_env($self, $envvars);
2491 if ($winbindd eq "yes") {
2492 print "checking for winbindd\n";
2494 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2495 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2496 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2497 $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping-dc";
2501 $ret = system($cmd);
2505 } while ($ret != 0 && $count < 20);
2507 print "WINBINDD not reachable after 20 seconds\n";
2508 teardown_env($self, $envvars);
2513 if ($smbd eq "yes") {
2514 # make sure smbd is also up set
2515 print "wait for smbd\n";
2519 $ret = system(Samba::bindir_path($self, "smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139");
2524 } while ($ret != 0 && $count < 20);
2526 print "SMBD failed to start up in a reasonable time (20sec)\n";
2527 teardown_env($self, $envvars);
2532 # Ensure we have domain users mapped.
2533 $netcmd = "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2534 $netcmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2535 $netcmd .= Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} ";
2537 $cmd = $netcmd . "groupmap delete ntgroup=domusers";
2538 $ret = system($cmd);
2540 $cmd = $netcmd . "groupmap add rid=513 unixgroup=domusers type=domain";
2541 $ret = system($cmd);
2543 print("\"$cmd\" failed\n");
2547 $cmd = $netcmd . "groupmap delete ntgroup=domadmins";
2548 $ret = system($cmd);
2550 $cmd = $netcmd . "groupmap add rid=512 unixgroup=domadmins type=domain";
2551 $ret = system($cmd);
2553 print("\"$cmd\" failed\n");
2557 $cmd = $netcmd . "groupmap delete ntgroup=everyone";
2558 $ret = system($cmd);
2560 $cmd = $netcmd . "groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin";
2561 $ret = system($cmd);
2563 print("\"$cmd\" failed\n");
2567 # note: creating builtin groups requires winbindd for the
2569 my $create_builtin_users = "no";
2570 if ($winbindd eq "yes") {
2571 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2572 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2573 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2574 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
2575 my $wbinfo_out = qx($cmd 2>&1);
2577 # wbinfo doesn't give us a better error code then
2578 # WBC_ERR_DOMAIN_NOT_FOUND, but at least that's
2579 # different then WBC_ERR_WINBIND_NOT_AVAILABLE
2580 if ($wbinfo_out !~ /WBC_ERR_DOMAIN_NOT_FOUND/) {
2581 print("Failed to run \"wbinfo --sid-to-gid=S-1-5-32-545\": $wbinfo_out");
2582 teardown_env($self, $envvars);
2585 $create_builtin_users = "yes";
2588 if ($create_builtin_users eq "yes") {
2589 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2590 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2591 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2592 $cmd .= Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
2593 $cmd .= "sam createbuiltingroup Users";
2594 $ret = system($cmd);
2596 print "Failed to create BUILTIN\\Users group\n";
2597 teardown_env($self, $envvars);
2601 $cmd = Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
2602 $cmd .= "cache del IDMAP/SID2XID/S-1-5-32-545";
2605 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2606 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2607 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2608 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
2609 $ret = system($cmd);
2611 print "Missing \"BUILTIN\\Users\", did net sam createbuiltingroup Users fail?\n";
2612 teardown_env($self, $envvars);
2617 print $self->getlog_env($envvars);