selftest: don't allow ntlmv1 for 'nt4_member' and 'ad_member'
[Samba.git] / selftest / target / Samba3.pm
blob5076c43bf185dc3cc9c44a1722c49d77e07291c5
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};
176 # Avoid hitting system krb5.conf -
177 # An env that needs Kerberos will reset this to the real
178 # value.
180 $ENV{KRB5_CONFIG} = "$path/no_krb5.conf";
182 if ($envname eq "nt4_dc") {
183 return $self->setup_nt4_dc("$path/nt4_dc");
184 } elsif ($envname eq "nt4_dc_schannel") {
185 return $self->setup_nt4_dc_schannel("$path/nt4_dc_schannel");
186 } elsif ($envname eq "simpleserver") {
187 return $self->setup_simpleserver("$path/simpleserver");
188 } elsif ($envname eq "fileserver") {
189 return $self->setup_fileserver("$path/fileserver");
190 } elsif ($envname eq "maptoguest") {
191 return $self->setup_maptoguest("$path/maptoguest");
192 } elsif ($envname eq "ktest") {
193 return $self->setup_ktest("$path/ktest");
194 } elsif ($envname eq "nt4_member") {
195 if (not defined($self->{vars}->{nt4_dc})) {
196 if (not defined($self->setup_nt4_dc("$path/nt4_dc"))) {
197 return undef;
200 return $self->setup_nt4_member("$path/nt4_member", $self->{vars}->{nt4_dc});
201 } else {
202 return "UNKNOWN";
206 sub setup_nt4_dc($$)
208 my ($self, $path) = @_;
210 print "PROVISIONING NT4 DC...";
212 my $nt4_dc_options = "
213 domain master = yes
214 domain logons = yes
215 lanman auth = yes
216 ntlm auth = yes
217 raw NTLMv2 auth = yes
219 rpc_server:epmapper = external
220 rpc_server:spoolss = external
221 rpc_server:lsarpc = external
222 rpc_server:samr = external
223 rpc_server:netlogon = external
224 rpc_server:register_embedded_np = yes
225 rpc_server:FssagentRpc = external
227 rpc_daemon:epmd = fork
228 rpc_daemon:spoolssd = fork
229 rpc_daemon:lsasd = fork
230 rpc_daemon:fssd = fork
231 fss: sequence timeout = 1
234 my $vars = $self->provision($path,
235 "LOCALNT4DC2",
236 "localntdc2pass",
237 $nt4_dc_options);
239 $vars or return undef;
241 if (not $self->check_or_start($vars, "yes", "yes", "yes")) {
242 return undef;
245 $vars->{DC_SERVER} = $vars->{SERVER};
246 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
247 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
248 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
249 $vars->{DC_USERNAME} = $vars->{USERNAME};
250 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
252 $self->{vars}->{nt4_dc} = $vars;
254 return $vars;
257 sub setup_nt4_dc_schannel($$)
259 my ($self, $path) = @_;
261 print "PROVISIONING NT4 DC WITH SERVER SCHANNEL ...";
263 my $pdc_options = "
264 domain master = yes
265 domain logons = yes
266 lanman auth = yes
268 rpc_server:epmapper = external
269 rpc_server:spoolss = external
270 rpc_server:lsarpc = external
271 rpc_server:samr = external
272 rpc_server:netlogon = external
273 rpc_server:register_embedded_np = yes
275 rpc_daemon:epmd = fork
276 rpc_daemon:spoolssd = fork
277 rpc_daemon:lsasd = fork
279 server schannel = yes
282 my $vars = $self->provision($path,
283 "LOCALNT4DC9",
284 "localntdc9pass",
285 $pdc_options);
287 $vars or return undef;
289 if (not $self->check_or_start($vars, "yes", "yes", "yes")) {
290 return undef;
293 $vars->{DC_SERVER} = $vars->{SERVER};
294 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
295 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
296 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
297 $vars->{DC_USERNAME} = $vars->{USERNAME};
298 $vars->{DC_PASSWORD} = $vars->{PASSWORD};
300 $self->{vars}->{nt4_dc_schannel} = $vars;
302 return $vars;
305 sub setup_nt4_member($$$)
307 my ($self, $prefix, $nt4_dc_vars) = @_;
308 my $count = 0;
309 my $rc;
311 print "PROVISIONING MEMBER...";
313 my $require_mutexes = "dbwrap_tdb_require_mutexes:* = yes";
314 $require_mutexes = "" if ($ENV{SELFTEST_DONT_REQUIRE_TDB_MUTEX_SUPPORT} eq "1");
316 my $member_options = "
317 security = domain
318 dbwrap_tdb_mutexes:* = yes
319 ${require_mutexes}
321 my $ret = $self->provision($prefix,
322 "LOCALNT4MEMBER3",
323 "localnt4member3pass",
324 $member_options);
326 $ret or return undef;
328 my $nmblookup = Samba::bindir_path($self, "nmblookup");
329 do {
330 print "Waiting for the LOGON SERVER registration ...\n";
331 $rc = system("$nmblookup $ret->{CONFIGURATION} $ret->{DOMAIN}\#1c");
332 if ($rc != 0) {
333 sleep(1);
335 $count++;
336 } while ($rc != 0 && $count < 10);
337 if ($count == 10) {
338 print "NMBD not reachable after 10 retries\n";
339 teardown_env($self, $ret);
340 return 0;
343 my $net = Samba::bindir_path($self, "net");
344 my $cmd = "";
345 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
346 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
347 $cmd .= "$net join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
348 $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}";
350 if (system($cmd) != 0) {
351 warn("Join failed\n$cmd");
352 return undef;
355 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
356 return undef;
359 $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
360 $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
361 $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
362 $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME};
363 $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME};
364 $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD};
366 return $ret;
369 sub setup_admember($$$$)
371 my ($self, $prefix, $dcvars) = @_;
373 # If we didn't build with ADS, pretend this env was never available
374 if (not $self->have_ads()) {
375 return "UNKNOWN";
378 print "PROVISIONING S3 AD MEMBER...";
380 my $member_options = "
381 security = ads
382 workgroup = $dcvars->{DOMAIN}
383 realm = $dcvars->{REALM}
384 netbios aliases = foo bar
387 my $ret = $self->provision($prefix,
388 "LOCALADMEMBER",
389 "loCalMemberPass",
390 $member_options,
391 $dcvars->{SERVER_IP},
392 $dcvars->{SERVER_IPV6});
394 $ret or return undef;
396 close(USERMAP);
397 $ret->{DOMAIN} = $dcvars->{DOMAIN};
398 $ret->{REALM} = $dcvars->{REALM};
400 my $ctx;
401 my $prefix_abs = abs_path($prefix);
402 $ctx = {};
403 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
404 $ctx->{domain} = $dcvars->{DOMAIN};
405 $ctx->{realm} = $dcvars->{REALM};
406 $ctx->{dnsname} = lc($dcvars->{REALM});
407 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
408 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
409 Samba::mk_krb5_conf($ctx, "");
411 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
413 my $net = Samba::bindir_path($self, "net");
414 my $cmd = "";
415 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
416 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
417 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
418 } else {
419 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
421 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
422 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
423 $cmd .= "$net join $ret->{CONFIGURATION}";
424 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
426 if (system($cmd) != 0) {
427 warn("Join failed\n$cmd");
428 return undef;
431 # We need world access to this share, as otherwise the domain
432 # administrator from the AD domain provided by Samba4 can't
433 # access the share for tests.
434 chmod 0777, "$prefix/share";
436 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
437 return undef;
440 $ret->{DC_SERVER} = $dcvars->{SERVER};
441 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
442 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
443 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
444 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
445 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
447 # Special case, this is called from Samba4.pm but needs to use the Samba3 check_env and get_log_env
448 $ret->{target} = $self;
450 return $ret;
453 sub setup_admember_rfc2307($$$$)
455 my ($self, $prefix, $dcvars) = @_;
457 # If we didn't build with ADS, pretend this env was never available
458 if (not $self->have_ads()) {
459 return "UNKNOWN";
462 print "PROVISIONING S3 AD MEMBER WITH idmap_rfc2307 config...";
464 my $member_options = "
465 security = ads
466 workgroup = $dcvars->{DOMAIN}
467 realm = $dcvars->{REALM}
468 idmap config * : backend = autorid
469 idmap config * : range = 1000000-1999999
470 idmap config * : rangesize = 100000
471 idmap config $dcvars->{DOMAIN} : backend = rfc2307
472 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
473 idmap config $dcvars->{DOMAIN} : ldap_server = ad
474 idmap config $dcvars->{DOMAIN} : bind_path_user = ou=idmap,dc=samba,dc=example,dc=com
475 idmap config $dcvars->{DOMAIN} : bind_path_group = ou=idmap,dc=samba,dc=example,dc=com
478 my $ret = $self->provision($prefix,
479 "RFC2307MEMBER",
480 "loCalMemberPass",
481 $member_options,
482 $dcvars->{SERVER_IP},
483 $dcvars->{SERVER_IPV6});
485 $ret or return undef;
487 close(USERMAP);
488 $ret->{DOMAIN} = $dcvars->{DOMAIN};
489 $ret->{REALM} = $dcvars->{REALM};
491 my $ctx;
492 my $prefix_abs = abs_path($prefix);
493 $ctx = {};
494 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
495 $ctx->{domain} = $dcvars->{DOMAIN};
496 $ctx->{realm} = $dcvars->{REALM};
497 $ctx->{dnsname} = lc($dcvars->{REALM});
498 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
499 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
500 Samba::mk_krb5_conf($ctx, "");
502 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
504 my $net = Samba::bindir_path($self, "net");
505 my $cmd = "";
506 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
507 if (defined($ret->{RESOLV_WRAPPER_CONF})) {
508 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
509 } else {
510 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
512 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
513 $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR=\"$ret->{SELFTEST_WINBINDD_SOCKET_DIR}\" ";
514 $cmd .= "$net join $ret->{CONFIGURATION}";
515 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
517 if (system($cmd) != 0) {
518 warn("Join failed\n$cmd");
519 return undef;
522 # We need world access to this share, as otherwise the domain
523 # administrator from the AD domain provided by Samba4 can't
524 # access the share for tests.
525 chmod 0777, "$prefix/share";
527 if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
528 return undef;
531 $ret->{DC_SERVER} = $dcvars->{SERVER};
532 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
533 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
534 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
535 $ret->{DC_USERNAME} = $dcvars->{USERNAME};
536 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
538 # Special case, this is called from Samba4.pm but needs to use the Samba3 check_env and get_log_env
539 $ret->{target} = $self;
541 return $ret;
544 sub setup_simpleserver($$)
546 my ($self, $path) = @_;
548 print "PROVISIONING simple server...";
550 my $prefix_abs = abs_path($path);
552 my $simpleserver_options = "
553 lanman auth = yes
554 ntlm auth = yes
555 vfs objects = xattr_tdb streams_depot time_audit full_audit
556 change notify = no
558 full_audit:syslog = no
559 full_audit:success = none
560 full_audit:failure = none
562 [vfs_aio_fork]
563 path = $prefix_abs/share
564 vfs objects = aio_fork
565 read only = no
566 vfs_aio_fork:erratic_testing_mode=yes
568 [dosmode]
569 path = $prefix_abs/share
570 vfs objects =
571 store dos attributes = yes
572 hide files = /hidefile/
573 hide dot files = yes
576 my $vars = $self->provision($path,
577 "LOCALSHARE4",
578 "local4pass",
579 $simpleserver_options);
581 $vars or return undef;
583 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
584 return undef;
587 $self->{vars}->{simpleserver} = $vars;
589 return $vars;
592 sub setup_fileserver($$)
594 my ($self, $path) = @_;
595 my $prefix_abs = abs_path($path);
596 my $srcdir_abs = abs_path($self->{srcdir});
598 print "PROVISIONING file server ...\n";
600 my @dirs = ();
602 mkdir($prefix_abs, 0777);
604 my $share_dir="$prefix_abs/share";
606 # Create share directory structure
607 my $lower_case_share_dir="$share_dir/lower-case";
608 push(@dirs, $lower_case_share_dir);
610 my $lower_case_share_dir_30000="$share_dir/lower-case-30000";
611 push(@dirs, $lower_case_share_dir_30000);
613 my $dfree_share_dir="$share_dir/dfree";
614 push(@dirs, $dfree_share_dir);
615 push(@dirs, "$dfree_share_dir/subdir1");
616 push(@dirs, "$dfree_share_dir/subdir2");
618 my $valid_users_sharedir="$share_dir/valid_users";
619 push(@dirs,$valid_users_sharedir);
621 my $offline_sharedir="$share_dir/offline";
622 push(@dirs,$offline_sharedir);
624 my $force_user_valid_users_dir = "$share_dir/force_user_valid_users";
625 push(@dirs, $force_user_valid_users_dir);
627 my $smbget_sharedir="$share_dir/smbget";
628 push(@dirs,$smbget_sharedir);
630 my $fileserver_options = "
631 [lowercase]
632 path = $lower_case_share_dir
633 comment = smb username is [%U]
634 case sensitive = True
635 default case = lower
636 preserve case = no
637 short preserve case = no
638 [lowercase-30000]
639 path = $lower_case_share_dir_30000
640 comment = smb username is [%U]
641 case sensitive = True
642 default case = lower
643 preserve case = no
644 short preserve case = no
645 [dfree]
646 path = $dfree_share_dir
647 comment = smb username is [%U]
648 dfree command = $srcdir_abs/testprogs/blackbox/dfree.sh
649 [valid-users-access]
650 path = $valid_users_sharedir
651 valid users = +userdup
652 [offline]
653 path = $offline_sharedir
654 vfs objects = offline
656 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878
657 # RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651
658 [force_user_valid_users]
659 path = $force_user_valid_users_dir
660 comment = force user with valid users combination test share
661 valid users = +force_user
662 force user = force_user
663 force group = everyone
664 write list = force_user
666 [smbget]
667 path = $smbget_sharedir
668 comment = smb username is [%U]
669 guest ok = yes
670 [ign_sysacls]
671 path = $share_dir
672 comment = ignore system acls
673 acl_xattr:ignore system acls = yes
676 my $vars = $self->provision($path,
677 "FILESERVER",
678 "fileserver",
679 $fileserver_options,
680 undef,
681 undef,
684 $vars or return undef;
686 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
687 return undef;
690 $self->{vars}->{fileserver} = $vars;
692 mkdir($_, 0777) foreach(@dirs);
694 ## Create case sensitive lower case share dir
695 foreach my $file ('a'..'z') {
696 my $full_path = $lower_case_share_dir . '/' . $file;
697 open my $fh, '>', $full_path;
698 # Add some content to file
699 print $fh $full_path;
700 close $fh;
703 for (my $file = 1; $file < 51; ++$file) {
704 my $full_path = $lower_case_share_dir . '/' . $file;
705 open my $fh, '>', $full_path;
706 # Add some content to file
707 print $fh $full_path;
708 close $fh;
711 # Create content for 30000 share
712 foreach my $file ('a'..'z') {
713 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
714 open my $fh, '>', $full_path;
715 # Add some content to file
716 print $fh $full_path;
717 close $fh;
720 for (my $file = 1; $file < 30001; ++$file) {
721 my $full_path = $lower_case_share_dir_30000 . '/' . $file;
722 open my $fh, '>', $full_path;
723 # Add some content to file
724 print $fh $full_path;
725 close $fh;
729 ## create a listable file in valid_users_share
731 my $valid_users_target = "$valid_users_sharedir/foo";
732 unless (open(VALID_USERS_TARGET, ">$valid_users_target")) {
733 warn("Unable to open $valid_users_target");
734 return undef;
736 close(VALID_USERS_TARGET);
737 chmod 0644, $valid_users_target;
739 return $vars;
742 sub setup_ktest($$$)
744 my ($self, $prefix) = @_;
746 # If we didn't build with ADS, pretend this env was never available
747 if (not $self->have_ads()) {
748 return "UNKNOWN";
751 print "PROVISIONING server with security=ads...";
753 my $ktest_options = "
754 workgroup = KTEST
755 realm = ktest.samba.example.com
756 security = ads
757 username map = $prefix/lib/username.map
758 server signing = required
761 my $ret = $self->provision($prefix,
762 "LOCALKTEST6",
763 "localktest6pass",
764 $ktest_options);
766 $ret or return undef;
768 my $ctx;
769 my $prefix_abs = abs_path($prefix);
770 $ctx = {};
771 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
772 $ctx->{domain} = "KTEST";
773 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
774 $ctx->{dnsname} = lc($ctx->{realm});
775 $ctx->{kdc_ipv4} = "0.0.0.0";
776 $ctx->{kdc_ipv6} = "::";
777 Samba::mk_krb5_conf($ctx, "");
779 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
781 open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map");
782 print USERMAP "
783 $ret->{USERNAME} = KTEST\\Administrator
785 close(USERMAP);
787 #This is the secrets.tdb created by 'net ads join' from Samba3 to a
788 #Samba4 DC with the same parameters as are being used here. The
789 #domain SID is S-1-5-21-1071277805-689288055-3486227160
791 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
792 chmod 0600, "$prefix/private/secrets.tdb";
794 #Make sure there's no old ntdb file.
795 system("rm -f $prefix/private/secrets.ntdb");
797 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
798 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
800 #and having in krb5.conf:
801 # ticket_lifetime = 799718400
802 # renew_lifetime = 799718400
804 # The commands for the -2 keytab where were:
805 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
806 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
807 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
808 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
809 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
811 # and then for the -3 keytab, I did
813 # net changetrustpw; kdestroy and the same again.
815 # This creates a credential cache with a very long lifetime (2036 at
816 # at 2011-04), and shows that running 'net changetrustpw' does not
817 # break existing logins (for the secrets.tdb method at least).
820 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
822 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
823 chmod 0600, "$prefix/krb5_ccache-2";
825 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
826 chmod 0600, "$prefix/krb5_ccache-3";
828 # We need world access to this share, as otherwise the domain
829 # administrator from the AD domain provided by ktest can't
830 # access the share for tests.
831 chmod 0777, "$prefix/share";
833 if (not $self->check_or_start($ret, "yes", "no", "yes")) {
834 return undef;
836 return $ret;
839 sub setup_maptoguest($$)
841 my ($self, $path) = @_;
843 print "PROVISIONING maptoguest...";
845 my $options = "
846 map to guest = bad user
847 ntlm auth = yes
850 my $vars = $self->provision($path,
851 "maptoguest",
852 "maptoguestpass",
853 $options);
855 $vars or return undef;
857 if (not $self->check_or_start($vars, "yes", "no", "yes")) {
858 return undef;
861 $self->{vars}->{s3maptoguest} = $vars;
863 return $vars;
866 sub stop_sig_term($$) {
867 my ($self, $pid) = @_;
868 kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
871 sub stop_sig_kill($$) {
872 my ($self, $pid) = @_;
873 kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
876 sub write_pid($$$)
878 my ($env_vars, $app, $pid) = @_;
880 open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
881 print PID $pid;
882 close(PID);
885 sub read_pid($$)
887 my ($env_vars, $app) = @_;
889 open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
890 my $pid = <PID>;
891 close(PID);
892 return $pid;
895 sub check_or_start($$$$$) {
896 my ($self, $env_vars, $nmbd, $winbindd, $smbd) = @_;
898 # use a pipe for stdin in the child processes. This allows
899 # those processes to monitor the pipe for EOF to ensure they
900 # exit when the test script exits
901 pipe(STDIN_READER, $env_vars->{STDIN_PIPE});
903 unlink($env_vars->{NMBD_TEST_LOG});
904 print "STARTING NMBD...";
905 my $pid = fork();
906 if ($pid == 0) {
907 open STDOUT, ">$env_vars->{NMBD_TEST_LOG}";
908 open STDERR, '>&STDOUT';
910 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
912 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
913 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
914 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
916 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
917 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
918 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
919 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
920 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
921 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
922 $ENV{UID_WRAPPER_ROOT} = "1";
924 $ENV{ENVNAME} = "$ENV{ENVNAME}.nmbd";
926 if ($nmbd ne "yes") {
927 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
928 my $signame = shift;
929 print("Skip nmbd received signal $signame");
930 exit 0;
932 sleep($self->{server_maxtime});
933 exit 0;
936 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "nmbd");
937 my @optargs = ("-d0");
938 if (defined($ENV{NMBD_OPTIONS})) {
939 @optargs = split(/ /, $ENV{NMBD_OPTIONS});
941 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
942 if(defined($ENV{NMBD_VALGRIND})) {
943 @preargs = split(/ /, $ENV{NMBD_VALGRIND});
945 my @args = ("-F", "--no-process-group",
946 "-s", $env_vars->{SERVERCONFFILE},
947 "-l", $env_vars->{LOGDIR});
948 if (not defined($ENV{NMBD_DONT_LOG_STDOUT})) {
949 push(@args, "--log-stdout");
952 close($env_vars->{STDIN_PIPE});
953 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
955 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
956 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
958 $env_vars->{NMBD_TL_PID} = $pid;
959 write_pid($env_vars, "nmbd", $pid);
960 print "DONE\n";
962 unlink($env_vars->{WINBINDD_TEST_LOG});
963 print "STARTING WINBINDD...";
964 $pid = fork();
965 if ($pid == 0) {
966 open STDOUT, ">$env_vars->{WINBINDD_TEST_LOG}";
967 open STDERR, '>&STDOUT';
969 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
971 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
972 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
973 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
975 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
976 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
977 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
978 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
979 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
980 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
981 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
982 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
983 } else {
984 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
986 $ENV{UID_WRAPPER_ROOT} = "1";
988 $ENV{ENVNAME} = "$ENV{ENVNAME}.winbindd";
990 if ($winbindd ne "yes") {
991 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
992 my $signame = shift;
993 print("Skip winbindd received signal $signame");
994 exit 0;
996 sleep($self->{server_maxtime});
997 exit 0;
1000 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "winbindd");
1001 my @optargs = ("-d0");
1002 if (defined($ENV{WINBINDD_OPTIONS})) {
1003 @optargs = split(/ /, $ENV{WINBINDD_OPTIONS});
1005 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1006 if(defined($ENV{WINBINDD_VALGRIND})) {
1007 @preargs = split(/ /, $ENV{WINBINDD_VALGRIND});
1009 my @args = ("-F", "--no-process-group",
1010 "-s", $env_vars->{SERVERCONFFILE},
1011 "-l", $env_vars->{LOGDIR});
1012 if (not defined($ENV{WINBINDD_DONT_LOG_STDOUT})) {
1013 push(@args, "--stdout");
1016 close($env_vars->{STDIN_PIPE});
1017 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1019 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1020 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1022 $env_vars->{WINBINDD_TL_PID} = $pid;
1023 write_pid($env_vars, "winbindd", $pid);
1024 print "DONE\n";
1026 unlink($env_vars->{SMBD_TEST_LOG});
1027 print "STARTING SMBD...";
1028 $pid = fork();
1029 if ($pid == 0) {
1030 open STDOUT, ">$env_vars->{SMBD_TEST_LOG}";
1031 open STDERR, '>&STDOUT';
1033 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
1035 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
1036 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
1037 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
1039 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
1040 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
1041 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
1042 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
1043 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
1044 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
1045 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
1046 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
1047 } else {
1048 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
1050 $ENV{UID_WRAPPER_ROOT} = "1";
1052 $ENV{ENVNAME} = "$ENV{ENVNAME}.smbd";
1054 if ($smbd ne "yes") {
1055 $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
1056 my $signame = shift;
1057 print("Skip smbd received signal $signame");
1058 exit 0;
1060 sleep($self->{server_maxtime});
1061 exit 0;
1064 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "smbd");
1065 my @optargs = ("-d0");
1066 if (defined($ENV{SMBD_OPTIONS})) {
1067 @optargs = split(/ /, $ENV{SMBD_OPTIONS});
1069 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
1070 if(defined($ENV{SMBD_VALGRIND})) {
1071 @preargs = split(/ /,$ENV{SMBD_VALGRIND});
1073 my @args = ("-F", "--no-process-group",
1074 "-s", $env_vars->{SERVERCONFFILE},
1075 "-l", $env_vars->{LOGDIR});
1076 if (not defined($ENV{SMBD_DONT_LOG_STDOUT})) {
1077 push(@args, "--log-stdout");
1080 close($env_vars->{STDIN_PIPE});
1081 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
1083 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
1084 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
1086 $env_vars->{SMBD_TL_PID} = $pid;
1087 write_pid($env_vars, "smbd", $pid);
1088 print "DONE\n";
1090 close(STDIN_READER);
1092 return $self->wait_for_start($env_vars, $nmbd, $winbindd, $smbd);
1095 sub createuser($$$$)
1097 my ($self, $username, $password, $conffile) = @_;
1098 my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $username > /dev/null";
1099 unless (open(PWD, "|$cmd")) {
1100 warn("Unable to set password for $username account\n$cmd");
1101 return undef;
1103 print PWD "$password\n$password\n";
1104 unless (close(PWD)) {
1105 warn("Unable to set password for $username account\n$cmd");
1106 return undef;
1108 print "DONE\n";
1111 sub provision($$$$$$$$)
1113 my ($self, $prefix, $server, $password, $extra_options, $dc_server_ip, $dc_server_ipv6, $no_delete_prefix) = @_;
1116 ## setup the various environment variables we need
1119 my $swiface = Samba::get_interface($server);
1120 my %ret = ();
1121 my $server_ip = "127.0.0.$swiface";
1122 my $server_ipv6 = sprintf("fd00:0000:0000:0000:0000:0000:5357:5f%02x", $swiface);
1123 my $domain = "SAMBA-TEST";
1125 my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
1126 chomp $unix_name;
1127 my $unix_uid = $>;
1128 my $unix_gids_str = $);
1129 my @unix_gids = split(" ", $unix_gids_str);
1131 my $prefix_abs = abs_path($prefix);
1132 my $bindir_abs = abs_path($self->{bindir});
1134 my @dirs = ();
1136 my $shrdir="$prefix_abs/share";
1137 push(@dirs,$shrdir);
1139 my $libdir="$prefix_abs/lib";
1140 push(@dirs,$libdir);
1142 my $piddir="$prefix_abs/pid";
1143 push(@dirs,$piddir);
1145 my $privatedir="$prefix_abs/private";
1146 push(@dirs,$privatedir);
1148 my $lockdir="$prefix_abs/lockdir";
1149 push(@dirs,$lockdir);
1151 my $eventlogdir="$prefix_abs/lockdir/eventlog";
1152 push(@dirs,$eventlogdir);
1154 my $logdir="$prefix_abs/logs";
1155 push(@dirs,$logdir);
1157 my $driver32dir="$shrdir/W32X86";
1158 push(@dirs,$driver32dir);
1160 my $driver64dir="$shrdir/x64";
1161 push(@dirs,$driver64dir);
1163 my $driver40dir="$shrdir/WIN40";
1164 push(@dirs,$driver40dir);
1166 my $ro_shrdir="$shrdir/root-tmp";
1167 push(@dirs,$ro_shrdir);
1169 my $msdfs_shrdir="$shrdir/msdfsshare";
1170 push(@dirs,$msdfs_shrdir);
1172 my $msdfs_deeppath="$msdfs_shrdir/deeppath";
1173 push(@dirs,$msdfs_deeppath);
1175 my $badnames_shrdir="$shrdir/badnames";
1176 push(@dirs,$badnames_shrdir);
1178 my $lease1_shrdir="$shrdir/SMB2_10";
1179 push(@dirs,$lease1_shrdir);
1181 my $lease2_shrdir="$shrdir/SMB3_00";
1182 push(@dirs,$lease2_shrdir);
1184 my $manglenames_shrdir="$shrdir/manglenames";
1185 push(@dirs,$manglenames_shrdir);
1187 my $widelinks_shrdir="$shrdir/widelinks";
1188 push(@dirs,$widelinks_shrdir);
1190 my $widelinks_linkdir="$shrdir/widelinks_foo";
1191 push(@dirs,$widelinks_linkdir);
1193 my $shadow_tstdir="$shrdir/shadow";
1194 push(@dirs,$shadow_tstdir);
1195 my $shadow_mntdir="$shadow_tstdir/mount";
1196 push(@dirs,$shadow_mntdir);
1197 my $shadow_basedir="$shadow_mntdir/base";
1198 push(@dirs,$shadow_basedir);
1199 my $shadow_shrdir="$shadow_basedir/share";
1200 push(@dirs,$shadow_shrdir);
1202 # this gets autocreated by winbindd
1203 my $wbsockdir="$prefix_abs/winbindd";
1204 my $wbsockprivdir="$lockdir/winbindd_privileged";
1206 my $nmbdsockdir="$prefix_abs/nmbd";
1207 unlink($nmbdsockdir);
1210 ## create the test directory layout
1212 die ("prefix_abs = ''") if $prefix_abs eq "";
1213 die ("prefix_abs = '/'") if $prefix_abs eq "/";
1215 mkdir($prefix_abs, 0777);
1216 print "CREATE TEST ENVIRONMENT IN '$prefix'...";
1217 if (not defined($no_delete_prefix) or not $no_delete_prefix) {
1218 system("rm -rf $prefix_abs/*");
1220 mkdir($_, 0777) foreach(@dirs);
1222 my $fs_specific_conf = $self->get_fs_specific_conf($shrdir);
1225 ## lockdir and piddir must be 0755
1227 chmod 0755, $lockdir;
1228 chmod 0755, $piddir;
1232 ## create ro and msdfs share layout
1235 chmod 0755, $ro_shrdir;
1236 my $unreadable_file = "$ro_shrdir/unreadable_file";
1237 unless (open(UNREADABLE_FILE, ">$unreadable_file")) {
1238 warn("Unable to open $unreadable_file");
1239 return undef;
1241 close(UNREADABLE_FILE);
1242 chmod 0600, $unreadable_file;
1244 my $msdfs_target = "$ro_shrdir/msdfs-target";
1245 unless (open(MSDFS_TARGET, ">$msdfs_target")) {
1246 warn("Unable to open $msdfs_target");
1247 return undef;
1249 close(MSDFS_TARGET);
1250 chmod 0666, $msdfs_target;
1251 symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp",
1252 "$msdfs_shrdir/msdfs-src1";
1253 symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
1256 ## create bad names in $badnames_shrdir
1258 ## (An invalid name, would be mangled to 8.3).
1259 my $badname_target = "$badnames_shrdir/\340|\231\216\377\177";
1260 unless (open(BADNAME_TARGET, ">$badname_target")) {
1261 warn("Unable to open $badname_target");
1262 return undef;
1264 close(BADNAME_TARGET);
1265 chmod 0666, $badname_target;
1267 ## (A bad name, would not be mangled to 8.3).
1268 my $badname_target = "$badnames_shrdir/\240\276\346\327\377\177";
1269 unless (open(BADNAME_TARGET, ">$badname_target")) {
1270 warn("Unable to open $badname_target");
1271 return undef;
1273 close(BADNAME_TARGET);
1274 chmod 0666, $badname_target;
1276 ## (A bad good name).
1277 my $badname_target = "$badnames_shrdir/blank.txt";
1278 unless (open(BADNAME_TARGET, ">$badname_target")) {
1279 warn("Unable to open $badname_target");
1280 return undef;
1282 close(BADNAME_TARGET);
1283 chmod 0666, $badname_target;
1286 ## create mangleable directory names in $manglenames_shrdir
1288 my $manglename_target = "$manglenames_shrdir/foo:bar";
1289 mkdir($manglename_target, 0777);
1292 ## create symlinks for widelinks tests.
1294 my $widelinks_target = "$widelinks_linkdir/target";
1295 unless (open(WIDELINKS_TARGET, ">$widelinks_target")) {
1296 warn("Unable to open $widelinks_target");
1297 return undef;
1299 close(WIDELINKS_TARGET);
1300 chmod 0666, $widelinks_target;
1302 ## This link should get ACCESS_DENIED
1304 symlink "$widelinks_target", "$widelinks_shrdir/source";
1306 ## This link should be allowed
1308 symlink "$widelinks_shrdir", "$widelinks_shrdir/dot";
1310 my $conffile="$libdir/server.conf";
1311 my $dfqconffile="$libdir/dfq.conf";
1313 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/lib/nss_wrapper/nss_wrapper.pl";
1314 my $nss_wrapper_passwd = "$privatedir/passwd";
1315 my $nss_wrapper_group = "$privatedir/group";
1316 my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts";
1317 my $resolv_conf = "$privatedir/resolv.conf";
1318 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
1320 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
1322 my $fake_snap_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/fake_snap.pl";
1324 my @eventlog_list = ("dns server", "application");
1327 ## calculate uids and gids
1330 my ($max_uid, $max_gid);
1331 my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
1332 my ($uid_pdbtest_wkn);
1333 my ($uid_smbget);
1334 my ($uid_force_user);
1335 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
1336 my ($gid_userdup, $gid_everyone);
1337 my ($gid_force_user);
1339 if ($unix_uid < 0xffff - 7) {
1340 $max_uid = 0xffff;
1341 } else {
1342 $max_uid = $unix_uid;
1345 $uid_root = $max_uid - 1;
1346 $uid_nobody = $max_uid - 2;
1347 $uid_pdbtest = $max_uid - 3;
1348 $uid_pdbtest2 = $max_uid - 4;
1349 $uid_userdup = $max_uid - 5;
1350 $uid_pdbtest_wkn = $max_uid - 6;
1351 $uid_force_user = $max_uid - 7;
1352 $uid_smbget = $max_uid - 8;
1354 if ($unix_gids[0] < 0xffff - 8) {
1355 $max_gid = 0xffff;
1356 } else {
1357 $max_gid = $unix_gids[0];
1360 $gid_nobody = $max_gid - 1;
1361 $gid_nogroup = $max_gid - 2;
1362 $gid_root = $max_gid - 3;
1363 $gid_domusers = $max_gid - 4;
1364 $gid_domadmins = $max_gid - 5;
1365 $gid_userdup = $max_gid - 6;
1366 $gid_everyone = $max_gid - 7;
1367 $gid_force_user = $max_gid - 8;
1370 ## create conffile
1373 unless (open(CONF, ">$conffile")) {
1374 warn("Unable to open $conffile");
1375 return undef;
1377 print CONF "
1378 [global]
1379 netbios name = $server
1380 interfaces = $server_ip/8 $server_ipv6/64
1381 bind interfaces only = yes
1382 panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
1383 smbd:suicide mode = yes
1385 workgroup = $domain
1387 private dir = $privatedir
1388 pid directory = $piddir
1389 lock directory = $lockdir
1390 log file = $logdir/log.\%m
1391 log level = 1
1392 debug pid = yes
1393 max log size = 0
1395 state directory = $lockdir
1396 cache directory = $lockdir
1398 passdb backend = tdbsam
1400 time server = yes
1402 add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1403 add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
1404 add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
1405 add user to group script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type member --action add --member %u --name %g --group_path $nss_wrapper_group
1406 delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
1407 delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
1408 delete user from group script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type member --action delete --member %u --name %g --group_path $nss_wrapper_group
1410 addprinter command = $mod_printer_pl -a -s $conffile --
1411 deleteprinter command = $mod_printer_pl -d -s $conffile --
1413 eventlog list = application \"dns server\"
1415 kernel oplocks = no
1416 kernel change notify = no
1418 logging = file
1419 printing = bsd
1420 printcap name = /dev/null
1422 winbindd socket directory = $wbsockdir
1423 nmbd:socket dir = $nmbdsockdir
1424 idmap config * : range = 100000-200000
1425 winbind enum users = yes
1426 winbind enum groups = yes
1427 winbind separator = /
1429 # min receivefile size = 4000
1431 read only = no
1433 smbd:sharedelay = 100000
1434 smbd:writetimeupdatedelay = 500000
1435 map hidden = no
1436 map system = no
1437 map readonly = no
1438 store dos attributes = yes
1439 create mask = 755
1440 dos filemode = yes
1441 strict rename = yes
1442 strict sync = yes
1443 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot
1445 printing = vlp
1446 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
1447 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
1448 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
1449 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
1450 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
1451 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
1452 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
1453 lpq cache time = 0
1454 print notify backchannel = yes
1456 ncalrpc dir = $prefix_abs/ncalrpc
1458 # The samba3.blackbox.smbclient_s3 test uses this to test that
1459 # sending messages works, and that the %m sub works.
1460 message command = mv %s $shrdir/message.%m
1462 # fsrvp server requires registry shares
1463 registry shares = yes
1465 # Used by RPC SRVSVC tests
1466 add share command = $bindir_abs/smbaddshare
1467 change share command = $bindir_abs/smbchangeshare
1468 delete share command = $bindir_abs/smbdeleteshare
1470 # fruit:copyfile is a global option
1471 fruit:copyfile = yes
1473 #this does not mean that we use non-secure test env,
1474 #it just means we ALLOW one to be configured.
1475 allow insecure wide links = yes
1477 # Begin extra options
1478 $extra_options
1479 # End extra options
1481 #Include user defined custom parameters if set
1484 if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
1485 print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
1488 print CONF "
1489 [tmp]
1490 path = $shrdir
1491 comment = smb username is [%U]
1492 [tmpsort]
1493 path = $shrdir
1494 comment = Load dirsort module
1495 vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot
1496 [tmpenc]
1497 path = $shrdir
1498 comment = encrypt smb username is [%U]
1499 smb encrypt = required
1500 vfs objects = dirsort
1501 [tmpguest]
1502 path = $shrdir
1503 guest ok = yes
1504 [guestonly]
1505 path = $shrdir
1506 guest only = yes
1507 guest ok = yes
1508 [forceuser]
1509 path = $shrdir
1510 force user = $unix_name
1511 guest ok = yes
1512 [forceuser_unixonly]
1513 comment = force a user with unix user SID and group SID
1514 path = $shrdir
1515 force user = pdbtest
1516 guest ok = yes
1517 [forceuser_wkngroup]
1518 comment = force a user with well-known group SID
1519 path = $shrdir
1520 force user = pdbtest_wkn
1521 guest ok = yes
1522 [forcegroup]
1523 path = $shrdir
1524 force group = nogroup
1525 guest ok = yes
1526 [ro-tmp]
1527 path = $ro_shrdir
1528 guest ok = yes
1529 [write-list-tmp]
1530 path = $shrdir
1531 read only = yes
1532 write list = $unix_name
1533 [valid-users-tmp]
1534 path = $shrdir
1535 valid users = $unix_name
1536 access based share enum = yes
1537 [msdfs-share]
1538 path = $msdfs_shrdir
1539 msdfs root = yes
1540 msdfs shuffle referrals = yes
1541 guest ok = yes
1542 [hideunread]
1543 copy = tmp
1544 hide unreadable = yes
1545 [tmpcase]
1546 copy = tmp
1547 case sensitive = yes
1548 [hideunwrite]
1549 copy = tmp
1550 hide unwriteable files = yes
1551 [durable]
1552 copy = tmp
1553 kernel share modes = no
1554 kernel oplocks = no
1555 posix locking = no
1556 [fs_specific]
1557 copy = tmp
1558 $fs_specific_conf
1559 [print1]
1560 copy = tmp
1561 printable = yes
1563 [print2]
1564 copy = print1
1565 [print3]
1566 copy = print1
1567 default devmode = no
1568 [lp]
1569 copy = print1
1571 [nfs4acl_simple]
1572 path = $shrdir
1573 comment = smb username is [%U]
1574 nfs4:mode = simple
1575 vfs objects = nfs4acl_xattr xattr_tdb
1577 [nfs4acl_special]
1578 path = $shrdir
1579 comment = smb username is [%U]
1580 nfs4:mode = special
1581 vfs objects = nfs4acl_xattr xattr_tdb
1583 [xcopy_share]
1584 path = $shrdir
1585 comment = smb username is [%U]
1586 create mask = 777
1587 force create mode = 777
1588 [posix_share]
1589 path = $shrdir
1590 comment = smb username is [%U]
1591 create mask = 0777
1592 force create mode = 0
1593 directory mask = 0777
1594 force directory mode = 0
1595 vfs objects = xattr_tdb streams_depot
1596 [aio]
1597 copy = tmp
1598 aio read size = 1
1599 aio write size = 1
1601 [print\$]
1602 copy = tmp
1604 [vfs_fruit]
1605 path = $shrdir
1606 vfs objects = catia fruit streams_xattr acl_xattr
1607 ea support = yes
1608 fruit:ressource = file
1609 fruit:metadata = netatalk
1610 fruit:locking = netatalk
1611 fruit:encoding = native
1613 [badname-tmp]
1614 path = $badnames_shrdir
1615 guest ok = yes
1617 [manglenames_share]
1618 path = $manglenames_shrdir
1619 guest ok = yes
1621 [dynamic_share]
1622 path = $shrdir/%R
1623 guest ok = yes
1625 [widelinks_share]
1626 path = $widelinks_shrdir
1627 wide links = no
1628 guest ok = yes
1630 [fsrvp_share]
1631 path = $shrdir
1632 comment = fake shapshots using rsync
1633 vfs objects = shell_snap shadow_copy2
1634 shell_snap:check path command = $fake_snap_pl --check
1635 shell_snap:create command = $fake_snap_pl --create
1636 shell_snap:delete command = $fake_snap_pl --delete
1637 # a relative path here fails, the snapshot dir is no longer found
1638 shadow:snapdir = $shrdir/.snapshots
1640 [shadow1]
1641 path = $shadow_shrdir
1642 comment = previous versions snapshots under mount point
1643 vfs objects = shadow_copy2
1644 shadow:mountpoint = $shadow_mntdir
1646 [shadow2]
1647 path = $shadow_shrdir
1648 comment = previous versions snapshots outside mount point
1649 vfs objects = shadow_copy2
1650 shadow:mountpoint = $shadow_mntdir
1651 shadow:snapdir = $shadow_tstdir/.snapshots
1653 [shadow3]
1654 path = $shadow_shrdir
1655 comment = previous versions with subvolume snapshots, snapshots under base dir
1656 vfs objects = shadow_copy2
1657 shadow:mountpoint = $shadow_mntdir
1658 shadow:basedir = $shadow_basedir
1659 shadow:snapdir = $shadow_basedir/.snapshots
1661 [shadow4]
1662 path = $shadow_shrdir
1663 comment = previous versions with subvolume snapshots, snapshots outside mount point
1664 vfs objects = shadow_copy2
1665 shadow:mountpoint = $shadow_mntdir
1666 shadow:basedir = $shadow_basedir
1667 shadow:snapdir = $shadow_tstdir/.snapshots
1669 [shadow5]
1670 path = $shadow_shrdir
1671 comment = previous versions at volume root snapshots under mount point
1672 vfs objects = shadow_copy2
1673 shadow:mountpoint = $shadow_shrdir
1675 [shadow6]
1676 path = $shadow_shrdir
1677 comment = previous versions at volume root snapshots outside mount point
1678 vfs objects = shadow_copy2
1679 shadow:mountpoint = $shadow_shrdir
1680 shadow:snapdir = $shadow_tstdir/.snapshots
1682 [shadow7]
1683 path = $shadow_shrdir
1684 comment = previous versions snapshots everywhere
1685 vfs objects = shadow_copy2
1686 shadow:mountpoint = $shadow_mntdir
1687 shadow:snapdirseverywhere = yes
1689 [shadow8]
1690 path = $shadow_shrdir
1691 comment = previous versions using snapsharepath
1692 vfs objects = shadow_copy2
1693 shadow:mountpoint = $shadow_mntdir
1694 shadow:snapdir = $shadow_tstdir/.snapshots
1695 shadow:snapsharepath = share
1697 [shadow_wl]
1698 path = $shadow_shrdir
1699 comment = previous versions with wide links allowed
1700 vfs objects = shadow_copy2
1701 shadow:mountpoint = $shadow_mntdir
1702 wide links = yes
1703 [dfq]
1704 path = $shrdir/dfree
1705 vfs objects = fake_dfq
1706 admin users = $unix_name
1707 include = $dfqconffile
1709 close(CONF);
1711 unless (open(DFQCONF, ">$dfqconffile")) {
1712 warn("Unable to open $dfqconffile");
1713 return undef;
1715 close(DFQCONF);
1718 ## create a test account
1721 unless (open(PASSWD, ">$nss_wrapper_passwd")) {
1722 warn("Unable to open $nss_wrapper_passwd");
1723 return undef;
1725 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
1726 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
1727 pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
1728 pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
1729 userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
1730 pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false
1731 force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false
1732 smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false
1734 if ($unix_uid != 0) {
1735 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
1738 close(PASSWD);
1740 unless (open(GROUP, ">$nss_wrapper_group")) {
1741 warn("Unable to open $nss_wrapper_group");
1742 return undef;
1744 print GROUP "nobody:x:$gid_nobody:
1745 nogroup:x:$gid_nogroup:nobody
1746 $unix_name-group:x:$unix_gids[0]:
1747 domusers:X:$gid_domusers:
1748 domadmins:X:$gid_domadmins:
1749 userdup:x:$gid_userdup:$unix_name
1750 everyone:x:$gid_everyone:
1751 force_user:x:$gid_force_user:
1753 if ($unix_gids[0] != 0) {
1754 print GROUP "root:x:$gid_root:
1758 close(GROUP);
1760 ## hosts
1761 my $hostname = lc($server);
1762 unless (open(HOSTS, ">>$nss_wrapper_hosts")) {
1763 warn("Unable to open $nss_wrapper_hosts");
1764 return undef;
1766 print HOSTS "${server_ip} ${hostname}.samba.example.com ${hostname}\n";
1767 print HOSTS "${server_ipv6} ${hostname}.samba.example.com ${hostname}\n";
1768 close(HOSTS);
1770 ## hosts
1771 unless (open(RESOLV_CONF, ">$resolv_conf")) {
1772 warn("Unable to open $resolv_conf");
1773 return undef;
1775 if (defined($dc_server_ip) or defined($dc_server_ipv6)) {
1776 if (defined($dc_server_ip)) {
1777 print RESOLV_CONF "nameserver $dc_server_ip\n";
1779 if (defined($dc_server_ipv6)) {
1780 print RESOLV_CONF "nameserver $dc_server_ipv6\n";
1782 } else {
1783 print RESOLV_CONF "nameserver ${server_ip}\n";
1784 print RESOLV_CONF "nameserver ${server_ipv6}\n";
1786 close(RESOLV_CONF);
1788 foreach my $evlog (@eventlog_list) {
1789 my $evlogtdb = "$eventlogdir/$evlog.tdb";
1790 open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
1791 close(EVENTLOG);
1794 $ENV{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
1795 $ENV{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
1796 $ENV{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
1797 $ENV{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
1798 if ($ENV{SAMBA_DNS_FAKING}) {
1799 $ENV{RESOLV_WRAPPER_CONF} = $resolv_conf;
1800 } else {
1801 $ENV{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
1804 createuser($self, $unix_name, $password, $conffile) || die("Unable to create user");
1805 createuser($self, "force_user", $password, $conffile) || die("Unable to create force_user");
1806 createuser($self, "smbget_user", $password, $conffile) || die("Unable to create smbget_user");
1808 open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
1809 print DNS_UPDATE_LIST "A $server. $server_ip\n";
1810 print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n";
1811 close(DNS_UPDATE_LIST);
1813 $ret{SERVER_IP} = $server_ip;
1814 $ret{SERVER_IPV6} = $server_ipv6;
1815 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
1816 $ret{NMBD_TEST_LOG_POS} = 0;
1817 $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
1818 $ret{WINBINDD_TEST_LOG_POS} = 0;
1819 $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
1820 $ret{SMBD_TEST_LOG_POS} = 0;
1821 $ret{SERVERCONFFILE} = $conffile;
1822 $ret{CONFIGURATION} ="-s $conffile";
1823 $ret{SERVER} = $server;
1824 $ret{USERNAME} = $unix_name;
1825 $ret{USERID} = $unix_uid;
1826 $ret{DOMAIN} = $domain;
1827 $ret{NETBIOSNAME} = $server;
1828 $ret{PASSWORD} = $password;
1829 $ret{PIDDIR} = $piddir;
1830 $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir;
1831 $ret{WINBINDD_PRIV_PIPE_DIR} = $wbsockprivdir;
1832 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
1833 $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
1834 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
1835 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
1836 $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
1837 $ret{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
1838 $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
1839 $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind";
1840 if ($ENV{SAMBA_DNS_FAKING}) {
1841 $ret{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
1842 } else {
1843 $ret{RESOLV_WRAPPER_CONF} = $resolv_conf;
1845 $ret{LOCAL_PATH} = "$shrdir";
1846 $ret{LOGDIR} = $logdir;
1849 # Avoid hitting system krb5.conf -
1850 # An env that needs Kerberos will reset this to the real
1851 # value.
1853 $ret{KRB5_CONFIG} = abs_path($prefix) . "/no_krb5.conf";
1855 return \%ret;
1858 sub wait_for_start($$$$$)
1860 my ($self, $envvars, $nmbd, $winbindd, $smbd) = @_;
1861 my $ret;
1863 if ($nmbd eq "yes") {
1864 my $count = 0;
1866 # give time for nbt server to register its names
1867 print "checking for nmbd\n";
1869 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
1870 my $nmblookup = Samba::bindir_path($self, "nmblookup");
1872 do {
1873 $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
1874 if ($ret != 0) {
1875 sleep(1);
1876 } else {
1877 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
1878 system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
1879 system("$nmblookup $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
1880 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
1882 $count++;
1883 } while ($ret != 0 && $count < 10);
1884 if ($count == 10) {
1885 print "NMBD not reachable after 10 retries\n";
1886 teardown_env($self, $envvars);
1887 return 0;
1891 if ($winbindd eq "yes") {
1892 print "checking for winbindd\n";
1893 my $count = 0;
1894 do {
1895 $ret = system("SELFTEST_WINBINDD_SOCKET_DIR=" . $envvars->{SELFTEST_WINBINDD_SOCKET_DIR} . " " . Samba::bindir_path($self, "wbinfo") . " --ping-dc");
1896 if ($ret != 0) {
1897 sleep(1);
1899 $count++;
1900 } while ($ret != 0 && $count < 20);
1901 if ($count == 20) {
1902 print "WINBINDD not reachable after 20 seconds\n";
1903 teardown_env($self, $envvars);
1904 return 0;
1908 if ($smbd eq "yes") {
1909 # make sure smbd is also up set
1910 print "wait for smbd\n";
1912 my $count = 0;
1913 do {
1914 $ret = system(Samba::bindir_path($self, "smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139");
1915 if ($ret != 0) {
1916 sleep(1);
1918 $count++
1919 } while ($ret != 0 && $count < 20);
1920 if ($count == 20) {
1921 print "SMBD failed to start up in a reasonable time (20sec)\n";
1922 teardown_env($self, $envvars);
1923 return 0;
1927 # Ensure we have domain users mapped.
1928 $ret = system(Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} groupmap add rid=513 unixgroup=domusers type=domain");
1929 if ($ret != 0) {
1930 return 1;
1932 $ret = system(Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} groupmap add rid=512 unixgroup=domadmins type=domain");
1933 if ($ret != 0) {
1934 return 1;
1936 $ret = system(Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin");
1937 if ($ret != 0) {
1938 return 1;
1941 if ($winbindd eq "yes") {
1942 # note: creating builtin groups requires winbindd for the
1943 # unix id allocator
1944 $ret = system("SELFTEST_WINBINDD_SOCKET_DIR=" . $envvars->{SELFTEST_WINBINDD_SOCKET_DIR} . " " . Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} sam createbuiltingroup Users");
1945 if ($ret != 0) {
1946 print "Failed to create BUILTIN\\Users group\n";
1947 return 0;
1949 my $count = 0;
1950 do {
1951 system(Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} cache flush");
1952 $ret = system("SELFTEST_WINBINDD_SOCKET_DIR=" . $envvars->{SELFTEST_WINBINDD_SOCKET_DIR} . " " . Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545");
1953 if ($ret != 0) {
1954 sleep(2);
1956 $count++;
1957 } while ($ret != 0 && $count < 10);
1958 if ($count == 10) {
1959 print "WINBINDD not reachable after 20 seconds\n";
1960 teardown_env($self, $envvars);
1961 return 0;
1965 print $self->getlog_env($envvars);
1967 return 1;