mirror of
https://github.com/samba-team/samba.git
synced 2025-02-02 09:47:23 +03:00
CVE-2016-0771: tests/dns: change samba.tests.dns from being a unittest
This makes it easier to invoke, particularly against Windows. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11128 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11686 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
8cee2c8146
commit
9f1ba00f1f
@ -16,6 +16,7 @@
|
||||
#
|
||||
|
||||
import os
|
||||
import sys
|
||||
import struct
|
||||
import random
|
||||
import socket
|
||||
@ -24,10 +25,39 @@ from samba import credentials, param
|
||||
from samba.tests import TestCase
|
||||
from samba.dcerpc import dns, dnsp, dnsserver
|
||||
from samba.netcmd.dns import TXTRecord, dns_record_match, data_to_dns_record
|
||||
from samba.tests.subunitrun import SubunitOptions, TestProgram
|
||||
import samba.getopt as options
|
||||
import optparse
|
||||
|
||||
parser = optparse.OptionParser("dns.py <server name> <server ip> [options]")
|
||||
sambaopts = options.SambaOptions(parser)
|
||||
parser.add_option_group(sambaopts)
|
||||
|
||||
# This timeout only has relevance when testing against Windows
|
||||
# Format errors tend to return patchy responses, so a timeout is needed.
|
||||
timeout = None
|
||||
parser.add_option("--timeout", type="int", dest="timeout",
|
||||
help="Specify timeout for DNS requests")
|
||||
|
||||
# use command line creds if available
|
||||
credopts = options.CredentialsOptions(parser)
|
||||
parser.add_option_group(credopts)
|
||||
subunitopts = SubunitOptions(parser)
|
||||
parser.add_option_group(subunitopts)
|
||||
|
||||
opts, args = parser.parse_args()
|
||||
|
||||
lp = sambaopts.get_loadparm()
|
||||
creds = credopts.get_credentials(lp)
|
||||
|
||||
timeout = opts.timeout
|
||||
|
||||
if len(args) < 2:
|
||||
parser.print_usage()
|
||||
sys.exit(1)
|
||||
|
||||
server_name = args[0]
|
||||
server_ip = args[1]
|
||||
creds.set_krb_forwardable(credentials.NO_KRB_FORWARDABLE)
|
||||
|
||||
def make_txt_record(records):
|
||||
rdata_txt = dns.txt_record()
|
||||
@ -39,10 +69,13 @@ def make_txt_record(records):
|
||||
|
||||
class DNSTest(TestCase):
|
||||
|
||||
def get_loadparm(self):
|
||||
lp = param.LoadParm()
|
||||
lp.load(os.getenv("SMB_CONF_PATH"))
|
||||
return lp
|
||||
def setUp(self):
|
||||
global server, server_ip, lp, creds
|
||||
super(DNSTest, self).setUp()
|
||||
self.server = server_name
|
||||
self.server_ip = server_ip
|
||||
self.lp = lp
|
||||
self.creds = creds
|
||||
|
||||
def errstr(self, errcode):
|
||||
"Return a readable error code"
|
||||
@ -1244,6 +1277,4 @@ class TestRPCRoundtrip(DNSTest):
|
||||
0, self.server_ip, self.get_dns_domain(),
|
||||
name, None, add_rec_buf)
|
||||
|
||||
if __name__ == "__main__":
|
||||
import unittest
|
||||
unittest.main()
|
||||
TestProgram(module=__name__, opts=subunitopts)
|
||||
|
@ -298,7 +298,7 @@ for f in sorted(os.listdir(os.path.join(samba4srcdir, "../pidl/tests"))):
|
||||
planperltestsuite("pidl.%s" % f[:-3], os.path.normpath(os.path.join(samba4srcdir, "../pidl/tests", f)))
|
||||
|
||||
# DNS tests
|
||||
planpythontestsuite("fl2003dc:local", "samba.tests.dns")
|
||||
plantestsuite_loadlist("samba.tests.dns", "fl2003dc:local", [python, os.path.join(srcdir(), "python/samba/tests/dns.py"), '$SERVER', '$SERVER_IP', '--machine-pass', '-U"$USERNAME%$PASSWORD"', '--workgroup=$DOMAIN', '$LOADLIST', '$LISTOPT'])
|
||||
|
||||
for t in smbtorture4_testsuites("dns_internal."):
|
||||
plansmbtorture4testsuite(t, "ad_dc_ntvfs:local", '//$SERVER/whavever')
|
||||
|
Loading…
x
Reference in New Issue
Block a user