mirror of
https://github.com/samba-team/samba.git
synced 2025-08-02 00:22:11 +03:00
samba-tool:dns: Check through all the DNS records for a match
There can be multiple dns records for a specified record type. Autobuild-User: Amitay Isaacs <amitay@samba.org> Autobuild-Date: Fri Jan 6 02:41:22 CET 2012 on sn-devel-104
This commit is contained in:
committed by
Amitay Isaacs
parent
f8163195b0
commit
200c22b994
@ -457,6 +457,7 @@ class SRVRecord(dnsserver.DNS_RPC_RECORD):
|
||||
srv.nameTarget.len = len(target)
|
||||
self.data = srv
|
||||
|
||||
# Match a dns record with specified data
|
||||
def dns_record_match(dns_conn, server, zone, name, record_type, data):
|
||||
select_flags = dnsserver.DNS_RPC_VIEW_AUTHORITY_DATA
|
||||
|
||||
@ -474,36 +475,35 @@ def dns_record_match(dns_conn, server, zone, name, record_type, data):
|
||||
except RuntimeError, e:
|
||||
return None
|
||||
|
||||
rec_match = None
|
||||
if res and res.count > 0:
|
||||
recs = res.rec[0]
|
||||
for rec in recs.records:
|
||||
if rec.wType == record_type:
|
||||
rec_match = rec
|
||||
break
|
||||
if not res or res.count == 0:
|
||||
return None
|
||||
|
||||
rec_match = None
|
||||
for rec in res.rec[0].records:
|
||||
if rec.wType != record_type:
|
||||
continue
|
||||
|
||||
if rec_match:
|
||||
found = False
|
||||
if record_type == dnsp.DNS_TYPE_A:
|
||||
if rec_match.data == data:
|
||||
if rec.data == data:
|
||||
found = True
|
||||
elif record_type == dnsp.DNS_TYPE_AAAA:
|
||||
if rec_match.data == data:
|
||||
if rec.data == data:
|
||||
found = True
|
||||
elif record_type == dnsp.DNS_TYPE_PTR:
|
||||
if rec_match.data.str.rstrip('.') == data.rstrip('.'):
|
||||
if rec.data.str.rstrip('.') == data.rstrip('.'):
|
||||
found = True
|
||||
elif record_type == dnsp.DNS_TYPE_CNAME:
|
||||
if rec_match.data.str.rstrip('.') == data.rstrip('.'):
|
||||
if rec.data.str.rstrip('.') == data.rstrip('.'):
|
||||
found = True
|
||||
elif record_type == dnsp.DNS_TYPE_NS:
|
||||
if rec_match.data.str.rstrip('.') == data.rstrip('.'):
|
||||
if rec.data.str.rstrip('.') == data.rstrip('.'):
|
||||
found = True
|
||||
|
||||
if found:
|
||||
return rec_match
|
||||
rec_match = rec
|
||||
break
|
||||
|
||||
return None
|
||||
return rec_match
|
||||
|
||||
|
||||
class cmd_serverinfo(Command):
|
||||
|
Reference in New Issue
Block a user