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);
14 my ($classname, $bindir, $ldap, $setupdir, $exeext) = @_;
15 $exeext = "" unless defined($exeext);
20 setupdir => $setupdir,
28 my ($self, $path) = @_;
30 return "$self->{bindir}/$path$self->{exeext}";
33 sub openldap_start($$$) {
39 my ($self, $env_vars) = @_;
40 my $ldbsearch = $self->bindir_path("ldbsearch");
42 my $uri = $env_vars->{LDAP_URI};
44 if (system("$ldbsearch -H $uri -s base -b \"\" supportedLDAPVersion > /dev/null") == 0) {
45 print "A SLAPD is still listening to $uri before we started the LDAP backend. Aborting!";
48 # running slapd in the background means it stays in the same process group, so it can be
50 if ($self->{ldap} eq "fedora-ds") {
51 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 &");
52 } elsif ($self->{ldap} eq "openldap") {
53 system("$ENV{OPENLDAP_SLAPD} -d0 -F $env_vars->{SLAPD_CONF_D} -h $uri > $env_vars->{LDAPDIR}/logs 2>&1 &");
55 while (system("$ldbsearch -H $uri -s base -b \"\" supportedLDAPVersion > /dev/null") != 0) {
58 $self->slapd_stop($env_vars);
68 my ($self, $envvars) = @_;
69 if ($self->{ldap} eq "fedora-ds") {
70 system("$envvars->{LDAPDIR}/slapd-$envvars->{LDAP_INSTANCE}/stop-slapd");
71 } elsif ($self->{ldap} eq "openldap") {
72 unless (open(IN, "<$envvars->{OPENLDAP_PIDFILE}")) {
73 warn("unable to open slapd pid file: $envvars->{OPENLDAP_PIDFILE}");
82 sub check_or_start($$$)
84 my ($self, $env_vars, $max_time) = @_;
85 return 0 if ( -p $env_vars->{SAMBA_TEST_FIFO});
87 unlink($env_vars->{SAMBA_TEST_FIFO});
88 POSIX::mkfifo($env_vars->{SAMBA_TEST_FIFO}, 0700);
89 unlink($env_vars->{SAMBA_TEST_LOG});
91 print "STARTING SAMBA... ";
94 open STDIN, $env_vars->{SAMBA_TEST_FIFO};
95 # we want out from samba to go to the log file, but also
96 # to the users terminal when running 'make test' on the command
97 # line. This puts it on stderr on the terminal
98 open STDOUT, "| tee $env_vars->{SAMBA_TEST_LOG} 1>&2";
99 open STDERR, '>&STDOUT';
101 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
104 if (defined($ENV{SAMBA_VALGRIND})) {
105 $valgrind = $ENV{SAMBA_VALGRIND};
108 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
109 $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR};
111 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
112 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
114 $ENV{UID_WRAPPER} = "1";
116 # Start slapd before samba, but with the fifo on stdin
117 if (defined($self->{ldap})) {
118 unless($self->slapd_start($env_vars)) {
119 warn("couldn't start slapd (main run)");
125 if (defined($max_time)) {
126 $optarg = "--maximum-runtime=$max_time ";
128 if (defined($ENV{SAMBA_OPTIONS})) {
129 $optarg.= " $ENV{SAMBA_OPTIONS}";
131 my $samba = $self->bindir_path("samba");
133 # allow selection of the process model using
134 # the environment varibale SAMBA_PROCESS_MODEL
135 # that allows us to change the process model for
136 # individual machines in the build farm
137 my $model = "single";
138 if (defined($ENV{SAMBA_PROCESS_MODEL})) {
139 $model = $ENV{SAMBA_PROCESS_MODEL};
141 my $ret = system("$valgrind $samba $optarg $env_vars->{CONFIGURATION} -M $model -i");
143 print "Unable to start $samba: $ret: $!\n";
146 unlink($env_vars->{SAMBA_TEST_FIFO});
149 print "$samba exits with status $exit\n";
150 } elsif ( $ret & 127 ) {
151 print "$samba got signal ".($ret & 127)." and exits with $exit!\n";
154 print "$samba failed with status $exit!\n";
160 open(DATA, ">$env_vars->{SAMBA_TEST_FIFO}");
165 sub wait_for_start($$)
167 my ($self, $testenv_vars) = @_;
168 # give time for nbt server to register its names
169 print "delaying for nbt name registration\n";
172 # This will return quickly when things are up, but be slow if we
173 # need to wait for (eg) SSL init
174 my $nmblookup = $self->bindir_path("nmblookup");
175 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{SERVER}");
176 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{SERVER}");
177 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
178 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
179 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSALIAS}");
180 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSALIAS}");
181 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{SERVER}");
182 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{SERVER}");
183 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
184 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
185 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSALIAS}");
186 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSALIAS}");
188 print $self->getlog_env($testenv_vars);
191 sub write_ldb_file($$$)
193 my ($self, $file, $ldif) = @_;
195 my $ldbadd = $self->bindir_path("ldbadd");
196 open(LDIF, "|$ldbadd -H $file >/dev/null");
201 sub add_wins_config($$)
203 my ($self, $privatedir) = @_;
205 return $self->write_ldb_file("$privatedir/wins_config.ldb", "
206 dn: name=TORTURE_11,CN=PARTNERS
207 objectClass: wreplPartner
218 my ($self, $ctx) = @_;
220 #Make the subdirectory be as fedora DS would expect
221 my $fedora_ds_dir = "$ctx->{ldapdir}/slapd-$ctx->{ldap_instance}";
223 my $pidfile = "$fedora_ds_dir/logs/slapd-$ctx->{ldap_instance}.pid";
225 return ($fedora_ds_dir, $pidfile);
230 my ($self, $ctx) = @_;
232 my $slapd_conf_d = "$ctx->{ldapdir}/slapd.d";
233 my $pidfile = "$ctx->{ldapdir}/slapd.pid";
235 return ($slapd_conf_d, $pidfile);
240 my ($self, $tlsdir) = @_;
242 #TLS and PKINIT crypto blobs
243 my $dhfile = "$tlsdir/dhparms.pem";
244 my $cafile = "$tlsdir/ca.pem";
245 my $certfile = "$tlsdir/cert.pem";
246 my $reqkdc = "$tlsdir/req-kdc.der";
247 my $kdccertfile = "$tlsdir/kdc.pem";
248 my $keyfile = "$tlsdir/key.pem";
249 my $adminkeyfile = "$tlsdir/adminkey.pem";
250 my $reqadmin = "$tlsdir/req-admin.der";
251 my $admincertfile = "$tlsdir/admincert.pem";
252 my $admincertupnfile = "$tlsdir/admincertupn.pem";
254 mkdir($tlsdir, 0777);
256 #This is specified here to avoid draining entropy on every run
257 open(DHFILE, ">$dhfile");
259 -----BEGIN DH PARAMETERS-----
260 MGYCYQC/eWD2xkb7uELmqLi+ygPMKyVcpHUo2yCluwnbPutEueuxrG/Cys8j8wLO
261 svCN/jYNyR2NszOmg7ZWcOC/4z/4pWDVPUZr8qrkhj5MRKJc52MncfaDglvEdJrv
263 -----END DH PARAMETERS-----
267 #Likewise, we pregenerate the key material. This allows the
268 #other certificates to be pre-generated
269 open(KEYFILE
, ">$keyfile");
271 -----BEGIN RSA PRIVATE KEY-----
272 MIICXQIBAAKBgQDKg6pAwCHUMA1DfHDmWhZfd+F0C+9Jxcqvpw9ii9En3E1uflpc
273 ol3+S9/6I/uaTmJHZre+DF3dTzb/UOZo0Zem8N+IzzkgoGkFafjXuT3BL5UPY2/H
274 6H+pPqVIRLOmrWImai359YyoKhFyo37Y6HPeU8QcZ+u2rS9geapIWfeuowIDAQAB
275 AoGAAqDLzFRR/BF1kpsiUfL4WFvTarCe9duhwj7ORc6fs785qAXuwUYAJ0Uvzmy6
276 HqoGv3t3RfmeHDmjcpPHsbOKnsOQn2MgmthidQlPBMWtQMff5zdoYNUFiPS0XQBq
277 szNW4PRjaA9KkLQVTwnzdXGkBSkn/nGxkaVu7OR3vJOBoo0CQQDO4upypesnbe6p
278 9/xqfZ2uim8IwV1fLlFClV7WlCaER8tsQF4lEi0XSzRdXGUD/dilpY88Nb+xok/X
279 8Z8OvgAXAkEA+pcLsx1gN7kxnARxv54jdzQjC31uesJgMKQXjJ0h75aUZwTNHmZQ
280 vPxi6u62YiObrN5oivkixwFNncT9MxTxVQJBAMaWUm2SjlLe10UX4Zdm1MEB6OsC
281 kVoX37CGKO7YbtBzCfTzJGt5Mwc1DSLA2cYnGJqIfSFShptALlwedot0HikCQAJu
282 jNKEKnbf+TdGY8Q0SKvTebOW2Aeg80YFkaTvsXCdyXrmdQcifw4WdO9KucJiDhSz
283 Y9hVapz7ykEJtFtWjLECQQDIlfc63I5ZpXfg4/nN4IJXUW6AmPVOYIA5215itgki
284 cSlMYli1H9MEXH0pQMGv5Qyd0OYIx2DDg96mZ+aFvqSG
285 -----END RSA PRIVATE KEY-----
289 open(ADMINKEYFILE
, ">$adminkeyfile");
291 print ADMINKEYFILE
<<EOF;
292 -----BEGIN RSA PRIVATE KEY-----
293 MIICXQIBAAKBgQD0+OL7TQBj0RejbIH1+g5GeRaWaM9xF43uE5y7jUHEsi5owhZF
294 5iIoHZeeL6cpDF5y1BZRs0JlA1VqMry1jjKlzFYVEMMFxB6esnXhl0Jpip1JkUMM
295 XLOP1m/0dqayuHBWozj9f/cdyCJr0wJIX1Z8Pr+EjYRGPn/MF0xdl3JRlwIDAQAB
296 AoGAP8mjCP628Ebc2eACQzOWjgEvwYCPK4qPmYOf1zJkArzG2t5XAGJ5WGrENRuB
297 cm3XFh1lpmaADl982UdW3gul4gXUy6w4XjKK4vVfhyHj0kZ/LgaXUK9BAGhroJ2L
298 osIOUsaC6jdx9EwSRctwdlF3wWJ8NK0g28AkvIk+FlolW4ECQQD7w5ouCDnf58CN
299 u4nARx4xv5XJXekBvOomkCQAmuOsdOb6b9wn3mm2E3au9fueITjb3soMR31AF6O4
300 eAY126rXAkEA+RgHzybzZEP8jCuznMqoN2fq/Vrs6+W3M8/G9mzGEMgLLpaf2Jiz
301 I9tLZ0+OFk9tkRaoCHPfUOCrVWJZ7Y53QQJBAMhoA6rw0WDyUcyApD5yXg6rusf4
302 ASpo/tqDkqUIpoL464Qe1tjFqtBM3gSXuhs9xsz+o0bzATirmJ+WqxrkKTECQHt2
303 OLCpKqwAspU7N+w32kaUADoRLisCEdrhWklbwpQgwsIVsCaoEOpt0CLloJRYTANE
304 yoZeAErTALjyZYZEPcECQQDlUi0N8DFxQ/lOwWyR3Hailft+mPqoPCa8QHlQZnlG
305 +cfgNl57YHMTZFwgUVFRdJNpjH/WdZ5QxDcIVli0q+Ko
306 -----END RSA PRIVATE KEY-----
310 # hxtool issue-certificate --self-signed --issue-ca \
311 # --ca-private-key="FILE:$KEYFILE" \
312 # --subject="CN=CA,DC=samba,DC=example,DC=com" \
313 # --certificate="FILE:$CAFILE" --lifetime="25 years"
315 open(CAFILE
, ">$cafile");
317 -----BEGIN CERTIFICATE-----
318 MIICcTCCAdqgAwIBAgIUaBPmjnPVqyFqR5foICmLmikJTzgwCwYJKoZIhvcNAQEFMFIxEzAR
319 BgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxlMRUwEwYKCZImiZPy
320 LGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMCIYDzIwMDgwMzAxMTIyMzEyWhgPMjAzMzAyMjQx
321 MjIzMTJaMFIxEzARBgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxl
322 MRUwEwYKCZImiZPyLGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMIGfMA0GCSqGSIb3DQEBAQUA
323 A4GNADCBiQKBgQDKg6pAwCHUMA1DfHDmWhZfd+F0C+9Jxcqvpw9ii9En3E1uflpcol3+S9/6
324 I/uaTmJHZre+DF3dTzb/UOZo0Zem8N+IzzkgoGkFafjXuT3BL5UPY2/H6H+pPqVIRLOmrWIm
325 ai359YyoKhFyo37Y6HPeU8QcZ+u2rS9geapIWfeuowIDAQABo0IwQDAOBgNVHQ8BAf8EBAMC
326 AaYwHQYDVR0OBBYEFMLZufegDKLZs0VOyFXYK1L6M8oyMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
327 KoZIhvcNAQEFBQADgYEAAZJbCAAkaqgFJ0xgNovn8Ydd0KswQPjicwiODPgw9ZPoD2HiOUVO
328 yYDRg/dhFF9y656OpcHk4N7qZ2sl3RlHkzDu+dseETW+CnKvQIoXNyeARRJSsSlwrwcoD4JR
329 HTLk2sGigsWwrJ2N99sG/cqSJLJ1MFwLrs6koweBnYU0f/g=
330 -----END CERTIFICATE-----
333 #generated with GNUTLS internally in Samba.
335 open(CERTFILE
, ">$certfile");
336 print CERTFILE
<<EOF;
337 -----BEGIN CERTIFICATE-----
338 MIICYTCCAcygAwIBAgIE5M7SRDALBgkqhkiG9w0BAQUwZTEdMBsGA1UEChMUU2Ft
339 YmEgQWRtaW5pc3RyYXRpb24xNDAyBgNVBAsTK1NhbWJhIC0gdGVtcG9yYXJ5IGF1
340 dG9nZW5lcmF0ZWQgY2VydGlmaWNhdGUxDjAMBgNVBAMTBVNhbWJhMB4XDTA2MDgw
341 NDA0MzY1MloXDTA4MDcwNDA0MzY1MlowZTEdMBsGA1UEChMUU2FtYmEgQWRtaW5p
342 c3RyYXRpb24xNDAyBgNVBAsTK1NhbWJhIC0gdGVtcG9yYXJ5IGF1dG9nZW5lcmF0
343 ZWQgY2VydGlmaWNhdGUxDjAMBgNVBAMTBVNhbWJhMIGcMAsGCSqGSIb3DQEBAQOB
344 jAAwgYgCgYDKg6pAwCHUMA1DfHDmWhZfd+F0C+9Jxcqvpw9ii9En3E1uflpcol3+
345 S9/6I/uaTmJHZre+DF3dTzb/UOZo0Zem8N+IzzkgoGkFafjXuT3BL5UPY2/H6H+p
346 PqVIRLOmrWImai359YyoKhFyo37Y6HPeU8QcZ+u2rS9geapIWfeuowIDAQABoyUw
347 IzAMBgNVHRMBAf8EAjAAMBMGA1UdJQQMMAoGCCsGAQUFBwMBMAsGCSqGSIb3DQEB
348 BQOBgQAmkN6XxvDnoMkGcWLCTwzxGfNNSVcYr7TtL2aJh285Xw9zaxcm/SAZBFyG
349 LYOChvh6hPU7joMdDwGfbiLrBnMag+BtGlmPLWwp/Kt1wNmrRhduyTQFhN3PP6fz
350 nBr9vVny2FewB2gHmelaPS//tXdxivSXKz3NFqqXLDJjq7P8wA==
351 -----END CERTIFICATE-----
356 # hxtool request-create \
357 # --subject="CN=krbtgt,CN=users,DC=samba,DC=example,DC=com" \
358 # --key="FILE:$KEYFILE" $KDCREQ
360 # hxtool issue-certificate --ca-certificate=FILE:$CAFILE,$KEYFILE \
361 # --type="pkinit-kdc" \
362 # --pk-init-principal="krbtgt/SAMBA.EXAMPLE.COM@SAMBA.EXAMPLE.COM" \
363 # --req="PKCS10:$KDCREQ" --certificate="FILE:$KDCCERTFILE" \
364 # --lifetime="25 years"
366 open(KDCCERTFILE
, ">$kdccertfile");
367 print KDCCERTFILE
<<EOF;
368 -----BEGIN CERTIFICATE-----
369 MIIDDDCCAnWgAwIBAgIUI2Tzj+JnMzMcdeabcNo30rovzFAwCwYJKoZIhvcNAQEFMFIxEzAR
370 BgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxlMRUwEwYKCZImiZPy
371 LGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMCIYDzIwMDgwMzAxMTMxOTIzWhgPMjAzMzAyMjQx
372 MzE5MjNaMGYxEzARBgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxl
373 MRUwEwYKCZImiZPyLGQBGQwFc2FtYmExDjAMBgNVBAMMBXVzZXJzMQ8wDQYDVQQDDAZrcmJ0
374 Z3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMqDqkDAIdQwDUN8cOZaFl934XQL70nF
375 yq+nD2KL0SfcTW5+WlyiXf5L3/oj+5pOYkdmt74MXd1PNv9Q5mjRl6bw34jPOSCgaQVp+Ne5
376 PcEvlQ9jb8fof6k+pUhEs6atYiZqLfn1jKgqEXKjftjoc95TxBxn67atL2B5qkhZ966jAgMB
377 AAGjgcgwgcUwDgYDVR0PAQH/BAQDAgWgMBIGA1UdJQQLMAkGBysGAQUCAwUwVAYDVR0RBE0w
378 S6BJBgYrBgEFAgKgPzA9oBMbEVNBTUJBLkVYQU1QTEUuQ09NoSYwJKADAgEBoR0wGxsGa3Ji
379 dGd0GxFTQU1CQS5FWEFNUExFLkNPTTAfBgNVHSMEGDAWgBTC2bn3oAyi2bNFTshV2CtS+jPK
380 MjAdBgNVHQ4EFgQUwtm596AMotmzRU7IVdgrUvozyjIwCQYDVR0TBAIwADANBgkqhkiG9w0B
381 AQUFAAOBgQBmrVD5MCmZjfHp1nEnHqTIh8r7lSmVtDx4s9MMjxm9oNrzbKXynvdhwQYFVarc
382 ge4yRRDXtSebErOl71zVJI9CVeQQpwcH+tA85oGA7oeFtO/S7ls581RUU6tGgyxV4veD+lJv
383 KPH5LevUtgD+q9H4LU4Sq5N3iFwBaeryB0g2wg==
384 -----END CERTIFICATE-----
387 # hxtool request-create \
388 # --subject="CN=Administrator,CN=users,DC=samba,DC=example,DC=com" \
389 # --key="FILE:$ADMINKEYFILE" $ADMINREQFILE
391 # hxtool issue-certificate --ca-certificate=FILE:$CAFILE,$KEYFILE \
392 # --type="pkinit-client" \
393 # --pk-init-principal="administrator@SAMBA.EXAMPLE.COM" \
394 # --req="PKCS10:$ADMINREQFILE" --certificate="FILE:$ADMINCERTFILE" \
395 # --lifetime="25 years"
397 open(ADMINCERTFILE
, ">$admincertfile");
398 print ADMINCERTFILE
<<EOF;
399 -----BEGIN CERTIFICATE-----
400 MIIDHTCCAoagAwIBAgIUUggzW4lLRkMKe1DAR2NKatkMDYwwCwYJKoZIhvcNAQELMFIxEzAR
401 BgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxlMRUwEwYKCZImiZPy
402 LGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMCIYDzIwMDkwNzI3MDMzMjE1WhgPMjAzNDA3MjIw
403 MzMyMTVaMG0xEzARBgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxl
404 MRUwEwYKCZImiZPyLGQBGQwFc2FtYmExDjAMBgNVBAMMBXVzZXJzMRYwFAYDVQQDDA1BZG1p
405 bmlzdHJhdG9yMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD0+OL7TQBj0RejbIH1+g5G
406 eRaWaM9xF43uE5y7jUHEsi5owhZF5iIoHZeeL6cpDF5y1BZRs0JlA1VqMry1jjKlzFYVEMMF
407 xB6esnXhl0Jpip1JkUMMXLOP1m/0dqayuHBWozj9f/cdyCJr0wJIX1Z8Pr+EjYRGPn/MF0xd
408 l3JRlwIDAQABo4HSMIHPMA4GA1UdDwEB/wQEAwIFoDAoBgNVHSUEITAfBgcrBgEFAgMEBggr
409 BgEFBQcDAgYKKwYBBAGCNxQCAjBIBgNVHREEQTA/oD0GBisGAQUCAqAzMDGgExsRU0FNQkEu
410 RVhBTVBMRS5DT02hGjAYoAMCAQGhETAPGw1BZG1pbmlzdHJhdG9yMB8GA1UdIwQYMBaAFMLZ
411 ufegDKLZs0VOyFXYK1L6M8oyMB0GA1UdDgQWBBQg81bLyfCA88C2B/BDjXlGuaFaxjAJBgNV
412 HRMEAjAAMA0GCSqGSIb3DQEBCwUAA4GBAEf/OSHUDJaGdtWGNuJeqcVYVMwrfBAc0OSwVhz1
413 7/xqKHWo8wIMPkYRtaRHKLNDsF8GkhQPCpVsa6mX/Nt7YQnNvwd+1SBP5E8GvwWw9ZzLJvma
414 nk2n89emuayLpVtp00PymrDLRBcNaRjFReQU8f0o509kiVPHduAp3jOiy13l
415 -----END CERTIFICATE-----
417 close(ADMINCERTFILE
);
419 # hxtool issue-certificate --ca-certificate=FILE:$CAFILE,$KEYFILE \
420 # --type="pkinit-client" \
421 # --ms-upn="administrator@samba.example.com" \
422 # --req="PKCS10:$ADMINREQFILE" --certificate="FILE:$ADMINCERTUPNFILE" \
423 # --lifetime="25 years"
425 open(ADMINCERTUPNFILE
, ">$admincertupnfile");
426 print ADMINCERTUPNFILE
<<EOF;
427 -----BEGIN CERTIFICATE-----
428 MIIDDzCCAnigAwIBAgIUUp3CJMuNaEaAdPKp3QdNIwG7a4wwCwYJKoZIhvcNAQELMFIxEzAR
429 BgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxlMRUwEwYKCZImiZPy
430 LGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMCIYDzIwMDkwNzI3MDMzMzA1WhgPMjAzNDA3MjIw
431 MzMzMDVaMG0xEzARBgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxl
432 MRUwEwYKCZImiZPyLGQBGQwFc2FtYmExDjAMBgNVBAMMBXVzZXJzMRYwFAYDVQQDDA1BZG1p
433 bmlzdHJhdG9yMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD0+OL7TQBj0RejbIH1+g5G
434 eRaWaM9xF43uE5y7jUHEsi5owhZF5iIoHZeeL6cpDF5y1BZRs0JlA1VqMry1jjKlzFYVEMMF
435 xB6esnXhl0Jpip1JkUMMXLOP1m/0dqayuHBWozj9f/cdyCJr0wJIX1Z8Pr+EjYRGPn/MF0xd
436 l3JRlwIDAQABo4HEMIHBMA4GA1UdDwEB/wQEAwIFoDAoBgNVHSUEITAfBgcrBgEFAgMEBggr
437 BgEFBQcDAgYKKwYBBAGCNxQCAjA6BgNVHREEMzAxoC8GCisGAQQBgjcUAgOgIQwfYWRtaW5p
438 c3RyYXRvckBzYW1iYS5leGFtcGxlLmNvbTAfBgNVHSMEGDAWgBTC2bn3oAyi2bNFTshV2CtS
439 +jPKMjAdBgNVHQ4EFgQUIPNWy8nwgPPAtgfwQ415RrmhWsYwCQYDVR0TBAIwADANBgkqhkiG
440 9w0BAQsFAAOBgQBk42+egeUB3Ji2PC55fbt3FNKxvmm2xUUFkV9POK/YR9rajKOwk5jtYSeS
441 Zd7J9s//rNFNa7waklFkDaY56+QWTFtdvxfE+KoHaqt6X8u6pqi7p3M4wDKQox+9Dx8yWFyq
442 Wfz/8alZ5aMezCQzXJyIaJsCLeKABosSwHcpAFmxlQ==
443 -----END CERTIFICATE-----
447 sub provision_raw_prepare
($$$$$$$$$$)
449 my ($self, $prefix, $server_role, $netbiosname, $netbiosalias,
450 $domain, $realm, $functional_level,
451 $swiface, $password, $kdc_ipv4) = @_;
454 unless(-d
$prefix or mkdir($prefix, 0777)) {
455 warn("Unable to create $prefix");
458 my $prefix_abs = abs_path
($prefix);
460 die ("prefix=''") if $prefix_abs eq "";
461 die ("prefix='/'") if $prefix_abs eq "/";
463 unless (system("rm -rf $prefix_abs/*") == 0) {
464 warn("Unable to clean up");
467 $ctx->{prefix
} = $prefix;
468 $ctx->{prefix_abs
} = $prefix_abs;
470 $ctx->{dns_host_file
} = "$ENV{SELFTEST_PREFIX}/dns_host_file";
472 $ctx->{server_role
} = $server_role;
473 $ctx->{netbiosname
} = $netbiosname;
474 $ctx->{netbiosalias
} = $netbiosalias;
475 $ctx->{swiface
} = $swiface;
476 $ctx->{password
} = $password;
477 $ctx->{kdc_ipv4
} = $kdc_ipv4;
479 $ctx->{server_loglevel
} = 1;
480 $ctx->{username
} = "Administrator";
481 $ctx->{domain
} = $domain;
482 $ctx->{realm
} = uc($realm);
483 $ctx->{dnsname
} = lc($realm);
484 $ctx->{sid_generator
} = "internal";
486 $ctx->{functional_level
} = $functional_level;
488 my $unix_name = ($ENV{USER
} or $ENV{LOGNAME
} or `whoami`);
490 $ctx->{unix_name
} = $unix_name;
491 $ctx->{unix_uid
} = $>;
492 $ctx->{unix_gids_str
} = $);
493 @
{$ctx->{unix_gids
}} = split(" ", $ctx->{unix_gids_str
});
495 $ctx->{etcdir
} = "$prefix_abs/etc";
496 $ctx->{piddir
} = "$prefix_abs/pid";
497 $ctx->{smb_conf
} = "$ctx->{etcdir}/smb.conf";
498 $ctx->{krb5_conf
} = "$ctx->{etcdir}/krb5.conf";
499 $ctx->{privatedir
} = "$prefix_abs/private";
500 $ctx->{ncalrpcdir
} = "$prefix_abs/ncalrpc";
501 $ctx->{lockdir
} = "$prefix_abs/lockdir";
502 $ctx->{winbindd_socket_dir
} = "$prefix_abs/winbindd_socket";
503 $ctx->{winbindd_privileged_socket_dir
} = "$prefix_abs/winbindd_privileged_socket";
504 $ctx->{ntp_signd_socket_dir
} = "$prefix_abs/ntp_signd_socket";
505 $ctx->{nsswrap_passwd
} = "$ctx->{etcdir}/passwd";
506 $ctx->{nsswrap_group
} = "$ctx->{etcdir}/group";
508 $ctx->{tlsdir
} = "$ctx->{privatedir}/tls";
510 $ctx->{ipv4
} = "127.0.0.$swiface";
511 $ctx->{interfaces
} = "$ctx->{ipv4}/8";
513 push(@
{$ctx->{directories
}}, $ctx->{privatedir
});
514 push(@
{$ctx->{directories
}}, $ctx->{etcdir
});
515 push(@
{$ctx->{directories
}}, $ctx->{piddir
});
516 push(@
{$ctx->{directories
}}, $ctx->{ncalrpcdir
});
517 push(@
{$ctx->{directories
}}, $ctx->{lockdir
});
519 $ctx->{smb_conf_extra_options
} = "";
521 my @provision_options = ();
522 push (@provision_options, "NSS_WRAPPER_PASSWD=\"$ctx->{nsswrap_passwd}\"");
523 push (@provision_options, "NSS_WRAPPER_GROUP=\"$ctx->{nsswrap_group}\"");
524 if (defined($ENV{GDB_PROVISION
})) {
525 push (@provision_options, "gdb --args");
527 if (defined($ENV{VALGRIND_PROVISION
})) {
528 push (@provision_options, "valgrind");
530 if (defined($ENV{PYTHON
})) {
531 push (@provision_options, $ENV{PYTHON
});
533 push (@provision_options, "$self->{setupdir}/provision");
534 push (@provision_options, "--configfile=$ctx->{smb_conf}");
535 push (@provision_options, "--host-name=$ctx->{netbiosname}");
536 push (@provision_options, "--host-ip=$ctx->{ipv4}");
537 push (@provision_options, "--quiet");
538 push (@provision_options, "--domain=$ctx->{domain}");
539 push (@provision_options, "--realm=$ctx->{realm}");
540 push (@provision_options, "--adminpass=$ctx->{password}");
541 push (@provision_options, "--krbtgtpass=krbtgt$ctx->{password}");
542 push (@provision_options, "--machinepass=machine$ctx->{password}");
543 push (@provision_options, "--root=$ctx->{unix_name}");
544 push (@provision_options, "--server-role=\"$ctx->{server_role}\"");
545 push (@provision_options, "--function-level=\"$ctx->{functional_level}\"");
547 @
{$ctx->{provision_options
}} = @provision_options;
553 # Step1 creates the basic configuration
555 sub provision_raw_step1
($$)
557 my ($self, $ctx) = @_;
559 mkdir($_, 0777) foreach (@
{$ctx->{directories
}});
561 unless (open(CONFFILE
, ">$ctx->{smb_conf}")) {
562 warn("can't open $ctx->{smb_conf}$?");
567 netbios name = $ctx->{netbiosname}
568 netbios aliases = $ctx->{netbiosalias}
569 posix:eadb = $ctx->{lockdir}/eadb.tdb
570 workgroup = $ctx->{domain}
571 realm = $ctx->{realm}
572 private dir = $ctx->{privatedir}
573 pid directory = $ctx->{piddir}
574 ncalrpc dir = $ctx->{ncalrpcdir}
575 lock dir = $ctx->{lockdir}
576 setup directory = $self->{setupdir}
577 modules dir = $self->{bindir}/modules
578 winbindd socket directory = $ctx->{winbindd_socket_dir}
579 winbindd privileged socket directory = $ctx->{winbindd_privileged_socket_dir}
580 ntp signd socket directory = $ctx->{ntp_signd_socket_dir}
581 winbind separator = /
582 name resolve order = file bcast
583 interfaces = $ctx->{interfaces}
584 tls dh params file = $ctx->{tlsdir}/dhparms.pem
585 panic action = $RealBin/gdb_backtrace \%PID% \%PROG%
587 server role = $ctx->{server_role}
588 notify:inotify = false
590 #We don't want to pass our self-tests if the PAC code is wrong
591 gensec:require_pac = true
592 log level = $ctx->{server_loglevel}
595 dns update command = $ENV{SRCDIR_ABS}/scripting/bin/samba_dnsupdate --all-interfaces --use-file=$ctx->{dns_host_file}
596 spn update command = $ENV{SRCDIR_ABS}/scripting/bin/samba_spnupdate
597 resolv:host file = $ctx->{dns_host_file}
598 dreplsrv:periodic_startup_interval = 0
601 if (defined($ctx->{sid_generator
}) && $ctx->{sid_generator
} ne "internal") {
603 sid generator = $ctx->{sid_generator}";
608 # Begin extra options
609 $ctx->{smb_conf_extra_options}
614 $self->mk_keyblobs($ctx->{tlsdir
});
616 unless (open(KRB5CONF
, ">$ctx->{krb5_conf}")) {
617 warn("can't open $ctx->{krb5_conf}$?");
621 #Generated krb5.conf for $ctx->{realm}
624 default_realm = $ctx->{realm}
625 dns_lookup_realm = false
626 dns_lookup_kdc = false
627 ticket_lifetime = 24h
632 kdc = $ctx->{kdc_ipv4}:88
633 admin_server = $ctx->{kdc_ipv4}:88
634 default_domain = $ctx->{dnsname}
637 kdc = $ctx->{kdc_ipv4}:88
638 admin_server = $ctx->{kdc_ipv4}:88
639 default_domain = $ctx->{dnsname}
642 kdc = $ctx->{kdc_ipv4}:88
643 admin_server = $ctx->{kdc_ipv4}:88
644 default_domain = $ctx->{dnsname}
648 pkinit_anchors = FILE:$ctx->{tlsdir}/ca.pem
652 pkinit_identity = FILE:$ctx->{tlsdir}/kdc.pem,$ctx->{tlsdir}/key.pem
653 pkinit_anchors = FILE:$ctx->{tlsdir}/ca.pem
656 .$ctx->{dnsname} = $ctx->{realm}
660 open(PWD
, ">$ctx->{nsswrap_passwd}");
662 root:x:0:0:root gecos:$ctx->{prefix_abs}:/bin/false
663 $ctx->{unix_name}:x:$ctx->{unix_uid}:@{$ctx->{unix_gids}}[0]:$ctx->{unix_name} gecos:$ctx->{prefix_abs}:/bin/false
664 nobody:x:65534:65533:nobody gecos:$ctx->{prefix_abs}:/bin/false
668 open(GRP
, ">$ctx->{nsswrap_group}");
674 nogroup:x:65534:nobody
678 my $configuration = "--configfile=$ctx->{smb_conf}";
680 #Ensure the config file is valid before we start
681 my $testparm = $self->bindir_path("../scripting/bin/testparm");
682 if (system("$testparm $configuration -v --suppress-prompt >/dev/null 2>&1") != 0) {
683 system("$testparm -v --suppress-prompt $configuration >&2");
684 warn("Failed to create a valid smb.conf configuration $testparm!");
688 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) {
689 warn("Failed to create a valid smb.conf configuration! $testparm $configuration -v --suppress-prompt --parameter-name=\"netbios name\" --section-name=global");
694 KRB5_CONFIG
=> $ctx->{krb5_conf
},
695 PIDDIR
=> $ctx->{piddir
},
696 SERVER
=> $ctx->{netbiosname
},
697 SERVER_IP
=> $ctx->{ipv4
},
698 NETBIOSNAME
=> $ctx->{netbiosname
},
699 NETBIOSALIAS
=> $ctx->{netbiosalias
},
700 DOMAIN
=> $ctx->{domain
},
701 USERNAME
=> $ctx->{username
},
702 REALM
=> $ctx->{realm
},
703 PASSWORD
=> $ctx->{password
},
704 LDAPDIR
=> $ctx->{ldapdir
},
705 LDAP_INSTANCE
=> $ctx->{ldap_instance
},
706 WINBINDD_SOCKET_DIR
=> $ctx->{winbindd_socket_dir
},
707 NCALRPCDIR
=> $ctx->{ncalrpcdir
},
708 LOCKDIR
=> $ctx->{lockdir
},
709 SERVERCONFFILE
=> $ctx->{smb_conf
},
710 CONFIGURATION
=> $configuration,
711 SOCKET_WRAPPER_DEFAULT_IFACE
=> $ctx->{swiface
},
712 NSS_WRAPPER_PASSWD
=> $ctx->{nsswrap_passwd
},
713 NSS_WRAPPER_GROUP
=> $ctx->{nsswrap_group
},
714 SAMBA_TEST_FIFO
=> "$ctx->{prefix}/samba_test.fifo",
715 SAMBA_TEST_LOG
=> "$ctx->{prefix}/samba_test.log",
716 SAMBA_TEST_LOG_POS
=> 0,
723 # Step2 runs the provision script
725 sub provision_raw_step2
($$$)
727 my ($self, $ctx, $ret) = @_;
729 my $provision_cmd = join(" ", @
{$ctx->{provision_options
}});
730 unless (system($provision_cmd) == 0) {
731 warn("Unable to provision: \n$provision_cmd\n");
738 sub provision
($$$$$$$$$)
740 my ($self, $prefix, $server_role, $netbiosname, $netbiosalias,
741 $domain, $realm, $functional_level,
742 $swiface, $password, $kdc_ipv4, $extra_smbconf_options) = @_;
744 my $ctx = $self->provision_raw_prepare($prefix, $server_role,
745 $netbiosname, $netbiosalias,
746 $domain, $realm, $functional_level,
747 $swiface, $password, $kdc_ipv4);
749 $ctx->{tmpdir
} = "$ctx->{prefix_abs}/tmp";
750 push(@
{$ctx->{directories
}}, "$ctx->{tmpdir}");
751 push(@
{$ctx->{directories
}}, "$ctx->{tmpdir}/test1");
752 push(@
{$ctx->{directories
}}, "$ctx->{tmpdir}/test2");
754 $msdfs = "yes" if ($server_role eq "domain controller");
755 $ctx->{smb_conf_extra_options
} = "
758 server max protocol = SMB2
759 $extra_smbconf_options
764 path = $ctx->{tmpdir}
766 posix:sharedelay = 10000
767 posix:oplocktimeout = 3
768 posix:writetimeupdatedelay = 500000
771 path = $ctx->{tmpdir}/test1
773 posix:sharedelay = 10000
774 posix:oplocktimeout = 3
775 posix:writetimeupdatedelay = 50000
778 path = $ctx->{tmpdir}/test2
780 posix:sharedelay = 10000
781 posix:oplocktimeout = 3
782 posix:writetimeupdatedelay = 50000
787 cifs:server = $ctx->{netbiosname}
789 #There is no username specified here, instead the client is expected
790 #to log in with kerberos, and the serverwill use delegated credentials.
793 path = $ctx->{tmpdir}
795 ntvfs handler = simple
798 path = $ctx->{lockdir}/sysvol
802 path = $ctx->{lockdir}/sysvol/$ctx->{dnsname}/scripts
807 ntvfs handler = cifsposix
810 if (defined($self->{ldap
})) {
811 $ctx->{ldapdir
} = "$ctx->{privatedir}/ldap";
812 push(@
{$ctx->{directories
}}, "$ctx->{ldapdir}");
814 my $ldap_uri= "$ctx->{ldapdir}/ldapi";
815 $ldap_uri =~ s
|/|%2F|g
;
816 $ldap_uri = "ldapi://$ldap_uri";
817 $ctx->{ldap_uri
} = $ldap_uri;
818 if ($self->{ldap
} eq "fedora-ds") {
819 $ctx->{sid_generator
} = "backend";
822 $ctx->{ldap_instance
} = lc($ctx->{netbiosname
});
825 my $ret = $self->provision_raw_step1($ctx);
830 if (defined($self->{ldap
})) {
831 $ret->{LDAP_URI
} = $ctx->{ldap_uri
};
832 push (@
{$ctx->{provision_options
}}, "--ldap-backend-type=" . $self->{ldap
});
833 push (@
{$ctx->{provision_options
}}, "--ldap-backend-nosync");
834 if ($self->{ldap
} eq "openldap") {
835 push (@
{$ctx->{provision_options
}}, "--slapd-path=" . $ENV{OPENLDAP_SLAPD
});
836 ($ret->{SLAPD_CONF_D
}, $ret->{OPENLDAP_PIDFILE
}) = $self->mk_openldap($ctx) or die("Unable to create openldap directories");
838 } elsif ($self->{ldap
} eq "fedora-ds") {
839 push (@
{$ctx->{provision_options
}}, "--slapd-path=" . "$ENV{FEDORA_DS_ROOT}/sbin/ns-slapd");
840 push (@
{$ctx->{provision_options
}}, "--setup-ds-path=" . "$ENV{FEDORA_DS_ROOT}/sbin/setup-ds.pl");
841 ($ret->{FEDORA_DS_DIR
}, $ret->{FEDORA_DS_PIDFILE
}) = $self->mk_fedora_ds($ctx) or die("Unable to create fedora ds directories");
846 return $self->provision_raw_step2($ctx, $ret);
849 sub provision_member
($$$)
851 my ($self, $prefix, $dcvars) = @_;
852 print "PROVISIONING MEMBER...";
854 my $ret = $self->provision($prefix,
863 $dcvars->{SERVER_IP
},
869 my $net = $self->bindir_path("net");
871 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
872 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
873 $cmd .= "$net join $ret->{CONFIGURATION} $dcvars->{REALM} member";
874 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
876 unless (system($cmd) == 0) {
877 warn("Join failed\n$cmd");
881 $ret->{MEMBER_SERVER
} = $ret->{SERVER
};
882 $ret->{MEMBER_SERVER_IP
} = $ret->{SERVER_IP
};
883 $ret->{MEMBER_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
884 $ret->{MEMBER_NETBIOSALIAS
} = $ret->{NETBIOSALIAS
};
885 $ret->{MEMBER_USERNAME
} = $ret->{USERNAME
};
886 $ret->{MEMBER_PASSWORD
} = $ret->{PASSWORD
};
888 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
889 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
890 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
891 $ret->{DC_NETBIOSALIAS
} = $dcvars->{DC_NETBIOSALIAS
};
892 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
893 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
898 sub provision_rpc_proxy
($$$)
900 my ($self, $prefix, $dcvars) = @_;
901 print "PROVISIONING RPC PROXY...";
903 my $extra_smbconf_options = "dcerpc_remote:binding = ncacn_ip_tcp:localdc
904 dcerpc endpoint servers = epmapper, remote
905 dcerpc_remote:interfaces = rpcecho
908 my $ret = $self->provision($prefix,
917 $dcvars->{SERVER_IP
},
918 $extra_smbconf_options);
924 my $net = $self->bindir_path("net");
926 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
927 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
928 $cmd .= "$net join $ret->{CONFIGURATION} $dcvars->{REALM} member";
929 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
931 unless (system($cmd) == 0) {
932 warn("Join failed\n$cmd");
936 $ret->{RPC_PROXY_SERVER
} = $ret->{SERVER
};
937 $ret->{RPC_PROXY_SERVER_IP
} = $ret->{SERVER_IP
};
938 $ret->{RPC_PROXY_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
939 $ret->{RPC_PROXY_NETBIOSALIAS
} = $ret->{NETBIOSALIAS
};
940 $ret->{RPC_PROXY_USERNAME
} = $ret->{USERNAME
};
941 $ret->{RPC_PROXY_PASSWORD
} = $ret->{PASSWORD
};
946 sub provision_vampire_dc
($$$)
948 my ($self, $prefix, $dcvars) = @_;
949 print "PROVISIONING VAMPIRE DC...";
951 # We do this so that we don't run the provision. That's the job of 'net vampire'.
952 my $ctx = $self->provision_raw_prepare($prefix, "domain controller",
958 2, $dcvars->{PASSWORD
},
959 $dcvars->{SERVER_IP
});
961 $ctx->{smb_conf_extra_options
} = "
963 server max protocol = SMB2
966 path = $ctx->{lockdir}/sysvol
970 path = $ctx->{lockdir}/sysvol/$ctx->{dnsname}/scripts
975 my $ret = $self->provision_raw_step1($ctx);
980 my $net = $self->bindir_path("net");
982 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
983 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
984 $cmd .= "$net vampire $ret->{CONFIGURATION} $dcvars->{REALM} --realm=$dcvars->{REALM}";
985 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
987 unless (system($cmd) == 0) {
988 warn("Join failed\n$cmd");
992 $ret->{VAMPIRE_DC_SERVER
} = $ret->{SERVER
};
993 $ret->{VAMPIRE_DC_SERVER_IP
} = $ret->{SERVER_IP
};
994 $ret->{VAMPIRE_DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
995 $ret->{VAMPIRE_DC_NETBIOSALIAS
} = $ret->{NETBIOSALIAS
};
997 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
998 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
999 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
1000 $ret->{DC_NETBIOSALIAS
} = $dcvars->{DC_NETBIOSALIAS
};
1001 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
1002 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
1007 sub provision_dc
($$)
1009 my ($self, $prefix) = @_;
1011 print "PROVISIONING DC...";
1012 my $ret = $self->provision($prefix,
1013 "domain controller",
1017 "samba.example.com",
1023 unless($self->add_wins_config("$prefix/private")) {
1024 warn("Unable to add wins configuration");
1028 $ret->{DC_SERVER
} = $ret->{SERVER
};
1029 $ret->{DC_SERVER_IP
} = $ret->{SERVER_IP
};
1030 $ret->{DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1031 $ret->{DC_NETBIOSALIAS
} = $ret->{NETBIOSALIAS
};
1032 $ret->{DC_USERNAME
} = $ret->{USERNAME
};
1033 $ret->{DC_PASSWORD
} = $ret->{PASSWORD
};
1038 sub provision_fl2000dc
($$)
1040 my ($self, $prefix) = @_;
1042 print "PROVISIONING DC...";
1043 my $ret = $self->provision($prefix,
1044 "domain controller",
1048 "samba2000.example.com",
1054 unless($self->add_wins_config("$prefix/private")) {
1055 warn("Unable to add wins configuration");
1062 sub provision_fl2003dc
($$)
1064 my ($self, $prefix) = @_;
1066 print "PROVISIONING DC...";
1067 my $ret = $self->provision($prefix,
1068 "domain controller",
1072 "samba2003.example.com",
1078 unless($self->add_wins_config("$prefix/private")) {
1079 warn("Unable to add wins configuration");
1086 sub provision_fl2008r2dc
($$)
1088 my ($self, $prefix) = @_;
1090 print "PROVISIONING DC...";
1091 my $ret = $self->provision($prefix,
1092 "domain controller",
1096 "samba2008R2.example.com",
1102 unless ($self->add_wins_config("$prefix/private")) {
1103 warn("Unable to add wins configuration");
1111 sub provision_rodc
($$$)
1113 my ($self, $prefix, $dcvars) = @_;
1114 print "PROVISIONING RODC...";
1116 # We do this so that we don't run the provision. That's the job of 'net join RODC'.
1117 my $ctx = $self->provision_raw_prepare($prefix, "domain controller",
1121 "samba.example.com",
1123 8, $dcvars->{PASSWORD
},
1124 $dcvars->{SERVER_IP
});
1129 $ctx->{tmpdir
} = "$ctx->{prefix_abs}/tmp";
1130 push(@
{$ctx->{directories
}}, "$ctx->{tmpdir}");
1132 $ctx->{smb_conf_extra_options
} = "
1134 server max protocol = SMB2
1137 path = $ctx->{lockdir}/sysvol
1141 path = $ctx->{lockdir}/sysvol/$ctx->{dnsname}/scripts
1145 path = $ctx->{tmpdir}
1147 posix:sharedelay = 10000
1148 posix:oplocktimeout = 3
1149 posix:writetimeupdatedelay = 500000
1153 my $ret = $self->provision_raw_step1($ctx);
1158 my $net = $self->bindir_path("net");
1160 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1161 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1162 $cmd .= "$net join $ret->{CONFIGURATION} $dcvars->{REALM} RODC";
1163 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
1164 $cmd .= " --server=$dcvars->{DC_SERVER}";
1166 unless (system($cmd) == 0) {
1167 warn("RODC join failed\n$cmd");
1171 $ret->{RODC_DC_SERVER
} = $ret->{SERVER
};
1172 $ret->{RODC_DC_SERVER_IP
} = $ret->{SERVER_IP
};
1173 $ret->{RODC_DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1174 $ret->{RODC_DC_NETBIOSALIAS
} = $ret->{NETBIOSALIAS
};
1176 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
1177 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
1178 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
1179 $ret->{DC_NETBIOSALIAS
} = $dcvars->{DC_NETBIOSALIAS
};
1180 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
1181 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
1186 sub teardown_env
($$)
1188 my ($self, $envvars) = @_;
1193 if (open(IN
, "<$envvars->{PIDDIR}/samba.pid")) {
1197 # Give the process 20 seconds to exit. gcov needs
1198 # this time to write out the covarge data
1200 until (kill(0, $pid) == 0) {
1201 # if no process sucessfully signalled, then we are done
1204 last if $count > 20;
1207 # If it is still around, kill it
1209 print "server process $pid took more than $count seconds to exit, killing\n";
1214 my $failed = $?
>> 8;
1216 $self->slapd_stop($envvars) if ($self->{ldap
});
1218 print $self->getlog_env($envvars);
1225 my ($self, $envvars) = @_;
1226 my $title = "SAMBA LOG of: $envvars->{NETBIOSNAME}\n";
1229 open(LOG
, "<$envvars->{SAMBA_TEST_LOG}");
1231 seek(LOG
, $envvars->{SAMBA_TEST_LOG_POS
}, SEEK_SET
);
1235 $envvars->{SAMBA_TEST_LOG_POS
} = tell(LOG
);
1238 return "" if $out eq $title;
1245 my ($self, $envvars) = @_;
1247 return (-p
$envvars->{SAMBA_TEST_FIFO
});
1252 my ($self, $envname, $path) = @_;
1254 if ($envname eq "dc") {
1255 return $self->setup_dc("$path/dc");
1256 } elsif ($envname eq "fl2000dc") {
1257 return $self->setup_fl2000dc("$path/fl2000dc");
1258 } elsif ($envname eq "fl2003dc") {
1259 return $self->setup_fl2003dc("$path/fl2003dc");
1260 } elsif ($envname eq "fl2008r2dc") {
1261 return $self->setup_fl2008r2dc("$path/fl2008r2dc");
1262 } elsif ($envname eq "rpc_proxy") {
1263 if (not defined($self->{vars
}->{dc
})) {
1264 $self->setup_dc("$path/dc");
1266 return $self->setup_rpc_proxy("$path/rpc_proxy", $self->{vars
}->{dc
});
1267 } elsif ($envname eq "vampire_dc") {
1268 if (not defined($self->{vars
}->{dc
})) {
1269 $self->setup_dc("$path/dc");
1271 return $self->setup_vampire_dc("$path/vampire_dc", $self->{vars
}->{dc
});
1272 } elsif ($envname eq "member") {
1273 if (not defined($self->{vars
}->{dc
})) {
1274 $self->setup_dc("$path/dc");
1276 return $self->setup_member("$path/member", $self->{vars
}->{dc
});
1277 } elsif ($envname eq "rodc") {
1278 if (not defined($self->{vars
}->{dc
})) {
1279 $self->setup_dc("$path/dc");
1281 return $self->setup_rodc("$path/rodc", $self->{vars
}->{dc
});
1282 } elsif ($envname eq "all") {
1283 if (not defined($self->{vars
}->{dc
})) {
1284 $self->setup_dc("$path/dc");
1286 my $ret = $self->setup_member("$path/member", $self->{vars
}->{dc
});
1287 if (not defined($self->{vars
}->{rpc_proxy
})) {
1288 my $rpc_proxy_ret = $self->setup_rpc_proxy("$path/rpc_proxy", $self->{vars
}->{dc
});
1290 $ret->{RPC_PROXY_SERVER
} = $rpc_proxy_ret->{SERVER
};
1291 $ret->{RPC_PROXY_SERVER_IP
} = $rpc_proxy_ret->{SERVER_IP
};
1292 $ret->{RPC_PROXY_NETBIOSNAME
} = $rpc_proxy_ret->{NETBIOSNAME
};
1293 $ret->{RPC_PROXY_NETBIOSALIAS
} = $rpc_proxy_ret->{NETBIOSALIAS
};
1294 $ret->{RPC_PROXY_USERNAME
} = $rpc_proxy_ret->{USERNAME
};
1295 $ret->{RPC_PROXY_PASSWORD
} = $rpc_proxy_ret->{PASSWORD
};
1297 if (not defined($self->{vars
}->{fl2000dc
})) {
1298 my $fl2000dc_ret = $self->setup_fl2000dc("$path/fl2000dc", $self->{vars
}->{dc
});
1300 $ret->{FL2000DC_SERVER
} = $fl2000dc_ret->{SERVER
};
1301 $ret->{FL2000DC_SERVER_IP
} = $fl2000dc_ret->{SERVER_IP
};
1302 $ret->{FL2000DC_NETBIOSNAME
} = $fl2000dc_ret->{NETBIOSNAME
};
1303 $ret->{FL2000DC_NETBIOSALIAS
} = $fl2000dc_ret->{NETBIOSALIAS
};
1304 $ret->{FL2000DC_USERNAME
} = $fl2000dc_ret->{USERNAME
};
1305 $ret->{FL2000DC_PASSWORD
} = $fl2000dc_ret->{PASSWORD
};
1307 if (not defined($self->{vars
}->{fl2003dc
})) {
1308 my $fl2003dc_ret = $self->setup_fl2003dc("$path/fl2003dc", $self->{vars
}->{dc
});
1310 $ret->{FL2003DC_SERVER
} = $fl2003dc_ret->{SERVER
};
1311 $ret->{FL2003DC_SERVER_IP
} = $fl2003dc_ret->{SERVER_IP
};
1312 $ret->{FL2003DC_NETBIOSNAME
} = $fl2003dc_ret->{NETBIOSNAME
};
1313 $ret->{FL2003DC_NETBIOSALIAS
} = $fl2003dc_ret->{NETBIOSALIAS
};
1314 $ret->{FL2003DC_USERNAME
} = $fl2003dc_ret->{USERNAME
};
1315 $ret->{FL2003DC_PASSWORD
} = $fl2003dc_ret->{PASSWORD
};
1317 if (not defined($self->{vars
}->{fl2008r2dc
})) {
1318 my $fl2008r2dc_ret = $self->setup_fl2008r2dc("$path/fl2008r2dc", $self->{vars
}->{dc
});
1320 $ret->{FL2008R2DC_SERVER
} = $fl2008r2dc_ret->{SERVER
};
1321 $ret->{FL2008R2DC_SERVER_IP
} = $fl2008r2dc_ret->{SERVER_IP
};
1322 $ret->{FL2008R2DC_NETBIOSNAME
} = $fl2008r2dc_ret->{NETBIOSNAME
};
1323 $ret->{FL2008R2DC_NETBIOSALIAS
} = $fl2008r2dc_ret->{NETBIOSALIAS
};
1324 $ret->{FL2008R2DC_USERNAME
} = $fl2008r2dc_ret->{USERNAME
};
1325 $ret->{FL2008R2DC_PASSWORD
} = $fl2008r2dc_ret->{PASSWORD
};
1329 warn("Samba4 can't provide environment '$envname'");
1334 sub setup_member
($$$)
1336 my ($self, $path, $dc_vars) = @_;
1338 my $env = $self->provision_member($path, $dc_vars);
1340 $self->check_or_start($env, ($ENV{SMBD_MAXTIME
} or 7500));
1342 $self->wait_for_start($env);
1344 $self->{vars
}->{member
} = $env;
1349 sub setup_rpc_proxy
($$$)
1351 my ($self, $path, $dc_vars) = @_;
1353 my $env = $self->provision_rpc_proxy($path, $dc_vars);
1355 $self->check_or_start($env, ($ENV{SMBD_MAXTIME
} or 7500));
1357 $self->wait_for_start($env);
1359 $self->{vars
}->{rpc_proxy
} = $env;
1366 my ($self, $path) = @_;
1368 my $env = $self->provision_dc($path);
1370 $self->check_or_start($env,
1371 ($ENV{SMBD_MAXTIME
} or 7500));
1373 $self->wait_for_start($env);
1375 $self->{vars
}->{dc
} = $env;
1380 sub setup_fl2000dc
($$)
1382 my ($self, $path) = @_;
1384 my $env = $self->provision_fl2000dc($path);
1386 $self->check_or_start($env,
1387 ($ENV{SMBD_MAXTIME
} or 7500));
1389 $self->wait_for_start($env);
1391 $self->{vars
}->{fl2000dc
} = $env;
1396 sub setup_fl2003dc
($$)
1398 my ($self, $path) = @_;
1400 my $env = $self->provision_fl2003dc($path);
1402 $self->check_or_start($env,
1403 ($ENV{SMBD_MAXTIME
} or 7500));
1405 $self->wait_for_start($env);
1407 $self->{vars
}->{fl2003dc
} = $env;
1412 sub setup_fl2008r2dc
($$)
1414 my ($self, $path) = @_;
1416 my $env = $self->provision_fl2008r2dc($path);
1418 $self->check_or_start($env,
1419 ($ENV{SMBD_MAXTIME
} or 7500));
1421 $self->wait_for_start($env);
1423 $self->{vars
}->{fl2008r2dc
} = $env;
1428 sub setup_vampire_dc
($$$)
1430 my ($self, $path, $dc_vars) = @_;
1432 my $env = $self->provision_vampire_dc($path, $dc_vars);
1434 $self->check_or_start($env,
1435 ($ENV{SMBD_MAXTIME
} or 7500));
1437 $self->wait_for_start($env);
1439 $self->{vars
}->{vampire_dc
} = $env;
1441 # force replicated DC to update repsTo/repsFrom
1442 # for vampired partitions
1443 my $net = $self->bindir_path("net");
1445 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
1446 $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
1447 $cmd .= " $net drs kcc $env->{DC_SERVER}";
1448 $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD}";
1449 unless (system($cmd) == 0) {
1450 warn("Failed to exec kcc\n$cmd");
1454 # as 'vampired' dc may add data in its local replica
1455 # we need to synchronize data between DCs
1456 my $base_dn = "DC=".join(",DC=", split(/\./, $dc_vars->{REALM
}));
1457 $cmd = "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
1458 $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
1459 $cmd .= " $net drs replicate $env->{DC_SERVER} $env->{VAMPIRE_DC_SERVER}";
1460 $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD}";
1461 # replicate Configuration NC
1462 my $cmd_repl = "$cmd \"CN=Configuration,$base_dn\"";
1463 unless(system($cmd_repl) == 0) {
1464 warn("Failed to replicate\n$cmd_repl");
1467 # replicate Default NC
1468 $cmd_repl = "$cmd \"$base_dn\"";
1469 unless(system($cmd_repl) == 0) {
1470 warn("Failed to replicate\n$cmd_repl");
1479 my ($self, $path, $dc_vars) = @_;
1481 my $env = $self->provision_rodc($path, $dc_vars);
1487 $self->check_or_start($env,
1488 ($ENV{SMBD_MAXTIME
} or 7500));
1490 $self->wait_for_start($env);
1492 $self->{vars
}->{rodc
} = $env;