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);
15 my ($classname, $bindir, $binary_mapping, $srcdir, $server_maxtime) = @_;
16 my $self = { vars => {},
18 binary_mapping => $binary_mapping,
20 server_maxtime => $server_maxtime
28 my ($self, $envvars) = @_;
30 my $smbdpid = read_pid($envvars, "smbd");
31 my $nmbdpid = read_pid($envvars, "nmbd");
32 my $winbinddpid = read_pid($envvars, "winbindd");
34 $self->stop_sig_term($smbdpid);
35 $self->stop_sig_term($nmbdpid);
36 $self->stop_sig_term($winbinddpid);
40 $self->stop_sig_kill($smbdpid);
41 $self->stop_sig_kill($nmbdpid);
42 $self->stop_sig_kill($winbinddpid);
47 sub getlog_env_app($$$)
49 my ($self, $envvars, $name) = @_;
51 my $title = "$name LOG of: $envvars->{NETBIOSNAME}\n";
54 open(LOG, "<".$envvars->{$name."_TEST_LOG"});
56 seek(LOG, $envvars->{$name."_TEST_LOG_POS"}, SEEK_SET);
60 $envvars->{$name."_TEST_LOG_POS"} = tell(LOG);
63 return "" if $out eq $title;
70 my ($self, $envvars) = @_;
73 $ret .= $self->getlog_env_app($envvars, "SMBD");
74 $ret .= $self->getlog_env_app($envvars, "NMBD");
75 $ret .= $self->getlog_env_app($envvars, "WINBINDD");
82 my ($self, $envvars) = @_;
90 my ($self, $envname, $path) = @_;
92 if (defined($self->{vars}->{$envname})) {
93 return $self->{vars}->{$envname};
96 if ($envname eq "s3dc") {
97 return $self->setup_s3dc("$path/s3dc");
98 } elsif ($envname eq "secshare") {
99 return $self->setup_secshare("$path/secshare");
100 } elsif ($envname eq "maptoguest") {
101 return $self->setup_maptoguest("$path/maptoguest");
102 } elsif ($envname eq "ktest") {
103 return $self->setup_ktest("$path/ktest");
104 } elsif ($envname eq "secserver") {
105 if (not defined($self->{vars}->{s3dc})) {
106 if (not defined($self->setup_s3dc("$path/s3dc"))) {
110 return $self->setup_secserver("$path/secserver", $self->{vars}->{s3dc});
111 } elsif ($envname eq "member") {
112 if (not defined($self->{vars}->{s3dc})) {
113 if (not defined($self->setup_s3dc("$path/s3dc"))) {
117 return $self->setup_member("$path/member", $self->{vars}->{s3dc});
125 my ($self, $path) = @_;
127 print "PROVISIONING S3DC...";
135 my $vars = $self->provision($path,
141 $vars or return undef;
143 $self->check_or_start($vars,
144 "yes", "yes", "yes");
146 if (not $self->wait_for_start($vars)) {
150 $vars->{DC_SERVER} = $vars->{SERVER};
151 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
152 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
153 $vars->{DC_USERNAME} = $vars->{USERNAME};
154 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
156 $self->{vars}->{s3dc} = $vars;
161 sub setup_member($$$)
163 my ($self, $prefix, $s3dcvars) = @_;
165 print "PROVISIONING MEMBER...";
167 my $member_options = "
171 my $ret = $self->provision($prefix,
177 $ret or return undef;
179 my $net = Samba::bindir_path($self, "net");
181 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
182 $cmd .= "$net join $ret->{CONFIGURATION} $s3dcvars->{DOMAIN} member";
183 $cmd .= " -U$s3dcvars->{USERNAME}\%$s3dcvars->{PASSWORD}";
185 if (system($cmd) != 0) {
186 warn("Join failed\n$cmd");
190 $self->check_or_start($ret, "yes", "yes", "yes");
192 if (not $self->wait_for_start($ret)) {
196 $ret->{DC_SERVER} = $s3dcvars->{SERVER};
197 $ret->{DC_SERVER_IP} = $s3dcvars->{SERVER_IP};
198 $ret->{DC_NETBIOSNAME} = $s3dcvars->{NETBIOSNAME};
199 $ret->{DC_USERNAME} = $s3dcvars->{USERNAME};
200 $ret->{DC_PASSWORD} = $s3dcvars->{PASSWORD};
205 sub setup_admember($$$$)
207 my ($self, $prefix, $dcvars, $iface) = @_;
209 print "PROVISIONING S3 AD MEMBER$iface...";
211 my $member_options = "
214 workgroup = $dcvars->{DOMAIN}
215 realm = $dcvars->{REALM}
218 my $ret = $self->provision($prefix,
219 "LOCALADMEMBER$iface",
221 "loCalMember${iface}Pass",
224 $ret or return undef;
227 $ret->{DOMAIN} = $dcvars->{DOMAIN};
228 $ret->{REALM} = $dcvars->{REALM};
231 my $prefix_abs = abs_path($prefix);
233 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
234 $ctx->{domain} = $dcvars->{DOMAIN};
235 $ctx->{realm} = $dcvars->{REALM};
236 $ctx->{dnsname} = lc($dcvars->{REALM});
237 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
238 Samba::mk_krb5_conf($ctx, "");
240 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
242 my $net = Samba::bindir_path($self, "net");
244 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
245 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
246 $cmd .= "$net join $ret->{CONFIGURATION}";
247 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
249 if (system($cmd) != 0) {
250 warn("Join failed\n$cmd");
254 # We need world access to this share, as otherwise the domain
255 # administrator from the AD domain provided by Samba4 can't
256 # access the share for tests.
257 chmod 0777, "$prefix/share";
259 $self->check_or_start($ret,
260 "yes", "yes", "yes");
262 $self->wait_for_start($ret);
264 $ret->{DC_SERVER} = $dcvars->{SERVER};
265 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
266 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
267 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
268 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
270 # Special case, this is called from Samba4.pm but needs to use the Samba3 check_env and get_log_env
271 $ret->{target} = $self;
276 sub setup_plugin_s4_dc($$$$)
278 my ($self, $prefix, $dcvars, $iface) = @_;
280 print "PROVISIONING S4 PLUGIN AD DC$iface...";
282 my $plugin_s4_dc_options = "
283 workgroup = $dcvars->{DOMAIN}
284 realm = $dcvars->{REALM}
288 passdb backend = samba4
289 auth methods = guest samba4
292 rpc_server:epmapper = disabled
293 rpc_server:rpcecho = disabled
294 rpc_server:dssetup = disabled
295 rpc_server:svctl = disabled
296 rpc_server:ntsvcs = disabled
297 rpc_server:eventlog = disabled
298 rpc_server:initshutdown = disabled
300 rpc_server:winreg = embedded
301 rpc_server:srvsvc = embedded
302 rpc_server:netdfs = embedded
303 rpc_server:wkssvc = embedded
304 rpc_server:spoolss = embedded
306 rpc_server:lsarpc = external
307 rpc_server:netlogon = external
308 rpc_server:samr = external
310 rpc_daemon:epmd = disabled
311 rpc_daemon:lsasd = disabled
312 rpc_daemon:spoolssd = disabled
314 rpc_server:tcpip = no
317 vfs objects = dfs_samba4
320 my $ret = $self->provision($prefix,
323 "pluGin${iface}Pass",
324 $plugin_s4_dc_options, 1);
326 $ret or return undef;
329 $ret->{DOMAIN} = $dcvars->{DOMAIN};
330 $ret->{REALM} = $dcvars->{REALM};
331 $ret->{KRB5_CONFIG} = $dcvars->{KRB5_CONFIG};
333 # We need world access to this share, as otherwise the domain
334 # administrator from the AD domain provided by Samba4 can't
335 # access the share for tests.
336 chmod 0777, "$prefix/share";
338 $self->check_or_start($ret,
341 $self->wait_for_start($ret);
343 # Special case, this is called from Samba4.pm but needs to use the Samba3 check_env and get_log_env
344 $ret->{target} = $self;
349 sub setup_secshare($$)
351 my ($self, $path) = @_;
353 print "PROVISIONING server with security=share...";
355 my $secshare_options = "
360 my $vars = $self->provision($path,
366 $vars or return undef;
368 $self->check_or_start($vars, "yes", "no", "yes");
370 if (not $self->wait_for_start($vars)) {
374 $self->{vars}->{secshare} = $vars;
379 sub setup_secserver($$$)
381 my ($self, $prefix, $s3dcvars) = @_;
383 print "PROVISIONING server with security=server...";
385 my $secserver_options = "
387 password server = $s3dcvars->{SERVER_IP}
390 my $ret = $self->provision($prefix,
396 $ret or return undef;
398 $self->check_or_start($ret, "yes", "no", "yes");
400 if (not $self->wait_for_start($ret)) {
404 $ret->{DC_SERVER} = $s3dcvars->{SERVER};
405 $ret->{DC_SERVER_IP} = $s3dcvars->{SERVER_IP};
406 $ret->{DC_NETBIOSNAME} = $s3dcvars->{NETBIOSNAME};
407 $ret->{DC_USERNAME} = $s3dcvars->{USERNAME};
408 $ret->{DC_PASSWORD} = $s3dcvars->{PASSWORD};
415 my ($self, $prefix) = @_;
417 print "PROVISIONING server with security=ads...";
419 my $ktest_options = "
421 realm = ktest.samba.example.com
423 username map = $prefix/lib/username.map
424 server signing = required
427 my $ret = $self->provision($prefix,
433 $ret or return undef;
436 my $prefix_abs = abs_path($prefix);
438 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
439 $ctx->{domain} = "KTEST";
440 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
441 $ctx->{dnsname} = lc($ctx->{realm});
442 $ctx->{kdc_ipv4} = "0.0.0.0";
443 Samba::mk_krb5_conf($ctx, "");
445 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
447 open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map");
449 $ret->{USERNAME} = KTEST\\Administrator
453 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
454 #Samba4 DC with the same parameters as are being used here. The
455 #domain SID is S-1-5-21-1071277805-689288055-3486227160
457 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
458 chmod 0600, "$prefix/private/secrets.tdb";
460 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
461 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
463 #and having in krb5.conf:
464 # ticket_lifetime = 799718400
465 # renew_lifetime = 799718400
467 # The commands for the -2 keytab where were:
468 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
469 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
470 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
471 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
472 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
474 # and then for the -3 keytab, I did
476 # net changetrustpw; kdestroy and the same again.
478 # This creates a credential cache with a very long lifetime (2036 at
479 # at 2011-04), and shows that running 'net changetrustpw' does not
480 # break existing logins (for the secrets.tdb method at least).
483 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
485 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
486 chmod 0600, "$prefix/krb5_ccache-2";
488 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
489 chmod 0600, "$prefix/krb5_ccache-3";
491 # We need world access to this share, as otherwise the domain
492 # administrator from the AD domain provided by ktest can't
493 # access the share for tests.
494 chmod 0777, "$prefix/share";
496 $self->check_or_start($ret, "yes", "no", "yes");
498 if (not $self->wait_for_start($ret)) {
504 sub setup_maptoguest($$)
506 my ($self, $path) = @_;
508 print "PROVISIONING maptoguest...";
511 map to guest = bad user
514 my $vars = $self->provision($path,
520 $vars or return undef;
522 $self->check_or_start($vars,
525 if (not $self->wait_for_start($vars)) {
529 $self->{vars}->{s3maptoguest} = $vars;
534 sub stop_sig_term($$) {
535 my ($self, $pid) = @_;
536 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
539 sub stop_sig_kill($$) {
540 my ($self, $pid) = @_;
541 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
546 my ($env_vars, $app, $pid) = @_;
548 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
555 my ($env_vars, $app) = @_;
557 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
563 sub check_or_start($$$$$) {
564 my ($self, $env_vars, $nmbd, $winbindd, $smbd) = @_;
566 unlink($env_vars->{NMBD_TEST_LOG});
567 print "STARTING NMBD...";
570 open STDOUT, ">$env_vars->{NMBD_TEST_LOG}";
571 open STDERR, '>&STDOUT';
573 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
575 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
576 $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR};
577 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
579 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
580 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
581 $ENV{NSS_WRAPPER_WINBIND_SO_PATH} = $env_vars->{NSS_WRAPPER_WINBIND_SO_PATH};
583 $ENV{UID_WRAPPER} = "1";
585 if ($nmbd ne "yes") {
586 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
588 print("Skip nmbd received signal $signame");
591 sleep($self->{server_maxtime});
595 my @optargs = ("-d0");
596 if (defined($ENV{NMBD_OPTIONS})) {
597 @optargs = split(/ /, $ENV{NMBD_OPTIONS});
600 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "nmbd");
602 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
603 if(defined($ENV{NMBD_VALGRIND})) {
604 @preargs = split(/ /, $ENV{NMBD_VALGRIND});
607 exec(@preargs, Samba::bindir_path($self, "nmbd"), "-F", "--no-process-group", "--log-stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start nmbd: $!");
609 write_pid($env_vars, "nmbd", $pid);
612 unlink($env_vars->{WINBINDD_TEST_LOG});
613 print "STARTING WINBINDD...";
616 open STDOUT, ">$env_vars->{WINBINDD_TEST_LOG}";
617 open STDERR, '>&STDOUT';
619 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
621 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
622 $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR};
623 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
625 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
626 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
627 $ENV{NSS_WRAPPER_WINBIND_SO_PATH} = $env_vars->{NSS_WRAPPER_WINBIND_SO_PATH};
629 $ENV{UID_WRAPPER} = "1";
631 if ($winbindd ne "yes") {
632 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
634 print("Skip winbindd received signal $signame");
637 sleep($self->{server_maxtime});
641 my @optargs = ("-d0");
642 if (defined($ENV{WINBINDD_OPTIONS})) {
643 @optargs = split(/ /, $ENV{WINBINDD_OPTIONS});
646 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "winbindd");
648 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
649 if(defined($ENV{WINBINDD_VALGRIND})) {
650 @preargs = split(/ /, $ENV{WINBINDD_VALGRIND});
653 print "Starting winbindd with config $env_vars->{SERVERCONFFILE}\n";
655 exec(@preargs, Samba::bindir_path($self, "winbindd"), "-F", "--no-process-group", "--stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start winbindd: $!");
657 write_pid($env_vars, "winbindd", $pid);
660 unlink($env_vars->{SMBD_TEST_LOG});
661 print "STARTING SMBD...";
664 open STDOUT, ">$env_vars->{SMBD_TEST_LOG}";
665 open STDERR, '>&STDOUT';
667 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
669 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
670 $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR};
671 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
673 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
674 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
675 $ENV{NSS_WRAPPER_WINBIND_SO_PATH} = $env_vars->{NSS_WRAPPER_WINBIND_SO_PATH};
677 $ENV{UID_WRAPPER} = "1";
679 if ($smbd ne "yes") {
680 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
682 print("Skip smbd received signal $signame");
685 sleep($self->{server_maxtime});
689 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "smbd");
690 my @optargs = ("-d0");
691 if (defined($ENV{SMBD_OPTIONS})) {
692 @optargs = split(/ /, $ENV{SMBD_OPTIONS});
694 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
695 if(defined($ENV{SMBD_VALGRIND})) {
696 @preargs = split(/ /,$ENV{SMBD_VALGRIND});
698 exec(@preargs, Samba::bindir_path($self, "smbd"), "-F", "--no-process-group", "--log-stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start smbd: $!");
700 write_pid($env_vars, "smbd", $pid);
706 sub provision($$$$$$$)
708 my ($self, $prefix, $server, $swiface, $password, $extra_options, $no_delete_prefix) = @_;
711 ## setup the various environment variables we need
715 my $server_ip = "127.0.0.$swiface";
716 my $domain = "SAMBA-TEST";
718 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
721 my $unix_gids_str = $);
722 my @unix_gids = split(" ", $unix_gids_str);
724 my $prefix_abs = abs_path($prefix);
725 my $bindir_abs = abs_path($self->{bindir});
726 my $vfs_modulesdir_abs = ($ENV{VFSLIBDIR} or $bindir_abs);
728 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
732 my $shrdir="$prefix_abs/share";
735 my $libdir="$prefix_abs/lib";
738 my $piddir="$prefix_abs/pid";
741 my $privatedir="$prefix_abs/private";
742 push(@dirs,$privatedir);
744 my $lockdir="$prefix_abs/lockdir";
745 push(@dirs,$lockdir);
747 my $eventlogdir="$prefix_abs/lockdir/eventlog";
748 push(@dirs,$eventlogdir);
750 my $logdir="$prefix_abs/logs";
753 my $driver32dir="$shrdir/W32X86";
754 push(@dirs,$driver32dir);
756 my $driver64dir="$shrdir/x64";
757 push(@dirs,$driver64dir);
759 my $driver40dir="$shrdir/WIN40";
760 push(@dirs,$driver40dir);
762 my $ro_shrdir="$shrdir/root-tmp";
763 push(@dirs,$ro_shrdir);
765 my $msdfs_shrdir="$shrdir/msdfsshare";
766 push(@dirs,$msdfs_shrdir);
768 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
769 push(@dirs,$msdfs_deeppath);
771 # this gets autocreated by winbindd
772 my $wbsockdir="$prefix_abs/winbindd";
773 my $wbsockprivdir="$lockdir/winbindd_privileged";
775 my $nmbdsockdir="$prefix_abs/nmbd";
776 unlink($nmbdsockdir);
779 ## create the test directory layout
781 die ("prefix_abs = ''") if $prefix_abs eq "";
782 die ("prefix_abs = '/'") if $prefix_abs eq "/";
784 mkdir($prefix_abs, 0777);
785 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
786 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
787 system("rm -rf $prefix_abs/*");
789 mkdir($_, 0777) foreach(@dirs);
792 ## create ro and msdfs share layout
795 chmod 0755, $ro_shrdir;
796 my $unreadable_file = "$ro_shrdir/unreadable_file";
797 unless (open(UNREADABLE_FILE, ">$unreadable_file")) {
798 warn("Unable to open $unreadable_file");
801 close(UNREADABLE_FILE);
802 chmod 0600, $unreadable_file;
804 my $msdfs_target = "$ro_shrdir/msdfs-target";
805 unless (open(MSDFS_TARGET, ">$msdfs_target")) {
806 warn("Unable to open $msdfs_target");
810 chmod 0666, $msdfs_target;
811 symlink "msdfs:$server_ip\\ro-tmp", "$msdfs_shrdir/msdfs-src1";
812 symlink "msdfs:$server_ip\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
814 my $conffile="$libdir/server.conf";
816 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/lib/nss_wrapper/nss_wrapper.pl";
817 my $nss_wrapper_passwd = "$privatedir/passwd";
818 my $nss_wrapper_group = "$privatedir/group";
820 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
822 my @eventlog_list = ("dns server", "application");
825 ## calculate uids and gids
828 my ($max_uid, $max_gid);
829 my ($uid_nobody, $uid_root);
830 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers);
832 if ($unix_uid < 0xffff - 2) {
835 $max_uid = $unix_uid;
838 $uid_root = $max_uid - 1;
839 $uid_nobody = $max_uid - 2;
841 if ($unix_gids[0] < 0xffff - 3) {
844 $max_gid = $unix_gids[0];
847 $gid_nobody = $max_gid - 1;
848 $gid_nogroup = $max_gid - 2;
849 $gid_root = $max_gid - 3;
850 $gid_domusers = $max_gid - 4;
856 unless (open(CONF, ">$conffile")) {
857 warn("Unable to open $conffile");
862 netbios name = $server
863 interfaces = $server_ip/8
864 bind interfaces only = yes
865 panic action = $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
869 private dir = $privatedir
870 pid directory = $piddir
871 lock directory = $lockdir
872 log file = $logdir/log.\%m
877 state directory = $lockdir
878 cache directory = $lockdir
880 passdb backend = tdbsam
884 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
885 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
886 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
887 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
888 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
889 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
890 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
892 addprinter command = $mod_printer_pl -a -s $conffile --
893 deleteprinter command = $mod_printer_pl -d -s $conffile --
895 eventlog list = application \"dns server\"
898 kernel change notify = no
902 printcap name = /dev/null
904 winbindd:socket dir = $wbsockdir
905 nmbd:socket dir = $nmbdsockdir
906 idmap config * : range = 100000-200000
907 winbind enum users = yes
908 winbind enum groups = yes
910 # min receivefile size = 4000
914 server signing = auto
916 smbd:sharedelay = 100000
917 # smbd:writetimeupdatedelay = 500000
921 store dos attributes = yes
924 vfs objects = $vfs_modulesdir_abs/xattr_tdb.so $vfs_modulesdir_abs/streams_depot.so
927 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
928 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
929 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
930 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
931 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
932 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
933 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
936 ncalrpc dir = $prefix_abs/ncalrpc
937 rpc_server:epmapper = external
938 rpc_server:spoolss = external
939 rpc_server:lsarpc = external
940 rpc_server:samr = external
941 rpc_server:netlogon = external
942 rpc_server:tcpip = yes
944 rpc_daemon:epmd = fork
945 rpc_daemon:spoolssd = fork
946 rpc_daemon:lsasd = fork
948 resolv:host file = $dns_host_file
950 # The samba3.blackbox.smbclient_s3 test uses this to test that
951 # sending messages works, and that the %m sub works.
952 message command = mv %s $shrdir/message.%m
954 # Begin extra options
958 #Include user defined custom parameters if set
961 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
962 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
968 comment = smb username is [%U]
978 force user = $unix_name
982 force group = nogroup
993 hide unreadable = yes
999 hide unwriteable files = yes
1012 comment = smb username is [%U]
1014 force create mode = 777
1021 ## create a test account
1024 unless (open(PASSWD, ">$nss_wrapper_passwd")) {
1025 warn("Unable to open $nss_wrapper_passwd");
1028 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
1029 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name 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(HOSTS, ">>$ENV{SELFTEST_PREFIX}/dns_host_file") or die("Unable to open $ENV{SELFTEST_PREFIX}/dns_host_file");
1073 print HOSTS "A $server. $server_ip
1077 $ret{SERVER_IP} = $server_ip;
1078 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
1079 $ret{NMBD_TEST_LOG_POS} = 0;
1080 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
1081 $ret{WINBINDD_TEST_LOG_POS} = 0;
1082 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
1083 $ret{SMBD_TEST_LOG_POS} = 0;
1084 $ret{SERVERCONFFILE} = $conffile;
1085 $ret{CONFIGURATION} ="-s $conffile";
1086 $ret{SERVER} = $server;
1087 $ret{USERNAME} = $unix_name;
1088 $ret{USERID} = $unix_uid;
1089 $ret{DOMAIN} = $domain;
1090 $ret{NETBIOSNAME} = $server;
1091 $ret{PASSWORD} = $password;
1092 $ret{PIDDIR} = $piddir;
1093 $ret{WINBINDD_SOCKET_DIR} = $wbsockdir;
1094 $ret{WINBINDD_PRIV_PIPE_DIR} = $wbsockprivdir;
1095 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
1096 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
1097 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
1098 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
1099 $ret{NSS_WRAPPER_WINBIND_SO_PATH} = $ENV{NSS_WRAPPER_WINBIND_SO_PATH};
1100 if (not defined($ret{NSS_WRAPPER_WINBIND_SO_PATH})) {
1101 $ret{NSS_WRAPPER_WINBIND_SO_PATH} = Samba::bindir_path($self, "default/nsswitch/libnss-winbind.so");
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 system(Samba::bindir_path($self, "nmblookup3") ." $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
1117 system(Samba::bindir_path($self, "nmblookup3") ." $envvars->{CONFIGURATION} __SAMBA__");
1118 system(Samba::bindir_path($self, "nmblookup3") ." $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
1119 system(Samba::bindir_path($self, "nmblookup3") ." $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
1120 system(Samba::bindir_path($self, "nmblookup3") ." $envvars->{CONFIGURATION} $envvars->{SERVER}");
1122 # make sure smbd is also up set
1123 print "wait for smbd\n";
1128 $ret = system(Samba::bindir_path($self, "smbclient3") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139");
1133 } while ($ret != 0 && $count < 10);
1135 print "SMBD failed to start up in a reasonable time (20sec)\n";
1136 teardown_env($self, $envvars);
1139 # Ensure we have domain users mapped.
1140 $ret = system(Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} groupmap add rid=513 unixgroup=domusers type=domain");
1145 print $self->getlog_env($envvars);