summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wintest/conf/abartlet.conf3
-rw-r--r--wintest/conf/tridge.conf1
-rwxr-xr-xwintest/test-s4-howto.py64
-rw-r--r--wintest/wintest.py19
4 files changed, 53 insertions, 34 deletions
diff --git a/wintest/conf/abartlet.conf b/wintest/conf/abartlet.conf
index b632c6e027..3fa4501739 100644
--- a/wintest/conf/abartlet.conf
+++ b/wintest/conf/abartlet.conf
@@ -19,7 +19,8 @@ INTERFACE : virbr0:0
# this is an additional IP that will be used for named to listen
# on. It should not be the primary IP of the interface
INTERFACE_IP : 192.168.122.2
-INTERFACE_NET : 192.168.122.2/24
+INTERFACE_IPV6 : 3ffe:ffff:0:f101::3
+INTERFACE_NET : 192.168.122.2/24
# how to run bind9
BIND9 : /usr/sbin/named
diff --git a/wintest/conf/tridge.conf b/wintest/conf/tridge.conf
index 1c7ed0bda7..a2bad630a2 100644
--- a/wintest/conf/tridge.conf
+++ b/wintest/conf/tridge.conf
@@ -19,6 +19,7 @@ INTERFACE : virbr0:0
# this is an additional IP that will be used for named to listen
# on. It should not be the primary IP of the interface
INTERFACE_IP : 10.0.0.2
+INTERFACE_IPV6 : 3ffe:ffff:0:f101::3
INTERFACE_NET : 10.0.0.2/24
# how to run bind9
diff --git a/wintest/test-s4-howto.py b/wintest/test-s4-howto.py
index ef4f75d761..d12968c50f 100755
--- a/wintest/test-s4-howto.py
+++ b/wintest/test-s4-howto.py
@@ -4,7 +4,7 @@
import sys, os
import optparse
-import wintest
+import wintest, pexpect
def check_prerequesites(t):
t.info("Checking prerequesites")
@@ -13,6 +13,8 @@ def check_prerequesites(t):
raise Exception("You must run this script as root")
t.putenv("KRB5_CONFIG", '${PREFIX}/private/krb5.conf')
t.run_cmd('ifconfig ${INTERFACE} ${INTERFACE_NET} up')
+ t.run_cmd('ifconfig ${INTERFACE} inet6 del ${INTERFACE_IPV6}/64', checkfail=False)
+ t.run_cmd('ifconfig ${INTERFACE} inet6 add ${INTERFACE_IPV6}/64 up')
def build_s4(t):
@@ -33,8 +35,8 @@ def provision_s4(t, func_level="2008"):
t.del_files(["var", "private"])
t.run_cmd("rm -f etc/smb.conf")
options=' --function-level=%s -d${DEBUGLEVEL}' % func_level
- options += ' --option=interfaces=${INTERFACE}'
- options += ' --host-ip=${INTERFACE_IP} --host-ip6="::"'
+ options += ' --option=interfaces="${INTERFACE} ${INTERFACE_IPV6}"'
+ options += ' --host-ip=${INTERFACE_IP} --host-ip6=${INTERFACE_IPV6}'
options += ' --option=bindinterfacesonly=yes'
t.run_cmd('sbin/provision --realm=${LCREALM} --domain=${DOMAIN} --adminpass=${PASSWORD1} --server-role="domain controller"' + options)
t.run_cmd('bin/samba-tool newuser testallowed ${PASSWORD1}')
@@ -88,16 +90,21 @@ def create_shares(t):
def set_nameserver(t, nameserver):
'''set the nameserver in resolv.conf'''
- if not getattr(t, 'resolv_conf_backup', False):
- t.run_cmd("mv -f /etc/resolv.conf /etc/resolv.conf.wintest-bak")
- t.write_file("/etc/resolv.conf", '''
+ t.write_file("/etc/resolv.conf.wintest", '''
# Generated by wintest, the Samba v Windows automated testing system
nameserver %s
# your original resolv.conf appears below:
''' % t.substitute(nameserver))
- t.run_cmd('cat /etc/resolv.conf.wintest-bak >> /etc/resolv.conf')
+ child = t.pexpect_spawn("cat /etc/resolv.conf", crlf=False)
+ i = child.expect(['your original resolv.conf appears below:', pexpect.EOF])
+ if i == 0:
+ child.expect(pexpect.EOF)
+ contents = child.before.replace('\r', '')
+ t.write_file('/etc/resolv.conf.wintest', contents, mode='a')
+ t.write_file('/etc/resolv.conf.wintest-bak', contents)
+ t.run_cmd("mv -f /etc/resolv.conf.wintest /etc/resolv.conf")
t.resolv_conf_backup = '/etc/resolv.conf.wintest-bak';
@@ -123,21 +130,24 @@ def restart_bind(t):
nameserver = t.get_nameserver()
if nameserver == t.getvar('INTERFACE_IP'):
- raise RuntimeError("old /etc/resolv.conf must not contain %s as a nameserver, this will create loops with the generated dns configuration")
+ raise RuntimeError("old /etc/resolv.conf must not contain %s as a nameserver, this will create loops with the generated dns configuration" % nameserver)
t.setvar('DNSSERVER', nameserver)
t.write_file("etc/named.conf", '''
options {
- listen-on port 53 { ${INTERFACE_IP}; };
+ listen-on port 53 { ${INTERFACE_IP}; };
+ listen-on-v6 port 53 { ${INTERFACE_IPV6}; };
directory "${PREFIX}/var/named";
dump-file "${PREFIX}/var/named/data/cache_dump.db";
pid-file "${PREFIX}/var/named/named.pid";
statistics-file "${PREFIX}/var/named/data/named_stats.txt";
memstatistics-file "${PREFIX}/var/named/data/named_mem_stats.txt";
- allow-query { ${INTERFACE_NET}; 127.0.0.0/8; };
+ allow-query { any; };
recursion yes;
- tkey-gssapi-credential "DNS/${LCREALM}";
+ tkey-gssapi-credential "DNS/${HOSTNAME}.${LCREALM}";
tkey-domain "${REALM}";
+ max-cache-ttl 10;
+ max-ncache-ttl 10;
forward only;
forwarders {
@@ -153,7 +163,7 @@ key "rndc-key" {
controls {
inet ${INTERFACE_IP} port 953
- allow { 127.0.0.0/8; ${INTERFACE_NET}; } keys { "rndc-key"; };
+ allow { any; } keys { "rndc-key"; };
};
include "${PREFIX}/private/named.conf";
@@ -484,7 +494,7 @@ def join_as_dc(t, vm):
child = t.open_telnet("${WIN_HOSTNAME}", "${WIN_DOMAIN}\\administrator", "${WIN_PASS}", set_time=True)
t.get_ipconfig(child)
t.retry_cmd("bin/samba-tool drs showrepl ${WIN_HOSTNAME}.${WIN_REALM} -Uadministrator%${WIN_PASS}", ['INBOUND NEIGHBORS'] )
- t.run_cmd('bin/samba-tool join ${WIN_REALM} DC -Uadministrator%${WIN_PASS} -d${DEBUGLEVEL} --option=interfaces=${INTERFACE}')
+ t.run_cmd('bin/samba-tool join ${WIN_REALM} DC -Uadministrator%${WIN_PASS} -d${DEBUGLEVEL} --option=interfaces="${INTERFACE} ${INTERFACE_IPV6"')
t.run_cmd('bin/samba-tool drs kcc ${WIN_HOSTNAME}.${WIN_REALM} -Uadministrator@${WIN_REALM}%${WIN_PASS}')
@@ -498,12 +508,12 @@ def test_join_as_dc(t, vm):
t.info("Forcing kcc runs, and replication")
t.run_cmd('bin/samba-tool drs kcc ${WIN_HOSTNAME}.${WIN_REALM} -Uadministrator@${WIN_REALM}%${WIN_PASS}')
- t.run_cmd('bin/samba-tool drs kcc ${HOSTNAME} -Uadministrator@${WIN_REALM}%${WIN_PASS}')
+ t.run_cmd('bin/samba-tool drs kcc ${HOSTNAME}.${WIN_REALM} -Uadministrator@${WIN_REALM}%${WIN_PASS}')
t.kinit("administrator@${WIN_REALM}", "${WIN_PASS}")
for nc in [ '${WIN_BASEDN}', 'CN=Configuration,${WIN_BASEDN}', 'CN=Schema,CN=Configuration,${WIN_BASEDN}' ]:
- t.cmd_contains("bin/samba-tool drs replicate ${HOSTNAME} ${WIN_HOSTNAME}.${WIN_REALM} %s -k yes" % nc, ["was successful"])
- t.cmd_contains("bin/samba-tool drs replicate ${WIN_HOSTNAME}.${WIN_REALM} ${HOSTNAME} %s -k yes" % nc, ["was successful"])
+ t.cmd_contains("bin/samba-tool drs replicate ${HOSTNAME}.${WIN_REALM} ${WIN_HOSTNAME}.${WIN_REALM} %s -k yes" % nc, ["was successful"])
+ t.cmd_contains("bin/samba-tool drs replicate ${WIN_HOSTNAME}.${WIN_REALM} ${HOSTNAME}.${WIN_REALM} %s -k yes" % nc, ["was successful"])
child.sendline("net use t: \\\\${HOSTNAME}.${WIN_REALM}\\test")
child.expect("The command completed successfully")
@@ -525,8 +535,8 @@ def test_join_as_dc(t, vm):
t.info("Checking if new users on windows propogate to samba")
child.sendline("net user test3 ${PASSWORD3} /add")
child.expect("The command completed successfully")
- t.retry_cmd("bin/smbclient -L ${HOSTNAME} -Utest3%${PASSWORD3} -k no", ['Sharename', 'IPC'])
- t.retry_cmd("bin/smbclient -L ${HOSTNAME} -Utest3%${PASSWORD3} -k yes", ['Sharename', 'IPC'])
+ t.retry_cmd("bin/smbclient -L ${HOSTNAME}.${WIN_REALM} -Utest3%${PASSWORD3} -k no", ['Sharename', 'IPC'])
+ t.retry_cmd("bin/smbclient -L ${HOSTNAME}.${WIN_REALM} -Utest3%${PASSWORD3} -k yes", ['Sharename', 'IPC'])
t.info("Checking propogation of user deletion")
t.run_cmd('bin/samba-tool user delete test2 -Uadministrator@${WIN_REALM}%${WIN_PASS}')
@@ -534,9 +544,9 @@ def test_join_as_dc(t, vm):
child.expect("The command completed successfully")
t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME}.${WIN_REALM} -Utest2%${PASSWORD2} -k no", ['LOGON_FAILURE'])
- t.retry_cmd("bin/smbclient -L ${HOSTNAME} -Utest3%${PASSWORD3} -k no", ['LOGON_FAILURE'])
+ t.retry_cmd("bin/smbclient -L ${HOSTNAME}.${WIN_REALM} -Utest3%${PASSWORD3} -k no", ['LOGON_FAILURE'])
t.retry_cmd("bin/smbclient -L ${WIN_HOSTNAME}.${WIN_REALM} -Utest2%${PASSWORD2} -k yes", ['LOGON_FAILURE'])
- t.retry_cmd("bin/smbclient -L ${HOSTNAME} -Utest3%${PASSWORD3} -k yes", ['LOGON_FAILURE'])
+ t.retry_cmd("bin/smbclient -L ${HOSTNAME}.${WIN_REALM} -Utest3%${PASSWORD3} -k yes", ['LOGON_FAILURE'])
t.vm_poweroff("${WIN_VM}")
@@ -553,7 +563,7 @@ def join_as_rodc(t, vm):
child = t.open_telnet("${WIN_HOSTNAME}", "${WIN_DOMAIN}\\administrator", "${WIN_PASS}", set_time=True)
t.get_ipconfig(child)
t.retry_cmd("bin/samba-tool drs showrepl ${WIN_HOSTNAME}.${WIN_REALM} -Uadministrator%${WIN_PASS}", ['INBOUND NEIGHBORS'] )
- t.run_cmd('bin/samba-tool join ${WIN_REALM} RODC -Uadministrator%${WIN_PASS} -d${DEBUGLEVEL} --option=interfaces=${INTERFACE}')
+ t.run_cmd('bin/samba-tool join ${WIN_REALM} RODC -Uadministrator%${WIN_PASS} -d${DEBUGLEVEL} --option=interfaces="${INTERFACE} ${INTERFACE_IPV6}"')
t.run_cmd('bin/samba-tool drs kcc ${WIN_HOSTNAME}.${WIN_REALM} -Uadministrator@${WIN_REALM}%${WIN_PASS}')
@@ -566,12 +576,12 @@ def test_join_as_rodc(t, vm):
child = t.open_telnet("${WIN_HOSTNAME}", "${WIN_DOMAIN}\\administrator", "${WIN_PASS}", set_time=True)
t.info("Forcing kcc runs, and replication")
- t.run_cmd('bin/samba-tool drs kcc ${HOSTNAME} -Uadministrator@${WIN_REALM}%${WIN_PASS}')
+ t.run_cmd('bin/samba-tool drs kcc ${HOSTNAME}.${WIN_REALM} -Uadministrator@${WIN_REALM}%${WIN_PASS}')
t.run_cmd('bin/samba-tool drs kcc ${WIN_HOSTNAME}.${WIN_REALM} -Uadministrator@${WIN_REALM}%${WIN_PASS}')
t.kinit("administrator@${WIN_REALM}", "${WIN_PASS}")
for nc in [ '${WIN_BASEDN}', 'CN=Configuration,${WIN_BASEDN}', 'CN=Schema,CN=Configuration,${WIN_BASEDN}' ]:
- t.cmd_contains("bin/samba-tool drs replicate ${HOSTNAME} ${WIN_HOSTNAME}.${WIN_REALM} %s -k yes" % nc, ["was successful"])
+ t.cmd_contains("bin/samba-tool drs replicate ${HOSTNAME}.${WIN_REALM} ${WIN_HOSTNAME}.${WIN_REALM} %s -k yes" % nc, ["was successful"])
child.sendline("net use t: \\\\${HOSTNAME}.${WIN_REALM}\\test")
child.expect("The command completed successfully")
@@ -595,8 +605,8 @@ def test_join_as_rodc(t, vm):
t.info("Checking if new users on windows propogate to samba")
child.sendline("net user test3 ${PASSWORD3} /add")
child.expect("The command completed successfully")
- t.retry_cmd("bin/smbclient -L ${HOSTNAME} -Utest3%${PASSWORD3} -k no", ['Sharename', 'IPC'])
- t.retry_cmd("bin/smbclient -L ${HOSTNAME} -Utest3%${PASSWORD3} -k yes", ['Sharename', 'IPC'])
+ t.retry_cmd("bin/smbclient -L ${HOSTNAME}.${WIN_REALM} -Utest3%${PASSWORD3} -k no", ['Sharename', 'IPC'])
+ t.retry_cmd("bin/smbclient -L ${HOSTNAME}.${WIN_REALM} -Utest3%${PASSWORD3} -k yes", ['Sharename', 'IPC'])
# should this work?
t.info("Checking if new users propogate to windows")
@@ -606,8 +616,8 @@ def test_join_as_rodc(t, vm):
child.sendline("net user test3 /del")
child.expect("The command completed successfully")
- t.retry_cmd("bin/smbclient -L ${HOSTNAME} -Utest3%${PASSWORD3} -k no", ['LOGON_FAILURE'])
- t.retry_cmd("bin/smbclient -L ${HOSTNAME} -Utest3%${PASSWORD3} -k yes", ['LOGON_FAILURE'])
+ t.retry_cmd("bin/smbclient -L ${HOSTNAME}.${WIN_REALM} -Utest3%${PASSWORD3} -k no", ['LOGON_FAILURE'])
+ t.retry_cmd("bin/smbclient -L ${HOSTNAME}.${WIN_REALM} -Utest3%${PASSWORD3} -k yes", ['LOGON_FAILURE'])
t.vm_poweroff("${WIN_VM}")
diff --git a/wintest/wintest.py b/wintest/wintest.py
index 81e2eda515..36d0659f03 100644
--- a/wintest/wintest.py
+++ b/wintest/wintest.py
@@ -117,6 +117,7 @@ class wintest():
f.close()
def run_cmd(self, cmd, dir=".", show=None, output=False, checkfail=True):
+ '''run a command'''
cmd = self.substitute(cmd)
if isinstance(cmd, list):
self.info('$ ' + " ".join(cmd))
@@ -133,7 +134,9 @@ class wintest():
else:
return subprocess.call(cmd, shell=shell, cwd=dir)
+
def run_child(self, cmd, dir="."):
+ '''create a child and return the Popen handle to it'''
cwd = os.getcwd()
cmd = self.substitute(cmd)
if isinstance(cmd, list):
@@ -145,7 +148,7 @@ class wintest():
else:
shell=True
os.chdir(dir)
- ret = subprocess.Popen(cmd, shell=shell)
+ ret = subprocess.Popen(cmd, shell=shell, stderr=subprocess.STDOUT)
os.chdir(cwd)
return ret
@@ -200,7 +203,7 @@ class wintest():
retries = retries - 1
raise RuntimeError("Failed to find %s" % contains)
- def pexpect_spawn(self, cmd, timeout=60):
+ def pexpect_spawn(self, cmd, timeout=60, crlf=True):
'''wrapper around pexpect spawn'''
cmd = self.substitute(cmd)
self.info("$ " + cmd)
@@ -214,8 +217,9 @@ class wintest():
line = self.substitute(line)
return ret.old_expect(line, timeout=timeout)
- ret.old_sendline = ret.sendline
- ret.sendline = sendline_sub
+ if crlf:
+ ret.old_sendline = ret.sendline
+ ret.sendline = sendline_sub
ret.old_expect = ret.expect
ret.expect = expect_sub
@@ -223,8 +227,11 @@ class wintest():
def get_nameserver(self):
'''Get the current nameserver from /etc/resolv.conf'''
- child = self.pexpect_spawn('cat /etc/resolv.conf')
- child.expect('nameserver')
+ child = self.pexpect_spawn('cat /etc/resolv.conf', crlf=False)
+ i = child.expect(['Generated by wintest', 'nameserver'])
+ if i == 0:
+ child.expect('your original resolv.conf')
+ child.expect('nameserver')
child.expect('\d+.\d+.\d+.\d+')
return child.after