2 # Bootstrap Samba and run a number of tests against it.
3 # Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
4 # Published under the GNU GPL, v3 or later.
10 use FindBin qw($RealBin);
13 use File::Path 'remove_tree';
18 my $smbd_build_options = Samba::bindir_path($self, "smbd") . " -b|";
19 open(IN, $smbd_build_options) or die("Unable to run $smbd_build_options: $!");
28 # If we were not built with ADS support, pretend we were never even available
29 print "smbd does not have ADS support\n" unless $found_ads;
33 # return smb.conf parameters applicable to @path, based on the underlying
35 sub get_fs_specific_conf($$)
37 my ($self, $path) = @_;
39 my $stat_out = `stat --file-system $path` or return "";
41 if ($stat_out =~ m/Type:\s+btrfs/) {
42 $mods .= "streams_xattr btrfs";
46 return "vfs objects = $mods";
53 my ($classname, $bindir, $srcdir, $server_maxtime) = @_;
54 my $self = { vars => {},
57 server_maxtime => $server_maxtime
65 my ($self, $envvars) = @_;
68 # This should cause smbd to terminate gracefully
69 close($envvars->{STDIN_PIPE});
71 my $smbdpid = $envvars->{SMBD_TL_PID};
72 my $nmbdpid = $envvars->{NMBD_TL_PID};
73 my $winbinddpid = $envvars->{WINBINDD_TL_PID};
75 # This should give it time to write out the gcov data
77 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
78 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
79 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
82 && $winbinddchild == -1) {
89 if ($count <= 20 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
93 $self->stop_sig_term($smbdpid);
94 $self->stop_sig_term($nmbdpid);
95 $self->stop_sig_term($winbinddpid);
99 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
100 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
101 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
104 && $winbinddchild == -1) {
111 if ($count <= 10 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
115 warn("timelimit process did not quit on SIGTERM, sending SIGKILL");
116 $self->stop_sig_kill($smbdpid);
117 $self->stop_sig_kill($nmbdpid);
118 $self->stop_sig_kill($winbinddpid);
123 sub getlog_env_app($$$)
125 my ($self, $envvars, $name) = @_;
127 my $title = "$name LOG of: $envvars->{NETBIOSNAME}\n";
130 open(LOG, "<".$envvars->{$name."_TEST_LOG"});
132 seek(LOG, $envvars->{$name."_TEST_LOG_POS"}, SEEK_SET);
136 $envvars->{$name."_TEST_LOG_POS"} = tell(LOG);
139 return "" if $out eq $title;
146 my ($self, $envvars) = @_;
149 $ret .= $self->getlog_env_app($envvars, "SMBD");
150 $ret .= $self->getlog_env_app($envvars, "NMBD");
151 $ret .= $self->getlog_env_app($envvars, "WINBINDD");
158 my ($self, $envvars) = @_;
160 my $childpid = waitpid(-1, WNOHANG);
166 # Declare the environments Samba3 makes available.
167 # To be set up, they will be called as
168 # samba3->setup_$envname($self, $path, $dep_1_vars, $dep_2_vars, ...)
169 %Samba3::ENV_DEPS = (
170 # name => [dep_1, dep_2, ...],
172 nt4_dc_schannel => [],
179 nt4_member => ["nt4_dc"],
181 ad_member => ["ad_dc"],
182 ad_member_rfc2307 => ["ad_dc_ntvfs"],
183 ad_member_idmap_rid => ["ad_dc"],
184 ad_member_idmap_ad => ["ad_dc"],
189 my ($self, $path) = @_;
191 print "PROVISIONING NT4 DC...";
193 my $nt4_dc_options = "
198 raw NTLMv2 auth = yes
199 server schannel = auto
201 rpc_server:epmapper = external
202 rpc_server:spoolss = external
203 rpc_server:lsarpc = external
204 rpc_server:samr = external
205 rpc_server:netlogon = external
206 rpc_server:register_embedded_np = yes
207 rpc_server:FssagentRpc = external
209 rpc_daemon:epmd = fork
210 rpc_daemon:spoolssd = fork
211 rpc_daemon:lsasd = fork
212 rpc_daemon:fssd = fork
213 fss: sequence timeout = 1
214 check parent directory delete on close = yes
217 my $vars = $self->provision($path, "SAMBA-TEST",
222 $vars or return undef;
224 if (not $self->check_or_start($vars, "yes", "yes", "yes")) {
228 $vars->{DOMSID} = $vars->{SAMSID};
229 $vars->{DC_SERVER} = $vars->{SERVER};
230 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
231 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
232 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
233 $vars->{DC_USERNAME} = $vars->{USERNAME};
234 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
239 sub setup_nt4_dc_schannel
241 my ($self, $path) = @_;
243 print "PROVISIONING NT4 DC WITH SERVER SCHANNEL ...";
250 rpc_server:epmapper = external
251 rpc_server:spoolss = external
252 rpc_server:lsarpc = external
253 rpc_server:samr = external
254 rpc_server:netlogon = external
255 rpc_server:register_embedded_np = yes
257 rpc_daemon:epmd = fork
258 rpc_daemon:spoolssd = fork
259 rpc_daemon:lsasd = fork
261 server schannel = yes
262 # used to reproduce bug #12772
263 server max protocol = SMB2_02
266 my $vars = $self->provision($path, "NT4SCHANNEL",
271 $vars or return undef;
273 if (not $self->check_or_start($vars, "yes", "yes", "yes")) {
277 $vars->{DOMSID} = $vars->{SAMSID};
278 $vars->{DC_SERVER} = $vars->{SERVER};
279 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
280 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
281 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
282 $vars->{DC_USERNAME} = $vars->{USERNAME};
283 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
290 my ($self, $prefix, $nt4_dc_vars) = @_;
294 print "PROVISIONING MEMBER...";
296 my $require_mutexes = "dbwrap_tdb_require_mutexes:* = yes";
297 $require_mutexes = "" if ($ENV{SELFTEST_DONT_REQUIRE_TDB_MUTEX_SUPPORT} eq "1");
299 my $member_options = "
301 dbwrap_tdb_mutexes:* = yes
304 my $ret = $self->provision($prefix, $nt4_dc_vars->{DOMAIN},
306 "localnt4member3pass",
309 $ret or return undef;
311 my $nmblookup = Samba::bindir_path($self, "nmblookup");
313 print "Waiting for the LOGON SERVER registration ...\n";
314 $rc = system("$nmblookup $ret->{CONFIGURATION} $ret->{DOMAIN}\#1c");
319 } while ($rc != 0 && $count < 10);
321 print "NMBD not reachable after 10 retries\n";
322 teardown_env($self, $ret);
326 my $net = Samba::bindir_path($self, "net");
328 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
329 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
330 $cmd .= "$net rpc join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
331 $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}";
333 if (system($cmd) != 0) {
334 warn("Join failed\n$cmd");
339 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
340 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
341 $cmd .= "$net $ret->{CONFIGURATION} primarytrust dumpinfo | grep -q 'REDACTED SECRET VALUES'";
343 if (system($cmd) != 0) {
344 warn("check failed\n$cmd");
348 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
352 $ret->{DOMSID} = $nt4_dc_vars->{DOMSID};
353 $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
354 $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
355 $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
356 $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME};
357 $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME};
358 $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD};
365 my ($self, $prefix, $dcvars) = @_;
367 my $prefix_abs = abs_path($prefix);
370 # If we didn't build with ADS, pretend this env was never available
371 if (not $self->have_ads()) {
375 print "PROVISIONING S3 AD MEMBER...";
377 mkdir($prefix_abs, 0777);
379 my $share_dir="$prefix_abs/share";
380 push(@dirs, $share_dir);
382 my $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}";
383 push(@dirs, $substitution_path);
385 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice";
386 push(@dirs, $substitution_path);
388 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/U_alice/G_domain users";
389 push(@dirs, $substitution_path);
391 # Using '/' as the winbind separator is a bad idea ...
392 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}";
393 push(@dirs, $substitution_path);
395 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice";
396 push(@dirs, $substitution_path);
398 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}";
399 push(@dirs, $substitution_path);
401 $substitution_path = "$share_dir/D_$dcvars->{DOMAIN}/u_$dcvars->{DOMAIN}/alice/g_$dcvars->{DOMAIN}/domain users";
402 push(@dirs, $substitution_path);
404 my $member_options = "
406 workgroup = $dcvars->{DOMAIN}
407 realm = $dcvars->{REALM}
408 netbios aliases = foo bar
409 template homedir = /home/%D/%G/%U
412 path = $share_dir/D_%D/U_%U/G_%G
416 path = $share_dir/D_%D/u_%u/g_%g
421 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
425 $dcvars->{SERVER_IP},
426 $dcvars->{SERVER_IPV6});
428 $ret or return undef;
430 mkdir($_, 0777) foreach(@dirs);
433 $ret->{DOMAIN} = $dcvars->{DOMAIN};
434 $ret->{REALM} = $dcvars->{REALM};
435 $ret->{DOMSID} = $dcvars->{DOMSID};
439 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
440 $ctx->{domain} = $dcvars->{DOMAIN};
441 $ctx->{realm} = $dcvars->{REALM};
442 $ctx->{dnsname} = lc($dcvars->{REALM});
443 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
444 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
445 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
446 Samba::mk_krb5_conf($ctx, "");
448 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
450 my $net = Samba::bindir_path($self, "net");
452 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
453 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
454 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
456 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
458 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
459 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
460 $cmd .= "$net join $ret->{CONFIGURATION}";
461 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
463 if (system($cmd) != 0) {
464 warn("Join failed\n$cmd");
468 # We need world access to this share, as otherwise the domain
469 # administrator from the AD domain provided by Samba4 can't
470 # access the share for tests.
471 chmod 0777, "$prefix/share";
473 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
477 $ret->{DC_SERVER} = $dcvars->{SERVER};
478 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
479 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
480 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
481 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
482 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
487 sub setup_ad_member_rfc2307
489 my ($self, $prefix, $dcvars) = @_;
491 # If we didn't build with ADS, pretend this env was never available
492 if (not $self->have_ads()) {
496 print "PROVISIONING S3 AD MEMBER WITH idmap_rfc2307 config...";
498 my $member_options = "
500 workgroup = $dcvars->{DOMAIN}
501 realm = $dcvars->{REALM}
503 idmap negative cache time = 0
504 idmap config * : backend = autorid
505 idmap config * : range = 1000000-1999999
506 idmap config * : rangesize = 100000
507 idmap config $dcvars->{DOMAIN} : backend = rfc2307
508 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
509 idmap config $dcvars->{DOMAIN} : ldap_server = ad
510 idmap config $dcvars->{DOMAIN} : bind_path_user = ou=idmap,dc=samba,dc=example,dc=com
511 idmap config $dcvars->{DOMAIN} : bind_path_group = ou=idmap,dc=samba,dc=example,dc=com
513 password server = $dcvars->{SERVER}
516 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
520 $dcvars->{SERVER_IP},
521 $dcvars->{SERVER_IPV6});
523 $ret or return undef;
526 $ret->{DOMAIN} = $dcvars->{DOMAIN};
527 $ret->{REALM} = $dcvars->{REALM};
528 $ret->{DOMSID} = $dcvars->{DOMSID};
531 my $prefix_abs = abs_path($prefix);
533 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
534 $ctx->{domain} = $dcvars->{DOMAIN};
535 $ctx->{realm} = $dcvars->{REALM};
536 $ctx->{dnsname} = lc($dcvars->{REALM});
537 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
538 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
539 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
540 Samba::mk_krb5_conf($ctx, "");
542 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
544 my $net = Samba::bindir_path($self, "net");
546 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
547 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
548 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
550 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
552 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
553 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
554 $cmd .= "$net join $ret->{CONFIGURATION}";
555 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
557 if (system($cmd) != 0) {
558 warn("Join failed\n$cmd");
562 # We need world access to this share, as otherwise the domain
563 # administrator from the AD domain provided by Samba4 can't
564 # access the share for tests.
565 chmod 0777, "$prefix/share";
567 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
571 $ret->{DC_SERVER} = $dcvars->{SERVER};
572 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
573 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
574 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
575 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
576 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
581 sub setup_ad_member_idmap_rid
583 my ($self, $prefix, $dcvars) = @_;
585 # If we didn't build with ADS, pretend this env was never available
586 if (not $self->have_ads()) {
590 print "PROVISIONING S3 AD MEMBER WITH idmap_rid config...";
592 my $member_options = "
594 workgroup = $dcvars->{DOMAIN}
595 realm = $dcvars->{REALM}
596 idmap config * : backend = tdb
597 idmap config * : range = 1000000-1999999
598 idmap config $dcvars->{DOMAIN} : backend = rid
599 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
602 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
606 $dcvars->{SERVER_IP},
607 $dcvars->{SERVER_IPV6});
609 $ret or return undef;
612 $ret->{DOMAIN} = $dcvars->{DOMAIN};
613 $ret->{REALM} = $dcvars->{REALM};
614 $ret->{DOMSID} = $dcvars->{DOMSID};
617 my $prefix_abs = abs_path($prefix);
619 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
620 $ctx->{domain} = $dcvars->{DOMAIN};
621 $ctx->{realm} = $dcvars->{REALM};
622 $ctx->{dnsname} = lc($dcvars->{REALM});
623 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
624 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
625 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
626 Samba::mk_krb5_conf($ctx, "");
628 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
630 my $net = Samba::bindir_path($self, "net");
632 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
633 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
634 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
636 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
638 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
639 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
640 $cmd .= "$net join $ret->{CONFIGURATION}";
641 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
643 if (system($cmd) != 0) {
644 warn("Join failed\n$cmd");
648 # We need world access to this share, as otherwise the domain
649 # administrator from the AD domain provided by Samba4 can't
650 # access the share for tests.
651 chmod 0777, "$prefix/share";
653 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
657 $ret->{DC_SERVER} = $dcvars->{SERVER};
658 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
659 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
660 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
661 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
662 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
667 sub setup_ad_member_idmap_ad
669 my ($self, $prefix, $dcvars) = @_;
671 # If we didn't build with ADS, pretend this env was never available
672 if (not $self->have_ads()) {
676 print "PROVISIONING S3 AD MEMBER WITH idmap_ad config...";
678 my $member_options = "
680 workgroup = $dcvars->{DOMAIN}
681 realm = $dcvars->{REALM}
682 password server = $dcvars->{SERVER}
683 idmap config * : backend = tdb
684 idmap config * : range = 1000000-1999999
685 idmap config $dcvars->{DOMAIN} : backend = ad
686 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
689 my $ret = $self->provision($prefix, $dcvars->{DOMAIN},
693 $dcvars->{SERVER_IP},
694 $dcvars->{SERVER_IPV6});
696 $ret or return undef;
699 $ret->{DOMAIN} = $dcvars->{DOMAIN};
700 $ret->{REALM} = $dcvars->{REALM};
701 $ret->{DOMSID} = $dcvars->{DOMSID};
704 my $prefix_abs = abs_path($prefix);
706 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
707 $ctx->{domain} = $dcvars->{DOMAIN};
708 $ctx->{realm} = $dcvars->{REALM};
709 $ctx->{dnsname} = lc($dcvars->{REALM});
710 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
711 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
712 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
713 Samba::mk_krb5_conf($ctx, "");
715 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
717 my $net = Samba::bindir_path($self, "net");
719 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
720 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
721 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
723 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
725 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
726 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
727 $cmd .= "$net join $ret->{CONFIGURATION}";
728 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
730 if (system($cmd) != 0) {
731 warn("Join failed\n$cmd");
735 # We need world access to this share, as otherwise the domain
736 # administrator from the AD domain provided by Samba4 can't
737 # access the share for tests.
738 chmod 0777, "$prefix/share";
740 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
744 $ret->{DC_SERVER} = $dcvars->{SERVER};
745 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
746 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
747 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
748 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
749 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
754 sub setup_simpleserver
756 my ($self, $path) = @_;
758 print "PROVISIONING simple server...";
760 my $prefix_abs = abs_path($path);
762 my $simpleserver_options = "
765 vfs objects = xattr_tdb streams_depot time_audit full_audit
769 full_audit:syslog = no
770 full_audit:success = none
771 full_audit:failure = none
774 path = $prefix_abs/share
776 vfs objects = aio_pthread
777 aio_pthread:aio open = yes
778 smbd:async dosmode = no
780 [vfs_aio_pthread_async_dosmode_default1]
781 path = $prefix_abs/share
783 vfs objects = aio_pthread
784 store dos attributes = yes
785 aio_pthread:aio open = yes
786 smbd:async dosmode = yes
788 [vfs_aio_pthread_async_dosmode_default2]
789 path = $prefix_abs/share
791 vfs objects = aio_pthread xattr_tdb
792 store dos attributes = yes
793 aio_pthread:aio open = yes
794 smbd:async dosmode = yes
796 [vfs_aio_pthread_async_dosmode_force_sync1]
797 path = $prefix_abs/share
799 vfs objects = aio_pthread
800 store dos attributes = yes
801 aio_pthread:aio open = yes
802 smbd:async dosmode = yes
803 # This simulates non linux systems
804 smbd:force sync user path safe threadpool = yes
805 smbd:force sync user chdir safe threadpool = yes
806 smbd:force sync root path safe threadpool = yes
807 smbd:force sync root chdir safe threadpool = yes
809 [vfs_aio_pthread_async_dosmode_force_sync2]
810 path = $prefix_abs/share
812 vfs objects = aio_pthread xattr_tdb
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
823 path = $prefix_abs/share
824 vfs objects = aio_fork
826 vfs_aio_fork:erratic_testing_mode=yes
829 path = $prefix_abs/share
831 store dos attributes = yes
832 hide files = /hidefile/
836 path = $prefix_abs/share
838 smb encrypt = desired
841 my $vars = $self->provision($path, "WORKGROUP",
844 $simpleserver_options);
846 $vars or return undef;
848 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
857 my ($self, $path) = @_;
858 my $prefix_abs = abs_path($path);
859 my $srcdir_abs = abs_path($self->{srcdir});
861 print "PROVISIONING file server ...\n";
865 mkdir($prefix_abs, 0777);
867 my $usershare_dir="$prefix_abs/lib/usershare";
869 mkdir("$prefix_abs/lib", 0755);
870 remove_tree($usershare_dir);
871 mkdir($usershare_dir, 01770);
873 my $share_dir="$prefix_abs/share";
875 # Create share directory structure
876 my $lower_case_share_dir="$share_dir/lower-case";
877 push(@dirs, $lower_case_share_dir);
879 my $lower_case_share_dir_30000="$share_dir/lower-case-30000";
880 push(@dirs, $lower_case_share_dir_30000);
882 my $dfree_share_dir="$share_dir/dfree";
883 push(@dirs, $dfree_share_dir);
884 push(@dirs, "$dfree_share_dir/subdir1");
885 push(@dirs, "$dfree_share_dir/subdir2");
886 push(@dirs, "$dfree_share_dir/subdir3");
888 my $valid_users_sharedir="$share_dir/valid_users";
889 push(@dirs,$valid_users_sharedir);
891 my $offline_sharedir="$share_dir/offline";
892 push(@dirs,$offline_sharedir);
894 my $force_user_valid_users_dir = "$share_dir/force_user_valid_users";
895 push(@dirs, $force_user_valid_users_dir);
897 my $smbget_sharedir="$share_dir/smbget";
898 push(@dirs,$smbget_sharedir);
900 my $tarmode_sharedir="$share_dir/tarmode";
901 push(@dirs,$tarmode_sharedir);
903 my $usershare_sharedir="$share_dir/usershares";
904 push(@dirs,$usershare_sharedir);
906 my $fileserver_options = "
907 kernel change notify = yes
909 usershare path = $usershare_dir
910 usershare max shares = 10
911 usershare allow guests = yes
912 usershare prefix allow list = $usershare_sharedir
915 path = $lower_case_share_dir
916 comment = smb username is [%U]
917 case sensitive = True
920 short preserve case = no
922 path = $lower_case_share_dir_30000
923 comment = smb username is [%U]
924 case sensitive = True
927 short preserve case = no
929 path = $dfree_share_dir
930 comment = smb username is [%U]
931 dfree command = $srcdir_abs/testprogs/blackbox/dfree.sh
933 path = $valid_users_sharedir
934 valid users = +userdup
936 path = $offline_sharedir
937 vfs objects = offline
939 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878
940 # RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651
941 [force_user_valid_users]
942 path = $force_user_valid_users_dir
943 comment = force user with valid users combination test share
944 valid users = +force_user
945 force user = force_user
946 force group = everyone
947 write list = force_user
950 path = $smbget_sharedir
951 comment = smb username is [%U]
955 comment = ignore system acls
956 acl_xattr:ignore system acls = yes
959 comment = inherit owner
963 comment = inherit only unix owner
964 inherit owner = unix only
965 acl_xattr:ignore system acls = yes
968 my $vars = $self->provision($path, "WORKGROUP",
976 $vars or return undef;
978 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
983 mkdir($_, 0777) foreach(@dirs);
985 ## Create case sensitive lower case share dir
986 foreach my $file ('a'..'z') {
987 my $full_path = $lower_case_share_dir . '/' . $file;
988 open my $fh, '>', $full_path;
989 # Add some content to file
990 print $fh $full_path;
994 for (my $file = 1; $file < 51; ++$file) {
995 my $full_path = $lower_case_share_dir . '/' . $file;
996 open my $fh, '>', $full_path;
997 # Add some content to file
998 print $fh $full_path;
1002 # Create content for 30000 share
1003 foreach my $file ('a'..'z') {
1004 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1005 open my $fh, '>', $full_path;
1006 # Add some content to file
1007 print $fh $full_path;
1011 for (my $file = 1; $file < 30001; ++$file) {
1012 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
1013 open my $fh, '>', $full_path;
1014 # Add some content to file
1015 print $fh $full_path;
1020 ## create a listable file in valid_users_share
1022 my $valid_users_target = "$valid_users_sharedir/foo";
1023 unless (open(VALID_USERS_TARGET, ">$valid_users_target")) {
1024 warn("Unable to open $valid_users_target");
1027 close(VALID_USERS_TARGET);
1028 chmod 0644, $valid_users_target;
1035 my ($self, $prefix) = @_;
1037 # If we didn't build with ADS, pretend this env was never available
1038 if (not $self->have_ads()) {
1042 print "PROVISIONING server with security=ads...";
1044 my $ktest_options = "
1046 realm = ktest.samba.example.com
1048 username map = $prefix/lib/username.map
1049 server signing = required
1050 server min protocol = SMB3_00
1051 client max protocol = SMB3
1053 # This disables NTLM auth against the local SAM, which
1054 # we use can then test this setting by.
1055 ntlm auth = disabled
1058 my $ret = $self->provision($prefix, "KTEST",
1063 $ret or return undef;
1066 my $prefix_abs = abs_path($prefix);
1068 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
1069 $ctx->{domain} = "KTEST";
1070 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
1071 $ctx->{dnsname} = lc($ctx->{realm});
1072 $ctx->{kdc_ipv4} = "0.0.0.0";
1073 $ctx->{kdc_ipv6} = "::";
1074 $ctx->{krb5_ccname} = "$prefix_abs/krb5cc_%{uid}";
1075 Samba::mk_krb5_conf($ctx, "");
1077 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
1079 open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map");
1081 $ret->{USERNAME} = KTEST\\Administrator
1085 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
1086 #Samba4 DC with the same parameters as are being used here. The
1087 #domain SID is S-1-5-21-1071277805-689288055-3486227160
1088 $ret->{SAMSID} = "S-1-5-21-1911091480-1468226576-2729736297";
1089 $ret->{DOMSID} = "S-1-5-21-1071277805-689288055-3486227160";
1091 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
1092 chmod 0600, "$prefix/private/secrets.tdb";
1094 #Make sure there's no old ntdb file.
1095 system("rm -f $prefix/private/secrets.ntdb");
1097 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
1098 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
1100 #and having in krb5.conf:
1101 # ticket_lifetime = 799718400
1102 # renew_lifetime = 799718400
1104 # The commands for the -2 keytab where were:
1105 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
1106 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
1107 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
1108 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1109 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
1111 # and then for the -3 keytab, I did
1113 # net changetrustpw; kdestroy and the same again.
1115 # This creates a credential cache with a very long lifetime (2036 at
1116 # at 2011-04), and shows that running 'net changetrustpw' does not
1117 # break existing logins (for the secrets.tdb method at least).
1120 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
1122 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
1123 chmod 0600, "$prefix/krb5_ccache-2";
1125 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
1126 chmod 0600, "$prefix/krb5_ccache-3";
1128 # We need world access to this share, as otherwise the domain
1129 # administrator from the AD domain provided by ktest can't
1130 # access the share for tests.
1131 chmod 0777, "$prefix/share";
1133 if (not $self->check_or_start($ret, "yes", "no", "yes")) {
1139 sub setup_maptoguest
1141 my ($self, $path) = @_;
1143 print "PROVISIONING maptoguest...";
1146 map to guest = bad user
1150 my $vars = $self->provision($path, "WORKGROUP",
1155 $vars or return undef;
1157 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
1164 sub stop_sig_term($$) {
1165 my ($self, $pid) = @_;
1166 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1169 sub stop_sig_kill($$) {
1170 my ($self, $pid) = @_;
1171 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
1176 my ($env_vars, $app, $pid) = @_;
1178 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
1185 my ($env_vars, $app) = @_;
1187 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
1193 sub check_or_start($$$$$) {
1194 my ($self, $env_vars, $nmbd, $winbindd, $smbd) = @_;
1196 # use a pipe for stdin in the child processes. This allows
1197 # those processes to monitor the pipe for EOF to ensure they
1198 # exit when the test script exits
1199 pipe(STDIN_READER, $env_vars->{STDIN_PIPE});
1201 unlink($env_vars->{NMBD_TEST_LOG});
1202 print "STARTING NMBD...";
1205 open STDOUT, ">$env_vars->{NMBD_TEST_LOG}";
1206 open STDERR, '>&STDOUT';
1208 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1210 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1211 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.nmbd";
1212 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1213 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1215 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1216 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1217 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1218 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1219 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1220 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1221 $ENV{UID_WRAPPER_ROOT} = "1";
1223 $ENV{ENVNAME} = "$ENV{ENVNAME}.nmbd";
1225 if ($nmbd ne "yes") {
1226 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1227 my $signame = shift;
1228 print("Skip nmbd received signal $signame");
1231 sleep($self->{server_maxtime});
1235 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "nmbd");
1236 my @optargs = ("-d0");
1237 if (defined($ENV{NMBD_OPTIONS})) {
1238 @optargs = split(/ /, $ENV{NMBD_OPTIONS});
1240 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1241 if(defined($ENV{NMBD_VALGRIND})) {
1242 @preargs = split(/ /, $ENV{NMBD_VALGRIND});
1244 my @args = ("-F", "--no-process-group",
1245 "-s", $env_vars->{SERVERCONFFILE},
1246 "-l", $env_vars->{LOGDIR});
1247 if (not defined($ENV{NMBD_DONT_LOG_STDOUT})) {
1248 push(@args, "--log-stdout");
1251 close($env_vars->{STDIN_PIPE});
1252 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1254 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1255 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1257 $env_vars->{NMBD_TL_PID} = $pid;
1258 write_pid($env_vars, "nmbd", $pid);
1261 unlink($env_vars->{WINBINDD_TEST_LOG});
1262 print "STARTING WINBINDD...";
1265 open STDOUT, ">$env_vars->{WINBINDD_TEST_LOG}";
1266 open STDERR, '>&STDOUT';
1268 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1270 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1271 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.winbindd";
1272 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1273 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1275 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1276 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1277 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1278 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1279 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1280 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1281 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
1282 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
1284 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
1286 $ENV{UID_WRAPPER_ROOT} = "1";
1288 $ENV{ENVNAME} = "$ENV{ENVNAME}.winbindd";
1290 if ($winbindd ne "yes") {
1291 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1292 my $signame = shift;
1293 print("Skip winbindd received signal $signame");
1296 sleep($self->{server_maxtime});
1300 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "winbindd");
1301 my @optargs = ("-d0");
1302 if (defined($ENV{WINBINDD_OPTIONS})) {
1303 @optargs = split(/ /, $ENV{WINBINDD_OPTIONS});
1305 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1306 if(defined($ENV{WINBINDD_VALGRIND})) {
1307 @preargs = split(/ /, $ENV{WINBINDD_VALGRIND});
1309 my @args = ("-F", "--no-process-group",
1310 "-s", $env_vars->{SERVERCONFFILE},
1311 "-l", $env_vars->{LOGDIR});
1312 if (not defined($ENV{WINBINDD_DONT_LOG_STDOUT})) {
1313 push(@args, "--stdout");
1316 close($env_vars->{STDIN_PIPE});
1317 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1319 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1320 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1322 $env_vars->{WINBINDD_TL_PID} = $pid;
1323 write_pid($env_vars, "winbindd", $pid);
1326 unlink($env_vars->{SMBD_TEST_LOG});
1327 print "STARTING SMBD...";
1330 open STDOUT, ">$env_vars->{SMBD_TEST_LOG}";
1331 open STDERR, '>&STDOUT';
1333 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1335 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1336 $ENV{KRB5CCNAME} = "$env_vars->{KRB5_CCACHE}.smbd";
1337 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1338 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1340 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1341 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1342 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1343 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1344 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1345 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1346 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
1347 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
1349 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
1351 $ENV{UID_WRAPPER_ROOT} = "1";
1353 $ENV{ENVNAME} = "$ENV{ENVNAME}.smbd";
1355 if ($smbd ne "yes") {
1356 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1357 my $signame = shift;
1358 print("Skip smbd received signal $signame");
1361 sleep($self->{server_maxtime});
1365 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "smbd");
1366 my @optargs = ("-d0");
1367 if (defined($ENV{SMBD_OPTIONS})) {
1368 @optargs = split(/ /, $ENV{SMBD_OPTIONS});
1370 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1371 if(defined($ENV{SMBD_VALGRIND})) {
1372 @preargs = split(/ /,$ENV{SMBD_VALGRIND});
1374 my @args = ("-F", "--no-process-group",
1375 "-s", $env_vars->{SERVERCONFFILE},
1376 "-l", $env_vars->{LOGDIR});
1377 if (not defined($ENV{SMBD_DONT_LOG_STDOUT})) {
1378 push(@args, "--log-stdout");
1381 close($env_vars->{STDIN_PIPE});
1382 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1384 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1385 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1387 $env_vars->{SMBD_TL_PID} = $pid;
1388 write_pid($env_vars, "smbd", $pid);
1391 close(STDIN_READER);
1393 return $self->wait_for_start($env_vars, $nmbd, $winbindd, $smbd);
1396 sub createuser($$$$$)
1398 my ($self, $username, $password, $conffile, $env) = @_;
1399 my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $username > /dev/null";
1402 while(my($var, $val) = each %$env) {
1403 $cmd = "$var=\"$val\" $cmd";
1406 unless (open(PWD, "|$cmd")) {
1407 warn("Unable to set password for $username account\n$cmd");
1410 print PWD "$password\n$password\n";
1411 unless (close(PWD)) {
1412 warn("Unable to set password for $username account\n$cmd");
1417 sub provision($$$$$$$$$)
1419 my ($self, $prefix, $domain, $server, $password, $extra_options, $dc_server_ip, $dc_server_ipv6, $no_delete_prefix) = @_;
1422 ## setup the various environment variables we need
1425 my $samsid = Samba::random_domain_sid();
1426 my $swiface = Samba::get_interface($server);
1428 my %createuser_env = ();
1429 my $server_ip = "127.0.0.$swiface";
1430 my $server_ipv6 = sprintf("fd00:0000:0000:0000:0000:0000:5357:5f%02x", $swiface);
1432 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
1435 my $unix_gids_str = $);
1436 my @unix_gids = split(" ", $unix_gids_str);
1438 my $prefix_abs = abs_path($prefix);
1439 my $bindir_abs = abs_path($self->{bindir});
1443 my $shrdir="$prefix_abs/share";
1444 push(@dirs,$shrdir);
1446 my $libdir="$prefix_abs/lib";
1447 push(@dirs,$libdir);
1449 my $piddir="$prefix_abs/pid";
1450 push(@dirs,$piddir);
1452 my $privatedir="$prefix_abs/private";
1453 push(@dirs,$privatedir);
1455 my $binddnsdir = "$prefix_abs/bind-dns";
1456 push(@dirs, $binddnsdir);
1458 my $lockdir="$prefix_abs/lockdir";
1459 push(@dirs,$lockdir);
1461 my $eventlogdir="$prefix_abs/lockdir/eventlog";
1462 push(@dirs,$eventlogdir);
1464 my $logdir="$prefix_abs/logs";
1465 push(@dirs,$logdir);
1467 my $driver32dir="$shrdir/W32X86";
1468 push(@dirs,$driver32dir);
1470 my $driver64dir="$shrdir/x64";
1471 push(@dirs,$driver64dir);
1473 my $driver40dir="$shrdir/WIN40";
1474 push(@dirs,$driver40dir);
1476 my $ro_shrdir="$shrdir/root-tmp";
1477 push(@dirs,$ro_shrdir);
1479 my $msdfs_shrdir="$shrdir/msdfsshare";
1480 push(@dirs,$msdfs_shrdir);
1482 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
1483 push(@dirs,$msdfs_deeppath);
1485 my $badnames_shrdir="$shrdir/badnames";
1486 push(@dirs,$badnames_shrdir);
1488 my $lease1_shrdir="$shrdir/SMB2_10";
1489 push(@dirs,$lease1_shrdir);
1491 my $lease2_shrdir="$shrdir/SMB3_00";
1492 push(@dirs,$lease2_shrdir);
1494 my $manglenames_shrdir="$shrdir/manglenames";
1495 push(@dirs,$manglenames_shrdir);
1497 my $widelinks_shrdir="$shrdir/widelinks";
1498 push(@dirs,$widelinks_shrdir);
1500 my $widelinks_linkdir="$shrdir/widelinks_foo";
1501 push(@dirs,$widelinks_linkdir);
1503 my $shadow_tstdir="$shrdir/shadow";
1504 push(@dirs,$shadow_tstdir);
1505 my $shadow_mntdir="$shadow_tstdir/mount";
1506 push(@dirs,$shadow_mntdir);
1507 my $shadow_basedir="$shadow_mntdir/base";
1508 push(@dirs,$shadow_basedir);
1509 my $shadow_shrdir="$shadow_basedir/share";
1510 push(@dirs,$shadow_shrdir);
1512 my $nosymlinks_shrdir="$shrdir/nosymlinks";
1513 push(@dirs,$nosymlinks_shrdir);
1515 my $local_symlinks_shrdir="$shrdir/local_symlinks";
1516 push(@dirs,$local_symlinks_shrdir);
1518 # this gets autocreated by winbindd
1519 my $wbsockdir="$prefix_abs/winbindd";
1521 my $nmbdsockdir="$prefix_abs/nmbd";
1522 unlink($nmbdsockdir);
1525 ## create the test directory layout
1527 die ("prefix_abs = ''") if $prefix_abs eq "";
1528 die ("prefix_abs = '/'") if $prefix_abs eq "/";
1530 mkdir($prefix_abs, 0777);
1531 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
1532 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
1533 system("rm -rf $prefix_abs/*");
1535 mkdir($_, 0777) foreach(@dirs);
1537 my $fs_specific_conf = $self->get_fs_specific_conf($shrdir);
1540 ## lockdir and piddir must be 0755
1542 chmod 0755, $lockdir;
1543 chmod 0755, $piddir;
1547 ## create ro and msdfs share layout
1550 chmod 0755, $ro_shrdir;
1551 my $unreadable_file = "$ro_shrdir/unreadable_file";
1552 unless (open(UNREADABLE_FILE, ">$unreadable_file")) {
1553 warn("Unable to open $unreadable_file");
1556 close(UNREADABLE_FILE);
1557 chmod 0600, $unreadable_file;
1559 my $msdfs_target = "$ro_shrdir/msdfs-target";
1560 unless (open(MSDFS_TARGET, ">$msdfs_target")) {
1561 warn("Unable to open $msdfs_target");
1564 close(MSDFS_TARGET);
1565 chmod 0666, $msdfs_target;
1566 symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp",
1567 "$msdfs_shrdir/msdfs-src1";
1568 symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
1571 ## create bad names in $badnames_shrdir
1573 ## (An invalid name, would be mangled to 8.3).
1574 my $badname_target = "$badnames_shrdir/\340|\231\216\377\177";
1575 unless (open(BADNAME_TARGET, ">$badname_target")) {
1576 warn("Unable to open $badname_target");
1579 close(BADNAME_TARGET);
1580 chmod 0666, $badname_target;
1582 ## (A bad name, would not be mangled to 8.3).
1583 my $badname_target = "$badnames_shrdir/\240\276\346\327\377\177";
1584 unless (open(BADNAME_TARGET, ">$badname_target")) {
1585 warn("Unable to open $badname_target");
1588 close(BADNAME_TARGET);
1589 chmod 0666, $badname_target;
1591 ## (A bad good name).
1592 my $badname_target = "$badnames_shrdir/blank.txt";
1593 unless (open(BADNAME_TARGET, ">$badname_target")) {
1594 warn("Unable to open $badname_target");
1597 close(BADNAME_TARGET);
1598 chmod 0666, $badname_target;
1601 ## create mangleable directory names in $manglenames_shrdir
1603 my $manglename_target = "$manglenames_shrdir/foo:bar";
1604 mkdir($manglename_target, 0777);
1607 ## create symlinks for widelinks tests.
1609 my $widelinks_target = "$widelinks_linkdir/target";
1610 unless (open(WIDELINKS_TARGET, ">$widelinks_target")) {
1611 warn("Unable to open $widelinks_target");
1614 close(WIDELINKS_TARGET);
1615 chmod 0666, $widelinks_target;
1617 ## This link should get ACCESS_DENIED
1619 symlink "$widelinks_target", "$widelinks_shrdir/source";
1621 ## This link should be allowed
1623 symlink "$widelinks_shrdir", "$widelinks_shrdir/dot";
1625 my $conffile="$libdir/server.conf";
1626 my $dfqconffile="$libdir/dfq.conf";
1628 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/third_party/nss_wrapper/nss_wrapper.pl";
1629 my $nss_wrapper_passwd = "$privatedir/passwd";
1630 my $nss_wrapper_group = "$privatedir/group";
1631 my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts";
1632 my $resolv_conf = "$privatedir/resolv.conf";
1633 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
1635 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
1637 my $fake_snap_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/fake_snap.pl";
1639 my @eventlog_list = ("dns server", "application");
1642 ## calculate uids and gids
1645 my ($max_uid, $max_gid);
1646 my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
1647 my ($uid_pdbtest_wkn);
1649 my ($uid_force_user);
1650 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
1651 my ($gid_userdup, $gid_everyone);
1652 my ($gid_force_user);
1656 if ($unix_uid < 0xffff - 10) {
1659 $max_uid = $unix_uid;
1662 $uid_root = $max_uid - 1;
1663 $uid_nobody = $max_uid - 2;
1664 $uid_pdbtest = $max_uid - 3;
1665 $uid_pdbtest2 = $max_uid - 4;
1666 $uid_userdup = $max_uid - 5;
1667 $uid_pdbtest_wkn = $max_uid - 6;
1668 $uid_force_user = $max_uid - 7;
1669 $uid_smbget = $max_uid - 8;
1670 $uid_user1 = $max_uid - 9;
1671 $uid_user2 = $max_uid - 10;
1673 if ($unix_gids[0] < 0xffff - 8) {
1676 $max_gid = $unix_gids[0];
1679 $gid_nobody = $max_gid - 1;
1680 $gid_nogroup = $max_gid - 2;
1681 $gid_root = $max_gid - 3;
1682 $gid_domusers = $max_gid - 4;
1683 $gid_domadmins = $max_gid - 5;
1684 $gid_userdup = $max_gid - 6;
1685 $gid_everyone = $max_gid - 7;
1686 $gid_force_user = $max_gid - 8;
1692 unless (open(CONF, ">$conffile")) {
1693 warn("Unable to open $conffile");
1698 netbios name = $server
1699 interfaces = $server_ip/8 $server_ipv6/64
1700 bind interfaces only = yes
1701 panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
1702 smbd:suicide mode = yes
1706 private dir = $privatedir
1707 binddns dir = $binddnsdir
1708 pid directory = $piddir
1709 lock directory = $lockdir
1710 log file = $logdir/log.\%m
1715 state directory = $lockdir
1716 cache directory = $lockdir
1718 passdb backend = tdbsam
1722 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1723 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
1724 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1725 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
1726 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
1727 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
1728 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
1730 addprinter command = $mod_printer_pl -a -s $conffile --
1731 deleteprinter command = $mod_printer_pl -d -s $conffile --
1733 eventlog list = application \"dns server\"
1736 kernel change notify = no
1740 printcap name = /dev/null
1742 winbindd socket directory = $wbsockdir
1743 nmbd:socket dir = $nmbdsockdir
1744 idmap config * : range = 100000-200000
1745 winbind enum users = yes
1746 winbind enum groups = yes
1747 winbind separator = /
1748 include system krb5 conf = no
1750 # min receivefile size = 4000
1754 smbd:sharedelay = 100000
1755 smbd:writetimeupdatedelay = 500000
1759 store dos attributes = yes
1764 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot
1767 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
1768 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
1769 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
1770 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
1771 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
1772 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
1773 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
1775 print notify backchannel = yes
1777 ncalrpc dir = $prefix_abs/ncalrpc
1779 # The samba3.blackbox.smbclient_s3 test uses this to test that
1780 # sending messages works, and that the %m sub works.
1781 message command = mv %s $shrdir/message.%m
1783 # fsrvp server requires registry shares
1784 registry shares = yes
1786 # Used by RPC SRVSVC tests
1787 add share command = $bindir_abs/smbaddshare
1788 change share command = $bindir_abs/smbchangeshare
1789 delete share command = $bindir_abs/smbdeleteshare
1791 # fruit:copyfile is a global option
1792 fruit:copyfile = yes
1794 #this does not mean that we use non-secure test env,
1795 #it just means we ALLOW one to be configured.
1796 allow insecure wide links = yes
1798 # Begin extra options
1802 #Include user defined custom parameters if set
1805 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
1806 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
1812 comment = smb username is [%U]
1815 comment = Load dirsort module
1816 vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot
1819 comment = encrypt smb username is [%U]
1820 smb encrypt = required
1821 vfs objects = dirsort
1831 force user = $unix_name
1833 [forceuser_unixonly]
1834 comment = force a user with unix user SID and group SID
1836 force user = pdbtest
1838 [forceuser_wkngroup]
1839 comment = force a user with well-known group SID
1841 force user = pdbtest_wkn
1845 force group = nogroup
1853 write list = $unix_name
1856 valid users = $unix_name
1857 access based share enum = yes
1859 path = $msdfs_shrdir
1861 msdfs shuffle referrals = yes
1865 hide unreadable = yes
1868 case sensitive = yes
1871 hide unwriteable files = yes
1874 kernel share modes = no
1888 default devmode = no
1894 comment = smb username is [%U]
1896 nfs4acl_xattr:version = 40
1897 vfs objects = nfs4acl_xattr xattr_tdb
1899 [nfs4acl_special_40]
1901 comment = smb username is [%U]
1903 nfs4acl_xattr:version = 40
1904 vfs objects = nfs4acl_xattr xattr_tdb
1908 comment = smb username is [%U]
1910 vfs objects = nfs4acl_xattr xattr_tdb
1914 comment = smb username is [%U]
1915 vfs objects = nfs4acl_xattr xattr_tdb
1917 nfs4acl_xattr:encoding = xdr
1918 nfs4acl_xattr:version = 40
1922 comment = smb username is [%U]
1923 vfs objects = nfs4acl_xattr xattr_tdb
1925 nfs4acl_xattr:encoding = xdr
1926 nfs4acl_xattr:version = 41
1930 comment = smb username is [%U]
1932 force create mode = 777
1935 comment = smb username is [%U]
1937 force create mode = 0
1938 directory mask = 0777
1939 force directory mode = 0
1940 vfs objects = xattr_tdb streams_depot
1951 vfs objects = catia fruit streams_xattr acl_xattr xattr_tdb
1952 fruit:resource = file
1953 fruit:metadata = netatalk
1954 fruit:locking = netatalk
1955 fruit:encoding = native
1956 fruit:veto_appledouble = no
1960 # This is used by vfs.fruit tests that require real fs xattr
1961 vfs objects = catia fruit streams_xattr acl_xattr
1962 fruit:resource = file
1963 fruit:metadata = netatalk
1964 fruit:locking = netatalk
1965 fruit:encoding = native
1966 fruit:veto_appledouble = no
1968 [vfs_fruit_metadata_stream]
1970 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
1971 fruit:resource = file
1972 fruit:metadata = stream
1973 fruit:veto_appledouble = no
1975 [vfs_fruit_stream_depot]
1977 vfs objects = fruit streams_depot acl_xattr xattr_tdb
1978 fruit:resource = stream
1979 fruit:metadata = stream
1980 fruit:veto_appledouble = no
1984 vfs objects = streams_xattr acl_xattr xattr_tdb
1986 [vfs_wo_fruit_stream_depot]
1988 vfs objects = streams_depot acl_xattr xattr_tdb
1990 [vfs_fruit_timemachine]
1992 vfs objects = fruit streams_xattr acl_xattr xattr_tdb
1993 fruit:resource = file
1994 fruit:metadata = stream
1995 fruit:time machine = yes
1996 fruit:time machine max size = 32K
1999 path = $badnames_shrdir
2003 path = $manglenames_shrdir
2011 path = $widelinks_shrdir
2017 comment = fake shapshots using rsync
2018 vfs objects = shell_snap shadow_copy2
2019 shell_snap:check path command = $fake_snap_pl --check
2020 shell_snap:create command = $fake_snap_pl --create
2021 shell_snap:delete command = $fake_snap_pl --delete
2022 # a relative path here fails, the snapshot dir is no longer found
2023 shadow:snapdir = $shrdir/.snapshots
2026 path = $shadow_shrdir
2027 comment = previous versions snapshots under mount point
2028 vfs objects = shadow_copy2
2029 shadow:mountpoint = $shadow_mntdir
2032 path = $shadow_shrdir
2033 comment = previous versions snapshots outside mount point
2034 vfs objects = shadow_copy2
2035 shadow:mountpoint = $shadow_mntdir
2036 shadow:snapdir = $shadow_tstdir/.snapshots
2039 path = $shadow_shrdir
2040 comment = previous versions with subvolume snapshots, snapshots under base dir
2041 vfs objects = shadow_copy2
2042 shadow:mountpoint = $shadow_mntdir
2043 shadow:basedir = $shadow_basedir
2044 shadow:snapdir = $shadow_basedir/.snapshots
2047 path = $shadow_shrdir
2048 comment = previous versions with subvolume snapshots, snapshots outside mount point
2049 vfs objects = shadow_copy2
2050 shadow:mountpoint = $shadow_mntdir
2051 shadow:basedir = $shadow_basedir
2052 shadow:snapdir = $shadow_tstdir/.snapshots
2055 path = $shadow_shrdir
2056 comment = previous versions at volume root snapshots under mount point
2057 vfs objects = shadow_copy2
2058 shadow:mountpoint = $shadow_shrdir
2061 path = $shadow_shrdir
2062 comment = previous versions at volume root snapshots outside mount point
2063 vfs objects = shadow_copy2
2064 shadow:mountpoint = $shadow_shrdir
2065 shadow:snapdir = $shadow_tstdir/.snapshots
2068 path = $shadow_shrdir
2069 comment = previous versions snapshots everywhere
2070 vfs objects = shadow_copy2
2071 shadow:mountpoint = $shadow_mntdir
2072 shadow:snapdirseverywhere = yes
2075 path = $shadow_shrdir
2076 comment = previous versions using snapsharepath
2077 vfs objects = shadow_copy2
2078 shadow:mountpoint = $shadow_mntdir
2079 shadow:snapdir = $shadow_tstdir/.snapshots
2080 shadow:snapsharepath = share
2083 comment = Testing shadow:format with default option
2084 vfs object = shadow_copy2
2085 path = $shadow_shrdir
2088 shadow:mountpoint = $shadow_mntdir
2089 shadow:basedir = $shadow_basedir
2090 shadow:snapdir = $shadow_basedir/.snapshots
2091 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2094 comment = Testing shadow:format with only date component
2095 vfs object = shadow_copy2
2096 path = $shadow_shrdir
2099 shadow:mountpoint = $shadow_mntdir
2100 shadow:basedir = $shadow_basedir
2101 shadow:snapdir = $shadow_basedir/.snapshots
2102 shadow:format = \@GMT-%Y-%m-%d
2105 comment = Testing shadow:format with some hardcoded prefix
2106 vfs object = shadow_copy2
2107 path = $shadow_shrdir
2110 shadow:mountpoint = $shadow_mntdir
2111 shadow:basedir = $shadow_basedir
2112 shadow:snapdir = $shadow_basedir/.snapshots
2113 shadow:format = snap\@GMT-%Y.%m.%d-%H.%M.%S
2116 comment = Testing shadow:format with modified format
2117 vfs object = shadow_copy2
2118 path = $shadow_shrdir
2121 shadow:mountpoint = $shadow_mntdir
2122 shadow:basedir = $shadow_basedir
2123 shadow:snapdir = $shadow_basedir/.snapshots
2124 shadow:format = \@GMT-%Y.%m.%d-%H_%M_%S-snap
2127 comment = Testing shadow:snapprefix regex
2128 vfs object = shadow_copy2
2129 path = $shadow_shrdir
2132 shadow:mountpoint = $shadow_mntdir
2133 shadow:basedir = $shadow_basedir
2134 shadow:snapdir = $shadow_basedir/.snapshots
2135 shadow:snapprefix = \^s[a-z]*p\$
2136 shadow:format = _GMT-%Y.%m.%d-%H.%M.%S
2139 comment = Testing shadow:snapprefix with delim regex
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:delimiter = \@GMT
2148 shadow:snapprefix = [a-z]*
2149 shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
2152 path = $shadow_shrdir
2153 comment = previous versions with wide links allowed
2154 vfs objects = shadow_copy2
2155 shadow:mountpoint = $shadow_mntdir
2158 path = $shrdir/dfree
2159 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2160 admin users = $unix_name
2161 include = $dfqconffile
2163 path = $shrdir/dfree
2164 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2165 admin users = $unix_name
2166 include = $dfqconffile
2167 dfree cache time = 60
2169 path = $shrdir/dfree
2170 vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
2172 include = $dfqconffile
2173 [acl_xattr_ign_sysacl_posix]
2175 acl_xattr:ignore system acls = yes
2176 acl_xattr:default acl style = posix
2177 [acl_xattr_ign_sysacl_windows]
2179 acl_xattr:ignore system acls = yes
2180 acl_xattr:default acl style = windows
2184 mangled names = illegal
2188 path = $nosymlinks_shrdir
2189 follow symlinks = no
2193 path = $local_symlinks_shrdir
2194 follow symlinks = yes
2198 kernel oplocks = yes
2199 vfs objects = streams_xattr xattr_tdb
2203 vfs objects = streams_xattr xattr_tdb
2207 smbd:find async delay usec = 10000
2210 vfs objects = error_inject
2211 include = $libdir/error_inject.conf
2215 my $net = Samba::bindir_path($self, "net");
2217 $cmd .= "SMB_CONF_PATH=\"$conffile\" ";
2218 $cmd .= "$net setlocalsid $samsid";
2220 if (system($cmd) != 0) {
2221 warn("Join failed\n$cmd");
2225 unless (open(DFQCONF, ">$dfqconffile")) {
2226 warn("Unable to open $dfqconffile");
2232 ## create a test account
2235 unless (open(PASSWD, ">$nss_wrapper_passwd")) {
2236 warn("Unable to open $nss_wrapper_passwd");
2239 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
2240 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
2241 pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2242 pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
2243 userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
2244 pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false
2245 force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false
2246 smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false
2247 user1:x:$uid_user1:$gid_nogroup:user1 gecos:$prefix_abs:/bin/false
2248 user2:x:$uid_user2:$gid_nogroup:user2 gecos:$prefix_abs:/bin/false
2250 if ($unix_uid != 0) {
2251 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
2256 unless (open(GROUP, ">$nss_wrapper_group")) {
2257 warn("Unable to open $nss_wrapper_group");
2260 print GROUP "nobody:x:$gid_nobody:
2261 nogroup:x:$gid_nogroup:nobody
2262 $unix_name-group:x:$unix_gids[0]:
2263 domusers:X:$gid_domusers:
2264 domadmins:X:$gid_domadmins:
2265 userdup:x:$gid_userdup:$unix_name
2266 everyone:x:$gid_everyone:
2267 force_user:x:$gid_force_user:
2269 if ($unix_gids[0] != 0) {
2270 print GROUP "root:x:$gid_root:
2277 my $hostname = lc($server);
2278 unless (open(HOSTS, ">>$nss_wrapper_hosts")) {
2279 warn("Unable to open $nss_wrapper_hosts");
2282 print HOSTS "${server_ip} ${hostname}.samba.example.com ${hostname}\n";
2283 print HOSTS "${server_ipv6} ${hostname}.samba.example.com ${hostname}\n";
2287 unless (open(RESOLV_CONF, ">$resolv_conf")) {
2288 warn("Unable to open $resolv_conf");
2291 if (defined($dc_server_ip) or defined($dc_server_ipv6)) {
2292 if (defined($dc_server_ip)) {
2293 print RESOLV_CONF "nameserver $dc_server_ip\n";
2295 if (defined($dc_server_ipv6)) {
2296 print RESOLV_CONF "nameserver $dc_server_ipv6\n";
2299 print RESOLV_CONF "nameserver ${server_ip}\n";
2300 print RESOLV_CONF "nameserver ${server_ipv6}\n";
2304 foreach my $evlog (@eventlog_list) {
2305 my $evlogtdb = "$eventlogdir/$evlog.tdb";
2306 open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
2310 $createuser_env{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2311 $createuser_env{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2312 $createuser_env{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2313 $createuser_env{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2314 if ($ENV{SAMBA_DNS_FAKING}) {
2315 $createuser_env{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2317 $createuser_env{RESOLV_WRAPPER_CONF} = $resolv_conf;
2320 createuser($self, $unix_name, $password, $conffile, \%createuser_env) || die("Unable to create user");
2321 createuser($self, "force_user", $password, $conffile, \%createuser_env) || die("Unable to create force_user");
2322 createuser($self, "smbget_user", $password, $conffile, \%createuser_env) || die("Unable to create smbget_user");
2323 createuser($self, "user1", $password, $conffile, \%createuser_env) || die("Unable to create user1");
2324 createuser($self, "user2", $password, $conffile, \%createuser_env) || die("Unable to create user2");
2326 open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
2327 print DNS_UPDATE_LIST "A $server. $server_ip\n";
2328 print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n";
2329 close(DNS_UPDATE_LIST);
2333 $ret{SERVER_IP} = $server_ip;
2334 $ret{SERVER_IPV6} = $server_ipv6;
2335 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
2336 $ret{NMBD_TEST_LOG_POS} = 0;
2337 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
2338 $ret{WINBINDD_TEST_LOG_POS} = 0;
2339 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
2340 $ret{SMBD_TEST_LOG_POS} = 0;
2341 $ret{SERVERCONFFILE} = $conffile;
2342 $ret{CONFIGURATION} ="-s $conffile";
2343 $ret{LOCK_DIR} = $lockdir;
2344 $ret{SERVER} = $server;
2345 $ret{USERNAME} = $unix_name;
2346 $ret{USERID} = $unix_uid;
2347 $ret{DOMAIN} = $domain;
2348 $ret{SAMSID} = $samsid;
2349 $ret{NETBIOSNAME} = $server;
2350 $ret{PASSWORD} = $password;
2351 $ret{PIDDIR} = $piddir;
2352 $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir;
2353 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
2354 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
2355 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
2356 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
2357 $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
2358 $ret{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
2359 $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
2360 $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind";
2361 if ($ENV{SAMBA_DNS_FAKING}) {
2362 $ret{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
2364 $ret{RESOLV_WRAPPER_CONF} = $resolv_conf;
2366 $ret{LOCAL_PATH} = "$shrdir";
2367 $ret{LOGDIR} = $logdir;
2370 # Avoid hitting system krb5.conf -
2371 # An env that needs Kerberos will reset this to the real
2374 $ret{KRB5_CONFIG} = abs_path($prefix) . "/no_krb5.conf";
2376 # Define KRB5CCNAME for each environment we set up
2377 $ret{KRB5_CCACHE} = abs_path($prefix) . "/krb5ccache";
2378 $ENV{KRB5CCNAME} = $ret{KRB5_CCACHE};
2383 sub wait_for_start($$$$$)
2385 my ($self, $envvars, $nmbd, $winbindd, $smbd) = @_;
2390 if ($nmbd eq "yes") {
2393 # give time for nbt server to register its names
2394 print "checking for nmbd\n";
2396 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
2397 my $nmblookup = Samba::bindir_path($self, "nmblookup");
2400 $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
2404 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
2405 system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
2406 system("$nmblookup $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
2407 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
2410 } while ($ret != 0 && $count < 10);
2412 print "NMBD not reachable after 10 retries\n";
2413 teardown_env($self, $envvars);
2418 if ($winbindd eq "yes") {
2419 print "checking for winbindd\n";
2421 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2422 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2423 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2424 $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping-dc";
2428 $ret = system($cmd);
2432 } while ($ret != 0 && $count < 20);
2434 print "WINBINDD not reachable after 20 seconds\n";
2435 teardown_env($self, $envvars);
2440 if ($smbd eq "yes") {
2441 # make sure smbd is also up set
2442 print "wait for smbd\n";
2446 $ret = system(Samba::bindir_path($self, "smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139");
2451 } while ($ret != 0 && $count < 20);
2453 print "SMBD failed to start up in a reasonable time (20sec)\n";
2454 teardown_env($self, $envvars);
2459 # Ensure we have domain users mapped.
2460 $netcmd = "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2461 $netcmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2462 $netcmd .= Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} ";
2464 $cmd = $netcmd . "groupmap delete ntgroup=domusers";
2465 $ret = system($cmd);
2467 $cmd = $netcmd . "groupmap add rid=513 unixgroup=domusers type=domain";
2468 $ret = system($cmd);
2470 print("\"$cmd\" failed\n");
2474 $cmd = $netcmd . "groupmap delete ntgroup=domadmins";
2475 $ret = system($cmd);
2477 $cmd = $netcmd . "groupmap add rid=512 unixgroup=domadmins type=domain";
2478 $ret = system($cmd);
2480 print("\"$cmd\" failed\n");
2484 $cmd = $netcmd . "groupmap delete ntgroup=everyone";
2485 $ret = system($cmd);
2487 $cmd = $netcmd . "groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin";
2488 $ret = system($cmd);
2490 print("\"$cmd\" failed\n");
2494 # note: creating builtin groups requires winbindd for the
2496 my $create_builtin_users = "no";
2497 if ($winbindd eq "yes") {
2498 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2499 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2500 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2501 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
2502 my $wbinfo_out = qx($cmd 2>&1);
2504 # wbinfo doesn't give us a better error code then
2505 # WBC_ERR_DOMAIN_NOT_FOUND, but at least that's
2506 # different then WBC_ERR_WINBIND_NOT_AVAILABLE
2507 if ($wbinfo_out !~ /WBC_ERR_DOMAIN_NOT_FOUND/) {
2508 print("Failed to run \"wbinfo --sid-to-gid=S-1-5-32-545\": $wbinfo_out");
2509 teardown_env($self, $envvars);
2512 $create_builtin_users = "yes";
2515 if ($create_builtin_users eq "yes") {
2516 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2517 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2518 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2519 $cmd .= Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
2520 $cmd .= "sam createbuiltingroup Users";
2521 $ret = system($cmd);
2523 print "Failed to create BUILTIN\\Users group\n";
2524 teardown_env($self, $envvars);
2528 $cmd = Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} ";
2529 $cmd .= "cache del IDMAP/SID2XID/S-1-5-32-545";
2532 $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' ";
2533 $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' ";
2534 $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' ";
2535 $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545";
2536 $ret = system($cmd);
2538 print "Missing \"BUILTIN\\Users\", did net sam createbuiltingroup Users fail?\n";
2539 teardown_env($self, $envvars);
2544 print $self->getlog_env($envvars);