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) = @_;
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
54 if ($self->{ldap} eq "fedora-ds") {
55 system("$ENV{FEDORA_DS_ROOT}/sbin/ns-slapd -D $env_vars->{FEDORA_DS_DIR} -d0 -i $env_vars->{FEDORA_DS_PIDFILE}> $env_vars->{LDAPDIR}/logs 2>&1 &");
56 } elsif ($self->{ldap} eq "openldap") {
57 system("$ENV{OPENLDAP_SLAPD} -d0 -F $env_vars->{SLAPD_CONF_D} -h $uri > $env_vars->{LDAPDIR}/logs 2>&1 &");
59 while (system("$ldbsearch -H $uri -s base -b \"\" supportedLDAPVersion > /dev/null") != 0) {
62 $self->slapd_stop($env_vars);
72 my ($self, $envvars) = @_;
73 if ($self->{ldap} eq "fedora-ds") {
74 system("$envvars->{LDAPDIR}/slapd-$envvars->{LDAP_INSTANCE}/stop-slapd");
75 } elsif ($self->{ldap} eq "openldap") {
76 unless (open(IN, "<$envvars->{OPENLDAP_PIDFILE}")) {
77 warn("unable to open slapd pid file: $envvars->{OPENLDAP_PIDFILE}");
86 sub check_or_start($$$)
88 my ($self, $env_vars, $process_model) = @_;
90 return 0 if $self->check_env($env_vars);
92 # use a pipe for stdin in the child processes. This allows
93 # those processes to monitor the pipe for EOF to ensure they
94 # exit when the test script exits
95 pipe(STDIN_READER, $env_vars->{STDIN_PIPE});
97 print "STARTING SAMBA...";
100 # we want out from samba to go to the log file, but also
101 # to the users terminal when running 'make test' on the command
102 # line. This puts it on stderr on the terminal
103 open STDOUT, "| tee $env_vars->{SAMBA_TEST_LOG} 1>&2";
104 open STDERR, '>&STDOUT';
106 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
108 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
109 $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR};
110 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
112 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
113 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
114 $ENV{NSS_WRAPPER_WINBIND_SO_PATH} = $env_vars->{NSS_WRAPPER_WINBIND_SO_PATH};
116 $ENV{UID_WRAPPER} = "1";
118 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "samba");
121 if (defined($ENV{SAMBA_OPTIONS})) {
122 @optargs = split(/ /, $ENV{SAMBA_OPTIONS});
124 if(defined($ENV{SAMBA_VALGRIND})) {
125 @preargs = split(/ /,$ENV{SAMBA_VALGRIND});
128 close($env_vars->{STDIN_PIPE});
129 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
131 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: $!");
133 $env_vars->{SAMBA_PID} = $pid;
141 sub wait_for_start($$)
143 my ($self, $testenv_vars) = @_;
144 # give time for nbt server to register its names
145 print "delaying for nbt name registration\n";
148 # This will return quickly when things are up, but be slow if we
149 # need to wait for (eg) SSL init
150 my $nmblookup = Samba::bindir_path($self, "nmblookup4");
151 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{SERVER}");
152 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{SERVER}");
153 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
154 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
155 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
156 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
157 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{SERVER}");
158 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{SERVER}");
159 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
160 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
161 system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
162 system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
164 print $self->getlog_env($testenv_vars);
167 sub write_ldb_file($$$)
169 my ($self, $file, $ldif) = @_;
171 my $ldbadd = Samba::bindir_path($self, "ldbadd");
172 open(LDIF, "|$ldbadd -H $file >/dev/null");
177 sub add_wins_config($$)
179 my ($self, $privatedir) = @_;
181 return $self->write_ldb_file("$privatedir/wins_config.ldb", "
182 dn: name=TORTURE_11,CN=PARTNERS
183 objectClass: wreplPartner
194 my ($self, $ctx) = @_;
196 #Make the subdirectory be as fedora DS would expect
197 my $fedora_ds_dir = "$ctx->{ldapdir}/slapd-$ctx->{ldap_instance}";
199 my $pidfile = "$fedora_ds_dir/logs/slapd-$ctx->{ldap_instance}.pid";
201 return ($fedora_ds_dir, $pidfile);
206 my ($self, $ctx) = @_;
208 my $slapd_conf_d = "$ctx->{ldapdir}/slapd.d";
209 my $pidfile = "$ctx->{ldapdir}/slapd.pid";
211 return ($slapd_conf_d, $pidfile);
216 my ($self, $tlsdir) = @_;
218 #TLS and PKINIT crypto blobs
219 my $dhfile = "$tlsdir/dhparms.pem";
220 my $cafile = "$tlsdir/ca.pem";
221 my $certfile = "$tlsdir/cert.pem";
222 my $reqkdc = "$tlsdir/req-kdc.der";
223 my $kdccertfile = "$tlsdir/kdc.pem";
224 my $keyfile = "$tlsdir/key.pem";
225 my $adminkeyfile = "$tlsdir/adminkey.pem";
226 my $reqadmin = "$tlsdir/req-admin.der";
227 my $admincertfile = "$tlsdir/admincert.pem";
228 my $admincertupnfile = "$tlsdir/admincertupn.pem";
230 mkdir($tlsdir, 0777);
232 #This is specified here to avoid draining entropy on every run
233 open(DHFILE, ">$dhfile");
235 -----BEGIN DH PARAMETERS-----
236 MGYCYQC/eWD2xkb7uELmqLi+ygPMKyVcpHUo2yCluwnbPutEueuxrG/Cys8j8wLO
237 svCN/jYNyR2NszOmg7ZWcOC/4z/4pWDVPUZr8qrkhj5MRKJc52MncfaDglvEdJrv
239 -----END DH PARAMETERS-----
243 #Likewise, we pregenerate the key material. This allows the
244 #other certificates to be pre-generated
245 open(KEYFILE
, ">$keyfile");
247 -----BEGIN RSA PRIVATE KEY-----
248 MIICXQIBAAKBgQDKg6pAwCHUMA1DfHDmWhZfd+F0C+9Jxcqvpw9ii9En3E1uflpc
249 ol3+S9/6I/uaTmJHZre+DF3dTzb/UOZo0Zem8N+IzzkgoGkFafjXuT3BL5UPY2/H
250 6H+pPqVIRLOmrWImai359YyoKhFyo37Y6HPeU8QcZ+u2rS9geapIWfeuowIDAQAB
251 AoGAAqDLzFRR/BF1kpsiUfL4WFvTarCe9duhwj7ORc6fs785qAXuwUYAJ0Uvzmy6
252 HqoGv3t3RfmeHDmjcpPHsbOKnsOQn2MgmthidQlPBMWtQMff5zdoYNUFiPS0XQBq
253 szNW4PRjaA9KkLQVTwnzdXGkBSkn/nGxkaVu7OR3vJOBoo0CQQDO4upypesnbe6p
254 9/xqfZ2uim8IwV1fLlFClV7WlCaER8tsQF4lEi0XSzRdXGUD/dilpY88Nb+xok/X
255 8Z8OvgAXAkEA+pcLsx1gN7kxnARxv54jdzQjC31uesJgMKQXjJ0h75aUZwTNHmZQ
256 vPxi6u62YiObrN5oivkixwFNncT9MxTxVQJBAMaWUm2SjlLe10UX4Zdm1MEB6OsC
257 kVoX37CGKO7YbtBzCfTzJGt5Mwc1DSLA2cYnGJqIfSFShptALlwedot0HikCQAJu
258 jNKEKnbf+TdGY8Q0SKvTebOW2Aeg80YFkaTvsXCdyXrmdQcifw4WdO9KucJiDhSz
259 Y9hVapz7ykEJtFtWjLECQQDIlfc63I5ZpXfg4/nN4IJXUW6AmPVOYIA5215itgki
260 cSlMYli1H9MEXH0pQMGv5Qyd0OYIx2DDg96mZ+aFvqSG
261 -----END RSA PRIVATE KEY-----
265 open(ADMINKEYFILE
, ">$adminkeyfile");
267 print ADMINKEYFILE
<<EOF;
268 -----BEGIN RSA PRIVATE KEY-----
269 MIICXQIBAAKBgQD0+OL7TQBj0RejbIH1+g5GeRaWaM9xF43uE5y7jUHEsi5owhZF
270 5iIoHZeeL6cpDF5y1BZRs0JlA1VqMry1jjKlzFYVEMMFxB6esnXhl0Jpip1JkUMM
271 XLOP1m/0dqayuHBWozj9f/cdyCJr0wJIX1Z8Pr+EjYRGPn/MF0xdl3JRlwIDAQAB
272 AoGAP8mjCP628Ebc2eACQzOWjgEvwYCPK4qPmYOf1zJkArzG2t5XAGJ5WGrENRuB
273 cm3XFh1lpmaADl982UdW3gul4gXUy6w4XjKK4vVfhyHj0kZ/LgaXUK9BAGhroJ2L
274 osIOUsaC6jdx9EwSRctwdlF3wWJ8NK0g28AkvIk+FlolW4ECQQD7w5ouCDnf58CN
275 u4nARx4xv5XJXekBvOomkCQAmuOsdOb6b9wn3mm2E3au9fueITjb3soMR31AF6O4
276 eAY126rXAkEA+RgHzybzZEP8jCuznMqoN2fq/Vrs6+W3M8/G9mzGEMgLLpaf2Jiz
277 I9tLZ0+OFk9tkRaoCHPfUOCrVWJZ7Y53QQJBAMhoA6rw0WDyUcyApD5yXg6rusf4
278 ASpo/tqDkqUIpoL464Qe1tjFqtBM3gSXuhs9xsz+o0bzATirmJ+WqxrkKTECQHt2
279 OLCpKqwAspU7N+w32kaUADoRLisCEdrhWklbwpQgwsIVsCaoEOpt0CLloJRYTANE
280 yoZeAErTALjyZYZEPcECQQDlUi0N8DFxQ/lOwWyR3Hailft+mPqoPCa8QHlQZnlG
281 +cfgNl57YHMTZFwgUVFRdJNpjH/WdZ5QxDcIVli0q+Ko
282 -----END RSA PRIVATE KEY-----
286 # hxtool issue-certificate --self-signed --issue-ca \
287 # --ca-private-key="FILE:$KEYFILE" \
288 # --subject="CN=CA,DC=samba,DC=example,DC=com" \
289 # --certificate="FILE:$CAFILE" --lifetime="25 years"
291 open(CAFILE
, ">$cafile");
293 -----BEGIN CERTIFICATE-----
294 MIICcTCCAdqgAwIBAgIUaBPmjnPVqyFqR5foICmLmikJTzgwCwYJKoZIhvcNAQEFMFIxEzAR
295 BgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxlMRUwEwYKCZImiZPy
296 LGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMCIYDzIwMDgwMzAxMTIyMzEyWhgPMjAzMzAyMjQx
297 MjIzMTJaMFIxEzARBgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxl
298 MRUwEwYKCZImiZPyLGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMIGfMA0GCSqGSIb3DQEBAQUA
299 A4GNADCBiQKBgQDKg6pAwCHUMA1DfHDmWhZfd+F0C+9Jxcqvpw9ii9En3E1uflpcol3+S9/6
300 I/uaTmJHZre+DF3dTzb/UOZo0Zem8N+IzzkgoGkFafjXuT3BL5UPY2/H6H+pPqVIRLOmrWIm
301 ai359YyoKhFyo37Y6HPeU8QcZ+u2rS9geapIWfeuowIDAQABo0IwQDAOBgNVHQ8BAf8EBAMC
302 AaYwHQYDVR0OBBYEFMLZufegDKLZs0VOyFXYK1L6M8oyMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
303 KoZIhvcNAQEFBQADgYEAAZJbCAAkaqgFJ0xgNovn8Ydd0KswQPjicwiODPgw9ZPoD2HiOUVO
304 yYDRg/dhFF9y656OpcHk4N7qZ2sl3RlHkzDu+dseETW+CnKvQIoXNyeARRJSsSlwrwcoD4JR
305 HTLk2sGigsWwrJ2N99sG/cqSJLJ1MFwLrs6koweBnYU0f/g=
306 -----END CERTIFICATE-----
309 #generated with GNUTLS internally in Samba.
311 open(CERTFILE
, ">$certfile");
312 print CERTFILE
<<EOF;
313 -----BEGIN CERTIFICATE-----
314 MIICYTCCAcygAwIBAgIE5M7SRDALBgkqhkiG9w0BAQUwZTEdMBsGA1UEChMUU2Ft
315 YmEgQWRtaW5pc3RyYXRpb24xNDAyBgNVBAsTK1NhbWJhIC0gdGVtcG9yYXJ5IGF1
316 dG9nZW5lcmF0ZWQgY2VydGlmaWNhdGUxDjAMBgNVBAMTBVNhbWJhMB4XDTA2MDgw
317 NDA0MzY1MloXDTA4MDcwNDA0MzY1MlowZTEdMBsGA1UEChMUU2FtYmEgQWRtaW5p
318 c3RyYXRpb24xNDAyBgNVBAsTK1NhbWJhIC0gdGVtcG9yYXJ5IGF1dG9nZW5lcmF0
319 ZWQgY2VydGlmaWNhdGUxDjAMBgNVBAMTBVNhbWJhMIGcMAsGCSqGSIb3DQEBAQOB
320 jAAwgYgCgYDKg6pAwCHUMA1DfHDmWhZfd+F0C+9Jxcqvpw9ii9En3E1uflpcol3+
321 S9/6I/uaTmJHZre+DF3dTzb/UOZo0Zem8N+IzzkgoGkFafjXuT3BL5UPY2/H6H+p
322 PqVIRLOmrWImai359YyoKhFyo37Y6HPeU8QcZ+u2rS9geapIWfeuowIDAQABoyUw
323 IzAMBgNVHRMBAf8EAjAAMBMGA1UdJQQMMAoGCCsGAQUFBwMBMAsGCSqGSIb3DQEB
324 BQOBgQAmkN6XxvDnoMkGcWLCTwzxGfNNSVcYr7TtL2aJh285Xw9zaxcm/SAZBFyG
325 LYOChvh6hPU7joMdDwGfbiLrBnMag+BtGlmPLWwp/Kt1wNmrRhduyTQFhN3PP6fz
326 nBr9vVny2FewB2gHmelaPS//tXdxivSXKz3NFqqXLDJjq7P8wA==
327 -----END CERTIFICATE-----
332 # hxtool request-create \
333 # --subject="CN=krbtgt,CN=users,DC=samba,DC=example,DC=com" \
334 # --key="FILE:$KEYFILE" $KDCREQ
336 # hxtool issue-certificate --ca-certificate=FILE:$CAFILE,$KEYFILE \
337 # --type="pkinit-kdc" \
338 # --pk-init-principal="krbtgt/SAMBA.EXAMPLE.COM@SAMBA.EXAMPLE.COM" \
339 # --req="PKCS10:$KDCREQ" --certificate="FILE:$KDCCERTFILE" \
340 # --lifetime="25 years"
342 open(KDCCERTFILE
, ">$kdccertfile");
343 print KDCCERTFILE
<<EOF;
344 -----BEGIN CERTIFICATE-----
345 MIIDDDCCAnWgAwIBAgIUI2Tzj+JnMzMcdeabcNo30rovzFAwCwYJKoZIhvcNAQEFMFIxEzAR
346 BgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxlMRUwEwYKCZImiZPy
347 LGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMCIYDzIwMDgwMzAxMTMxOTIzWhgPMjAzMzAyMjQx
348 MzE5MjNaMGYxEzARBgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxl
349 MRUwEwYKCZImiZPyLGQBGQwFc2FtYmExDjAMBgNVBAMMBXVzZXJzMQ8wDQYDVQQDDAZrcmJ0
350 Z3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMqDqkDAIdQwDUN8cOZaFl934XQL70nF
351 yq+nD2KL0SfcTW5+WlyiXf5L3/oj+5pOYkdmt74MXd1PNv9Q5mjRl6bw34jPOSCgaQVp+Ne5
352 PcEvlQ9jb8fof6k+pUhEs6atYiZqLfn1jKgqEXKjftjoc95TxBxn67atL2B5qkhZ966jAgMB
353 AAGjgcgwgcUwDgYDVR0PAQH/BAQDAgWgMBIGA1UdJQQLMAkGBysGAQUCAwUwVAYDVR0RBE0w
354 S6BJBgYrBgEFAgKgPzA9oBMbEVNBTUJBLkVYQU1QTEUuQ09NoSYwJKADAgEBoR0wGxsGa3Ji
355 dGd0GxFTQU1CQS5FWEFNUExFLkNPTTAfBgNVHSMEGDAWgBTC2bn3oAyi2bNFTshV2CtS+jPK
356 MjAdBgNVHQ4EFgQUwtm596AMotmzRU7IVdgrUvozyjIwCQYDVR0TBAIwADANBgkqhkiG9w0B
357 AQUFAAOBgQBmrVD5MCmZjfHp1nEnHqTIh8r7lSmVtDx4s9MMjxm9oNrzbKXynvdhwQYFVarc
358 ge4yRRDXtSebErOl71zVJI9CVeQQpwcH+tA85oGA7oeFtO/S7ls581RUU6tGgyxV4veD+lJv
359 KPH5LevUtgD+q9H4LU4Sq5N3iFwBaeryB0g2wg==
360 -----END CERTIFICATE-----
363 # hxtool request-create \
364 # --subject="CN=Administrator,CN=users,DC=samba,DC=example,DC=com" \
365 # --key="FILE:$ADMINKEYFILE" $ADMINREQFILE
367 # hxtool issue-certificate --ca-certificate=FILE:$CAFILE,$KEYFILE \
368 # --type="pkinit-client" \
369 # --pk-init-principal="administrator@SAMBA.EXAMPLE.COM" \
370 # --req="PKCS10:$ADMINREQFILE" --certificate="FILE:$ADMINCERTFILE" \
371 # --lifetime="25 years"
373 open(ADMINCERTFILE
, ">$admincertfile");
374 print ADMINCERTFILE
<<EOF;
375 -----BEGIN CERTIFICATE-----
376 MIIDHTCCAoagAwIBAgIUUggzW4lLRkMKe1DAR2NKatkMDYwwCwYJKoZIhvcNAQELMFIxEzAR
377 BgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxlMRUwEwYKCZImiZPy
378 LGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMCIYDzIwMDkwNzI3MDMzMjE1WhgPMjAzNDA3MjIw
379 MzMyMTVaMG0xEzARBgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxl
380 MRUwEwYKCZImiZPyLGQBGQwFc2FtYmExDjAMBgNVBAMMBXVzZXJzMRYwFAYDVQQDDA1BZG1p
381 bmlzdHJhdG9yMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD0+OL7TQBj0RejbIH1+g5G
382 eRaWaM9xF43uE5y7jUHEsi5owhZF5iIoHZeeL6cpDF5y1BZRs0JlA1VqMry1jjKlzFYVEMMF
383 xB6esnXhl0Jpip1JkUMMXLOP1m/0dqayuHBWozj9f/cdyCJr0wJIX1Z8Pr+EjYRGPn/MF0xd
384 l3JRlwIDAQABo4HSMIHPMA4GA1UdDwEB/wQEAwIFoDAoBgNVHSUEITAfBgcrBgEFAgMEBggr
385 BgEFBQcDAgYKKwYBBAGCNxQCAjBIBgNVHREEQTA/oD0GBisGAQUCAqAzMDGgExsRU0FNQkEu
386 RVhBTVBMRS5DT02hGjAYoAMCAQGhETAPGw1BZG1pbmlzdHJhdG9yMB8GA1UdIwQYMBaAFMLZ
387 ufegDKLZs0VOyFXYK1L6M8oyMB0GA1UdDgQWBBQg81bLyfCA88C2B/BDjXlGuaFaxjAJBgNV
388 HRMEAjAAMA0GCSqGSIb3DQEBCwUAA4GBAEf/OSHUDJaGdtWGNuJeqcVYVMwrfBAc0OSwVhz1
389 7/xqKHWo8wIMPkYRtaRHKLNDsF8GkhQPCpVsa6mX/Nt7YQnNvwd+1SBP5E8GvwWw9ZzLJvma
390 nk2n89emuayLpVtp00PymrDLRBcNaRjFReQU8f0o509kiVPHduAp3jOiy13l
391 -----END CERTIFICATE-----
393 close(ADMINCERTFILE
);
395 # hxtool issue-certificate --ca-certificate=FILE:$CAFILE,$KEYFILE \
396 # --type="pkinit-client" \
397 # --ms-upn="administrator@samba.example.com" \
398 # --req="PKCS10:$ADMINREQFILE" --certificate="FILE:$ADMINCERTUPNFILE" \
399 # --lifetime="25 years"
401 open(ADMINCERTUPNFILE
, ">$admincertupnfile");
402 print ADMINCERTUPNFILE
<<EOF;
403 -----BEGIN CERTIFICATE-----
404 MIIDDzCCAnigAwIBAgIUUp3CJMuNaEaAdPKp3QdNIwG7a4wwCwYJKoZIhvcNAQELMFIxEzAR
405 BgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxlMRUwEwYKCZImiZPy
406 LGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMCIYDzIwMDkwNzI3MDMzMzA1WhgPMjAzNDA3MjIw
407 MzMzMDVaMG0xEzARBgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxl
408 MRUwEwYKCZImiZPyLGQBGQwFc2FtYmExDjAMBgNVBAMMBXVzZXJzMRYwFAYDVQQDDA1BZG1p
409 bmlzdHJhdG9yMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD0+OL7TQBj0RejbIH1+g5G
410 eRaWaM9xF43uE5y7jUHEsi5owhZF5iIoHZeeL6cpDF5y1BZRs0JlA1VqMry1jjKlzFYVEMMF
411 xB6esnXhl0Jpip1JkUMMXLOP1m/0dqayuHBWozj9f/cdyCJr0wJIX1Z8Pr+EjYRGPn/MF0xd
412 l3JRlwIDAQABo4HEMIHBMA4GA1UdDwEB/wQEAwIFoDAoBgNVHSUEITAfBgcrBgEFAgMEBggr
413 BgEFBQcDAgYKKwYBBAGCNxQCAjA6BgNVHREEMzAxoC8GCisGAQQBgjcUAgOgIQwfYWRtaW5p
414 c3RyYXRvckBzYW1iYS5leGFtcGxlLmNvbTAfBgNVHSMEGDAWgBTC2bn3oAyi2bNFTshV2CtS
415 +jPKMjAdBgNVHQ4EFgQUIPNWy8nwgPPAtgfwQ415RrmhWsYwCQYDVR0TBAIwADANBgkqhkiG
416 9w0BAQsFAAOBgQBk42+egeUB3Ji2PC55fbt3FNKxvmm2xUUFkV9POK/YR9rajKOwk5jtYSeS
417 Zd7J9s//rNFNa7waklFkDaY56+QWTFtdvxfE+KoHaqt6X8u6pqi7p3M4wDKQox+9Dx8yWFyq
418 Wfz/8alZ5aMezCQzXJyIaJsCLeKABosSwHcpAFmxlQ==
419 -----END CERTIFICATE-----
423 sub provision_raw_prepare
($$$$$$$$$$)
425 my ($self, $prefix, $server_role, $hostname,
426 $domain, $realm, $functional_level,
427 $password, $kdc_ipv4, $use_ntvfs) = @_;
429 my $netbiosname = uc($hostname);
431 unless(-d
$prefix or mkdir($prefix, 0777)) {
432 warn("Unable to create $prefix");
435 my $prefix_abs = abs_path
($prefix);
437 die ("prefix=''") if $prefix_abs eq "";
438 die ("prefix='/'") if $prefix_abs eq "/";
440 unless (system("rm -rf $prefix_abs/*") == 0) {
441 warn("Unable to clean up");
445 my $swiface = Samba
::get_interface
($hostname);
447 $ctx->{prefix
} = $prefix;
448 $ctx->{prefix_abs
} = $prefix_abs;
450 $ctx->{dns_host_file
} = "$ENV{SELFTEST_PREFIX}/dns_host_file";
452 $ctx->{server_role
} = $server_role;
453 $ctx->{hostname
} = $hostname;
454 $ctx->{netbiosname
} = $netbiosname;
455 $ctx->{swiface
} = $swiface;
456 $ctx->{password
} = $password;
457 $ctx->{kdc_ipv4
} = $kdc_ipv4;
459 $ctx->{server_loglevel
} =$ENV{SERVER_LOG_LEVEL
} || 1;
460 $ctx->{username
} = "Administrator";
461 $ctx->{domain
} = $domain;
462 $ctx->{realm
} = uc($realm);
463 $ctx->{dnsname
} = lc($realm);
465 $ctx->{functional_level
} = $functional_level;
467 my $unix_name = ($ENV{USER
} or $ENV{LOGNAME
} or `whoami`);
469 $ctx->{unix_name
} = $unix_name;
470 $ctx->{unix_uid
} = $>;
471 $ctx->{unix_gids_str
} = $);
472 @
{$ctx->{unix_gids
}} = split(" ", $ctx->{unix_gids_str
});
474 $ctx->{etcdir
} = "$prefix_abs/etc";
475 $ctx->{piddir
} = "$prefix_abs/pid";
476 $ctx->{smb_conf
} = "$ctx->{etcdir}/smb.conf";
477 $ctx->{krb5_conf
} = "$ctx->{etcdir}/krb5.conf";
478 $ctx->{privatedir
} = "$prefix_abs/private";
479 $ctx->{ncalrpcdir
} = "$prefix_abs/ncalrpc";
480 $ctx->{lockdir
} = "$prefix_abs/lockdir";
481 $ctx->{logdir
} = "$prefix_abs/logs";
482 $ctx->{statedir
} = "$prefix_abs/statedir";
483 $ctx->{cachedir
} = "$prefix_abs/cachedir";
484 $ctx->{winbindd_socket_dir
} = "$prefix_abs/winbindd_socket";
485 $ctx->{winbindd_privileged_socket_dir
} = "$prefix_abs/winbindd_privileged_socket";
486 $ctx->{ntp_signd_socket_dir
} = "$prefix_abs/ntp_signd_socket";
487 $ctx->{nsswrap_passwd
} = "$ctx->{etcdir}/passwd";
488 $ctx->{nsswrap_group
} = "$ctx->{etcdir}/group";
490 $ctx->{tlsdir
} = "$ctx->{privatedir}/tls";
492 $ctx->{ipv4
} = "127.0.0.$swiface";
493 $ctx->{interfaces
} = "$ctx->{ipv4}/8";
495 push(@
{$ctx->{directories
}}, $ctx->{privatedir
});
496 push(@
{$ctx->{directories
}}, $ctx->{etcdir
});
497 push(@
{$ctx->{directories
}}, $ctx->{piddir
});
498 push(@
{$ctx->{directories
}}, $ctx->{lockdir
});
499 push(@
{$ctx->{directories
}}, $ctx->{logdir
});
500 push(@
{$ctx->{directories
}}, $ctx->{statedir
});
501 push(@
{$ctx->{directories
}}, $ctx->{cachedir
});
503 $ctx->{smb_conf_extra_options
} = "";
505 my @provision_options = ();
506 push (@provision_options, "NSS_WRAPPER_PASSWD=\"$ctx->{nsswrap_passwd}\"");
507 push (@provision_options, "NSS_WRAPPER_GROUP=\"$ctx->{nsswrap_group}\"");
508 if (defined($ENV{GDB_PROVISION
})) {
509 push (@provision_options, "gdb --args");
510 if (!defined($ENV{PYTHON
})) {
511 push (@provision_options, "env");
512 push (@provision_options, "python");
515 if (defined($ENV{VALGRIND_PROVISION
})) {
516 push (@provision_options, "valgrind");
517 if (!defined($ENV{PYTHON
})) {
518 push (@provision_options, "env");
519 push (@provision_options, "python");
522 if (defined($ENV{PYTHON
})) {
523 push (@provision_options, $ENV{PYTHON
});
525 push (@provision_options, "$self->{srcdir}/source4/setup/provision");
526 push (@provision_options, "--configfile=$ctx->{smb_conf}");
527 push (@provision_options, "--host-name=$ctx->{hostname}");
528 push (@provision_options, "--host-ip=$ctx->{ipv4}");
529 push (@provision_options, "--quiet");
530 push (@provision_options, "--domain=$ctx->{domain}");
531 push (@provision_options, "--realm=$ctx->{realm}");
532 push (@provision_options, "--adminpass=$ctx->{password}");
533 push (@provision_options, "--krbtgtpass=krbtgt$ctx->{password}");
534 push (@provision_options, "--machinepass=machine$ctx->{password}");
535 push (@provision_options, "--root=$ctx->{unix_name}");
536 push (@provision_options, "--server-role=\"$ctx->{server_role}\"");
537 push (@provision_options, "--function-level=\"$ctx->{functional_level}\"");
538 push (@provision_options, "--dns-backend=BIND9_DLZ");
541 push (@provision_options, "--use-ntvfs");
544 @
{$ctx->{provision_options
}} = @provision_options;
550 # Step1 creates the basic configuration
552 sub provision_raw_step1
($$)
554 my ($self, $ctx) = @_;
556 mkdir($_, 0777) foreach (@
{$ctx->{directories
}});
558 unless (open(CONFFILE
, ">$ctx->{smb_conf}")) {
559 warn("can't open $ctx->{smb_conf}$?");
563 $acl = "true" if (defined $ENV{WITH_ACL
});
567 netbios name = $ctx->{netbiosname}
568 posix:eadb = $ctx->{statedir}/eadb.tdb
569 workgroup = $ctx->{domain}
570 realm = $ctx->{realm}
571 private dir = $ctx->{privatedir}
572 pid directory = $ctx->{piddir}
573 ncalrpc dir = $ctx->{ncalrpcdir}
574 lock dir = $ctx->{lockdir}
575 state directory = $ctx->{statedir}
576 cache directory = $ctx->{cachedir}
577 winbindd socket directory = $ctx->{winbindd_socket_dir}
578 winbindd privileged socket directory = $ctx->{winbindd_privileged_socket_dir}
579 ntp signd socket directory = $ctx->{ntp_signd_socket_dir}
580 winbind separator = /
581 name resolve order = file bcast
582 interfaces = $ctx->{interfaces}
583 tls dh params file = $ctx->{tlsdir}/dhparms.pem
584 panic action = $RealBin/gdb_backtrace \%d
586 server role = $ctx->{server_role}
587 server services = +echo +dns +smb -s3fs
588 dcerpc endpoint servers = +winreg +srvsvc
589 notify:inotify = false
591 #We don't want to pass our self-tests if the PAC code is wrong
592 gensec:require_pac = true
593 log file = $ctx->{logdir}/log.\%m
594 log level = $ctx->{server_loglevel}
597 dns update command = $ENV{SRCDIR_ABS}/source4/scripting/bin/samba_dnsupdate --all-interfaces --use-file=$ctx->{dns_host_file} -s $ctx->{smb_conf}
598 spn update command = $ENV{SRCDIR_ABS}/source4/scripting/bin/samba_spnupdate -s $ctx->{smb_conf}
599 resolv:host file = $ctx->{dns_host_file}
600 dreplsrv:periodic_startup_interval = 0
601 dsdb:schema update allowed = yes
603 passdb backend = samba4
605 vfs objects = dfs_samba4 acl_xattr fake_acls xattr_tdb streams_depot
607 # remove this again, when our smb2 client library
608 # supports signin on compound related requests
614 # Begin extra options
615 $ctx->{smb_conf_extra_options}
620 $self->mk_keyblobs($ctx->{tlsdir
});
622 #Default the KDC IP to the server's IP
623 if (not defined($ctx->{kdc_ipv4
})) {
624 $ctx->{kdc_ipv4
} = $ctx->{ipv4
};
627 Samba
::mk_krb5_conf
($ctx, "");
629 open(PWD
, ">$ctx->{nsswrap_passwd}");
631 root:x:0:0:root gecos:$ctx->{prefix_abs}:/bin/false
632 nobody:x:65534:65533:nobody gecos:$ctx->{prefix_abs}:/bin/false
633 pdbtest:x:65533:65533:pdbtest gecos:$ctx->{prefix_abs}:/bin/false
637 open(GRP
, ">$ctx->{nsswrap_group}");
643 nogroup:x:65534:nobody
647 my $configuration = "--configfile=$ctx->{smb_conf}";
649 #Ensure the config file is valid before we start
650 my $testparm = Samba
::bindir_path
($self, "samba-tool") . " testparm";
651 if (system("$testparm $configuration -v --suppress-prompt >/dev/null 2>&1") != 0) {
652 system("$testparm -v --suppress-prompt $configuration >&2");
653 warn("Failed to create a valid smb.conf configuration $testparm!");
656 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) {
657 warn("Failed to create a valid smb.conf configuration! $testparm $configuration -v --suppress-prompt --parameter-name=\"netbios name\" --section-name=global");
662 KRB5_CONFIG
=> $ctx->{krb5_conf
},
663 PIDDIR
=> $ctx->{piddir
},
664 SERVER
=> $ctx->{hostname
},
665 SERVER_IP
=> $ctx->{ipv4
},
666 NETBIOSNAME
=> $ctx->{netbiosname
},
667 DOMAIN
=> $ctx->{domain
},
668 USERNAME
=> $ctx->{username
},
669 REALM
=> $ctx->{realm
},
670 PASSWORD
=> $ctx->{password
},
671 LDAPDIR
=> $ctx->{ldapdir
},
672 LDAP_INSTANCE
=> $ctx->{ldap_instance
},
673 WINBINDD_SOCKET_DIR
=> $ctx->{winbindd_socket_dir
},
674 NCALRPCDIR
=> $ctx->{ncalrpcdir
},
675 LOCKDIR
=> $ctx->{lockdir
},
676 STATEDIR
=> $ctx->{statedir
},
677 CACHEDIR
=> $ctx->{cachedir
},
678 PRIVATEDIR
=> $ctx->{privatedir
},
679 SERVERCONFFILE
=> $ctx->{smb_conf
},
680 CONFIGURATION
=> $configuration,
681 SOCKET_WRAPPER_DEFAULT_IFACE
=> $ctx->{swiface
},
682 NSS_WRAPPER_PASSWD
=> $ctx->{nsswrap_passwd
},
683 NSS_WRAPPER_GROUP
=> $ctx->{nsswrap_group
},
684 SAMBA_TEST_FIFO
=> "$ctx->{prefix}/samba_test.fifo",
685 SAMBA_TEST_LOG
=> "$ctx->{prefix}/samba_test.log",
686 SAMBA_TEST_LOG_POS
=> 0,
687 NSS_WRAPPER_WINBIND_SO_PATH
=> Samba
::bindir_path
($self, "default/nsswitch/libnss-winbind.so"),
688 LOCAL_PATH
=> $ctx->{share
}
695 # Step2 runs the provision script
697 sub provision_raw_step2
($$$)
699 my ($self, $ctx, $ret) = @_;
701 my $provision_cmd = join(" ", @
{$ctx->{provision_options
}});
702 unless (system($provision_cmd) == 0) {
703 warn("Unable to provision: \n$provision_cmd\n");
710 sub provision
($$$$$$$$$)
712 my ($self, $prefix, $server_role, $hostname,
713 $domain, $realm, $functional_level,
714 $password, $kdc_ipv4, $extra_smbconf_options, $extra_smbconf_shares, $use_ntvfs) = @_;
716 my $ctx = $self->provision_raw_prepare($prefix, $server_role,
718 $domain, $realm, $functional_level,
719 $password, $kdc_ipv4, $use_ntvfs);
721 $ctx->{share
} = "$ctx->{prefix_abs}/share";
722 push(@
{$ctx->{directories
}}, "$ctx->{share}");
723 push(@
{$ctx->{directories
}}, "$ctx->{share}/test1");
724 push(@
{$ctx->{directories
}}, "$ctx->{share}/test2");
726 # precreate directories for printer drivers
727 push(@
{$ctx->{directories
}}, "$ctx->{share}/W32X86");
728 push(@
{$ctx->{directories
}}, "$ctx->{share}/x64");
729 push(@
{$ctx->{directories
}}, "$ctx->{share}/WIN40");
732 $msdfs = "yes" if ($server_role eq "domain controller");
733 $ctx->{smb_conf_extra_options
} = "
736 server max protocol = SMB2
740 $extra_smbconf_options
745 posix:sharedelay = 10000
746 posix:oplocktimeout = 3
747 posix:writetimeupdatedelay = 50000
752 posix:sharedelay = 10000
753 posix:oplocktimeout = 3
754 posix:writetimeupdatedelay = 50000
756 force create mode = 777
762 force create mode = 0
763 directory mask = 0777
764 force directory mode = 0
767 path = $ctx->{share}/test1
769 posix:sharedelay = 10000
770 posix:oplocktimeout = 3
771 posix:writetimeupdatedelay = 50000
774 path = $ctx->{share}/test2
776 posix:sharedelay = 10000
777 posix:oplocktimeout = 3
778 posix:writetimeupdatedelay = 50000
783 cifs:server = $ctx->{netbiosname}
785 cifs:use-s4u2proxy = yes
786 # There is no username specified here, instead the client is expected
787 # to log in with kerberos, and the serverwill use delegated credentials.
788 # Or the server tries s4u2self/s4u2proxy to impersonate the client
793 ntvfs handler = simple
796 path = $ctx->{statedir}/sysvol
800 path = $ctx->{statedir}/sysvol/$ctx->{dnsname}/scripts
805 ntvfs handler = cifsposix
807 $extra_smbconf_shares
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;
819 $ctx->{ldap_instance
} = lc($ctx->{netbiosname
});
822 my $ret = $self->provision_raw_step1($ctx);
823 unless (defined $ret) {
827 if (defined($self->{ldap
})) {
828 $ret->{LDAP_URI
} = $ctx->{ldap_uri
};
829 push (@
{$ctx->{provision_options
}}, "--ldap-backend-type=" . $self->{ldap
});
830 push (@
{$ctx->{provision_options
}}, "--ldap-backend-nosync");
831 if ($self->{ldap
} eq "openldap") {
832 push (@
{$ctx->{provision_options
}}, "--slapd-path=" . $ENV{OPENLDAP_SLAPD
});
833 ($ret->{SLAPD_CONF_D
}, $ret->{OPENLDAP_PIDFILE
}) = $self->mk_openldap($ctx) or die("Unable to create openldap directories");
835 } elsif ($self->{ldap
} eq "fedora-ds") {
836 push (@
{$ctx->{provision_options
}}, "--slapd-path=" . "$ENV{FEDORA_DS_ROOT}/sbin/ns-slapd");
837 push (@
{$ctx->{provision_options
}}, "--setup-ds-path=" . "$ENV{FEDORA_DS_ROOT}/sbin/setup-ds.pl");
838 ($ret->{FEDORA_DS_DIR
}, $ret->{FEDORA_DS_PIDFILE
}) = $self->mk_fedora_ds($ctx) or die("Unable to create fedora ds directories");
843 return $self->provision_raw_step2($ctx, $ret);
846 sub provision_member
($$$)
848 my ($self, $prefix, $dcvars) = @_;
849 print "PROVISIONING MEMBER...";
851 my $ret = $self->provision($prefix,
858 $dcvars->{SERVER_IP
},
864 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
866 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
867 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
868 $cmd .= "$samba_tool domain join $ret->{CONFIGURATION} $dcvars->{REALM} member";
869 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
870 $cmd .= " --machinepass=machine$ret->{password}";
872 unless (system($cmd) == 0) {
873 warn("Join failed\n$cmd");
877 $ret->{MEMBER_SERVER
} = $ret->{SERVER
};
878 $ret->{MEMBER_SERVER_IP
} = $ret->{SERVER_IP
};
879 $ret->{MEMBER_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
880 $ret->{MEMBER_USERNAME
} = $ret->{USERNAME
};
881 $ret->{MEMBER_PASSWORD
} = $ret->{PASSWORD
};
883 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
884 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
885 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
886 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
887 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
892 sub provision_rpc_proxy
($$$)
894 my ($self, $prefix, $dcvars) = @_;
895 print "PROVISIONING RPC PROXY...";
897 my $extra_smbconf_options = "
900 dcerpc_remote:binding = ncacn_ip_tcp:$dcvars->{SERVER}
901 dcerpc endpoint servers = epmapper, remote
902 dcerpc_remote:interfaces = rpcecho
907 cifs:server = $dcvars->{SERVER}
909 cifs:use-s4u2proxy = yes
910 # There is no username specified here, instead the client is expected
911 # to log in with kerberos, and the serverwill use delegated credentials.
912 # Or the server tries s4u2self/s4u2proxy to impersonate the client
916 my $ret = $self->provision($prefix,
923 $dcvars->{SERVER_IP
},
924 $extra_smbconf_options, "", 1);
930 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
932 # The joind runs in the context of the rpc_proxy/member for now
934 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
935 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
936 $cmd .= "$samba_tool domain join $ret->{CONFIGURATION} $dcvars->{REALM} member";
937 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
938 $cmd .= " --machinepass=machine$ret->{password}";
940 unless (system($cmd) == 0) {
941 warn("Join failed\n$cmd");
945 # Setting up delegation runs in the context of the DC for now
947 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$dcvars->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
948 $cmd .= "KRB5_CONFIG=\"$dcvars->{KRB5_CONFIG}\" ";
949 $cmd .= "$samba_tool delegation for-any-protocol '$ret->{NETBIOSNAME}\$' on";
950 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD} $dcvars->{CONFIGURATION}";
952 unless (system($cmd) == 0) {
953 warn("Delegation failed\n$cmd");
957 # Setting up delegation runs in the context of the DC for now
959 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$dcvars->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
960 $cmd .= "KRB5_CONFIG=\"$dcvars->{KRB5_CONFIG}\" ";
961 $cmd .= "$samba_tool delegation add-service '$ret->{NETBIOSNAME}\$' cifs/$dcvars->{SERVER}";
962 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD} $dcvars->{CONFIGURATION}";
964 unless (system($cmd) == 0) {
965 warn("Delegation failed\n$cmd");
969 $ret->{RPC_PROXY_SERVER
} = $ret->{SERVER
};
970 $ret->{RPC_PROXY_SERVER_IP
} = $ret->{SERVER_IP
};
971 $ret->{RPC_PROXY_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
972 $ret->{RPC_PROXY_USERNAME
} = $ret->{USERNAME
};
973 $ret->{RPC_PROXY_PASSWORD
} = $ret->{PASSWORD
};
975 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
976 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
977 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
978 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
979 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
984 sub provision_promoted_vampire_dc
($$$)
986 my ($self, $prefix, $dcvars) = @_;
987 print "PROVISIONING VAMPIRE DC...";
989 # We do this so that we don't run the provision. That's the job of 'net vampire'.
990 my $ctx = $self->provision_raw_prepare($prefix, "domain controller",
996 $dcvars->{SERVER_IP
}, 1);
998 $ctx->{smb_conf_extra_options
} = "
1000 server max protocol = SMB2
1003 path = $ctx->{statedir}/sysvol
1007 path = $ctx->{statedir}/sysvol/$ctx->{dnsname}/scripts
1012 my $ret = $self->provision_raw_step1($ctx);
1017 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
1019 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1020 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1021 $cmd .= "$samba_tool domain join $ret->{CONFIGURATION} $dcvars->{REALM} MEMBER --realm=$dcvars->{REALM}";
1022 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
1023 $cmd .= " --machinepass=machine$ret->{password}";
1025 unless (system($cmd) == 0) {
1026 warn("Join failed\n$cmd");
1030 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
1032 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1033 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1034 $cmd .= "$samba_tool domain dcpromo $ret->{CONFIGURATION} $dcvars->{REALM} DC --realm=$dcvars->{REALM}";
1035 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
1036 $cmd .= " --machinepass=machine$ret->{password} --use-ntvfs";
1038 unless (system($cmd) == 0) {
1039 warn("Join failed\n$cmd");
1043 $ret->{PROMOTED_VAMPIRE_DC_SERVER
} = $ret->{SERVER
};
1044 $ret->{PROMOTED_VAMPIRE_DC_SERVER_IP
} = $ret->{SERVER_IP
};
1045 $ret->{PROMOTED_VAMPIRE_DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1047 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
1048 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
1049 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
1050 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
1051 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
1056 sub provision_vampire_dc
($$$)
1058 my ($self, $prefix, $dcvars) = @_;
1059 print "PROVISIONING VAMPIRE DC...";
1061 # We do this so that we don't run the provision. That's the job of 'net vampire'.
1062 my $ctx = $self->provision_raw_prepare($prefix, "domain controller",
1065 "samba.example.com",
1067 $dcvars->{PASSWORD
},
1068 $dcvars->{SERVER_IP
}, 1);
1070 $ctx->{smb_conf_extra_options
} = "
1072 server max protocol = SMB2
1075 path = $ctx->{statedir}/sysvol
1079 path = $ctx->{statedir}/sysvol/$ctx->{dnsname}/scripts
1084 my $ret = $self->provision_raw_step1($ctx);
1089 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
1091 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1092 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1093 $cmd .= "$samba_tool domain join $ret->{CONFIGURATION} $dcvars->{REALM} DC --realm=$dcvars->{REALM}";
1094 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD} --domain-critical-only";
1095 $cmd .= " --machinepass=machine$ret->{password} --use-ntvfs";
1097 unless (system($cmd) == 0) {
1098 warn("Join failed\n$cmd");
1102 $ret->{VAMPIRE_DC_SERVER
} = $ret->{SERVER
};
1103 $ret->{VAMPIRE_DC_SERVER_IP
} = $ret->{SERVER_IP
};
1104 $ret->{VAMPIRE_DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1106 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
1107 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
1108 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
1109 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
1110 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
1115 sub provision_subdom_dc
($$$)
1117 my ($self, $prefix, $dcvars) = @_;
1118 print "PROVISIONING SUBDOMAIN DC...";
1120 # We do this so that we don't run the provision. That's the job of 'net vampire'.
1121 my $ctx = $self->provision_raw_prepare($prefix, "domain controller",
1124 "sub.samba.example.com",
1126 $dcvars->{PASSWORD
},
1129 $ctx->{smb_conf_extra_options
} = "
1131 server max protocol = SMB2
1134 path = $ctx->{statedir}/sysvol
1138 path = $ctx->{statedir}/sysvol/$ctx->{dnsname}/scripts
1143 my $ret = $self->provision_raw_step1($ctx);
1148 my $dc_realms = Samba
::mk_realms_stanza
($dcvars->{REALM
}, lc($dcvars->{REALM
}),
1149 $dcvars->{DOMAIN
}, $dcvars->{SERVER_IP
});
1150 Samba
::mk_krb5_conf
($ctx, $dc_realms);
1152 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
1154 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1155 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1156 $cmd .= "$samba_tool domain join $ret->{CONFIGURATION} $ctx->{realm} subdomain ";
1157 $cmd .= "--parent-domain=$dcvars->{REALM} -U$dcvars->{DC_USERNAME}\@$dcvars->{REALM}\%$dcvars->{DC_PASSWORD}";
1158 $cmd .= " --machinepass=machine$ret->{password} --use-ntvfs";
1160 unless (system($cmd) == 0) {
1161 warn("Join failed\n$cmd");
1165 $ret->{SUBDOM_DC_SERVER
} = $ret->{SERVER
};
1166 $ret->{SUBDOM_DC_SERVER_IP
} = $ret->{SERVER_IP
};
1167 $ret->{SUBDOM_DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1169 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
1170 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
1171 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
1172 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
1173 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
1178 sub provision_dc
($$)
1180 my ($self, $prefix) = @_;
1182 print "PROVISIONING DC...";
1183 my $extra_conf_options = "netbios aliases = localDC1-a
1184 allow dns updates = True";
1185 my $ret = $self->provision($prefix,
1186 "domain controller",
1189 "samba.example.com",
1192 undef, $extra_conf_options, "", 1);
1194 return undef unless(defined $ret);
1195 unless($self->add_wins_config("$prefix/private")) {
1196 warn("Unable to add wins configuration");
1199 $ret->{NETBIOSALIAS
} = "localdc1-a";
1200 $ret->{DC_SERVER
} = $ret->{SERVER
};
1201 $ret->{DC_SERVER_IP
} = $ret->{SERVER_IP
};
1202 $ret->{DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1203 $ret->{DC_USERNAME
} = $ret->{USERNAME
};
1204 $ret->{DC_PASSWORD
} = $ret->{PASSWORD
};
1209 sub provision_fl2000dc
($$)
1211 my ($self, $prefix) = @_;
1213 print "PROVISIONING DC...";
1214 my $ret = $self->provision($prefix,
1215 "domain controller",
1218 "samba2000.example.com",
1223 unless($self->add_wins_config("$prefix/private")) {
1224 warn("Unable to add wins configuration");
1231 sub provision_fl2003dc
($$)
1233 my ($self, $prefix) = @_;
1235 print "PROVISIONING DC...";
1236 my $ret = $self->provision($prefix,
1237 "domain controller",
1240 "samba2003.example.com",
1245 unless($self->add_wins_config("$prefix/private")) {
1246 warn("Unable to add wins configuration");
1253 sub provision_fl2008r2dc
($$)
1255 my ($self, $prefix) = @_;
1257 print "PROVISIONING DC...";
1258 my $ret = $self->provision($prefix,
1259 "domain controller",
1262 "samba2008R2.example.com",
1267 unless ($self->add_wins_config("$prefix/private")) {
1268 warn("Unable to add wins configuration");
1276 sub provision_rodc
($$$)
1278 my ($self, $prefix, $dcvars) = @_;
1279 print "PROVISIONING RODC...";
1281 # We do this so that we don't run the provision. That's the job of 'net join RODC'.
1282 my $ctx = $self->provision_raw_prepare($prefix, "domain controller",
1285 "samba.example.com",
1287 $dcvars->{PASSWORD
},
1288 $dcvars->{SERVER_IP
}, 1);
1293 $ctx->{share
} = "$ctx->{prefix_abs}/share";
1294 push(@
{$ctx->{directories
}}, "$ctx->{share}");
1296 $ctx->{smb_conf_extra_options
} = "
1298 server max protocol = SMB2
1301 path = $ctx->{statedir}/sysvol
1305 path = $ctx->{statedir}/sysvol/$ctx->{dnsname}/scripts
1309 path = $ctx->{share}
1311 posix:sharedelay = 10000
1312 posix:oplocktimeout = 3
1313 posix:writetimeupdatedelay = 50000
1317 my $ret = $self->provision_raw_step1($ctx);
1322 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
1324 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
1325 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
1326 $cmd .= "$samba_tool domain join $ret->{CONFIGURATION} $dcvars->{REALM} RODC";
1327 $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
1328 $cmd .= " --server=$dcvars->{DC_SERVER} --use-ntvfs";
1330 unless (system($cmd) == 0) {
1331 warn("RODC join failed\n$cmd");
1335 # we overwrite the kdc after the RODC join
1336 # so that use the RODC as kdc and test
1338 $ctx->{kdc_ipv4
} = $ret->{SERVER_IP
};
1339 Samba
::mk_krb5_conf
($ctx);
1341 $ret->{RODC_DC_SERVER
} = $ret->{SERVER
};
1342 $ret->{RODC_DC_SERVER_IP
} = $ret->{SERVER_IP
};
1343 $ret->{RODC_DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1345 $ret->{DC_SERVER
} = $dcvars->{DC_SERVER
};
1346 $ret->{DC_SERVER_IP
} = $dcvars->{DC_SERVER_IP
};
1347 $ret->{DC_NETBIOSNAME
} = $dcvars->{DC_NETBIOSNAME
};
1348 $ret->{DC_USERNAME
} = $dcvars->{DC_USERNAME
};
1349 $ret->{DC_PASSWORD
} = $dcvars->{DC_PASSWORD
};
1354 sub provision_plugin_s4_dc
($$)
1356 my ($self, $prefix) = @_;
1358 my $prefix_abs = abs_path
($prefix);
1360 my $bindir_abs = abs_path
($self->{bindir
});
1361 my $lockdir="$prefix_abs/lockdir";
1362 my $conffile="$prefix_abs/etc/smb.conf";
1364 my $extra_smbconf_options = "
1365 server services = -smb +s3fs
1366 xattr_tdb:file = $prefix_abs/statedir/xattr.tdb
1369 kernel change notify = no
1373 printcap name = /dev/null
1377 server signing = auto
1379 smbd:sharedelay = 100000
1380 smbd:writetimeupdatedelay = 500000
1384 dcerpc endpoint servers = -winreg -srvsvc
1386 printcap name = /dev/null
1388 addprinter command = $ENV{SRCDIR_ABS}/source3/script/tests/printing/modprinter.pl -a -s $conffile --
1389 deleteprinter command = $ENV{SRCDIR_ABS}/source3/script/tests/printing/modprinter.pl -d -s $conffile --
1392 print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
1393 lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
1394 lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
1395 lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
1396 lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
1397 queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
1398 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
1403 my $extra_smbconf_shares = "
1407 smb encrypt = required
1411 case sensitive = yes
1419 hide unreadable = yes
1436 print "PROVISIONING PLUGIN S4 DC...";
1437 my $ret = $self->provision($prefix,
1438 "domain controller",
1441 "plugin.samba.example.com",
1444 undef, $extra_smbconf_options,
1445 $extra_smbconf_shares, 0);
1447 return undef unless(defined $ret);
1448 unless($self->add_wins_config("$prefix/private")) {
1449 warn("Unable to add wins configuration");
1453 $ret->{DC_SERVER
} = $ret->{SERVER
};
1454 $ret->{DC_SERVER_IP
} = $ret->{SERVER_IP
};
1455 $ret->{DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1456 $ret->{DC_USERNAME
} = $ret->{USERNAME
};
1457 $ret->{DC_PASSWORD
} = $ret->{PASSWORD
};
1462 sub provision_chgdcpass
($$)
1464 my ($self, $prefix) = @_;
1466 print "PROVISIONING CHGDCPASS...";
1467 my $ret = $self->provision($prefix,
1468 "domain controller",
1471 "chgdcpassword.samba.example.com",
1476 return undef unless(defined $ret);
1477 unless($self->add_wins_config("$prefix/private")) {
1478 warn("Unable to add wins configuration");
1482 # Remove secrets.tdb from this environment to test that we still start up
1483 # on systems without the new matching secrets.tdb records
1484 unless (unlink("$ret->{PRIVATEDIR}/secrets.tdb")) {
1485 warn("Unable to remove $ret->{PRIVATEDIR}/secrets.tdb added during provision");
1489 $ret->{DC_SERVER
} = $ret->{SERVER
};
1490 $ret->{DC_SERVER_IP
} = $ret->{SERVER_IP
};
1491 $ret->{DC_NETBIOSNAME
} = $ret->{NETBIOSNAME
};
1492 $ret->{DC_USERNAME
} = $ret->{USERNAME
};
1493 $ret->{DC_PASSWORD
} = $ret->{PASSWORD
};
1498 sub teardown_env
($$)
1500 my ($self, $envvars) = @_;
1503 # This should cause samba to terminate gracefully
1504 close($envvars->{STDIN_PIPE
});
1506 $pid = $envvars->{SAMBA_PID
};
1510 # This should give it time to write out the gcov data
1511 until ($count > 30) {
1512 if (Samba
::cleanup_child
($pid, "samba") == -1) {
1519 if ($count <= 20 && kill(0, $pid) == 0) {
1525 until ($count > 20) {
1526 if (Samba
::cleanup_child
($pid, "samba") == -1) {
1533 # If it is still around, kill it
1534 if ($count > 20 && kill(0, $pid) == 0) {
1535 warn "server process $pid took more than $count seconds to exit, killing\n";
1539 $self->slapd_stop($envvars) if ($self->{ldap
});
1541 print $self->getlog_env($envvars);
1548 my ($self, $envvars) = @_;
1549 my $title = "SAMBA LOG of: $envvars->{NETBIOSNAME}\n";
1552 open(LOG
, "<$envvars->{SAMBA_TEST_LOG}");
1554 seek(LOG
, $envvars->{SAMBA_TEST_LOG_POS
}, SEEK_SET
);
1558 $envvars->{SAMBA_TEST_LOG_POS
} = tell(LOG
);
1561 return "" if $out eq $title;
1568 my ($self, $envvars) = @_;
1570 my $childpid = Samba
::cleanup_child
($envvars->{SAMBA_PID
}, "samba");
1572 return ($childpid == 0);
1577 my ($self, $envname, $path) = @_;
1578 my $target3 = $self->{target3
};
1580 $ENV{ENVNAME
} = $envname;
1582 if (defined($self->{vars
}->{$envname})) {
1583 return $self->{vars
}->{$envname};
1586 if ($envname eq "dc") {
1587 return $self->setup_dc("$path/dc");
1588 } elsif ($envname eq "fl2000dc") {
1589 return $self->setup_fl2000dc("$path/fl2000dc");
1590 } elsif ($envname eq "fl2003dc") {
1591 return $self->setup_fl2003dc("$path/fl2003dc");
1592 } elsif ($envname eq "fl2008r2dc") {
1593 return $self->setup_fl2008r2dc("$path/fl2008r2dc");
1594 } elsif ($envname eq "rpc_proxy") {
1595 if (not defined($self->{vars
}->{dc
})) {
1596 $self->setup_dc("$path/dc");
1598 return $self->setup_rpc_proxy("$path/rpc_proxy", $self->{vars
}->{dc
});
1599 } elsif ($envname eq "vampire_dc") {
1600 if (not defined($self->{vars
}->{dc
})) {
1601 $self->setup_dc("$path/dc");
1603 return $self->setup_vampire_dc("$path/vampire_dc", $self->{vars
}->{dc
});
1604 } elsif ($envname eq "promoted_vampire_dc") {
1605 if (not defined($self->{vars
}->{dc
})) {
1606 $self->setup_dc("$path/dc");
1608 return $self->setup_promoted_vampire_dc("$path/promoted_vampire_dc", $self->{vars
}->{dc
});
1609 } elsif ($envname eq "subdom_dc") {
1610 if (not defined($self->{vars
}->{dc
})) {
1611 $self->setup_dc("$path/dc");
1613 return $self->setup_subdom_dc("$path/subdom_dc", $self->{vars
}->{dc
});
1614 } elsif ($envname eq "s4member") {
1615 if (not defined($self->{vars
}->{dc
})) {
1616 $self->setup_dc("$path/dc");
1618 return $self->setup_member("$path/s4member", $self->{vars
}->{dc
});
1619 } elsif ($envname eq "rodc") {
1620 if (not defined($self->{vars
}->{dc
})) {
1621 $self->setup_dc("$path/dc");
1623 return $self->setup_rodc("$path/rodc", $self->{vars
}->{dc
});
1624 } elsif ($envname eq "chgdcpass") {
1625 return $self->setup_chgdcpass("$path/chgdcpass", $self->{vars
}->{chgdcpass
});
1626 } elsif ($envname eq "s3member") {
1627 if (not defined($self->{vars
}->{dc
})) {
1628 $self->setup_dc("$path/dc");
1630 return $target3->setup_admember("$path/s3member", $self->{vars
}->{dc
}, 29);
1631 } elsif ($envname eq "plugin_s4_dc") {
1632 return $self->setup_plugin_s4_dc("$path/plugin_s4_dc");
1638 sub setup_member
($$$)
1640 my ($self, $path, $dc_vars) = @_;
1642 my $env = $self->provision_member($path, $dc_vars);
1645 $self->check_or_start($env, "single");
1647 $self->wait_for_start($env);
1649 $self->{vars
}->{member
} = $env;
1655 sub setup_rpc_proxy
($$$)
1657 my ($self, $path, $dc_vars) = @_;
1659 my $env = $self->provision_rpc_proxy($path, $dc_vars);
1662 $self->check_or_start($env, "single");
1664 $self->wait_for_start($env);
1666 $self->{vars
}->{rpc_proxy
} = $env;
1673 my ($self, $path) = @_;
1675 my $env = $self->provision_dc($path);
1677 $self->check_or_start($env, "standard");
1679 $self->wait_for_start($env);
1681 $self->{vars
}->{dc
} = $env;
1686 sub setup_chgdcpass
($$)
1688 my ($self, $path) = @_;
1690 my $env = $self->provision_chgdcpass($path);
1692 $self->check_or_start($env, "single");
1694 $self->wait_for_start($env);
1696 $self->{vars
}->{chgdcpass
} = $env;
1701 sub setup_fl2000dc
($$)
1703 my ($self, $path) = @_;
1705 my $env = $self->provision_fl2000dc($path);
1707 $self->check_or_start($env, "single");
1709 $self->wait_for_start($env);
1711 $self->{vars
}->{fl2000dc
} = $env;
1717 sub setup_fl2003dc
($$)
1719 my ($self, $path) = @_;
1721 my $env = $self->provision_fl2003dc($path);
1724 $self->check_or_start($env, "single");
1726 $self->wait_for_start($env);
1728 $self->{vars
}->{fl2003dc
} = $env;
1733 sub setup_fl2008r2dc
($$)
1735 my ($self, $path) = @_;
1737 my $env = $self->provision_fl2008r2dc($path);
1740 $self->check_or_start($env, "single");
1742 $self->wait_for_start($env);
1744 $self->{vars
}->{fl2008r2dc
} = $env;
1750 sub setup_vampire_dc
($$$)
1752 my ($self, $path, $dc_vars) = @_;
1754 my $env = $self->provision_vampire_dc($path, $dc_vars);
1757 $self->check_or_start($env, "single");
1759 $self->wait_for_start($env);
1761 $self->{vars
}->{vampire_dc
} = $env;
1763 # force replicated DC to update repsTo/repsFrom
1764 # for vampired partitions
1765 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
1767 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
1768 $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
1769 $cmd .= " $samba_tool drs kcc $env->{DC_SERVER}";
1770 $cmd .= " $env->{CONFIGURATION}";
1771 $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD}";
1772 unless (system($cmd) == 0) {
1773 warn("Failed to exec kcc\n$cmd");
1777 # as 'vampired' dc may add data in its local replica
1778 # we need to synchronize data between DCs
1779 my $base_dn = "DC=".join(",DC=", split(/\./, $dc_vars->{REALM
}));
1780 $cmd = "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
1781 $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
1782 $cmd .= " $samba_tool drs replicate $env->{DC_SERVER} $env->{SERVER}";
1783 $cmd .= " $dc_vars->{CONFIGURATION}";
1784 $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD}";
1785 # replicate Configuration NC
1786 my $cmd_repl = "$cmd \"CN=Configuration,$base_dn\"";
1787 unless(system($cmd_repl) == 0) {
1788 warn("Failed to replicate\n$cmd_repl");
1791 # replicate Default NC
1792 $cmd_repl = "$cmd \"$base_dn\"";
1793 unless(system($cmd_repl) == 0) {
1794 warn("Failed to replicate\n$cmd_repl");
1802 sub setup_promoted_vampire_dc
($$$)
1804 my ($self, $path, $dc_vars) = @_;
1806 my $env = $self->provision_promoted_vampire_dc($path, $dc_vars);
1809 $self->check_or_start($env, "single");
1811 $self->wait_for_start($env);
1813 $self->{vars
}->{promoted_vampire_dc
} = $env;
1815 # force replicated DC to update repsTo/repsFrom
1816 # for vampired partitions
1817 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
1819 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
1820 $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
1821 $cmd .= " $samba_tool drs kcc $env->{DC_SERVER}";
1822 $cmd .= " $env->{CONFIGURATION}";
1823 $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD}";
1824 unless (system($cmd) == 0) {
1825 warn("Failed to exec kcc\n$cmd");
1829 # as 'vampired' dc may add data in its local replica
1830 # we need to synchronize data between DCs
1831 my $base_dn = "DC=".join(",DC=", split(/\./, $dc_vars->{REALM
}));
1832 $cmd = "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
1833 $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
1834 $cmd .= " $samba_tool drs replicate $env->{DC_SERVER} $env->{SERVER}";
1835 $cmd .= " $dc_vars->{CONFIGURATION}";
1836 $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD}";
1837 # replicate Configuration NC
1838 my $cmd_repl = "$cmd \"CN=Configuration,$base_dn\"";
1839 unless(system($cmd_repl) == 0) {
1840 warn("Failed to replicate\n$cmd_repl");
1843 # replicate Default NC
1844 $cmd_repl = "$cmd \"$base_dn\"";
1845 unless(system($cmd_repl) == 0) {
1846 warn("Failed to replicate\n$cmd_repl");
1854 sub setup_subdom_dc
($$$)
1856 my ($self, $path, $dc_vars) = @_;
1858 my $env = $self->provision_subdom_dc($path, $dc_vars);
1861 $self->check_or_start($env, "single");
1863 $self->wait_for_start($env);
1865 $self->{vars
}->{subdom_dc
} = $env;
1867 # force replicated DC to update repsTo/repsFrom
1868 # for primary domain partitions
1869 my $samba_tool = Samba
::bindir_path
($self, "samba-tool");
1871 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
1872 $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
1873 $cmd .= " $samba_tool drs kcc $env->{DC_SERVER}";
1874 $cmd .= " $env->{CONFIGURATION}";
1875 $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD} --realm=$dc_vars->{DC_REALM}";
1876 unless (system($cmd) == 0) {
1877 warn("Failed to exec kcc\n$cmd");
1881 # as 'subdomain' dc may add data in its local replica
1882 # we need to synchronize data between DCs
1883 my $base_dn = "DC=".join(",DC=", split(/\./, $env->{REALM
}));
1884 my $config_dn = "CN=Configuration,DC=".join(",DC=", split(/\./, $dc_vars->{REALM
}));
1885 $cmd = "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
1886 $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
1887 $cmd .= " $samba_tool drs replicate $env->{DC_SERVER} $env->{SUBDOM_DC_SERVER}";
1888 $cmd .= " $dc_vars->{CONFIGURATION}";
1889 $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD} --realm=$dc_vars->{DC_REALM}";
1890 # replicate Configuration NC
1891 my $cmd_repl = "$cmd \"$config_dn\"";
1892 unless(system($cmd_repl) == 0) {
1893 warn("Failed to replicate\n$cmd_repl");
1896 # replicate Default NC
1897 $cmd_repl = "$cmd \"$base_dn\"";
1898 unless(system($cmd_repl) == 0) {
1899 warn("Failed to replicate\n$cmd_repl");
1909 my ($self, $path, $dc_vars) = @_;
1911 my $env = $self->provision_rodc($path, $dc_vars);
1917 $self->check_or_start($env, "single");
1919 $self->wait_for_start($env);
1921 $self->{vars
}->{rodc
} = $env;
1926 sub setup_plugin_s4_dc
($$)
1928 my ($self, $path) = @_;
1930 # If we didn't build with ADS, pretend this env was never available
1931 if (not $self->{target3
}->have_ads()) {
1935 my $env = $self->provision_plugin_s4_dc($path);
1940 $self->check_or_start($env, "single");
1942 $self->wait_for_start($env);
1944 $self->{vars
}->{plugin_s4_dc
} = $env;