summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/python/samba/netcmd/dns.py38
1 files changed, 33 insertions, 5 deletions
diff --git a/source4/scripting/python/samba/netcmd/dns.py b/source4/scripting/python/samba/netcmd/dns.py
index b566a34159..f1adc06faa 100644
--- a/source4/scripting/python/samba/netcmd/dns.py
+++ b/source4/scripting/python/samba/netcmd/dns.py
@@ -519,8 +519,15 @@ def data_to_dns_record(record_type, data):
return rec
+# Match dns name (of type DNS_RPC_NAME)
+def dns_name_equal(n1, n2):
+ return n1.str.rstrip('.').lower() == n2.str.rstrip('.').lower()
+
+
# Match a dns record with specified data
def dns_record_match(dns_conn, server, zone, name, record_type, data):
+ urec = data_to_dns_record(record_type, data)
+
select_flags = dnsserver.DNS_RPC_VIEW_AUTHORITY_DATA
try:
@@ -547,19 +554,40 @@ def dns_record_match(dns_conn, server, zone, name, record_type, data):
found = False
if record_type == dnsp.DNS_TYPE_A:
- if rec.data == data:
+ if rec.data == urec.data:
found = True
elif record_type == dnsp.DNS_TYPE_AAAA:
- if rec.data == data:
+ if rec.data == urec.data:
found = True
elif record_type == dnsp.DNS_TYPE_PTR:
- if rec.data.str.rstrip('.').lower() == data.rstrip('.').lower():
+ if dns_name_equal(rec.data, urec.data):
found = True
elif record_type == dnsp.DNS_TYPE_CNAME:
- if rec.data.str.rstrip('.').lower() == data.rstrip('.').lower():
+ if dns_name_equal(rec.data, urec.data):
found = True
elif record_type == dnsp.DNS_TYPE_NS:
- if rec.data.str.rstrip('.').lower() == data.rstrip('.').lower():
+ if dns_name_equal(rec.data, urec.data):
+ found = True
+ elif record_type == dnsp.DNS_TYPE_MX:
+ if dns_name_equal(rec.data.nameExchange, urec.data.nameExchange) and \
+ rec.data.wPreference == urec.data.wPreference:
+ found = True
+ elif record_type == dnsp.DNS_TYPE_SRV:
+ if rec.data.wPriority == urec.data.wPriority and \
+ rec.data.wWeight == urec.data.wWeight and \
+ rec.data.wPort == urec.data.wPort and \
+ dns_name_equal(rec.data.nameTarget, urec.data.nameTarget):
+ found = True
+ elif record_type == dnsp.DNS_TYPE_SOA:
+ if rec.data.dwSerialNo == urec.data.dwSerialNo and \
+ rec.data.dwRefresh == urec.data.dwRefresh and \
+ rec.data.dwRetry == urec.data.dwRetry and \
+ rec.data.dwExpire == urec.data.dwExpire and \
+ rec.data.dwMinimumTtl == urec.data.dwMinimumTtl and \
+ dns_name_equal(rec.data.NamePrimaryServer,
+ urec.data.NamePrimaryServer) and \
+ dns_name_equal(rec.data.ZoneAdministratorEmail,
+ urec.data.ZoneAdministratorEmail):
found = True
if found:
rec_match = rec