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, $server_maxtime) = @_;
23 binary_mapping => $binary_mapping,
25 server_maxtime => $server_maxtime,
26 target3 => new Samba3($bindir, $binary_mapping, $srcdir, $server_maxtime)
32 sub scriptdir_path($$) {
33 my ($self, $path) = @_;
34 return "$self->{srcdir}/source4/scripting/$path";
37 sub openldap_start($$$) {
43 my ($self, $env_vars, $STDIN_READER) = @_;
44 my $ldbsearch = Samba::bindir_path($self, "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
56 open STDOUT, ">$env_vars->{LDAPDIR}/logs";
57 open STDERR, '>&STDOUT';
58 close($env_vars->{STDIN_PIPE});
59 open STDIN, ">&", $STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
61 if ($self->{ldap} eq "fedora-ds") {
62 exec("$ENV{FEDORA_DS_ROOT}/sbin/ns-slapd", "-D", $env_vars->{FEDORA_DS_DIR}, "-d0", "-i", $env_vars->{FEDORA_DS_PIDFILE});
63 } elsif ($self->{ldap} eq "openldap") {
64 exec($ENV{OPENLDAP_SLAPD}, "-dnone", "-F", $env_vars->{SLAPD_CONF_D}, "-h", $uri);
66 die("Unable to start slapd: $!");
68 $env_vars->{SLAPD_PID} = $pid;
70 while (system("$ldbsearch -H $uri -s base -b \"\" supportedLDAPVersion > /dev/null") != 0) {
73 $self->slapd_stop($env_vars);
83 my ($self, $envvars) = @_;
84 kill 9, $envvars->{SLAPD_PID};
88 sub check_or_start($$$)
90 my ($self, $env_vars, $process_model) = @_;
93 return 0 if $self->check_env($env_vars);
95 # use a pipe for stdin in the child processes. This allows
96 # those processes to monitor the pipe for EOF to ensure they
97 # exit when the test script exits
98 pipe($STDIN_READER, $env_vars->{STDIN_PIPE});
100 # Start slapd before samba, but with the fifo on stdin
101 if (defined($self->{ldap})) {
102 unless($self->slapd_start($env_vars, $STDIN_READER)) {
103 warn("couldn't start slapd (main run)");
108 print "STARTING SAMBA...";
111 # we want out from samba to go to the log file, but also
112 # to the users terminal when running 'make test' on the command
113 # line. This puts it on stderr on the terminal
114 open STDOUT, "| tee $env_vars->{SAMBA_TEST_LOG} 1>&2";
115 open STDERR, '>&STDOUT';
117 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
119 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
120 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
121 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
123 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
124 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
125 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
126 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
127 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
129 $ENV{UID_WRAPPER} = "1";
131 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "samba");
134 if (defined($ENV{SAMBA_OPTIONS})) {
135 @optargs = split(/ /, $ENV{SAMBA_OPTIONS});
137 if(defined($ENV{SAMBA_VALGRIND})) {
138 @preargs = split(/ /,$ENV{SAMBA_VALGRIND});
141 close($env_vars->{STDIN_PIPE});
142 open STDIN, ">&", $STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
144 exec(@preargs, Samba::bindir_path($self, "samba"), "-M", $process_model, "-i", "--maximum-runtime=$self->{server_maxtime}", $env_vars->{CONFIGURATION}, @optargs) or die("Unable to start samba: $!");
146 $env_vars->{SAMBA_PID} = $pid;
149 close($STDIN_READER);
154 sub wait_for_start($$)
156 my ($self, $testenv_vars) = @_;
158 # give time for nbt server to register its names
159 print "delaying for nbt name registration\n";
162 # This will return quickly when things are up, but be slow if we
163 # need to wait for (eg) SSL init
164 my $nmblookup = Samba::bindir_path($self, "nmblookup4");
165 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{SERVER}");
166 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{SERVER}");
167 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
168 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
169 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
170 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
171 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{SERVER}");
172 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{SERVER}");
173 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
174 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
175 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
176 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
178 # Ensure we have the first RID Set before we start tests. This makes the tests more reliable.
179 if ($testenv_vars->{SERVER_ROLE} eq "domain controller" and not ($testenv_vars->{NETBIOS_NAME} eq "rodc")) {
180 # Add hosts file for name lookups
181 $ENV{NSS_WRAPPER_HOSTS} = $testenv_vars->{NSS_WRAPPER_HOSTS};
183 print "waiting for working LDAP and a RID Set to be allocated\n";
184 my $ldbsearch = Samba::bindir_path($self, "ldbsearch");
186 my $base_dn = "DC=".join(",DC=", split(/\./, $testenv_vars->{REALM}));
187 my $rid_set_dn = "cn=RID Set,cn=$testenv_vars->{NETBIOSNAME},ou=domain controllers,$base_dn";
189 while (system("$ldbsearch -H ldap://$testenv_vars->{SERVER} -U$testenv_vars->{USERNAME}%$testenv_vars->{PASSWORD} -s base -b \"$rid_set_dn\" rIDAllocationPool > /dev/null") != 0) {
198 print $self->getlog_env($testenv_vars);
203 sub write_ldb_file($$$)
205 my ($self, $file, $ldif) = @_;
207 my $ldbadd = Samba::bindir_path($self, "ldbadd");
208 open(LDIF, "|$ldbadd -H $file >/dev/null");
213 sub add_wins_config($$)
215 my ($self, $privatedir) = @_;
217 return $self->write_ldb_file("$privatedir/wins_config.ldb", "
218 dn: name=TORTURE_11,CN=PARTNERS
219 objectClass: wreplPartner
230 my ($self, $ctx) = @_;
232 #Make the subdirectory be as fedora DS would expect
233 my $fedora_ds_dir = "$ctx->{ldapdir}/slapd-$ctx->{ldap_instance}";
235 my $pidfile = "$fedora_ds_dir/logs/slapd-$ctx->{ldap_instance}.pid";
237 return ($fedora_ds_dir, $pidfile);
242 my ($self, $ctx) = @_;
244 my $slapd_conf_d = "$ctx->{ldapdir}/slapd.d";
245 my $pidfile = "$ctx->{ldapdir}/slapd.pid";
247 return ($slapd_conf_d, $pidfile);
252 my ($self, $tlsdir) = @_;
254 #TLS and PKINIT crypto blobs
255 my $dhfile = "$tlsdir/dhparms.pem";
256 my $cafile = "$tlsdir/ca.pem";
257 my $certfile = "$tlsdir/cert.pem";
258 my $reqkdc = "$tlsdir/req-kdc.der";
259 my $kdccertfile = "$tlsdir/kdc.pem";
260 my $keyfile = "$tlsdir/key.pem";
261 my $adminkeyfile = "$tlsdir/adminkey.pem";
262 my $reqadmin = "$tlsdir/req-admin.der";
263 my $admincertfile = "$tlsdir/admincert.pem";
264 my $admincertupnfile = "$tlsdir/admincertupn.pem";
266 mkdir($tlsdir, 0700);
267 my $oldumask = umask;
270 #This is specified here to avoid draining entropy on every run
271 open(DHFILE, ">$dhfile");
273 -----BEGIN DH PARAMETERS-----
274 MGYCYQC/eWD2xkb7uELmqLi+ygPMKyVcpHUo2yCluwnbPutEueuxrG/Cys8j8wLO
275 svCN/jYNyR2NszOmg7ZWcOC/4z/4pWDVPUZr8qrkhj5MRKJc52MncfaDglvEdJrv
277 -----END DH PARAMETERS-----
281 #Likewise, we pregenerate the key material. This allows the
282 #other certificates to be pre-generated
283 open(KEYFILE
, ">$keyfile");
285 -----BEGIN RSA PRIVATE KEY-----
286 MIICXQIBAAKBgQDKg6pAwCHUMA1DfHDmWhZfd+F0C+9Jxcqvpw9ii9En3E1uflpc
287 ol3+S9/6I/uaTmJHZre+DF3dTzb/UOZo0Zem8N+IzzkgoGkFafjXuT3BL5UPY2/H
288 6H+pPqVIRLOmrWImai359YyoKhFyo37Y6HPeU8QcZ+u2rS9geapIWfeuowIDAQAB
289 AoGAAqDLzFRR/BF1kpsiUfL4WFvTarCe9duhwj7ORc6fs785qAXuwUYAJ0Uvzmy6
290 HqoGv3t3RfmeHDmjcpPHsbOKnsOQn2MgmthidQlPBMWtQMff5zdoYNUFiPS0XQBq
291 szNW4PRjaA9KkLQVTwnzdXGkBSkn/nGxkaVu7OR3vJOBoo0CQQDO4upypesnbe6p
292 9/xqfZ2uim8IwV1fLlFClV7WlCaER8tsQF4lEi0XSzRdXGUD/dilpY88Nb+xok/X
293 8Z8OvgAXAkEA+pcLsx1gN7kxnARxv54jdzQjC31uesJgMKQXjJ0h75aUZwTNHmZQ
294 vPxi6u62YiObrN5oivkixwFNncT9MxTxVQJBAMaWUm2SjlLe10UX4Zdm1MEB6OsC
295 kVoX37CGKO7YbtBzCfTzJGt5Mwc1DSLA2cYnGJqIfSFShptALlwedot0HikCQAJu
296 jNKEKnbf+TdGY8Q0SKvTebOW2Aeg80YFkaTvsXCdyXrmdQcifw4WdO9KucJiDhSz
297 Y9hVapz7ykEJtFtWjLECQQDIlfc63I5ZpXfg4/nN4IJXUW6AmPVOYIA5215itgki
298 cSlMYli1H9MEXH0pQMGv5Qyd0OYIx2DDg96mZ+aFvqSG
299 -----END RSA PRIVATE KEY-----
303 open(ADMINKEYFILE
, ">$adminkeyfile");
305 print ADMINKEYFILE
<<EOF;
306 -----BEGIN RSA PRIVATE KEY-----
307 MIICXQIBAAKBgQD0+OL7TQBj0RejbIH1+g5GeRaWaM9xF43uE5y7jUHEsi5owhZF
308 5iIoHZeeL6cpDF5y1BZRs0JlA1VqMry1jjKlzFYVEMMFxB6esnXhl0Jpip1JkUMM
309 XLOP1m/0dqayuHBWozj9f/cdyCJr0wJIX1Z8Pr+EjYRGPn/MF0xdl3JRlwIDAQAB
310 AoGAP8mjCP628Ebc2eACQzOWjgEvwYCPK4qPmYOf1zJkArzG2t5XAGJ5WGrENRuB
311 cm3XFh1lpmaADl982UdW3gul4gXUy6w4XjKK4vVfhyHj0kZ/LgaXUK9BAGhroJ2L
312 osIOUsaC6jdx9EwSRctwdlF3wWJ8NK0g28AkvIk+FlolW4ECQQD7w5ouCDnf58CN
313 u4nARx4xv5XJXekBvOomkCQAmuOsdOb6b9wn3mm2E3au9fueITjb3soMR31AF6O4
314 eAY126rXAkEA+RgHzybzZEP8jCuznMqoN2fq/Vrs6+W3M8/G9mzGEMgLLpaf2Jiz
315 I9tLZ0+OFk9tkRaoCHPfUOCrVWJZ7Y53QQJBAMhoA6rw0WDyUcyApD5yXg6rusf4
316 ASpo/tqDkqUIpoL464Qe1tjFqtBM3gSXuhs9xsz+o0bzATirmJ+WqxrkKTECQHt2
317 OLCpKqwAspU7N+w32kaUADoRLisCEdrhWklbwpQgwsIVsCaoEOpt0CLloJRYTANE
318 yoZeAErTALjyZYZEPcECQQDlUi0N8DFxQ/lOwWyR3Hailft+mPqoPCa8QHlQZnlG
319 +cfgNl57YHMTZFwgUVFRdJNpjH/WdZ5QxDcIVli0q+Ko
320 -----END RSA PRIVATE KEY-----
324 # hxtool issue-certificate --self-signed --issue-ca \
325 # --ca-private-key="FILE:$KEYFILE" \
326 # --subject="CN=CA,DC=samba,DC=example,DC=com" \
327 # --certificate="FILE:$CAFILE" --lifetime="25 years"
329 open(CAFILE
, ">$cafile");
331 -----BEGIN CERTIFICATE-----
332 MIICcTCCAdqgAwIBAgIUaBPmjnPVqyFqR5foICmLmikJTzgwCwYJKoZIhvcNAQEFMFIxEzAR
333 BgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxlMRUwEwYKCZImiZPy
334 LGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMCIYDzIwMDgwMzAxMTIyMzEyWhgPMjAzMzAyMjQx
335 MjIzMTJaMFIxEzARBgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxl
336 MRUwEwYKCZImiZPyLGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMIGfMA0GCSqGSIb3DQEBAQUA
337 A4GNADCBiQKBgQDKg6pAwCHUMA1DfHDmWhZfd+F0C+9Jxcqvpw9ii9En3E1uflpcol3+S9/6
338 I/uaTmJHZre+DF3dTzb/UOZo0Zem8N+IzzkgoGkFafjXuT3BL5UPY2/H6H+pPqVIRLOmrWIm
339 ai359YyoKhFyo37Y6HPeU8QcZ+u2rS9geapIWfeuowIDAQABo0IwQDAOBgNVHQ8BAf8EBAMC
340 AaYwHQYDVR0OBBYEFMLZufegDKLZs0VOyFXYK1L6M8oyMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
341 KoZIhvcNAQEFBQADgYEAAZJbCAAkaqgFJ0xgNovn8Ydd0KswQPjicwiODPgw9ZPoD2HiOUVO
342 yYDRg/dhFF9y656OpcHk4N7qZ2sl3RlHkzDu+dseETW+CnKvQIoXNyeARRJSsSlwrwcoD4JR
343 HTLk2sGigsWwrJ2N99sG/cqSJLJ1MFwLrs6koweBnYU0f/g=
344 -----END CERTIFICATE-----
347 #generated with GNUTLS internally in Samba.
349 open(CERTFILE
, ">$certfile");
350 print CERTFILE
<<EOF;
351 -----BEGIN CERTIFICATE-----
352 MIICYTCCAcygAwIBAgIE5M7SRDALBgkqhkiG9w0BAQUwZTEdMBsGA1UEChMUU2Ft
353 YmEgQWRtaW5pc3RyYXRpb24xNDAyBgNVBAsTK1NhbWJhIC0gdGVtcG9yYXJ5IGF1
354 dG9nZW5lcmF0ZWQgY2VydGlmaWNhdGUxDjAMBgNVBAMTBVNhbWJhMB4XDTA2MDgw
355 NDA0MzY1MloXDTA4MDcwNDA0MzY1MlowZTEdMBsGA1UEChMUU2FtYmEgQWRtaW5p
356 c3RyYXRpb24xNDAyBgNVBAsTK1NhbWJhIC0gdGVtcG9yYXJ5IGF1dG9nZW5lcmF0
357 ZWQgY2VydGlmaWNhdGUxDjAMBgNVBAMTBVNhbWJhMIGcMAsGCSqGSIb3DQEBAQOB
358 jAAwgYgCgYDKg6pAwCHUMA1DfHDmWhZfd+F0C+9Jxcqvpw9ii9En3E1uflpcol3+
359 S9/6I/uaTmJHZre+DF3dTzb/UOZo0Zem8N+IzzkgoGkFafjXuT3BL5UPY2/H6H+p
360 PqVIRLOmrWImai359YyoKhFyo37Y6HPeU8QcZ+u2rS9geapIWfeuowIDAQABoyUw
361 IzAMBgNVHRMBAf8EAjAAMBMGA1UdJQQMMAoGCCsGAQUFBwMBMAsGCSqGSIb3DQEB
362 BQOBgQAmkN6XxvDnoMkGcWLCTwzxGfNNSVcYr7TtL2aJh285Xw9zaxcm/SAZBFyG
363 LYOChvh6hPU7joMdDwGfbiLrBnMag+BtGlmPLWwp/Kt1wNmrRhduyTQFhN3PP6fz
364 nBr9vVny2FewB2gHmelaPS//tXdxivSXKz3NFqqXLDJjq7P8wA==
365 -----END CERTIFICATE-----
370 # hxtool request-create \
371 # --subject="CN=krbtgt,CN=users,DC=samba,DC=example,DC=com" \
372 # --key="FILE:$KEYFILE" $KDCREQ
374 # hxtool issue-certificate --ca-certificate=FILE:$CAFILE,$KEYFILE \
375 # --type="pkinit-kdc" \
376 # --pk-init-principal="krbtgt/SAMBA.EXAMPLE.COM@SAMBA.EXAMPLE.COM" \
377 # --req="PKCS10:$KDCREQ" --certificate="FILE:$KDCCERTFILE" \
378 # --lifetime="25 years"
380 open(KDCCERTFILE
, ">$kdccertfile");
381 print KDCCERTFILE
<<EOF;
382 -----BEGIN CERTIFICATE-----
383 MIIDDDCCAnWgAwIBAgIUI2Tzj+JnMzMcdeabcNo30rovzFAwCwYJKoZIhvcNAQEFMFIxEzAR
384 BgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxlMRUwEwYKCZImiZPy
385 LGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMCIYDzIwMDgwMzAxMTMxOTIzWhgPMjAzMzAyMjQx
386 MzE5MjNaMGYxEzARBgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxl
387 MRUwEwYKCZImiZPyLGQBGQwFc2FtYmExDjAMBgNVBAMMBXVzZXJzMQ8wDQYDVQQDDAZrcmJ0
388 Z3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMqDqkDAIdQwDUN8cOZaFl934XQL70nF
389 yq+nD2KL0SfcTW5+WlyiXf5L3/oj+5pOYkdmt74MXd1PNv9Q5mjRl6bw34jPOSCgaQVp+Ne5
390 PcEvlQ9jb8fof6k+pUhEs6atYiZqLfn1jKgqEXKjftjoc95TxBxn67atL2B5qkhZ966jAgMB
391 AAGjgcgwgcUwDgYDVR0PAQH/BAQDAgWgMBIGA1UdJQQLMAkGBysGAQUCAwUwVAYDVR0RBE0w
392 S6BJBgYrBgEFAgKgPzA9oBMbEVNBTUJBLkVYQU1QTEUuQ09NoSYwJKADAgEBoR0wGxsGa3Ji
393 dGd0GxFTQU1CQS5FWEFNUExFLkNPTTAfBgNVHSMEGDAWgBTC2bn3oAyi2bNFTshV2CtS+jPK
394 MjAdBgNVHQ4EFgQUwtm596AMotmzRU7IVdgrUvozyjIwCQYDVR0TBAIwADANBgkqhkiG9w0B
395 AQUFAAOBgQBmrVD5MCmZjfHp1nEnHqTIh8r7lSmVtDx4s9MMjxm9oNrzbKXynvdhwQYFVarc
396 ge4yRRDXtSebErOl71zVJI9CVeQQpwcH+tA85oGA7oeFtO/S7ls581RUU6tGgyxV4veD+lJv
397 KPH5LevUtgD+q9H4LU4Sq5N3iFwBaeryB0g2wg==
398 -----END CERTIFICATE-----
401 # hxtool request-create \
402 # --subject="CN=Administrator,CN=users,DC=samba,DC=example,DC=com" \
403 # --key="FILE:$ADMINKEYFILE" $ADMINREQFILE
405 # hxtool issue-certificate --ca-certificate=FILE:$CAFILE,$KEYFILE \
406 # --type="pkinit-client" \
407 # --pk-init-principal="administrator@SAMBA.EXAMPLE.COM" \
408 # --req="PKCS10:$ADMINREQFILE" --certificate="FILE:$ADMINCERTFILE" \
409 # --lifetime="25 years"
411 open(ADMINCERTFILE
, ">$admincertfile");
412 print ADMINCERTFILE
<<EOF;
413 -----BEGIN CERTIFICATE-----
414 MIIDHTCCAoagAwIBAgIUUggzW4lLRkMKe1DAR2NKatkMDYwwCwYJKoZIhvcNAQELMFIxEzAR
415 BgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxlMRUwEwYKCZImiZPy
416 LGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMCIYDzIwMDkwNzI3MDMzMjE1WhgPMjAzNDA3MjIw
417 MzMyMTVaMG0xEzARBgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxl
418 MRUwEwYKCZImiZPyLGQBGQwFc2FtYmExDjAMBgNVBAMMBXVzZXJzMRYwFAYDVQQDDA1BZG1p
419 bmlzdHJhdG9yMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD0+OL7TQBj0RejbIH1+g5G
420 eRaWaM9xF43uE5y7jUHEsi5owhZF5iIoHZeeL6cpDF5y1BZRs0JlA1VqMry1jjKlzFYVEMMF
421 xB6esnXhl0Jpip1JkUMMXLOP1m/0dqayuHBWozj9f/cdyCJr0wJIX1Z8Pr+EjYRGPn/MF0xd
422 l3JRlwIDAQABo4HSMIHPMA4GA1UdDwEB/wQEAwIFoDAoBgNVHSUEITAfBgcrBgEFAgMEBggr
423 BgEFBQcDAgYKKwYBBAGCNxQCAjBIBgNVHREEQTA/oD0GBisGAQUCAqAzMDGgExsRU0FNQkEu
424 RVhBTVBMRS5DT02hGjAYoAMCAQGhETAPGw1BZG1pbmlzdHJhdG9yMB8GA1UdIwQYMBaAFMLZ
425 ufegDKLZs0VOyFXYK1L6M8oyMB0GA1UdDgQWBBQg81bLyfCA88C2B/BDjXlGuaFaxjAJBgNV
426 HRMEAjAAMA0GCSqGSIb3DQEBCwUAA4GBAEf/OSHUDJaGdtWGNuJeqcVYVMwrfBAc0OSwVhz1
427 7/xqKHWo8wIMPkYRtaRHKLNDsF8GkhQPCpVsa6mX/Nt7YQnNvwd+1SBP5E8GvwWw9ZzLJvma
428 nk2n89emuayLpVtp00PymrDLRBcNaRjFReQU8f0o509kiVPHduAp3jOiy13l
429 -----END CERTIFICATE-----
431 close(ADMINCERTFILE
);
433 # hxtool issue-certificate --ca-certificate=FILE:$CAFILE,$KEYFILE \
434 # --type="pkinit-client" \
435 # --ms-upn="administrator@samba.example.com" \
436 # --req="PKCS10:$ADMINREQFILE" --certificate="FILE:$ADMINCERTUPNFILE" \
437 # --lifetime="25 years"
439 open(ADMINCERTUPNFILE
, ">$admincertupnfile");
440 print ADMINCERTUPNFILE
<<EOF;
441 -----BEGIN CERTIFICATE-----
442 MIIDDzCCAnigAwIBAgIUUp3CJMuNaEaAdPKp3QdNIwG7a4wwCwYJKoZIhvcNAQELMFIxEzAR
443 BgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxlMRUwEwYKCZImiZPy
444 LGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMCIYDzIwMDkwNzI3MDMzMzA1WhgPMjAzNDA3MjIw
445 MzMzMDVaMG0xEzARBgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxl
446 MRUwEwYKCZImiZPyLGQBGQwFc2FtYmExDjAMBgNVBAMMBXVzZXJzMRYwFAYDVQQDDA1BZG1p
447 bmlzdHJhdG9yMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD0+OL7TQBj0RejbIH1+g5G
448 eRaWaM9xF43uE5y7jUHEsi5owhZF5iIoHZeeL6cpDF5y1BZRs0JlA1VqMry1jjKlzFYVEMMF
449 xB6esnXhl0Jpip1JkUMMXLOP1m/0dqayuHBWozj9f/cdyCJr0wJIX1Z8Pr+EjYRGPn/MF0xd
450 l3JRlwIDAQABo4HEMIHBMA4GA1UdDwEB/wQEAwIFoDAoBgNVHSUEITAfBgcrBgEFAgMEBggr
451 BgEFBQcDAgYKKwYBBAGCNxQCAjA6BgNVHREEMzAxoC8GCisGAQQBgjcUAgOgIQwfYWRtaW5p
452 c3RyYXRvckBzYW1iYS5leGFtcGxlLmNvbTAfBgNVHSMEGDAWgBTC2bn3oAyi2bNFTshV2CtS
453 +jPKMjAdBgNVHQ4EFgQUIPNWy8nwgPPAtgfwQ415RrmhWsYwCQYDVR0TBAIwADANBgkqhkiG
454 9w0BAQsFAAOBgQBk42+egeUB3Ji2PC55fbt3FNKxvmm2xUUFkV9POK/YR9rajKOwk5jtYSeS
455 Zd7J9s//rNFNa7waklFkDaY56+QWTFtdvxfE+KoHaqt6X8u6pqi7p3M4wDKQox+9Dx8yWFyq
456 Wfz/8alZ5aMezCQzXJyIaJsCLeKABosSwHcpAFmxlQ==
457 -----END CERTIFICATE-----
463 sub provision_raw_prepare
($$$$$$$$$$)
465 my ($self, $prefix, $server_role, $hostname,
466 $domain, $realm, $functional_level,
467 $password, $kdc_ipv4) = @_;
469 my $netbiosname = uc($hostname);
471 unless(-d
$prefix or mkdir($prefix, 0777)) {
472 warn("Unable to create $prefix");
475 my $prefix_abs = abs_path
($prefix);
477 die ("prefix=''") if $prefix_abs eq "";
478 die ("prefix='/'") if $prefix_abs eq "/";
480 unless (system("rm -rf $prefix_abs/*") == 0) {
481 warn("Unable to clean up");
485 my $swiface = Samba
::get_interface
($hostname);
487 $ctx->{prefix
} = $prefix;
488 $ctx->{prefix_abs
} = $prefix_abs;
490 $ctx->{dns_host_file
} = "$ENV{SELFTEST_PREFIX}/dns_host_file";
492 $ctx->{server_role
} = $server_role;
493 $ctx->{hostname
} = $hostname;
494 $ctx->{netbiosname
} = $netbiosname;
495 $ctx->{swiface
} = $swiface;
496 $ctx->{password
} = $password;
497 $ctx->{kdc_ipv4
} = $kdc_ipv4;
500 # Set smbd log level here.
502 $ctx->{server_loglevel
} =$ENV{SERVER_LOG_LEVEL
} || 1;
503 $ctx->{username
} = "Administrator";
504 $ctx->{domain
} = $domain;
505 $ctx->{realm
} = uc($realm);
506 $ctx->{dnsname
} = lc($realm);
508 $ctx->{functional_level
} = $functional_level;
510 my $unix_name = ($ENV{USER
} or $ENV{LOGNAME
} or `whoami`);
512 $ctx->{unix_name
} = $unix_name;
513 $ctx->{unix_uid
} = $>;
514 my @mygid = split(" ", $();
515 $ctx->{unix_gid
} = $mygid[0];
516 $ctx->{unix_gids_str
} = $);
517 @
{$ctx->{unix_gids
}} = split(" ", $ctx->{unix_gids_str
});
519 $ctx->{etcdir
} = "$prefix_abs/etc";
520 $ctx->{piddir
} = "$prefix_abs/pid";
521 $ctx->{smb_conf
} = "$ctx->{etcdir}/smb.conf";
522 $ctx->{krb5_conf
} = "$ctx->{etcdir}/krb5.conf";
523 $ctx->{privatedir
} = "$prefix_abs/private";
524 $ctx->{ncalrpcdir
} = "$prefix_abs/ncalrpc";
525 $ctx->{lockdir
} = "$prefix_abs/lockdir";
526 $ctx->{logdir
} = "$prefix_abs/logs";
527 $ctx->{statedir
} = "$prefix_abs/statedir";
528 $ctx->{cachedir
} = "$prefix_abs/cachedir";
529 $ctx->{winbindd_socket_dir
} = "$prefix_abs/winbindd_socket";
530 $ctx->{winbindd_privileged_socket_dir
} = "$prefix_abs/winbindd_privileged_socket";
531 $ctx->{ntp_signd_socket_dir
} = "$prefix_abs/ntp_signd_socket";
532 $ctx->{nsswrap_passwd
} = "$ctx->{etcdir}/passwd";
533 $ctx->{nsswrap_group
} = "$ctx->{etcdir}/group";
534 $ctx->{nsswrap_hosts
} = "$ENV{SELFTEST_PREFIX}/hosts";
536 $ctx->{tlsdir
} = "$ctx->{privatedir}/tls";
538 $ctx->{ipv4
} = "127.0.0.$swiface";
539 $ctx->{ipv6
} = sprintf("fd00:0000:0000:0000:0000:0000:5357:5f%02x", $swiface);
540 $ctx->{interfaces
} = "$ctx->{ipv4}/8 $ctx->{ipv6}/64";
542 push(@
{$ctx->{directories
}}, $ctx->{privatedir
});
543 push(@
{$ctx->{directories
}}, $ctx->{etcdir
});
544 push(@
{$ctx->{directories
}}, $ctx->{piddir
});
545 push(@
{$ctx->{directories
}}, $ctx->{lockdir
});
546 push(@
{$ctx->{directories
}}, $ctx->{logdir
});
547 push(@
{$ctx->{directories
}}, $ctx->{statedir
});
548 push(@
{$ctx->{directories
}}, $ctx->{cachedir
});
550 $ctx->{smb_conf_extra_options
} = "";
552 my @provision_options = ();
553 push (@provision_options, "NSS_WRAPPER_PASSWD=\"$ctx->{nsswrap_passwd}\"");
554 push (@provision_options, "NSS_WRAPPER_GROUP=\"$ctx->{nsswrap_group}\"");
555 push (@provision_options, "NSS_WRAPPER_HOSTS=\"$ctx->{nsswrap_hosts}\"");
556 if (defined($ENV{GDB_PROVISION
})) {
557 push (@provision_options, "gdb --args");
558 if (!defined($ENV{PYTHON
})) {
559 push (@provision_options, "env");
560 push (@provision_options, "python");
563 if (defined($ENV{VALGRIND_PROVISION
})) {
564 push (@provision_options, "valgrind");
565 if (!defined($ENV{PYTHON
})) {
566 push (@provision_options, "env");
567 push (@provision_options, "python");
570 if (defined($ENV{PYTHON
})) {
571 push (@provision_options, $ENV{PYTHON
});
573 push (@provision_options, Samba
::bindir_path
($self, "samba-tool"));
574 push (@provision_options, "domain");
575 push (@provision_options, "provision");
576 push (@provision_options, "--configfile=$ctx->{smb_conf}");
577 push (@provision_options, "--host-name=$ctx->{hostname}");
578 push (@provision_options, "--host-ip=$ctx->{ipv4}");
579 push (@provision_options, "--quiet");
580 push (@provision_options, "--domain=$ctx->{domain}");
581 push (@provision_options, "--realm=$ctx->{realm}");
582 push (@provision_options, "--adminpass=$ctx->{password}");
583 push (@provision_options, "--krbtgtpass=krbtgt$ctx->{password}");
584 push (@provision_options, "--machinepass=machine$ctx->{password}");
585 push (@provision_options, "--root=$ctx->{unix_name}");
586 push (@provision_options, "--server-role=\"$ctx->{server_role}\"");
587 push (@provision_options, "--function-level=\"$ctx->{functional_level}\"");
589 @
{$ctx->{provision_options
}} = @provision_options;
595 # Step1 creates the basic configuration
597 sub provision_raw_step1
($$)
599 my ($self, $ctx) = @_;
601 mkdir($_, 0777) foreach (@
{$ctx->{directories
}});
604 ## lockdir and piddir must be 0755
606 chmod 0755, $ctx->{lockdir
};
607 chmod 0755, $ctx->{piddir
};
609 unless (open(CONFFILE
, ">$ctx->{smb_conf}")) {
610 warn("can't open $ctx->{smb_conf}$?");
615 netbios name = $ctx->{netbiosname}
616 posix:eadb = $ctx->{statedir}/eadb.tdb
617 workgroup = $ctx->{domain}
618 realm = $ctx->{realm}
619 private dir = $ctx->{privatedir}
620 pid directory = $ctx->{piddir}
621 ncalrpc dir = $ctx->{ncalrpcdir}
622 lock dir = $ctx->{lockdir}
623 state directory = $ctx->{statedir}
624 cache directory = $ctx->{cachedir}
625 winbindd socket directory = $ctx->{winbindd_socket_dir}
626 winbindd privileged socket directory = $ctx->{winbindd_privileged_socket_dir}
627 ntp signd socket directory = $ctx->{ntp_signd_socket_dir}
628 winbind separator = /
629 name resolve order = file bcast
630 interfaces = $ctx->{interfaces}
631 tls dh params file = $ctx->{tlsdir}/dhparms.pem
632 panic action = $RealBin/gdb_backtrace \%d
634 server role = $ctx->{server_role}
635 server services = +echo +smb -s3fs
636 dcerpc endpoint servers = +winreg +srvsvc
637 notify:inotify = false
639 #We don't want to pass our self-tests if the PAC code is wrong
640 gensec:require_pac = true
641 log file = $ctx->{logdir}/log.\%m
642 log level = $ctx->{server_loglevel}
645 dns update command = $ENV{SRCDIR_ABS}/source4/scripting/bin/samba_dnsupdate --all-interfaces --use-file=$ctx->{dns_host_file} -s $ctx->{smb_conf}
646 spn update command = $ENV{SRCDIR_ABS}/source4/scripting/bin/samba_spnupdate -s $ctx->{smb_conf}
647 resolv:host file = $ctx->{dns_host_file}
648 dreplsrv:periodic_startup_interval = 0
649 dsdb:schema update allowed = yes
651 vfs objects = dfs_samba4 acl_xattr fake_acls xattr_tdb streams_depot
653 # remove this again, when our smb2 client library
654 # supports signin on compound related requests
657 idmap_ldb:use rfc2307=yes
658 winbind enum users = yes
659 winbind enum groups = yes
664 # Begin extra options
665 $ctx->{smb_conf_extra_options}
670 $self->mk_keyblobs($ctx->{tlsdir
});
672 #Default the KDC IP to the server's IP
673 if (not defined($ctx->{kdc_ipv4
})) {
674 $ctx->{kdc_ipv4
} = $ctx->{ipv4
};
677 Samba
::mk_krb5_conf
($ctx, "");
679 open(PWD
, ">$ctx->{nsswrap_passwd}");
681 root:x:0:0:root gecos:$ctx->{prefix_abs}:/bin/false
682 $ctx->{unix_name}:x:$ctx->{unix_uid}:100:$ctx->{unix_name} gecos:$ctx->{prefix_abs}:/bin/false
683 nobody:x:65534:65533:nobody gecos:$ctx->{prefix_abs}:/bin/false
684 pdbtest:x:65533:65533:pdbtest gecos:$ctx->{prefix_abs}:/bin/false
685 pdbtest2:x:65532:65533:pdbtest gecos:$ctx->{prefix_abs}:/bin/false
686 pdbtest3:x:65531:65533:pdbtest gecos:$ctx->{prefix_abs}:/bin/false
687 pdbtest4:x:65530:65533:pdbtest gecos:$ctx->{prefix_abs}:/bin/false
690 my $uid_rfc2307test = 65533;
692 open(GRP
, ">$ctx->{nsswrap_group}");
698 nogroup:x:65534:nobody
699 $ctx->{unix_name}:x:$ctx->{unix_gid}:
702 my $gid_rfc2307test = 65532;
704 my $hostname = lc($ctx->{hostname
});
705 open(HOSTS
, ">>$ctx->{nsswrap_hosts}");
706 print HOSTS
"$ctx->{ipv4} ${hostname}.$ctx->{dnsname} ${hostname}\n";
707 print HOSTS
"$ctx->{ipv6} ${hostname}.$ctx->{dnsname} ${hostname}\n";
710 my $configuration = "--configfile=$ctx->{smb_conf}";
712 #Ensure the config file is valid before we start
713 my $testparm = Samba
::bindir_path
($self, "samba-tool") . " testparm";
714 if (system("$testparm $configuration -v --suppress-prompt >/dev/null 2>&1") != 0) {
715 system("$testparm -v --suppress-prompt $configuration >&2");
716 warn("Failed to create a valid smb.conf configuration $testparm!");
719 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) {
720 warn("Failed to create a valid smb.conf configuration! $testparm $configuration -v --suppress-prompt --parameter-name=\"netbios name\" --section-name=global");
725 KRB5_CONFIG
=> $ctx->{krb5_conf
},
726 PIDDIR
=> $ctx->{piddir
},
727 SERVER
=> $ctx->{hostname
},
728 SERVER_IP
=> $ctx->{ipv4
},
729 SERVER_IPV6
=> $ctx->{ipv6
},
730 NETBIOSNAME
=> $ctx->{netbiosname
},
731 DOMAIN
=> $ctx->{domain
},
732 USERNAME
=> $ctx->{username
},
733 REALM
=> $ctx->{realm
},
734 PASSWORD
=> $ctx->{password
},
735 LDAPDIR
=> $ctx->{ldapdir
},
736 LDAP_INSTANCE
=> $ctx->{ldap_instance
},
737 SELFTEST_WINBINDD_SOCKET_DIR
=> $ctx->{winbindd_socket_dir
},
738 NCALRPCDIR
=> $ctx->{ncalrpcdir
},
739 LOCKDIR
=> $ctx->{lockdir
},
740 STATEDIR
=> $ctx->{statedir
},
741 CACHEDIR
=> $ctx->{cachedir
},
742 PRIVATEDIR
=> $ctx->{privatedir
},
743 SERVERCONFFILE
=> $ctx->{smb_conf
},
744 CONFIGURATION
=> $configuration,
745 SOCKET_WRAPPER_DEFAULT_IFACE
=> $ctx->{swiface
},
746 NSS_WRAPPER_PASSWD
=> $ctx->{nsswrap_passwd
},
747 NSS_WRAPPER_GROUP
=> $ctx->{nsswrap_group
},
748 NSS_WRAPPER_HOSTS
=> $ctx->{nsswrap_hosts
},
749 SAMBA_TEST_FIFO
=> "$ctx->{prefix}/samba_test.fifo",
750 SAMBA_TEST_LOG
=> "$ctx->{prefix}/samba_test.log",
751 SAMBA_TEST_LOG_POS
=> 0,
752 NSS_WRAPPER_MODULE_SO_PATH
=> Samba
::nss_wrapper_winbind_so_path
($self),
753 NSS_WRAPPER_MODULE_FN_PREFIX
=> "winbind",
754 LOCAL_PATH
=> $ctx->{share
},
755 UID_RFC2307TEST
=> $uid_rfc2307test,
756 GID_RFC2307TEST
=> $gid_rfc2307test,
757 SERVER_ROLE
=> $ctx->{server_role
}
764 # Step2 runs the provision script
766 sub provision_raw_step2
($$$)
768 my ($self, $ctx, $ret) = @_;
770 my $provision_cmd = join(" ", @
{$ctx->{provision_options
}});
771 unless (system($provision_cmd) == 0) {
772 warn("Unable to provision: \n$provision_cmd\n");
779 sub provision
($$$$$$$$$)
781 my ($self, $prefix, $server_role, $hostname,
782 $domain, $realm, $functional_level,
783 $password, $kdc_ipv4, $extra_smbconf_options, $extra_smbconf_shares,
784 $extra_provision_options) = @_;
786 my $ctx = $self->provision_raw_prepare($prefix, $server_role,
788 $domain, $realm, $functional_level,
789 $password, $kdc_ipv4);
791 if (defined($extra_provision_options)) {
792 push (@
{$ctx->{provision_options
}}, @
{$extra_provision_options});
794 push (@
{$ctx->{provision_options
}}, "--use-ntvfs");
797 $ctx->{share
} = "$ctx->{prefix_abs}/share";
798 push(@
{$ctx->{directories
}}, "$ctx->{share}");
799 push(@
{$ctx->{directories
}}, "$ctx->{share}/test1");
800 push(@
{$ctx->{directories
}}, "$ctx->{share}/test2");
802 # precreate directories for printer drivers
803 push(@
{$ctx->{directories
}}, "$ctx->{share}/W32X86");
804 push(@
{$ctx->{directories
}}, "$ctx->{share}/x64");
805 push(@
{$ctx->{directories
}}, "$ctx->{share}/WIN40");
808 $msdfs = "yes" if ($server_role eq "domain controller");
809 $ctx->{smb_conf_extra_options
} = "
812 server max protocol = SMB2
815 allow nt4 crypto = yes
817 $extra_smbconf_options
822 posix:sharedelay = 10000
823 posix:oplocktimeout = 3
824 posix:writetimeupdatedelay = 50000
829 posix:sharedelay = 10000
830 posix:oplocktimeout = 3
831 posix:writetimeupdatedelay = 50000
833 force create mode = 777
839 force create mode = 0
840 directory mask = 0777
841 force directory mode = 0
844 path = $ctx->{share}/test1
846 posix:sharedelay = 10000
847 posix:oplocktimeout = 3
848 posix:writetimeupdatedelay = 50000
851 path = $ctx->{share}/test2
853 posix:sharedelay = 10000
854 posix:oplocktimeout = 3
855 posix:writetimeupdatedelay = 50000
858 path = $ctx->{share}/_ignore_cifs_
861 cifs:server = $ctx->{netbiosname}
863 cifs:use-s4u2proxy = yes
864 # There is no username specified here, instead the client is expected
865 # to log in with kerberos, and the serverwill use delegated credentials.
866 # Or the server tries s4u2self/s4u2proxy to impersonate the client
871 ntvfs handler = simple
874 path = $ctx->{statedir}/sysvol
878 path = $ctx->{statedir}/sysvol/$ctx->{dnsname}/scripts
883 ntvfs handler = cifsposix
887 vfs objects = catia fruit streams_xattr
888 fruit:ressource = file
889 fruit:metadata = netatalk
890 fruit:locking = netatalk
891 fruit:encoding = native
893 $extra_smbconf_shares
896 if (defined($self->{ldap
})) {
897 $ctx->{ldapdir
} = "$ctx->{privatedir}/ldap";
898 push(@
{$ctx->{directories
}}, "$ctx->{ldapdir}");
900 my $ldap_uri= "$ctx->{ldapdir}/ldapi";
901 $ldap_uri =~ s
|/|%2F|g
;
902 $ldap_uri = "ldapi://$ldap_uri";
903 $ctx->{ldap_uri
} = $ldap_uri;
905 $ctx->{ldap_instance
} = lc($ctx->{netbiosname
});
908 my $ret = $self->provision_raw_step1($ctx);
909 unless (defined $ret) {
913 if (defined($self->{ldap
})) {
914 $ret->{LDAP_URI
} = $ctx->{ldap_uri
};
915 push (@
{$ctx->{provision_options
}}, "--ldap-backend-type=" . $self->{ldap
});
916 push (@
{$ctx->{provision_options
}}, "--ldap-backend-nosync");
917 if ($self->{ldap
} eq "openldap") {
918 push (@
{$ctx->{provision_options
}}, "--slapd-path=" . $ENV{OPENLDAP_SLAPD
});
919 ($ret->{SLAPD_CONF_D
}, $ret->{OPENLDAP_PIDFILE
}) = $self->mk_openldap($ctx) or die("Unable to create openldap directories");
921 } elsif ($self->{ldap
} eq "fedora-ds") {
922 push (@
{$ctx->{provision_options
}}, "--slapd-path=" . "$ENV{FEDORA_DS_ROOT}/sbin/ns-slapd");
923 push (@
{$ctx->{provision_options
}}, "--setup-ds-path=" . "$ENV{FEDORA_DS_ROOT}/sbin/setup-ds.pl");
924 ($ret->{FEDORA_DS_DIR
}, $ret->{FEDORA_DS_PIDFILE
}) = $self->mk_fedora_ds($ctx) or die("Unable to create fedora ds directories");
929 return $self->provision_raw_step2($ctx, $ret);
932 sub provision_s4member
($$$)
934 my ($self, $prefix, $dcvars) = @_;
935 print "PROVISIONING MEMBER...";
936 my $extra_smb_conf = "
937 passdb backend = samba_dsdb
938 winbindd:use external pipes = true
940 rpc_server:default = external
941 rpc_server:svcctl = embedded
942 rpc_server:srvsvc = embedded
943 rpc_server:eventlog = embedded
944 rpc_server:ntsvcs = embedded
945 rpc_server:winreg = embedded
946 rpc_server:spoolss = embedded
947 rpc_daemon:spoolssd = embedded
948 rpc_server:tcpip = no
950 my $ret = $self->provision($prefix,
957 $dcvars->{SERVER_IP
},
958 $extra_smb_conf, "", undef);
963 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
965 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
966 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
967 $cmd .= "$samba_tool domain join $ret->{CONFIGURATION} $dcvars->{REALM} member";
968 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
969 $cmd .= " --machinepass=machine$ret->{PASSWORD}";
971 unless (system($cmd) == 0) {
972 warn("Join failed\n$cmd");
976 $ret->{MEMBER_SERVER
} = $ret->{SERVER
};
977 $ret->{MEMBER_SERVER_IP
} = $ret->{SERVER_IP
};
978 $ret->{MEMBER_SERVER_IPV6
} = $ret->{SERVER_IPV6
};
979 $ret->{MEMBER_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
980 $ret->{MEMBER_USERNAME
} = $ret->{USERNAME
};
981 $ret->{MEMBER_PASSWORD
} = $ret->{PASSWORD
};
983 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
984 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
985 $ret->{DC_SERVER_IPV6
} = $dcvars->{DC_SERVER_IPV6
};
986 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
987 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
988 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
993 sub provision_rpc_proxy
($$$)
995 my ($self, $prefix, $dcvars) = @_;
996 print "PROVISIONING RPC PROXY...";
998 my $extra_smbconf_options = "
999 passdb backend = samba_dsdb
1002 dcerpc_remote:binding = ncacn_ip_tcp:$dcvars->{SERVER}
1003 dcerpc endpoint servers = epmapper, remote
1004 dcerpc_remote:interfaces = rpcecho
1007 path = /tmp/_ignore_cifs_to_dc_/_none_
1009 ntvfs handler = cifs
1010 cifs:server = $dcvars->{SERVER}
1012 cifs:use-s4u2proxy = yes
1013 # There is no username specified here, instead the client is expected
1014 # to log in with kerberos, and the serverwill use delegated credentials.
1015 # Or the server tries s4u2self/s4u2proxy to impersonate the client
1019 my $ret = $self->provision($prefix,
1023 "samba.example.com",
1026 $dcvars->{SERVER_IP
},
1027 $extra_smbconf_options, "", undef);
1033 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
1035 # The joind runs in the context of the rpc_proxy/member for now
1037 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1038 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1039 $cmd .= "$samba_tool domain join $ret->{CONFIGURATION} $dcvars->{REALM} member";
1040 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
1041 $cmd .= " --machinepass=machine$ret->{PASSWORD}";
1043 unless (system($cmd) == 0) {
1044 warn("Join failed\n$cmd");
1048 # Setting up delegation runs in the context of the DC for now
1050 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$dcvars->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1051 $cmd .= "KRB5_CONFIG=\"$dcvars->{KRB5_CONFIG}\" ";
1052 $cmd .= "$samba_tool delegation for-any-protocol '$ret->{NETBIOSNAME}\$' on";
1053 $cmd .= " $dcvars->{CONFIGURATION}";
1056 unless (system($cmd) == 0) {
1057 warn("Delegation failed\n$cmd");
1061 # Setting up delegation runs in the context of the DC for now
1063 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$dcvars->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1064 $cmd .= "KRB5_CONFIG=\"$dcvars->{KRB5_CONFIG}\" ";
1065 $cmd .= "$samba_tool delegation add-service '$ret->{NETBIOSNAME}\$' cifs/$dcvars->{SERVER}";
1066 $cmd .= " $dcvars->{CONFIGURATION}";
1068 unless (system($cmd) == 0) {
1069 warn("Delegation failed\n$cmd");
1073 $ret->{RPC_PROXY_SERVER
} = $ret->{SERVER
};
1074 $ret->{RPC_PROXY_SERVER_IP
} = $ret->{SERVER_IP
};
1075 $ret->{RPC_PROXY_SERVER_IPV6
} = $ret->{SERVER_IPV6
};
1076 $ret->{RPC_PROXY_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1077 $ret->{RPC_PROXY_USERNAME
} = $ret->{USERNAME
};
1078 $ret->{RPC_PROXY_PASSWORD
} = $ret->{PASSWORD
};
1080 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
1081 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
1082 $ret->{DC_SERVER_IPV6
} = $dcvars->{DC_SERVER_IPV6
};
1083 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
1084 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
1085 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
1090 sub provision_promoted_dc
($$$)
1092 my ($self, $prefix, $dcvars) = @_;
1093 print "PROVISIONING VAMPIRE DC...";
1095 # We do this so that we don't run the provision. That's the job of 'net vampire'.
1096 my $ctx = $self->provision_raw_prepare($prefix, "domain controller",
1099 "samba.example.com",
1101 $dcvars->{PASSWORD
},
1102 $dcvars->{SERVER_IP
});
1104 push (@
{$ctx->{provision_options
}}, "--use-ntvfs");
1106 $ctx->{smb_conf_extra_options
} = "
1108 server max protocol = SMB2
1111 path = $ctx->{statedir}/sysvol
1115 path = $ctx->{statedir}/sysvol/$ctx->{dnsname}/scripts
1120 my $ret = $self->provision_raw_step1($ctx);
1125 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
1127 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1128 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1129 $cmd .= "$samba_tool domain join $ret->{CONFIGURATION} $dcvars->{REALM} MEMBER --realm=$dcvars->{REALM}";
1130 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
1131 $cmd .= " --machinepass=machine$ret->{PASSWORD}";
1133 unless (system($cmd) == 0) {
1134 warn("Join failed\n$cmd");
1138 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
1140 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1141 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1142 $cmd .= "$samba_tool domain dcpromo $ret->{CONFIGURATION} $dcvars->{REALM} DC --realm=$dcvars->{REALM}";
1143 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
1144 $cmd .= " --machinepass=machine$ret->{PASSWORD} --use-ntvfs --dns-backend=BIND9_DLZ";
1146 unless (system($cmd) == 0) {
1147 warn("Join failed\n$cmd");
1151 $ret->{PROMOTED_DC_SERVER
} = $ret->{SERVER
};
1152 $ret->{PROMOTED_DC_SERVER_IP
} = $ret->{SERVER_IP
};
1153 $ret->{PROMOTED_DC_SERVER_IPV6
} = $ret->{SERVER_IPV6
};
1154 $ret->{PROMOTED_DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1156 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
1157 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
1158 $ret->{DC_SERVER_IPV6
} = $dcvars->{DC_SERVER_IPV6
};
1159 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
1160 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
1161 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
1166 sub provision_vampire_dc
($$$)
1168 my ($self, $prefix, $dcvars) = @_;
1169 print "PROVISIONING VAMPIRE DC...";
1171 # We do this so that we don't run the provision. That's the job of 'net vampire'.
1172 my $ctx = $self->provision_raw_prepare($prefix, "domain controller",
1175 "samba.example.com",
1177 $dcvars->{PASSWORD
},
1178 $dcvars->{SERVER_IP
});
1180 push (@
{$ctx->{provision_options
}}, "--use-ntvfs");
1182 $ctx->{smb_conf_extra_options
} = "
1184 server max protocol = SMB2
1187 path = $ctx->{statedir}/sysvol
1191 path = $ctx->{statedir}/sysvol/$ctx->{dnsname}/scripts
1196 my $ret = $self->provision_raw_step1($ctx);
1201 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
1203 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1204 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1205 $cmd .= "$samba_tool domain join $ret->{CONFIGURATION} $dcvars->{REALM} DC --realm=$dcvars->{REALM}";
1206 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD} --domain-critical-only";
1207 $cmd .= " --machinepass=machine$ret->{PASSWORD} --use-ntvfs";
1209 unless (system($cmd) == 0) {
1210 warn("Join failed\n$cmd");
1214 $ret->{VAMPIRE_DC_SERVER
} = $ret->{SERVER
};
1215 $ret->{VAMPIRE_DC_SERVER_IP
} = $ret->{SERVER_IP
};
1216 $ret->{VAMPIRE_DC_SERVER_IPV6
} = $ret->{SERVER_IPV6
};
1217 $ret->{VAMPIRE_DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1219 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
1220 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
1221 $ret->{DC_SERVER_IPV6
} = $dcvars->{DC_SERVER_IPV6
};
1222 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
1223 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
1224 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
1225 $ret->{DC_REALM
} = $dcvars->{DC_REALM
};
1230 sub provision_subdom_dc
($$$)
1232 my ($self, $prefix, $dcvars) = @_;
1233 print "PROVISIONING SUBDOMAIN DC...";
1235 # We do this so that we don't run the provision. That's the job of 'net vampire'.
1236 my $ctx = $self->provision_raw_prepare($prefix, "domain controller",
1239 "sub.samba.example.com",
1241 $dcvars->{PASSWORD
},
1244 push (@
{$ctx->{provision_options
}}, "--use-ntvfs");
1246 $ctx->{smb_conf_extra_options
} = "
1248 server max protocol = SMB2
1251 path = $ctx->{statedir}/sysvol
1255 path = $ctx->{statedir}/sysvol/$ctx->{dnsname}/scripts
1260 my $ret = $self->provision_raw_step1($ctx);
1265 # This ensures we share the krb5.conf with the main DC, so
1266 # they can find each other. Sadly only works between 'dc' and
1267 # 'subdom_dc', the other DCs won't see it
1269 my $dc_realms = Samba
::mk_realms_stanza
($dcvars->{REALM
}, lc($dcvars->{REALM
}),
1270 $dcvars->{DOMAIN
}, $dcvars->{SERVER_IP
});
1272 $ret->{KRB5_CONFIG
} = $dcvars->{KRB5_CONFIG
};
1273 $ctx->{krb5_conf
} = $dcvars->{KRB5_CONFIG
};
1275 Samba
::mk_krb5_conf
($ctx, $dc_realms);
1277 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
1279 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1280 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1281 $cmd .= "$samba_tool domain join $ret->{CONFIGURATION} $ctx->{dnsname} subdomain ";
1282 $cmd .= "--parent-domain=$dcvars->{REALM} -U$dcvars->{DC_USERNAME}\@$dcvars->{REALM}\%$dcvars->{DC_PASSWORD}";
1283 $cmd .= " --machinepass=machine$ret->{PASSWORD} --use-ntvfs";
1284 $cmd .= " --adminpass=$ret->{PASSWORD}";
1286 unless (system($cmd) == 0) {
1287 warn("Join failed\n$cmd");
1291 $ret->{SUBDOM_DC_SERVER
} = $ret->{SERVER
};
1292 $ret->{SUBDOM_DC_SERVER_IP
} = $ret->{SERVER_IP
};
1293 $ret->{SUBDOM_DC_SERVER_IPV6
} = $ret->{SERVER_IPV6
};
1294 $ret->{SUBDOM_DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1296 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
1297 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
1298 $ret->{DC_SERVER_IPV6
} = $dcvars->{DC_SERVER_IPV6
};
1299 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
1300 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
1301 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
1306 sub provision_dc
($$)
1308 my ($self, $prefix) = @_;
1310 print "PROVISIONING DC...";
1311 my $extra_conf_options = "netbios aliases = localDC1-a
1312 server services = +winbind -winbindd";
1313 my $ret = $self->provision($prefix,
1314 "domain controller",
1317 "samba.example.com",
1320 undef, $extra_conf_options, "", undef);
1322 return undef unless(defined $ret);
1323 unless($self->add_wins_config("$prefix/private")) {
1324 warn("Unable to add wins configuration");
1327 $ret->{NETBIOSALIAS
} = "localdc1-a";
1328 $ret->{DC_SERVER
} = $ret->{SERVER
};
1329 $ret->{DC_SERVER_IP
} = $ret->{SERVER_IP
};
1330 $ret->{DC_SERVER_IPV6
} = $ret->{SERVER_IPV6
};
1331 $ret->{DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1332 $ret->{DC_USERNAME
} = $ret->{USERNAME
};
1333 $ret->{DC_PASSWORD
} = $ret->{PASSWORD
};
1334 $ret->{DC_REALM
} = $ret->{REALM
};
1339 sub provision_fl2000dc
($$)
1341 my ($self, $prefix) = @_;
1343 print "PROVISIONING DC...";
1344 my $ret = $self->provision($prefix,
1345 "domain controller",
1348 "samba2000.example.com",
1351 undef, "", "", undef);
1353 unless($self->add_wins_config("$prefix/private")) {
1354 warn("Unable to add wins configuration");
1361 sub provision_fl2003dc
($$)
1363 my ($self, $prefix) = @_;
1365 print "PROVISIONING DC...";
1366 my $extra_conf_options = "allow dns updates = nonsecure and secure";
1367 my $ret = $self->provision($prefix,
1368 "domain controller",
1371 "samba2003.example.com",
1374 undef, $extra_conf_options, "", undef);
1376 unless (defined $ret) {
1380 $ret->{DC_SERVER
} = $ret->{SERVER
};
1381 $ret->{DC_SERVER_IP
} = $ret->{SERVER_IP
};
1382 $ret->{DC_SERVER_IPV6
} = $ret->{SERVER_IPV6
};
1383 $ret->{DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1384 $ret->{DC_USERNAME
} = $ret->{USERNAME
};
1385 $ret->{DC_PASSWORD
} = $ret->{PASSWORD
};
1387 my @samba_tool_options;
1388 push (@samba_tool_options, Samba
::bindir_path
($self, "samba-tool"));
1389 push (@samba_tool_options, "domain");
1390 push (@samba_tool_options, "passwordsettings");
1391 push (@samba_tool_options, "set");
1392 push (@samba_tool_options, "--configfile=$ret->{SERVERCONFFILE}");
1393 push (@samba_tool_options, "--min-pwd-age=0");
1394 push (@samba_tool_options, "--history-length=1");
1396 my $samba_tool_cmd = join(" ", @samba_tool_options);
1398 unless (system($samba_tool_cmd) == 0) {
1399 warn("Unable to set min password age to 0: \n$samba_tool_cmd\n");
1405 unless($self->add_wins_config("$prefix/private")) {
1406 warn("Unable to add wins configuration");
1413 sub provision_fl2008r2dc
($$)
1415 my ($self, $prefix) = @_;
1417 print "PROVISIONING DC...";
1418 my $ret = $self->provision($prefix,
1419 "domain controller",
1422 "samba2008R2.example.com",
1425 undef, "", "", undef);
1427 unless ($self->add_wins_config("$prefix/private")) {
1428 warn("Unable to add wins configuration");
1436 sub provision_rodc
($$$)
1438 my ($self, $prefix, $dcvars) = @_;
1439 print "PROVISIONING RODC...";
1441 # We do this so that we don't run the provision. That's the job of 'net join RODC'.
1442 my $ctx = $self->provision_raw_prepare($prefix, "domain controller",
1445 "samba.example.com",
1447 $dcvars->{PASSWORD
},
1448 $dcvars->{SERVER_IP
});
1453 push (@
{$ctx->{provision_options
}}, "--use-ntvfs");
1455 $ctx->{share
} = "$ctx->{prefix_abs}/share";
1456 push(@
{$ctx->{directories
}}, "$ctx->{share}");
1458 $ctx->{smb_conf_extra_options
} = "
1460 server max protocol = SMB2
1463 path = $ctx->{statedir}/sysvol
1467 path = $ctx->{statedir}/sysvol/$ctx->{dnsname}/scripts
1471 path = $ctx->{share}
1473 posix:sharedelay = 10000
1474 posix:oplocktimeout = 3
1475 posix:writetimeupdatedelay = 50000
1479 my $ret = $self->provision_raw_step1($ctx);
1484 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
1486 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1487 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1488 $cmd .= "$samba_tool domain join $ret->{CONFIGURATION} $dcvars->{REALM} RODC";
1489 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
1490 $cmd .= " --server=$dcvars->{DC_SERVER} --use-ntvfs";
1492 unless (system($cmd) == 0) {
1493 warn("RODC join failed\n$cmd");
1497 # we overwrite the kdc after the RODC join
1498 # so that use the RODC as kdc and test
1500 $ctx->{kdc_ipv4
} = $ret->{SERVER_IP
};
1501 Samba
::mk_krb5_conf
($ctx);
1503 $ret->{RODC_DC_SERVER
} = $ret->{SERVER
};
1504 $ret->{RODC_DC_SERVER_IP
} = $ret->{SERVER_IP
};
1505 $ret->{RODC_DC_SERVER_IPV6
} = $ret->{SERVER_IPV6
};
1506 $ret->{RODC_DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1508 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
1509 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
1510 $ret->{DC_SERVER_IPV6
} = $dcvars->{DC_SERVER_IPV6
};
1511 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
1512 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
1513 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
1518 sub provision_plugin_s4_dc
($$)
1520 my ($self, $prefix) = @_;
1522 my $prefix_abs = abs_path
($prefix);
1524 my $bindir_abs = abs_path
($self->{bindir
});
1525 my $lockdir="$prefix_abs/lockdir";
1526 my $conffile="$prefix_abs/etc/smb.conf";
1528 my $extra_smbconf_options = "
1529 server services = -smb +s3fs
1530 xattr_tdb:file = $prefix_abs/statedir/xattr.tdb
1532 dbwrap_tdb_mutexes:* = yes
1535 kernel change notify = no
1539 printcap name = /dev/null
1543 server signing = auto
1545 smbd:sharedelay = 100000
1546 smbd:writetimeupdatedelay = 500000
1550 dcerpc endpoint servers = -winreg -srvsvc
1552 printcap name = /dev/null
1554 addprinter command = $ENV{SRCDIR_ABS}/source3/script/tests/printing/modprinter.pl -a -s $conffile --
1555 deleteprinter command = $ENV{SRCDIR_ABS}/source3/script/tests/printing/modprinter.pl -d -s $conffile --
1558 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
1559 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
1560 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
1561 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
1562 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
1563 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
1564 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
1566 print notify backchannel = yes
1569 my $extra_smbconf_shares = "
1573 smb encrypt = required
1577 case sensitive = yes
1585 hide unreadable = yes
1589 kernel share modes = no
1608 print "PROVISIONING PLUGIN S4 DC...";
1609 my $ret = $self->provision($prefix,
1610 "domain controller",
1613 "plugindc.samba.example.com",
1616 undef, $extra_smbconf_options,
1617 $extra_smbconf_shares, undef);
1619 return undef unless(defined $ret);
1620 unless($self->add_wins_config("$prefix/private")) {
1621 warn("Unable to add wins configuration");
1625 $ret->{DC_SERVER
} = $ret->{SERVER
};
1626 $ret->{DC_SERVER_IP
} = $ret->{SERVER_IP
};
1627 $ret->{DC_SERVER_IPV6
} = $ret->{SERVER_IPV6
};
1628 $ret->{DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1629 $ret->{DC_USERNAME
} = $ret->{USERNAME
};
1630 $ret->{DC_PASSWORD
} = $ret->{PASSWORD
};
1635 sub provision_chgdcpass
($$)
1637 my ($self, $prefix) = @_;
1639 print "PROVISIONING CHGDCPASS...";
1640 my $extra_provision_options = undef;
1641 push (@
{$extra_provision_options}, "--dns-backend=BIND9_DLZ");
1642 my $extra_conf_options = "server services = +winbind -winbindd";
1643 my $ret = $self->provision($prefix,
1644 "domain controller",
1647 "chgdcpassword.samba.example.com",
1650 undef, $extra_conf_options, "",
1651 $extra_provision_options);
1653 return undef unless(defined $ret);
1654 unless($self->add_wins_config("$prefix/private")) {
1655 warn("Unable to add wins configuration");
1659 # Remove secrets.tdb from this environment to test that we
1660 # still start up on systems without the new matching
1661 # secrets.tdb records. For this reason we don't run winbindd
1662 # in this environment
1663 unless (unlink("$ret->{PRIVATEDIR}/secrets.tdb") || unlink("$ret->{PRIVATEDIR}/secrets.ntdb")) {
1664 warn("Unable to remove $ret->{PRIVATEDIR}/secrets.tdb added during provision");
1668 $ret->{DC_SERVER
} = $ret->{SERVER
};
1669 $ret->{DC_SERVER_IP
} = $ret->{SERVER_IP
};
1670 $ret->{DC_SERVER_IPV6
} = $ret->{SERVER_IPV6
};
1671 $ret->{DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1672 $ret->{DC_USERNAME
} = $ret->{USERNAME
};
1673 $ret->{DC_PASSWORD
} = $ret->{PASSWORD
};
1678 sub teardown_env
($$)
1680 my ($self, $envvars) = @_;
1683 # This should cause samba to terminate gracefully
1684 close($envvars->{STDIN_PIPE
});
1686 $pid = $envvars->{SAMBA_PID
};
1690 # This should give it time to write out the gcov data
1691 until ($count > 30) {
1692 if (Samba
::cleanup_child
($pid, "samba") == -1) {
1699 if ($count > 30 || kill(0, $pid)) {
1702 until ($count > 40) {
1703 if (Samba
::cleanup_child
($pid, "samba") == -1) {
1709 # If it is still around, kill it
1710 warn "server process $pid took more than $count seconds to exit, killing\n";
1714 $self->slapd_stop($envvars) if ($self->{ldap
});
1716 print $self->getlog_env($envvars);
1723 my ($self, $envvars) = @_;
1724 my $title = "SAMBA LOG of: $envvars->{NETBIOSNAME}\n";
1727 open(LOG
, "<$envvars->{SAMBA_TEST_LOG}");
1729 seek(LOG
, $envvars->{SAMBA_TEST_LOG_POS
}, SEEK_SET
);
1733 $envvars->{SAMBA_TEST_LOG_POS
} = tell(LOG
);
1736 return "" if $out eq $title;
1743 my ($self, $envvars) = @_;
1745 my $childpid = Samba
::cleanup_child
($envvars->{SAMBA_PID
}, "samba");
1747 return ($childpid == 0);
1752 my ($self, $envname, $path) = @_;
1753 my $target3 = $self->{target3
};
1755 $ENV{ENVNAME
} = $envname;
1757 if (defined($self->{vars
}->{$envname})) {
1758 return $self->{vars
}->{$envname};
1761 if ($envname eq "dc") {
1762 return $self->setup_dc("$path/dc");
1763 } elsif ($envname eq "fl2000dc") {
1764 return $self->setup_fl2000dc("$path/fl2000dc");
1765 } elsif ($envname eq "fl2003dc") {
1766 return $self->setup_fl2003dc("$path/fl2003dc");
1767 } elsif ($envname eq "fl2008r2dc") {
1768 return $self->setup_fl2008r2dc("$path/fl2008r2dc");
1769 } elsif ($envname eq "rpc_proxy") {
1770 if (not defined($self->{vars
}->{dc
})) {
1771 $self->setup_dc("$path/dc");
1773 return $self->setup_rpc_proxy("$path/rpc_proxy", $self->{vars
}->{dc
});
1774 } elsif ($envname eq "vampire_dc") {
1775 if (not defined($self->{vars
}->{dc
})) {
1776 $self->setup_dc("$path/dc");
1778 return $self->setup_vampire_dc("$path/vampire_dc", $self->{vars
}->{dc
});
1779 } elsif ($envname eq "promoted_dc") {
1780 if (not defined($self->{vars
}->{dc
})) {
1781 $self->setup_dc("$path/dc");
1783 return $self->setup_promoted_dc("$path/promoted_dc", $self->{vars
}->{dc
});
1784 } elsif ($envname eq "subdom_dc") {
1785 if (not defined($self->{vars
}->{dc
})) {
1786 $self->setup_dc("$path/dc");
1788 return $self->setup_subdom_dc("$path/subdom_dc", $self->{vars
}->{dc
});
1789 } elsif ($envname eq "s4member") {
1790 if (not defined($self->{vars
}->{dc
})) {
1791 $self->setup_dc("$path/dc");
1793 return $self->setup_s4member("$path/s4member", $self->{vars
}->{dc
});
1794 } elsif ($envname eq "rodc") {
1795 if (not defined($self->{vars
}->{dc
})) {
1796 $self->setup_dc("$path/dc");
1798 return $self->setup_rodc("$path/rodc", $self->{vars
}->{dc
});
1799 } elsif ($envname eq "chgdcpass") {
1800 return $self->setup_chgdcpass("$path/chgdcpass", $self->{vars
}->{chgdcpass
});
1801 } elsif ($envname eq "s3member") {
1802 if (not defined($self->{vars
}->{dc
})) {
1803 $self->setup_dc("$path/dc");
1805 return $target3->setup_admember("$path/s3member", $self->{vars
}->{dc
}, 29);
1806 } elsif ($envname eq "plugin_s4_dc") {
1807 return $self->setup_plugin_s4_dc("$path/plugin_s4_dc");
1808 } elsif ($envname eq "s3member_rfc2307") {
1809 if (not defined($self->{vars
}->{dc
})) {
1810 $self->setup_dc("$path/dc");
1812 return $target3->setup_admember_rfc2307("$path/s3member_rfc2307",
1813 $self->{vars
}->{dc
}, 34);
1819 sub setup_s4member
($$$)
1821 my ($self, $path, $dc_vars) = @_;
1823 my $env = $self->provision_s4member($path, $dc_vars);
1826 $self->check_or_start($env, "single");
1828 $self->wait_for_start($env);
1830 $self->{vars
}->{s4member
} = $env;
1836 sub setup_rpc_proxy
($$$)
1838 my ($self, $path, $dc_vars) = @_;
1840 my $env = $self->provision_rpc_proxy($path, $dc_vars);
1843 $self->check_or_start($env, "single");
1845 $self->wait_for_start($env);
1847 $self->{vars
}->{rpc_proxy
} = $env;
1854 my ($self, $path) = @_;
1856 my $env = $self->provision_dc($path);
1858 $self->check_or_start($env, "standard");
1860 $self->wait_for_start($env);
1862 $self->{vars
}->{dc
} = $env;
1867 sub setup_chgdcpass
($$)
1869 my ($self, $path) = @_;
1871 my $env = $self->provision_chgdcpass($path);
1873 $self->check_or_start($env, "single");
1875 $self->wait_for_start($env);
1877 $self->{vars
}->{chgdcpass
} = $env;
1882 sub setup_fl2000dc
($$)
1884 my ($self, $path) = @_;
1886 my $env = $self->provision_fl2000dc($path);
1888 $self->check_or_start($env, "single");
1890 $self->wait_for_start($env);
1892 $self->{vars
}->{fl2000dc
} = $env;
1898 sub setup_fl2003dc
($$)
1900 my ($self, $path) = @_;
1902 my $env = $self->provision_fl2003dc($path);
1905 $self->check_or_start($env, "single");
1907 $self->wait_for_start($env);
1909 $self->{vars
}->{fl2003dc
} = $env;
1914 sub setup_fl2008r2dc
($$)
1916 my ($self, $path) = @_;
1918 my $env = $self->provision_fl2008r2dc($path);
1921 $self->check_or_start($env, "single");
1923 $self->wait_for_start($env);
1925 $self->{vars
}->{fl2008r2dc
} = $env;
1931 sub setup_vampire_dc
($$$)
1933 my ($self, $path, $dc_vars) = @_;
1935 my $env = $self->provision_vampire_dc($path, $dc_vars);
1938 $self->check_or_start($env, "single");
1940 $self->wait_for_start($env);
1942 $self->{vars
}->{vampire_dc
} = $env;
1944 # force replicated DC to update repsTo/repsFrom
1945 # for vampired partitions
1946 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
1948 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
1949 $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
1950 $cmd .= " $samba_tool drs kcc $env->{DC_SERVER}";
1951 $cmd .= " $env->{CONFIGURATION}";
1952 $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD}";
1953 unless (system($cmd) == 0) {
1954 warn("Failed to exec kcc\n$cmd");
1958 # as 'vampired' dc may add data in its local replica
1959 # we need to synchronize data between DCs
1960 my $base_dn = "DC=".join(",DC=", split(/\./, $dc_vars->{REALM
}));
1961 $cmd = "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
1962 $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
1963 $cmd .= " $samba_tool drs replicate $env->{DC_SERVER} $env->{SERVER}";
1964 $cmd .= " $dc_vars->{CONFIGURATION}";
1965 $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD}";
1966 # replicate Configuration NC
1967 my $cmd_repl = "$cmd \"CN=Configuration,$base_dn\"";
1968 unless(system($cmd_repl) == 0) {
1969 warn("Failed to replicate\n$cmd_repl");
1972 # replicate Default NC
1973 $cmd_repl = "$cmd \"$base_dn\"";
1974 unless(system($cmd_repl) == 0) {
1975 warn("Failed to replicate\n$cmd_repl");
1983 sub setup_promoted_dc
($$$)
1985 my ($self, $path, $dc_vars) = @_;
1987 my $env = $self->provision_promoted_dc($path, $dc_vars);
1990 $self->check_or_start($env, "single");
1992 $self->wait_for_start($env);
1994 $self->{vars
}->{promoted_dc
} = $env;
1996 # force replicated DC to update repsTo/repsFrom
1997 # for vampired partitions
1998 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
2000 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
2001 $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
2002 $cmd .= " $samba_tool drs kcc $env->{DC_SERVER}";
2003 $cmd .= " $env->{CONFIGURATION}";
2004 $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD}";
2005 unless (system($cmd) == 0) {
2006 warn("Failed to exec kcc\n$cmd");
2010 # as 'vampired' dc may add data in its local replica
2011 # we need to synchronize data between DCs
2012 my $base_dn = "DC=".join(",DC=", split(/\./, $dc_vars->{REALM
}));
2013 $cmd = "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
2014 $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
2015 $cmd .= " $samba_tool drs replicate $env->{DC_SERVER} $env->{SERVER}";
2016 $cmd .= " $dc_vars->{CONFIGURATION}";
2017 $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD}";
2018 # replicate Configuration NC
2019 my $cmd_repl = "$cmd \"CN=Configuration,$base_dn\"";
2020 unless(system($cmd_repl) == 0) {
2021 warn("Failed to replicate\n$cmd_repl");
2024 # replicate Default NC
2025 $cmd_repl = "$cmd \"$base_dn\"";
2026 unless(system($cmd_repl) == 0) {
2027 warn("Failed to replicate\n$cmd_repl");
2035 sub setup_subdom_dc
($$$)
2037 my ($self, $path, $dc_vars) = @_;
2039 my $env = $self->provision_subdom_dc($path, $dc_vars);
2042 $self->check_or_start($env, "single");
2044 $self->wait_for_start($env);
2046 $self->{vars
}->{subdom_dc
} = $env;
2048 # force replicated DC to update repsTo/repsFrom
2049 # for primary domain partitions
2050 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
2052 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
2053 $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
2054 $cmd .= " $samba_tool drs kcc $env->{DC_SERVER}";
2055 $cmd .= " $env->{CONFIGURATION}";
2056 $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD} --realm=$dc_vars->{DC_REALM}";
2057 unless (system($cmd) == 0) {
2058 warn("Failed to exec kcc\n$cmd");
2062 # as 'subdomain' dc may add data in its local replica
2063 # we need to synchronize data between DCs
2064 my $base_dn = "DC=".join(",DC=", split(/\./, $env->{REALM
}));
2065 my $config_dn = "CN=Configuration,DC=".join(",DC=", split(/\./, $dc_vars->{REALM
}));
2066 $cmd = "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
2067 $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
2068 $cmd .= " $samba_tool drs replicate $env->{DC_SERVER} $env->{SUBDOM_DC_SERVER}";
2069 $cmd .= " $dc_vars->{CONFIGURATION}";
2070 $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD} --realm=$dc_vars->{DC_REALM}";
2071 # replicate Configuration NC
2072 my $cmd_repl = "$cmd \"$config_dn\"";
2073 unless(system($cmd_repl) == 0) {
2074 warn("Failed to replicate\n$cmd_repl");
2077 # replicate Default NC
2078 $cmd_repl = "$cmd \"$base_dn\"";
2079 unless(system($cmd_repl) == 0) {
2080 warn("Failed to replicate\n$cmd_repl");
2090 my ($self, $path, $dc_vars) = @_;
2092 my $env = $self->provision_rodc($path, $dc_vars);
2098 $self->check_or_start($env, "single");
2100 $self->wait_for_start($env);
2102 $self->{vars
}->{rodc
} = $env;
2107 sub setup_plugin_s4_dc
($$)
2109 my ($self, $path) = @_;
2111 # If we didn't build with ADS, pretend this env was never available
2112 if (not $self->{target3
}->have_ads()) {
2116 my $env = $self->provision_plugin_s4_dc($path);
2121 $self->check_or_start($env, "single");
2123 $self->wait_for_start($env);
2125 $self->{vars
}->{plugin_s4_dc
} = $env;