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
32 my ($classname, $bindir, $binary_mapping, $srcdir, $server_maxtime) = @_;
33 my $self = { vars => {},
35 binary_mapping => $binary_mapping,
37 server_maxtime => $server_maxtime
45 my ($self, $envvars) = @_;
48 # This should cause smbd to terminate gracefully
49 close($envvars->{STDIN_PIPE});
51 my $smbdpid = $envvars->{SMBD_TL_PID};
52 my $nmbdpid = $envvars->{NMBD_TL_PID};
53 my $winbinddpid = $envvars->{WINBINDD_TL_PID};
55 # This should give it time to write out the gcov data
57 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
58 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
59 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
62 && $winbinddchild == -1) {
69 if ($count <= 20 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
73 $self->stop_sig_term($smbdpid);
74 $self->stop_sig_term($nmbdpid);
75 $self->stop_sig_term($winbinddpid);
79 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
80 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
81 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
84 && $winbinddchild == -1) {
91 if ($count <= 10 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
95 warn("timelimit process did not quit on SIGTERM, sending SIGKILL");
96 $self->stop_sig_kill($smbdpid);
97 $self->stop_sig_kill($nmbdpid);
98 $self->stop_sig_kill($winbinddpid);
103 sub getlog_env_app($$$)
105 my ($self, $envvars, $name) = @_;
107 my $title = "$name LOG of: $envvars->{NETBIOSNAME}\n";
110 open(LOG, "<".$envvars->{$name."_TEST_LOG"});
112 seek(LOG, $envvars->{$name."_TEST_LOG_POS"}, SEEK_SET);
116 $envvars->{$name."_TEST_LOG_POS"} = tell(LOG);
119 return "" if $out eq $title;
126 my ($self, $envvars) = @_;
129 $ret .= $self->getlog_env_app($envvars, "SMBD");
130 $ret .= $self->getlog_env_app($envvars, "NMBD");
131 $ret .= $self->getlog_env_app($envvars, "WINBINDD");
138 my ($self, $envvars) = @_;
140 my $childpid = waitpid(-1, WNOHANG);
148 my ($self, $envname, $path) = @_;
150 if (defined($self->{vars}->{$envname})) {
151 return $self->{vars}->{$envname};
154 if ($envname eq "s3dc") {
155 return $self->setup_s3dc("$path/s3dc");
156 } elsif ($envname eq "simpleserver") {
157 return $self->setup_simpleserver("$path/simpleserver");
158 } elsif ($envname eq "maptoguest") {
159 return $self->setup_maptoguest("$path/maptoguest");
160 } elsif ($envname eq "ktest") {
161 return $self->setup_ktest("$path/ktest");
162 } elsif ($envname eq "member") {
163 if (not defined($self->{vars}->{s3dc})) {
164 if (not defined($self->setup_s3dc("$path/s3dc"))) {
168 return $self->setup_member("$path/member", $self->{vars}->{s3dc});
176 my ($self, $path) = @_;
178 print "PROVISIONING S3DC...";
185 rpc_server:epmapper = external
186 rpc_server:spoolss = external
187 rpc_server:lsarpc = external
188 rpc_server:samr = external
189 rpc_server:netlogon = external
190 rpc_server:register_embedded_np = yes
192 rpc_daemon:epmd = fork
193 rpc_daemon:spoolssd = fork
194 rpc_daemon:lsasd = fork
197 my $vars = $self->provision($path,
202 $vars or return undef;
204 $self->check_or_start($vars,
205 "yes", "yes", "yes");
207 if (not $self->wait_for_start($vars)) {
211 $vars->{DC_SERVER} = $vars->{SERVER};
212 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
213 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
214 $vars->{DC_USERNAME} = $vars->{USERNAME};
215 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
217 $self->{vars}->{s3dc} = $vars;
222 sub setup_member($$$)
224 my ($self, $prefix, $s3dcvars) = @_;
226 print "PROVISIONING MEMBER...";
228 my $member_options = "
232 my $ret = $self->provision($prefix,
237 $ret or return undef;
239 my $net = Samba::bindir_path($self, "net");
241 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
242 $cmd .= "$net join $ret->{CONFIGURATION} $s3dcvars->{DOMAIN} member";
243 $cmd .= " -U$s3dcvars->{USERNAME}\%$s3dcvars->{PASSWORD}";
245 if (system($cmd) != 0) {
246 warn("Join failed\n$cmd");
250 $self->check_or_start($ret, "yes", "yes", "yes");
252 if (not $self->wait_for_start($ret)) {
256 $ret->{DC_SERVER} = $s3dcvars->{SERVER};
257 $ret->{DC_SERVER_IP} = $s3dcvars->{SERVER_IP};
258 $ret->{DC_NETBIOSNAME} = $s3dcvars->{NETBIOSNAME};
259 $ret->{DC_USERNAME} = $s3dcvars->{USERNAME};
260 $ret->{DC_PASSWORD} = $s3dcvars->{PASSWORD};
265 sub setup_admember($$$$)
267 my ($self, $prefix, $dcvars) = @_;
269 # If we didn't build with ADS, pretend this env was never available
270 if (not $self->have_ads()) {
274 print "PROVISIONING S3 AD MEMBER...";
276 my $member_options = "
279 workgroup = $dcvars->{DOMAIN}
280 realm = $dcvars->{REALM}
283 my $ret = $self->provision($prefix,
288 $ret or return undef;
291 $ret->{DOMAIN} = $dcvars->{DOMAIN};
292 $ret->{REALM} = $dcvars->{REALM};
295 my $prefix_abs = abs_path($prefix);
297 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
298 $ctx->{domain} = $dcvars->{DOMAIN};
299 $ctx->{realm} = $dcvars->{REALM};
300 $ctx->{dnsname} = lc($dcvars->{REALM});
301 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
302 Samba::mk_krb5_conf($ctx, "");
304 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
306 my $net = Samba::bindir_path($self, "net");
308 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
309 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
310 $cmd .= "$net join $ret->{CONFIGURATION}";
311 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
313 if (system($cmd) != 0) {
314 warn("Join failed\n$cmd");
318 # We need world access to this share, as otherwise the domain
319 # administrator from the AD domain provided by Samba4 can't
320 # access the share for tests.
321 chmod 0777, "$prefix/share";
323 $self->check_or_start($ret,
324 "yes", "yes", "yes");
326 $self->wait_for_start($ret);
328 $ret->{DC_SERVER} = $dcvars->{SERVER};
329 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
330 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
331 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
332 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
334 # Special case, this is called from Samba4.pm but needs to use the Samba3 check_env and get_log_env
335 $ret->{target} = $self;
340 sub setup_simpleserver($$)
342 my ($self, $path) = @_;
343 my $vfs_modulesdir_abs = $ENV{VFSLIBDIR};
345 print "PROVISIONING server with security=share...";
347 my $prefix_abs = abs_path($path);
349 my $simpleserver_options = "
351 vfs objects = $vfs_modulesdir_abs/xattr_tdb.so $vfs_modulesdir_abs/streams_depot.so
354 path = $prefix_abs/share
355 vfs objects = $vfs_modulesdir_abs/aio_fork.so
357 vfs_aio_fork:erratic_testing_mode=yes
360 my $vars = $self->provision($path,
363 $simpleserver_options);
365 $vars or return undef;
367 $self->check_or_start($vars, "yes", "no", "yes");
369 if (not $self->wait_for_start($vars)) {
373 $self->{vars}->{simpleserver} = $vars;
380 my ($self, $prefix) = @_;
382 # If we didn't build with ADS, pretend this env was never available
383 if (not $self->have_ads()) {
387 print "PROVISIONING server with security=ads...";
389 my $ktest_options = "
391 realm = ktest.samba.example.com
393 username map = $prefix/lib/username.map
394 server signing = required
397 my $ret = $self->provision($prefix,
402 $ret or return undef;
405 my $prefix_abs = abs_path($prefix);
407 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
408 $ctx->{domain} = "KTEST";
409 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
410 $ctx->{dnsname} = lc($ctx->{realm});
411 $ctx->{kdc_ipv4} = "0.0.0.0";
412 Samba::mk_krb5_conf($ctx, "");
414 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
416 open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map");
418 $ret->{USERNAME} = KTEST\\Administrator
422 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
423 #Samba4 DC with the same parameters as are being used here. The
424 #domain SID is S-1-5-21-1071277805-689288055-3486227160
426 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
427 chmod 0600, "$prefix/private/secrets.tdb";
429 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
430 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
432 #and having in krb5.conf:
433 # ticket_lifetime = 799718400
434 # renew_lifetime = 799718400
436 # The commands for the -2 keytab where were:
437 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
438 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
439 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
440 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
441 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
443 # and then for the -3 keytab, I did
445 # net changetrustpw; kdestroy and the same again.
447 # This creates a credential cache with a very long lifetime (2036 at
448 # at 2011-04), and shows that running 'net changetrustpw' does not
449 # break existing logins (for the secrets.tdb method at least).
452 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
454 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
455 chmod 0600, "$prefix/krb5_ccache-2";
457 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
458 chmod 0600, "$prefix/krb5_ccache-3";
460 # We need world access to this share, as otherwise the domain
461 # administrator from the AD domain provided by ktest can't
462 # access the share for tests.
463 chmod 0777, "$prefix/share";
465 $self->check_or_start($ret, "yes", "no", "yes");
467 if (not $self->wait_for_start($ret)) {
473 sub setup_maptoguest($$)
475 my ($self, $path) = @_;
477 print "PROVISIONING maptoguest...";
480 map to guest = bad user
483 my $vars = $self->provision($path,
488 $vars or return undef;
490 $self->check_or_start($vars,
493 if (not $self->wait_for_start($vars)) {
497 $self->{vars}->{s3maptoguest} = $vars;
502 sub stop_sig_term($$) {
503 my ($self, $pid) = @_;
504 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
507 sub stop_sig_kill($$) {
508 my ($self, $pid) = @_;
509 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
514 my ($env_vars, $app, $pid) = @_;
516 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
523 my ($env_vars, $app) = @_;
525 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
531 sub check_or_start($$$$$) {
532 my ($self, $env_vars, $nmbd, $winbindd, $smbd) = @_;
534 # use a pipe for stdin in the child processes. This allows
535 # those processes to monitor the pipe for EOF to ensure they
536 # exit when the test script exits
537 pipe(STDIN_READER, $env_vars->{STDIN_PIPE});
539 unlink($env_vars->{NMBD_TEST_LOG});
540 print "STARTING NMBD...";
543 open STDOUT, ">$env_vars->{NMBD_TEST_LOG}";
544 open STDERR, '>&STDOUT';
546 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
548 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
549 $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR};
550 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
552 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
553 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
554 $ENV{NSS_WRAPPER_WINBIND_SO_PATH} = $env_vars->{NSS_WRAPPER_WINBIND_SO_PATH};
556 $ENV{UID_WRAPPER} = "1";
558 if ($nmbd ne "yes") {
559 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
561 print("Skip nmbd received signal $signame");
564 sleep($self->{server_maxtime});
568 my @optargs = ("-d0");
569 if (defined($ENV{NMBD_OPTIONS})) {
570 @optargs = split(/ /, $ENV{NMBD_OPTIONS});
573 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "nmbd");
575 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
576 if(defined($ENV{NMBD_VALGRIND})) {
577 @preargs = split(/ /, $ENV{NMBD_VALGRIND});
580 close($env_vars->{STDIN_PIPE});
581 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
583 exec(@preargs, Samba::bindir_path($self, "nmbd"), "-F", "--no-process-group", "--log-stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start nmbd: $!");
585 $env_vars->{NMBD_TL_PID} = $pid;
586 write_pid($env_vars, "nmbd", $pid);
589 unlink($env_vars->{WINBINDD_TEST_LOG});
590 print "STARTING WINBINDD...";
593 open STDOUT, ">$env_vars->{WINBINDD_TEST_LOG}";
594 open STDERR, '>&STDOUT';
596 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
598 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
599 $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR};
600 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
602 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
603 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
604 $ENV{NSS_WRAPPER_WINBIND_SO_PATH} = $env_vars->{NSS_WRAPPER_WINBIND_SO_PATH};
606 $ENV{UID_WRAPPER} = "1";
608 if ($winbindd ne "yes") {
609 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
611 print("Skip winbindd received signal $signame");
614 sleep($self->{server_maxtime});
618 my @optargs = ("-d0");
619 if (defined($ENV{WINBINDD_OPTIONS})) {
620 @optargs = split(/ /, $ENV{WINBINDD_OPTIONS});
623 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "winbindd");
625 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
626 if(defined($ENV{WINBINDD_VALGRIND})) {
627 @preargs = split(/ /, $ENV{WINBINDD_VALGRIND});
630 print "Starting winbindd with config $env_vars->{SERVERCONFFILE}\n";
632 close($env_vars->{STDIN_PIPE});
633 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
635 exec(@preargs, Samba::bindir_path($self, "winbindd"), "-F", "--no-process-group", "--stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start winbindd: $!");
637 $env_vars->{WINBINDD_TL_PID} = $pid;
638 write_pid($env_vars, "winbindd", $pid);
641 unlink($env_vars->{SMBD_TEST_LOG});
642 print "STARTING SMBD...";
645 open STDOUT, ">$env_vars->{SMBD_TEST_LOG}";
646 open STDERR, '>&STDOUT';
648 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
650 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
651 $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR};
652 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
654 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
655 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
656 $ENV{NSS_WRAPPER_WINBIND_SO_PATH} = $env_vars->{NSS_WRAPPER_WINBIND_SO_PATH};
658 $ENV{UID_WRAPPER} = "1";
660 if ($smbd ne "yes") {
661 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
663 print("Skip smbd received signal $signame");
666 sleep($self->{server_maxtime});
670 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "smbd");
671 my @optargs = ("-d0");
672 if (defined($ENV{SMBD_OPTIONS})) {
673 @optargs = split(/ /, $ENV{SMBD_OPTIONS});
675 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
676 if(defined($ENV{SMBD_VALGRIND})) {
677 @preargs = split(/ /,$ENV{SMBD_VALGRIND});
680 close($env_vars->{STDIN_PIPE});
681 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
683 exec(@preargs, Samba::bindir_path($self, "smbd"), "-F", "--no-process-group", "--log-stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start smbd: $!");
685 $env_vars->{SMBD_TL_PID} = $pid;
686 write_pid($env_vars, "smbd", $pid);
694 sub provision($$$$$$)
696 my ($self, $prefix, $server, $password, $extra_options, $no_delete_prefix) = @_;
699 ## setup the various environment variables we need
702 my $swiface = Samba::get_interface($server);
704 my $server_ip = "127.0.0.$swiface";
705 my $domain = "SAMBA-TEST";
707 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
710 my $unix_gids_str = $);
711 my @unix_gids = split(" ", $unix_gids_str);
713 my $prefix_abs = abs_path($prefix);
714 my $bindir_abs = abs_path($self->{bindir});
715 my $vfs_modulesdir_abs = ($ENV{VFSLIBDIR} or $bindir_abs);
717 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
721 my $shrdir="$prefix_abs/share";
724 my $libdir="$prefix_abs/lib";
727 my $piddir="$prefix_abs/pid";
730 my $privatedir="$prefix_abs/private";
731 push(@dirs,$privatedir);
733 my $lockdir="$prefix_abs/lockdir";
734 push(@dirs,$lockdir);
736 my $eventlogdir="$prefix_abs/lockdir/eventlog";
737 push(@dirs,$eventlogdir);
739 my $logdir="$prefix_abs/logs";
742 my $driver32dir="$shrdir/W32X86";
743 push(@dirs,$driver32dir);
745 my $driver64dir="$shrdir/x64";
746 push(@dirs,$driver64dir);
748 my $driver40dir="$shrdir/WIN40";
749 push(@dirs,$driver40dir);
751 my $ro_shrdir="$shrdir/root-tmp";
752 push(@dirs,$ro_shrdir);
754 my $msdfs_shrdir="$shrdir/msdfsshare";
755 push(@dirs,$msdfs_shrdir);
757 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
758 push(@dirs,$msdfs_deeppath);
760 # this gets autocreated by winbindd
761 my $wbsockdir="$prefix_abs/winbindd";
762 my $wbsockprivdir="$lockdir/winbindd_privileged";
764 my $nmbdsockdir="$prefix_abs/nmbd";
765 unlink($nmbdsockdir);
768 ## create the test directory layout
770 die ("prefix_abs = ''") if $prefix_abs eq "";
771 die ("prefix_abs = '/'") if $prefix_abs eq "/";
773 mkdir($prefix_abs, 0777);
774 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
775 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
776 system("rm -rf $prefix_abs/*");
778 mkdir($_, 0777) foreach(@dirs);
781 ## create ro and msdfs share layout
784 chmod 0755, $ro_shrdir;
785 my $unreadable_file = "$ro_shrdir/unreadable_file";
786 unless (open(UNREADABLE_FILE, ">$unreadable_file")) {
787 warn("Unable to open $unreadable_file");
790 close(UNREADABLE_FILE);
791 chmod 0600, $unreadable_file;
793 my $msdfs_target = "$ro_shrdir/msdfs-target";
794 unless (open(MSDFS_TARGET, ">$msdfs_target")) {
795 warn("Unable to open $msdfs_target");
799 chmod 0666, $msdfs_target;
800 symlink "msdfs:$server_ip\\ro-tmp", "$msdfs_shrdir/msdfs-src1";
801 symlink "msdfs:$server_ip\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
803 my $conffile="$libdir/server.conf";
805 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/lib/nss_wrapper/nss_wrapper.pl";
806 my $nss_wrapper_passwd = "$privatedir/passwd";
807 my $nss_wrapper_group = "$privatedir/group";
809 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
811 my @eventlog_list = ("dns server", "application");
814 ## calculate uids and gids
817 my ($max_uid, $max_gid);
818 my ($uid_nobody, $uid_root, $uid_pdbtest);
819 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers);
821 if ($unix_uid < 0xffff - 2) {
824 $max_uid = $unix_uid;
827 $uid_root = $max_uid - 1;
828 $uid_nobody = $max_uid - 2;
829 $uid_pdbtest = $max_uid - 3;
831 if ($unix_gids[0] < 0xffff - 3) {
834 $max_gid = $unix_gids[0];
837 $gid_nobody = $max_gid - 1;
838 $gid_nogroup = $max_gid - 2;
839 $gid_root = $max_gid - 3;
840 $gid_domusers = $max_gid - 4;
846 unless (open(CONF, ">$conffile")) {
847 warn("Unable to open $conffile");
852 netbios name = $server
853 interfaces = $server_ip/8
854 bind interfaces only = yes
855 panic action = $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
856 smbd:suicide mode = yes
860 private dir = $privatedir
861 pid directory = $piddir
862 lock directory = $lockdir
863 log file = $logdir/log.\%m
868 state directory = $lockdir
869 cache directory = $lockdir
871 passdb backend = tdbsam
875 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
876 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
877 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
878 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
879 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
880 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
881 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
883 addprinter command = $mod_printer_pl -a -s $conffile --
884 deleteprinter command = $mod_printer_pl -d -s $conffile --
886 eventlog list = application \"dns server\"
889 kernel change notify = no
893 printcap name = /dev/null
895 winbindd:socket dir = $wbsockdir
896 nmbd:socket dir = $nmbdsockdir
897 idmap config * : range = 100000-200000
898 winbind enum users = yes
899 winbind enum groups = yes
901 # min receivefile size = 4000
904 server signing = auto
906 smbd:sharedelay = 100000
907 smbd:writetimeupdatedelay = 500000
911 store dos attributes = yes
913 directory mask = 0777
915 vfs objects = $vfs_modulesdir_abs/acl_xattr.so $vfs_modulesdir_abs/fake_acls.so $vfs_modulesdir_abs/xattr_tdb.so $vfs_modulesdir_abs/streams_depot.so
918 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
919 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
920 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
921 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
922 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
923 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
924 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
927 ncalrpc dir = $prefix_abs/ncalrpc
928 resolv:host file = $dns_host_file
930 # The samba3.blackbox.smbclient_s3 test uses this to test that
931 # sending messages works, and that the %m sub works.
932 message command = mv %s $shrdir/message.%m
934 # Begin extra options
938 #Include user defined custom parameters if set
941 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
942 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
948 comment = smb username is [%U]
951 comment = encrypt smb username is [%U]
952 smb encrypt = required
962 force user = $unix_name
966 force group = nogroup
977 hide unreadable = yes
983 hide unwriteable files = yes
986 kernel share modes = no
1002 comment = smb username is [%U]
1004 force create mode = 777
1007 comment = smb username is [%U]
1009 force create mode = 0
1010 directory mask = 0777
1011 force directory mode = 0
1012 vfs objects = $vfs_modulesdir_abs/xattr_tdb.so
1020 ## create a test account
1023 unless (open(PASSWD, ">$nss_wrapper_passwd")) {
1024 warn("Unable to open $nss_wrapper_passwd");
1027 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
1028 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
1029 pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
1031 if ($unix_uid != 0) {
1032 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false";
1036 unless (open(GROUP, ">$nss_wrapper_group")) {
1037 warn("Unable to open $nss_wrapper_group");
1040 print GROUP "nobody:x:$gid_nobody:
1041 nogroup:x:$gid_nogroup:nobody
1042 $unix_name-group:x:$unix_gids[0]:
1043 domusers:X:$gid_domusers:
1045 if ($unix_gids[0] != 0) {
1046 print GROUP "root:x:$gid_root:";
1051 foreach my $evlog (@eventlog_list) {
1052 my $evlogtdb = "$eventlogdir/$evlog.tdb";
1053 open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
1057 $ENV{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
1058 $ENV{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
1060 my $cmd = Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $unix_name > /dev/null";
1061 unless (open(PWD, "|$cmd")) {
1062 warn("Unable to set password for test account\n$cmd");
1065 print PWD "$password\n$password\n";
1066 unless (close(PWD)) {
1067 warn("Unable to set password for test account\n$cmd");
1072 open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
1073 print DNS_UPDATE_LIST "A $server. $server_ip";
1074 close(DNS_UPDATE_LIST);
1076 if (system("$ENV{SRCDIR_ABS}/source4/scripting/bin/samba_dnsupdate --all-interfaces --use-file=$dns_host_file -s $conffile --update-list=$prefix/dns_update_list --no-substiutions --no-credentials") != 0) {
1077 die "Unable to update hostname into $dns_host_file";
1080 $ret{SERVER_IP} = $server_ip;
1081 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
1082 $ret{NMBD_TEST_LOG_POS} = 0;
1083 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
1084 $ret{WINBINDD_TEST_LOG_POS} = 0;
1085 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
1086 $ret{SMBD_TEST_LOG_POS} = 0;
1087 $ret{SERVERCONFFILE} = $conffile;
1088 $ret{CONFIGURATION} ="-s $conffile";
1089 $ret{SERVER} = $server;
1090 $ret{USERNAME} = $unix_name;
1091 $ret{USERID} = $unix_uid;
1092 $ret{DOMAIN} = $domain;
1093 $ret{NETBIOSNAME} = $server;
1094 $ret{PASSWORD} = $password;
1095 $ret{PIDDIR} = $piddir;
1096 $ret{WINBINDD_SOCKET_DIR} = $wbsockdir;
1097 $ret{WINBINDD_PRIV_PIPE_DIR} = $wbsockprivdir;
1098 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
1099 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
1100 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
1101 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
1102 $ret{NSS_WRAPPER_WINBIND_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
1103 $ret{LOCAL_PATH} = "$shrdir";
1108 sub wait_for_start($$)
1110 my ($self, $envvars) = @_;
1112 # give time for nbt server to register its names
1113 print "delaying for nbt name registration\n";
1115 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
1116 my $nmblookup = Samba::bindir_path($self, "nmblookup3");
1117 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
1118 system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
1119 system("$nmblookup $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
1120 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
1121 system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
1123 # make sure smbd is also up set
1124 print "wait for smbd\n";
1129 $ret = system(Samba::bindir_path($self, "smbclient3") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139");
1134 } while ($ret != 0 && $count < 10);
1136 print "SMBD failed to start up in a reasonable time (20sec)\n";
1137 teardown_env($self, $envvars);
1140 # Ensure we have domain users mapped.
1141 $ret = system(Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} groupmap add rid=513 unixgroup=domusers type=domain");
1146 print $self->getlog_env($envvars);