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);
15 my ($classname, $bindir, $ldap, $setupdir, $exeext) = @_;
16 $exeext = "" unless defined($exeext);
21 setupdir => $setupdir,
29 my ($self, $path) = @_;
31 my $valpath = "$self->{bindir}/$path$self->{exeext}";
33 return $valpath if (-f $valpath);
37 sub openldap_start($$$) {
43 my ($self, $env_vars) = @_;
44 my $ldbsearch = $self->bindir_path("ldbsearch");
46 my $uri = $env_vars->{LDAP_URI};
48 if (system("$ldbsearch -H $uri -s base -b \"\" supportedLDAPVersion > /dev/null") == 0) {
49 print "A SLAPD is still listening to $uri before we started the LDAP backend. Aborting!";
52 # running slapd in the background means it stays in the same process group, so it can be
54 if ($self->{ldap} eq "fedora-ds") {
55 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 &");
56 } elsif ($self->{ldap} eq "openldap") {
57 system("$ENV{OPENLDAP_SLAPD} -d0 -F $env_vars->{SLAPD_CONF_D} -h $uri > $env_vars->{LDAPDIR}/logs 2>&1 &");
59 while (system("$ldbsearch -H $uri -s base -b \"\" supportedLDAPVersion > /dev/null") != 0) {
62 $self->slapd_stop($env_vars);
72 my ($self, $envvars) = @_;
73 if ($self->{ldap} eq "fedora-ds") {
74 system("$envvars->{LDAPDIR}/slapd-$envvars->{LDAP_INSTANCE}/stop-slapd");
75 } elsif ($self->{ldap} eq "openldap") {
76 unless (open(IN, "<$envvars->{OPENLDAP_PIDFILE}")) {
77 warn("unable to open slapd pid file: $envvars->{OPENLDAP_PIDFILE}");
86 sub check_or_start($$$)
88 my ($self, $env_vars, $max_time) = @_;
89 return 0 if ( -p $env_vars->{SAMBA_TEST_FIFO});
91 unlink($env_vars->{SAMBA_TEST_FIFO});
92 POSIX::mkfifo($env_vars->{SAMBA_TEST_FIFO}, 0700);
93 unlink($env_vars->{SAMBA_TEST_LOG});
96 print "STARTING SAMBA for $ENV{ENVNAME}\n";
99 open STDIN, $env_vars->{SAMBA_TEST_FIFO};
100 # we want out from samba to go to the log file, but also
101 # to the users terminal when running 'make test' on the command
102 # line. This puts it on stderr on the terminal
103 open STDOUT, "| tee $env_vars->{SAMBA_TEST_LOG} 1>&2";
104 open STDERR, '>&STDOUT';
106 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
109 if (defined($ENV{SAMBA_VALGRIND})) {
110 $valgrind = $ENV{SAMBA_VALGRIND};
113 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
114 $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR};
116 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
117 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
119 $ENV{UID_WRAPPER} = "1";
121 # Start slapd before samba, but with the fifo on stdin
122 if (defined($self->{ldap})) {
123 unless($self->slapd_start($env_vars)) {
124 warn("couldn't start slapd (main run)");
130 if (defined($max_time)) {
131 $optarg = "--maximum-runtime=$max_time ";
133 if (defined($ENV{SAMBA_OPTIONS})) {
134 $optarg.= " $ENV{SAMBA_OPTIONS}";
136 my $samba = $self->bindir_path("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 = $self->bindir_path("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->{NETBIOSALIAS}");
190 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSALIAS}");
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->{NETBIOSALIAS}");
196 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSALIAS}");
198 print $self->getlog_env($testenv_vars);
201 sub write_ldb_file($$$)
203 my ($self, $file, $ldif) = @_;
205 my $ldbadd = $self->bindir_path("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, $netbiosalias,
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->{netbiosalias
} = $netbiosalias;
485 $ctx->{swiface
} = $swiface;
486 $ctx->{password
} = $password;
487 $ctx->{kdc_ipv4
} = $kdc_ipv4;
489 $ctx->{server_loglevel
} =$ENV{SERVER_LOG_LEVEL
} || 1;
490 $ctx->{username
} = "Administrator";
491 $ctx->{domain
} = $domain;
492 $ctx->{realm
} = uc($realm);
493 $ctx->{dnsname
} = lc($realm);
494 $ctx->{sid_generator
} = "internal";
496 $ctx->{functional_level
} = $functional_level;
498 my $unix_name = ($ENV{USER
} or $ENV{LOGNAME
} or `whoami`);
500 $ctx->{unix_name
} = $unix_name;
501 $ctx->{unix_uid
} = $>;
502 $ctx->{unix_gids_str
} = $);
503 @
{$ctx->{unix_gids
}} = split(" ", $ctx->{unix_gids_str
});
505 $ctx->{etcdir
} = "$prefix_abs/etc";
506 $ctx->{piddir
} = "$prefix_abs/pid";
507 $ctx->{smb_conf
} = "$ctx->{etcdir}/smb.conf";
508 $ctx->{krb5_conf
} = "$ctx->{etcdir}/krb5.conf";
509 $ctx->{privatedir
} = "$prefix_abs/private";
510 $ctx->{ncalrpcdir
} = "$prefix_abs/ncalrpc";
511 $ctx->{lockdir
} = "$prefix_abs/lockdir";
512 $ctx->{winbindd_socket_dir
} = "$prefix_abs/winbindd_socket";
513 $ctx->{winbindd_privileged_socket_dir
} = "$prefix_abs/winbindd_privileged_socket";
514 $ctx->{ntp_signd_socket_dir
} = "$prefix_abs/ntp_signd_socket";
515 $ctx->{nsswrap_passwd
} = "$ctx->{etcdir}/passwd";
516 $ctx->{nsswrap_group
} = "$ctx->{etcdir}/group";
518 $ctx->{tlsdir
} = "$ctx->{privatedir}/tls";
520 $ctx->{ipv4
} = "127.0.0.$swiface";
521 $ctx->{interfaces
} = "$ctx->{ipv4}/8";
523 push(@
{$ctx->{directories
}}, $ctx->{privatedir
});
524 push(@
{$ctx->{directories
}}, $ctx->{etcdir
});
525 push(@
{$ctx->{directories
}}, $ctx->{piddir
});
526 push(@
{$ctx->{directories
}}, $ctx->{ncalrpcdir
});
527 push(@
{$ctx->{directories
}}, $ctx->{lockdir
});
529 $ctx->{smb_conf_extra_options
} = "";
531 my @provision_options = ();
532 push (@provision_options, "NSS_WRAPPER_PASSWD=\"$ctx->{nsswrap_passwd}\"");
533 push (@provision_options, "NSS_WRAPPER_GROUP=\"$ctx->{nsswrap_group}\"");
534 if (defined($ENV{GDB_PROVISION
})) {
535 push (@provision_options, "gdb --args");
536 if (!defined($ENV{PYTHON
})) {
537 push (@provision_options, "env");
538 push (@provision_options, "python");
541 if (defined($ENV{VALGRIND_PROVISION
})) {
542 push (@provision_options, "valgrind");
543 if (!defined($ENV{PYTHON
})) {
544 push (@provision_options, "env");
545 push (@provision_options, "python");
548 if (defined($ENV{PYTHON
})) {
549 push (@provision_options, $ENV{PYTHON
});
551 push (@provision_options, "$self->{setupdir}/provision");
552 push (@provision_options, "--configfile=$ctx->{smb_conf}");
553 push (@provision_options, "--host-name=$ctx->{netbiosname}");
554 push (@provision_options, "--host-ip=$ctx->{ipv4}");
555 push (@provision_options, "--quiet");
556 push (@provision_options, "--domain=$ctx->{domain}");
557 push (@provision_options, "--realm=$ctx->{realm}");
558 push (@provision_options, "--adminpass=$ctx->{password}");
559 push (@provision_options, "--krbtgtpass=krbtgt$ctx->{password}");
560 push (@provision_options, "--machinepass=machine$ctx->{password}");
561 push (@provision_options, "--root=$ctx->{unix_name}");
562 push (@provision_options, "--server-role=\"$ctx->{server_role}\"");
563 push (@provision_options, "--function-level=\"$ctx->{functional_level}\"");
565 @
{$ctx->{provision_options
}} = @provision_options;
571 # Step1 creates the basic configuration
573 sub provision_raw_step1
($$)
575 my ($self, $ctx) = @_;
577 mkdir($_, 0777) foreach (@
{$ctx->{directories
}});
579 unless (open(CONFFILE
, ">$ctx->{smb_conf}")) {
580 warn("can't open $ctx->{smb_conf}$?");
585 netbios name = $ctx->{netbiosname}
586 netbios aliases = $ctx->{netbiosalias}
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 setup directory = $self->{setupdir}
595 winbindd socket directory = $ctx->{winbindd_socket_dir}
596 winbindd privileged socket directory = $ctx->{winbindd_privileged_socket_dir}
597 ntp signd socket directory = $ctx->{ntp_signd_socket_dir}
598 winbind separator = /
599 name resolve order = file bcast
600 interfaces = $ctx->{interfaces}
601 tls dh params file = $ctx->{tlsdir}/dhparms.pem
602 panic action = $RealBin/gdb_backtrace \%PID% \%PROG%
604 server role = $ctx->{server_role}
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}/scripting/bin/samba_dnsupdate --all-interfaces --use-file=$ctx->{dns_host_file}
613 spn update command = $ENV{SRCDIR_ABS}/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 unless (open(KRB5CONF
, ">$ctx->{krb5_conf}")) {
634 warn("can't open $ctx->{krb5_conf}$?");
638 #Generated krb5.conf for $ctx->{realm}
641 default_realm = $ctx->{realm}
642 dns_lookup_realm = false
643 dns_lookup_kdc = false
644 ticket_lifetime = 24h
646 allow_weak_crypto = yes
650 kdc = $ctx->{kdc_ipv4}:88
651 admin_server = $ctx->{kdc_ipv4}:88
652 default_domain = $ctx->{dnsname}
655 kdc = $ctx->{kdc_ipv4}:88
656 admin_server = $ctx->{kdc_ipv4}:88
657 default_domain = $ctx->{dnsname}
660 kdc = $ctx->{kdc_ipv4}:88
661 admin_server = $ctx->{kdc_ipv4}:88
662 default_domain = $ctx->{dnsname}
666 pkinit_anchors = FILE:$ctx->{tlsdir}/ca.pem
670 pkinit_identity = FILE:$ctx->{tlsdir}/kdc.pem,$ctx->{tlsdir}/key.pem
671 pkinit_anchors = FILE:$ctx->{tlsdir}/ca.pem
674 .$ctx->{dnsname} = $ctx->{realm}
678 open(PWD
, ">$ctx->{nsswrap_passwd}");
680 root:x:0:0:root gecos:$ctx->{prefix_abs}:/bin/false
681 $ctx->{unix_name}:x:$ctx->{unix_uid}:@{$ctx->{unix_gids}}[0]:$ctx->{unix_name} gecos:$ctx->{prefix_abs}:/bin/false
682 nobody:x:65534:65533:nobody gecos:$ctx->{prefix_abs}:/bin/false
686 open(GRP
, ">$ctx->{nsswrap_group}");
692 nogroup:x:65534:nobody
696 my $configuration = "--configfile=$ctx->{smb_conf}";
698 #Ensure the config file is valid before we start
699 my $testparm = $self->bindir_path("../scripting/bin/testparm");
700 if (system("$testparm $configuration -v --suppress-prompt >/dev/null 2>&1") != 0) {
701 system("$testparm -v --suppress-prompt $configuration >&2");
702 warn("Failed to create a valid smb.conf configuration $testparm!");
705 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) {
706 warn("Failed to create a valid smb.conf configuration! $testparm $configuration -v --suppress-prompt --parameter-name=\"netbios name\" --section-name=global");
711 KRB5_CONFIG
=> $ctx->{krb5_conf
},
712 PIDDIR
=> $ctx->{piddir
},
713 SERVER
=> $ctx->{netbiosname
},
714 SERVER_IP
=> $ctx->{ipv4
},
715 NETBIOSNAME
=> $ctx->{netbiosname
},
716 NETBIOSALIAS
=> $ctx->{netbiosalias
},
717 DOMAIN
=> $ctx->{domain
},
718 USERNAME
=> $ctx->{username
},
719 REALM
=> $ctx->{realm
},
720 PASSWORD
=> $ctx->{password
},
721 LDAPDIR
=> $ctx->{ldapdir
},
722 LDAP_INSTANCE
=> $ctx->{ldap_instance
},
723 WINBINDD_SOCKET_DIR
=> $ctx->{winbindd_socket_dir
},
724 NCALRPCDIR
=> $ctx->{ncalrpcdir
},
725 LOCKDIR
=> $ctx->{lockdir
},
726 SERVERCONFFILE
=> $ctx->{smb_conf
},
727 CONFIGURATION
=> $configuration,
728 SOCKET_WRAPPER_DEFAULT_IFACE
=> $ctx->{swiface
},
729 NSS_WRAPPER_PASSWD
=> $ctx->{nsswrap_passwd
},
730 NSS_WRAPPER_GROUP
=> $ctx->{nsswrap_group
},
731 SAMBA_TEST_FIFO
=> "$ctx->{prefix}/samba_test.fifo",
732 SAMBA_TEST_LOG
=> "$ctx->{prefix}/samba_test.log",
733 SAMBA_TEST_LOG_POS
=> 0,
740 # Step2 runs the provision script
742 sub provision_raw_step2
($$$)
744 my ($self, $ctx, $ret) = @_;
746 my $provision_cmd = join(" ", @
{$ctx->{provision_options
}});
747 unless (system($provision_cmd) == 0) {
748 warn("Unable to provision: \n$provision_cmd\n");
755 sub provision
($$$$$$$$$)
757 my ($self, $prefix, $server_role, $netbiosname, $netbiosalias,
758 $domain, $realm, $functional_level,
759 $swiface, $password, $kdc_ipv4, $extra_smbconf_options) = @_;
761 my $ctx = $self->provision_raw_prepare($prefix, $server_role,
762 $netbiosname, $netbiosalias,
763 $domain, $realm, $functional_level,
764 $swiface, $password, $kdc_ipv4);
766 $ctx->{tmpdir
} = "$ctx->{prefix_abs}/tmp";
767 push(@
{$ctx->{directories
}}, "$ctx->{tmpdir}");
768 push(@
{$ctx->{directories
}}, "$ctx->{tmpdir}/test1");
769 push(@
{$ctx->{directories
}}, "$ctx->{tmpdir}/test2");
771 $msdfs = "yes" if ($server_role eq "domain controller");
772 $ctx->{smb_conf_extra_options
} = "
775 server max protocol = SMB2
776 $extra_smbconf_options
781 path = $ctx->{tmpdir}
783 posix:sharedelay = 10000
784 posix:oplocktimeout = 3
785 posix:writetimeupdatedelay = 500000
788 path = $ctx->{tmpdir}/test1
790 posix:sharedelay = 10000
791 posix:oplocktimeout = 3
792 posix:writetimeupdatedelay = 50000
795 path = $ctx->{tmpdir}/test2
797 posix:sharedelay = 10000
798 posix:oplocktimeout = 3
799 posix:writetimeupdatedelay = 50000
804 cifs:server = $ctx->{netbiosname}
806 #There is no username specified here, instead the client is expected
807 #to log in with kerberos, and the serverwill use delegated credentials.
810 path = $ctx->{tmpdir}
812 ntvfs handler = simple
815 path = $ctx->{lockdir}/sysvol
819 path = $ctx->{lockdir}/sysvol/$ctx->{dnsname}/scripts
824 ntvfs handler = cifsposix
827 if (defined($self->{ldap
})) {
828 $ctx->{ldapdir
} = "$ctx->{privatedir}/ldap";
829 push(@
{$ctx->{directories
}}, "$ctx->{ldapdir}");
831 my $ldap_uri= "$ctx->{ldapdir}/ldapi";
832 $ldap_uri =~ s
|/|%2F|g
;
833 $ldap_uri = "ldapi://$ldap_uri";
834 $ctx->{ldap_uri
} = $ldap_uri;
835 if ($self->{ldap
} eq "fedora-ds") {
836 $ctx->{sid_generator
} = "backend";
839 $ctx->{ldap_instance
} = lc($ctx->{netbiosname
});
842 my $ret = $self->provision_raw_step1($ctx);
843 unless (defined $ret) {
847 if (defined($self->{ldap
})) {
848 $ret->{LDAP_URI
} = $ctx->{ldap_uri
};
849 push (@
{$ctx->{provision_options
}}, "--ldap-backend-type=" . $self->{ldap
});
850 push (@
{$ctx->{provision_options
}}, "--ldap-backend-nosync");
851 if ($self->{ldap
} eq "openldap") {
852 push (@
{$ctx->{provision_options
}}, "--slapd-path=" . $ENV{OPENLDAP_SLAPD
});
853 ($ret->{SLAPD_CONF_D
}, $ret->{OPENLDAP_PIDFILE
}) = $self->mk_openldap($ctx) or die("Unable to create openldap directories");
855 } elsif ($self->{ldap
} eq "fedora-ds") {
856 push (@
{$ctx->{provision_options
}}, "--slapd-path=" . "$ENV{FEDORA_DS_ROOT}/sbin/ns-slapd");
857 push (@
{$ctx->{provision_options
}}, "--setup-ds-path=" . "$ENV{FEDORA_DS_ROOT}/sbin/setup-ds.pl");
858 ($ret->{FEDORA_DS_DIR
}, $ret->{FEDORA_DS_PIDFILE
}) = $self->mk_fedora_ds($ctx) or die("Unable to create fedora ds directories");
863 return $self->provision_raw_step2($ctx, $ret);
866 sub provision_member
($$$)
868 my ($self, $prefix, $dcvars) = @_;
869 print "PROVISIONING MEMBER...";
871 my $ret = $self->provision($prefix,
880 $dcvars->{SERVER_IP
},
886 my $samba_tool = $self->bindir_path("samba-tool");
888 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
889 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
890 $cmd .= "$samba_tool join $ret->{CONFIGURATION} $dcvars->{REALM} member";
891 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
893 unless (system($cmd) == 0) {
894 warn("Join failed\n$cmd");
898 $ret->{MEMBER_SERVER
} = $ret->{SERVER
};
899 $ret->{MEMBER_SERVER_IP
} = $ret->{SERVER_IP
};
900 $ret->{MEMBER_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
901 $ret->{MEMBER_NETBIOSALIAS
} = $ret->{NETBIOSALIAS
};
902 $ret->{MEMBER_USERNAME
} = $ret->{USERNAME
};
903 $ret->{MEMBER_PASSWORD
} = $ret->{PASSWORD
};
905 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
906 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
907 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
908 $ret->{DC_NETBIOSALIAS
} = $dcvars->{DC_NETBIOSALIAS
};
909 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
910 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
915 sub provision_rpc_proxy
($$$)
917 my ($self, $prefix, $dcvars) = @_;
918 print "PROVISIONING RPC PROXY...";
920 my $extra_smbconf_options = "dcerpc_remote:binding = ncacn_ip_tcp:localdc
921 dcerpc endpoint servers = epmapper, remote
922 dcerpc_remote:interfaces = rpcecho
925 my $ret = $self->provision($prefix,
934 $dcvars->{SERVER_IP
},
935 $extra_smbconf_options);
941 my $samba_tool = $self->bindir_path("samba-tool");
943 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
944 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
945 $cmd .= "$samba_tool join $ret->{CONFIGURATION} $dcvars->{REALM} member";
946 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
948 unless (system($cmd) == 0) {
949 warn("Join failed\n$cmd");
953 $ret->{RPC_PROXY_SERVER
} = $ret->{SERVER
};
954 $ret->{RPC_PROXY_SERVER_IP
} = $ret->{SERVER_IP
};
955 $ret->{RPC_PROXY_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
956 $ret->{RPC_PROXY_NETBIOSALIAS
} = $ret->{NETBIOSALIAS
};
957 $ret->{RPC_PROXY_USERNAME
} = $ret->{USERNAME
};
958 $ret->{RPC_PROXY_PASSWORD
} = $ret->{PASSWORD
};
963 sub provision_vampire_dc
($$$)
965 my ($self, $prefix, $dcvars) = @_;
966 print "PROVISIONING VAMPIRE DC...";
968 # We do this so that we don't run the provision. That's the job of 'net vampire'.
969 my $ctx = $self->provision_raw_prepare($prefix, "domain controller",
975 2, $dcvars->{PASSWORD
},
976 $dcvars->{SERVER_IP
});
978 $ctx->{smb_conf_extra_options
} = "
980 server max protocol = SMB2
983 path = $ctx->{lockdir}/sysvol
987 path = $ctx->{lockdir}/sysvol/$ctx->{dnsname}/scripts
992 my $ret = $self->provision_raw_step1($ctx);
997 my $samba_tool = $self->bindir_path("samba-tool");
999 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1000 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1001 $cmd .= "$samba_tool join $ret->{CONFIGURATION} $dcvars->{REALM} DC --realm=$dcvars->{REALM}";
1002 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
1004 unless (system($cmd) == 0) {
1005 warn("Join failed\n$cmd");
1009 $ret->{VAMPIRE_DC_SERVER
} = $ret->{SERVER
};
1010 $ret->{VAMPIRE_DC_SERVER_IP
} = $ret->{SERVER_IP
};
1011 $ret->{VAMPIRE_DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1012 $ret->{VAMPIRE_DC_NETBIOSALIAS
} = $ret->{NETBIOSALIAS
};
1014 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
1015 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
1016 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
1017 $ret->{DC_NETBIOSALIAS
} = $dcvars->{DC_NETBIOSALIAS
};
1018 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
1019 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
1024 sub provision_dc
($$)
1026 my ($self, $prefix) = @_;
1028 print "PROVISIONING DC...";
1029 my $ret = $self->provision($prefix,
1030 "domain controller",
1034 "samba.example.com",
1040 return undef unless(defined $ret);
1041 unless($self->add_wins_config("$prefix/private")) {
1042 warn("Unable to add wins configuration");
1046 $ret->{DC_SERVER
} = $ret->{SERVER
};
1047 $ret->{DC_SERVER_IP
} = $ret->{SERVER_IP
};
1048 $ret->{DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1049 $ret->{DC_NETBIOSALIAS
} = $ret->{NETBIOSALIAS
};
1050 $ret->{DC_USERNAME
} = $ret->{USERNAME
};
1051 $ret->{DC_PASSWORD
} = $ret->{PASSWORD
};
1056 sub provision_fl2000dc
($$)
1058 my ($self, $prefix) = @_;
1060 print "PROVISIONING DC...";
1061 my $ret = $self->provision($prefix,
1062 "domain controller",
1066 "samba2000.example.com",
1072 unless($self->add_wins_config("$prefix/private")) {
1073 warn("Unable to add wins configuration");
1080 sub provision_fl2003dc
($$)
1082 my ($self, $prefix) = @_;
1084 print "PROVISIONING DC...";
1085 my $ret = $self->provision($prefix,
1086 "domain controller",
1090 "samba2003.example.com",
1096 unless($self->add_wins_config("$prefix/private")) {
1097 warn("Unable to add wins configuration");
1104 sub provision_fl2008r2dc
($$)
1106 my ($self, $prefix) = @_;
1108 print "PROVISIONING DC...";
1109 my $ret = $self->provision($prefix,
1110 "domain controller",
1114 "samba2008R2.example.com",
1120 unless ($self->add_wins_config("$prefix/private")) {
1121 warn("Unable to add wins configuration");
1129 sub provision_rodc
($$$)
1131 my ($self, $prefix, $dcvars) = @_;
1132 print "PROVISIONING RODC...";
1134 # We do this so that we don't run the provision. That's the job of 'net join RODC'.
1135 my $ctx = $self->provision_raw_prepare($prefix, "domain controller",
1139 "samba.example.com",
1141 8, $dcvars->{PASSWORD
},
1142 $dcvars->{SERVER_IP
});
1147 $ctx->{tmpdir
} = "$ctx->{prefix_abs}/tmp";
1148 push(@
{$ctx->{directories
}}, "$ctx->{tmpdir}");
1150 $ctx->{smb_conf_extra_options
} = "
1152 server max protocol = SMB2
1155 path = $ctx->{lockdir}/sysvol
1159 path = $ctx->{lockdir}/sysvol/$ctx->{dnsname}/scripts
1163 path = $ctx->{tmpdir}
1165 posix:sharedelay = 10000
1166 posix:oplocktimeout = 3
1167 posix:writetimeupdatedelay = 500000
1171 my $ret = $self->provision_raw_step1($ctx);
1176 my $samba_tool = $self->bindir_path("samba-tool");
1178 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1179 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1180 $cmd .= "$samba_tool join $ret->{CONFIGURATION} $dcvars->{REALM} RODC";
1181 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
1182 $cmd .= " --server=$dcvars->{DC_SERVER}";
1184 unless (system($cmd) == 0) {
1185 warn("RODC join failed\n$cmd");
1189 $ret->{RODC_DC_SERVER
} = $ret->{SERVER
};
1190 $ret->{RODC_DC_SERVER_IP
} = $ret->{SERVER_IP
};
1191 $ret->{RODC_DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1192 $ret->{RODC_DC_NETBIOSALIAS
} = $ret->{NETBIOSALIAS
};
1194 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
1195 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
1196 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
1197 $ret->{DC_NETBIOSALIAS
} = $dcvars->{DC_NETBIOSALIAS
};
1198 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
1199 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
1204 sub teardown_env
($$)
1206 my ($self, $envvars) = @_;
1211 if (open(IN
, "<$envvars->{PIDDIR}/samba.pid")) {
1215 # Give the process 20 seconds to exit. gcov needs
1216 # this time to write out the covarge data
1218 until (kill(0, $pid) == 0) {
1219 # if no process sucessfully signalled, then we are done
1222 last if $count > 20;
1225 # If it is still around, kill it
1227 print "server process $pid took more than $count seconds to exit, killing\n";
1232 my $failed = $?
>> 8;
1234 $self->slapd_stop($envvars) if ($self->{ldap
});
1236 print $self->getlog_env($envvars);
1243 my ($self, $envvars) = @_;
1244 my $title = "SAMBA LOG of: $envvars->{NETBIOSNAME}\n";
1247 open(LOG
, "<$envvars->{SAMBA_TEST_LOG}");
1249 seek(LOG
, $envvars->{SAMBA_TEST_LOG_POS
}, SEEK_SET
);
1253 $envvars->{SAMBA_TEST_LOG_POS
} = tell(LOG
);
1256 return "" if $out eq $title;
1263 my ($self, $envvars) = @_;
1265 return (-p
$envvars->{SAMBA_TEST_FIFO
});
1270 my ($self, $envname, $path) = @_;
1272 $ENV{ENVNAME
} = $envname;
1274 if ($envname eq "dc") {
1275 return $self->setup_dc("$path/dc");
1276 } elsif ($envname eq "fl2000dc") {
1277 return $self->setup_fl2000dc("$path/fl2000dc");
1278 } elsif ($envname eq "fl2003dc") {
1279 return $self->setup_fl2003dc("$path/fl2003dc");
1280 } elsif ($envname eq "fl2008r2dc") {
1281 return $self->setup_fl2008r2dc("$path/fl2008r2dc");
1282 } elsif ($envname eq "rpc_proxy") {
1283 if (not defined($self->{vars
}->{dc
})) {
1284 $self->setup_dc("$path/dc");
1286 return $self->setup_rpc_proxy("$path/rpc_proxy", $self->{vars
}->{dc
});
1287 } elsif ($envname eq "vampire_dc") {
1288 if (not defined($self->{vars
}->{dc
})) {
1289 $self->setup_dc("$path/dc");
1291 return $self->setup_vampire_dc("$path/vampire_dc", $self->{vars
}->{dc
});
1292 } elsif ($envname eq "member") {
1293 if (not defined($self->{vars
}->{dc
})) {
1294 $self->setup_dc("$path/dc");
1296 return $self->setup_member("$path/member", $self->{vars
}->{dc
});
1297 } elsif ($envname eq "rodc") {
1298 if (not defined($self->{vars
}->{dc
})) {
1299 $self->setup_dc("$path/dc");
1301 return $self->setup_rodc("$path/rodc", $self->{vars
}->{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/member", $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_NETBIOSALIAS
} = $rpc_proxy_ret->{NETBIOSALIAS
};
1316 $ret->{RPC_PROXY_USERNAME
} = $rpc_proxy_ret->{USERNAME
};
1317 $ret->{RPC_PROXY_PASSWORD
} = $rpc_proxy_ret->{PASSWORD
};
1319 if (not defined($self->{vars
}->{fl2000dc
})) {
1320 $ENV{ENVNAME
} = "fl2000dc";
1321 my $fl2000dc_ret = $self->setup_fl2000dc("$path/fl2000dc", $self->{vars
}->{dc
});
1323 $ret->{FL2000DC_SERVER
} = $fl2000dc_ret->{SERVER
};
1324 $ret->{FL2000DC_SERVER_IP
} = $fl2000dc_ret->{SERVER_IP
};
1325 $ret->{FL2000DC_NETBIOSNAME
} = $fl2000dc_ret->{NETBIOSNAME
};
1326 $ret->{FL2000DC_NETBIOSALIAS
} = $fl2000dc_ret->{NETBIOSALIAS
};
1327 $ret->{FL2000DC_USERNAME
} = $fl2000dc_ret->{USERNAME
};
1328 $ret->{FL2000DC_PASSWORD
} = $fl2000dc_ret->{PASSWORD
};
1330 if (not defined($self->{vars
}->{fl2003dc
})) {
1331 $ENV{ENVNAME
} = "fl2003dc";
1332 my $fl2003dc_ret = $self->setup_fl2003dc("$path/fl2003dc", $self->{vars
}->{dc
});
1334 $ret->{FL2003DC_SERVER
} = $fl2003dc_ret->{SERVER
};
1335 $ret->{FL2003DC_SERVER_IP
} = $fl2003dc_ret->{SERVER_IP
};
1336 $ret->{FL2003DC_NETBIOSNAME
} = $fl2003dc_ret->{NETBIOSNAME
};
1337 $ret->{FL2003DC_NETBIOSALIAS
} = $fl2003dc_ret->{NETBIOSALIAS
};
1338 $ret->{FL2003DC_USERNAME
} = $fl2003dc_ret->{USERNAME
};
1339 $ret->{FL2003DC_PASSWORD
} = $fl2003dc_ret->{PASSWORD
};
1341 if (not defined($self->{vars
}->{fl2008r2dc
})) {
1342 $ENV{ENVNAME
} = "fl2008r2dc";
1343 my $fl2008r2dc_ret = $self->setup_fl2008r2dc("$path/fl2008r2dc", $self->{vars
}->{dc
});
1345 $ret->{FL2008R2DC_SERVER
} = $fl2008r2dc_ret->{SERVER
};
1346 $ret->{FL2008R2DC_SERVER_IP
} = $fl2008r2dc_ret->{SERVER_IP
};
1347 $ret->{FL2008R2DC_NETBIOSNAME
} = $fl2008r2dc_ret->{NETBIOSNAME
};
1348 $ret->{FL2008R2DC_NETBIOSALIAS
} = $fl2008r2dc_ret->{NETBIOSALIAS
};
1349 $ret->{FL2008R2DC_USERNAME
} = $fl2008r2dc_ret->{USERNAME
};
1350 $ret->{FL2008R2DC_PASSWORD
} = $fl2008r2dc_ret->{PASSWORD
};
1354 warn("Samba4 can't provide environment '$envname'");
1359 sub setup_member
($$$)
1361 my ($self, $path, $dc_vars) = @_;
1363 my $env = $self->provision_member($path, $dc_vars);
1366 $self->check_or_start($env, ($ENV{SMBD_MAXTIME
} or 7500));
1368 $self->wait_for_start($env);
1370 $self->{vars
}->{member
} = $env;
1376 sub setup_rpc_proxy
($$$)
1378 my ($self, $path, $dc_vars) = @_;
1380 my $env = $self->provision_rpc_proxy($path, $dc_vars);
1383 $self->check_or_start($env, ($ENV{SMBD_MAXTIME
} or 7500));
1385 $self->wait_for_start($env);
1387 $self->{vars
}->{rpc_proxy
} = $env;
1394 my ($self, $path) = @_;
1396 my $env = $self->provision_dc($path);
1398 $self->check_or_start($env,
1399 ($ENV{SMBD_MAXTIME
} or 7500));
1401 $self->wait_for_start($env);
1403 $self->{vars
}->{dc
} = $env;
1408 sub setup_fl2000dc
($$)
1410 my ($self, $path) = @_;
1412 my $env = $self->provision_fl2000dc($path);
1414 $self->check_or_start($env,
1415 ($ENV{SMBD_MAXTIME
} or 7500));
1417 $self->wait_for_start($env);
1419 $self->{vars
}->{fl2000dc
} = $env;
1425 sub setup_fl2003dc
($$)
1427 my ($self, $path) = @_;
1429 my $env = $self->provision_fl2003dc($path);
1432 $self->check_or_start($env,
1433 ($ENV{SMBD_MAXTIME
} or 7500));
1435 $self->wait_for_start($env);
1437 $self->{vars
}->{fl2003dc
} = $env;
1442 sub setup_fl2008r2dc
($$)
1444 my ($self, $path) = @_;
1446 my $env = $self->provision_fl2008r2dc($path);
1449 $self->check_or_start($env,
1450 ($ENV{SMBD_MAXTIME
} or 7500));
1452 $self->wait_for_start($env);
1454 $self->{vars
}->{fl2008r2dc
} = $env;
1460 sub setup_vampire_dc
($$$)
1462 my ($self, $path, $dc_vars) = @_;
1464 my $env = $self->provision_vampire_dc($path, $dc_vars);
1467 $self->check_or_start($env,
1468 ($ENV{SMBD_MAXTIME
} or 7500));
1470 $self->wait_for_start($env);
1472 $self->{vars
}->{vampire_dc
} = $env;
1474 # force replicated DC to update repsTo/repsFrom
1475 # for vampired partitions
1476 my $samba_tool = $self->bindir_path("samba-tool");
1478 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
1479 $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
1480 $cmd .= " $samba_tool drs kcc $env->{DC_SERVER}";
1481 $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD}";
1482 unless (system($cmd) == 0) {
1483 warn("Failed to exec kcc\n$cmd");
1487 # as 'vampired' dc may add data in its local replica
1488 # we need to synchronize data between DCs
1489 my $base_dn = "DC=".join(",DC=", split(/\./, $dc_vars->{REALM
}));
1490 $cmd = "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
1491 $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
1492 $cmd .= " $samba_tool drs replicate $env->{DC_SERVER} $env->{VAMPIRE_DC_SERVER}";
1493 $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD}";
1494 # replicate Configuration NC
1495 my $cmd_repl = "$cmd \"CN=Configuration,$base_dn\"";
1496 unless(system($cmd_repl) == 0) {
1497 warn("Failed to replicate\n$cmd_repl");
1500 # replicate Default NC
1501 $cmd_repl = "$cmd \"$base_dn\"";
1502 unless(system($cmd_repl) == 0) {
1503 warn("Failed to replicate\n$cmd_repl");
1513 my ($self, $path, $dc_vars) = @_;
1515 my $env = $self->provision_rodc($path, $dc_vars);
1521 $self->check_or_start($env,
1522 ($ENV{SMBD_MAXTIME
} or 7500));
1524 $self->wait_for_start($env);
1526 $self->{vars
}->{rodc
} = $env;