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.
|
---|
5 |
|
---|
6 | package Samba3;
|
---|
7 |
|
---|
8 | use strict;
|
---|
9 | use Cwd qw(abs_path);
|
---|
10 | use FindBin qw($RealBin);
|
---|
11 | use POSIX;
|
---|
12 | use target::Samba;
|
---|
13 |
|
---|
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: $!");
|
---|
19 |
|
---|
20 | while (<IN>) {
|
---|
21 | if (/WITH_ADS/) {
|
---|
22 | $found_ads = 1;
|
---|
23 | }
|
---|
24 | }
|
---|
25 | close IN;
|
---|
26 |
|
---|
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;
|
---|
30 | }
|
---|
31 |
|
---|
32 | # return smb.conf parameters applicable to @path, based on the underlying
|
---|
33 | # filesystem type
|
---|
34 | sub get_fs_specific_conf($$)
|
---|
35 | {
|
---|
36 | my ($self, $path) = @_;
|
---|
37 | my $mods = "";
|
---|
38 | my $stat_out = `stat --file-system $path` or return "";
|
---|
39 |
|
---|
40 | if ($stat_out =~ m/Type:\s+btrfs/) {
|
---|
41 | $mods .= "btrfs ";
|
---|
42 | }
|
---|
43 |
|
---|
44 | if ($mods) {
|
---|
45 | return "vfs objects = $mods";
|
---|
46 | }
|
---|
47 |
|
---|
48 | return undef;
|
---|
49 | }
|
---|
50 |
|
---|
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
|
---|
57 | };
|
---|
58 | bless $self;
|
---|
59 | return $self;
|
---|
60 | }
|
---|
61 |
|
---|
62 | sub teardown_env($$)
|
---|
63 | {
|
---|
64 | my ($self, $envvars) = @_;
|
---|
65 | my $count = 0;
|
---|
66 |
|
---|
67 | # This should cause smbd to terminate gracefully
|
---|
68 | close($envvars->{STDIN_PIPE});
|
---|
69 |
|
---|
70 | my $smbdpid = $envvars->{SMBD_TL_PID};
|
---|
71 | my $nmbdpid = $envvars->{NMBD_TL_PID};
|
---|
72 | my $winbinddpid = $envvars->{WINBINDD_TL_PID};
|
---|
73 |
|
---|
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;
|
---|
83 | }
|
---|
84 | sleep(1);
|
---|
85 | $count++;
|
---|
86 | }
|
---|
87 |
|
---|
88 | if ($count <= 20 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
|
---|
89 | return;
|
---|
90 | }
|
---|
91 |
|
---|
92 | $self->stop_sig_term($smbdpid);
|
---|
93 | $self->stop_sig_term($nmbdpid);
|
---|
94 | $self->stop_sig_term($winbinddpid);
|
---|
95 |
|
---|
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;
|
---|
105 | }
|
---|
106 | sleep(1);
|
---|
107 | $count++;
|
---|
108 | }
|
---|
109 |
|
---|
110 | if ($count <= 10 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) {
|
---|
111 | return;
|
---|
112 | }
|
---|
113 |
|
---|
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);
|
---|
118 |
|
---|
119 | return 0;
|
---|
120 | }
|
---|
121 |
|
---|
122 | sub getlog_env_app($$$)
|
---|
123 | {
|
---|
124 | my ($self, $envvars, $name) = @_;
|
---|
125 |
|
---|
126 | my $title = "$name LOG of: $envvars->{NETBIOSNAME}\n";
|
---|
127 | my $out = $title;
|
---|
128 |
|
---|
129 | open(LOG, "<".$envvars->{$name."_TEST_LOG"});
|
---|
130 |
|
---|
131 | seek(LOG, $envvars->{$name."_TEST_LOG_POS"}, SEEK_SET);
|
---|
132 | while (<LOG>) {
|
---|
133 | $out .= $_;
|
---|
134 | }
|
---|
135 | $envvars->{$name."_TEST_LOG_POS"} = tell(LOG);
|
---|
136 | close(LOG);
|
---|
137 |
|
---|
138 | return "" if $out eq $title;
|
---|
139 |
|
---|
140 | return $out;
|
---|
141 | }
|
---|
142 |
|
---|
143 | sub getlog_env($$)
|
---|
144 | {
|
---|
145 | my ($self, $envvars) = @_;
|
---|
146 | my $ret = "";
|
---|
147 |
|
---|
148 | $ret .= $self->getlog_env_app($envvars, "SMBD");
|
---|
149 | $ret .= $self->getlog_env_app($envvars, "NMBD");
|
---|
150 | $ret .= $self->getlog_env_app($envvars, "WINBINDD");
|
---|
151 |
|
---|
152 | return $ret;
|
---|
153 | }
|
---|
154 |
|
---|
155 | sub check_env($$)
|
---|
156 | {
|
---|
157 | my ($self, $envvars) = @_;
|
---|
158 |
|
---|
159 | my $childpid = waitpid(-1, WNOHANG);
|
---|
160 |
|
---|
161 | # TODO ...
|
---|
162 | return 1;
|
---|
163 | }
|
---|
164 |
|
---|
165 | sub setup_env($$$)
|
---|
166 | {
|
---|
167 | my ($self, $envname, $path) = @_;
|
---|
168 |
|
---|
169 | $ENV{ENVNAME} = $envname;
|
---|
170 |
|
---|
171 | if (defined($self->{vars}->{$envname})) {
|
---|
172 | return $self->{vars}->{$envname};
|
---|
173 | }
|
---|
174 |
|
---|
175 | #
|
---|
176 | # Avoid hitting system krb5.conf -
|
---|
177 | # An env that needs Kerberos will reset this to the real
|
---|
178 | # value.
|
---|
179 | #
|
---|
180 | $ENV{KRB5_CONFIG} = "$path/no_krb5.conf";
|
---|
181 |
|
---|
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;
|
---|
198 | }
|
---|
199 | }
|
---|
200 | return $self->setup_nt4_member("$path/nt4_member", $self->{vars}->{nt4_dc});
|
---|
201 | } else {
|
---|
202 | return "UNKNOWN";
|
---|
203 | }
|
---|
204 | }
|
---|
205 |
|
---|
206 | sub setup_nt4_dc($$)
|
---|
207 | {
|
---|
208 | my ($self, $path) = @_;
|
---|
209 |
|
---|
210 | print "PROVISIONING NT4 DC...";
|
---|
211 |
|
---|
212 | my $nt4_dc_options = "
|
---|
213 | domain master = yes
|
---|
214 | domain logons = yes
|
---|
215 | lanman auth = yes
|
---|
216 | raw NTLMv2 auth = yes
|
---|
217 |
|
---|
218 | rpc_server:epmapper = external
|
---|
219 | rpc_server:spoolss = external
|
---|
220 | rpc_server:lsarpc = external
|
---|
221 | rpc_server:samr = external
|
---|
222 | rpc_server:netlogon = external
|
---|
223 | rpc_server:register_embedded_np = yes
|
---|
224 | rpc_server:FssagentRpc = external
|
---|
225 |
|
---|
226 | rpc_daemon:epmd = fork
|
---|
227 | rpc_daemon:spoolssd = fork
|
---|
228 | rpc_daemon:lsasd = fork
|
---|
229 | rpc_daemon:fssd = fork
|
---|
230 | fss: sequence timeout = 1
|
---|
231 | ";
|
---|
232 |
|
---|
233 | my $vars = $self->provision($path,
|
---|
234 | "LOCALNT4DC2",
|
---|
235 | "localntdc2pass",
|
---|
236 | $nt4_dc_options);
|
---|
237 |
|
---|
238 | $vars or return undef;
|
---|
239 |
|
---|
240 | if (not $self->check_or_start($vars, "yes", "yes", "yes")) {
|
---|
241 | return undef;
|
---|
242 | }
|
---|
243 |
|
---|
244 | $vars->{DC_SERVER} = $vars->{SERVER};
|
---|
245 | $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
|
---|
246 | $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
|
---|
247 | $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
|
---|
248 | $vars->{DC_USERNAME} = $vars->{USERNAME};
|
---|
249 | $vars->{DC_PASSWORD} = $vars->{PASSWORD};
|
---|
250 |
|
---|
251 | $self->{vars}->{nt4_dc} = $vars;
|
---|
252 |
|
---|
253 | return $vars;
|
---|
254 | }
|
---|
255 |
|
---|
256 | sub setup_nt4_dc_schannel($$)
|
---|
257 | {
|
---|
258 | my ($self, $path) = @_;
|
---|
259 |
|
---|
260 | print "PROVISIONING NT4 DC WITH SERVER SCHANNEL ...";
|
---|
261 |
|
---|
262 | my $pdc_options = "
|
---|
263 | domain master = yes
|
---|
264 | domain logons = yes
|
---|
265 | lanman auth = yes
|
---|
266 |
|
---|
267 | rpc_server:epmapper = external
|
---|
268 | rpc_server:spoolss = external
|
---|
269 | rpc_server:lsarpc = external
|
---|
270 | rpc_server:samr = external
|
---|
271 | rpc_server:netlogon = external
|
---|
272 | rpc_server:register_embedded_np = yes
|
---|
273 |
|
---|
274 | rpc_daemon:epmd = fork
|
---|
275 | rpc_daemon:spoolssd = fork
|
---|
276 | rpc_daemon:lsasd = fork
|
---|
277 |
|
---|
278 | server schannel = yes
|
---|
279 | ";
|
---|
280 |
|
---|
281 | my $vars = $self->provision($path,
|
---|
282 | "LOCALNT4DC9",
|
---|
283 | "localntdc9pass",
|
---|
284 | $pdc_options);
|
---|
285 |
|
---|
286 | $vars or return undef;
|
---|
287 |
|
---|
288 | if (not $self->check_or_start($vars, "yes", "yes", "yes")) {
|
---|
289 | return undef;
|
---|
290 | }
|
---|
291 |
|
---|
292 | $vars->{DC_SERVER} = $vars->{SERVER};
|
---|
293 | $vars->{DC_SERVER_IP} = $vars->{SERVER_IP};
|
---|
294 | $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6};
|
---|
295 | $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME};
|
---|
296 | $vars->{DC_USERNAME} = $vars->{USERNAME};
|
---|
297 | $vars->{DC_PASSWORD} = $vars->{PASSWORD};
|
---|
298 |
|
---|
299 | $self->{vars}->{nt4_dc_schannel} = $vars;
|
---|
300 |
|
---|
301 | return $vars;
|
---|
302 | }
|
---|
303 |
|
---|
304 | sub setup_nt4_member($$$)
|
---|
305 | {
|
---|
306 | my ($self, $prefix, $nt4_dc_vars) = @_;
|
---|
307 | my $count = 0;
|
---|
308 | my $rc;
|
---|
309 |
|
---|
310 | print "PROVISIONING MEMBER...";
|
---|
311 |
|
---|
312 | my $member_options = "
|
---|
313 | security = domain
|
---|
314 | server signing = on
|
---|
315 | dbwrap_tdb_mutexes:* = yes
|
---|
316 | ";
|
---|
317 | my $ret = $self->provision($prefix,
|
---|
318 | "LOCALNT4MEMBER3",
|
---|
319 | "localnt4member3pass",
|
---|
320 | $member_options);
|
---|
321 |
|
---|
322 | $ret or return undef;
|
---|
323 |
|
---|
324 | my $nmblookup = Samba::bindir_path($self, "nmblookup");
|
---|
325 | do {
|
---|
326 | print "Waiting for the LOGON SERVER registration ...\n";
|
---|
327 | $rc = system("$nmblookup $ret->{CONFIGURATION} $ret->{DOMAIN}\#1c");
|
---|
328 | if ($rc != 0) {
|
---|
329 | sleep(1);
|
---|
330 | }
|
---|
331 | $count++;
|
---|
332 | } while ($rc != 0 && $count < 10);
|
---|
333 | if ($count == 10) {
|
---|
334 | print "NMBD not reachable after 10 retries\n";
|
---|
335 | teardown_env($self, $ret);
|
---|
336 | return 0;
|
---|
337 | }
|
---|
338 |
|
---|
339 | my $net = Samba::bindir_path($self, "net");
|
---|
340 | my $cmd = "";
|
---|
341 | $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
|
---|
342 | $cmd .= "$net join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member";
|
---|
343 | $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}";
|
---|
344 |
|
---|
345 | if (system($cmd) != 0) {
|
---|
346 | warn("Join failed\n$cmd");
|
---|
347 | return undef;
|
---|
348 | }
|
---|
349 |
|
---|
350 | if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
|
---|
351 | return undef;
|
---|
352 | }
|
---|
353 |
|
---|
354 | $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER};
|
---|
355 | $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP};
|
---|
356 | $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6};
|
---|
357 | $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME};
|
---|
358 | $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME};
|
---|
359 | $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD};
|
---|
360 |
|
---|
361 | return $ret;
|
---|
362 | }
|
---|
363 |
|
---|
364 | sub setup_admember($$$$)
|
---|
365 | {
|
---|
366 | my ($self, $prefix, $dcvars) = @_;
|
---|
367 |
|
---|
368 | # If we didn't build with ADS, pretend this env was never available
|
---|
369 | if (not $self->have_ads()) {
|
---|
370 | return "UNKNOWN";
|
---|
371 | }
|
---|
372 |
|
---|
373 | print "PROVISIONING S3 AD MEMBER...";
|
---|
374 |
|
---|
375 | my $member_options = "
|
---|
376 | security = ads
|
---|
377 | server signing = on
|
---|
378 | workgroup = $dcvars->{DOMAIN}
|
---|
379 | realm = $dcvars->{REALM}
|
---|
380 | ";
|
---|
381 |
|
---|
382 | my $ret = $self->provision($prefix,
|
---|
383 | "LOCALADMEMBER",
|
---|
384 | "loCalMemberPass",
|
---|
385 | $member_options,
|
---|
386 | $dcvars->{SERVER_IP},
|
---|
387 | $dcvars->{SERVER_IPV6});
|
---|
388 |
|
---|
389 | $ret or return undef;
|
---|
390 |
|
---|
391 | close(USERMAP);
|
---|
392 | $ret->{DOMAIN} = $dcvars->{DOMAIN};
|
---|
393 | $ret->{REALM} = $dcvars->{REALM};
|
---|
394 |
|
---|
395 | my $ctx;
|
---|
396 | my $prefix_abs = abs_path($prefix);
|
---|
397 | $ctx = {};
|
---|
398 | $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
|
---|
399 | $ctx->{domain} = $dcvars->{DOMAIN};
|
---|
400 | $ctx->{realm} = $dcvars->{REALM};
|
---|
401 | $ctx->{dnsname} = lc($dcvars->{REALM});
|
---|
402 | $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
|
---|
403 | $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
|
---|
404 | Samba::mk_krb5_conf($ctx, "");
|
---|
405 |
|
---|
406 | $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
|
---|
407 |
|
---|
408 | my $net = Samba::bindir_path($self, "net");
|
---|
409 | my $cmd = "";
|
---|
410 | $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
|
---|
411 | if (defined($ret->{RESOLV_WRAPPER_CONF})) {
|
---|
412 | $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
|
---|
413 | } else {
|
---|
414 | $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
|
---|
415 | }
|
---|
416 | $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
|
---|
417 | $cmd .= "$net join $ret->{CONFIGURATION}";
|
---|
418 | $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
|
---|
419 |
|
---|
420 | if (system($cmd) != 0) {
|
---|
421 | warn("Join failed\n$cmd");
|
---|
422 | return undef;
|
---|
423 | }
|
---|
424 |
|
---|
425 | # We need world access to this share, as otherwise the domain
|
---|
426 | # administrator from the AD domain provided by Samba4 can't
|
---|
427 | # access the share for tests.
|
---|
428 | chmod 0777, "$prefix/share";
|
---|
429 |
|
---|
430 | if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
|
---|
431 | return undef;
|
---|
432 | }
|
---|
433 |
|
---|
434 | $ret->{DC_SERVER} = $dcvars->{SERVER};
|
---|
435 | $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
|
---|
436 | $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
|
---|
437 | $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
|
---|
438 | $ret->{DC_USERNAME} = $dcvars->{USERNAME};
|
---|
439 | $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
|
---|
440 |
|
---|
441 | # Special case, this is called from Samba4.pm but needs to use the Samba3 check_env and get_log_env
|
---|
442 | $ret->{target} = $self;
|
---|
443 |
|
---|
444 | return $ret;
|
---|
445 | }
|
---|
446 |
|
---|
447 | sub setup_admember_rfc2307($$$$)
|
---|
448 | {
|
---|
449 | my ($self, $prefix, $dcvars) = @_;
|
---|
450 |
|
---|
451 | # If we didn't build with ADS, pretend this env was never available
|
---|
452 | if (not $self->have_ads()) {
|
---|
453 | return "UNKNOWN";
|
---|
454 | }
|
---|
455 |
|
---|
456 | print "PROVISIONING S3 AD MEMBER WITH idmap_rfc2307 config...";
|
---|
457 |
|
---|
458 | my $member_options = "
|
---|
459 | security = ads
|
---|
460 | server signing = on
|
---|
461 | workgroup = $dcvars->{DOMAIN}
|
---|
462 | realm = $dcvars->{REALM}
|
---|
463 | idmap config * : backend = autorid
|
---|
464 | idmap config * : range = 1000000-1999999
|
---|
465 | idmap config * : rangesize = 100000
|
---|
466 | idmap config $dcvars->{DOMAIN} : backend = rfc2307
|
---|
467 | idmap config $dcvars->{DOMAIN} : range = 2000000-2999999
|
---|
468 | idmap config $dcvars->{DOMAIN} : ldap_server = ad
|
---|
469 | idmap config $dcvars->{DOMAIN} : bind_path_user = ou=idmap,dc=samba,dc=example,dc=com
|
---|
470 | idmap config $dcvars->{DOMAIN} : bind_path_group = ou=idmap,dc=samba,dc=example,dc=com
|
---|
471 | ";
|
---|
472 |
|
---|
473 | my $ret = $self->provision($prefix,
|
---|
474 | "RFC2307MEMBER",
|
---|
475 | "loCalMemberPass",
|
---|
476 | $member_options,
|
---|
477 | $dcvars->{SERVER_IP},
|
---|
478 | $dcvars->{SERVER_IPV6});
|
---|
479 |
|
---|
480 | $ret or return undef;
|
---|
481 |
|
---|
482 | close(USERMAP);
|
---|
483 | $ret->{DOMAIN} = $dcvars->{DOMAIN};
|
---|
484 | $ret->{REALM} = $dcvars->{REALM};
|
---|
485 |
|
---|
486 | my $ctx;
|
---|
487 | my $prefix_abs = abs_path($prefix);
|
---|
488 | $ctx = {};
|
---|
489 | $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
|
---|
490 | $ctx->{domain} = $dcvars->{DOMAIN};
|
---|
491 | $ctx->{realm} = $dcvars->{REALM};
|
---|
492 | $ctx->{dnsname} = lc($dcvars->{REALM});
|
---|
493 | $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
|
---|
494 | $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6};
|
---|
495 | Samba::mk_krb5_conf($ctx, "");
|
---|
496 |
|
---|
497 | $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
|
---|
498 |
|
---|
499 | my $net = Samba::bindir_path($self, "net");
|
---|
500 | my $cmd = "";
|
---|
501 | $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
|
---|
502 | if (defined($ret->{RESOLV_WRAPPER_CONF})) {
|
---|
503 | $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" ";
|
---|
504 | } else {
|
---|
505 | $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" ";
|
---|
506 | }
|
---|
507 | $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
|
---|
508 | $cmd .= "$net join $ret->{CONFIGURATION}";
|
---|
509 | $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}";
|
---|
510 |
|
---|
511 | if (system($cmd) != 0) {
|
---|
512 | warn("Join failed\n$cmd");
|
---|
513 | return undef;
|
---|
514 | }
|
---|
515 |
|
---|
516 | # We need world access to this share, as otherwise the domain
|
---|
517 | # administrator from the AD domain provided by Samba4 can't
|
---|
518 | # access the share for tests.
|
---|
519 | chmod 0777, "$prefix/share";
|
---|
520 |
|
---|
521 | if (not $self->check_or_start($ret, "yes", "yes", "yes")) {
|
---|
522 | return undef;
|
---|
523 | }
|
---|
524 |
|
---|
525 | $ret->{DC_SERVER} = $dcvars->{SERVER};
|
---|
526 | $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
|
---|
527 | $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6};
|
---|
528 | $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
|
---|
529 | $ret->{DC_USERNAME} = $dcvars->{USERNAME};
|
---|
530 | $ret->{DC_PASSWORD} = $dcvars->{PASSWORD};
|
---|
531 |
|
---|
532 | # Special case, this is called from Samba4.pm but needs to use the Samba3 check_env and get_log_env
|
---|
533 | $ret->{target} = $self;
|
---|
534 |
|
---|
535 | return $ret;
|
---|
536 | }
|
---|
537 |
|
---|
538 | sub setup_simpleserver($$)
|
---|
539 | {
|
---|
540 | my ($self, $path) = @_;
|
---|
541 |
|
---|
542 | print "PROVISIONING simple server...";
|
---|
543 |
|
---|
544 | my $prefix_abs = abs_path($path);
|
---|
545 |
|
---|
546 | my $simpleserver_options = "
|
---|
547 | lanman auth = yes
|
---|
548 | vfs objects = xattr_tdb streams_depot
|
---|
549 | change notify = no
|
---|
550 |
|
---|
551 | [vfs_aio_fork]
|
---|
552 | path = $prefix_abs/share
|
---|
553 | vfs objects = aio_fork
|
---|
554 | read only = no
|
---|
555 | vfs_aio_fork:erratic_testing_mode=yes
|
---|
556 |
|
---|
557 | [dosmode]
|
---|
558 | path = $prefix_abs/share
|
---|
559 | vfs objects =
|
---|
560 | store dos attributes = yes
|
---|
561 | hide files = /hidefile/
|
---|
562 | hide dot files = yes
|
---|
563 | ";
|
---|
564 |
|
---|
565 | my $vars = $self->provision($path,
|
---|
566 | "LOCALSHARE4",
|
---|
567 | "local4pass",
|
---|
568 | $simpleserver_options);
|
---|
569 |
|
---|
570 | $vars or return undef;
|
---|
571 |
|
---|
572 | if (not $self->check_or_start($vars, "yes", "no", "yes")) {
|
---|
573 | return undef;
|
---|
574 | }
|
---|
575 |
|
---|
576 | $self->{vars}->{simpleserver} = $vars;
|
---|
577 |
|
---|
578 | return $vars;
|
---|
579 | }
|
---|
580 |
|
---|
581 | sub setup_fileserver($$)
|
---|
582 | {
|
---|
583 | my ($self, $path) = @_;
|
---|
584 | my $prefix_abs = abs_path($path);
|
---|
585 | my $srcdir_abs = abs_path($self->{srcdir});
|
---|
586 |
|
---|
587 | print "PROVISIONING file server ...\n";
|
---|
588 |
|
---|
589 | my @dirs = ();
|
---|
590 |
|
---|
591 | mkdir($prefix_abs, 0777);
|
---|
592 |
|
---|
593 | my $share_dir="$prefix_abs/share";
|
---|
594 |
|
---|
595 | # Create share directory structure
|
---|
596 | my $lower_case_share_dir="$share_dir/lower-case";
|
---|
597 | push(@dirs, $lower_case_share_dir);
|
---|
598 |
|
---|
599 | my $lower_case_share_dir_30000="$share_dir/lower-case-30000";
|
---|
600 | push(@dirs, $lower_case_share_dir_30000);
|
---|
601 |
|
---|
602 | my $dfree_share_dir="$share_dir/dfree";
|
---|
603 | push(@dirs, $dfree_share_dir);
|
---|
604 | push(@dirs, "$dfree_share_dir/subdir1");
|
---|
605 | push(@dirs, "$dfree_share_dir/subdir2");
|
---|
606 | push(@dirs, "$dfree_share_dir/subdir3");
|
---|
607 |
|
---|
608 | my $valid_users_sharedir="$share_dir/valid_users";
|
---|
609 | push(@dirs,$valid_users_sharedir);
|
---|
610 |
|
---|
611 | my $offline_sharedir="$share_dir/offline";
|
---|
612 | push(@dirs,$offline_sharedir);
|
---|
613 |
|
---|
614 | my $force_user_valid_users_dir = "$share_dir/force_user_valid_users";
|
---|
615 | push(@dirs, $force_user_valid_users_dir);
|
---|
616 |
|
---|
617 | my $smbget_sharedir="$share_dir/smbget";
|
---|
618 | push(@dirs,$smbget_sharedir);
|
---|
619 |
|
---|
620 | my $fileserver_options = "
|
---|
621 | [lowercase]
|
---|
622 | path = $lower_case_share_dir
|
---|
623 | comment = smb username is [%U]
|
---|
624 | case sensitive = True
|
---|
625 | default case = lower
|
---|
626 | preserve case = no
|
---|
627 | short preserve case = no
|
---|
628 | [lowercase-30000]
|
---|
629 | path = $lower_case_share_dir_30000
|
---|
630 | comment = smb username is [%U]
|
---|
631 | case sensitive = True
|
---|
632 | default case = lower
|
---|
633 | preserve case = no
|
---|
634 | short preserve case = no
|
---|
635 | [dfree]
|
---|
636 | path = $dfree_share_dir
|
---|
637 | comment = smb username is [%U]
|
---|
638 | dfree command = $srcdir_abs/testprogs/blackbox/dfree.sh
|
---|
639 | [valid-users-access]
|
---|
640 | path = $valid_users_sharedir
|
---|
641 | valid users = +userdup
|
---|
642 | [offline]
|
---|
643 | path = $offline_sharedir
|
---|
644 | vfs objects = offline
|
---|
645 |
|
---|
646 | # BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878
|
---|
647 | # RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651
|
---|
648 | [force_user_valid_users]
|
---|
649 | path = $force_user_valid_users_dir
|
---|
650 | comment = force user with valid users combination test share
|
---|
651 | valid users = +force_user
|
---|
652 | force user = force_user
|
---|
653 | force group = everyone
|
---|
654 | write list = force_user
|
---|
655 |
|
---|
656 | [smbget]
|
---|
657 | path = $smbget_sharedir
|
---|
658 | comment = smb username is [%U]
|
---|
659 | guest ok = yes
|
---|
660 | ";
|
---|
661 |
|
---|
662 | my $vars = $self->provision($path,
|
---|
663 | "FILESERVER",
|
---|
664 | "fileserver",
|
---|
665 | $fileserver_options,
|
---|
666 | undef,
|
---|
667 | undef,
|
---|
668 | 1);
|
---|
669 |
|
---|
670 | $vars or return undef;
|
---|
671 |
|
---|
672 | if (not $self->check_or_start($vars, "yes", "no", "yes")) {
|
---|
673 | return undef;
|
---|
674 | }
|
---|
675 |
|
---|
676 | $self->{vars}->{fileserver} = $vars;
|
---|
677 |
|
---|
678 | mkdir($_, 0777) foreach(@dirs);
|
---|
679 |
|
---|
680 | ## Create case sensitive lower case share dir
|
---|
681 | foreach my $file ('a'..'z') {
|
---|
682 | my $full_path = $lower_case_share_dir . '/' . $file;
|
---|
683 | open my $fh, '>', $full_path;
|
---|
684 | # Add some content to file
|
---|
685 | print $fh $full_path;
|
---|
686 | close $fh;
|
---|
687 | }
|
---|
688 |
|
---|
689 | for (my $file = 1; $file < 51; ++$file) {
|
---|
690 | my $full_path = $lower_case_share_dir . '/' . $file;
|
---|
691 | open my $fh, '>', $full_path;
|
---|
692 | # Add some content to file
|
---|
693 | print $fh $full_path;
|
---|
694 | close $fh;
|
---|
695 | }
|
---|
696 |
|
---|
697 | # Create content for 30000 share
|
---|
698 | foreach my $file ('a'..'z') {
|
---|
699 | my $full_path = $lower_case_share_dir_30000 . '/' . $file;
|
---|
700 | open my $fh, '>', $full_path;
|
---|
701 | # Add some content to file
|
---|
702 | print $fh $full_path;
|
---|
703 | close $fh;
|
---|
704 | }
|
---|
705 |
|
---|
706 | for (my $file = 1; $file < 30001; ++$file) {
|
---|
707 | my $full_path = $lower_case_share_dir_30000 . '/' . $file;
|
---|
708 | open my $fh, '>', $full_path;
|
---|
709 | # Add some content to file
|
---|
710 | print $fh $full_path;
|
---|
711 | close $fh;
|
---|
712 | }
|
---|
713 |
|
---|
714 | ##
|
---|
715 | ## create a listable file in valid_users_share
|
---|
716 | ##
|
---|
717 | my $valid_users_target = "$valid_users_sharedir/foo";
|
---|
718 | unless (open(VALID_USERS_TARGET, ">$valid_users_target")) {
|
---|
719 | warn("Unable to open $valid_users_target");
|
---|
720 | return undef;
|
---|
721 | }
|
---|
722 | close(VALID_USERS_TARGET);
|
---|
723 | chmod 0644, $valid_users_target;
|
---|
724 |
|
---|
725 | return $vars;
|
---|
726 | }
|
---|
727 |
|
---|
728 | sub setup_ktest($$$)
|
---|
729 | {
|
---|
730 | my ($self, $prefix) = @_;
|
---|
731 |
|
---|
732 | # If we didn't build with ADS, pretend this env was never available
|
---|
733 | if (not $self->have_ads()) {
|
---|
734 | return "UNKNOWN";
|
---|
735 | }
|
---|
736 |
|
---|
737 | print "PROVISIONING server with security=ads...";
|
---|
738 |
|
---|
739 | my $ktest_options = "
|
---|
740 | workgroup = KTEST
|
---|
741 | realm = ktest.samba.example.com
|
---|
742 | security = ads
|
---|
743 | username map = $prefix/lib/username.map
|
---|
744 | server signing = required
|
---|
745 | ";
|
---|
746 |
|
---|
747 | my $ret = $self->provision($prefix,
|
---|
748 | "LOCALKTEST6",
|
---|
749 | "localktest6pass",
|
---|
750 | $ktest_options);
|
---|
751 |
|
---|
752 | $ret or return undef;
|
---|
753 |
|
---|
754 | my $ctx;
|
---|
755 | my $prefix_abs = abs_path($prefix);
|
---|
756 | $ctx = {};
|
---|
757 | $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf";
|
---|
758 | $ctx->{domain} = "KTEST";
|
---|
759 | $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
|
---|
760 | $ctx->{dnsname} = lc($ctx->{realm});
|
---|
761 | $ctx->{kdc_ipv4} = "0.0.0.0";
|
---|
762 | $ctx->{kdc_ipv6} = "::";
|
---|
763 | Samba::mk_krb5_conf($ctx, "");
|
---|
764 |
|
---|
765 | $ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
|
---|
766 |
|
---|
767 | open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map");
|
---|
768 | print USERMAP "
|
---|
769 | $ret->{USERNAME} = KTEST\\Administrator
|
---|
770 | ";
|
---|
771 | close(USERMAP);
|
---|
772 |
|
---|
773 | #This is the secrets.tdb created by 'net ads join' from Samba3 to a
|
---|
774 | #Samba4 DC with the same parameters as are being used here. The
|
---|
775 | #domain SID is S-1-5-21-1071277805-689288055-3486227160
|
---|
776 |
|
---|
777 | system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb");
|
---|
778 | chmod 0600, "$prefix/private/secrets.tdb";
|
---|
779 |
|
---|
780 | #Make sure there's no old ntdb file.
|
---|
781 | system("rm -f $prefix/private/secrets.ntdb");
|
---|
782 |
|
---|
783 | #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with:
|
---|
784 | # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232"
|
---|
785 | #
|
---|
786 | #and having in krb5.conf:
|
---|
787 | # ticket_lifetime = 799718400
|
---|
788 | # renew_lifetime = 799718400
|
---|
789 | #
|
---|
790 | # The commands for the -2 keytab where were:
|
---|
791 | # kinit administrator@KTEST.SAMBA.EXAMPLE.COM
|
---|
792 | # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM
|
---|
793 | # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM
|
---|
794 | # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
|
---|
795 | # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM
|
---|
796 | #
|
---|
797 | # and then for the -3 keytab, I did
|
---|
798 | #
|
---|
799 | # net changetrustpw; kdestroy and the same again.
|
---|
800 | #
|
---|
801 | # This creates a credential cache with a very long lifetime (2036 at
|
---|
802 | # at 2011-04), and shows that running 'net changetrustpw' does not
|
---|
803 | # break existing logins (for the secrets.tdb method at least).
|
---|
804 | #
|
---|
805 |
|
---|
806 | $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache";
|
---|
807 |
|
---|
808 | system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2");
|
---|
809 | chmod 0600, "$prefix/krb5_ccache-2";
|
---|
810 |
|
---|
811 | system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
|
---|
812 | chmod 0600, "$prefix/krb5_ccache-3";
|
---|
813 |
|
---|
814 | # We need world access to this share, as otherwise the domain
|
---|
815 | # administrator from the AD domain provided by ktest can't
|
---|
816 | # access the share for tests.
|
---|
817 | chmod 0777, "$prefix/share";
|
---|
818 |
|
---|
819 | if (not $self->check_or_start($ret, "yes", "no", "yes")) {
|
---|
820 | return undef;
|
---|
821 | }
|
---|
822 | return $ret;
|
---|
823 | }
|
---|
824 |
|
---|
825 | sub setup_maptoguest($$)
|
---|
826 | {
|
---|
827 | my ($self, $path) = @_;
|
---|
828 |
|
---|
829 | print "PROVISIONING maptoguest...";
|
---|
830 |
|
---|
831 | my $options = "
|
---|
832 | map to guest = bad user
|
---|
833 | ";
|
---|
834 |
|
---|
835 | my $vars = $self->provision($path,
|
---|
836 | "maptoguest",
|
---|
837 | "maptoguestpass",
|
---|
838 | $options);
|
---|
839 |
|
---|
840 | $vars or return undef;
|
---|
841 |
|
---|
842 | if (not $self->check_or_start($vars, "yes", "no", "yes")) {
|
---|
843 | return undef;
|
---|
844 | }
|
---|
845 |
|
---|
846 | $self->{vars}->{s3maptoguest} = $vars;
|
---|
847 |
|
---|
848 | return $vars;
|
---|
849 | }
|
---|
850 |
|
---|
851 | sub stop_sig_term($$) {
|
---|
852 | my ($self, $pid) = @_;
|
---|
853 | kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
|
---|
854 | }
|
---|
855 |
|
---|
856 | sub stop_sig_kill($$) {
|
---|
857 | my ($self, $pid) = @_;
|
---|
858 | kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
|
---|
859 | }
|
---|
860 |
|
---|
861 | sub write_pid($$$)
|
---|
862 | {
|
---|
863 | my ($env_vars, $app, $pid) = @_;
|
---|
864 |
|
---|
865 | open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid");
|
---|
866 | print PID $pid;
|
---|
867 | close(PID);
|
---|
868 | }
|
---|
869 |
|
---|
870 | sub read_pid($$)
|
---|
871 | {
|
---|
872 | my ($env_vars, $app) = @_;
|
---|
873 |
|
---|
874 | open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid");
|
---|
875 | my $pid = <PID>;
|
---|
876 | close(PID);
|
---|
877 | return $pid;
|
---|
878 | }
|
---|
879 |
|
---|
880 | sub check_or_start($$$$$) {
|
---|
881 | my ($self, $env_vars, $nmbd, $winbindd, $smbd) = @_;
|
---|
882 |
|
---|
883 | # use a pipe for stdin in the child processes. This allows
|
---|
884 | # those processes to monitor the pipe for EOF to ensure they
|
---|
885 | # exit when the test script exits
|
---|
886 | pipe(STDIN_READER, $env_vars->{STDIN_PIPE});
|
---|
887 |
|
---|
888 | unlink($env_vars->{NMBD_TEST_LOG});
|
---|
889 | print "STARTING NMBD...";
|
---|
890 | my $pid = fork();
|
---|
891 | if ($pid == 0) {
|
---|
892 | open STDOUT, ">$env_vars->{NMBD_TEST_LOG}";
|
---|
893 | open STDERR, '>&STDOUT';
|
---|
894 |
|
---|
895 | SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
|
---|
896 |
|
---|
897 | $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
|
---|
898 | $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
|
---|
899 | $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
|
---|
900 |
|
---|
901 | $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
|
---|
902 | $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
|
---|
903 | $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
|
---|
904 | $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
|
---|
905 | $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
|
---|
906 | $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
|
---|
907 | $ENV{UID_WRAPPER_ROOT} = "1";
|
---|
908 |
|
---|
909 | $ENV{ENVNAME} = "$ENV{ENVNAME}.nmbd";
|
---|
910 |
|
---|
911 | if ($nmbd ne "yes") {
|
---|
912 | $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
|
---|
913 | my $signame = shift;
|
---|
914 | print("Skip nmbd received signal $signame");
|
---|
915 | exit 0;
|
---|
916 | };
|
---|
917 | sleep($self->{server_maxtime});
|
---|
918 | exit 0;
|
---|
919 | }
|
---|
920 |
|
---|
921 | $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "nmbd");
|
---|
922 | my @optargs = ("-d0");
|
---|
923 | if (defined($ENV{NMBD_OPTIONS})) {
|
---|
924 | @optargs = split(/ /, $ENV{NMBD_OPTIONS});
|
---|
925 | }
|
---|
926 | my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
|
---|
927 | if(defined($ENV{NMBD_VALGRIND})) {
|
---|
928 | @preargs = split(/ /, $ENV{NMBD_VALGRIND});
|
---|
929 | }
|
---|
930 | my @args = ("-F", "--no-process-group",
|
---|
931 | "-s", $env_vars->{SERVERCONFFILE},
|
---|
932 | "-l", $env_vars->{LOGDIR});
|
---|
933 | if (not defined($ENV{NMBD_DONT_LOG_STDOUT})) {
|
---|
934 | push(@args, "--log-stdout");
|
---|
935 | }
|
---|
936 |
|
---|
937 | close($env_vars->{STDIN_PIPE});
|
---|
938 | open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
|
---|
939 |
|
---|
940 | exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
|
---|
941 | or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
|
---|
942 | }
|
---|
943 | $env_vars->{NMBD_TL_PID} = $pid;
|
---|
944 | write_pid($env_vars, "nmbd", $pid);
|
---|
945 | print "DONE\n";
|
---|
946 |
|
---|
947 | unlink($env_vars->{WINBINDD_TEST_LOG});
|
---|
948 | print "STARTING WINBINDD...";
|
---|
949 | $pid = fork();
|
---|
950 | if ($pid == 0) {
|
---|
951 | open STDOUT, ">$env_vars->{WINBINDD_TEST_LOG}";
|
---|
952 | open STDERR, '>&STDOUT';
|
---|
953 |
|
---|
954 | SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
|
---|
955 |
|
---|
956 | $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
|
---|
957 | $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
|
---|
958 | $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
|
---|
959 |
|
---|
960 | $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
|
---|
961 | $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
|
---|
962 | $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
|
---|
963 | $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
|
---|
964 | $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
|
---|
965 | $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
|
---|
966 | if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
|
---|
967 | $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
|
---|
968 | } else {
|
---|
969 | $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
|
---|
970 | }
|
---|
971 | $ENV{UID_WRAPPER_ROOT} = "1";
|
---|
972 |
|
---|
973 | $ENV{ENVNAME} = "$ENV{ENVNAME}.winbindd";
|
---|
974 |
|
---|
975 | if ($winbindd ne "yes") {
|
---|
976 | $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
|
---|
977 | my $signame = shift;
|
---|
978 | print("Skip winbindd received signal $signame");
|
---|
979 | exit 0;
|
---|
980 | };
|
---|
981 | sleep($self->{server_maxtime});
|
---|
982 | exit 0;
|
---|
983 | }
|
---|
984 |
|
---|
985 | $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "winbindd");
|
---|
986 | my @optargs = ("-d0");
|
---|
987 | if (defined($ENV{WINBINDD_OPTIONS})) {
|
---|
988 | @optargs = split(/ /, $ENV{WINBINDD_OPTIONS});
|
---|
989 | }
|
---|
990 | my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
|
---|
991 | if(defined($ENV{WINBINDD_VALGRIND})) {
|
---|
992 | @preargs = split(/ /, $ENV{WINBINDD_VALGRIND});
|
---|
993 | }
|
---|
994 | my @args = ("-F", "--no-process-group",
|
---|
995 | "-s", $env_vars->{SERVERCONFFILE},
|
---|
996 | "-l", $env_vars->{LOGDIR});
|
---|
997 | if (not defined($ENV{WINBINDD_DONT_LOG_STDOUT})) {
|
---|
998 | push(@args, "--stdout");
|
---|
999 | }
|
---|
1000 |
|
---|
1001 | close($env_vars->{STDIN_PIPE});
|
---|
1002 | open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
|
---|
1003 |
|
---|
1004 | exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
|
---|
1005 | or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
|
---|
1006 | }
|
---|
1007 | $env_vars->{WINBINDD_TL_PID} = $pid;
|
---|
1008 | write_pid($env_vars, "winbindd", $pid);
|
---|
1009 | print "DONE\n";
|
---|
1010 |
|
---|
1011 | unlink($env_vars->{SMBD_TEST_LOG});
|
---|
1012 | print "STARTING SMBD...";
|
---|
1013 | $pid = fork();
|
---|
1014 | if ($pid == 0) {
|
---|
1015 | open STDOUT, ">$env_vars->{SMBD_TEST_LOG}";
|
---|
1016 | open STDERR, '>&STDOUT';
|
---|
1017 |
|
---|
1018 | SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
|
---|
1019 |
|
---|
1020 | $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
|
---|
1021 | $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
|
---|
1022 | $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
|
---|
1023 |
|
---|
1024 | $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
|
---|
1025 | $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
|
---|
1026 | $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
|
---|
1027 | $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME};
|
---|
1028 | $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
|
---|
1029 | $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
|
---|
1030 | if (defined($env_vars->{RESOLV_WRAPPER_CONF})) {
|
---|
1031 | $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF};
|
---|
1032 | } else {
|
---|
1033 | $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS};
|
---|
1034 | }
|
---|
1035 | $ENV{UID_WRAPPER_ROOT} = "1";
|
---|
1036 |
|
---|
1037 | $ENV{ENVNAME} = "$ENV{ENVNAME}.smbd";
|
---|
1038 |
|
---|
1039 | if ($smbd ne "yes") {
|
---|
1040 | $SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
|
---|
1041 | my $signame = shift;
|
---|
1042 | print("Skip smbd received signal $signame");
|
---|
1043 | exit 0;
|
---|
1044 | };
|
---|
1045 | sleep($self->{server_maxtime});
|
---|
1046 | exit 0;
|
---|
1047 | }
|
---|
1048 |
|
---|
1049 | $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "smbd");
|
---|
1050 | my @optargs = ("-d0");
|
---|
1051 | if (defined($ENV{SMBD_OPTIONS})) {
|
---|
1052 | @optargs = split(/ /, $ENV{SMBD_OPTIONS});
|
---|
1053 | }
|
---|
1054 | my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
|
---|
1055 | if(defined($ENV{SMBD_VALGRIND})) {
|
---|
1056 | @preargs = split(/ /,$ENV{SMBD_VALGRIND});
|
---|
1057 | }
|
---|
1058 | my @args = ("-F", "--no-process-group",
|
---|
1059 | "-s", $env_vars->{SERVERCONFFILE},
|
---|
1060 | "-l", $env_vars->{LOGDIR});
|
---|
1061 | if (not defined($ENV{SMBD_DONT_LOG_STDOUT})) {
|
---|
1062 | push(@args, "--log-stdout");
|
---|
1063 | }
|
---|
1064 |
|
---|
1065 | close($env_vars->{STDIN_PIPE});
|
---|
1066 | open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
|
---|
1067 |
|
---|
1068 | exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs)
|
---|
1069 | or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!");
|
---|
1070 | }
|
---|
1071 | $env_vars->{SMBD_TL_PID} = $pid;
|
---|
1072 | write_pid($env_vars, "smbd", $pid);
|
---|
1073 | print "DONE\n";
|
---|
1074 |
|
---|
1075 | close(STDIN_READER);
|
---|
1076 |
|
---|
1077 | return $self->wait_for_start($env_vars, $nmbd, $winbindd, $smbd);
|
---|
1078 | }
|
---|
1079 |
|
---|
1080 | sub createuser($$$$)
|
---|
1081 | {
|
---|
1082 | my ($self, $username, $password, $conffile) = @_;
|
---|
1083 | my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $username > /dev/null";
|
---|
1084 | unless (open(PWD, "|$cmd")) {
|
---|
1085 | warn("Unable to set password for $username account\n$cmd");
|
---|
1086 | return undef;
|
---|
1087 | }
|
---|
1088 | print PWD "$password\n$password\n";
|
---|
1089 | unless (close(PWD)) {
|
---|
1090 | warn("Unable to set password for $username account\n$cmd");
|
---|
1091 | return undef;
|
---|
1092 | }
|
---|
1093 | }
|
---|
1094 |
|
---|
1095 | sub provision($$$$$$$$)
|
---|
1096 | {
|
---|
1097 | my ($self, $prefix, $server, $password, $extra_options, $dc_server_ip, $dc_server_ipv6, $no_delete_prefix) = @_;
|
---|
1098 |
|
---|
1099 | ##
|
---|
1100 | ## setup the various environment variables we need
|
---|
1101 | ##
|
---|
1102 |
|
---|
1103 | my $swiface = Samba::get_interface($server);
|
---|
1104 | my %ret = ();
|
---|
1105 | my $server_ip = "127.0.0.$swiface";
|
---|
1106 | my $server_ipv6 = sprintf("fd00:0000:0000:0000:0000:0000:5357:5f%02x", $swiface);
|
---|
1107 | my $domain = "SAMBA-TEST";
|
---|
1108 |
|
---|
1109 | my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`);
|
---|
1110 | chomp $unix_name;
|
---|
1111 | my $unix_uid = $>;
|
---|
1112 | my $unix_gids_str = $);
|
---|
1113 | my @unix_gids = split(" ", $unix_gids_str);
|
---|
1114 |
|
---|
1115 | my $prefix_abs = abs_path($prefix);
|
---|
1116 | my $bindir_abs = abs_path($self->{bindir});
|
---|
1117 |
|
---|
1118 | my @dirs = ();
|
---|
1119 |
|
---|
1120 | my $shrdir="$prefix_abs/share";
|
---|
1121 | push(@dirs,$shrdir);
|
---|
1122 |
|
---|
1123 | my $libdir="$prefix_abs/lib";
|
---|
1124 | push(@dirs,$libdir);
|
---|
1125 |
|
---|
1126 | my $piddir="$prefix_abs/pid";
|
---|
1127 | push(@dirs,$piddir);
|
---|
1128 |
|
---|
1129 | my $privatedir="$prefix_abs/private";
|
---|
1130 | push(@dirs,$privatedir);
|
---|
1131 |
|
---|
1132 | my $lockdir="$prefix_abs/lockdir";
|
---|
1133 | push(@dirs,$lockdir);
|
---|
1134 |
|
---|
1135 | my $eventlogdir="$prefix_abs/lockdir/eventlog";
|
---|
1136 | push(@dirs,$eventlogdir);
|
---|
1137 |
|
---|
1138 | my $logdir="$prefix_abs/logs";
|
---|
1139 | push(@dirs,$logdir);
|
---|
1140 |
|
---|
1141 | my $driver32dir="$shrdir/W32X86";
|
---|
1142 | push(@dirs,$driver32dir);
|
---|
1143 |
|
---|
1144 | my $driver64dir="$shrdir/x64";
|
---|
1145 | push(@dirs,$driver64dir);
|
---|
1146 |
|
---|
1147 | my $driver40dir="$shrdir/WIN40";
|
---|
1148 | push(@dirs,$driver40dir);
|
---|
1149 |
|
---|
1150 | my $ro_shrdir="$shrdir/root-tmp";
|
---|
1151 | push(@dirs,$ro_shrdir);
|
---|
1152 |
|
---|
1153 | my $msdfs_shrdir="$shrdir/msdfsshare";
|
---|
1154 | push(@dirs,$msdfs_shrdir);
|
---|
1155 |
|
---|
1156 | my $msdfs_deeppath="$msdfs_shrdir/deeppath";
|
---|
1157 | push(@dirs,$msdfs_deeppath);
|
---|
1158 |
|
---|
1159 | my $badnames_shrdir="$shrdir/badnames";
|
---|
1160 | push(@dirs,$badnames_shrdir);
|
---|
1161 |
|
---|
1162 | my $lease1_shrdir="$shrdir/SMB2_10";
|
---|
1163 | push(@dirs,$lease1_shrdir);
|
---|
1164 |
|
---|
1165 | my $lease2_shrdir="$shrdir/SMB3_00";
|
---|
1166 | push(@dirs,$lease2_shrdir);
|
---|
1167 |
|
---|
1168 | my $manglenames_shrdir="$shrdir/manglenames";
|
---|
1169 | push(@dirs,$manglenames_shrdir);
|
---|
1170 |
|
---|
1171 | my $widelinks_shrdir="$shrdir/widelinks";
|
---|
1172 | push(@dirs,$widelinks_shrdir);
|
---|
1173 |
|
---|
1174 | my $widelinks_linkdir="$shrdir/widelinks_foo";
|
---|
1175 | push(@dirs,$widelinks_linkdir);
|
---|
1176 |
|
---|
1177 | my $shadow_tstdir="$shrdir/shadow";
|
---|
1178 | push(@dirs,$shadow_tstdir);
|
---|
1179 | my $shadow_mntdir="$shadow_tstdir/mount";
|
---|
1180 | push(@dirs,$shadow_mntdir);
|
---|
1181 | my $shadow_basedir="$shadow_mntdir/base";
|
---|
1182 | push(@dirs,$shadow_basedir);
|
---|
1183 | my $shadow_shrdir="$shadow_basedir/share";
|
---|
1184 | push(@dirs,$shadow_shrdir);
|
---|
1185 |
|
---|
1186 | # this gets autocreated by winbindd
|
---|
1187 | my $wbsockdir="$prefix_abs/winbindd";
|
---|
1188 | my $wbsockprivdir="$lockdir/winbindd_privileged";
|
---|
1189 |
|
---|
1190 | my $nmbdsockdir="$prefix_abs/nmbd";
|
---|
1191 | unlink($nmbdsockdir);
|
---|
1192 |
|
---|
1193 | ##
|
---|
1194 | ## create the test directory layout
|
---|
1195 | ##
|
---|
1196 | die ("prefix_abs = ''") if $prefix_abs eq "";
|
---|
1197 | die ("prefix_abs = '/'") if $prefix_abs eq "/";
|
---|
1198 |
|
---|
1199 | mkdir($prefix_abs, 0777);
|
---|
1200 | print "CREATE TEST ENVIRONMENT IN '$prefix'...";
|
---|
1201 | if (not defined($no_delete_prefix) or not $no_delete_prefix) {
|
---|
1202 | system("rm -rf $prefix_abs/*");
|
---|
1203 | }
|
---|
1204 | mkdir($_, 0777) foreach(@dirs);
|
---|
1205 |
|
---|
1206 | my $fs_specific_conf = $self->get_fs_specific_conf($shrdir);
|
---|
1207 |
|
---|
1208 | ##
|
---|
1209 | ## lockdir and piddir must be 0755
|
---|
1210 | ##
|
---|
1211 | chmod 0755, $lockdir;
|
---|
1212 | chmod 0755, $piddir;
|
---|
1213 |
|
---|
1214 |
|
---|
1215 | ##
|
---|
1216 | ## create ro and msdfs share layout
|
---|
1217 | ##
|
---|
1218 |
|
---|
1219 | chmod 0755, $ro_shrdir;
|
---|
1220 | my $unreadable_file = "$ro_shrdir/unreadable_file";
|
---|
1221 | unless (open(UNREADABLE_FILE, ">$unreadable_file")) {
|
---|
1222 | warn("Unable to open $unreadable_file");
|
---|
1223 | return undef;
|
---|
1224 | }
|
---|
1225 | close(UNREADABLE_FILE);
|
---|
1226 | chmod 0600, $unreadable_file;
|
---|
1227 |
|
---|
1228 | my $msdfs_target = "$ro_shrdir/msdfs-target";
|
---|
1229 | unless (open(MSDFS_TARGET, ">$msdfs_target")) {
|
---|
1230 | warn("Unable to open $msdfs_target");
|
---|
1231 | return undef;
|
---|
1232 | }
|
---|
1233 | close(MSDFS_TARGET);
|
---|
1234 | chmod 0666, $msdfs_target;
|
---|
1235 | symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp",
|
---|
1236 | "$msdfs_shrdir/msdfs-src1";
|
---|
1237 | symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2";
|
---|
1238 |
|
---|
1239 | ##
|
---|
1240 | ## create bad names in $badnames_shrdir
|
---|
1241 | ##
|
---|
1242 | ## (An invalid name, would be mangled to 8.3).
|
---|
1243 | my $badname_target = "$badnames_shrdir/\340|\231\216\377\177";
|
---|
1244 | unless (open(BADNAME_TARGET, ">$badname_target")) {
|
---|
1245 | warn("Unable to open $badname_target");
|
---|
1246 | return undef;
|
---|
1247 | }
|
---|
1248 | close(BADNAME_TARGET);
|
---|
1249 | chmod 0666, $badname_target;
|
---|
1250 |
|
---|
1251 | ## (A bad name, would not be mangled to 8.3).
|
---|
1252 | my $badname_target = "$badnames_shrdir/\240\276\346\327\377\177";
|
---|
1253 | unless (open(BADNAME_TARGET, ">$badname_target")) {
|
---|
1254 | warn("Unable to open $badname_target");
|
---|
1255 | return undef;
|
---|
1256 | }
|
---|
1257 | close(BADNAME_TARGET);
|
---|
1258 | chmod 0666, $badname_target;
|
---|
1259 |
|
---|
1260 | ## (A bad good name).
|
---|
1261 | my $badname_target = "$badnames_shrdir/blank.txt";
|
---|
1262 | unless (open(BADNAME_TARGET, ">$badname_target")) {
|
---|
1263 | warn("Unable to open $badname_target");
|
---|
1264 | return undef;
|
---|
1265 | }
|
---|
1266 | close(BADNAME_TARGET);
|
---|
1267 | chmod 0666, $badname_target;
|
---|
1268 |
|
---|
1269 | ##
|
---|
1270 | ## create mangleable directory names in $manglenames_shrdir
|
---|
1271 | ##
|
---|
1272 | my $manglename_target = "$manglenames_shrdir/foo:bar";
|
---|
1273 | mkdir($manglename_target, 0777);
|
---|
1274 |
|
---|
1275 | ##
|
---|
1276 | ## create symlinks for widelinks tests.
|
---|
1277 | ##
|
---|
1278 | my $widelinks_target = "$widelinks_linkdir/target";
|
---|
1279 | unless (open(WIDELINKS_TARGET, ">$widelinks_target")) {
|
---|
1280 | warn("Unable to open $widelinks_target");
|
---|
1281 | return undef;
|
---|
1282 | }
|
---|
1283 | close(WIDELINKS_TARGET);
|
---|
1284 | chmod 0666, $widelinks_target;
|
---|
1285 | ##
|
---|
1286 | ## This link should get ACCESS_DENIED
|
---|
1287 | ##
|
---|
1288 | symlink "$widelinks_target", "$widelinks_shrdir/source";
|
---|
1289 | ##
|
---|
1290 | ## This link should be allowed
|
---|
1291 | ##
|
---|
1292 | symlink "$widelinks_shrdir", "$widelinks_shrdir/dot";
|
---|
1293 |
|
---|
1294 | my $conffile="$libdir/server.conf";
|
---|
1295 | my $dfqconffile="$libdir/dfq.conf";
|
---|
1296 |
|
---|
1297 | my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/lib/nss_wrapper/nss_wrapper.pl";
|
---|
1298 | my $nss_wrapper_passwd = "$privatedir/passwd";
|
---|
1299 | my $nss_wrapper_group = "$privatedir/group";
|
---|
1300 | my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts";
|
---|
1301 | my $resolv_conf = "$privatedir/resolv.conf";
|
---|
1302 | my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file";
|
---|
1303 |
|
---|
1304 | my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl";
|
---|
1305 |
|
---|
1306 | my $fake_snap_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/fake_snap.pl";
|
---|
1307 |
|
---|
1308 | my @eventlog_list = ("dns server", "application");
|
---|
1309 |
|
---|
1310 | ##
|
---|
1311 | ## calculate uids and gids
|
---|
1312 | ##
|
---|
1313 |
|
---|
1314 | my ($max_uid, $max_gid);
|
---|
1315 | my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
|
---|
1316 | my ($uid_pdbtest_wkn);
|
---|
1317 | my ($uid_smbget);
|
---|
1318 | my ($uid_force_user);
|
---|
1319 | my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
|
---|
1320 | my ($gid_userdup, $gid_everyone);
|
---|
1321 | my ($gid_force_user);
|
---|
1322 | my ($uid_user1);
|
---|
1323 | my ($uid_user2);
|
---|
1324 |
|
---|
1325 | if ($unix_uid < 0xffff - 10) {
|
---|
1326 | $max_uid = 0xffff;
|
---|
1327 | } else {
|
---|
1328 | $max_uid = $unix_uid;
|
---|
1329 | }
|
---|
1330 |
|
---|
1331 | $uid_root = $max_uid - 1;
|
---|
1332 | $uid_nobody = $max_uid - 2;
|
---|
1333 | $uid_pdbtest = $max_uid - 3;
|
---|
1334 | $uid_pdbtest2 = $max_uid - 4;
|
---|
1335 | $uid_userdup = $max_uid - 5;
|
---|
1336 | $uid_pdbtest_wkn = $max_uid - 6;
|
---|
1337 | $uid_force_user = $max_uid - 7;
|
---|
1338 | $uid_smbget = $max_uid - 8;
|
---|
1339 | $uid_user1 = $max_uid - 9;
|
---|
1340 | $uid_user2 = $max_uid - 10;
|
---|
1341 |
|
---|
1342 | if ($unix_gids[0] < 0xffff - 8) {
|
---|
1343 | $max_gid = 0xffff;
|
---|
1344 | } else {
|
---|
1345 | $max_gid = $unix_gids[0];
|
---|
1346 | }
|
---|
1347 |
|
---|
1348 | $gid_nobody = $max_gid - 1;
|
---|
1349 | $gid_nogroup = $max_gid - 2;
|
---|
1350 | $gid_root = $max_gid - 3;
|
---|
1351 | $gid_domusers = $max_gid - 4;
|
---|
1352 | $gid_domadmins = $max_gid - 5;
|
---|
1353 | $gid_userdup = $max_gid - 6;
|
---|
1354 | $gid_everyone = $max_gid - 7;
|
---|
1355 | $gid_force_user = $max_gid - 8;
|
---|
1356 |
|
---|
1357 | ##
|
---|
1358 | ## create conffile
|
---|
1359 | ##
|
---|
1360 |
|
---|
1361 | unless (open(CONF, ">$conffile")) {
|
---|
1362 | warn("Unable to open $conffile");
|
---|
1363 | return undef;
|
---|
1364 | }
|
---|
1365 | print CONF "
|
---|
1366 | [global]
|
---|
1367 | netbios name = $server
|
---|
1368 | interfaces = $server_ip/8 $server_ipv6/64
|
---|
1369 | bind interfaces only = yes
|
---|
1370 | panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY)
|
---|
1371 | smbd:suicide mode = yes
|
---|
1372 |
|
---|
1373 | workgroup = $domain
|
---|
1374 |
|
---|
1375 | private dir = $privatedir
|
---|
1376 | pid directory = $piddir
|
---|
1377 | lock directory = $lockdir
|
---|
1378 | log file = $logdir/log.\%m
|
---|
1379 | log level = 1
|
---|
1380 | debug pid = yes
|
---|
1381 | max log size = 0
|
---|
1382 |
|
---|
1383 | state directory = $lockdir
|
---|
1384 | cache directory = $lockdir
|
---|
1385 |
|
---|
1386 | passdb backend = tdbsam
|
---|
1387 |
|
---|
1388 | time server = yes
|
---|
1389 |
|
---|
1390 | add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
|
---|
1391 | add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g
|
---|
1392 | add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup
|
---|
1393 | 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
|
---|
1394 | delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u
|
---|
1395 | delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g
|
---|
1396 | 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
|
---|
1397 |
|
---|
1398 | addprinter command = $mod_printer_pl -a -s $conffile --
|
---|
1399 | deleteprinter command = $mod_printer_pl -d -s $conffile --
|
---|
1400 |
|
---|
1401 | eventlog list = application \"dns server\"
|
---|
1402 |
|
---|
1403 | kernel oplocks = no
|
---|
1404 | kernel change notify = no
|
---|
1405 | smb2 leases = yes
|
---|
1406 |
|
---|
1407 | logging = file
|
---|
1408 | printing = bsd
|
---|
1409 | printcap name = /dev/null
|
---|
1410 |
|
---|
1411 | winbindd socket directory = $wbsockdir
|
---|
1412 | nmbd:socket dir = $nmbdsockdir
|
---|
1413 | idmap config * : range = 100000-200000
|
---|
1414 | winbind enum users = yes
|
---|
1415 | winbind enum groups = yes
|
---|
1416 | winbind separator = /
|
---|
1417 |
|
---|
1418 | # min receivefile size = 4000
|
---|
1419 |
|
---|
1420 | read only = no
|
---|
1421 | server signing = auto
|
---|
1422 |
|
---|
1423 | smbd:sharedelay = 100000
|
---|
1424 | smbd:writetimeupdatedelay = 500000
|
---|
1425 | map hidden = no
|
---|
1426 | map system = no
|
---|
1427 | map readonly = no
|
---|
1428 | store dos attributes = yes
|
---|
1429 | create mask = 755
|
---|
1430 | dos filemode = yes
|
---|
1431 | strict rename = yes
|
---|
1432 | strict sync = yes
|
---|
1433 | vfs objects = acl_xattr fake_acls xattr_tdb streams_depot
|
---|
1434 |
|
---|
1435 | printing = vlp
|
---|
1436 | print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
|
---|
1437 | lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
|
---|
1438 | lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
|
---|
1439 | lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
|
---|
1440 | lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
|
---|
1441 | queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
|
---|
1442 | queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
|
---|
1443 | lpq cache time = 0
|
---|
1444 | print notify backchannel = yes
|
---|
1445 |
|
---|
1446 | ncalrpc dir = $prefix_abs/ncalrpc
|
---|
1447 |
|
---|
1448 | # The samba3.blackbox.smbclient_s3 test uses this to test that
|
---|
1449 | # sending messages works, and that the %m sub works.
|
---|
1450 | message command = mv %s $shrdir/message.%m
|
---|
1451 |
|
---|
1452 | # fsrvp server requires registry shares
|
---|
1453 | registry shares = yes
|
---|
1454 |
|
---|
1455 | # Used by RPC SRVSVC tests
|
---|
1456 | add share command = $bindir_abs/smbaddshare
|
---|
1457 | change share command = $bindir_abs/smbchangeshare
|
---|
1458 | delete share command = $bindir_abs/smbdeleteshare
|
---|
1459 |
|
---|
1460 | # fruit:copyfile is a global option
|
---|
1461 | fruit:copyfile = yes
|
---|
1462 |
|
---|
1463 | #this does not mean that we use non-secure test env,
|
---|
1464 | #it just means we ALLOW one to be configured.
|
---|
1465 | allow insecure wide links = yes
|
---|
1466 |
|
---|
1467 | # Begin extra options
|
---|
1468 | $extra_options
|
---|
1469 | # End extra options
|
---|
1470 |
|
---|
1471 | #Include user defined custom parameters if set
|
---|
1472 | ";
|
---|
1473 |
|
---|
1474 | if (defined($ENV{INCLUDE_CUSTOM_CONF})) {
|
---|
1475 | print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n";
|
---|
1476 | }
|
---|
1477 |
|
---|
1478 | print CONF "
|
---|
1479 | [tmp]
|
---|
1480 | path = $shrdir
|
---|
1481 | comment = smb username is [%U]
|
---|
1482 | [tmpsort]
|
---|
1483 | path = $shrdir
|
---|
1484 | comment = Load dirsort module
|
---|
1485 | vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot
|
---|
1486 | [tmpenc]
|
---|
1487 | path = $shrdir
|
---|
1488 | comment = encrypt smb username is [%U]
|
---|
1489 | smb encrypt = required
|
---|
1490 | vfs objects = dirsort
|
---|
1491 | [tmpguest]
|
---|
1492 | path = $shrdir
|
---|
1493 | guest ok = yes
|
---|
1494 | [guestonly]
|
---|
1495 | path = $shrdir
|
---|
1496 | guest only = yes
|
---|
1497 | guest ok = yes
|
---|
1498 | [forceuser]
|
---|
1499 | path = $shrdir
|
---|
1500 | force user = $unix_name
|
---|
1501 | guest ok = yes
|
---|
1502 | [forceuser_unixonly]
|
---|
1503 | comment = force a user with unix user SID and group SID
|
---|
1504 | path = $shrdir
|
---|
1505 | force user = pdbtest
|
---|
1506 | guest ok = yes
|
---|
1507 | [forceuser_wkngroup]
|
---|
1508 | comment = force a user with well-known group SID
|
---|
1509 | path = $shrdir
|
---|
1510 | force user = pdbtest_wkn
|
---|
1511 | guest ok = yes
|
---|
1512 | [forcegroup]
|
---|
1513 | path = $shrdir
|
---|
1514 | force group = nogroup
|
---|
1515 | guest ok = yes
|
---|
1516 | [ro-tmp]
|
---|
1517 | path = $ro_shrdir
|
---|
1518 | guest ok = yes
|
---|
1519 | [write-list-tmp]
|
---|
1520 | path = $shrdir
|
---|
1521 | read only = yes
|
---|
1522 | write list = $unix_name
|
---|
1523 | [valid-users-tmp]
|
---|
1524 | path = $shrdir
|
---|
1525 | valid users = $unix_name
|
---|
1526 | [msdfs-share]
|
---|
1527 | path = $msdfs_shrdir
|
---|
1528 | msdfs root = yes
|
---|
1529 | msdfs shuffle referrals = yes
|
---|
1530 | guest ok = yes
|
---|
1531 | [hideunread]
|
---|
1532 | copy = tmp
|
---|
1533 | hide unreadable = yes
|
---|
1534 | [tmpcase]
|
---|
1535 | copy = tmp
|
---|
1536 | case sensitive = yes
|
---|
1537 | [hideunwrite]
|
---|
1538 | copy = tmp
|
---|
1539 | hide unwriteable files = yes
|
---|
1540 | [durable]
|
---|
1541 | copy = tmp
|
---|
1542 | kernel share modes = no
|
---|
1543 | kernel oplocks = no
|
---|
1544 | posix locking = no
|
---|
1545 | [fs_specific]
|
---|
1546 | copy = tmp
|
---|
1547 | $fs_specific_conf
|
---|
1548 | [print1]
|
---|
1549 | copy = tmp
|
---|
1550 | printable = yes
|
---|
1551 |
|
---|
1552 | [print2]
|
---|
1553 | copy = print1
|
---|
1554 | [print3]
|
---|
1555 | copy = print1
|
---|
1556 | default devmode = no
|
---|
1557 | [lp]
|
---|
1558 | copy = print1
|
---|
1559 |
|
---|
1560 | [nfs4acl_simple]
|
---|
1561 | path = $shrdir
|
---|
1562 | comment = smb username is [%U]
|
---|
1563 | nfs4:mode = simple
|
---|
1564 | vfs objects = nfs4acl_xattr xattr_tdb
|
---|
1565 |
|
---|
1566 | [nfs4acl_special]
|
---|
1567 | path = $shrdir
|
---|
1568 | comment = smb username is [%U]
|
---|
1569 | nfs4:mode = special
|
---|
1570 | vfs objects = nfs4acl_xattr xattr_tdb
|
---|
1571 |
|
---|
1572 | [xcopy_share]
|
---|
1573 | path = $shrdir
|
---|
1574 | comment = smb username is [%U]
|
---|
1575 | create mask = 777
|
---|
1576 | force create mode = 777
|
---|
1577 | [posix_share]
|
---|
1578 | path = $shrdir
|
---|
1579 | comment = smb username is [%U]
|
---|
1580 | create mask = 0777
|
---|
1581 | force create mode = 0
|
---|
1582 | directory mask = 0777
|
---|
1583 | force directory mode = 0
|
---|
1584 | vfs objects = xattr_tdb
|
---|
1585 | [aio]
|
---|
1586 | copy = tmp
|
---|
1587 | aio read size = 1
|
---|
1588 | aio write size = 1
|
---|
1589 |
|
---|
1590 | [print\$]
|
---|
1591 | copy = tmp
|
---|
1592 |
|
---|
1593 | [vfs_fruit]
|
---|
1594 | path = $shrdir
|
---|
1595 | vfs objects = catia fruit streams_xattr acl_xattr
|
---|
1596 | ea support = yes
|
---|
1597 | fruit:ressource = file
|
---|
1598 | fruit:metadata = netatalk
|
---|
1599 | fruit:locking = netatalk
|
---|
1600 | fruit:encoding = native
|
---|
1601 |
|
---|
1602 | [badname-tmp]
|
---|
1603 | path = $badnames_shrdir
|
---|
1604 | guest ok = yes
|
---|
1605 |
|
---|
1606 | [manglenames_share]
|
---|
1607 | path = $manglenames_shrdir
|
---|
1608 | guest ok = yes
|
---|
1609 |
|
---|
1610 | [dynamic_share]
|
---|
1611 | path = $shrdir/%R
|
---|
1612 | guest ok = yes
|
---|
1613 |
|
---|
1614 | [widelinks_share]
|
---|
1615 | path = $widelinks_shrdir
|
---|
1616 | wide links = no
|
---|
1617 | guest ok = yes
|
---|
1618 |
|
---|
1619 | [fsrvp_share]
|
---|
1620 | path = $shrdir
|
---|
1621 | comment = fake shapshots using rsync
|
---|
1622 | vfs objects = shell_snap shadow_copy2
|
---|
1623 | shell_snap:check path command = $fake_snap_pl --check
|
---|
1624 | shell_snap:create command = $fake_snap_pl --create
|
---|
1625 | shell_snap:delete command = $fake_snap_pl --delete
|
---|
1626 | # a relative path here fails, the snapshot dir is no longer found
|
---|
1627 | shadow:snapdir = $shrdir/.snapshots
|
---|
1628 |
|
---|
1629 | [shadow1]
|
---|
1630 | path = $shadow_shrdir
|
---|
1631 | comment = previous versions snapshots under mount point
|
---|
1632 | vfs objects = shadow_copy2
|
---|
1633 | shadow:mountpoint = $shadow_mntdir
|
---|
1634 |
|
---|
1635 | [shadow2]
|
---|
1636 | path = $shadow_shrdir
|
---|
1637 | comment = previous versions snapshots outside mount point
|
---|
1638 | vfs objects = shadow_copy2
|
---|
1639 | shadow:mountpoint = $shadow_mntdir
|
---|
1640 | shadow:snapdir = $shadow_tstdir/.snapshots
|
---|
1641 |
|
---|
1642 | [shadow3]
|
---|
1643 | path = $shadow_shrdir
|
---|
1644 | comment = previous versions with subvolume snapshots, snapshots under base dir
|
---|
1645 | vfs objects = shadow_copy2
|
---|
1646 | shadow:mountpoint = $shadow_mntdir
|
---|
1647 | shadow:basedir = $shadow_basedir
|
---|
1648 | shadow:snapdir = $shadow_basedir/.snapshots
|
---|
1649 |
|
---|
1650 | [shadow4]
|
---|
1651 | path = $shadow_shrdir
|
---|
1652 | comment = previous versions with subvolume snapshots, snapshots outside mount point
|
---|
1653 | vfs objects = shadow_copy2
|
---|
1654 | shadow:mountpoint = $shadow_mntdir
|
---|
1655 | shadow:basedir = $shadow_basedir
|
---|
1656 | shadow:snapdir = $shadow_tstdir/.snapshots
|
---|
1657 |
|
---|
1658 | [shadow5]
|
---|
1659 | path = $shadow_shrdir
|
---|
1660 | comment = previous versions at volume root snapshots under mount point
|
---|
1661 | vfs objects = shadow_copy2
|
---|
1662 | shadow:mountpoint = $shadow_shrdir
|
---|
1663 |
|
---|
1664 | [shadow6]
|
---|
1665 | path = $shadow_shrdir
|
---|
1666 | comment = previous versions at volume root snapshots outside mount point
|
---|
1667 | vfs objects = shadow_copy2
|
---|
1668 | shadow:mountpoint = $shadow_shrdir
|
---|
1669 | shadow:snapdir = $shadow_tstdir/.snapshots
|
---|
1670 |
|
---|
1671 | [shadow7]
|
---|
1672 | path = $shadow_shrdir
|
---|
1673 | comment = previous versions snapshots everywhere
|
---|
1674 | vfs objects = shadow_copy2
|
---|
1675 | shadow:mountpoint = $shadow_mntdir
|
---|
1676 | shadow:snapdirseverywhere = yes
|
---|
1677 |
|
---|
1678 | [shadow8]
|
---|
1679 | path = $shadow_shrdir
|
---|
1680 | comment = previous versions using snapsharepath
|
---|
1681 | vfs objects = shadow_copy2
|
---|
1682 | shadow:mountpoint = $shadow_mntdir
|
---|
1683 | shadow:snapdir = $shadow_tstdir/.snapshots
|
---|
1684 | shadow:snapsharepath = share
|
---|
1685 |
|
---|
1686 | [shadow_wl]
|
---|
1687 | path = $shadow_shrdir
|
---|
1688 | comment = previous versions with wide links allowed
|
---|
1689 | vfs objects = shadow_copy2
|
---|
1690 | shadow:mountpoint = $shadow_mntdir
|
---|
1691 | wide links = yes
|
---|
1692 | [dfq]
|
---|
1693 | path = $shrdir/dfree
|
---|
1694 | vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
|
---|
1695 | admin users = $unix_name
|
---|
1696 | include = $dfqconffile
|
---|
1697 | [dfq_owner]
|
---|
1698 | path = $shrdir/dfree
|
---|
1699 | vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
|
---|
1700 | inherit owner = yes
|
---|
1701 | include = $dfqconffile
|
---|
1702 |
|
---|
1703 | [acl_xattr_ign_sysacl_posix]
|
---|
1704 | copy = tmp
|
---|
1705 | acl_xattr:ignore system acls = yes
|
---|
1706 | acl_xattr:default acl style = posix
|
---|
1707 | [acl_xattr_ign_sysacl_windows]
|
---|
1708 | copy = tmp
|
---|
1709 | acl_xattr:ignore system acls = yes
|
---|
1710 | acl_xattr:default acl style = windows
|
---|
1711 | ";
|
---|
1712 | close(CONF);
|
---|
1713 |
|
---|
1714 | unless (open(DFQCONF, ">$dfqconffile")) {
|
---|
1715 | warn("Unable to open $dfqconffile");
|
---|
1716 | return undef;
|
---|
1717 | }
|
---|
1718 | close(DFQCONF);
|
---|
1719 |
|
---|
1720 | ##
|
---|
1721 | ## create a test account
|
---|
1722 | ##
|
---|
1723 |
|
---|
1724 | unless (open(PASSWD, ">$nss_wrapper_passwd")) {
|
---|
1725 | warn("Unable to open $nss_wrapper_passwd");
|
---|
1726 | return undef;
|
---|
1727 | }
|
---|
1728 | print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
|
---|
1729 | $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
|
---|
1730 | pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
|
---|
1731 | pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
|
---|
1732 | userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
|
---|
1733 | pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false
|
---|
1734 | force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false
|
---|
1735 | smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false
|
---|
1736 | user1:x:$uid_user1:$gid_nogroup:user1 gecos:$prefix_abs:/bin/false
|
---|
1737 | user2:x:$uid_user2:$gid_nogroup:user2 gecos:$prefix_abs:/bin/false
|
---|
1738 | ";
|
---|
1739 | if ($unix_uid != 0) {
|
---|
1740 | print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
|
---|
1741 | ";
|
---|
1742 | }
|
---|
1743 | close(PASSWD);
|
---|
1744 |
|
---|
1745 | unless (open(GROUP, ">$nss_wrapper_group")) {
|
---|
1746 | warn("Unable to open $nss_wrapper_group");
|
---|
1747 | return undef;
|
---|
1748 | }
|
---|
1749 | print GROUP "nobody:x:$gid_nobody:
|
---|
1750 | nogroup:x:$gid_nogroup:nobody
|
---|
1751 | $unix_name-group:x:$unix_gids[0]:
|
---|
1752 | domusers:X:$gid_domusers:
|
---|
1753 | domadmins:X:$gid_domadmins:
|
---|
1754 | userdup:x:$gid_userdup:$unix_name
|
---|
1755 | everyone:x:$gid_everyone:
|
---|
1756 | force_user:x:$gid_force_user:
|
---|
1757 | ";
|
---|
1758 | if ($unix_gids[0] != 0) {
|
---|
1759 | print GROUP "root:x:$gid_root:
|
---|
1760 | ";
|
---|
1761 | }
|
---|
1762 |
|
---|
1763 | close(GROUP);
|
---|
1764 |
|
---|
1765 | ## hosts
|
---|
1766 | my $hostname = lc($server);
|
---|
1767 | unless (open(HOSTS, ">>$nss_wrapper_hosts")) {
|
---|
1768 | warn("Unable to open $nss_wrapper_hosts");
|
---|
1769 | return undef;
|
---|
1770 | }
|
---|
1771 | print HOSTS "${server_ip} ${hostname}.samba.example.com ${hostname}\n";
|
---|
1772 | print HOSTS "${server_ipv6} ${hostname}.samba.example.com ${hostname}\n";
|
---|
1773 | close(HOSTS);
|
---|
1774 |
|
---|
1775 | ## hosts
|
---|
1776 | unless (open(RESOLV_CONF, ">$resolv_conf")) {
|
---|
1777 | warn("Unable to open $resolv_conf");
|
---|
1778 | return undef;
|
---|
1779 | }
|
---|
1780 | if (defined($dc_server_ip) or defined($dc_server_ipv6)) {
|
---|
1781 | if (defined($dc_server_ip)) {
|
---|
1782 | print RESOLV_CONF "nameserver $dc_server_ip\n";
|
---|
1783 | }
|
---|
1784 | if (defined($dc_server_ipv6)) {
|
---|
1785 | print RESOLV_CONF "nameserver $dc_server_ipv6\n";
|
---|
1786 | }
|
---|
1787 | } else {
|
---|
1788 | print RESOLV_CONF "nameserver ${server_ip}\n";
|
---|
1789 | print RESOLV_CONF "nameserver ${server_ipv6}\n";
|
---|
1790 | }
|
---|
1791 | close(RESOLV_CONF);
|
---|
1792 |
|
---|
1793 | foreach my $evlog (@eventlog_list) {
|
---|
1794 | my $evlogtdb = "$eventlogdir/$evlog.tdb";
|
---|
1795 | open(EVENTLOG, ">$evlogtdb") or die("Unable to open $evlogtdb");
|
---|
1796 | close(EVENTLOG);
|
---|
1797 | }
|
---|
1798 |
|
---|
1799 | $ENV{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
|
---|
1800 | $ENV{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
|
---|
1801 | $ENV{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
|
---|
1802 | $ENV{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
|
---|
1803 | if ($ENV{SAMBA_DNS_FAKING}) {
|
---|
1804 | $ENV{RESOLV_WRAPPER_CONF} = $resolv_conf;
|
---|
1805 | } else {
|
---|
1806 | $ENV{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
|
---|
1807 | }
|
---|
1808 |
|
---|
1809 | createuser($self, $unix_name, $password, $conffile) || die("Unable to create user");
|
---|
1810 | createuser($self, "force_user", $password, $conffile) || die("Unable to create force_user");
|
---|
1811 | createuser($self, "smbget_user", $password, $conffile) || die("Unable to create smbget_user");
|
---|
1812 | createuser($self, "user1", $password, $conffile) || die("Unable to create user1");
|
---|
1813 | createuser($self, "user2", $password, $conffile) || die("Unable to create user2");
|
---|
1814 |
|
---|
1815 | open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
|
---|
1816 | print DNS_UPDATE_LIST "A $server. $server_ip\n";
|
---|
1817 | print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n";
|
---|
1818 | close(DNS_UPDATE_LIST);
|
---|
1819 |
|
---|
1820 | print "DONE\n";
|
---|
1821 |
|
---|
1822 | $ret{SERVER_IP} = $server_ip;
|
---|
1823 | $ret{SERVER_IPV6} = $server_ipv6;
|
---|
1824 | $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
|
---|
1825 | $ret{NMBD_TEST_LOG_POS} = 0;
|
---|
1826 | $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log";
|
---|
1827 | $ret{WINBINDD_TEST_LOG_POS} = 0;
|
---|
1828 | $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
|
---|
1829 | $ret{SMBD_TEST_LOG_POS} = 0;
|
---|
1830 | $ret{SERVERCONFFILE} = $conffile;
|
---|
1831 | $ret{CONFIGURATION} ="-s $conffile";
|
---|
1832 | $ret{SERVER} = $server;
|
---|
1833 | $ret{USERNAME} = $unix_name;
|
---|
1834 | $ret{USERID} = $unix_uid;
|
---|
1835 | $ret{DOMAIN} = $domain;
|
---|
1836 | $ret{NETBIOSNAME} = $server;
|
---|
1837 | $ret{PASSWORD} = $password;
|
---|
1838 | $ret{PIDDIR} = $piddir;
|
---|
1839 | $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir;
|
---|
1840 | $ret{WINBINDD_PRIV_PIPE_DIR} = $wbsockprivdir;
|
---|
1841 | $ret{NMBD_SOCKET_DIR} = $nmbdsockdir;
|
---|
1842 | $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface;
|
---|
1843 | $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
|
---|
1844 | $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
|
---|
1845 | $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts;
|
---|
1846 | $ret{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com";
|
---|
1847 | $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self);
|
---|
1848 | $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind";
|
---|
1849 | if ($ENV{SAMBA_DNS_FAKING}) {
|
---|
1850 | $ret{RESOLV_WRAPPER_HOSTS} = $dns_host_file;
|
---|
1851 | } else {
|
---|
1852 | $ret{RESOLV_WRAPPER_CONF} = $resolv_conf;
|
---|
1853 | }
|
---|
1854 | $ret{LOCAL_PATH} = "$shrdir";
|
---|
1855 | $ret{LOGDIR} = $logdir;
|
---|
1856 |
|
---|
1857 | #
|
---|
1858 | # Avoid hitting system krb5.conf -
|
---|
1859 | # An env that needs Kerberos will reset this to the real
|
---|
1860 | # value.
|
---|
1861 | #
|
---|
1862 | $ret{KRB5_CONFIG} = abs_path($prefix) . "/no_krb5.conf";
|
---|
1863 |
|
---|
1864 | return \%ret;
|
---|
1865 | }
|
---|
1866 |
|
---|
1867 | sub wait_for_start($$$$$)
|
---|
1868 | {
|
---|
1869 | my ($self, $envvars, $nmbd, $winbindd, $smbd) = @_;
|
---|
1870 | my $ret;
|
---|
1871 |
|
---|
1872 | if ($nmbd eq "yes") {
|
---|
1873 | my $count = 0;
|
---|
1874 |
|
---|
1875 | # give time for nbt server to register its names
|
---|
1876 | print "checking for nmbd\n";
|
---|
1877 |
|
---|
1878 | # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
|
---|
1879 | my $nmblookup = Samba::bindir_path($self, "nmblookup");
|
---|
1880 |
|
---|
1881 | do {
|
---|
1882 | $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}");
|
---|
1883 | if ($ret != 0) {
|
---|
1884 | sleep(1);
|
---|
1885 | } else {
|
---|
1886 | system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
|
---|
1887 | system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__");
|
---|
1888 | system("$nmblookup $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
|
---|
1889 | system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
|
---|
1890 | }
|
---|
1891 | $count++;
|
---|
1892 | } while ($ret != 0 && $count < 10);
|
---|
1893 | if ($count == 10) {
|
---|
1894 | print "NMBD not reachable after 10 retries\n";
|
---|
1895 | teardown_env($self, $envvars);
|
---|
1896 | return 0;
|
---|
1897 | }
|
---|
1898 | }
|
---|
1899 |
|
---|
1900 | if ($winbindd eq "yes") {
|
---|
1901 | print "checking for winbindd\n";
|
---|
1902 | my $count = 0;
|
---|
1903 | do {
|
---|
1904 | $ret = system("SELFTEST_WINBINDD_SOCKET_DIR=" . $envvars->{SELFTEST_WINBINDD_SOCKET_DIR} . " " . Samba::bindir_path($self, "wbinfo") . " --ping-dc");
|
---|
1905 | if ($ret != 0) {
|
---|
1906 | sleep(2);
|
---|
1907 | }
|
---|
1908 | $count++;
|
---|
1909 | } while ($ret != 0 && $count < 10);
|
---|
1910 | if ($count == 10) {
|
---|
1911 | print "WINBINDD not reachable after 20 seconds\n";
|
---|
1912 | teardown_env($self, $envvars);
|
---|
1913 | return 0;
|
---|
1914 | }
|
---|
1915 | }
|
---|
1916 |
|
---|
1917 | if ($smbd eq "yes") {
|
---|
1918 | # make sure smbd is also up set
|
---|
1919 | print "wait for smbd\n";
|
---|
1920 |
|
---|
1921 | my $count = 0;
|
---|
1922 | do {
|
---|
1923 | $ret = system(Samba::bindir_path($self, "smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139");
|
---|
1924 | if ($ret != 0) {
|
---|
1925 | sleep(2);
|
---|
1926 | }
|
---|
1927 | $count++
|
---|
1928 | } while ($ret != 0 && $count < 10);
|
---|
1929 | if ($count == 10) {
|
---|
1930 | print "SMBD failed to start up in a reasonable time (20sec)\n";
|
---|
1931 | teardown_env($self, $envvars);
|
---|
1932 | return 0;
|
---|
1933 | }
|
---|
1934 | }
|
---|
1935 |
|
---|
1936 | # Ensure we have domain users mapped.
|
---|
1937 | $ret = system(Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} groupmap add rid=513 unixgroup=domusers type=domain");
|
---|
1938 | if ($ret != 0) {
|
---|
1939 | return 1;
|
---|
1940 | }
|
---|
1941 | $ret = system(Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} groupmap add rid=512 unixgroup=domadmins type=domain");
|
---|
1942 | if ($ret != 0) {
|
---|
1943 | return 1;
|
---|
1944 | }
|
---|
1945 | $ret = system(Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin");
|
---|
1946 | if ($ret != 0) {
|
---|
1947 | return 1;
|
---|
1948 | }
|
---|
1949 |
|
---|
1950 | if ($winbindd eq "yes") {
|
---|
1951 | # note: creating builtin groups requires winbindd for the
|
---|
1952 | # unix id allocator
|
---|
1953 | $ret = system("SELFTEST_WINBINDD_SOCKET_DIR=" . $envvars->{SELFTEST_WINBINDD_SOCKET_DIR} . " " . Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} sam createbuiltingroup Users");
|
---|
1954 | if ($ret != 0) {
|
---|
1955 | print "Failed to create BUILTIN\\Users group\n";
|
---|
1956 | return 0;
|
---|
1957 | }
|
---|
1958 | my $count = 0;
|
---|
1959 | do {
|
---|
1960 | system(Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} cache flush");
|
---|
1961 | $ret = system("SELFTEST_WINBINDD_SOCKET_DIR=" . $envvars->{SELFTEST_WINBINDD_SOCKET_DIR} . " " . Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545");
|
---|
1962 | if ($ret != 0) {
|
---|
1963 | sleep(2);
|
---|
1964 | }
|
---|
1965 | $count++;
|
---|
1966 | } while ($ret != 0 && $count < 10);
|
---|
1967 | if ($count == 10) {
|
---|
1968 | print "WINBINDD not reachable after 20 seconds\n";
|
---|
1969 | teardown_env($self, $envvars);
|
---|
1970 | return 0;
|
---|
1971 | }
|
---|
1972 | }
|
---|
1973 |
|
---|
1974 | print $self->getlog_env($envvars);
|
---|
1975 |
|
---|
1976 | return 1;
|
---|
1977 | }
|
---|
1978 |
|
---|
1979 | 1;
|
---|