dcerpc.idl: accept invalid dcerpc_bind_nak pdus
[Samba.git] / selftest / target / Samba3.pm
blob15423fef3d5e90fac22068ec53564196ace06a1b
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;
12 use target::Samba;
14 sub have_ads($) {
15 my ($self) = @_;
16 my $found_ads = 0;
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: $!");
20 while (<IN>) {
21 if (/WITH_ADS/) {
22 $found_ads = 1;
25 close IN;
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;
29 return $found_ads;
32 # return smb.conf parameters applicable to @path, based on the underlying
33 # filesystem type
34 sub get_fs_specific_conf($$)
36 my ($self, $path) = @_;
37 my $mods = "";
38 my $stat_out = `stat --file-system $path` or return "";
40 if ($stat_out =~ m/Type:\s+btrfs/) {
41 $mods .= "btrfs ";
44 if ($mods) {
45 return "vfs objects = $mods";
48 return undef;
51 sub new($$) {
52 my ($classname, $bindir, $srcdir, $server_maxtime) = @_;
53 my $self = { vars => {},
54 bindir => $bindir,
55 srcdir => $srcdir,
56 server_maxtime => $server_maxtime
58 bless $self;
59 return $self;
62 sub teardown_env($$)
64 my ($self, $envvars) = @_;
65 my $count = 0;
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
75 until ($count > 20) {
76 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
77 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
78 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
79 if ($smbdchild == -1
80 && $nmbdchild == -1
81 && $winbinddchild == -1) {
82 last;
84 sleep(1);
85 $count++;
88 if ($count <= 20 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
89 return;
92 $self->stop_sig_term($smbdpid);
93 $self->stop_sig_term($nmbdpid);
94 $self->stop_sig_term($winbinddpid);
96 $count = 0;
97 until ($count > 10) {
98 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd");
99 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd");
100 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd");
101 if ($smbdchild == -1
102 && $nmbdchild == -1
103 && $winbinddchild == -1) {
104 last;
106 sleep(1);
107 $count++;
110 if ($count <= 10 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
111 return;
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);
119 return 0;
122 sub getlog_env_app($$$)
124 my ($self, $envvars, $name) = @_;
126 my $title = "$name LOG of: $envvars->{NETBIOSNAME}\n";
127 my $out = $title;
129 open(LOG, "<".$envvars->{$name."_TEST_LOG"});
131 seek(LOG, $envvars->{$name."_TEST_LOG_POS"}, SEEK_SET);
132 while (<LOG>) {
133 $out .= $_;
135 $envvars->{$name."_TEST_LOG_POS"} = tell(LOG);
136 close(LOG);
138 return "" if $out eq $title;
140 return $out;
143 sub getlog_env($$)
145 my ($self, $envvars) = @_;
146 my $ret = "";
148 $ret .= $self->getlog_env_app($envvars, "SMBD");
149 $ret .= $self->getlog_env_app($envvars, "NMBD");
150 $ret .= $self->getlog_env_app($envvars, "WINBINDD");
152 return $ret;
155 sub check_env($$)
157 my ($self, $envvars) = @_;
159 my $childpid = waitpid(-1, WNOHANG);
161 # TODO ...
162 return 1;
165 sub setup_env($$$)
167 my ($self, $envname, $path) = @_;
169 $ENV{ENVNAME} = $envname;
171 if (defined($self->{vars}->{$envname})) {
172 return $self->{vars}->{$envname};
175 if ($envname eq "nt4_dc") {
176 return $self->setup_nt4_dc("$path/nt4_dc");
177 } elsif ($envname eq "nt4_dc_schannel") {
178 return $self->setup_nt4_dc_schannel("$path/nt4_dc_schannel");
179 } elsif ($envname eq "simpleserver") {
180 return $self->setup_simpleserver("$path/simpleserver");
181 } elsif ($envname eq "fileserver") {
182 return $self->setup_fileserver("$path/fileserver");
183 } elsif ($envname eq "maptoguest") {
184 return $self->setup_maptoguest("$path/maptoguest");
185 } elsif ($envname eq "ktest") {
186 return $self->setup_ktest("$path/ktest");
187 } elsif ($envname eq "nt4_member") {
188 if (not defined($self->{vars}->{nt4_dc})) {
189 if (not defined($self->setup_nt4_dc("$path/nt4_dc"))) {
190 return undef;
193 return $self->setup_nt4_member("$path/nt4_member", $self->{vars}->{nt4_dc});
194 } else {
195 return "UNKNOWN";
199 sub setup_nt4_dc($$)
201 my ($self, $path) = @_;
203 print "PROVISIONING NT4 DC...";
205 my $nt4_dc_options = "
206 domain master = yes
207 domain logons = yes
208 lanman auth = yes
210 rpc_server:epmapper = external
211 rpc_server:spoolss = external
212 rpc_server:lsarpc = external
213 rpc_server:samr = external
214 rpc_server:netlogon = external
215 rpc_server:register_embedded_np = yes
216 rpc_server:FssagentRpc = external
218 rpc_daemon:epmd = fork
219 rpc_daemon:spoolssd = fork
220 rpc_daemon:lsasd = fork
221 rpc_daemon:fssd = fork
222 fss: sequence timeout = 1
225 my $vars = $self->provision($path,
226 "LOCALNT4DC2",
227 "localntdc2pass",
228 $nt4_dc_options);
230 $vars or return undef;
232 if (not $self->check_or_start($vars, "yes", "yes", "yes")) {
233 return undef;
236 $vars->{DC_SERVER} = $vars->{SERVER};
237 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
238 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
239 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
240 $vars->{DC_USERNAME} = $vars->{USERNAME};
241 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
243 $self->{vars}->{nt4_dc} = $vars;
245 return $vars;
248 sub setup_nt4_dc_schannel($$)
250 my ($self, $path) = @_;
252 print "PROVISIONING NT4 DC WITH SERVER SCHANNEL ...";
254 my $pdc_options = "
255 domain master = yes
256 domain logons = yes
257 lanman auth = yes
259 rpc_server:epmapper = external
260 rpc_server:spoolss = external
261 rpc_server:lsarpc = external
262 rpc_server:samr = external
263 rpc_server:netlogon = external
264 rpc_server:register_embedded_np = yes
266 rpc_daemon:epmd = fork
267 rpc_daemon:spoolssd = fork
268 rpc_daemon:lsasd = fork
270 server schannel = yes
273 my $vars = $self->provision($path,
274 "LOCALNT4DC9",
275 "localntdc9pass",
276 $pdc_options);
278 $vars or return undef;
280 if (not $self->check_or_start($vars, "yes", "yes", "yes")) {
281 return undef;
284 $vars->{DC_SERVER} = $vars->{SERVER};
285 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
286 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
287 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
288 $vars->{DC_USERNAME} = $vars->{USERNAME};
289 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
291 $self->{vars}->{nt4_dc_schannel} = $vars;
293 return $vars;
296 sub setup_nt4_member($$$)
298 my ($self, $prefix, $nt4_dc_vars) = @_;
299 my $count = 0;
300 my $rc;
302 print "PROVISIONING MEMBER...";
304 my $member_options = "
305 security = domain
306 server signing = on
307 dbwrap_tdb_mutexes:* = yes
309 my $ret = $self->provision($prefix,
310 "LOCALNT4MEMBER3",
311 "localnt4member3pass",
312 $member_options);
314 $ret or return undef;
316 my $nmblookup = Samba::bindir_path($self, "nmblookup");
317 do {
318 print "Waiting for the LOGON SERVER registration ...\n";
319 $rc = system("$nmblookup $ret->{CONFIGURATION} $ret->{DOMAIN}\#1c");
320 if ($rc != 0) {
321 sleep(1);
323 $count++;
324 } while ($rc != 0 && $count < 10);
325 if ($count == 10) {
326 print "NMBD not reachable after 10 retries\n";
327 teardown_env($self, $ret);
328 return 0;
331 my $net = Samba::bindir_path($self, "net");
332 my $cmd = "";
333 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
334 $cmd .= "$net join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
335 $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}";
337 if (system($cmd) != 0) {
338 warn("Join failed\n$cmd");
339 return undef;
342 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
343 return undef;
346 $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
347 $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
348 $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
349 $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME};
350 $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME};
351 $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD};
353 return $ret;
356 sub setup_admember($$$$)
358 my ($self, $prefix, $dcvars) = @_;
360 # If we didn't build with ADS, pretend this env was never available
361 if (not $self->have_ads()) {
362 return "UNKNOWN";
365 print "PROVISIONING S3 AD MEMBER...";
367 my $member_options = "
368 security = ads
369 server signing = on
370 workgroup = $dcvars->{DOMAIN}
371 realm = $dcvars->{REALM}
374 my $ret = $self->provision($prefix,
375 "LOCALADMEMBER",
376 "loCalMemberPass",
377 $member_options,
378 $dcvars->{SERVER_IP},
379 $dcvars->{SERVER_IPV6});
381 $ret or return undef;
383 close(USERMAP);
384 $ret->{DOMAIN} = $dcvars->{DOMAIN};
385 $ret->{REALM} = $dcvars->{REALM};
387 my $ctx;
388 my $prefix_abs = abs_path($prefix);
389 $ctx = {};
390 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
391 $ctx->{domain} = $dcvars->{DOMAIN};
392 $ctx->{realm} = $dcvars->{REALM};
393 $ctx->{dnsname} = lc($dcvars->{REALM});
394 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
395 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
396 Samba::mk_krb5_conf($ctx, "");
398 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
400 my $net = Samba::bindir_path($self, "net");
401 my $cmd = "";
402 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
403 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
404 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
405 } else {
406 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
408 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
409 $cmd .= "$net join $ret->{CONFIGURATION}";
410 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
412 if (system($cmd) != 0) {
413 warn("Join failed\n$cmd");
414 return undef;
417 # We need world access to this share, as otherwise the domain
418 # administrator from the AD domain provided by Samba4 can't
419 # access the share for tests.
420 chmod 0777, "$prefix/share";
422 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
423 return undef;
426 $ret->{DC_SERVER} = $dcvars->{SERVER};
427 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
428 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
429 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
430 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
431 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
433 # Special case, this is called from Samba4.pm but needs to use the Samba3 check_env and get_log_env
434 $ret->{target} = $self;
436 return $ret;
439 sub setup_admember_rfc2307($$$$)
441 my ($self, $prefix, $dcvars) = @_;
443 # If we didn't build with ADS, pretend this env was never available
444 if (not $self->have_ads()) {
445 return "UNKNOWN";
448 print "PROVISIONING S3 AD MEMBER WITH idmap_rfc2307 config...";
450 my $member_options = "
451 security = ads
452 server signing = on
453 workgroup = $dcvars->{DOMAIN}
454 realm = $dcvars->{REALM}
455 idmap config $dcvars->{DOMAIN} : backend = rfc2307
456 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
457 idmap config $dcvars->{DOMAIN} : ldap_server = ad
458 idmap config $dcvars->{DOMAIN} : bind_path_user = ou=idmap,dc=samba,dc=example,dc=com
459 idmap config $dcvars->{DOMAIN} : bind_path_group = ou=idmap,dc=samba,dc=example,dc=com
462 my $ret = $self->provision($prefix,
463 "RFC2307MEMBER",
464 "loCalMemberPass",
465 $member_options,
466 $dcvars->{SERVER_IP},
467 $dcvars->{SERVER_IPV6});
469 $ret or return undef;
471 close(USERMAP);
472 $ret->{DOMAIN} = $dcvars->{DOMAIN};
473 $ret->{REALM} = $dcvars->{REALM};
475 my $ctx;
476 my $prefix_abs = abs_path($prefix);
477 $ctx = {};
478 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
479 $ctx->{domain} = $dcvars->{DOMAIN};
480 $ctx->{realm} = $dcvars->{REALM};
481 $ctx->{dnsname} = lc($dcvars->{REALM});
482 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
483 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
484 Samba::mk_krb5_conf($ctx, "");
486 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
488 my $net = Samba::bindir_path($self, "net");
489 my $cmd = "";
490 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
491 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
492 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
493 } else {
494 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
496 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
497 $cmd .= "$net join $ret->{CONFIGURATION}";
498 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
500 if (system($cmd) != 0) {
501 warn("Join failed\n$cmd");
502 return undef;
505 # We need world access to this share, as otherwise the domain
506 # administrator from the AD domain provided by Samba4 can't
507 # access the share for tests.
508 chmod 0777, "$prefix/share";
510 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
511 return undef;
514 $ret->{DC_SERVER} = $dcvars->{SERVER};
515 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
516 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
517 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
518 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
519 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
521 # Special case, this is called from Samba4.pm but needs to use the Samba3 check_env and get_log_env
522 $ret->{target} = $self;
524 return $ret;
527 sub setup_simpleserver($$)
529 my ($self, $path) = @_;
531 print "PROVISIONING simple server...";
533 my $prefix_abs = abs_path($path);
535 my $simpleserver_options = "
536 lanman auth = yes
537 vfs objects = xattr_tdb streams_depot
538 change notify = no
540 [vfs_aio_fork]
541 path = $prefix_abs/share
542 vfs objects = aio_fork
543 read only = no
544 vfs_aio_fork:erratic_testing_mode=yes
547 my $vars = $self->provision($path,
548 "LOCALSHARE4",
549 "local4pass",
550 $simpleserver_options);
552 $vars or return undef;
554 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
555 return undef;
558 $self->{vars}->{simpleserver} = $vars;
560 return $vars;
563 sub setup_fileserver($$)
565 my ($self, $path) = @_;
566 my $prefix_abs = abs_path($path);
567 my $srcdir_abs = abs_path($self->{srcdir});
569 print "PROVISIONING file server ...\n";
571 my @dirs = ();
573 mkdir($prefix_abs, 0777);
575 my $share_dir="$prefix_abs/share";
577 # Create share directory structure
578 my $lower_case_share_dir="$share_dir/lower-case";
579 push(@dirs, $lower_case_share_dir);
581 my $lower_case_share_dir_30000="$share_dir/lower-case-30000";
582 push(@dirs, $lower_case_share_dir_30000);
584 my $dfree_share_dir="$share_dir/dfree";
585 push(@dirs, $dfree_share_dir);
587 my $valid_users_sharedir="$share_dir/valid_users";
588 push(@dirs,$valid_users_sharedir);
590 my $fileserver_options = "
591 [lowercase]
592 path = $lower_case_share_dir
593 comment = smb username is [%U]
594 case sensitive = True
595 default case = lower
596 preserve case = no
597 short preserve case = no
598 [lowercase-30000]
599 path = $lower_case_share_dir_30000
600 comment = smb username is [%U]
601 case sensitive = True
602 default case = lower
603 preserve case = no
604 short preserve case = no
605 [dfree]
606 path = $dfree_share_dir
607 comment = smb username is [%U]
608 dfree command = $srcdir_abs/testprogs/blackbox/dfree.sh
609 [valid-users-access]
610 path = $valid_users_sharedir
611 valid users = +userdup
614 my $vars = $self->provision($path,
615 "FILESERVER",
616 "fileserver",
617 $fileserver_options,
618 undef,
619 undef,
622 $vars or return undef;
624 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
625 return undef;
628 $self->{vars}->{fileserver} = $vars;
630 mkdir($_, 0777) foreach(@dirs);
632 ## Create case sensitive lower case share dir
633 foreach my $file ('a'..'z') {
634 my $full_path = $lower_case_share_dir . '/' . $file;
635 open my $fh, '>', $full_path;
636 # Add some content to file
637 print $fh $full_path;
638 close $fh;
641 for (my $file = 1; $file < 51; ++$file) {
642 my $full_path = $lower_case_share_dir . '/' . $file;
643 open my $fh, '>', $full_path;
644 # Add some content to file
645 print $fh $full_path;
646 close $fh;
649 # Create content for 30000 share
650 foreach my $file ('a'..'z') {
651 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
652 open my $fh, '>', $full_path;
653 # Add some content to file
654 print $fh $full_path;
655 close $fh;
658 for (my $file = 1; $file < 30001; ++$file) {
659 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
660 open my $fh, '>', $full_path;
661 # Add some content to file
662 print $fh $full_path;
663 close $fh;
667 ## create a listable file in valid_users_share
669 my $valid_users_target = "$valid_users_sharedir/foo";
670 unless (open(VALID_USERS_TARGET, ">$valid_users_target")) {
671 warn("Unable to open $valid_users_target");
672 return undef;
674 close(VALID_USERS_TARGET);
675 chmod 0644, $valid_users_target;
677 return $vars;
680 sub setup_ktest($$$)
682 my ($self, $prefix) = @_;
684 # If we didn't build with ADS, pretend this env was never available
685 if (not $self->have_ads()) {
686 return "UNKNOWN";
689 print "PROVISIONING server with security=ads...";
691 my $ktest_options = "
692 workgroup = KTEST
693 realm = ktest.samba.example.com
694 security = ads
695 username map = $prefix/lib/username.map
696 server signing = required
699 my $ret = $self->provision($prefix,
700 "LOCALKTEST6",
701 "localktest6pass",
702 $ktest_options);
704 $ret or return undef;
706 my $ctx;
707 my $prefix_abs = abs_path($prefix);
708 $ctx = {};
709 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
710 $ctx->{domain} = "KTEST";
711 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
712 $ctx->{dnsname} = lc($ctx->{realm});
713 $ctx->{kdc_ipv4} = "0.0.0.0";
714 $ctx->{kdc_ipv6} = "::";
715 Samba::mk_krb5_conf($ctx, "");
717 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
719 open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map");
720 print USERMAP "
721 $ret->{USERNAME} = KTEST\\Administrator
723 close(USERMAP);
725 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
726 #Samba4 DC with the same parameters as are being used here. The
727 #domain SID is S-1-5-21-1071277805-689288055-3486227160
729 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
730 chmod 0600, "$prefix/private/secrets.tdb";
732 #Make sure there's no old ntdb file.
733 system("rm -f $prefix/private/secrets.ntdb");
735 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
736 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
738 #and having in krb5.conf:
739 # ticket_lifetime = 799718400
740 # renew_lifetime = 799718400
742 # The commands for the -2 keytab where were:
743 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
744 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
745 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
746 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
747 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
749 # and then for the -3 keytab, I did
751 # net changetrustpw; kdestroy and the same again.
753 # This creates a credential cache with a very long lifetime (2036 at
754 # at 2011-04), and shows that running 'net changetrustpw' does not
755 # break existing logins (for the secrets.tdb method at least).
758 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
760 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
761 chmod 0600, "$prefix/krb5_ccache-2";
763 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
764 chmod 0600, "$prefix/krb5_ccache-3";
766 # We need world access to this share, as otherwise the domain
767 # administrator from the AD domain provided by ktest can't
768 # access the share for tests.
769 chmod 0777, "$prefix/share";
771 if (not $self->check_or_start($ret, "yes", "no", "yes")) {
772 return undef;
774 return $ret;
777 sub setup_maptoguest($$)
779 my ($self, $path) = @_;
781 print "PROVISIONING maptoguest...";
783 my $options = "
784 map to guest = bad user
787 my $vars = $self->provision($path,
788 "maptoguest",
789 "maptoguestpass",
790 $options);
792 $vars or return undef;
794 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
795 return undef;
798 $self->{vars}->{s3maptoguest} = $vars;
800 return $vars;
803 sub stop_sig_term($$) {
804 my ($self, $pid) = @_;
805 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
808 sub stop_sig_kill($$) {
809 my ($self, $pid) = @_;
810 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
813 sub write_pid($$$)
815 my ($env_vars, $app, $pid) = @_;
817 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
818 print PID $pid;
819 close(PID);
822 sub read_pid($$)
824 my ($env_vars, $app) = @_;
826 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
827 my $pid = <PID>;
828 close(PID);
829 return $pid;
832 sub check_or_start($$$$$) {
833 my ($self, $env_vars, $nmbd, $winbindd, $smbd) = @_;
835 # use a pipe for stdin in the child processes. This allows
836 # those processes to monitor the pipe for EOF to ensure they
837 # exit when the test script exits
838 pipe(STDIN_READER, $env_vars->{STDIN_PIPE});
840 unlink($env_vars->{NMBD_TEST_LOG});
841 print "STARTING NMBD...";
842 my $pid = fork();
843 if ($pid == 0) {
844 open STDOUT, ">$env_vars->{NMBD_TEST_LOG}";
845 open STDERR, '>&STDOUT';
847 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
849 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
850 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
851 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
853 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
854 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
855 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
856 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
857 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
858 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
860 $ENV{ENVNAME} = "$ENV{ENVNAME}.nmbd";
862 if ($nmbd ne "yes") {
863 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
864 my $signame = shift;
865 print("Skip nmbd received signal $signame");
866 exit 0;
868 sleep($self->{server_maxtime});
869 exit 0;
872 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "nmbd");
873 my @optargs = ("-d0");
874 if (defined($ENV{NMBD_OPTIONS})) {
875 @optargs = split(/ /, $ENV{NMBD_OPTIONS});
877 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
878 if(defined($ENV{NMBD_VALGRIND})) {
879 @preargs = split(/ /, $ENV{NMBD_VALGRIND});
881 my @args = ("-F", "--no-process-group",
882 "-s", $env_vars->{SERVERCONFFILE},
883 "-l", $env_vars->{LOGDIR});
884 if (not defined($ENV{NMBD_DONT_LOG_STDOUT})) {
885 push(@args, "--log-stdout");
888 close($env_vars->{STDIN_PIPE});
889 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
891 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
892 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
894 $env_vars->{NMBD_TL_PID} = $pid;
895 write_pid($env_vars, "nmbd", $pid);
896 print "DONE\n";
898 unlink($env_vars->{WINBINDD_TEST_LOG});
899 print "STARTING WINBINDD...";
900 $pid = fork();
901 if ($pid == 0) {
902 open STDOUT, ">$env_vars->{WINBINDD_TEST_LOG}";
903 open STDERR, '>&STDOUT';
905 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
907 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
908 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
909 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
911 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
912 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
913 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
914 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
915 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
916 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
917 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
918 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
919 } else {
920 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
923 $ENV{ENVNAME} = "$ENV{ENVNAME}.winbindd";
925 if ($winbindd ne "yes") {
926 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
927 my $signame = shift;
928 print("Skip winbindd received signal $signame");
929 exit 0;
931 sleep($self->{server_maxtime});
932 exit 0;
935 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "winbindd");
936 my @optargs = ("-d0");
937 if (defined($ENV{WINBINDD_OPTIONS})) {
938 @optargs = split(/ /, $ENV{WINBINDD_OPTIONS});
940 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
941 if(defined($ENV{WINBINDD_VALGRIND})) {
942 @preargs = split(/ /, $ENV{WINBINDD_VALGRIND});
944 my @args = ("-F", "--no-process-group",
945 "-s", $env_vars->{SERVERCONFFILE},
946 "-l", $env_vars->{LOGDIR});
947 if (not defined($ENV{WINBINDD_DONT_LOG_STDOUT})) {
948 push(@args, "--stdout");
951 close($env_vars->{STDIN_PIPE});
952 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
954 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
955 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
957 $env_vars->{WINBINDD_TL_PID} = $pid;
958 write_pid($env_vars, "winbindd", $pid);
959 print "DONE\n";
961 unlink($env_vars->{SMBD_TEST_LOG});
962 print "STARTING SMBD...";
963 $pid = fork();
964 if ($pid == 0) {
965 open STDOUT, ">$env_vars->{SMBD_TEST_LOG}";
966 open STDERR, '>&STDOUT';
968 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
970 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
971 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
972 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
974 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
975 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
976 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
977 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
978 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
979 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
980 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
981 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
982 } else {
983 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
986 $ENV{ENVNAME} = "$ENV{ENVNAME}.smbd";
988 if ($smbd ne "yes") {
989 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
990 my $signame = shift;
991 print("Skip smbd received signal $signame");
992 exit 0;
994 sleep($self->{server_maxtime});
995 exit 0;
998 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "smbd");
999 my @optargs = ("-d0");
1000 if (defined($ENV{SMBD_OPTIONS})) {
1001 @optargs = split(/ /, $ENV{SMBD_OPTIONS});
1003 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1004 if(defined($ENV{SMBD_VALGRIND})) {
1005 @preargs = split(/ /,$ENV{SMBD_VALGRIND});
1007 my @args = ("-F", "--no-process-group",
1008 "-s", $env_vars->{SERVERCONFFILE},
1009 "-l", $env_vars->{LOGDIR});
1010 if (not defined($ENV{SMBD_DONT_LOG_STDOUT})) {
1011 push(@args, "--log-stdout");
1014 close($env_vars->{STDIN_PIPE});
1015 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1017 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1018 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1020 $env_vars->{SMBD_TL_PID} = $pid;
1021 write_pid($env_vars, "smbd", $pid);
1022 print "DONE\n";
1024 close(STDIN_READER);
1026 return $self->wait_for_start($env_vars, $nmbd, $winbindd, $smbd);
1029 sub provision($$$$$$$$)
1031 my ($self, $prefix, $server, $password, $extra_options, $dc_server_ip, $dc_server_ipv6, $no_delete_prefix) = @_;
1034 ## setup the various environment variables we need
1037 my $swiface = Samba::get_interface($server);
1038 my %ret = ();
1039 my $server_ip = "127.0.0.$swiface";
1040 my $server_ipv6 = sprintf("fd00:0000:0000:0000:0000:0000:5357:5f%02x", $swiface);
1041 my $domain = "SAMBA-TEST";
1043 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
1044 chomp $unix_name;
1045 my $unix_uid = $>;
1046 my $unix_gids_str = $);
1047 my @unix_gids = split(" ", $unix_gids_str);
1049 my $prefix_abs = abs_path($prefix);
1050 my $bindir_abs = abs_path($self->{bindir});
1052 my @dirs = ();
1054 my $shrdir="$prefix_abs/share";
1055 push(@dirs,$shrdir);
1057 my $libdir="$prefix_abs/lib";
1058 push(@dirs,$libdir);
1060 my $piddir="$prefix_abs/pid";
1061 push(@dirs,$piddir);
1063 my $privatedir="$prefix_abs/private";
1064 push(@dirs,$privatedir);
1066 my $lockdir="$prefix_abs/lockdir";
1067 push(@dirs,$lockdir);
1069 my $eventlogdir="$prefix_abs/lockdir/eventlog";
1070 push(@dirs,$eventlogdir);
1072 my $logdir="$prefix_abs/logs";
1073 push(@dirs,$logdir);
1075 my $driver32dir="$shrdir/W32X86";
1076 push(@dirs,$driver32dir);
1078 my $driver64dir="$shrdir/x64";
1079 push(@dirs,$driver64dir);
1081 my $driver40dir="$shrdir/WIN40";
1082 push(@dirs,$driver40dir);
1084 my $ro_shrdir="$shrdir/root-tmp";
1085 push(@dirs,$ro_shrdir);
1087 my $msdfs_shrdir="$shrdir/msdfsshare";
1088 push(@dirs,$msdfs_shrdir);
1090 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
1091 push(@dirs,$msdfs_deeppath);
1093 my $badnames_shrdir="$shrdir/badnames";
1094 push(@dirs,$badnames_shrdir);
1096 my $lease1_shrdir="$shrdir/SMB2_10";
1097 push(@dirs,$lease1_shrdir);
1099 my $lease2_shrdir="$shrdir/SMB3_00";
1100 push(@dirs,$lease2_shrdir);
1102 my $manglenames_shrdir="$shrdir/manglenames";
1103 push(@dirs,$manglenames_shrdir);
1105 # this gets autocreated by winbindd
1106 my $wbsockdir="$prefix_abs/winbindd";
1107 my $wbsockprivdir="$lockdir/winbindd_privileged";
1109 my $nmbdsockdir="$prefix_abs/nmbd";
1110 unlink($nmbdsockdir);
1113 ## create the test directory layout
1115 die ("prefix_abs = ''") if $prefix_abs eq "";
1116 die ("prefix_abs = '/'") if $prefix_abs eq "/";
1118 mkdir($prefix_abs, 0777);
1119 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
1120 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
1121 system("rm -rf $prefix_abs/*");
1123 mkdir($_, 0777) foreach(@dirs);
1125 my $fs_specific_conf = $self->get_fs_specific_conf($shrdir);
1128 ## lockdir and piddir must be 0755
1130 chmod 0755, $lockdir;
1131 chmod 0755, $piddir;
1135 ## create ro and msdfs share layout
1138 chmod 0755, $ro_shrdir;
1139 my $unreadable_file = "$ro_shrdir/unreadable_file";
1140 unless (open(UNREADABLE_FILE, ">$unreadable_file")) {
1141 warn("Unable to open $unreadable_file");
1142 return undef;
1144 close(UNREADABLE_FILE);
1145 chmod 0600, $unreadable_file;
1147 my $msdfs_target = "$ro_shrdir/msdfs-target";
1148 unless (open(MSDFS_TARGET, ">$msdfs_target")) {
1149 warn("Unable to open $msdfs_target");
1150 return undef;
1152 close(MSDFS_TARGET);
1153 chmod 0666, $msdfs_target;
1154 symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp",
1155 "$msdfs_shrdir/msdfs-src1";
1156 symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
1159 ## create bad names in $badnames_shrdir
1161 ## (An invalid name, would be mangled to 8.3).
1162 my $badname_target = "$badnames_shrdir/\340|\231\216\377\177";
1163 unless (open(BADNAME_TARGET, ">$badname_target")) {
1164 warn("Unable to open $badname_target");
1165 return undef;
1167 close(BADNAME_TARGET);
1168 chmod 0666, $badname_target;
1170 ## (A bad name, would not be mangled to 8.3).
1171 my $badname_target = "$badnames_shrdir/\240\276\346\327\377\177";
1172 unless (open(BADNAME_TARGET, ">$badname_target")) {
1173 warn("Unable to open $badname_target");
1174 return undef;
1176 close(BADNAME_TARGET);
1177 chmod 0666, $badname_target;
1179 ## (A bad good name).
1180 my $badname_target = "$badnames_shrdir/blank.txt";
1181 unless (open(BADNAME_TARGET, ">$badname_target")) {
1182 warn("Unable to open $badname_target");
1183 return undef;
1185 close(BADNAME_TARGET);
1186 chmod 0666, $badname_target;
1189 ## create mangleable directory names in $manglenames_shrdir
1191 my $manglename_target = "$manglenames_shrdir/foo:bar";
1192 mkdir($manglename_target, 0777);
1194 my $conffile="$libdir/server.conf";
1196 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/lib/nss_wrapper/nss_wrapper.pl";
1197 my $nss_wrapper_passwd = "$privatedir/passwd";
1198 my $nss_wrapper_group = "$privatedir/group";
1199 my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts";
1200 my $resolv_conf = "$privatedir/resolv.conf";
1201 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
1203 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
1205 my $fake_snap_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/fake_snap.pl";
1207 my @eventlog_list = ("dns server", "application");
1210 ## calculate uids and gids
1213 my ($max_uid, $max_gid);
1214 my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
1215 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
1216 my ($gid_userdup);
1218 if ($unix_uid < 0xffff - 5) {
1219 $max_uid = 0xffff;
1220 } else {
1221 $max_uid = $unix_uid;
1224 $uid_root = $max_uid - 1;
1225 $uid_nobody = $max_uid - 2;
1226 $uid_pdbtest = $max_uid - 3;
1227 $uid_pdbtest2 = $max_uid - 4;
1228 $uid_userdup = $max_uid - 5;
1230 if ($unix_gids[0] < 0xffff - 6) {
1231 $max_gid = 0xffff;
1232 } else {
1233 $max_gid = $unix_gids[0];
1236 $gid_nobody = $max_gid - 1;
1237 $gid_nogroup = $max_gid - 2;
1238 $gid_root = $max_gid - 3;
1239 $gid_domusers = $max_gid - 4;
1240 $gid_domadmins = $max_gid - 5;
1241 $gid_userdup = $max_gid - 6;
1244 ## create conffile
1247 unless (open(CONF, ">$conffile")) {
1248 warn("Unable to open $conffile");
1249 return undef;
1251 print CONF "
1252 [global]
1253 netbios name = $server
1254 interfaces = $server_ip/8 $server_ipv6/64
1255 bind interfaces only = yes
1256 panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
1257 smbd:suicide mode = yes
1259 workgroup = $domain
1261 private dir = $privatedir
1262 pid directory = $piddir
1263 lock directory = $lockdir
1264 log file = $logdir/log.\%m
1265 log level = 1
1266 debug pid = yes
1267 max log size = 0
1269 state directory = $lockdir
1270 cache directory = $lockdir
1272 passdb backend = tdbsam
1274 time server = yes
1276 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1277 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
1278 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1279 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
1280 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
1281 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
1282 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
1284 addprinter command = $mod_printer_pl -a -s $conffile --
1285 deleteprinter command = $mod_printer_pl -d -s $conffile --
1287 eventlog list = application \"dns server\"
1289 kernel oplocks = no
1290 kernel change notify = no
1291 smb2 leases = yes
1293 logging = file
1294 printing = bsd
1295 printcap name = /dev/null
1297 winbindd socket directory = $wbsockdir
1298 nmbd:socket dir = $nmbdsockdir
1299 idmap config * : range = 100000-200000
1300 winbind enum users = yes
1301 winbind enum groups = yes
1302 winbind separator = /
1304 # min receivefile size = 4000
1306 read only = no
1307 server signing = auto
1309 smbd:sharedelay = 100000
1310 smbd:writetimeupdatedelay = 500000
1311 map hidden = no
1312 map system = no
1313 map readonly = no
1314 store dos attributes = yes
1315 create mask = 755
1316 dos filemode = yes
1317 strict rename = yes
1318 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot
1320 printing = vlp
1321 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
1322 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
1323 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
1324 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
1325 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
1326 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
1327 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
1328 lpq cache time = 0
1329 print notify backchannel = yes
1331 ncalrpc dir = $prefix_abs/ncalrpc
1333 # The samba3.blackbox.smbclient_s3 test uses this to test that
1334 # sending messages works, and that the %m sub works.
1335 message command = mv %s $shrdir/message.%m
1337 # fsrvp server requires registry shares
1338 registry shares = yes
1340 # Used by RPC SRVSVC tests
1341 add share command = $bindir_abs/smbaddshare
1342 change share command = $bindir_abs/smbchangeshare
1343 delete share command = $bindir_abs/smbdeleteshare
1345 # fruit:copyfile is a global option
1346 fruit:copyfile = yes
1348 # Begin extra options
1349 $extra_options
1350 # End extra options
1352 #Include user defined custom parameters if set
1355 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
1356 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
1359 print CONF "
1360 [tmp]
1361 path = $shrdir
1362 comment = smb username is [%U]
1363 [tmpsort]
1364 path = $shrdir
1365 comment = Load dirsort module
1366 vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot
1367 [tmpenc]
1368 path = $shrdir
1369 comment = encrypt smb username is [%U]
1370 smb encrypt = required
1371 vfs objects = dirsort
1372 [tmpguest]
1373 path = $shrdir
1374 guest ok = yes
1375 [guestonly]
1376 path = $shrdir
1377 guest only = yes
1378 guest ok = yes
1379 [forceuser]
1380 path = $shrdir
1381 force user = $unix_name
1382 guest ok = yes
1383 [forceuser_unixonly]
1384 path = $shrdir
1385 force user = pdbtest
1386 guest ok = yes
1387 [forcegroup]
1388 path = $shrdir
1389 force group = nogroup
1390 guest ok = yes
1391 [ro-tmp]
1392 path = $ro_shrdir
1393 guest ok = yes
1394 [write-list-tmp]
1395 path = $shrdir
1396 read only = yes
1397 write list = $unix_name
1398 [valid-users-tmp]
1399 path = $shrdir
1400 valid users = $unix_name
1401 [msdfs-share]
1402 path = $msdfs_shrdir
1403 msdfs root = yes
1404 msdfs shuffle referrals = yes
1405 guest ok = yes
1406 [hideunread]
1407 copy = tmp
1408 hide unreadable = yes
1409 [tmpcase]
1410 copy = tmp
1411 case sensitive = yes
1412 [hideunwrite]
1413 copy = tmp
1414 hide unwriteable files = yes
1415 [durable]
1416 copy = tmp
1417 kernel share modes = no
1418 kernel oplocks = no
1419 posix locking = no
1420 [fs_specific]
1421 copy = tmp
1422 $fs_specific_conf
1423 [print1]
1424 copy = tmp
1425 printable = yes
1427 [print2]
1428 copy = print1
1429 [print3]
1430 copy = print1
1431 default devmode = no
1432 [lp]
1433 copy = print1
1435 [nfs4acl_simple]
1436 path = $shrdir
1437 comment = smb username is [%U]
1438 nfs4:mode = simple
1439 vfs objects = nfs4acl_xattr xattr_tdb
1441 [nfs4acl_special]
1442 path = $shrdir
1443 comment = smb username is [%U]
1444 nfs4:mode = special
1445 vfs objects = nfs4acl_xattr xattr_tdb
1447 [xcopy_share]
1448 path = $shrdir
1449 comment = smb username is [%U]
1450 create mask = 777
1451 force create mode = 777
1452 [posix_share]
1453 path = $shrdir
1454 comment = smb username is [%U]
1455 create mask = 0777
1456 force create mode = 0
1457 directory mask = 0777
1458 force directory mode = 0
1459 vfs objects = xattr_tdb
1460 [aio]
1461 copy = tmp
1462 aio read size = 1
1463 aio write size = 1
1465 [print\$]
1466 copy = tmp
1468 [vfs_fruit]
1469 path = $shrdir
1470 vfs objects = catia fruit streams_xattr acl_xattr
1471 ea support = yes
1472 fruit:ressource = file
1473 fruit:metadata = netatalk
1474 fruit:locking = netatalk
1475 fruit:encoding = native
1477 [badname-tmp]
1478 path = $badnames_shrdir
1479 guest ok = yes
1481 [manglenames_share]
1482 path = $manglenames_shrdir
1483 guest ok = yes
1485 [dynamic_share]
1486 path = $shrdir/%R
1487 guest ok = yes
1489 [fsrvp_share]
1490 path = $shrdir
1491 comment = fake shapshots using rsync
1492 vfs objects = shell_snap shadow_copy2
1493 shell_snap:check path command = $fake_snap_pl --check
1494 shell_snap:create command = $fake_snap_pl --create
1495 shell_snap:delete command = $fake_snap_pl --delete
1496 # a relative path here fails, the snapshot dir is no longer found
1497 shadow:snapdir = $shrdir/.snapshots
1499 close(CONF);
1502 ## create a test account
1505 unless (open(PASSWD, ">$nss_wrapper_passwd")) {
1506 warn("Unable to open $nss_wrapper_passwd");
1507 return undef;
1509 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
1510 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
1511 pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
1512 pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
1513 userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
1515 if ($unix_uid != 0) {
1516 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
1519 close(PASSWD);
1521 unless (open(GROUP, ">$nss_wrapper_group")) {
1522 warn("Unable to open $nss_wrapper_group");
1523 return undef;
1525 print GROUP "nobody:x:$gid_nobody:
1526 nogroup:x:$gid_nogroup:nobody
1527 $unix_name-group:x:$unix_gids[0]:
1528 domusers:X:$gid_domusers:
1529 domadmins:X:$gid_domadmins:
1530 userdup:x:$gid_userdup:$unix_name
1532 if ($unix_gids[0] != 0) {
1533 print GROUP "root:x:$gid_root:
1537 close(GROUP);
1539 ## hosts
1540 my $hostname = lc($server);
1541 unless (open(HOSTS, ">>$nss_wrapper_hosts")) {
1542 warn("Unable to open $nss_wrapper_hosts");
1543 return undef;
1545 print HOSTS "${server_ip} ${hostname}.samba.example.com ${hostname}\n";
1546 print HOSTS "${server_ipv6} ${hostname}.samba.example.com ${hostname}\n";
1547 close(HOSTS);
1549 ## hosts
1550 unless (open(RESOLV_CONF, ">$resolv_conf")) {
1551 warn("Unable to open $resolv_conf");
1552 return undef;
1554 if (defined($dc_server_ip) or defined($dc_server_ipv6)) {
1555 if (defined($dc_server_ip)) {
1556 print RESOLV_CONF "nameserver $dc_server_ip\n";
1558 if (defined($dc_server_ipv6)) {
1559 print RESOLV_CONF "nameserver $dc_server_ipv6\n";
1561 } else {
1562 print RESOLV_CONF "nameserver ${server_ip}\n";
1563 print RESOLV_CONF "nameserver ${server_ipv6}\n";
1565 close(RESOLV_CONF);
1567 foreach my $evlog (@eventlog_list) {
1568 my $evlogtdb = "$eventlogdir/$evlog.tdb";
1569 open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
1570 close(EVENTLOG);
1573 $ENV{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
1574 $ENV{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
1575 $ENV{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
1576 $ENV{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
1577 if ($ENV{SAMBA_DNS_FAKING}) {
1578 $ENV{RESOLV_WRAPPER_CONF} = $resolv_conf;
1579 } else {
1580 $ENV{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
1583 my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $unix_name > /dev/null";
1584 unless (open(PWD, "|$cmd")) {
1585 warn("Unable to set password for test account\n$cmd");
1586 return undef;
1588 print PWD "$password\n$password\n";
1589 unless (close(PWD)) {
1590 warn("Unable to set password for test account\n$cmd");
1591 return undef;
1593 print "DONE\n";
1595 open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
1596 print DNS_UPDATE_LIST "A $server. $server_ip\n";
1597 print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n";
1598 close(DNS_UPDATE_LIST);
1600 $ret{SERVER_IP} = $server_ip;
1601 $ret{SERVER_IPV6} = $server_ipv6;
1602 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
1603 $ret{NMBD_TEST_LOG_POS} = 0;
1604 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
1605 $ret{WINBINDD_TEST_LOG_POS} = 0;
1606 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
1607 $ret{SMBD_TEST_LOG_POS} = 0;
1608 $ret{SERVERCONFFILE} = $conffile;
1609 $ret{CONFIGURATION} ="-s $conffile";
1610 $ret{SERVER} = $server;
1611 $ret{USERNAME} = $unix_name;
1612 $ret{USERID} = $unix_uid;
1613 $ret{DOMAIN} = $domain;
1614 $ret{NETBIOSNAME} = $server;
1615 $ret{PASSWORD} = $password;
1616 $ret{PIDDIR} = $piddir;
1617 $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir;
1618 $ret{WINBINDD_PRIV_PIPE_DIR} = $wbsockprivdir;
1619 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
1620 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
1621 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
1622 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
1623 $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
1624 $ret{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
1625 $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
1626 $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind";
1627 if ($ENV{SAMBA_DNS_FAKING}) {
1628 $ret{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
1629 } else {
1630 $ret{RESOLV_WRAPPER_CONF} = $resolv_conf;
1632 $ret{LOCAL_PATH} = "$shrdir";
1633 $ret{LOGDIR} = $logdir;
1635 return \%ret;
1638 sub wait_for_start($$$$$)
1640 my ($self, $envvars, $nmbd, $winbindd, $smbd) = @_;
1641 my $ret;
1643 if ($nmbd eq "yes") {
1644 my $count = 0;
1646 # give time for nbt server to register its names
1647 print "checking for nmbd\n";
1649 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
1650 my $nmblookup = Samba::bindir_path($self, "nmblookup");
1652 do {
1653 $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
1654 if ($ret != 0) {
1655 sleep(1);
1656 } else {
1657 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
1658 system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
1659 system("$nmblookup $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
1660 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
1662 $count++;
1663 } while ($ret != 0 && $count < 10);
1664 if ($count == 10) {
1665 print "NMBD not reachable after 10 retries\n";
1666 teardown_env($self, $envvars);
1667 return 0;
1671 if ($winbindd eq "yes") {
1672 print "checking for winbindd\n";
1673 my $count = 0;
1674 do {
1675 $ret = system("SELFTEST_WINBINDD_SOCKET_DIR=" . $envvars->{SELFTEST_WINBINDD_SOCKET_DIR} . " " . Samba::bindir_path($self, "wbinfo") . " --ping-dc");
1676 if ($ret != 0) {
1677 sleep(2);
1679 $count++;
1680 } while ($ret != 0 && $count < 10);
1681 if ($count == 10) {
1682 print "WINBINDD not reachable after 20 seconds\n";
1683 teardown_env($self, $envvars);
1684 return 0;
1688 if ($smbd eq "yes") {
1689 # make sure smbd is also up set
1690 print "wait for smbd\n";
1692 my $count = 0;
1693 do {
1694 $ret = system(Samba::bindir_path($self, "smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139");
1695 if ($ret != 0) {
1696 sleep(2);
1698 $count++
1699 } while ($ret != 0 && $count < 10);
1700 if ($count == 10) {
1701 print "SMBD failed to start up in a reasonable time (20sec)\n";
1702 teardown_env($self, $envvars);
1703 return 0;
1707 # Ensure we have domain users mapped.
1708 $ret = system(Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} groupmap add rid=513 unixgroup=domusers type=domain");
1709 if ($ret != 0) {
1710 return 1;
1712 $ret = system(Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} groupmap add rid=512 unixgroup=domadmins type=domain");
1713 if ($ret != 0) {
1714 return 1;
1717 if ($winbindd eq "yes") {
1718 # note: creating builtin groups requires winbindd for the
1719 # unix id allocator
1720 $ret = system("SELFTEST_WINBINDD_SOCKET_DIR=" . $envvars->{SELFTEST_WINBINDD_SOCKET_DIR} . " " . Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} sam createbuiltingroup Users");
1721 if ($ret != 0) {
1722 print "Failed to create BUILTIN\\Users group\n";
1723 return 0;
1725 my $count = 0;
1726 do {
1727 system(Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} cache flush");
1728 $ret = system("SELFTEST_WINBINDD_SOCKET_DIR=" . $envvars->{SELFTEST_WINBINDD_SOCKET_DIR} . " " . Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545");
1729 if ($ret != 0) {
1730 sleep(2);
1732 $count++;
1733 } while ($ret != 0 && $count < 10);
1734 if ($count == 10) {
1735 print "WINBINDD not reachable after 20 seconds\n";
1736 teardown_env($self, $envvars);
1737 return 0;
1741 print $self->getlog_env($envvars);
1743 return 1;