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);
17 my $smbd_build_options = Samba::bindir_path($self, "smbd") . " -b|";
18 open(IN, $smbd_build_options) or die("Unable to run $smbd_build_options: $!");
27 # If we were not built with ADS support, pretend we were never even available
28 print "smbd does not have ADS support\n" unless $found_ads;
32 # return smb.conf parameters applicable to @path, based on the underlying
34 sub get_fs_specific_conf($$)
36 my ($self, $path) = @_;
38 my $stat_out = `stat --file-system $path` or return "";
40 if ($stat_out =~ m/Type:\s+btrfs/) {
45 return "vfs objects = $mods";
52 my ($classname, $bindir, $srcdir, $server_maxtime) = @_;
53 my $self = { vars => {},
56 server_maxtime => $server_maxtime
64 my ($self, $envvars) = @_;
67 # This should cause smbd to terminate gracefully
68 close($envvars->{STDIN_PIPE});
70 my $smbdpid = $envvars->{SMBD_TL_PID};
71 my $nmbdpid = $envvars->{NMBD_TL_PID};
72 my $winbinddpid = $envvars->{WINBINDD_TL_PID};
74 # This should give it time to write out the gcov data
76 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
77 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
78 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
81 && $winbinddchild == -1) {
88 if ($count <= 20 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
92 $self->stop_sig_term($smbdpid);
93 $self->stop_sig_term($nmbdpid);
94 $self->stop_sig_term($winbinddpid);
98 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
99 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
100 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
103 && $winbinddchild == -1) {
110 if ($count <= 10 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
114 warn("timelimit process did not quit on SIGTERM, sending SIGKILL");
115 $self->stop_sig_kill($smbdpid);
116 $self->stop_sig_kill($nmbdpid);
117 $self->stop_sig_kill($winbinddpid);
122 sub getlog_env_app($$$)
124 my ($self, $envvars, $name) = @_;
126 my $title = "$name LOG of: $envvars->{NETBIOSNAME}\n";
129 open(LOG, "<".$envvars->{$name."_TEST_LOG"});
131 seek(LOG, $envvars->{$name."_TEST_LOG_POS"}, SEEK_SET);
135 $envvars->{$name."_TEST_LOG_POS"} = tell(LOG);
138 return "" if $out eq $title;
145 my ($self, $envvars) = @_;
148 $ret .= $self->getlog_env_app($envvars, "SMBD");
149 $ret .= $self->getlog_env_app($envvars, "NMBD");
150 $ret .= $self->getlog_env_app($envvars, "WINBINDD");
157 my ($self, $envvars) = @_;
159 my $childpid = waitpid(-1, WNOHANG);
167 my ($self, $envname, $path) = @_;
169 $ENV{ENVNAME} = $envname;
171 if (defined($self->{vars}->{$envname})) {
172 return $self->{vars}->{$envname};
176 # Avoid hitting system krb5.conf -
177 # An env that needs Kerberos will reset this to the real
180 $ENV{KRB5_CONFIG} = "$path/no_krb5.conf";
182 if ($envname eq "nt4_dc") {
183 return $self->setup_nt4_dc("$path/nt4_dc");
184 } elsif ($envname eq "nt4_dc_schannel") {
185 return $self->setup_nt4_dc_schannel("$path/nt4_dc_schannel");
186 } elsif ($envname eq "simpleserver") {
187 return $self->setup_simpleserver("$path/simpleserver");
188 } elsif ($envname eq "fileserver") {
189 return $self->setup_fileserver("$path/fileserver");
190 } elsif ($envname eq "maptoguest") {
191 return $self->setup_maptoguest("$path/maptoguest");
192 } elsif ($envname eq "ktest") {
193 return $self->setup_ktest("$path/ktest");
194 } elsif ($envname eq "nt4_member") {
195 if (not defined($self->{vars}->{nt4_dc})) {
196 if (not defined($self->setup_nt4_dc("$path/nt4_dc"))) {
200 return $self->setup_nt4_member("$path/nt4_member", $self->{vars}->{nt4_dc});
208 my ($self, $path) = @_;
210 print "PROVISIONING NT4 DC...";
212 my $nt4_dc_options = "
217 raw NTLMv2 auth = yes
219 rpc_server:epmapper = external
220 rpc_server:spoolss = external
221 rpc_server:lsarpc = external
222 rpc_server:samr = external
223 rpc_server:netlogon = external
224 rpc_server:register_embedded_np = yes
225 rpc_server:FssagentRpc = external
227 rpc_daemon:epmd = fork
228 rpc_daemon:spoolssd = fork
229 rpc_daemon:lsasd = fork
230 rpc_daemon:fssd = fork
231 fss: sequence timeout = 1
234 my $vars = $self->provision($path,
239 $vars or return undef;
241 if (not $self->check_or_start($vars, "yes", "yes", "yes")) {
245 $vars->{DC_SERVER} = $vars->{SERVER};
246 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
247 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
248 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
249 $vars->{DC_USERNAME} = $vars->{USERNAME};
250 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
252 $self->{vars}->{nt4_dc} = $vars;
257 sub setup_nt4_dc_schannel($$)
259 my ($self, $path) = @_;
261 print "PROVISIONING NT4 DC WITH SERVER SCHANNEL ...";
268 rpc_server:epmapper = external
269 rpc_server:spoolss = external
270 rpc_server:lsarpc = external
271 rpc_server:samr = external
272 rpc_server:netlogon = external
273 rpc_server:register_embedded_np = yes
275 rpc_daemon:epmd = fork
276 rpc_daemon:spoolssd = fork
277 rpc_daemon:lsasd = fork
279 server schannel = yes
282 my $vars = $self->provision($path,
287 $vars or return undef;
289 if (not $self->check_or_start($vars, "yes", "yes", "yes")) {
293 $vars->{DC_SERVER} = $vars->{SERVER};
294 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
295 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
296 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
297 $vars->{DC_USERNAME} = $vars->{USERNAME};
298 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
300 $self->{vars}->{nt4_dc_schannel} = $vars;
305 sub setup_nt4_member($$$)
307 my ($self, $prefix, $nt4_dc_vars) = @_;
311 print "PROVISIONING MEMBER...";
313 my $require_mutexes = "dbwrap_tdb_require_mutexes:* = yes";
314 $require_mutexes = "" if ($ENV{SELFTEST_DONT_REQUIRE_TDB_MUTEX_SUPPORT} eq "1");
316 my $member_options = "
318 dbwrap_tdb_mutexes:* = yes
321 my $ret = $self->provision($prefix,
323 "localnt4member3pass",
326 $ret or return undef;
328 my $nmblookup = Samba::bindir_path($self, "nmblookup");
330 print "Waiting for the LOGON SERVER registration ...\n";
331 $rc = system("$nmblookup $ret->{CONFIGURATION} $ret->{DOMAIN}\#1c");
336 } while ($rc != 0 && $count < 10);
338 print "NMBD not reachable after 10 retries\n";
339 teardown_env($self, $ret);
343 my $net = Samba::bindir_path($self, "net");
345 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
346 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
347 $cmd .= "$net join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
348 $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}";
350 if (system($cmd) != 0) {
351 warn("Join failed\n$cmd");
355 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
359 $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
360 $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
361 $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
362 $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME};
363 $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME};
364 $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD};
369 sub setup_admember($$$$)
371 my ($self, $prefix, $dcvars) = @_;
373 # If we didn't build with ADS, pretend this env was never available
374 if (not $self->have_ads()) {
378 print "PROVISIONING S3 AD MEMBER...";
380 my $member_options = "
382 workgroup = $dcvars->{DOMAIN}
383 realm = $dcvars->{REALM}
384 netbios aliases = foo bar
387 my $ret = $self->provision($prefix,
391 $dcvars->{SERVER_IP},
392 $dcvars->{SERVER_IPV6});
394 $ret or return undef;
397 $ret->{DOMAIN} = $dcvars->{DOMAIN};
398 $ret->{REALM} = $dcvars->{REALM};
401 my $prefix_abs = abs_path($prefix);
403 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
404 $ctx->{domain} = $dcvars->{DOMAIN};
405 $ctx->{realm} = $dcvars->{REALM};
406 $ctx->{dnsname} = lc($dcvars->{REALM});
407 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
408 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
409 Samba::mk_krb5_conf($ctx, "");
411 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
413 my $net = Samba::bindir_path($self, "net");
415 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
416 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
417 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
419 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
421 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
422 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
423 $cmd .= "$net join $ret->{CONFIGURATION}";
424 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
426 if (system($cmd) != 0) {
427 warn("Join failed\n$cmd");
431 # We need world access to this share, as otherwise the domain
432 # administrator from the AD domain provided by Samba4 can't
433 # access the share for tests.
434 chmod 0777, "$prefix/share";
436 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
440 $ret->{DC_SERVER} = $dcvars->{SERVER};
441 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
442 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
443 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
444 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
445 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
447 # Special case, this is called from Samba4.pm but needs to use the Samba3 check_env and get_log_env
448 $ret->{target} = $self;
453 sub setup_admember_rfc2307($$$$)
455 my ($self, $prefix, $dcvars) = @_;
457 # If we didn't build with ADS, pretend this env was never available
458 if (not $self->have_ads()) {
462 print "PROVISIONING S3 AD MEMBER WITH idmap_rfc2307 config...";
464 my $member_options = "
466 workgroup = $dcvars->{DOMAIN}
467 realm = $dcvars->{REALM}
468 idmap config * : backend = autorid
469 idmap config * : range = 1000000-1999999
470 idmap config * : rangesize = 100000
471 idmap config $dcvars->{DOMAIN} : backend = rfc2307
472 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
473 idmap config $dcvars->{DOMAIN} : ldap_server = ad
474 idmap config $dcvars->{DOMAIN} : bind_path_user = ou=idmap,dc=samba,dc=example,dc=com
475 idmap config $dcvars->{DOMAIN} : bind_path_group = ou=idmap,dc=samba,dc=example,dc=com
478 my $ret = $self->provision($prefix,
482 $dcvars->{SERVER_IP},
483 $dcvars->{SERVER_IPV6});
485 $ret or return undef;
488 $ret->{DOMAIN} = $dcvars->{DOMAIN};
489 $ret->{REALM} = $dcvars->{REALM};
492 my $prefix_abs = abs_path($prefix);
494 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
495 $ctx->{domain} = $dcvars->{DOMAIN};
496 $ctx->{realm} = $dcvars->{REALM};
497 $ctx->{dnsname} = lc($dcvars->{REALM});
498 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
499 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
500 Samba::mk_krb5_conf($ctx, "");
502 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
504 my $net = Samba::bindir_path($self, "net");
506 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
507 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
508 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
510 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
512 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
513 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
514 $cmd .= "$net join $ret->{CONFIGURATION}";
515 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
517 if (system($cmd) != 0) {
518 warn("Join failed\n$cmd");
522 # We need world access to this share, as otherwise the domain
523 # administrator from the AD domain provided by Samba4 can't
524 # access the share for tests.
525 chmod 0777, "$prefix/share";
527 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
531 $ret->{DC_SERVER} = $dcvars->{SERVER};
532 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
533 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
534 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
535 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
536 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
538 # Special case, this is called from Samba4.pm but needs to use the Samba3 check_env and get_log_env
539 $ret->{target} = $self;
544 sub setup_simpleserver($$)
546 my ($self, $path) = @_;
548 print "PROVISIONING simple server...";
550 my $prefix_abs = abs_path($path);
552 my $simpleserver_options = "
555 vfs objects = xattr_tdb streams_depot time_audit full_audit
558 full_audit:syslog = no
559 full_audit:success = none
560 full_audit:failure = none
563 path = $prefix_abs/share
564 vfs objects = aio_fork
566 vfs_aio_fork:erratic_testing_mode=yes
569 path = $prefix_abs/share
571 store dos attributes = yes
572 hide files = /hidefile/
576 my $vars = $self->provision($path,
579 $simpleserver_options);
581 $vars or return undef;
583 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
587 $self->{vars}->{simpleserver} = $vars;
592 sub setup_fileserver($$)
594 my ($self, $path) = @_;
595 my $prefix_abs = abs_path($path);
596 my $srcdir_abs = abs_path($self->{srcdir});
598 print "PROVISIONING file server ...\n";
602 mkdir($prefix_abs, 0777);
604 my $share_dir="$prefix_abs/share";
606 # Create share directory structure
607 my $lower_case_share_dir="$share_dir/lower-case";
608 push(@dirs, $lower_case_share_dir);
610 my $lower_case_share_dir_30000="$share_dir/lower-case-30000";
611 push(@dirs, $lower_case_share_dir_30000);
613 my $dfree_share_dir="$share_dir/dfree";
614 push(@dirs, $dfree_share_dir);
615 push(@dirs, "$dfree_share_dir/subdir1");
616 push(@dirs, "$dfree_share_dir/subdir2");
618 my $valid_users_sharedir="$share_dir/valid_users";
619 push(@dirs,$valid_users_sharedir);
621 my $offline_sharedir="$share_dir/offline";
622 push(@dirs,$offline_sharedir);
624 my $force_user_valid_users_dir = "$share_dir/force_user_valid_users";
625 push(@dirs, $force_user_valid_users_dir);
627 my $smbget_sharedir="$share_dir/smbget";
628 push(@dirs,$smbget_sharedir);
630 my $fileserver_options = "
632 path = $lower_case_share_dir
633 comment = smb username is [%U]
634 case sensitive = True
637 short preserve case = no
639 path = $lower_case_share_dir_30000
640 comment = smb username is [%U]
641 case sensitive = True
644 short preserve case = no
646 path = $dfree_share_dir
647 comment = smb username is [%U]
648 dfree command = $srcdir_abs/testprogs/blackbox/dfree.sh
650 path = $valid_users_sharedir
651 valid users = +userdup
653 path = $offline_sharedir
654 vfs objects = offline
656 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878
657 # RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651
658 [force_user_valid_users]
659 path = $force_user_valid_users_dir
660 comment = force user with valid users combination test share
661 valid users = +force_user
662 force user = force_user
663 force group = everyone
664 write list = force_user
667 path = $smbget_sharedir
668 comment = smb username is [%U]
672 comment = ignore system acls
673 acl_xattr:ignore system acls = yes
676 my $vars = $self->provision($path,
684 $vars or return undef;
686 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
690 $self->{vars}->{fileserver} = $vars;
692 mkdir($_, 0777) foreach(@dirs);
694 ## Create case sensitive lower case share dir
695 foreach my $file ('a'..'z') {
696 my $full_path = $lower_case_share_dir . '/' . $file;
697 open my $fh, '>', $full_path;
698 # Add some content to file
699 print $fh $full_path;
703 for (my $file = 1; $file < 51; ++$file) {
704 my $full_path = $lower_case_share_dir . '/' . $file;
705 open my $fh, '>', $full_path;
706 # Add some content to file
707 print $fh $full_path;
711 # Create content for 30000 share
712 foreach my $file ('a'..'z') {
713 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
714 open my $fh, '>', $full_path;
715 # Add some content to file
716 print $fh $full_path;
720 for (my $file = 1; $file < 30001; ++$file) {
721 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
722 open my $fh, '>', $full_path;
723 # Add some content to file
724 print $fh $full_path;
729 ## create a listable file in valid_users_share
731 my $valid_users_target = "$valid_users_sharedir/foo";
732 unless (open(VALID_USERS_TARGET, ">$valid_users_target")) {
733 warn("Unable to open $valid_users_target");
736 close(VALID_USERS_TARGET);
737 chmod 0644, $valid_users_target;
744 my ($self, $prefix) = @_;
746 # If we didn't build with ADS, pretend this env was never available
747 if (not $self->have_ads()) {
751 print "PROVISIONING server with security=ads...";
753 my $ktest_options = "
755 realm = ktest.samba.example.com
757 username map = $prefix/lib/username.map
758 server signing = required
761 my $ret = $self->provision($prefix,
766 $ret or return undef;
769 my $prefix_abs = abs_path($prefix);
771 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
772 $ctx->{domain} = "KTEST";
773 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
774 $ctx->{dnsname} = lc($ctx->{realm});
775 $ctx->{kdc_ipv4} = "0.0.0.0";
776 $ctx->{kdc_ipv6} = "::";
777 Samba::mk_krb5_conf($ctx, "");
779 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
781 open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map");
783 $ret->{USERNAME} = KTEST\\Administrator
787 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
788 #Samba4 DC with the same parameters as are being used here. The
789 #domain SID is S-1-5-21-1071277805-689288055-3486227160
791 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
792 chmod 0600, "$prefix/private/secrets.tdb";
794 #Make sure there's no old ntdb file.
795 system("rm -f $prefix/private/secrets.ntdb");
797 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
798 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
800 #and having in krb5.conf:
801 # ticket_lifetime = 799718400
802 # renew_lifetime = 799718400
804 # The commands for the -2 keytab where were:
805 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
806 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
807 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
808 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
809 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
811 # and then for the -3 keytab, I did
813 # net changetrustpw; kdestroy and the same again.
815 # This creates a credential cache with a very long lifetime (2036 at
816 # at 2011-04), and shows that running 'net changetrustpw' does not
817 # break existing logins (for the secrets.tdb method at least).
820 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
822 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
823 chmod 0600, "$prefix/krb5_ccache-2";
825 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
826 chmod 0600, "$prefix/krb5_ccache-3";
828 # We need world access to this share, as otherwise the domain
829 # administrator from the AD domain provided by ktest can't
830 # access the share for tests.
831 chmod 0777, "$prefix/share";
833 if (not $self->check_or_start($ret, "yes", "no", "yes")) {
839 sub setup_maptoguest($$)
841 my ($self, $path) = @_;
843 print "PROVISIONING maptoguest...";
846 map to guest = bad user
850 my $vars = $self->provision($path,
855 $vars or return undef;
857 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
861 $self->{vars}->{s3maptoguest} = $vars;
866 sub stop_sig_term($$) {
867 my ($self, $pid) = @_;
868 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
871 sub stop_sig_kill($$) {
872 my ($self, $pid) = @_;
873 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
878 my ($env_vars, $app, $pid) = @_;
880 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
887 my ($env_vars, $app) = @_;
889 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
895 sub check_or_start($$$$$) {
896 my ($self, $env_vars, $nmbd, $winbindd, $smbd) = @_;
898 # use a pipe for stdin in the child processes. This allows
899 # those processes to monitor the pipe for EOF to ensure they
900 # exit when the test script exits
901 pipe(STDIN_READER, $env_vars->{STDIN_PIPE});
903 unlink($env_vars->{NMBD_TEST_LOG});
904 print "STARTING NMBD...";
907 open STDOUT, ">$env_vars->{NMBD_TEST_LOG}";
908 open STDERR, '>&STDOUT';
910 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
912 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
913 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
914 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
916 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
917 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
918 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
919 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
920 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
921 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
922 $ENV{UID_WRAPPER_ROOT} = "1";
924 $ENV{ENVNAME} = "$ENV{ENVNAME}.nmbd";
926 if ($nmbd ne "yes") {
927 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
929 print("Skip nmbd received signal $signame");
932 sleep($self->{server_maxtime});
936 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "nmbd");
937 my @optargs = ("-d0");
938 if (defined($ENV{NMBD_OPTIONS})) {
939 @optargs = split(/ /, $ENV{NMBD_OPTIONS});
941 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
942 if(defined($ENV{NMBD_VALGRIND})) {
943 @preargs = split(/ /, $ENV{NMBD_VALGRIND});
945 my @args = ("-F", "--no-process-group",
946 "-s", $env_vars->{SERVERCONFFILE},
947 "-l", $env_vars->{LOGDIR});
948 if (not defined($ENV{NMBD_DONT_LOG_STDOUT})) {
949 push(@args, "--log-stdout");
952 close($env_vars->{STDIN_PIPE});
953 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
955 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
956 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
958 $env_vars->{NMBD_TL_PID} = $pid;
959 write_pid($env_vars, "nmbd", $pid);
962 unlink($env_vars->{WINBINDD_TEST_LOG});
963 print "STARTING WINBINDD...";
966 open STDOUT, ">$env_vars->{WINBINDD_TEST_LOG}";
967 open STDERR, '>&STDOUT';
969 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
971 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
972 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
973 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
975 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
976 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
977 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
978 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
979 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
980 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
981 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
982 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
984 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
986 $ENV{UID_WRAPPER_ROOT} = "1";
988 $ENV{ENVNAME} = "$ENV{ENVNAME}.winbindd";
990 if ($winbindd ne "yes") {
991 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
993 print("Skip winbindd received signal $signame");
996 sleep($self->{server_maxtime});
1000 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "winbindd");
1001 my @optargs = ("-d0");
1002 if (defined($ENV{WINBINDD_OPTIONS})) {
1003 @optargs = split(/ /, $ENV{WINBINDD_OPTIONS});
1005 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1006 if(defined($ENV{WINBINDD_VALGRIND})) {
1007 @preargs = split(/ /, $ENV{WINBINDD_VALGRIND});
1009 my @args = ("-F", "--no-process-group",
1010 "-s", $env_vars->{SERVERCONFFILE},
1011 "-l", $env_vars->{LOGDIR});
1012 if (not defined($ENV{WINBINDD_DONT_LOG_STDOUT})) {
1013 push(@args, "--stdout");
1016 close($env_vars->{STDIN_PIPE});
1017 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1019 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1020 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1022 $env_vars->{WINBINDD_TL_PID} = $pid;
1023 write_pid($env_vars, "winbindd", $pid);
1026 unlink($env_vars->{SMBD_TEST_LOG});
1027 print "STARTING SMBD...";
1030 open STDOUT, ">$env_vars->{SMBD_TEST_LOG}";
1031 open STDERR, '>&STDOUT';
1033 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1035 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1036 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1037 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1039 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1040 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1041 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1042 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1043 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1044 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1045 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
1046 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
1048 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
1050 $ENV{UID_WRAPPER_ROOT} = "1";
1052 $ENV{ENVNAME} = "$ENV{ENVNAME}.smbd";
1054 if ($smbd ne "yes") {
1055 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1056 my $signame = shift;
1057 print("Skip smbd received signal $signame");
1060 sleep($self->{server_maxtime});
1064 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "smbd");
1065 my @optargs = ("-d0");
1066 if (defined($ENV{SMBD_OPTIONS})) {
1067 @optargs = split(/ /, $ENV{SMBD_OPTIONS});
1069 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1070 if(defined($ENV{SMBD_VALGRIND})) {
1071 @preargs = split(/ /,$ENV{SMBD_VALGRIND});
1073 my @args = ("-F", "--no-process-group",
1074 "-s", $env_vars->{SERVERCONFFILE},
1075 "-l", $env_vars->{LOGDIR});
1076 if (not defined($ENV{SMBD_DONT_LOG_STDOUT})) {
1077 push(@args, "--log-stdout");
1080 close($env_vars->{STDIN_PIPE});
1081 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1083 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1084 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1086 $env_vars->{SMBD_TL_PID} = $pid;
1087 write_pid($env_vars, "smbd", $pid);
1090 close(STDIN_READER);
1092 return $self->wait_for_start($env_vars, $nmbd, $winbindd, $smbd);
1095 sub createuser($$$$)
1097 my ($self, $username, $password, $conffile) = @_;
1098 my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $username > /dev/null";
1099 unless (open(PWD, "|$cmd")) {
1100 warn("Unable to set password for $username account\n$cmd");
1103 print PWD "$password\n$password\n";
1104 unless (close(PWD)) {
1105 warn("Unable to set password for $username account\n$cmd");
1111 sub provision($$$$$$$$)
1113 my ($self, $prefix, $server, $password, $extra_options, $dc_server_ip, $dc_server_ipv6, $no_delete_prefix) = @_;
1116 ## setup the various environment variables we need
1119 my $swiface = Samba::get_interface($server);
1121 my $server_ip = "127.0.0.$swiface";
1122 my $server_ipv6 = sprintf("fd00:0000:0000:0000:0000:0000:5357:5f%02x", $swiface);
1123 my $domain = "SAMBA-TEST";
1125 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
1128 my $unix_gids_str = $);
1129 my @unix_gids = split(" ", $unix_gids_str);
1131 my $prefix_abs = abs_path($prefix);
1132 my $bindir_abs = abs_path($self->{bindir});
1136 my $shrdir="$prefix_abs/share";
1137 push(@dirs,$shrdir);
1139 my $libdir="$prefix_abs/lib";
1140 push(@dirs,$libdir);
1142 my $piddir="$prefix_abs/pid";
1143 push(@dirs,$piddir);
1145 my $privatedir="$prefix_abs/private";
1146 push(@dirs,$privatedir);
1148 my $lockdir="$prefix_abs/lockdir";
1149 push(@dirs,$lockdir);
1151 my $eventlogdir="$prefix_abs/lockdir/eventlog";
1152 push(@dirs,$eventlogdir);
1154 my $logdir="$prefix_abs/logs";
1155 push(@dirs,$logdir);
1157 my $driver32dir="$shrdir/W32X86";
1158 push(@dirs,$driver32dir);
1160 my $driver64dir="$shrdir/x64";
1161 push(@dirs,$driver64dir);
1163 my $driver40dir="$shrdir/WIN40";
1164 push(@dirs,$driver40dir);
1166 my $ro_shrdir="$shrdir/root-tmp";
1167 push(@dirs,$ro_shrdir);
1169 my $msdfs_shrdir="$shrdir/msdfsshare";
1170 push(@dirs,$msdfs_shrdir);
1172 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
1173 push(@dirs,$msdfs_deeppath);
1175 my $badnames_shrdir="$shrdir/badnames";
1176 push(@dirs,$badnames_shrdir);
1178 my $lease1_shrdir="$shrdir/SMB2_10";
1179 push(@dirs,$lease1_shrdir);
1181 my $lease2_shrdir="$shrdir/SMB3_00";
1182 push(@dirs,$lease2_shrdir);
1184 my $manglenames_shrdir="$shrdir/manglenames";
1185 push(@dirs,$manglenames_shrdir);
1187 my $widelinks_shrdir="$shrdir/widelinks";
1188 push(@dirs,$widelinks_shrdir);
1190 my $widelinks_linkdir="$shrdir/widelinks_foo";
1191 push(@dirs,$widelinks_linkdir);
1193 my $shadow_tstdir="$shrdir/shadow";
1194 push(@dirs,$shadow_tstdir);
1195 my $shadow_mntdir="$shadow_tstdir/mount";
1196 push(@dirs,$shadow_mntdir);
1197 my $shadow_basedir="$shadow_mntdir/base";
1198 push(@dirs,$shadow_basedir);
1199 my $shadow_shrdir="$shadow_basedir/share";
1200 push(@dirs,$shadow_shrdir);
1202 # this gets autocreated by winbindd
1203 my $wbsockdir="$prefix_abs/winbindd";
1204 my $wbsockprivdir="$lockdir/winbindd_privileged";
1206 my $nmbdsockdir="$prefix_abs/nmbd";
1207 unlink($nmbdsockdir);
1210 ## create the test directory layout
1212 die ("prefix_abs = ''") if $prefix_abs eq "";
1213 die ("prefix_abs = '/'") if $prefix_abs eq "/";
1215 mkdir($prefix_abs, 0777);
1216 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
1217 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
1218 system("rm -rf $prefix_abs/*");
1220 mkdir($_, 0777) foreach(@dirs);
1222 my $fs_specific_conf = $self->get_fs_specific_conf($shrdir);
1225 ## lockdir and piddir must be 0755
1227 chmod 0755, $lockdir;
1228 chmod 0755, $piddir;
1232 ## create ro and msdfs share layout
1235 chmod 0755, $ro_shrdir;
1236 my $unreadable_file = "$ro_shrdir/unreadable_file";
1237 unless (open(UNREADABLE_FILE, ">$unreadable_file")) {
1238 warn("Unable to open $unreadable_file");
1241 close(UNREADABLE_FILE);
1242 chmod 0600, $unreadable_file;
1244 my $msdfs_target = "$ro_shrdir/msdfs-target";
1245 unless (open(MSDFS_TARGET, ">$msdfs_target")) {
1246 warn("Unable to open $msdfs_target");
1249 close(MSDFS_TARGET);
1250 chmod 0666, $msdfs_target;
1251 symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp",
1252 "$msdfs_shrdir/msdfs-src1";
1253 symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
1256 ## create bad names in $badnames_shrdir
1258 ## (An invalid name, would be mangled to 8.3).
1259 my $badname_target = "$badnames_shrdir/\340|\231\216\377\177";
1260 unless (open(BADNAME_TARGET, ">$badname_target")) {
1261 warn("Unable to open $badname_target");
1264 close(BADNAME_TARGET);
1265 chmod 0666, $badname_target;
1267 ## (A bad name, would not be mangled to 8.3).
1268 my $badname_target = "$badnames_shrdir/\240\276\346\327\377\177";
1269 unless (open(BADNAME_TARGET, ">$badname_target")) {
1270 warn("Unable to open $badname_target");
1273 close(BADNAME_TARGET);
1274 chmod 0666, $badname_target;
1276 ## (A bad good name).
1277 my $badname_target = "$badnames_shrdir/blank.txt";
1278 unless (open(BADNAME_TARGET, ">$badname_target")) {
1279 warn("Unable to open $badname_target");
1282 close(BADNAME_TARGET);
1283 chmod 0666, $badname_target;
1286 ## create mangleable directory names in $manglenames_shrdir
1288 my $manglename_target = "$manglenames_shrdir/foo:bar";
1289 mkdir($manglename_target, 0777);
1292 ## create symlinks for widelinks tests.
1294 my $widelinks_target = "$widelinks_linkdir/target";
1295 unless (open(WIDELINKS_TARGET, ">$widelinks_target")) {
1296 warn("Unable to open $widelinks_target");
1299 close(WIDELINKS_TARGET);
1300 chmod 0666, $widelinks_target;
1302 ## This link should get ACCESS_DENIED
1304 symlink "$widelinks_target", "$widelinks_shrdir/source";
1306 ## This link should be allowed
1308 symlink "$widelinks_shrdir", "$widelinks_shrdir/dot";
1310 my $conffile="$libdir/server.conf";
1311 my $dfqconffile="$libdir/dfq.conf";
1313 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/lib/nss_wrapper/nss_wrapper.pl";
1314 my $nss_wrapper_passwd = "$privatedir/passwd";
1315 my $nss_wrapper_group = "$privatedir/group";
1316 my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts";
1317 my $resolv_conf = "$privatedir/resolv.conf";
1318 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
1320 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
1322 my $fake_snap_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/fake_snap.pl";
1324 my @eventlog_list = ("dns server", "application");
1327 ## calculate uids and gids
1330 my ($max_uid, $max_gid);
1331 my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
1332 my ($uid_pdbtest_wkn);
1334 my ($uid_force_user);
1335 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
1336 my ($gid_userdup, $gid_everyone);
1337 my ($gid_force_user);
1339 if ($unix_uid < 0xffff - 7) {
1342 $max_uid = $unix_uid;
1345 $uid_root = $max_uid - 1;
1346 $uid_nobody = $max_uid - 2;
1347 $uid_pdbtest = $max_uid - 3;
1348 $uid_pdbtest2 = $max_uid - 4;
1349 $uid_userdup = $max_uid - 5;
1350 $uid_pdbtest_wkn = $max_uid - 6;
1351 $uid_force_user = $max_uid - 7;
1352 $uid_smbget = $max_uid - 8;
1354 if ($unix_gids[0] < 0xffff - 8) {
1357 $max_gid = $unix_gids[0];
1360 $gid_nobody = $max_gid - 1;
1361 $gid_nogroup = $max_gid - 2;
1362 $gid_root = $max_gid - 3;
1363 $gid_domusers = $max_gid - 4;
1364 $gid_domadmins = $max_gid - 5;
1365 $gid_userdup = $max_gid - 6;
1366 $gid_everyone = $max_gid - 7;
1367 $gid_force_user = $max_gid - 8;
1373 unless (open(CONF, ">$conffile")) {
1374 warn("Unable to open $conffile");
1379 netbios name = $server
1380 interfaces = $server_ip/8 $server_ipv6/64
1381 bind interfaces only = yes
1382 panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
1383 smbd:suicide mode = yes
1387 private dir = $privatedir
1388 pid directory = $piddir
1389 lock directory = $lockdir
1390 log file = $logdir/log.\%m
1395 state directory = $lockdir
1396 cache directory = $lockdir
1398 passdb backend = tdbsam
1402 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1403 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
1404 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1405 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
1406 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
1407 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
1408 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
1410 addprinter command = $mod_printer_pl -a -s $conffile --
1411 deleteprinter command = $mod_printer_pl -d -s $conffile --
1413 eventlog list = application \"dns server\"
1416 kernel change notify = no
1420 printcap name = /dev/null
1422 winbindd socket directory = $wbsockdir
1423 nmbd:socket dir = $nmbdsockdir
1424 idmap config * : range = 100000-200000
1425 winbind enum users = yes
1426 winbind enum groups = yes
1427 winbind separator = /
1429 # min receivefile size = 4000
1433 smbd:sharedelay = 100000
1434 smbd:writetimeupdatedelay = 500000
1438 store dos attributes = yes
1443 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot
1446 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
1447 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
1448 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
1449 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
1450 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
1451 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
1452 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
1454 print notify backchannel = yes
1456 ncalrpc dir = $prefix_abs/ncalrpc
1458 # The samba3.blackbox.smbclient_s3 test uses this to test that
1459 # sending messages works, and that the %m sub works.
1460 message command = mv %s $shrdir/message.%m
1462 # fsrvp server requires registry shares
1463 registry shares = yes
1465 # Used by RPC SRVSVC tests
1466 add share command = $bindir_abs/smbaddshare
1467 change share command = $bindir_abs/smbchangeshare
1468 delete share command = $bindir_abs/smbdeleteshare
1470 # fruit:copyfile is a global option
1471 fruit:copyfile = yes
1473 #this does not mean that we use non-secure test env,
1474 #it just means we ALLOW one to be configured.
1475 allow insecure wide links = yes
1477 # Begin extra options
1481 #Include user defined custom parameters if set
1484 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
1485 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
1491 comment = smb username is [%U]
1494 comment = Load dirsort module
1495 vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot
1498 comment = encrypt smb username is [%U]
1499 smb encrypt = required
1500 vfs objects = dirsort
1510 force user = $unix_name
1512 [forceuser_unixonly]
1513 comment = force a user with unix user SID and group SID
1515 force user = pdbtest
1517 [forceuser_wkngroup]
1518 comment = force a user with well-known group SID
1520 force user = pdbtest_wkn
1524 force group = nogroup
1532 write list = $unix_name
1535 valid users = $unix_name
1536 access based share enum = yes
1538 path = $msdfs_shrdir
1540 msdfs shuffle referrals = yes
1544 hide unreadable = yes
1547 case sensitive = yes
1550 hide unwriteable files = yes
1553 kernel share modes = no
1567 default devmode = no
1573 comment = smb username is [%U]
1575 vfs objects = nfs4acl_xattr xattr_tdb
1579 comment = smb username is [%U]
1581 vfs objects = nfs4acl_xattr xattr_tdb
1585 comment = smb username is [%U]
1587 force create mode = 777
1590 comment = smb username is [%U]
1592 force create mode = 0
1593 directory mask = 0777
1594 force directory mode = 0
1595 vfs objects = xattr_tdb streams_depot
1606 vfs objects = catia fruit streams_xattr acl_xattr
1608 fruit:ressource = file
1609 fruit:metadata = netatalk
1610 fruit:locking = netatalk
1611 fruit:encoding = native
1614 path = $badnames_shrdir
1618 path = $manglenames_shrdir
1626 path = $widelinks_shrdir
1632 comment = fake shapshots using rsync
1633 vfs objects = shell_snap shadow_copy2
1634 shell_snap:check path command = $fake_snap_pl --check
1635 shell_snap:create command = $fake_snap_pl --create
1636 shell_snap:delete command = $fake_snap_pl --delete
1637 # a relative path here fails, the snapshot dir is no longer found
1638 shadow:snapdir = $shrdir/.snapshots
1641 path = $shadow_shrdir
1642 comment = previous versions snapshots under mount point
1643 vfs objects = shadow_copy2
1644 shadow:mountpoint = $shadow_mntdir
1647 path = $shadow_shrdir
1648 comment = previous versions snapshots outside mount point
1649 vfs objects = shadow_copy2
1650 shadow:mountpoint = $shadow_mntdir
1651 shadow:snapdir = $shadow_tstdir/.snapshots
1654 path = $shadow_shrdir
1655 comment = previous versions with subvolume snapshots, snapshots under base dir
1656 vfs objects = shadow_copy2
1657 shadow:mountpoint = $shadow_mntdir
1658 shadow:basedir = $shadow_basedir
1659 shadow:snapdir = $shadow_basedir/.snapshots
1662 path = $shadow_shrdir
1663 comment = previous versions with subvolume snapshots, snapshots outside mount point
1664 vfs objects = shadow_copy2
1665 shadow:mountpoint = $shadow_mntdir
1666 shadow:basedir = $shadow_basedir
1667 shadow:snapdir = $shadow_tstdir/.snapshots
1670 path = $shadow_shrdir
1671 comment = previous versions at volume root snapshots under mount point
1672 vfs objects = shadow_copy2
1673 shadow:mountpoint = $shadow_shrdir
1676 path = $shadow_shrdir
1677 comment = previous versions at volume root snapshots outside mount point
1678 vfs objects = shadow_copy2
1679 shadow:mountpoint = $shadow_shrdir
1680 shadow:snapdir = $shadow_tstdir/.snapshots
1683 path = $shadow_shrdir
1684 comment = previous versions snapshots everywhere
1685 vfs objects = shadow_copy2
1686 shadow:mountpoint = $shadow_mntdir
1687 shadow:snapdirseverywhere = yes
1690 path = $shadow_shrdir
1691 comment = previous versions using snapsharepath
1692 vfs objects = shadow_copy2
1693 shadow:mountpoint = $shadow_mntdir
1694 shadow:snapdir = $shadow_tstdir/.snapshots
1695 shadow:snapsharepath = share
1698 path = $shadow_shrdir
1699 comment = previous versions with wide links allowed
1700 vfs objects = shadow_copy2
1701 shadow:mountpoint = $shadow_mntdir
1704 path = $shrdir/dfree
1705 vfs objects = fake_dfq
1706 admin users = $unix_name
1707 include = $dfqconffile
1711 unless (open(DFQCONF, ">$dfqconffile")) {
1712 warn("Unable to open $dfqconffile");
1718 ## create a test account
1721 unless (open(PASSWD, ">$nss_wrapper_passwd")) {
1722 warn("Unable to open $nss_wrapper_passwd");
1725 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
1726 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
1727 pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
1728 pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
1729 userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
1730 pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false
1731 force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false
1732 smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false
1734 if ($unix_uid != 0) {
1735 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
1740 unless (open(GROUP, ">$nss_wrapper_group")) {
1741 warn("Unable to open $nss_wrapper_group");
1744 print GROUP "nobody:x:$gid_nobody:
1745 nogroup:x:$gid_nogroup:nobody
1746 $unix_name-group:x:$unix_gids[0]:
1747 domusers:X:$gid_domusers:
1748 domadmins:X:$gid_domadmins:
1749 userdup:x:$gid_userdup:$unix_name
1750 everyone:x:$gid_everyone:
1751 force_user:x:$gid_force_user:
1753 if ($unix_gids[0] != 0) {
1754 print GROUP "root:x:$gid_root:
1761 my $hostname = lc($server);
1762 unless (open(HOSTS, ">>$nss_wrapper_hosts")) {
1763 warn("Unable to open $nss_wrapper_hosts");
1766 print HOSTS "${server_ip} ${hostname}.samba.example.com ${hostname}\n";
1767 print HOSTS "${server_ipv6} ${hostname}.samba.example.com ${hostname}\n";
1771 unless (open(RESOLV_CONF, ">$resolv_conf")) {
1772 warn("Unable to open $resolv_conf");
1775 if (defined($dc_server_ip) or defined($dc_server_ipv6)) {
1776 if (defined($dc_server_ip)) {
1777 print RESOLV_CONF "nameserver $dc_server_ip\n";
1779 if (defined($dc_server_ipv6)) {
1780 print RESOLV_CONF "nameserver $dc_server_ipv6\n";
1783 print RESOLV_CONF "nameserver ${server_ip}\n";
1784 print RESOLV_CONF "nameserver ${server_ipv6}\n";
1788 foreach my $evlog (@eventlog_list) {
1789 my $evlogtdb = "$eventlogdir/$evlog.tdb";
1790 open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
1794 $ENV{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
1795 $ENV{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
1796 $ENV{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
1797 $ENV{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
1798 if ($ENV{SAMBA_DNS_FAKING}) {
1799 $ENV{RESOLV_WRAPPER_CONF} = $resolv_conf;
1801 $ENV{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
1804 createuser($self, $unix_name, $password, $conffile) || die("Unable to create user");
1805 createuser($self, "force_user", $password, $conffile) || die("Unable to create force_user");
1806 createuser($self, "smbget_user", $password, $conffile) || die("Unable to create smbget_user");
1808 open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
1809 print DNS_UPDATE_LIST "A $server. $server_ip\n";
1810 print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n";
1811 close(DNS_UPDATE_LIST);
1813 $ret{SERVER_IP} = $server_ip;
1814 $ret{SERVER_IPV6} = $server_ipv6;
1815 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
1816 $ret{NMBD_TEST_LOG_POS} = 0;
1817 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
1818 $ret{WINBINDD_TEST_LOG_POS} = 0;
1819 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
1820 $ret{SMBD_TEST_LOG_POS} = 0;
1821 $ret{SERVERCONFFILE} = $conffile;
1822 $ret{CONFIGURATION} ="-s $conffile";
1823 $ret{SERVER} = $server;
1824 $ret{USERNAME} = $unix_name;
1825 $ret{USERID} = $unix_uid;
1826 $ret{DOMAIN} = $domain;
1827 $ret{NETBIOSNAME} = $server;
1828 $ret{PASSWORD} = $password;
1829 $ret{PIDDIR} = $piddir;
1830 $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir;
1831 $ret{WINBINDD_PRIV_PIPE_DIR} = $wbsockprivdir;
1832 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
1833 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
1834 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
1835 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
1836 $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
1837 $ret{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
1838 $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
1839 $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind";
1840 if ($ENV{SAMBA_DNS_FAKING}) {
1841 $ret{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
1843 $ret{RESOLV_WRAPPER_CONF} = $resolv_conf;
1845 $ret{LOCAL_PATH} = "$shrdir";
1846 $ret{LOGDIR} = $logdir;
1849 # Avoid hitting system krb5.conf -
1850 # An env that needs Kerberos will reset this to the real
1853 $ret{KRB5_CONFIG} = abs_path($prefix) . "/no_krb5.conf";
1858 sub wait_for_start($$$$$)
1860 my ($self, $envvars, $nmbd, $winbindd, $smbd) = @_;
1863 if ($nmbd eq "yes") {
1866 # give time for nbt server to register its names
1867 print "checking for nmbd\n";
1869 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
1870 my $nmblookup = Samba::bindir_path($self, "nmblookup");
1873 $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
1877 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
1878 system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
1879 system("$nmblookup $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
1880 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
1883 } while ($ret != 0 && $count < 10);
1885 print "NMBD not reachable after 10 retries\n";
1886 teardown_env($self, $envvars);
1891 if ($winbindd eq "yes") {
1892 print "checking for winbindd\n";
1895 $ret = system("SELFTEST_WINBINDD_SOCKET_DIR=" . $envvars->{SELFTEST_WINBINDD_SOCKET_DIR} . " " . Samba::bindir_path($self, "wbinfo") . " --ping-dc");
1900 } while ($ret != 0 && $count < 20);
1902 print "WINBINDD not reachable after 20 seconds\n";
1903 teardown_env($self, $envvars);
1908 if ($smbd eq "yes") {
1909 # make sure smbd is also up set
1910 print "wait for smbd\n";
1914 $ret = system(Samba::bindir_path($self, "smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139");
1919 } while ($ret != 0 && $count < 20);
1921 print "SMBD failed to start up in a reasonable time (20sec)\n";
1922 teardown_env($self, $envvars);
1927 # Ensure we have domain users mapped.
1928 $ret = system(Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} groupmap add rid=513 unixgroup=domusers type=domain");
1932 $ret = system(Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} groupmap add rid=512 unixgroup=domadmins type=domain");
1936 $ret = system(Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin");
1941 if ($winbindd eq "yes") {
1942 # note: creating builtin groups requires winbindd for the
1944 $ret = system("SELFTEST_WINBINDD_SOCKET_DIR=" . $envvars->{SELFTEST_WINBINDD_SOCKET_DIR} . " " . Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} sam createbuiltingroup Users");
1946 print "Failed to create BUILTIN\\Users group\n";
1951 system(Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} cache flush");
1952 $ret = system("SELFTEST_WINBINDD_SOCKET_DIR=" . $envvars->{SELFTEST_WINBINDD_SOCKET_DIR} . " " . Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545");
1957 } while ($ret != 0 && $count < 10);
1959 print "WINBINDD not reachable after 20 seconds\n";
1960 teardown_env($self, $envvars);
1965 print $self->getlog_env($envvars);