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.
15 my ($classname, $bindir, $ldap, $srcdir, $server_maxtime) = @_;
18 samba3
=> new Samba3
($bindir, $srcdir, $server_maxtime),
19 samba4
=> new Samba4
($bindir, $ldap, $srcdir, $server_maxtime),
27 my ($self, $envname, $path) = @_;
29 $ENV{ENVNAME
} = $envname;
31 my $env = $self->{samba4
}->setup_env($envname, $path);
32 if (defined($env) and $env ne "UNKNOWN") {
33 if (not defined($env->{target
})) {
34 $env->{target
} = $self->{samba4
};
36 } elsif (defined($env) and $env eq "UNKNOWN") {
37 $env = $self->{samba3
}->setup_env($envname, $path);
38 if (defined($env) and $env ne "UNKNOWN") {
39 if (not defined($env->{target
})) {
40 $env->{target
} = $self->{samba3
};
44 if (defined($env) and ($env eq "UNKNOWN")) {
45 warn("Samba can't provide environment '$envname'");
48 if (not defined $env) {
49 warn("failed to start up environment '$envname'");
56 my ($object, $path) = @_;
58 my $valpath = "$object->{bindir}/$path";
60 return $valpath if (-f
$valpath or -d
$valpath);
64 sub nss_wrapper_winbind_so_path
($) {
66 my $ret = $ENV{NSS_WRAPPER_WINBIND_SO_PATH
};
67 if (not defined($ret)) {
68 $ret = bindir_path
($object, "shared/libnss_wrapper_winbind.so.2");
69 $ret = abs_path
($ret);
74 sub copy_file_content
($$)
77 open(IN
, "${in}") or die("failed to open in[${in}] for reading: $!");
78 open(OUT
, ">${out}") or die("failed to open out[${out}] for writing: $!");
86 sub prepare_keyblobs
($)
90 my $cadir = "$ENV{SRCDIR_ABS}/selftest/manage-ca/CA-samba.example.com";
91 my $cacert = "$cadir/Public/CA-samba.example.com-cert.pem";
92 my $cacrl_pem = "$cadir/Public/CA-samba.example.com-crl.pem";
93 my $dcdnsname = "$ctx->{hostname}.$ctx->{dnsname}";
94 my $dcdir = "$cadir/DCs/$dcdnsname";
95 my $dccert = "$dcdir/DC-$dcdnsname-cert.pem";
96 my $dckey_private = "$dcdir/DC-$dcdnsname-private-key.pem";
97 my $adminprincipalname = "administrator\@$ctx->{dnsname}";
98 my $admindir = "$cadir/Users/$adminprincipalname";
99 my $admincert = "$admindir/USER-$adminprincipalname-cert.pem";
100 my $adminkey_private = "$admindir/USER-$adminprincipalname-private-key.pem";
101 my $pkinitprincipalname = "pkinit\@$ctx->{dnsname}";
102 my $pkinitdir = "$cadir/Users/$pkinitprincipalname";
103 my $pkinitcert = "$pkinitdir/USER-$pkinitprincipalname-cert.pem";
104 my $pkinitkey_private = "$pkinitdir/USER-$pkinitprincipalname-private-key.pem";
106 my $tlsdir = "$ctx->{tlsdir}";
107 my $pkinitdir = "$ctx->{prefix_abs}/pkinit";
108 #TLS and PKINIT crypto blobs
109 my $dhfile = "$tlsdir/dhparms.pem";
110 my $cafile = "$tlsdir/ca.pem";
111 my $crlfile = "$tlsdir/crl.pem";
112 my $certfile = "$tlsdir/cert.pem";
113 my $keyfile = "$tlsdir/key.pem";
114 my $admincertfile = "$pkinitdir/USER-$adminprincipalname-cert.pem";
115 my $adminkeyfile = "$pkinitdir/USER-$adminprincipalname-private-key.pem";
116 my $pkinitcertfile = "$pkinitdir/USER-$pkinitprincipalname-cert.pem";
117 my $pkinitkeyfile = "$pkinitdir/USER-$pkinitprincipalname-private-key.pem";
119 mkdir($tlsdir, 0700);
120 mkdir($pkinitdir, 0700);
121 my $oldumask = umask;
124 # This is specified here to avoid draining entropy on every run
126 # openssl dhparam -out dhparms.pem -text -2 8192
127 open(DHFILE
, ">$dhfile");
129 -----BEGIN DH PARAMETERS-----
130 MIIECAKCBAEAlcpjuJptCzC2bIIApLuyFLw2nODQUztqs/peysY9e3LgWh/xrc87
131 SWJNSUrqFJFh2m357WH0XGcTdTk0b/8aIYIWjbwEhWR/5hZ+1x2TDrX1awkYayAe
132 pr0arycmWHaAmhw+m+dBdj2O2jRMe7gn0ha85JALNl+Z3wv2q2eys8TIiQ2dbHPx
133 XvpMmlAv7QHZnp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8QtFR7+/0Nfoni6ydFGs5fNH/L1ckq6FEO4OhgucJw9H
150 YRmiFlsQBQNny78vNchwZne3ZixkShtGW0hWDdi2n+h7St1peNJCNJjMbEhRsPRx
151 RmNGWh4AL8rho4RO9OBao0MnUdjbbffD+wIBAg==
152 -----END DH PARAMETERS-----
156 if (! -e
${dckey_private
}) {
161 copy_file_content
(${cacert
}, ${cafile
});
162 copy_file_content
(${cacrl_pem
}, ${crlfile
});
163 copy_file_content
(${dccert
}, ${certfile
});
164 copy_file_content
(${dckey_private
}, ${keyfile
});
165 if (-e
${adminkey_private
}) {
166 copy_file_content
(${admincert
}, ${admincertfile
});
167 copy_file_content
(${adminkey_private
}, ${adminkeyfile
});
169 if (-e
${pkinitkey_private
}) {
170 copy_file_content
(${pkinitcert
}, ${pkinitcertfile
});
171 copy_file_content
(${pkinitkey_private
}, ${pkinitkeyfile
});
174 # COMPAT stuff to be removed in a later commit
175 my $kdccertfile = "$tlsdir/kdc.pem";
176 copy_file_content
(${dccert
}, ${kdccertfile
});
185 unless (open(KRB5CONF
, ">$ctx->{krb5_conf}")) {
186 warn("can't open $ctx->{krb5_conf}$?");
190 my $our_realms_stanza = mk_realms_stanza
($ctx->{realm
},
195 #Generated krb5.conf for $ctx->{realm}
198 default_realm = $ctx->{realm}
199 dns_lookup_realm = false
200 dns_lookup_kdc = true
201 ticket_lifetime = 24h
203 allow_weak_crypto = yes
207 if (defined($ctx->{krb5_ccname
})) {
209 default_ccache_name = $ctx->{krb5_ccname}
214 if (defined($ctx->{supported_enctypes
})) {
216 default_etypes = $ctx->{supported_enctypes}
217 default_as_etypes = $ctx->{supported_enctypes}
218 default_tgs_enctypes = $ctx->{supported_enctypes}
219 default_tkt_enctypes = $ctx->{supported_enctypes}
220 permitted_enctypes = $ctx->{supported_enctypes}
230 if (defined($ctx->{tlsdir
})) {
234 pkinit_anchors = FILE:$ctx->{tlsdir}/ca.pem
238 pkinit_identity = FILE:$ctx->{tlsdir}/kdc.pem,$ctx->{tlsdir}/key.pem
239 pkinit_anchors = FILE:$ctx->{tlsdir}/ca.pem
246 sub mk_realms_stanza
($$$$)
248 my ($realm, $dnsname, $domain, $kdc_ipv4) = @_;
249 my $lc_domain = lc($domain);
251 my $realms_stanza = "
254 admin_server = $kdc_ipv4:88
255 default_domain = $dnsname
259 admin_server = $kdc_ipv4:88
260 default_domain = $dnsname
264 admin_server = $kdc_ipv4:88
265 default_domain = $dnsname
269 admin_server = $kdc_ipv4:88
270 default_domain = $dnsname
274 return $realms_stanza;
279 my ($netbiosname) = @_;
280 $netbiosname = lc($netbiosname);
283 $interfaces{"localnt4dc2"} = 3;
284 $interfaces{"localnt4member3"} = 4;
285 $interfaces{"localshare4"} = 5;
287 $interfaces{"localktest6"} = 7;
288 $interfaces{"maptoguest"} = 8;
289 $interfaces{"localnt4dc9"} = 9;
291 # 11-16 used by selftest.pl for client interfaces
293 $interfaces{"localdc"} = 21;
294 $interfaces{"localvampiredc"} = 22;
295 $interfaces{"s4member"} = 23;
296 $interfaces{"localrpcproxy"} = 24;
297 $interfaces{"dc5"} = 25;
298 $interfaces{"dc6"} = 26;
299 $interfaces{"dc7"} = 27;
300 $interfaces{"rodc"} = 28;
301 $interfaces{"localadmember"} = 29;
302 $interfaces{"addc"} = 30;
303 $interfaces{"localsubdc"} = 31;
304 $interfaces{"chgdcpass"} = 32;
305 $interfaces{"promotedvdc"} = 33;
306 $interfaces{"rfc2307member"} = 34;
307 $interfaces{"fileserver"} = 35;
308 $interfaces{"fakednsforwarder1"} = 36;
309 $interfaces{"fakednsforwarder2"} = 37;
310 $interfaces{"s4member_dflt"} = 38;
311 $interfaces{"vampire2000dc"} = 39;
313 # update lib/socket_wrapper/socket_wrapper.c
314 # #define MAX_WRAPPED_INTERFACES 40
315 # if you wish to have more than 40 interfaces
317 if (not defined($interfaces{$netbiosname})) {
321 return $interfaces{$netbiosname};
324 sub cleanup_child
($$)
326 my ($pid, $name) = @_;
328 if (!defined($pid)) {
329 print STDERR
"cleanup_child: pid not defined ... not calling waitpid\n";
333 my $childpid = waitpid($pid, WNOHANG
);
335 if ($childpid == 0) {
336 } elsif ($childpid < 0) {
337 printf STDERR
"%s child process %d isn't here any more\n", $name, $pid;
340 printf STDERR
"%s child process %d, died with signal %d, %s coredump\n",
341 $name, $childpid, ($?
& 127), ($?
& 128) ?
'with' : 'without';
343 printf STDERR
"%s child process %d exited with value %d\n", $name, $childpid, $?
>> 8;