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.
10 use FindBin
qw($RealBin);
17 my ($classname, $bindir, $binary_mapping, $ldap, $srcdir, $exeext, $server_maxtime) = @_;
18 $exeext = "" unless defined($exeext);
24 binary_mapping => $binary_mapping,
27 server_maxtime => $server_maxtime,
28 target3 => new Samba3($bindir, $binary_mapping, $srcdir, $exeext, $server_maxtime)
34 sub scriptdir_path($$) {
35 my ($self, $path) = @_;
36 return "$self->{srcdir}/source4/scripting/$path";
39 sub openldap_start($$$) {
45 my ($self, $env_vars) = @_;
46 my $ldbsearch = Samba::bindir_path($self, "ldbsearch");
48 my $uri = $env_vars->{LDAP_URI};
50 if (system("$ldbsearch -H $uri -s base -b \"\" supportedLDAPVersion > /dev/null") == 0) {
51 print "A SLAPD is still listening to $uri before we started the LDAP backend. Aborting!";
54 # running slapd in the background means it stays in the same process group, so it can be
56 if ($self->{ldap} eq "fedora-ds") {
57 system("$ENV{FEDORA_DS_ROOT}/sbin/ns-slapd -D $env_vars->{FEDORA_DS_DIR} -d0 -i $env_vars->{FEDORA_DS_PIDFILE}> $env_vars->{LDAPDIR}/logs 2>&1 &");
58 } elsif ($self->{ldap} eq "openldap") {
59 system("$ENV{OPENLDAP_SLAPD} -d0 -F $env_vars->{SLAPD_CONF_D} -h $uri > $env_vars->{LDAPDIR}/logs 2>&1 &");
61 while (system("$ldbsearch -H $uri -s base -b \"\" supportedLDAPVersion > /dev/null") != 0) {
64 $self->slapd_stop($env_vars);
74 my ($self, $envvars) = @_;
75 if ($self->{ldap} eq "fedora-ds") {
76 system("$envvars->{LDAPDIR}/slapd-$envvars->{LDAP_INSTANCE}/stop-slapd");
77 } elsif ($self->{ldap} eq "openldap") {
78 unless (open(IN, "<$envvars->{OPENLDAP_PIDFILE}")) {
79 warn("unable to open slapd pid file: $envvars->{OPENLDAP_PIDFILE}");
88 sub check_or_start($$)
90 my ($self, $env_vars) = @_;
91 return 0 if ( -p $env_vars->{SAMBA_TEST_FIFO});
93 unlink($env_vars->{SAMBA_TEST_FIFO});
94 POSIX::mkfifo($env_vars->{SAMBA_TEST_FIFO}, 0700);
95 unlink($env_vars->{SAMBA_TEST_LOG});
98 print "STARTING SAMBA for $ENV{ENVNAME}\n";
101 open STDIN, $env_vars->{SAMBA_TEST_FIFO};
102 # we want out from samba to go to the log file, but also
103 # to the users terminal when running 'make test' on the command
104 # line. This puts it on stderr on the terminal
105 open STDOUT, "| tee $env_vars->{SAMBA_TEST_LOG} 1>&2";
106 open STDERR, '>&STDOUT';
108 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
111 if (defined($ENV{SAMBA_VALGRIND})) {
112 $valgrind = $ENV{SAMBA_VALGRIND};
115 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
116 $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR};
118 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
119 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
121 $ENV{UID_WRAPPER} = "1";
123 # Start slapd before samba, but with the fifo on stdin
124 if (defined($self->{ldap})) {
125 unless($self->slapd_start($env_vars)) {
126 warn("couldn't start slapd (main run)");
132 $optarg = "--maximum-runtime=$self->{server_maxtime}";
133 if (defined($ENV{SAMBA_OPTIONS})) {
134 $optarg.= " $ENV{SAMBA_OPTIONS}";
136 my $samba = Samba::bindir_path($self, "samba");
138 # allow selection of the process model using
139 # the environment varibale SAMBA_PROCESS_MODEL
140 # that allows us to change the process model for
141 # individual machines in the build farm
142 my $model = "single";
143 if (defined($ENV{SAMBA_PROCESS_MODEL})) {
144 $model = $ENV{SAMBA_PROCESS_MODEL};
147 my $cmdline = "$valgrind ${pwd}/$samba $optarg $env_vars->{CONFIGURATION} -M $model -i";
148 my $ret = system("$cmdline");
150 print "Unable to start $cmdline: $ret: $!\n";
153 my $exit = ($ret >> 8);
154 unlink($env_vars->{SAMBA_TEST_FIFO});
156 print "$samba exited with no error\n";
158 } elsif ( $ret & 127 ) {
159 print "$samba got signal ".($ret & 127)." and exits with $exit!\n";
161 print "$samba failed with status $exit!\n";
170 open(DATA, ">$env_vars->{SAMBA_TEST_FIFO}");
175 sub wait_for_start($$)
177 my ($self, $testenv_vars) = @_;
178 # give time for nbt server to register its names
179 print "delaying for nbt name registration\n";
182 # This will return quickly when things are up, but be slow if we
183 # need to wait for (eg) SSL init
184 my $nmblookup = Samba::bindir_path($self, "nmblookup");
185 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{SERVER}");
186 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{SERVER}");
187 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
188 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
189 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
190 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
191 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{SERVER}");
192 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{SERVER}");
193 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
194 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
195 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
196 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
198 print $self->getlog_env($testenv_vars);
201 sub write_ldb_file($$$)
203 my ($self, $file, $ldif) = @_;
205 my $ldbadd = Samba::bindir_path($self, "ldbadd");
206 open(LDIF, "|$ldbadd -H $file >/dev/null");
211 sub add_wins_config($$)
213 my ($self, $privatedir) = @_;
215 return $self->write_ldb_file("$privatedir/wins_config.ldb", "
216 dn: name=TORTURE_11,CN=PARTNERS
217 objectClass: wreplPartner
228 my ($self, $ctx) = @_;
230 #Make the subdirectory be as fedora DS would expect
231 my $fedora_ds_dir = "$ctx->{ldapdir}/slapd-$ctx->{ldap_instance}";
233 my $pidfile = "$fedora_ds_dir/logs/slapd-$ctx->{ldap_instance}.pid";
235 return ($fedora_ds_dir, $pidfile);
240 my ($self, $ctx) = @_;
242 my $slapd_conf_d = "$ctx->{ldapdir}/slapd.d";
243 my $pidfile = "$ctx->{ldapdir}/slapd.pid";
245 return ($slapd_conf_d, $pidfile);
250 my ($self, $tlsdir) = @_;
252 #TLS and PKINIT crypto blobs
253 my $dhfile = "$tlsdir/dhparms.pem";
254 my $cafile = "$tlsdir/ca.pem";
255 my $certfile = "$tlsdir/cert.pem";
256 my $reqkdc = "$tlsdir/req-kdc.der";
257 my $kdccertfile = "$tlsdir/kdc.pem";
258 my $keyfile = "$tlsdir/key.pem";
259 my $adminkeyfile = "$tlsdir/adminkey.pem";
260 my $reqadmin = "$tlsdir/req-admin.der";
261 my $admincertfile = "$tlsdir/admincert.pem";
262 my $admincertupnfile = "$tlsdir/admincertupn.pem";
264 mkdir($tlsdir, 0777);
266 #This is specified here to avoid draining entropy on every run
267 open(DHFILE, ">$dhfile");
269 -----BEGIN DH PARAMETERS-----
270 MGYCYQC/eWD2xkb7uELmqLi+ygPMKyVcpHUo2yCluwnbPutEueuxrG/Cys8j8wLO
271 svCN/jYNyR2NszOmg7ZWcOC/4z/4pWDVPUZr8qrkhj5MRKJc52MncfaDglvEdJrv
273 -----END DH PARAMETERS-----
277 #Likewise, we pregenerate the key material. This allows the
278 #other certificates to be pre-generated
279 open(KEYFILE
, ">$keyfile");
281 -----BEGIN RSA PRIVATE KEY-----
282 MIICXQIBAAKBgQDKg6pAwCHUMA1DfHDmWhZfd+F0C+9Jxcqvpw9ii9En3E1uflpc
283 ol3+S9/6I/uaTmJHZre+DF3dTzb/UOZo0Zem8N+IzzkgoGkFafjXuT3BL5UPY2/H
284 6H+pPqVIRLOmrWImai359YyoKhFyo37Y6HPeU8QcZ+u2rS9geapIWfeuowIDAQAB
285 AoGAAqDLzFRR/BF1kpsiUfL4WFvTarCe9duhwj7ORc6fs785qAXuwUYAJ0Uvzmy6
286 HqoGv3t3RfmeHDmjcpPHsbOKnsOQn2MgmthidQlPBMWtQMff5zdoYNUFiPS0XQBq
287 szNW4PRjaA9KkLQVTwnzdXGkBSkn/nGxkaVu7OR3vJOBoo0CQQDO4upypesnbe6p
288 9/xqfZ2uim8IwV1fLlFClV7WlCaER8tsQF4lEi0XSzRdXGUD/dilpY88Nb+xok/X
289 8Z8OvgAXAkEA+pcLsx1gN7kxnARxv54jdzQjC31uesJgMKQXjJ0h75aUZwTNHmZQ
290 vPxi6u62YiObrN5oivkixwFNncT9MxTxVQJBAMaWUm2SjlLe10UX4Zdm1MEB6OsC
291 kVoX37CGKO7YbtBzCfTzJGt5Mwc1DSLA2cYnGJqIfSFShptALlwedot0HikCQAJu
292 jNKEKnbf+TdGY8Q0SKvTebOW2Aeg80YFkaTvsXCdyXrmdQcifw4WdO9KucJiDhSz
293 Y9hVapz7ykEJtFtWjLECQQDIlfc63I5ZpXfg4/nN4IJXUW6AmPVOYIA5215itgki
294 cSlMYli1H9MEXH0pQMGv5Qyd0OYIx2DDg96mZ+aFvqSG
295 -----END RSA PRIVATE KEY-----
299 open(ADMINKEYFILE
, ">$adminkeyfile");
301 print ADMINKEYFILE
<<EOF;
302 -----BEGIN RSA PRIVATE KEY-----
303 MIICXQIBAAKBgQD0+OL7TQBj0RejbIH1+g5GeRaWaM9xF43uE5y7jUHEsi5owhZF
304 5iIoHZeeL6cpDF5y1BZRs0JlA1VqMry1jjKlzFYVEMMFxB6esnXhl0Jpip1JkUMM
305 XLOP1m/0dqayuHBWozj9f/cdyCJr0wJIX1Z8Pr+EjYRGPn/MF0xdl3JRlwIDAQAB
306 AoGAP8mjCP628Ebc2eACQzOWjgEvwYCPK4qPmYOf1zJkArzG2t5XAGJ5WGrENRuB
307 cm3XFh1lpmaADl982UdW3gul4gXUy6w4XjKK4vVfhyHj0kZ/LgaXUK9BAGhroJ2L
308 osIOUsaC6jdx9EwSRctwdlF3wWJ8NK0g28AkvIk+FlolW4ECQQD7w5ouCDnf58CN
309 u4nARx4xv5XJXekBvOomkCQAmuOsdOb6b9wn3mm2E3au9fueITjb3soMR31AF6O4
310 eAY126rXAkEA+RgHzybzZEP8jCuznMqoN2fq/Vrs6+W3M8/G9mzGEMgLLpaf2Jiz
311 I9tLZ0+OFk9tkRaoCHPfUOCrVWJZ7Y53QQJBAMhoA6rw0WDyUcyApD5yXg6rusf4
312 ASpo/tqDkqUIpoL464Qe1tjFqtBM3gSXuhs9xsz+o0bzATirmJ+WqxrkKTECQHt2
313 OLCpKqwAspU7N+w32kaUADoRLisCEdrhWklbwpQgwsIVsCaoEOpt0CLloJRYTANE
314 yoZeAErTALjyZYZEPcECQQDlUi0N8DFxQ/lOwWyR3Hailft+mPqoPCa8QHlQZnlG
315 +cfgNl57YHMTZFwgUVFRdJNpjH/WdZ5QxDcIVli0q+Ko
316 -----END RSA PRIVATE KEY-----
320 # hxtool issue-certificate --self-signed --issue-ca \
321 # --ca-private-key="FILE:$KEYFILE" \
322 # --subject="CN=CA,DC=samba,DC=example,DC=com" \
323 # --certificate="FILE:$CAFILE" --lifetime="25 years"
325 open(CAFILE
, ">$cafile");
327 -----BEGIN CERTIFICATE-----
328 MIICcTCCAdqgAwIBAgIUaBPmjnPVqyFqR5foICmLmikJTzgwCwYJKoZIhvcNAQEFMFIxEzAR
329 BgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxlMRUwEwYKCZImiZPy
330 LGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMCIYDzIwMDgwMzAxMTIyMzEyWhgPMjAzMzAyMjQx
331 MjIzMTJaMFIxEzARBgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxl
332 MRUwEwYKCZImiZPyLGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMIGfMA0GCSqGSIb3DQEBAQUA
333 A4GNADCBiQKBgQDKg6pAwCHUMA1DfHDmWhZfd+F0C+9Jxcqvpw9ii9En3E1uflpcol3+S9/6
334 I/uaTmJHZre+DF3dTzb/UOZo0Zem8N+IzzkgoGkFafjXuT3BL5UPY2/H6H+pPqVIRLOmrWIm
335 ai359YyoKhFyo37Y6HPeU8QcZ+u2rS9geapIWfeuowIDAQABo0IwQDAOBgNVHQ8BAf8EBAMC
336 AaYwHQYDVR0OBBYEFMLZufegDKLZs0VOyFXYK1L6M8oyMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
337 KoZIhvcNAQEFBQADgYEAAZJbCAAkaqgFJ0xgNovn8Ydd0KswQPjicwiODPgw9ZPoD2HiOUVO
338 yYDRg/dhFF9y656OpcHk4N7qZ2sl3RlHkzDu+dseETW+CnKvQIoXNyeARRJSsSlwrwcoD4JR
339 HTLk2sGigsWwrJ2N99sG/cqSJLJ1MFwLrs6koweBnYU0f/g=
340 -----END CERTIFICATE-----
343 #generated with GNUTLS internally in Samba.
345 open(CERTFILE
, ">$certfile");
346 print CERTFILE
<<EOF;
347 -----BEGIN CERTIFICATE-----
348 MIICYTCCAcygAwIBAgIE5M7SRDALBgkqhkiG9w0BAQUwZTEdMBsGA1UEChMUU2Ft
349 YmEgQWRtaW5pc3RyYXRpb24xNDAyBgNVBAsTK1NhbWJhIC0gdGVtcG9yYXJ5IGF1
350 dG9nZW5lcmF0ZWQgY2VydGlmaWNhdGUxDjAMBgNVBAMTBVNhbWJhMB4XDTA2MDgw
351 NDA0MzY1MloXDTA4MDcwNDA0MzY1MlowZTEdMBsGA1UEChMUU2FtYmEgQWRtaW5p
352 c3RyYXRpb24xNDAyBgNVBAsTK1NhbWJhIC0gdGVtcG9yYXJ5IGF1dG9nZW5lcmF0
353 ZWQgY2VydGlmaWNhdGUxDjAMBgNVBAMTBVNhbWJhMIGcMAsGCSqGSIb3DQEBAQOB
354 jAAwgYgCgYDKg6pAwCHUMA1DfHDmWhZfd+F0C+9Jxcqvpw9ii9En3E1uflpcol3+
355 S9/6I/uaTmJHZre+DF3dTzb/UOZo0Zem8N+IzzkgoGkFafjXuT3BL5UPY2/H6H+p
356 PqVIRLOmrWImai359YyoKhFyo37Y6HPeU8QcZ+u2rS9geapIWfeuowIDAQABoyUw
357 IzAMBgNVHRMBAf8EAjAAMBMGA1UdJQQMMAoGCCsGAQUFBwMBMAsGCSqGSIb3DQEB
358 BQOBgQAmkN6XxvDnoMkGcWLCTwzxGfNNSVcYr7TtL2aJh285Xw9zaxcm/SAZBFyG
359 LYOChvh6hPU7joMdDwGfbiLrBnMag+BtGlmPLWwp/Kt1wNmrRhduyTQFhN3PP6fz
360 nBr9vVny2FewB2gHmelaPS//tXdxivSXKz3NFqqXLDJjq7P8wA==
361 -----END CERTIFICATE-----
366 # hxtool request-create \
367 # --subject="CN=krbtgt,CN=users,DC=samba,DC=example,DC=com" \
368 # --key="FILE:$KEYFILE" $KDCREQ
370 # hxtool issue-certificate --ca-certificate=FILE:$CAFILE,$KEYFILE \
371 # --type="pkinit-kdc" \
372 # --pk-init-principal="krbtgt/SAMBA.EXAMPLE.COM@SAMBA.EXAMPLE.COM" \
373 # --req="PKCS10:$KDCREQ" --certificate="FILE:$KDCCERTFILE" \
374 # --lifetime="25 years"
376 open(KDCCERTFILE
, ">$kdccertfile");
377 print KDCCERTFILE
<<EOF;
378 -----BEGIN CERTIFICATE-----
379 MIIDDDCCAnWgAwIBAgIUI2Tzj+JnMzMcdeabcNo30rovzFAwCwYJKoZIhvcNAQEFMFIxEzAR
380 BgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxlMRUwEwYKCZImiZPy
381 LGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMCIYDzIwMDgwMzAxMTMxOTIzWhgPMjAzMzAyMjQx
382 MzE5MjNaMGYxEzARBgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxl
383 MRUwEwYKCZImiZPyLGQBGQwFc2FtYmExDjAMBgNVBAMMBXVzZXJzMQ8wDQYDVQQDDAZrcmJ0
384 Z3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMqDqkDAIdQwDUN8cOZaFl934XQL70nF
385 yq+nD2KL0SfcTW5+WlyiXf5L3/oj+5pOYkdmt74MXd1PNv9Q5mjRl6bw34jPOSCgaQVp+Ne5
386 PcEvlQ9jb8fof6k+pUhEs6atYiZqLfn1jKgqEXKjftjoc95TxBxn67atL2B5qkhZ966jAgMB
387 AAGjgcgwgcUwDgYDVR0PAQH/BAQDAgWgMBIGA1UdJQQLMAkGBysGAQUCAwUwVAYDVR0RBE0w
388 S6BJBgYrBgEFAgKgPzA9oBMbEVNBTUJBLkVYQU1QTEUuQ09NoSYwJKADAgEBoR0wGxsGa3Ji
389 dGd0GxFTQU1CQS5FWEFNUExFLkNPTTAfBgNVHSMEGDAWgBTC2bn3oAyi2bNFTshV2CtS+jPK
390 MjAdBgNVHQ4EFgQUwtm596AMotmzRU7IVdgrUvozyjIwCQYDVR0TBAIwADANBgkqhkiG9w0B
391 AQUFAAOBgQBmrVD5MCmZjfHp1nEnHqTIh8r7lSmVtDx4s9MMjxm9oNrzbKXynvdhwQYFVarc
392 ge4yRRDXtSebErOl71zVJI9CVeQQpwcH+tA85oGA7oeFtO/S7ls581RUU6tGgyxV4veD+lJv
393 KPH5LevUtgD+q9H4LU4Sq5N3iFwBaeryB0g2wg==
394 -----END CERTIFICATE-----
397 # hxtool request-create \
398 # --subject="CN=Administrator,CN=users,DC=samba,DC=example,DC=com" \
399 # --key="FILE:$ADMINKEYFILE" $ADMINREQFILE
401 # hxtool issue-certificate --ca-certificate=FILE:$CAFILE,$KEYFILE \
402 # --type="pkinit-client" \
403 # --pk-init-principal="administrator@SAMBA.EXAMPLE.COM" \
404 # --req="PKCS10:$ADMINREQFILE" --certificate="FILE:$ADMINCERTFILE" \
405 # --lifetime="25 years"
407 open(ADMINCERTFILE
, ">$admincertfile");
408 print ADMINCERTFILE
<<EOF;
409 -----BEGIN CERTIFICATE-----
410 MIIDHTCCAoagAwIBAgIUUggzW4lLRkMKe1DAR2NKatkMDYwwCwYJKoZIhvcNAQELMFIxEzAR
411 BgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxlMRUwEwYKCZImiZPy
412 LGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMCIYDzIwMDkwNzI3MDMzMjE1WhgPMjAzNDA3MjIw
413 MzMyMTVaMG0xEzARBgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxl
414 MRUwEwYKCZImiZPyLGQBGQwFc2FtYmExDjAMBgNVBAMMBXVzZXJzMRYwFAYDVQQDDA1BZG1p
415 bmlzdHJhdG9yMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD0+OL7TQBj0RejbIH1+g5G
416 eRaWaM9xF43uE5y7jUHEsi5owhZF5iIoHZeeL6cpDF5y1BZRs0JlA1VqMry1jjKlzFYVEMMF
417 xB6esnXhl0Jpip1JkUMMXLOP1m/0dqayuHBWozj9f/cdyCJr0wJIX1Z8Pr+EjYRGPn/MF0xd
418 l3JRlwIDAQABo4HSMIHPMA4GA1UdDwEB/wQEAwIFoDAoBgNVHSUEITAfBgcrBgEFAgMEBggr
419 BgEFBQcDAgYKKwYBBAGCNxQCAjBIBgNVHREEQTA/oD0GBisGAQUCAqAzMDGgExsRU0FNQkEu
420 RVhBTVBMRS5DT02hGjAYoAMCAQGhETAPGw1BZG1pbmlzdHJhdG9yMB8GA1UdIwQYMBaAFMLZ
421 ufegDKLZs0VOyFXYK1L6M8oyMB0GA1UdDgQWBBQg81bLyfCA88C2B/BDjXlGuaFaxjAJBgNV
422 HRMEAjAAMA0GCSqGSIb3DQEBCwUAA4GBAEf/OSHUDJaGdtWGNuJeqcVYVMwrfBAc0OSwVhz1
423 7/xqKHWo8wIMPkYRtaRHKLNDsF8GkhQPCpVsa6mX/Nt7YQnNvwd+1SBP5E8GvwWw9ZzLJvma
424 nk2n89emuayLpVtp00PymrDLRBcNaRjFReQU8f0o509kiVPHduAp3jOiy13l
425 -----END CERTIFICATE-----
427 close(ADMINCERTFILE
);
429 # hxtool issue-certificate --ca-certificate=FILE:$CAFILE,$KEYFILE \
430 # --type="pkinit-client" \
431 # --ms-upn="administrator@samba.example.com" \
432 # --req="PKCS10:$ADMINREQFILE" --certificate="FILE:$ADMINCERTUPNFILE" \
433 # --lifetime="25 years"
435 open(ADMINCERTUPNFILE
, ">$admincertupnfile");
436 print ADMINCERTUPNFILE
<<EOF;
437 -----BEGIN CERTIFICATE-----
438 MIIDDzCCAnigAwIBAgIUUp3CJMuNaEaAdPKp3QdNIwG7a4wwCwYJKoZIhvcNAQELMFIxEzAR
439 BgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxlMRUwEwYKCZImiZPy
440 LGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMCIYDzIwMDkwNzI3MDMzMzA1WhgPMjAzNDA3MjIw
441 MzMzMDVaMG0xEzARBgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxl
442 MRUwEwYKCZImiZPyLGQBGQwFc2FtYmExDjAMBgNVBAMMBXVzZXJzMRYwFAYDVQQDDA1BZG1p
443 bmlzdHJhdG9yMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD0+OL7TQBj0RejbIH1+g5G
444 eRaWaM9xF43uE5y7jUHEsi5owhZF5iIoHZeeL6cpDF5y1BZRs0JlA1VqMry1jjKlzFYVEMMF
445 xB6esnXhl0Jpip1JkUMMXLOP1m/0dqayuHBWozj9f/cdyCJr0wJIX1Z8Pr+EjYRGPn/MF0xd
446 l3JRlwIDAQABo4HEMIHBMA4GA1UdDwEB/wQEAwIFoDAoBgNVHSUEITAfBgcrBgEFAgMEBggr
447 BgEFBQcDAgYKKwYBBAGCNxQCAjA6BgNVHREEMzAxoC8GCisGAQQBgjcUAgOgIQwfYWRtaW5p
448 c3RyYXRvckBzYW1iYS5leGFtcGxlLmNvbTAfBgNVHSMEGDAWgBTC2bn3oAyi2bNFTshV2CtS
449 +jPKMjAdBgNVHQ4EFgQUIPNWy8nwgPPAtgfwQ415RrmhWsYwCQYDVR0TBAIwADANBgkqhkiG
450 9w0BAQsFAAOBgQBk42+egeUB3Ji2PC55fbt3FNKxvmm2xUUFkV9POK/YR9rajKOwk5jtYSeS
451 Zd7J9s//rNFNa7waklFkDaY56+QWTFtdvxfE+KoHaqt6X8u6pqi7p3M4wDKQox+9Dx8yWFyq
452 Wfz/8alZ5aMezCQzXJyIaJsCLeKABosSwHcpAFmxlQ==
453 -----END CERTIFICATE-----
457 sub provision_raw_prepare
($$$$$$$$$$)
459 my ($self, $prefix, $server_role, $netbiosname,
460 $domain, $realm, $functional_level,
461 $swiface, $password, $kdc_ipv4) = @_;
464 unless(-d
$prefix or mkdir($prefix, 0777)) {
465 warn("Unable to create $prefix");
468 my $prefix_abs = abs_path
($prefix);
470 die ("prefix=''") if $prefix_abs eq "";
471 die ("prefix='/'") if $prefix_abs eq "/";
473 unless (system("rm -rf $prefix_abs/*") == 0) {
474 warn("Unable to clean up");
477 $ctx->{prefix
} = $prefix;
478 $ctx->{prefix_abs
} = $prefix_abs;
480 $ctx->{dns_host_file
} = "$ENV{SELFTEST_PREFIX}/dns_host_file";
482 $ctx->{server_role
} = $server_role;
483 $ctx->{netbiosname
} = $netbiosname;
484 $ctx->{swiface
} = $swiface;
485 $ctx->{password
} = $password;
486 $ctx->{kdc_ipv4
} = $kdc_ipv4;
488 $ctx->{server_loglevel
} =$ENV{SERVER_LOG_LEVEL
} || 1;
489 $ctx->{username
} = "Administrator";
490 $ctx->{domain
} = $domain;
491 $ctx->{realm
} = uc($realm);
492 $ctx->{dnsname
} = lc($realm);
493 $ctx->{sid_generator
} = "internal";
495 $ctx->{functional_level
} = $functional_level;
497 my $unix_name = ($ENV{USER
} or $ENV{LOGNAME
} or `whoami`);
499 $ctx->{unix_name
} = $unix_name;
500 $ctx->{unix_uid
} = $>;
501 $ctx->{unix_gids_str
} = $);
502 @
{$ctx->{unix_gids
}} = split(" ", $ctx->{unix_gids_str
});
504 $ctx->{etcdir
} = "$prefix_abs/etc";
505 $ctx->{piddir
} = "$prefix_abs/pid";
506 $ctx->{smb_conf
} = "$ctx->{etcdir}/smb.conf";
507 $ctx->{krb5_conf
} = "$ctx->{etcdir}/krb5.conf";
508 $ctx->{privatedir
} = "$prefix_abs/private";
509 $ctx->{ncalrpcdir
} = "$prefix_abs/ncalrpc";
510 $ctx->{lockdir
} = "$prefix_abs/lockdir";
511 $ctx->{winbindd_socket_dir
} = "$prefix_abs/winbindd_socket";
512 $ctx->{winbindd_privileged_socket_dir
} = "$prefix_abs/winbindd_privileged_socket";
513 $ctx->{ntp_signd_socket_dir
} = "$prefix_abs/ntp_signd_socket";
514 $ctx->{nsswrap_passwd
} = "$ctx->{etcdir}/passwd";
515 $ctx->{nsswrap_group
} = "$ctx->{etcdir}/group";
517 $ctx->{tlsdir
} = "$ctx->{privatedir}/tls";
519 $ctx->{ipv4
} = "127.0.0.$swiface";
520 $ctx->{interfaces
} = "$ctx->{ipv4}/8";
522 push(@
{$ctx->{directories
}}, $ctx->{privatedir
});
523 push(@
{$ctx->{directories
}}, $ctx->{etcdir
});
524 push(@
{$ctx->{directories
}}, $ctx->{piddir
});
525 push(@
{$ctx->{directories
}}, $ctx->{lockdir
});
527 $ctx->{smb_conf_extra_options
} = "";
529 my @provision_options = ();
530 push (@provision_options, "NSS_WRAPPER_PASSWD=\"$ctx->{nsswrap_passwd}\"");
531 push (@provision_options, "NSS_WRAPPER_GROUP=\"$ctx->{nsswrap_group}\"");
532 if (defined($ENV{GDB_PROVISION
})) {
533 push (@provision_options, "gdb --args");
534 if (!defined($ENV{PYTHON
})) {
535 push (@provision_options, "env");
536 push (@provision_options, "python");
539 if (defined($ENV{VALGRIND_PROVISION
})) {
540 push (@provision_options, "valgrind");
541 if (!defined($ENV{PYTHON
})) {
542 push (@provision_options, "env");
543 push (@provision_options, "python");
546 if (defined($ENV{PYTHON
})) {
547 push (@provision_options, $ENV{PYTHON
});
549 push (@provision_options, "$self->{srcdir}/source4/setup/provision");
550 push (@provision_options, "--configfile=$ctx->{smb_conf}");
551 push (@provision_options, "--host-name=$ctx->{netbiosname}");
552 push (@provision_options, "--host-ip=$ctx->{ipv4}");
553 push (@provision_options, "--quiet");
554 push (@provision_options, "--domain=$ctx->{domain}");
555 push (@provision_options, "--realm=$ctx->{realm}");
556 push (@provision_options, "--adminpass=$ctx->{password}");
557 push (@provision_options, "--krbtgtpass=krbtgt$ctx->{password}");
558 push (@provision_options, "--machinepass=machine$ctx->{password}");
559 push (@provision_options, "--root=$ctx->{unix_name}");
560 push (@provision_options, "--server-role=\"$ctx->{server_role}\"");
561 push (@provision_options, "--function-level=\"$ctx->{functional_level}\"");
563 @
{$ctx->{provision_options
}} = @provision_options;
569 # Step1 creates the basic configuration
571 sub provision_raw_step1
($$)
573 my ($self, $ctx) = @_;
575 mkdir($_, 0777) foreach (@
{$ctx->{directories
}});
577 unless (open(CONFFILE
, ">$ctx->{smb_conf}")) {
578 warn("can't open $ctx->{smb_conf}$?");
582 $acl = "true" if (defined $ENV{WITH_ACL
});
586 netbios name = $ctx->{netbiosname}
587 posix:eadb = $ctx->{lockdir}/eadb.tdb
588 workgroup = $ctx->{domain}
589 realm = $ctx->{realm}
590 private dir = $ctx->{privatedir}
591 pid directory = $ctx->{piddir}
592 ncalrpc dir = $ctx->{ncalrpcdir}
593 lock dir = $ctx->{lockdir}
594 winbindd socket directory = $ctx->{winbindd_socket_dir}
595 winbindd privileged socket directory = $ctx->{winbindd_privileged_socket_dir}
596 ntp signd socket directory = $ctx->{ntp_signd_socket_dir}
597 winbind separator = /
598 name resolve order = file bcast
599 interfaces = $ctx->{interfaces}
600 tls dh params file = $ctx->{tlsdir}/dhparms.pem
601 panic action = $RealBin/gdb_backtrace \%PID% \%PROG%
603 server role = $ctx->{server_role}
604 server services = +echo
605 notify:inotify = false
607 #We don't want to pass our self-tests if the PAC code is wrong
608 gensec:require_pac = true
609 log level = $ctx->{server_loglevel}
612 dns update command = $ENV{SRCDIR_ABS}/source4/scripting/bin/samba_dnsupdate --all-interfaces --use-file=$ctx->{dns_host_file}
613 spn update command = $ENV{SRCDIR_ABS}/source4/scripting/bin/samba_spnupdate
614 resolv:host file = $ctx->{dns_host_file}
615 dreplsrv:periodic_startup_interval = 0
618 if (defined($ctx->{sid_generator
}) && $ctx->{sid_generator
} ne "internal") {
620 sid generator = $ctx->{sid_generator}";
625 # Begin extra options
626 $ctx->{smb_conf_extra_options}
631 $self->mk_keyblobs($ctx->{tlsdir
});
633 #Default the KDC IP to the server's IP
634 if (not defined($ctx->{kdc_ipv4
})) {
635 $ctx->{kdc_ipv4
} = $ctx->{ipv4
};
638 Samba
::mk_krb5_conf
($ctx);
640 open(PWD
, ">$ctx->{nsswrap_passwd}");
642 root:x:0:0:root gecos:$ctx->{prefix_abs}:/bin/false
643 $ctx->{unix_name}:x:$ctx->{unix_uid}:@{$ctx->{unix_gids}}[0]:$ctx->{unix_name} gecos:$ctx->{prefix_abs}:/bin/false
644 nobody:x:65534:65533:nobody gecos:$ctx->{prefix_abs}:/bin/false
648 open(GRP
, ">$ctx->{nsswrap_group}");
654 nogroup:x:65534:nobody
658 my $configuration = "--configfile=$ctx->{smb_conf}";
660 #Ensure the config file is valid before we start
661 my $testparm = Samba
::bindir_path
($self, "samba-tool") . " testparm";
662 if (system("$testparm $configuration -v --suppress-prompt >/dev/null 2>&1") != 0) {
663 system("$testparm -v --suppress-prompt $configuration >&2");
664 warn("Failed to create a valid smb.conf configuration $testparm!");
667 unless (system("($testparm $configuration -v --suppress-prompt --parameter-name=\"netbios name\" --section-name=global 2> /dev/null | grep -i \"^$ctx->{netbiosname}\" ) >/dev/null 2>&1") == 0) {
668 warn("Failed to create a valid smb.conf configuration! $testparm $configuration -v --suppress-prompt --parameter-name=\"netbios name\" --section-name=global");
673 KRB5_CONFIG
=> $ctx->{krb5_conf
},
674 PIDDIR
=> $ctx->{piddir
},
675 SERVER
=> $ctx->{netbiosname
},
676 SERVER_IP
=> $ctx->{ipv4
},
677 NETBIOSNAME
=> $ctx->{netbiosname
},
678 DOMAIN
=> $ctx->{domain
},
679 USERNAME
=> $ctx->{username
},
680 REALM
=> $ctx->{realm
},
681 PASSWORD
=> $ctx->{password
},
682 LDAPDIR
=> $ctx->{ldapdir
},
683 LDAP_INSTANCE
=> $ctx->{ldap_instance
},
684 WINBINDD_SOCKET_DIR
=> $ctx->{winbindd_socket_dir
},
685 NCALRPCDIR
=> $ctx->{ncalrpcdir
},
686 LOCKDIR
=> $ctx->{lockdir
},
687 SERVERCONFFILE
=> $ctx->{smb_conf
},
688 CONFIGURATION
=> $configuration,
689 SOCKET_WRAPPER_DEFAULT_IFACE
=> $ctx->{swiface
},
690 NSS_WRAPPER_PASSWD
=> $ctx->{nsswrap_passwd
},
691 NSS_WRAPPER_GROUP
=> $ctx->{nsswrap_group
},
692 SAMBA_TEST_FIFO
=> "$ctx->{prefix}/samba_test.fifo",
693 SAMBA_TEST_LOG
=> "$ctx->{prefix}/samba_test.log",
694 SAMBA_TEST_LOG_POS
=> 0,
701 # Step2 runs the provision script
703 sub provision_raw_step2
($$$)
705 my ($self, $ctx, $ret) = @_;
707 my $provision_cmd = join(" ", @
{$ctx->{provision_options
}});
708 unless (system($provision_cmd) == 0) {
709 warn("Unable to provision: \n$provision_cmd\n");
716 sub provision
($$$$$$$$$)
718 my ($self, $prefix, $server_role, $netbiosname,
719 $domain, $realm, $functional_level,
720 $swiface, $password, $kdc_ipv4, $extra_smbconf_options) = @_;
722 my $ctx = $self->provision_raw_prepare($prefix, $server_role,
724 $domain, $realm, $functional_level,
725 $swiface, $password, $kdc_ipv4);
727 $ctx->{tmpdir
} = "$ctx->{prefix_abs}/tmp";
728 push(@
{$ctx->{directories
}}, "$ctx->{tmpdir}");
729 push(@
{$ctx->{directories
}}, "$ctx->{tmpdir}/test1");
730 push(@
{$ctx->{directories
}}, "$ctx->{tmpdir}/test2");
732 $msdfs = "yes" if ($server_role eq "domain controller");
733 $ctx->{smb_conf_extra_options
} = "
736 server max protocol = SMB2
737 $extra_smbconf_options
742 path = $ctx->{tmpdir}
744 posix:sharedelay = 10000
745 posix:oplocktimeout = 3
746 posix:writetimeupdatedelay = 500000
749 path = $ctx->{tmpdir}/test1
751 posix:sharedelay = 10000
752 posix:oplocktimeout = 3
753 posix:writetimeupdatedelay = 50000
756 path = $ctx->{tmpdir}/test2
758 posix:sharedelay = 10000
759 posix:oplocktimeout = 3
760 posix:writetimeupdatedelay = 50000
765 cifs:server = $ctx->{netbiosname}
767 #There is no username specified here, instead the client is expected
768 #to log in with kerberos, and the serverwill use delegated credentials.
771 path = $ctx->{tmpdir}
773 ntvfs handler = simple
776 path = $ctx->{lockdir}/sysvol
780 path = $ctx->{lockdir}/sysvol/$ctx->{dnsname}/scripts
785 ntvfs handler = cifsposix
788 if (defined($self->{ldap
})) {
789 $ctx->{ldapdir
} = "$ctx->{privatedir}/ldap";
790 push(@
{$ctx->{directories
}}, "$ctx->{ldapdir}");
792 my $ldap_uri= "$ctx->{ldapdir}/ldapi";
793 $ldap_uri =~ s
|/|%2F|g
;
794 $ldap_uri = "ldapi://$ldap_uri";
795 $ctx->{ldap_uri
} = $ldap_uri;
796 if ($self->{ldap
} eq "fedora-ds") {
797 $ctx->{sid_generator
} = "backend";
800 $ctx->{ldap_instance
} = lc($ctx->{netbiosname
});
803 my $ret = $self->provision_raw_step1($ctx);
804 unless (defined $ret) {
808 if (defined($self->{ldap
})) {
809 $ret->{LDAP_URI
} = $ctx->{ldap_uri
};
810 push (@
{$ctx->{provision_options
}}, "--ldap-backend-type=" . $self->{ldap
});
811 push (@
{$ctx->{provision_options
}}, "--ldap-backend-nosync");
812 if ($self->{ldap
} eq "openldap") {
813 push (@
{$ctx->{provision_options
}}, "--slapd-path=" . $ENV{OPENLDAP_SLAPD
});
814 ($ret->{SLAPD_CONF_D
}, $ret->{OPENLDAP_PIDFILE
}) = $self->mk_openldap($ctx) or die("Unable to create openldap directories");
816 } elsif ($self->{ldap
} eq "fedora-ds") {
817 push (@
{$ctx->{provision_options
}}, "--slapd-path=" . "$ENV{FEDORA_DS_ROOT}/sbin/ns-slapd");
818 push (@
{$ctx->{provision_options
}}, "--setup-ds-path=" . "$ENV{FEDORA_DS_ROOT}/sbin/setup-ds.pl");
819 ($ret->{FEDORA_DS_DIR
}, $ret->{FEDORA_DS_PIDFILE
}) = $self->mk_fedora_ds($ctx) or die("Unable to create fedora ds directories");
824 return $self->provision_raw_step2($ctx, $ret);
827 sub provision_member
($$$)
829 my ($self, $prefix, $dcvars) = @_;
830 print "PROVISIONING MEMBER...";
832 my $ret = $self->provision($prefix,
840 $dcvars->{SERVER_IP
},
846 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
848 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
849 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
850 $cmd .= "$samba_tool join $ret->{CONFIGURATION} $dcvars->{REALM} member";
851 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
853 unless (system($cmd) == 0) {
854 warn("Join failed\n$cmd");
858 $ret->{MEMBER_SERVER
} = $ret->{SERVER
};
859 $ret->{MEMBER_SERVER_IP
} = $ret->{SERVER_IP
};
860 $ret->{MEMBER_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
861 $ret->{MEMBER_USERNAME
} = $ret->{USERNAME
};
862 $ret->{MEMBER_PASSWORD
} = $ret->{PASSWORD
};
864 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
865 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
866 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
867 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
868 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
873 sub provision_rpc_proxy
($$$)
875 my ($self, $prefix, $dcvars) = @_;
876 print "PROVISIONING RPC PROXY...";
878 my $extra_smbconf_options = "dcerpc_remote:binding = ncacn_ip_tcp:$dcvars->{SERVER}
879 dcerpc endpoint servers = epmapper, remote
880 dcerpc_remote:interfaces = rpcecho
883 my $ret = $self->provision($prefix,
891 $dcvars->{SERVER_IP
},
892 $extra_smbconf_options);
898 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
900 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
901 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
902 $cmd .= "$samba_tool join $ret->{CONFIGURATION} $dcvars->{REALM} member";
903 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
905 unless (system($cmd) == 0) {
906 warn("Join failed\n$cmd");
910 $ret->{RPC_PROXY_SERVER
} = $ret->{SERVER
};
911 $ret->{RPC_PROXY_SERVER_IP
} = $ret->{SERVER_IP
};
912 $ret->{RPC_PROXY_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
913 $ret->{RPC_PROXY_USERNAME
} = $ret->{USERNAME
};
914 $ret->{RPC_PROXY_PASSWORD
} = $ret->{PASSWORD
};
916 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
917 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
918 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
919 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
920 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
925 sub provision_vampire_dc
($$$)
927 my ($self, $prefix, $dcvars) = @_;
928 print "PROVISIONING VAMPIRE DC...";
930 # We do this so that we don't run the provision. That's the job of 'net vampire'.
931 my $ctx = $self->provision_raw_prepare($prefix, "domain controller",
936 22, $dcvars->{PASSWORD
},
937 $dcvars->{SERVER_IP
});
939 $ctx->{smb_conf_extra_options
} = "
941 server max protocol = SMB2
944 path = $ctx->{lockdir}/sysvol
948 path = $ctx->{lockdir}/sysvol/$ctx->{dnsname}/scripts
953 my $ret = $self->provision_raw_step1($ctx);
958 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
960 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
961 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
962 $cmd .= "$samba_tool join $ret->{CONFIGURATION} $dcvars->{REALM} DC --realm=$dcvars->{REALM}";
963 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
965 unless (system($cmd) == 0) {
966 warn("Join failed\n$cmd");
970 $ret->{VAMPIRE_DC_SERVER
} = $ret->{SERVER
};
971 $ret->{VAMPIRE_DC_SERVER_IP
} = $ret->{SERVER_IP
};
972 $ret->{VAMPIRE_DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
974 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
975 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
976 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
977 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
978 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
985 my ($self, $prefix) = @_;
987 print "PROVISIONING DC...";
988 my $ret = $self->provision($prefix,
996 undef, "netbios aliases = DC1");
998 return undef unless(defined $ret);
999 unless($self->add_wins_config("$prefix/private")) {
1000 warn("Unable to add wins configuration");
1004 $ret->{NETBIOSALIAS
} = "DC1";
1005 $ret->{DC_SERVER
} = $ret->{SERVER
};
1006 $ret->{DC_SERVER_IP
} = $ret->{SERVER_IP
};
1007 $ret->{DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1008 $ret->{DC_USERNAME
} = $ret->{USERNAME
};
1009 $ret->{DC_PASSWORD
} = $ret->{PASSWORD
};
1014 sub provision_fl2000dc
($$)
1016 my ($self, $prefix) = @_;
1018 print "PROVISIONING DC...";
1019 my $ret = $self->provision($prefix,
1020 "domain controller",
1023 "samba2000.example.com",
1029 unless($self->add_wins_config("$prefix/private")) {
1030 warn("Unable to add wins configuration");
1037 sub provision_fl2003dc
($$)
1039 my ($self, $prefix) = @_;
1041 print "PROVISIONING DC...";
1042 my $ret = $self->provision($prefix,
1043 "domain controller",
1046 "samba2003.example.com",
1052 unless($self->add_wins_config("$prefix/private")) {
1053 warn("Unable to add wins configuration");
1060 sub provision_fl2008r2dc
($$)
1062 my ($self, $prefix) = @_;
1064 print "PROVISIONING DC...";
1065 my $ret = $self->provision($prefix,
1066 "domain controller",
1069 "samba2008R2.example.com",
1075 unless ($self->add_wins_config("$prefix/private")) {
1076 warn("Unable to add wins configuration");
1084 sub provision_rodc
($$$)
1086 my ($self, $prefix, $dcvars) = @_;
1087 print "PROVISIONING RODC...";
1089 # We do this so that we don't run the provision. That's the job of 'net join RODC'.
1090 my $ctx = $self->provision_raw_prepare($prefix, "domain controller",
1093 "samba.example.com",
1095 28, $dcvars->{PASSWORD
},
1096 $dcvars->{SERVER_IP
});
1101 $ctx->{tmpdir
} = "$ctx->{prefix_abs}/tmp";
1102 push(@
{$ctx->{directories
}}, "$ctx->{tmpdir}");
1104 $ctx->{smb_conf_extra_options
} = "
1106 server max protocol = SMB2
1109 path = $ctx->{lockdir}/sysvol
1113 path = $ctx->{lockdir}/sysvol/$ctx->{dnsname}/scripts
1117 path = $ctx->{tmpdir}
1119 posix:sharedelay = 10000
1120 posix:oplocktimeout = 3
1121 posix:writetimeupdatedelay = 500000
1125 my $ret = $self->provision_raw_step1($ctx);
1130 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
1132 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1133 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1134 $cmd .= "$samba_tool join $ret->{CONFIGURATION} $dcvars->{REALM} RODC";
1135 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
1136 $cmd .= " --server=$dcvars->{DC_SERVER}";
1138 unless (system($cmd) == 0) {
1139 warn("RODC join failed\n$cmd");
1143 # we overwrite the kdc after the RODC join
1144 # so that use the RODC as kdc and test
1146 $ctx->{kdc_ipv4
} = $ret->{SERVER_IP
};
1147 Samba
::mk_krb5_conf
($ctx);
1149 $ret->{RODC_DC_SERVER
} = $ret->{SERVER
};
1150 $ret->{RODC_DC_SERVER_IP
} = $ret->{SERVER_IP
};
1151 $ret->{RODC_DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1153 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
1154 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
1155 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
1156 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
1157 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
1162 sub provision_plugin_s4_dc
($$)
1164 my ($self, $prefix) = @_;
1166 my $extra_smbconf_options = "
1167 server services = -winbind, -smb
1170 print "PROVISIONING PLUGIN S4 DC...";
1171 my $ret = $self->provision($prefix,
1172 "domain controller",
1175 "plugin.samba.example.com",
1179 undef, $extra_smbconf_options);
1181 return undef unless(defined $ret);
1182 unless($self->add_wins_config("$prefix/private")) {
1183 warn("Unable to add wins configuration");
1187 $ret->{DC_SERVER
} = $ret->{SERVER
};
1188 $ret->{DC_SERVER_IP
} = $ret->{SERVER_IP
};
1189 $ret->{DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1190 $ret->{DC_USERNAME
} = $ret->{USERNAME
};
1191 $ret->{DC_PASSWORD
} = $ret->{PASSWORD
};
1196 sub teardown_env
($$)
1198 my ($self, $envvars) = @_;
1203 if (open(IN
, "<$envvars->{PIDDIR}/samba.pid")) {
1207 # Give the process 20 seconds to exit. gcov needs
1208 # this time to write out the covarge data
1210 until (kill(0, $pid) == 0) {
1211 # if no process sucessfully signalled, then we are done
1214 last if $count > 20;
1217 # If it is still around, kill it
1219 print "server process $pid took more than $count seconds to exit, killing\n";
1224 my $failed = $?
>> 8;
1226 $self->slapd_stop($envvars) if ($self->{ldap
});
1228 print $self->getlog_env($envvars);
1235 my ($self, $envvars) = @_;
1236 my $title = "SAMBA LOG of: $envvars->{NETBIOSNAME}\n";
1239 open(LOG
, "<$envvars->{SAMBA_TEST_LOG}");
1241 seek(LOG
, $envvars->{SAMBA_TEST_LOG_POS
}, SEEK_SET
);
1245 $envvars->{SAMBA_TEST_LOG_POS
} = tell(LOG
);
1248 return "" if $out eq $title;
1255 my ($self, $envvars) = @_;
1257 return (-p
$envvars->{SAMBA_TEST_FIFO
});
1262 my ($self, $envname, $path) = @_;
1263 my $target3 = $self->{target3
};
1265 $ENV{ENVNAME
} = $envname;
1267 if ($envname eq "dc") {
1268 return $self->setup_dc("$path/dc");
1269 } elsif ($envname eq "fl2000dc") {
1270 return $self->setup_fl2000dc("$path/fl2000dc");
1271 } elsif ($envname eq "fl2003dc") {
1272 return $self->setup_fl2003dc("$path/fl2003dc");
1273 } elsif ($envname eq "fl2008r2dc") {
1274 return $self->setup_fl2008r2dc("$path/fl2008r2dc");
1275 } elsif ($envname eq "rpc_proxy") {
1276 if (not defined($self->{vars
}->{dc
})) {
1277 $self->setup_dc("$path/dc");
1279 return $self->setup_rpc_proxy("$path/rpc_proxy", $self->{vars
}->{dc
});
1280 } elsif ($envname eq "vampire_dc") {
1281 if (not defined($self->{vars
}->{dc
})) {
1282 $self->setup_dc("$path/dc");
1284 return $self->setup_vampire_dc("$path/vampire_dc", $self->{vars
}->{dc
});
1285 } elsif ($envname eq "s4member") {
1286 if (not defined($self->{vars
}->{dc
})) {
1287 $self->setup_dc("$path/dc");
1289 return $self->setup_member("$path/s4member", $self->{vars
}->{dc
});
1290 } elsif ($envname eq "rodc") {
1291 if (not defined($self->{vars
}->{dc
})) {
1292 $self->setup_dc("$path/dc");
1294 return $self->setup_rodc("$path/rodc", $self->{vars
}->{dc
});
1295 } elsif ($envname eq "s3member") {
1296 if (not defined($self->{vars
}->{dc
})) {
1297 $self->setup_dc("$path/dc");
1299 return $target3->setup_admember("$path/s3member", $self->{vars
}->{dc
}, 29);
1300 } elsif ($envname eq "plugin_s4_dc") {
1301 return $self->setup_plugin_s4_dc("$path/plugin_s4_dc");
1302 } elsif ($envname eq "all") {
1303 if (not defined($self->{vars
}->{dc
})) {
1304 $ENV{ENVNAME
} = "dc";
1305 $self->setup_dc("$path/dc");
1307 my $ret = $self->setup_member("$path/s4member", $self->{vars
}->{dc
});
1308 if (not defined($self->{vars
}->{rpc_proxy
})) {
1309 $ENV{ENVNAME
} = "rpc_proxy";
1310 my $rpc_proxy_ret = $self->setup_rpc_proxy("$path/rpc_proxy", $self->{vars
}->{dc
});
1312 $ret->{RPC_PROXY_SERVER
} = $rpc_proxy_ret->{SERVER
};
1313 $ret->{RPC_PROXY_SERVER_IP
} = $rpc_proxy_ret->{SERVER_IP
};
1314 $ret->{RPC_PROXY_NETBIOSNAME
} = $rpc_proxy_ret->{NETBIOSNAME
};
1315 $ret->{RPC_PROXY_USERNAME
} = $rpc_proxy_ret->{USERNAME
};
1316 $ret->{RPC_PROXY_PASSWORD
} = $rpc_proxy_ret->{PASSWORD
};
1318 if (not defined($self->{vars
}->{fl2000dc
})) {
1319 $ENV{ENVNAME
} = "fl2000dc";
1320 my $fl2000dc_ret = $self->setup_fl2000dc("$path/fl2000dc", $self->{vars
}->{dc
});
1322 $ret->{FL2000DC_SERVER
} = $fl2000dc_ret->{SERVER
};
1323 $ret->{FL2000DC_SERVER_IP
} = $fl2000dc_ret->{SERVER_IP
};
1324 $ret->{FL2000DC_NETBIOSNAME
} = $fl2000dc_ret->{NETBIOSNAME
};
1325 $ret->{FL2000DC_USERNAME
} = $fl2000dc_ret->{USERNAME
};
1326 $ret->{FL2000DC_PASSWORD
} = $fl2000dc_ret->{PASSWORD
};
1328 if (not defined($self->{vars
}->{fl2003dc
})) {
1329 $ENV{ENVNAME
} = "fl2003dc";
1330 my $fl2003dc_ret = $self->setup_fl2003dc("$path/fl2003dc", $self->{vars
}->{dc
});
1332 $ret->{FL2003DC_SERVER
} = $fl2003dc_ret->{SERVER
};
1333 $ret->{FL2003DC_SERVER_IP
} = $fl2003dc_ret->{SERVER_IP
};
1334 $ret->{FL2003DC_NETBIOSNAME
} = $fl2003dc_ret->{NETBIOSNAME
};
1335 $ret->{FL2003DC_USERNAME
} = $fl2003dc_ret->{USERNAME
};
1336 $ret->{FL2003DC_PASSWORD
} = $fl2003dc_ret->{PASSWORD
};
1338 if (not defined($self->{vars
}->{fl2008r2dc
})) {
1339 $ENV{ENVNAME
} = "fl2008r2dc";
1340 my $fl2008r2dc_ret = $self->setup_fl2008r2dc("$path/fl2008r2dc", $self->{vars
}->{dc
});
1342 $ret->{FL2008R2DC_SERVER
} = $fl2008r2dc_ret->{SERVER
};
1343 $ret->{FL2008R2DC_SERVER_IP
} = $fl2008r2dc_ret->{SERVER_IP
};
1344 $ret->{FL2008R2DC_NETBIOSNAME
} = $fl2008r2dc_ret->{NETBIOSNAME
};
1345 $ret->{FL2008R2DC_USERNAME
} = $fl2008r2dc_ret->{USERNAME
};
1346 $ret->{FL2008R2DC_PASSWORD
} = $fl2008r2dc_ret->{PASSWORD
};
1348 if (not defined($self->{vars
}->{s3member
})) {
1349 $ENV{ENVNAME
} = "s3member";
1350 my $s3member_ret = $target3->setup_admember("$path/s3member", $self->{vars
}->{dc
}, 29);
1351 $self->{vars
}->{s3member
} = $s3member_ret;
1353 $ret->{S3MEMBER_SERVER
} = $s3member_ret->{SERVER
};
1354 $ret->{S3MEMBER_SERVER_IP
} = $s3member_ret->{SERVER_IP
};
1355 $ret->{S3MEMBER_NETBIOSNAME
} = $s3member_ret->{NETBIOSNAME
};
1356 $ret->{S3MEMBER_NETBIOSALIAS
} = $s3member_ret->{NETBIOSALIAS
};
1357 $ret->{S3MEMBER_USERNAME
} = $s3member_ret->{USERNAME
};
1358 $ret->{S3MEMBER_PASSWORD
} = $s3member_ret->{PASSWORD
};
1366 sub setup_member
($$$)
1368 my ($self, $path, $dc_vars) = @_;
1370 my $env = $self->provision_member($path, $dc_vars);
1373 $self->check_or_start($env);
1375 $self->wait_for_start($env);
1377 $self->{vars
}->{member
} = $env;
1383 sub setup_rpc_proxy
($$$)
1385 my ($self, $path, $dc_vars) = @_;
1387 my $env = $self->provision_rpc_proxy($path, $dc_vars);
1390 $self->check_or_start($env);
1392 $self->wait_for_start($env);
1394 $self->{vars
}->{rpc_proxy
} = $env;
1401 my ($self, $path) = @_;
1403 my $env = $self->provision_dc($path);
1405 $self->check_or_start($env);
1407 $self->wait_for_start($env);
1409 $self->{vars
}->{dc
} = $env;
1414 sub setup_fl2000dc
($$)
1416 my ($self, $path) = @_;
1418 my $env = $self->provision_fl2000dc($path);
1420 $self->check_or_start($env);
1422 $self->wait_for_start($env);
1424 $self->{vars
}->{fl2000dc
} = $env;
1430 sub setup_fl2003dc
($$)
1432 my ($self, $path) = @_;
1434 my $env = $self->provision_fl2003dc($path);
1437 $self->check_or_start($env);
1439 $self->wait_for_start($env);
1441 $self->{vars
}->{fl2003dc
} = $env;
1446 sub setup_fl2008r2dc
($$)
1448 my ($self, $path) = @_;
1450 my $env = $self->provision_fl2008r2dc($path);
1453 $self->check_or_start($env);
1455 $self->wait_for_start($env);
1457 $self->{vars
}->{fl2008r2dc
} = $env;
1463 sub setup_vampire_dc
($$$)
1465 my ($self, $path, $dc_vars) = @_;
1467 my $env = $self->provision_vampire_dc($path, $dc_vars);
1470 $self->check_or_start($env);
1472 $self->wait_for_start($env);
1474 $self->{vars
}->{vampire_dc
} = $env;
1476 # force replicated DC to update repsTo/repsFrom
1477 # for vampired partitions
1478 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
1480 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
1481 $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
1482 $cmd .= " $samba_tool drs kcc $env->{DC_SERVER}";
1483 $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD}";
1484 unless (system($cmd) == 0) {
1485 warn("Failed to exec kcc\n$cmd");
1489 # as 'vampired' dc may add data in its local replica
1490 # we need to synchronize data between DCs
1491 my $base_dn = "DC=".join(",DC=", split(/\./, $dc_vars->{REALM
}));
1492 $cmd = "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
1493 $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
1494 $cmd .= " $samba_tool drs replicate $env->{DC_SERVER} $env->{VAMPIRE_DC_SERVER}";
1495 $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD}";
1496 # replicate Configuration NC
1497 my $cmd_repl = "$cmd \"CN=Configuration,$base_dn\"";
1498 unless(system($cmd_repl) == 0) {
1499 warn("Failed to replicate\n$cmd_repl");
1502 # replicate Default NC
1503 $cmd_repl = "$cmd \"$base_dn\"";
1504 unless(system($cmd_repl) == 0) {
1505 warn("Failed to replicate\n$cmd_repl");
1515 my ($self, $path, $dc_vars) = @_;
1517 my $env = $self->provision_rodc($path, $dc_vars);
1523 $self->check_or_start($env);
1525 $self->wait_for_start($env);
1527 $self->{vars
}->{rodc
} = $env;
1532 sub setup_plugin_s4_dc
($$)
1534 my ($self, $path) = @_;
1536 my $env = $self->provision_plugin_s4_dc($path);
1538 $self->check_or_start($env);
1540 $self->wait_for_start($env);
1542 my $s3_part_env = $self->{target3
}->setup_plugin_s4_dc($path, $env, 30);
1543 if (not defined($s3_part_env)) {
1547 $self->{vars
}->{plugin_s4_dc
} = $s3_part_env;