use target::Samba3;
sub new($$$$$) {
- my ($classname, $bindir, $binary_mapping, $ldap, $srcdir, $exeext, $server_maxtime) = @_;
- $exeext = "" unless defined($exeext);
+ my ($classname, $bindir, $binary_mapping, $ldap, $srcdir, $server_maxtime) = @_;
my $self = {
vars => {},
bindir => $bindir,
binary_mapping => $binary_mapping,
srcdir => $srcdir,
- exeext => $exeext,
server_maxtime => $server_maxtime,
- target3 => new Samba3($bindir, $binary_mapping, $srcdir, $exeext, $server_maxtime)
+ target3 => new Samba3($bindir, $binary_mapping, $srcdir, $server_maxtime)
};
bless $self;
return $self;
sub slapd_start($$)
{
my $count = 0;
- my ($self, $env_vars) = @_;
+ my ($self, $env_vars, $STDIN_READER) = @_;
my $ldbsearch = Samba::bindir_path($self, "ldbsearch");
my $uri = $env_vars->{LDAP_URI};
}
# running slapd in the background means it stays in the same process group, so it can be
# killed by timelimit
- if ($self->{ldap} eq "fedora-ds") {
- 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 &");
- } elsif ($self->{ldap} eq "openldap") {
- system("$ENV{OPENLDAP_SLAPD} -d0 -F $env_vars->{SLAPD_CONF_D} -h $uri > $env_vars->{LDAPDIR}/logs 2>&1 &");
+ my $pid = fork();
+ if ($pid == 0) {
+ open STDOUT, ">$env_vars->{LDAPDIR}/logs";
+ open STDERR, '>&STDOUT';
+ close($env_vars->{STDIN_PIPE});
+ open STDIN, ">&", $STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
+
+ if ($self->{ldap} eq "fedora-ds") {
+ exec("$ENV{FEDORA_DS_ROOT}/sbin/ns-slapd", "-D", $env_vars->{FEDORA_DS_DIR}, "-d0", "-i", $env_vars->{FEDORA_DS_PIDFILE});
+ } elsif ($self->{ldap} eq "openldap") {
+ exec($ENV{OPENLDAP_SLAPD}, "-dnone", "-F", $env_vars->{SLAPD_CONF_D}, "-h", $uri);
+ }
+ die("Unable to start slapd: $!");
}
+ $env_vars->{SLAPD_PID} = $pid;
+ sleep(1);
while (system("$ldbsearch -H $uri -s base -b \"\" supportedLDAPVersion > /dev/null") != 0) {
$count++;
if ($count > 40) {
sub slapd_stop($$)
{
my ($self, $envvars) = @_;
- if ($self->{ldap} eq "fedora-ds") {
- system("$envvars->{LDAPDIR}/slapd-$envvars->{LDAP_INSTANCE}/stop-slapd");
- } elsif ($self->{ldap} eq "openldap") {
- unless (open(IN, "<$envvars->{OPENLDAP_PIDFILE}")) {
- warn("unable to open slapd pid file: $envvars->{OPENLDAP_PIDFILE}");
- return 0;
- }
- kill 9, <IN>;
- close(IN);
- }
+ kill 9, $envvars->{SLAPD_PID};
return 1;
}
sub check_or_start($$$)
{
- my ($self, $env_vars, $process_model) = @_;
- return 0 if ( -p $env_vars->{SAMBA_TEST_FIFO});
+ my ($self, $env_vars, $process_model) = @_;
+ my $STDIN_READER;
- unlink($env_vars->{SAMBA_TEST_FIFO});
- POSIX::mkfifo($env_vars->{SAMBA_TEST_FIFO}, 0700);
- unlink($env_vars->{SAMBA_TEST_LOG});
-
- my $pwd = `pwd`;
- print "STARTING SAMBA for $ENV{ENVNAME}\n";
+ return 0 if $self->check_env($env_vars);
+
+ # use a pipe for stdin in the child processes. This allows
+ # those processes to monitor the pipe for EOF to ensure they
+ # exit when the test script exits
+ pipe($STDIN_READER, $env_vars->{STDIN_PIPE});
+
+ # Start slapd before samba, but with the fifo on stdin
+ if (defined($self->{ldap})) {
+ unless($self->slapd_start($env_vars, $STDIN_READER)) {
+ warn("couldn't start slapd (main run)");
+ return undef;
+ }
+ }
+
+ print "STARTING SAMBA...";
my $pid = fork();
if ($pid == 0) {
- open STDIN, $env_vars->{SAMBA_TEST_FIFO};
# we want out from samba to go to the log file, but also
# to the users terminal when running 'make test' on the command
# line. This puts it on stderr on the terminal
SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
- my $valgrind = "";
- if (defined($ENV{SAMBA_VALGRIND})) {
- $valgrind = $ENV{SAMBA_VALGRIND};
- }
-
$ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
- $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR};
+ $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR};
+ $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR};
$ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
$ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
+ $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS};
+ $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH};
+ $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX};
$ENV{UID_WRAPPER} = "1";
- # Start slapd before samba, but with the fifo on stdin
- if (defined($self->{ldap})) {
- unless($self->slapd_start($env_vars)) {
- warn("couldn't start slapd (main run)");
- return undef;
- }
- }
-
- my $optarg = "";
- $optarg = "--maximum-runtime=$self->{server_maxtime}";
+ $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "samba");
+ my @preargs = ();
+ my @optargs = ();
if (defined($ENV{SAMBA_OPTIONS})) {
- $optarg.= " $ENV{SAMBA_OPTIONS}";
+ @optargs = split(/ /, $ENV{SAMBA_OPTIONS});
}
- my $samba = Samba::bindir_path($self, "samba");
-
- chomp($pwd);
- my $cmdline = "$valgrind ${pwd}/$samba $optarg $env_vars->{CONFIGURATION} -M $process_model -i";
- my $ret = system("$cmdline");
- if ($ret == -1) {
- print "Unable to start $cmdline: $ret: $!\n";
- exit 1;
+ if(defined($ENV{SAMBA_VALGRIND})) {
+ @preargs = split(/ /,$ENV{SAMBA_VALGRIND});
}
- my $exit = ($ret >> 8);
- unlink($env_vars->{SAMBA_TEST_FIFO});
- if ($ret == 0) {
- print "$samba exited with no error\n";
- exit 0;
- } elsif ( $ret & 127 ) {
- print "$samba got signal ".($ret & 127)." and exits with $exit!\n";
- } else {
- print "$samba failed with status $exit!\n";
- }
- if ($exit == 0) {
- $exit = -1;
- }
- exit $exit;
+
+ close($env_vars->{STDIN_PIPE});
+ open STDIN, ">&", $STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
+
+ 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: $!");
}
+ $env_vars->{SAMBA_PID} = $pid;
print "DONE\n";
- open(DATA, ">$env_vars->{SAMBA_TEST_FIFO}");
+ close($STDIN_READER);
return $pid;
}
sub wait_for_start($$)
{
my ($self, $testenv_vars) = @_;
+ my $ret;
# give time for nbt server to register its names
print "delaying for nbt name registration\n";
sleep 2;
# This will return quickly when things are up, but be slow if we
# need to wait for (eg) SSL init
- my $nmblookup = Samba::bindir_path($self, "nmblookup");
+ my $nmblookup = Samba::bindir_path($self, "nmblookup4");
system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{SERVER}");
system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{SERVER}");
system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}");
+ # Ensure we have the first RID Set before we start tests. This makes the tests more reliable.
+ if ($testenv_vars->{SERVER_ROLE} eq "domain controller" and not ($testenv_vars->{NETBIOS_NAME} eq "rodc")) {
+ # Add hosts file for name lookups
+ $ENV{NSS_WRAPPER_HOSTS} = $testenv_vars->{NSS_WRAPPER_HOSTS};
+
+ print "waiting for working LDAP and a RID Set to be allocated\n";
+ my $ldbsearch = Samba::bindir_path($self, "ldbsearch");
+ my $count = 0;
+ my $base_dn = "DC=".join(",DC=", split(/\./, $testenv_vars->{REALM}));
+ my $rid_set_dn = "cn=RID Set,cn=$testenv_vars->{NETBIOSNAME},ou=domain controllers,$base_dn";
+ sleep(1);
+ 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) {
+ $count++;
+ if ($count > 40) {
+ $ret = 1;
+ last;
+ }
+ sleep(1);
+ }
+ }
print $self->getlog_env($testenv_vars);
+
+ return $ret
}
sub write_ldb_file($$$)
my $admincertfile = "$tlsdir/admincert.pem";
my $admincertupnfile = "$tlsdir/admincertupn.pem";
- mkdir($tlsdir, 0777);
+ mkdir($tlsdir, 0700);
+ my $oldumask = umask;
+ umask 0077;
#This is specified here to avoid draining entropy on every run
open(DHFILE, ">$dhfile");
Wfz/8alZ5aMezCQzXJyIaJsCLeKABosSwHcpAFmxlQ==
-----END CERTIFICATE-----
EOF
+
+ umask $oldumask;
}
sub provision_raw_prepare($$$$$$$$$$)
{
my ($self, $prefix, $server_role, $hostname,
$domain, $realm, $functional_level,
- $swiface, $password, $kdc_ipv4) = @_;
+ $password, $kdc_ipv4) = @_;
my $ctx;
my $netbiosname = uc($hostname);
warn("Unable to clean up");
}
+
+ my $swiface = Samba::get_interface($hostname);
+
$ctx->{prefix} = $prefix;
$ctx->{prefix_abs} = $prefix_abs;
$ctx->{password} = $password;
$ctx->{kdc_ipv4} = $kdc_ipv4;
+#
+# Set smbd log level here.
+#
$ctx->{server_loglevel} =$ENV{SERVER_LOG_LEVEL} || 1;
$ctx->{username} = "Administrator";
$ctx->{domain} = $domain;
$ctx->{realm} = uc($realm);
$ctx->{dnsname} = lc($realm);
- $ctx->{sid_generator} = "internal";
$ctx->{functional_level} = $functional_level;
chomp $unix_name;
$ctx->{unix_name} = $unix_name;
$ctx->{unix_uid} = $>;
+ my @mygid = split(" ", $();
+ $ctx->{unix_gid} = $mygid[0];
$ctx->{unix_gids_str} = $);
@{$ctx->{unix_gids}} = split(" ", $ctx->{unix_gids_str});
$ctx->{privatedir} = "$prefix_abs/private";
$ctx->{ncalrpcdir} = "$prefix_abs/ncalrpc";
$ctx->{lockdir} = "$prefix_abs/lockdir";
+ $ctx->{logdir} = "$prefix_abs/logs";
$ctx->{statedir} = "$prefix_abs/statedir";
$ctx->{cachedir} = "$prefix_abs/cachedir";
$ctx->{winbindd_socket_dir} = "$prefix_abs/winbindd_socket";
$ctx->{ntp_signd_socket_dir} = "$prefix_abs/ntp_signd_socket";
$ctx->{nsswrap_passwd} = "$ctx->{etcdir}/passwd";
$ctx->{nsswrap_group} = "$ctx->{etcdir}/group";
+ $ctx->{nsswrap_hosts} = "$ENV{SELFTEST_PREFIX}/hosts";
$ctx->{tlsdir} = "$ctx->{privatedir}/tls";
push(@{$ctx->{directories}}, $ctx->{etcdir});
push(@{$ctx->{directories}}, $ctx->{piddir});
push(@{$ctx->{directories}}, $ctx->{lockdir});
+ push(@{$ctx->{directories}}, $ctx->{logdir});
push(@{$ctx->{directories}}, $ctx->{statedir});
push(@{$ctx->{directories}}, $ctx->{cachedir});
my @provision_options = ();
push (@provision_options, "NSS_WRAPPER_PASSWD=\"$ctx->{nsswrap_passwd}\"");
push (@provision_options, "NSS_WRAPPER_GROUP=\"$ctx->{nsswrap_group}\"");
+ push (@provision_options, "NSS_WRAPPER_HOSTS=\"$ctx->{nsswrap_hosts}\"");
if (defined($ENV{GDB_PROVISION})) {
push (@provision_options, "gdb --args");
if (!defined($ENV{PYTHON})) {
if (defined($ENV{PYTHON})) {
push (@provision_options, $ENV{PYTHON});
}
- push (@provision_options, "$self->{srcdir}/source4/setup/provision");
+ push (@provision_options, Samba::bindir_path($self, "samba-tool"));
+ push (@provision_options, "domain");
+ push (@provision_options, "provision");
push (@provision_options, "--configfile=$ctx->{smb_conf}");
push (@provision_options, "--host-name=$ctx->{hostname}");
push (@provision_options, "--host-ip=$ctx->{ipv4}");
mkdir($_, 0777) foreach (@{$ctx->{directories}});
+ ##
+ ## lockdir and piddir must be 0755
+ ##
+ chmod 0755, $ctx->{lockdir};
+ chmod 0755, $ctx->{piddir};
+
unless (open(CONFFILE, ">$ctx->{smb_conf}")) {
warn("can't open $ctx->{smb_conf}$?");
return undef;
}
- my $acl = "false";
- $acl = "true" if (defined $ENV{WITH_ACL});
print CONFFILE "
[global]
- acl:search = $acl
netbios name = $ctx->{netbiosname}
posix:eadb = $ctx->{statedir}/eadb.tdb
workgroup = $ctx->{domain}
panic action = $RealBin/gdb_backtrace \%d
wins support = yes
server role = $ctx->{server_role}
- server services = +echo
+ server services = +echo +smb -s3fs
+ dcerpc endpoint servers = +winreg +srvsvc
notify:inotify = false
ldb:nosync = true
#We don't want to pass our self-tests if the PAC code is wrong
gensec:require_pac = true
+ log file = $ctx->{logdir}/log.\%m
log level = $ctx->{server_loglevel}
lanman auth = Yes
rndc command = true
- dns update command = $ENV{SRCDIR_ABS}/source4/scripting/bin/samba_dnsupdate --all-interfaces --use-file=$ctx->{dns_host_file}
- spn update command = $ENV{SRCDIR_ABS}/source4/scripting/bin/samba_spnupdate
- resolv:host file = $ctx->{dns_host_file}
+ dns update command = $ENV{SRCDIR_ABS}/source4/scripting/bin/samba_dnsupdate --all-interfaces --use-file=$ctx->{dns_host_file} -s $ctx->{smb_conf}
+ spn update command = $ENV{SRCDIR_ABS}/source4/scripting/bin/samba_spnupdate -s $ctx->{smb_conf}
+ resolv:host file = $ctx->{dns_host_file}
dreplsrv:periodic_startup_interval = 0
+ dsdb:schema update allowed = yes
- passdb backend = samba4
-";
+ vfs objects = dfs_samba4 acl_xattr fake_acls xattr_tdb streams_depot
- if (defined($ctx->{sid_generator}) && $ctx->{sid_generator} ne "internal") {
- print CONFFILE "
- sid generator = $ctx->{sid_generator}";
- }
+ # remove this again, when our smb2 client library
+ # supports signin on compound related requests
+ server signing = on
+
+ idmap_ldb:use rfc2307=yes
+ winbind enum users = yes
+ winbind enum groups = yes
+";
print CONFFILE "
open(PWD, ">$ctx->{nsswrap_passwd}");
print PWD "
root:x:0:0:root gecos:$ctx->{prefix_abs}:/bin/false
-$ctx->{unix_name}:x:$ctx->{unix_uid}:@{$ctx->{unix_gids}}[0]:$ctx->{unix_name} gecos:$ctx->{prefix_abs}:/bin/false
+$ctx->{unix_name}:x:$ctx->{unix_uid}:100:$ctx->{unix_name} gecos:$ctx->{prefix_abs}:/bin/false
nobody:x:65534:65533:nobody gecos:$ctx->{prefix_abs}:/bin/false
+pdbtest:x:65533:65533:pdbtest gecos:$ctx->{prefix_abs}:/bin/false
+pdbtest2:x:65532:65533:pdbtest gecos:$ctx->{prefix_abs}:/bin/false
+pdbtest3:x:65531:65533:pdbtest gecos:$ctx->{prefix_abs}:/bin/false
+pdbtest4:x:65530:65533:pdbtest gecos:$ctx->{prefix_abs}:/bin/false
";
close(PWD);
+ my $uid_rfc2307test = 65533;
open(GRP, ">$ctx->{nsswrap_group}");
print GRP "
users:x:100:
nobody:x:65533:
nogroup:x:65534:nobody
+$ctx->{unix_name}:x:$ctx->{unix_gid}:
";
close(GRP);
+ my $gid_rfc2307test = 65532;
+
+ my $hostname = lc($ctx->{hostname});
+ open(HOSTS, ">>$ctx->{nsswrap_hosts}");
+ print HOSTS "$ctx->{ipv4} ${hostname}.samba.example.com ${hostname}
+";
+ close(HOSTS);
my $configuration = "--configfile=$ctx->{smb_conf}";
PASSWORD => $ctx->{password},
LDAPDIR => $ctx->{ldapdir},
LDAP_INSTANCE => $ctx->{ldap_instance},
- WINBINDD_SOCKET_DIR => $ctx->{winbindd_socket_dir},
+ SELFTEST_WINBINDD_SOCKET_DIR => $ctx->{winbindd_socket_dir},
NCALRPCDIR => $ctx->{ncalrpcdir},
LOCKDIR => $ctx->{lockdir},
STATEDIR => $ctx->{statedir},
CACHEDIR => $ctx->{cachedir},
+ PRIVATEDIR => $ctx->{privatedir},
SERVERCONFFILE => $ctx->{smb_conf},
CONFIGURATION => $configuration,
SOCKET_WRAPPER_DEFAULT_IFACE => $ctx->{swiface},
NSS_WRAPPER_PASSWD => $ctx->{nsswrap_passwd},
NSS_WRAPPER_GROUP => $ctx->{nsswrap_group},
+ NSS_WRAPPER_HOSTS => $ctx->{nsswrap_hosts},
SAMBA_TEST_FIFO => "$ctx->{prefix}/samba_test.fifo",
SAMBA_TEST_LOG => "$ctx->{prefix}/samba_test.log",
SAMBA_TEST_LOG_POS => 0,
+ NSS_WRAPPER_MODULE_SO_PATH => Samba::nss_wrapper_winbind_so_path($self),
+ NSS_WRAPPER_MODULE_FN_PREFIX => "winbind",
+ LOCAL_PATH => $ctx->{share},
+ UID_RFC2307TEST => $uid_rfc2307test,
+ GID_RFC2307TEST => $gid_rfc2307test,
+ SERVER_ROLE => $ctx->{server_role}
};
return $ret;
{
my ($self, $prefix, $server_role, $hostname,
$domain, $realm, $functional_level,
- $swiface, $password, $kdc_ipv4, $extra_smbconf_options) = @_;
+ $password, $kdc_ipv4, $extra_smbconf_options, $extra_smbconf_shares,
+ $extra_provision_options) = @_;
my $ctx = $self->provision_raw_prepare($prefix, $server_role,
$hostname,
$domain, $realm, $functional_level,
- $swiface, $password, $kdc_ipv4);
+ $password, $kdc_ipv4);
+
+ if (defined($extra_provision_options)) {
+ push (@{$ctx->{provision_options}}, @{$extra_provision_options});
+ } else {
+ push (@{$ctx->{provision_options}}, "--use-ntvfs");
+ }
+
+ $ctx->{share} = "$ctx->{prefix_abs}/share";
+ push(@{$ctx->{directories}}, "$ctx->{share}");
+ push(@{$ctx->{directories}}, "$ctx->{share}/test1");
+ push(@{$ctx->{directories}}, "$ctx->{share}/test2");
+
+ # precreate directories for printer drivers
+ push(@{$ctx->{directories}}, "$ctx->{share}/W32X86");
+ push(@{$ctx->{directories}}, "$ctx->{share}/x64");
+ push(@{$ctx->{directories}}, "$ctx->{share}/WIN40");
- $ctx->{tmpdir} = "$ctx->{prefix_abs}/tmp";
- push(@{$ctx->{directories}}, "$ctx->{tmpdir}");
- push(@{$ctx->{directories}}, "$ctx->{tmpdir}/test1");
- push(@{$ctx->{directories}}, "$ctx->{tmpdir}/test2");
my $msdfs = "no";
$msdfs = "yes" if ($server_role eq "domain controller");
$ctx->{smb_conf_extra_options} = "
server max protocol = SMB2
host msdfs = $msdfs
lanman auth = yes
+ allow nt4 crypto = yes
$extra_smbconf_options
[tmp]
- path = $ctx->{tmpdir}
+ path = $ctx->{share}
read only = no
posix:sharedelay = 10000
posix:oplocktimeout = 3
- posix:writetimeupdatedelay = 500000
+ posix:writetimeupdatedelay = 50000
+
+[xcopy_share]
+ path = $ctx->{share}
+ read only = no
+ posix:sharedelay = 10000
+ posix:oplocktimeout = 3
+ posix:writetimeupdatedelay = 50000
+ create mask = 777
+ force create mode = 777
+
+[posix_share]
+ path = $ctx->{share}
+ read only = no
+ create mask = 0777
+ force create mode = 0
+ directory mask = 0777
+ force directory mode = 0
[test1]
- path = $ctx->{tmpdir}/test1
+ path = $ctx->{share}/test1
read only = no
posix:sharedelay = 10000
posix:oplocktimeout = 3
posix:writetimeupdatedelay = 50000
[test2]
- path = $ctx->{tmpdir}/test2
+ path = $ctx->{share}/test2
read only = no
posix:sharedelay = 10000
posix:oplocktimeout = 3
# Or the server tries s4u2self/s4u2proxy to impersonate the client
[simple]
- path = $ctx->{tmpdir}
+ path = $ctx->{share}
read only = no
ntvfs handler = simple
[sysvol]
path = $ctx->{statedir}/sysvol
- read only = yes
+ read only = no
[netlogon]
path = $ctx->{statedir}/sysvol/$ctx->{dnsname}/scripts
[cifsposix]
copy = simple
ntvfs handler = cifsposix
+
+$extra_smbconf_shares
";
if (defined($self->{ldap})) {
$ldap_uri =~ s|/|%2F|g;
$ldap_uri = "ldapi://$ldap_uri";
$ctx->{ldap_uri} = $ldap_uri;
- if ($self->{ldap} eq "fedora-ds") {
- $ctx->{sid_generator} = "backend";
- }
$ctx->{ldap_instance} = lc($ctx->{netbiosname});
}
return $self->provision_raw_step2($ctx, $ret);
}
-sub provision_member($$$)
+sub provision_s4member($$$)
{
my ($self, $prefix, $dcvars) = @_;
print "PROVISIONING MEMBER...";
"SAMBADOMAIN",
"samba.example.com",
"2008",
- 23,
"locMEMpass3",
$dcvars->{SERVER_IP},
- "");
+ "", "", undef);
unless ($ret) {
return undef;
}
$cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
$cmd .= "$samba_tool domain join $ret->{CONFIGURATION} $dcvars->{REALM} member";
$cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
+ $cmd .= " --machinepass=machine$ret->{PASSWORD}";
unless (system($cmd) == 0) {
warn("Join failed\n$cmd");
"SAMBADOMAIN",
"samba.example.com",
"2008",
- 24,
"locRPCproxypass4",
$dcvars->{SERVER_IP},
- $extra_smbconf_options);
+ $extra_smbconf_options, "", undef);
unless ($ret) {
return undef;
$cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
$cmd .= "$samba_tool domain join $ret->{CONFIGURATION} $dcvars->{REALM} member";
$cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
+ $cmd .= " --machinepass=machine$ret->{PASSWORD}";
unless (system($cmd) == 0) {
warn("Join failed\n$cmd");
$cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$dcvars->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
$cmd .= "KRB5_CONFIG=\"$dcvars->{KRB5_CONFIG}\" ";
$cmd .= "$samba_tool delegation for-any-protocol '$ret->{NETBIOSNAME}\$' on";
- $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD} $dcvars->{CONFIGURATION}";
+ $cmd .= " $dcvars->{CONFIGURATION}";
+ print $cmd;
unless (system($cmd) == 0) {
warn("Delegation failed\n$cmd");
$cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$dcvars->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
$cmd .= "KRB5_CONFIG=\"$dcvars->{KRB5_CONFIG}\" ";
$cmd .= "$samba_tool delegation add-service '$ret->{NETBIOSNAME}\$' cifs/$dcvars->{SERVER}";
- $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD} $dcvars->{CONFIGURATION}";
+ $cmd .= " $dcvars->{CONFIGURATION}";
unless (system($cmd) == 0) {
warn("Delegation failed\n$cmd");
return $ret;
}
+sub provision_promoted_dc($$$)
+{
+ my ($self, $prefix, $dcvars) = @_;
+ print "PROVISIONING VAMPIRE DC...";
+
+ # We do this so that we don't run the provision. That's the job of 'net vampire'.
+ my $ctx = $self->provision_raw_prepare($prefix, "domain controller",
+ "promotedvdc",
+ "SAMBADOMAIN",
+ "samba.example.com",
+ "2008",
+ $dcvars->{PASSWORD},
+ $dcvars->{SERVER_IP});
+
+ push (@{$ctx->{provision_options}}, "--use-ntvfs");
+
+ $ctx->{smb_conf_extra_options} = "
+ max xmit = 32K
+ server max protocol = SMB2
+
+[sysvol]
+ path = $ctx->{statedir}/sysvol
+ read only = yes
+
+[netlogon]
+ path = $ctx->{statedir}/sysvol/$ctx->{dnsname}/scripts
+ read only = no
+
+";
+
+ my $ret = $self->provision_raw_step1($ctx);
+ unless ($ret) {
+ return undef;
+ }
+
+ my $samba_tool = Samba::bindir_path($self, "samba-tool");
+ my $cmd = "";
+ $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
+ $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
+ $cmd .= "$samba_tool domain join $ret->{CONFIGURATION} $dcvars->{REALM} MEMBER --realm=$dcvars->{REALM}";
+ $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
+ $cmd .= " --machinepass=machine$ret->{PASSWORD}";
+
+ unless (system($cmd) == 0) {
+ warn("Join failed\n$cmd");
+ return undef;
+ }
+
+ my $samba_tool = Samba::bindir_path($self, "samba-tool");
+ my $cmd = "";
+ $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
+ $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
+ $cmd .= "$samba_tool domain dcpromo $ret->{CONFIGURATION} $dcvars->{REALM} DC --realm=$dcvars->{REALM}";
+ $cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
+ $cmd .= " --machinepass=machine$ret->{PASSWORD} --use-ntvfs --dns-backend=BIND9_DLZ";
+
+ unless (system($cmd) == 0) {
+ warn("Join failed\n$cmd");
+ return undef;
+ }
+
+ $ret->{PROMOTED_DC_SERVER} = $ret->{SERVER};
+ $ret->{PROMOTED_DC_SERVER_IP} = $ret->{SERVER_IP};
+ $ret->{PROMOTED_DC_NETBIOSNAME} = $ret->{NETBIOSNAME};
+
+ $ret->{DC_SERVER} = $dcvars->{DC_SERVER};
+ $ret->{DC_SERVER_IP} = $dcvars->{DC_SERVER_IP};
+ $ret->{DC_NETBIOSNAME} = $dcvars->{DC_NETBIOSNAME};
+ $ret->{DC_USERNAME} = $dcvars->{DC_USERNAME};
+ $ret->{DC_PASSWORD} = $dcvars->{DC_PASSWORD};
+
+ return $ret;
+}
+
sub provision_vampire_dc($$$)
{
my ($self, $prefix, $dcvars) = @_;
"SAMBADOMAIN",
"samba.example.com",
"2008",
- 22, $dcvars->{PASSWORD},
+ $dcvars->{PASSWORD},
$dcvars->{SERVER_IP});
+ push (@{$ctx->{provision_options}}, "--use-ntvfs");
+
$ctx->{smb_conf_extra_options} = "
max xmit = 32K
server max protocol = SMB2
$cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
$cmd .= "$samba_tool domain join $ret->{CONFIGURATION} $dcvars->{REALM} DC --realm=$dcvars->{REALM}";
$cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD} --domain-critical-only";
+ $cmd .= " --machinepass=machine$ret->{PASSWORD} --use-ntvfs";
unless (system($cmd) == 0) {
warn("Join failed\n$cmd");
return $ret;
}
+sub provision_subdom_dc($$$)
+{
+ my ($self, $prefix, $dcvars) = @_;
+ print "PROVISIONING SUBDOMAIN DC...";
+
+ # We do this so that we don't run the provision. That's the job of 'net vampire'.
+ my $ctx = $self->provision_raw_prepare($prefix, "domain controller",
+ "localsubdc",
+ "SAMBASUBDOM",
+ "sub.samba.example.com",
+ "2008",
+ $dcvars->{PASSWORD},
+ undef);
+
+ push (@{$ctx->{provision_options}}, "--use-ntvfs");
+
+ $ctx->{smb_conf_extra_options} = "
+ max xmit = 32K
+ server max protocol = SMB2
+
+[sysvol]
+ path = $ctx->{statedir}/sysvol
+ read only = yes
+
+[netlogon]
+ path = $ctx->{statedir}/sysvol/$ctx->{dnsname}/scripts
+ read only = no
+
+";
+
+ my $ret = $self->provision_raw_step1($ctx);
+ unless ($ret) {
+ return undef;
+ }
+
+ my $dc_realms = Samba::mk_realms_stanza($dcvars->{REALM}, lc($dcvars->{REALM}),
+ $dcvars->{DOMAIN}, $dcvars->{SERVER_IP});
+ Samba::mk_krb5_conf($ctx, $dc_realms);
+
+ my $samba_tool = Samba::bindir_path($self, "samba-tool");
+ my $cmd = "";
+ $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
+ $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
+ $cmd .= "$samba_tool domain join $ret->{CONFIGURATION} $ctx->{realm} subdomain ";
+ $cmd .= "--parent-domain=$dcvars->{REALM} -U$dcvars->{DC_USERNAME}\@$dcvars->{REALM}\%$dcvars->{DC_PASSWORD}";
+ $cmd .= " --machinepass=machine$ret->{PASSWORD} --use-ntvfs";
+
+ unless (system($cmd) == 0) {
+ warn("Join failed\n$cmd");
+ return undef;
+ }
+
+ $ret->{SUBDOM_DC_SERVER} = $ret->{SERVER};
+ $ret->{SUBDOM_DC_SERVER_IP} = $ret->{SERVER_IP};
+ $ret->{SUBDOM_DC_NETBIOSNAME} = $ret->{NETBIOSNAME};
+
+ $ret->{DC_SERVER} = $dcvars->{DC_SERVER};
+ $ret->{DC_SERVER_IP} = $dcvars->{DC_SERVER_IP};
+ $ret->{DC_NETBIOSNAME} = $dcvars->{DC_NETBIOSNAME};
+ $ret->{DC_USERNAME} = $dcvars->{DC_USERNAME};
+ $ret->{DC_PASSWORD} = $dcvars->{DC_PASSWORD};
+
+ return $ret;
+}
+
sub provision_dc($$)
{
my ($self, $prefix) = @_;
print "PROVISIONING DC...";
+ my $extra_conf_options = "netbios aliases = localDC1-a";
my $ret = $self->provision($prefix,
"domain controller",
"localdc",
"SAMBADOMAIN",
"samba.example.com",
"2008",
- 21,
"locDCpass1",
- undef, "netbios aliases = DC1");
+ undef, $extra_conf_options, "", undef);
return undef unless(defined $ret);
unless($self->add_wins_config("$prefix/private")) {
warn("Unable to add wins configuration");
return undef;
}
-
- $ret->{NETBIOSALIAS} = "DC1";
+ $ret->{NETBIOSALIAS} = "localdc1-a";
$ret->{DC_SERVER} = $ret->{SERVER};
$ret->{DC_SERVER_IP} = $ret->{SERVER_IP};
$ret->{DC_NETBIOSNAME} = $ret->{NETBIOSNAME};
"SAMBA2000",
"samba2000.example.com",
"2000",
- 25,
"locDCpass5",
- undef, "");
+ undef, "", "", undef);
unless($self->add_wins_config("$prefix/private")) {
warn("Unable to add wins configuration");
"SAMBA2003",
"samba2003.example.com",
"2003",
- 26,
"locDCpass6",
- undef, "");
+ undef, "allow dns updates = nonsecure and secure", "", undef);
+
+ unless (defined $ret) {
+ return undef;
+ }
+
+ $ret->{DC_SERVER} = $ret->{SERVER};
+ $ret->{DC_SERVER_IP} = $ret->{SERVER_IP};
+ $ret->{DC_NETBIOSNAME} = $ret->{NETBIOSNAME};
+ $ret->{DC_USERNAME} = $ret->{USERNAME};
+ $ret->{DC_PASSWORD} = $ret->{PASSWORD};
+
+ my @samba_tool_options;
+ push (@samba_tool_options, Samba::bindir_path($self, "samba-tool"));
+ push (@samba_tool_options, "domain");
+ push (@samba_tool_options, "passwordsettings");
+ push (@samba_tool_options, "set");
+ push (@samba_tool_options, "--configfile=$ret->{SERVERCONFFILE}");
+ push (@samba_tool_options, "--min-pwd-age=0");
+ push (@samba_tool_options, "--history-length=1");
+
+ my $samba_tool_cmd = join(" ", @samba_tool_options);
+
+ unless (system($samba_tool_cmd) == 0) {
+ warn("Unable to set min password age to 0: \n$samba_tool_cmd\n");
+ return undef;
+ }
+
+ return $ret;
unless($self->add_wins_config("$prefix/private")) {
warn("Unable to add wins configuration");
"SAMBA2008R2",
"samba2008R2.example.com",
"2008_R2",
- 27,
"locDCpass7",
- undef, "");
+ undef, "", "", undef);
unless ($self->add_wins_config("$prefix/private")) {
warn("Unable to add wins configuration");
"SAMBADOMAIN",
"samba.example.com",
"2008",
- 28, $dcvars->{PASSWORD},
+ $dcvars->{PASSWORD},
$dcvars->{SERVER_IP});
unless ($ctx) {
return undef;
}
- $ctx->{tmpdir} = "$ctx->{prefix_abs}/tmp";
- push(@{$ctx->{directories}}, "$ctx->{tmpdir}");
+ push (@{$ctx->{provision_options}}, "--use-ntvfs");
+
+ $ctx->{share} = "$ctx->{prefix_abs}/share";
+ push(@{$ctx->{directories}}, "$ctx->{share}");
$ctx->{smb_conf_extra_options} = "
max xmit = 32K
read only = yes
[tmp]
- path = $ctx->{tmpdir}
+ path = $ctx->{share}
read only = no
posix:sharedelay = 10000
posix:oplocktimeout = 3
- posix:writetimeupdatedelay = 500000
+ posix:writetimeupdatedelay = 50000
";
$cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
$cmd .= "$samba_tool domain join $ret->{CONFIGURATION} $dcvars->{REALM} RODC";
$cmd .= " -U$dcvars->{DC_USERNAME}\%$dcvars->{DC_PASSWORD}";
- $cmd .= " --server=$dcvars->{DC_SERVER}";
+ $cmd .= " --server=$dcvars->{DC_SERVER} --use-ntvfs";
unless (system($cmd) == 0) {
warn("RODC join failed\n$cmd");
{
my ($self, $prefix) = @_;
+ my $prefix_abs = abs_path($prefix);
+
+ my $bindir_abs = abs_path($self->{bindir});
+ my $lockdir="$prefix_abs/lockdir";
+ my $conffile="$prefix_abs/etc/smb.conf";
+
my $extra_smbconf_options = "
-server services = -smb
+ server services = -smb +s3fs
+ xattr_tdb:file = $prefix_abs/statedir/xattr.tdb
+
+ dbwrap_tdb_mutexes:* = yes
+
+ kernel oplocks = no
+ kernel change notify = no
+
+ syslog = no
+ printing = bsd
+ printcap name = /dev/null
+
+ max protocol = SMB3
+ read only = no
+ server signing = auto
+
+ smbd:sharedelay = 100000
+ smbd:writetimeupdatedelay = 500000
+ create mask = 755
+ dos filemode = yes
+
+ dcerpc endpoint servers = -winreg -srvsvc
+
+ printcap name = /dev/null
+
+ addprinter command = $ENV{SRCDIR_ABS}/source3/script/tests/printing/modprinter.pl -a -s $conffile --
+ deleteprinter command = $ENV{SRCDIR_ABS}/source3/script/tests/printing/modprinter.pl -d -s $conffile --
+
+ printing = vlp
+ print command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb print %p %s
+ lpq command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpq %p
+ lp rm command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lprm %p %j
+ lp pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lppause %p %j
+ lp resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb lpresume %p %j
+ queue pause command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queuepause %p
+ queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
+ lpq cache time = 0
+ print notify backchannel = yes
+
+";
+
+ my $extra_smbconf_shares = "
+
+[tmpenc]
+ copy = tmp
+ smb encrypt = required
+
+[tmpcase]
+ copy = tmp
+ case sensitive = yes
+
+[tmpguest]
+ copy = tmp
+ guest ok = yes
+
+[hideunread]
+ copy = tmp
+ hide unreadable = yes
+
+[durable]
+ copy = tmp
+ kernel share modes = no
+ kernel oplocks = no
+ posix locking = no
+
+[print\$]
+ copy = tmp
+
+[print1]
+ copy = tmp
+ printable = yes
+
+[print2]
+ copy = print1
+[print3]
+ copy = print1
+[lp]
+ copy = print1
";
print "PROVISIONING PLUGIN S4 DC...";
"domain controller",
"plugindc",
"PLUGINDOMAIN",
- "plugin.samba.example.com",
+ "plugindc.samba.example.com",
"2008",
- 30,
"locDCpass1",
- undef, $extra_smbconf_options);
+ undef, $extra_smbconf_options,
+ $extra_smbconf_shares, undef);
return undef unless(defined $ret);
unless($self->add_wins_config("$prefix/private")) {
return $ret;
}
+sub provision_chgdcpass($$)
+{
+ my ($self, $prefix) = @_;
+
+ print "PROVISIONING CHGDCPASS...";
+ my $extra_provision_options = undef;
+ push (@{$extra_provision_options}, "--dns-backend=BIND9_DLZ");
+ my $ret = $self->provision($prefix,
+ "domain controller",
+ "chgdcpass",
+ "CHDCDOMAIN",
+ "chgdcpassword.samba.example.com",
+ "2008",
+ "chgDCpass1",
+ undef, "", "",
+ $extra_provision_options);
+
+ return undef unless(defined $ret);
+ unless($self->add_wins_config("$prefix/private")) {
+ warn("Unable to add wins configuration");
+ return undef;
+ }
+
+ # Remove secrets.tdb from this environment to test that we still start up
+ # on systems without the new matching secrets.tdb records
+ unless (unlink("$ret->{PRIVATEDIR}/secrets.tdb") || unlink("$ret->{PRIVATEDIR}/secrets.ntdb")) {
+ warn("Unable to remove $ret->{PRIVATEDIR}/secrets.tdb added during provision");
+ return undef;
+ }
+
+ $ret->{DC_SERVER} = $ret->{SERVER};
+ $ret->{DC_SERVER_IP} = $ret->{SERVER_IP};
+ $ret->{DC_NETBIOSNAME} = $ret->{NETBIOSNAME};
+ $ret->{DC_USERNAME} = $ret->{USERNAME};
+ $ret->{DC_PASSWORD} = $ret->{PASSWORD};
+
+ return $ret;
+}
+
sub teardown_env($$)
{
my ($self, $envvars) = @_;
my $pid;
- close(DATA);
+ # This should cause samba to terminate gracefully
+ close($envvars->{STDIN_PIPE});
- if (open(IN, "<$envvars->{PIDDIR}/samba.pid")) {
- $pid = <IN>;
- close(IN);
+ $pid = $envvars->{SAMBA_PID};
+ my $count = 0;
+ my $childpid;
+
+ # This should give it time to write out the gcov data
+ until ($count > 30) {
+ if (Samba::cleanup_child($pid, "samba") == -1) {
+ last;
+ }
+ sleep(1);
+ $count++;
+ }
- # Give the process 20 seconds to exit. gcov needs
- # this time to write out the covarge data
- my $count = 0;
- until (kill(0, $pid) == 0) {
- # if no process sucessfully signalled, then we are done
- sleep(1);
- $count++;
- last if $count > 20;
- }
+ if ($count > 30 || kill(0, $pid)) {
+ kill "TERM", $pid;
- # If it is still around, kill it
- if ($count > 20) {
- print "server process $pid took more than $count seconds to exit, killing\n";
- kill 9, $pid;
+ until ($count > 40) {
+ if (Samba::cleanup_child($pid, "samba") == -1) {
+ last;
}
+ sleep(1);
+ $count++;
+ }
+ # If it is still around, kill it
+ warn "server process $pid took more than $count seconds to exit, killing\n";
+ kill 9, $pid;
}
- my $failed = $? >> 8;
-
$self->slapd_stop($envvars) if ($self->{ldap});
print $self->getlog_env($envvars);
- return $failed;
+ return;
}
sub getlog_env($$)
{
my ($self, $envvars) = @_;
- return (-p $envvars->{SAMBA_TEST_FIFO});
+ my $childpid = Samba::cleanup_child($envvars->{SAMBA_PID}, "samba");
+
+ return ($childpid == 0);
}
sub setup_env($$$)
$ENV{ENVNAME} = $envname;
+ if (defined($self->{vars}->{$envname})) {
+ return $self->{vars}->{$envname};
+ }
+
if ($envname eq "dc") {
return $self->setup_dc("$path/dc");
} elsif ($envname eq "fl2000dc") {
$self->setup_dc("$path/dc");
}
return $self->setup_vampire_dc("$path/vampire_dc", $self->{vars}->{dc});
+ } elsif ($envname eq "promoted_dc") {
+ if (not defined($self->{vars}->{dc})) {
+ $self->setup_dc("$path/dc");
+ }
+ return $self->setup_promoted_dc("$path/promoted_dc", $self->{vars}->{dc});
+ } elsif ($envname eq "subdom_dc") {
+ if (not defined($self->{vars}->{dc})) {
+ $self->setup_dc("$path/dc");
+ }
+ return $self->setup_subdom_dc("$path/subdom_dc", $self->{vars}->{dc});
} elsif ($envname eq "s4member") {
if (not defined($self->{vars}->{dc})) {
$self->setup_dc("$path/dc");
}
- return $self->setup_member("$path/s4member", $self->{vars}->{dc});
+ return $self->setup_s4member("$path/s4member", $self->{vars}->{dc});
} elsif ($envname eq "rodc") {
if (not defined($self->{vars}->{dc})) {
$self->setup_dc("$path/dc");
}
return $self->setup_rodc("$path/rodc", $self->{vars}->{dc});
+ } elsif ($envname eq "chgdcpass") {
+ return $self->setup_chgdcpass("$path/chgdcpass", $self->{vars}->{chgdcpass});
} elsif ($envname eq "s3member") {
if (not defined($self->{vars}->{dc})) {
$self->setup_dc("$path/dc");
return $target3->setup_admember("$path/s3member", $self->{vars}->{dc}, 29);
} elsif ($envname eq "plugin_s4_dc") {
return $self->setup_plugin_s4_dc("$path/plugin_s4_dc");
- } elsif ($envname eq "all") {
+ } elsif ($envname eq "s3member_rfc2307") {
if (not defined($self->{vars}->{dc})) {
- $ENV{ENVNAME} = "dc";
$self->setup_dc("$path/dc");
}
- my $ret = $self->setup_member("$path/s4member", $self->{vars}->{dc});
- if (not defined($self->{vars}->{rpc_proxy})) {
- $ENV{ENVNAME} = "rpc_proxy";
- my $rpc_proxy_ret = $self->setup_rpc_proxy("$path/rpc_proxy", $self->{vars}->{dc});
-
- $ret->{RPC_PROXY_SERVER} = $rpc_proxy_ret->{SERVER};
- $ret->{RPC_PROXY_SERVER_IP} = $rpc_proxy_ret->{SERVER_IP};
- $ret->{RPC_PROXY_NETBIOSNAME} = $rpc_proxy_ret->{NETBIOSNAME};
- $ret->{RPC_PROXY_USERNAME} = $rpc_proxy_ret->{USERNAME};
- $ret->{RPC_PROXY_PASSWORD} = $rpc_proxy_ret->{PASSWORD};
- }
- if (not defined($self->{vars}->{fl2000dc})) {
- $ENV{ENVNAME} = "fl2000dc";
- my $fl2000dc_ret = $self->setup_fl2000dc("$path/fl2000dc", $self->{vars}->{dc});
-
- $ret->{FL2000DC_SERVER} = $fl2000dc_ret->{SERVER};
- $ret->{FL2000DC_SERVER_IP} = $fl2000dc_ret->{SERVER_IP};
- $ret->{FL2000DC_NETBIOSNAME} = $fl2000dc_ret->{NETBIOSNAME};
- $ret->{FL2000DC_USERNAME} = $fl2000dc_ret->{USERNAME};
- $ret->{FL2000DC_PASSWORD} = $fl2000dc_ret->{PASSWORD};
- }
- if (not defined($self->{vars}->{fl2003dc})) {
- $ENV{ENVNAME} = "fl2003dc";
- my $fl2003dc_ret = $self->setup_fl2003dc("$path/fl2003dc", $self->{vars}->{dc});
-
- $ret->{FL2003DC_SERVER} = $fl2003dc_ret->{SERVER};
- $ret->{FL2003DC_SERVER_IP} = $fl2003dc_ret->{SERVER_IP};
- $ret->{FL2003DC_NETBIOSNAME} = $fl2003dc_ret->{NETBIOSNAME};
- $ret->{FL2003DC_USERNAME} = $fl2003dc_ret->{USERNAME};
- $ret->{FL2003DC_PASSWORD} = $fl2003dc_ret->{PASSWORD};
- }
- if (not defined($self->{vars}->{fl2008r2dc})) {
- $ENV{ENVNAME} = "fl2008r2dc";
- my $fl2008r2dc_ret = $self->setup_fl2008r2dc("$path/fl2008r2dc", $self->{vars}->{dc});
-
- $ret->{FL2008R2DC_SERVER} = $fl2008r2dc_ret->{SERVER};
- $ret->{FL2008R2DC_SERVER_IP} = $fl2008r2dc_ret->{SERVER_IP};
- $ret->{FL2008R2DC_NETBIOSNAME} = $fl2008r2dc_ret->{NETBIOSNAME};
- $ret->{FL2008R2DC_USERNAME} = $fl2008r2dc_ret->{USERNAME};
- $ret->{FL2008R2DC_PASSWORD} = $fl2008r2dc_ret->{PASSWORD};
- }
- if (not defined($self->{vars}->{s3member})) {
- $ENV{ENVNAME} = "s3member";
- my $s3member_ret = $target3->setup_admember("$path/s3member", $self->{vars}->{dc}, 29);
- $self->{vars}->{s3member} = $s3member_ret;
-
- $ret->{S3MEMBER_SERVER} = $s3member_ret->{SERVER};
- $ret->{S3MEMBER_SERVER_IP} = $s3member_ret->{SERVER_IP};
- $ret->{S3MEMBER_NETBIOSNAME} = $s3member_ret->{NETBIOSNAME};
- $ret->{S3MEMBER_NETBIOSALIAS} = $s3member_ret->{NETBIOSALIAS};
- $ret->{S3MEMBER_USERNAME} = $s3member_ret->{USERNAME};
- $ret->{S3MEMBER_PASSWORD} = $s3member_ret->{PASSWORD};
- }
- return $ret;
+ return $target3->setup_admember_rfc2307("$path/s3member_rfc2307",
+ $self->{vars}->{dc}, 34);
} else {
- return undef;
+ return "UNKNOWN";
}
}
-sub setup_member($$$)
+sub setup_s4member($$$)
{
my ($self, $path, $dc_vars) = @_;
- my $env = $self->provision_member($path, $dc_vars);
+ my $env = $self->provision_s4member($path, $dc_vars);
if (defined $env) {
$self->check_or_start($env, "single");
$self->wait_for_start($env);
- $self->{vars}->{member} = $env;
+ $self->{vars}->{s4member} = $env;
}
return $env;
return $env;
}
+sub setup_chgdcpass($$)
+{
+ my ($self, $path) = @_;
+
+ my $env = $self->provision_chgdcpass($path);
+ if (defined $env) {
+ $self->check_or_start($env, "single");
+
+ $self->wait_for_start($env);
+
+ $self->{vars}->{chgdcpass} = $env;
+ }
+ return $env;
+}
+
sub setup_fl2000dc($$)
{
my ($self, $path) = @_;
my $base_dn = "DC=".join(",DC=", split(/\./, $dc_vars->{REALM}));
$cmd = "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
$cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
- $cmd .= " $samba_tool drs replicate $env->{DC_SERVER} $env->{VAMPIRE_DC_SERVER}";
+ $cmd .= " $samba_tool drs replicate $env->{DC_SERVER} $env->{SERVER}";
$cmd .= " $dc_vars->{CONFIGURATION}";
$cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD}";
# replicate Configuration NC
return $env;
}
+sub setup_promoted_dc($$$)
+{
+ my ($self, $path, $dc_vars) = @_;
+
+ my $env = $self->provision_promoted_dc($path, $dc_vars);
+
+ if (defined $env) {
+ $self->check_or_start($env, "single");
+
+ $self->wait_for_start($env);
+
+ $self->{vars}->{promoted_dc} = $env;
+
+ # force replicated DC to update repsTo/repsFrom
+ # for vampired partitions
+ my $samba_tool = Samba::bindir_path($self, "samba-tool");
+ my $cmd = "";
+ $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
+ $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
+ $cmd .= " $samba_tool drs kcc $env->{DC_SERVER}";
+ $cmd .= " $env->{CONFIGURATION}";
+ $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD}";
+ unless (system($cmd) == 0) {
+ warn("Failed to exec kcc\n$cmd");
+ return undef;
+ }
+
+ # as 'vampired' dc may add data in its local replica
+ # we need to synchronize data between DCs
+ my $base_dn = "DC=".join(",DC=", split(/\./, $dc_vars->{REALM}));
+ $cmd = "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
+ $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
+ $cmd .= " $samba_tool drs replicate $env->{DC_SERVER} $env->{SERVER}";
+ $cmd .= " $dc_vars->{CONFIGURATION}";
+ $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD}";
+ # replicate Configuration NC
+ my $cmd_repl = "$cmd \"CN=Configuration,$base_dn\"";
+ unless(system($cmd_repl) == 0) {
+ warn("Failed to replicate\n$cmd_repl");
+ return undef;
+ }
+ # replicate Default NC
+ $cmd_repl = "$cmd \"$base_dn\"";
+ unless(system($cmd_repl) == 0) {
+ warn("Failed to replicate\n$cmd_repl");
+ return undef;
+ }
+ }
+
+ return $env;
+}
+
+sub setup_subdom_dc($$$)
+{
+ my ($self, $path, $dc_vars) = @_;
+
+ my $env = $self->provision_subdom_dc($path, $dc_vars);
+
+ if (defined $env) {
+ $self->check_or_start($env, "single");
+
+ $self->wait_for_start($env);
+
+ $self->{vars}->{subdom_dc} = $env;
+
+ # force replicated DC to update repsTo/repsFrom
+ # for primary domain partitions
+ my $samba_tool = Samba::bindir_path($self, "samba-tool");
+ my $cmd = "";
+ $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
+ $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
+ $cmd .= " $samba_tool drs kcc $env->{DC_SERVER}";
+ $cmd .= " $env->{CONFIGURATION}";
+ $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD} --realm=$dc_vars->{DC_REALM}";
+ unless (system($cmd) == 0) {
+ warn("Failed to exec kcc\n$cmd");
+ return undef;
+ }
+
+ # as 'subdomain' dc may add data in its local replica
+ # we need to synchronize data between DCs
+ my $base_dn = "DC=".join(",DC=", split(/\./, $env->{REALM}));
+ my $config_dn = "CN=Configuration,DC=".join(",DC=", split(/\./, $dc_vars->{REALM}));
+ $cmd = "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
+ $cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";
+ $cmd .= " $samba_tool drs replicate $env->{DC_SERVER} $env->{SUBDOM_DC_SERVER}";
+ $cmd .= " $dc_vars->{CONFIGURATION}";
+ $cmd .= " -U$dc_vars->{DC_USERNAME}\%$dc_vars->{DC_PASSWORD} --realm=$dc_vars->{DC_REALM}";
+ # replicate Configuration NC
+ my $cmd_repl = "$cmd \"$config_dn\"";
+ unless(system($cmd_repl) == 0) {
+ warn("Failed to replicate\n$cmd_repl");
+ return undef;
+ }
+ # replicate Default NC
+ $cmd_repl = "$cmd \"$base_dn\"";
+ unless(system($cmd_repl) == 0) {
+ warn("Failed to replicate\n$cmd_repl");
+ return undef;
+ }
+ }
+
+ return $env;
+}
+
sub setup_rodc($$$)
{
my ($self, $path, $dc_vars) = @_;
{
my ($self, $path) = @_;
- my $env = $self->provision_plugin_s4_dc($path);
- if (defined $env) {
- $self->check_or_start($env, "single");
-
- $self->wait_for_start($env);
-
- my $s3_part_env = $self->{target3}->setup_plugin_s4_dc($path, $env, 30);
- if (not defined($s3_part_env)) {
- return undef;
- }
+ # If we didn't build with ADS, pretend this env was never available
+ if (not $self->{target3}->have_ads()) {
+ return "UNKNOWN";
+ }
- $self->{vars}->{plugin_s4_dc} = $s3_part_env;
+ my $env = $self->provision_plugin_s4_dc($path);
+ unless ($env) {
+ return undef;
}
+
+ $self->check_or_start($env, "single");
+
+ $self->wait_for_start($env);
+
+ $self->{vars}->{plugin_s4_dc} = $env;
return $env;
}