Cosmetic. Fix bad indentation.
[Samba.git] / selftest / target / Samba3.pm
blob38148ebbeeb6f190f767346880189491dde53985
1 #!/usr/bin/perl
2 # Bootstrap Samba and run a number of tests against it.
3 # Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
4 # Published under the GNU GPL, v3 or later.
6 package Samba3;
8 use strict;
9 use Cwd qw(abs_path);
10 use FindBin qw($RealBin);
11 use POSIX;
13 sub binpath($$)
15 my ($self, $binary) = @_;
17 if (defined($self->{bindir})) {
18 my $path = "$self->{bindir}/$binary";
19 -f $path or die("File $path doesn't exist");
20 return $path;
23 return $binary;
26 sub new($$) {
27 my ($classname, $bindir, $srcdir) = @_;
28 my $self = { bindir => $bindir,
29 srcdir => $srcdir
31 bless $self;
32 return $self;
35 sub teardown_env($$)
37 my ($self, $envvars) = @_;
39 my $smbdpid = read_pid($envvars, "smbd");
40 my $nmbdpid = read_pid($envvars, "nmbd");
41 my $winbinddpid = read_pid($envvars, "winbindd");
43 $self->stop_sig_term($smbdpid);
44 $self->stop_sig_term($nmbdpid);
45 $self->stop_sig_term($winbinddpid);
47 sleep(2);
49 $self->stop_sig_kill($smbdpid);
50 $self->stop_sig_kill($nmbdpid);
51 $self->stop_sig_kill($winbinddpid);
53 return 0;
56 sub getlog_env_app($$$)
58 my ($self, $envvars, $name) = @_;
60 my $title = "$name LOG of: $envvars->{NETBIOSNAME}\n";
61 my $out = $title;
63 open(LOG, "<".$envvars->{$name."_TEST_LOG"});
65 seek(LOG, $envvars->{$name."_TEST_LOG_POS"}, SEEK_SET);
66 while (<LOG>) {
67 $out .= $_;
69 $envvars->{$name."_TEST_LOG_POS"} = tell(LOG);
70 close(LOG);
72 return "" if $out eq $title;
74 return $out;
77 sub getlog_env($$)
79 my ($self, $envvars) = @_;
80 my $ret = "";
82 $ret .= $self->getlog_env_app($envvars, "SMBD");
83 $ret .= $self->getlog_env_app($envvars, "NMBD");
84 $ret .= $self->getlog_env_app($envvars, "WINBINDD");
86 return $ret;
89 sub check_env($$)
91 my ($self, $envvars) = @_;
93 # TODO ...
94 return 1;
97 sub setup_env($$$)
99 my ($self, $envname, $path) = @_;
101 if ($envname eq "dc") {
102 return $self->setup_dc("$path/dc");
103 } elsif ($envname eq "secshare") {
104 return $self->setup_secshare("$path/secshare");
105 } elsif ($envname eq "secserver") {
106 if (not defined($self->{vars}->{dc})) {
107 $self->setup_dc("$path/dc");
109 return $self->setup_secserver("$path/secserver", $self->{vars}->{dc});
110 } elsif ($envname eq "member") {
111 if (not defined($self->{vars}->{dc})) {
112 $self->setup_dc("$path/dc");
114 return $self->setup_member("$path/member", $self->{vars}->{dc});
115 } else {
116 return undef;
120 sub setup_dc($$)
122 my ($self, $path) = @_;
124 print "PROVISIONING DC...";
126 my $dc_options = "
127 domain master = yes
128 domain logons = yes
129 lanman auth = yes
132 my $vars = $self->provision($path,
133 "LOCALDC2",
135 "localdc2pass",
136 $dc_options);
138 $self->check_or_start($vars,
139 ($ENV{SMBD_MAXTIME} or 2700),
140 "yes", "yes", "yes");
142 $self->wait_for_start($vars);
144 $vars->{DC_SERVER} = $vars->{SERVER};
145 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
146 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
147 $vars->{DC_USERNAME} = $vars->{USERNAME};
148 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
150 $self->{vars}->{dc} = $vars;
152 return $vars;
155 sub setup_member($$$)
157 my ($self, $prefix, $dcvars) = @_;
159 print "PROVISIONING MEMBER...";
161 my $member_options = "
162 security = domain
163 server signing = on
165 my $ret = $self->provision($prefix,
166 "LOCALMEMBER3",
168 "localmember3pass",
169 $member_options);
171 $ret or die("Unable to provision");
173 my $net = $self->binpath("net");
174 my $cmd = "";
175 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
176 $cmd .= "$net join $ret->{CONFIGURATION} $dcvars->{DOMAIN} member";
177 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
179 system($cmd) == 0 or die("Join failed\n$cmd");
181 $self->check_or_start($ret,
182 ($ENV{SMBD_MAXTIME} or 2700),
183 "yes", "yes", "yes");
185 $self->wait_for_start($ret);
187 $ret->{DC_SERVER} = $dcvars->{SERVER};
188 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
189 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
190 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
191 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
193 return $ret;
196 sub setup_secshare($$)
198 my ($self, $path) = @_;
200 print "PROVISIONING server with security=share...";
202 my $secshare_options = "
203 security = share
204 lanman auth = yes
207 my $vars = $self->provision($path,
208 "LOCALSHARE4",
210 "local4pass",
211 $secshare_options);
213 $self->check_or_start($vars,
214 ($ENV{SMBD_MAXTIME} or 2700),
215 "yes", "no", "yes");
217 $self->wait_for_start($vars);
219 $self->{vars}->{secshare} = $vars;
221 return $vars;
224 sub setup_secserver($$$)
226 my ($self, $prefix, $dcvars) = @_;
228 print "PROVISIONING server with security=server...";
230 my $secserver_options = "
231 security = server
232 password server = $dcvars->{SERVER_IP}
235 my $ret = $self->provision($prefix,
236 "LOCALSERVER5",
238 "localserver5pass",
239 $secserver_options);
241 $ret or die("Unable to provision");
243 $self->check_or_start($ret,
244 ($ENV{SMBD_MAXTIME} or 2700),
245 "yes", "no", "yes");
247 $self->wait_for_start($ret);
249 $ret->{DC_SERVER} = $dcvars->{SERVER};
250 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
251 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
252 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
253 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
255 return $ret;
258 sub stop_sig_term($$) {
259 my ($self, $pid) = @_;
260 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
263 sub stop_sig_kill($$) {
264 my ($self, $pid) = @_;
265 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
268 sub write_pid($$$)
270 my ($env_vars, $app, $pid) = @_;
272 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
273 print PID $pid;
274 close(PID);
277 sub read_pid($$)
279 my ($env_vars, $app) = @_;
281 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
282 my $pid = <PID>;
283 close(PID);
284 return $pid;
287 sub check_or_start($$$$$) {
288 my ($self, $env_vars, $maxtime, $nmbd, $winbindd, $smbd) = @_;
290 unlink($env_vars->{NMBD_TEST_LOG});
291 print "STARTING NMBD...";
292 my $pid = fork();
293 if ($pid == 0) {
294 open STDOUT, ">$env_vars->{NMBD_TEST_LOG}";
295 open STDERR, '>&STDOUT';
297 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
299 $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR};
300 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
302 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
303 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
304 $ENV{NSS_WRAPPER_WINBIND_SO_PATH} = $env_vars->{NSS_WRAPPER_WINBIND_SO_PATH};
306 if ($nmbd ne "yes") {
307 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
308 my $signame = shift;
309 print("Skip nmbd received signal $signame");
310 exit 0;
312 sleep($maxtime);
313 exit 0;
316 my @optargs = ("-d0");
317 if (defined($ENV{NMBD_OPTIONS})) {
318 @optargs = split(/ /, $ENV{NMBD_OPTIONS});
321 $ENV{MAKE_TEST_BINARY} = $self->binpath("nmbd");
323 my @preargs = ($self->binpath("timelimit"), $maxtime);
324 if(defined($ENV{NMBD_VALGRIND})) {
325 @preargs = split(/ /, $ENV{NMBD_VALGRIND});
328 exec(@preargs, $self->binpath("nmbd"), "-F", "--no-process-group", "-S", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start nmbd: $!");
330 write_pid($env_vars, "nmbd", $pid);
331 print "DONE\n";
333 unlink($env_vars->{WINBINDD_TEST_LOG});
334 print "STARTING WINBINDD...";
335 $pid = fork();
336 if ($pid == 0) {
337 open STDOUT, ">$env_vars->{WINBINDD_TEST_LOG}";
338 open STDERR, '>&STDOUT';
340 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
342 $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR};
343 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
345 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
346 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
347 $ENV{NSS_WRAPPER_WINBIND_SO_PATH} = $env_vars->{NSS_WRAPPER_WINBIND_SO_PATH};
349 if ($winbindd ne "yes") {
350 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
351 my $signame = shift;
352 print("Skip winbindd received signal $signame");
353 exit 0;
355 sleep($maxtime);
356 exit 0;
359 my @optargs = ("-d0");
360 if (defined($ENV{WINBINDD_OPTIONS})) {
361 @optargs = split(/ /, $ENV{WINBINDD_OPTIONS});
364 $ENV{MAKE_TEST_BINARY} = $self->binpath("winbindd");
366 my @preargs = ($self->binpath("timelimit"), $maxtime);
367 if(defined($ENV{WINBINDD_VALGRIND})) {
368 @preargs = split(/ /, $ENV{WINBINDD_VALGRIND});
371 exec(@preargs, $self->binpath("winbindd"), "-F", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start winbindd: $!");
373 write_pid($env_vars, "winbindd", $pid);
374 print "DONE\n";
376 unlink($env_vars->{SMBD_TEST_LOG});
377 print "STARTING SMBD...";
378 $pid = fork();
379 if ($pid == 0) {
380 open STDOUT, ">$env_vars->{SMBD_TEST_LOG}";
381 open STDERR, '>&STDOUT';
383 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
385 $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR};
386 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
388 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
389 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
390 $ENV{NSS_WRAPPER_WINBIND_SO_PATH} = $env_vars->{NSS_WRAPPER_WINBIND_SO_PATH};
392 if ($smbd ne "yes") {
393 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
394 my $signame = shift;
395 print("Skip smbd received signal $signame");
396 exit 0;
398 sleep($maxtime);
399 exit 0;
402 $ENV{MAKE_TEST_BINARY} = $self->binpath("smbd");
403 my @optargs = ("-d0");
404 if (defined($ENV{SMBD_OPTIONS})) {
405 @optargs = split(/ /, $ENV{SMBD_OPTIONS});
407 my @preargs = ($self->binpath("timelimit"), $maxtime);
408 if(defined($ENV{SMBD_VALGRIND})) {
409 @preargs = split(/ /,$ENV{SMBD_VALGRIND});
411 exec(@preargs, $self->binpath("smbd"), "-F", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start smbd: $!");
413 write_pid($env_vars, "smbd", $pid);
414 print "DONE\n";
416 return 0;
419 sub provision($$$$$$)
421 my ($self, $prefix, $server, $swiface, $password, $extra_options) = @_;
424 ## setup the various environment variables we need
427 my %ret = ();
428 my $server_ip = "127.0.0.$swiface";
429 my $domain = "SAMBA-TEST";
431 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
432 chomp $unix_name;
433 my $unix_uid = $>;
434 my $unix_gids_str = $);
435 my @unix_gids = split(" ", $unix_gids_str);
437 my $prefix_abs = abs_path($prefix);
438 my $bindir_abs = abs_path($self->{bindir});
439 my $vfs_modulesdir_abs = ($ENV{VFSLIBDIR} or $bindir_abs);
441 my @dirs = ();
443 my $shrdir="$prefix_abs/share";
444 push(@dirs,$shrdir);
446 my $libdir="$prefix_abs/lib";
447 push(@dirs,$libdir);
449 my $piddir="$prefix_abs/pid";
450 push(@dirs,$piddir);
452 my $privatedir="$prefix_abs/private";
453 push(@dirs,$privatedir);
455 my $lockdir="$prefix_abs/lockdir";
456 push(@dirs,$lockdir);
458 my $eventlogdir="$prefix_abs/lockdir/eventlog";
459 push(@dirs,$eventlogdir);
461 my $logdir="$prefix_abs/logs";
462 push(@dirs,$logdir);
464 my $driver32dir="$shrdir/W32X86";
465 push(@dirs,$driver32dir);
467 my $driver64dir="$shrdir/x64";
468 push(@dirs,$driver64dir);
470 my $driver40dir="$shrdir/WIN40";
471 push(@dirs,$driver40dir);
473 my $ro_shrdir="$shrdir/root-tmp";
474 push(@dirs,$ro_shrdir);
476 my $msdfs_shrdir="$shrdir/msdfsshare";
477 push(@dirs,$msdfs_shrdir);
479 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
480 push(@dirs,$msdfs_deeppath);
482 # this gets autocreated by winbindd
483 my $wbsockdir="$prefix_abs/winbindd";
484 my $wbsockprivdir="$lockdir/winbindd_privileged";
486 my $nmbdsockdir="$prefix_abs/nmbd";
487 unlink($nmbdsockdir);
490 ## create the test directory layout
492 die ("prefix_abs = ''") if $prefix_abs eq "";
493 die ("prefix_abs = '/'") if $prefix_abs eq "/";
495 mkdir($prefix_abs, 0777);
496 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
497 system("rm -rf $prefix_abs/*");
498 mkdir($_, 0777) foreach(@dirs);
501 ## create ro and msdfs share layout
504 chmod 0755, $ro_shrdir;
505 my $unreadable_file = "$ro_shrdir/unreadable_file";
506 open(UNREADABLE_FILE, ">$unreadable_file") or die("Unable to open $unreadable_file");
507 close(UNREADABLE_FILE);
508 chmod 0600, $unreadable_file;
510 my $msdfs_target = "$ro_shrdir/msdfs-target";
511 open(MSDFS_TARGET, ">$msdfs_target") or die("Unable to open $msdfs_target");
512 close(MSDFS_TARGET);
513 chmod 0666, $msdfs_target;
514 symlink "msdfs:$server_ip\\ro-tmp", "$msdfs_shrdir/msdfs-src1";
515 symlink "msdfs:$server_ip\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
517 my $conffile="$libdir/server.conf";
519 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/lib/nss_wrapper/nss_wrapper.pl";
520 my $nss_wrapper_passwd = "$privatedir/passwd";
521 my $nss_wrapper_group = "$privatedir/group";
523 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
525 my @eventlog_list = ("dns server", "application");
528 ## calculate uids and gids
531 my ($max_uid, $max_gid);
532 my ($uid_nobody, $uid_root);
533 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers);
535 if ($unix_uid < 0xffff - 2) {
536 $max_uid = 0xffff;
537 } else {
538 $max_uid = $unix_uid;
541 $uid_root = $max_uid - 1;
542 $uid_nobody = $max_uid - 2;
544 if ($unix_gids[0] < 0xffff - 3) {
545 $max_gid = 0xffff;
546 } else {
547 $max_gid = $unix_gids[0];
550 $gid_nobody = $max_gid - 1;
551 $gid_nogroup = $max_gid - 2;
552 $gid_root = $max_gid - 3;
553 $gid_domusers = $max_gid - 4;
556 ## create conffile
559 open(CONF, ">$conffile") or die("Unable to open $conffile");
560 print CONF "
561 [global]
562 netbios name = $server
563 interfaces = $server_ip/8
564 bind interfaces only = yes
565 panic action = $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
567 workgroup = $domain
569 private dir = $privatedir
570 pid directory = $piddir
571 lock directory = $lockdir
572 log file = $logdir/log.\%m
573 log level = 0
574 debug pid = yes
576 name resolve order = bcast
578 state directory = $lockdir
579 cache directory = $lockdir
581 passdb backend = tdbsam
583 time server = yes
585 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
586 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
587 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
588 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
589 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
590 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
591 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
593 addprinter command = $mod_printer_pl -a -s $conffile --
594 deleteprinter command = $mod_printer_pl -d -s $conffile --
596 eventlog list = application \"dns server\"
598 kernel oplocks = no
599 kernel change notify = no
601 syslog = no
602 printing = bsd
603 printcap name = /dev/null
605 winbindd:socket dir = $wbsockdir
606 nmbd:socket dir = $nmbdsockdir
607 idmap config * : range = 100000-200000
608 winbind enum users = yes
609 winbind enum groups = yes
611 # min receivefile size = 4000
613 max protocol = SMB2
614 read only = no
615 server signing = auto
617 smbd:sharedelay = 100000
618 # smbd:writetimeupdatedelay = 500000
619 map hidden = no
620 map system = no
621 map readonly = no
622 store dos attributes = yes
623 create mask = 755
624 vfs objects = $vfs_modulesdir_abs/xattr_tdb.so $vfs_modulesdir_abs/streams_depot.so
626 printing = vlp
627 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
628 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
629 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
630 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
631 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
632 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
633 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
634 lpq cache time = 0
636 ncalrpc dir = $lockdir/ncalrpc
637 rpc_server:epmapper = embedded
639 # Begin extra options
640 $extra_options
641 # End extra options
643 #Include user defined custom parameters if set
646 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
647 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
650 print CONF "
651 [tmp]
652 path = $shrdir
653 [tmpguest]
654 path = $shrdir
655 guest ok = yes
656 [guestonly]
657 path = $shrdir
658 guest only = yes
659 guest ok = yes
660 [forceuser]
661 path = $shrdir
662 force user = $unix_name
663 guest ok = yes
664 [forcegroup]
665 path = $shrdir
666 force group = nogroup
667 guest ok = yes
668 [ro-tmp]
669 path = $ro_shrdir
670 guest ok = yes
671 [msdfs-share]
672 path = $msdfs_shrdir
673 msdfs root = yes
674 guest ok = yes
675 [hideunread]
676 copy = tmp
677 hide unreadable = yes
678 [tmpcase]
679 copy = tmp
680 case sensitive = yes
681 [hideunwrite]
682 copy = tmp
683 hide unwriteable files = yes
684 [print1]
685 copy = tmp
686 printable = yes
688 [print2]
689 copy = print1
690 [print3]
691 copy = print1
692 [lp]
693 copy = print1
694 [print\$]
695 copy = tmp
697 close(CONF);
700 ## create a test account
703 open(PASSWD, ">$nss_wrapper_passwd") or die("Unable to open $nss_wrapper_passwd");
704 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
705 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
707 if ($unix_uid != 0) {
708 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false";
710 close(PASSWD);
712 open(GROUP, ">$nss_wrapper_group") or die("Unable to open $nss_wrapper_group");
713 print GROUP "nobody:x:$gid_nobody:
714 nogroup:x:$gid_nogroup:nobody
715 $unix_name-group:x:$unix_gids[0]:
716 domusers:X:$gid_domusers:
718 if ($unix_gids[0] != 0) {
719 print GROUP "root:x:$gid_root:";
722 close(GROUP);
724 foreach my $evlog (@eventlog_list) {
725 my $evlogtdb = "$eventlogdir/$evlog.tdb";
726 open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
727 close(EVENTLOG);
730 $ENV{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
731 $ENV{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
733 open(PWD, "|".$self->binpath("smbpasswd")." -c $conffile -L -s -a $unix_name >/dev/null");
734 print PWD "$password\n$password\n";
735 close(PWD) or die("Unable to set password for test account");
737 print "DONE\n";
739 $ret{SERVER_IP} = $server_ip;
740 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
741 $ret{NMBD_TEST_LOG_POS} = 0;
742 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
743 $ret{WINBINDD_TEST_LOG_POS} = 0;
744 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
745 $ret{SMBD_TEST_LOG_POS} = 0;
746 $ret{SERVERCONFFILE} = $conffile;
747 $ret{CONFIGURATION} ="-s $conffile";
748 $ret{SERVER} = $server;
749 $ret{USERNAME} = $unix_name;
750 $ret{USERID} = $unix_uid;
751 $ret{DOMAIN} = $domain;
752 $ret{NETBIOSNAME} = $server;
753 $ret{PASSWORD} = $password;
754 $ret{PIDDIR} = $piddir;
755 $ret{WINBINDD_SOCKET_DIR} = $wbsockdir;
756 $ret{WINBINDD_PRIV_PIPE_DIR} = $wbsockprivdir;
757 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
758 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
759 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
760 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
761 $ret{NSS_WRAPPER_WINBIND_SO_PATH} = $ENV{NSS_WRAPPER_WINBIND_SO_PATH};
762 $ret{LOCAL_PATH} = "$shrdir";
764 return \%ret;
767 sub wait_for_start($$)
769 my ($self, $envvars) = @_;
771 # give time for nbt server to register its names
772 print "delaying for nbt name registration\n";
773 sleep(10);
774 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
775 system($self->binpath("nmblookup") ." $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
776 system($self->binpath("nmblookup") ." $envvars->{CONFIGURATION} __SAMBA__");
777 system($self->binpath("nmblookup") ." $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
778 system($self->binpath("nmblookup") ." $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
779 system($self->binpath("nmblookup") ." $envvars->{CONFIGURATION} $envvars->{SERVER}");
780 # make sure smbd is also up set
781 print "wait for smbd\n";
782 system($self->binpath("smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER_IP} -U% -p 139 | head -2");
783 system($self->binpath("smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER_IP} -U% -p 139 | head -2");
785 # Ensure we have domain users mapped.
786 system($self->binpath("net") ." $envvars->{CONFIGURATION} groupmap add rid=513 unixgroup=domusers type=domain");
788 print $self->getlog_env($envvars);