summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2012-02-28 15:12:44 +1100
committerAmitay Isaacs <amitay@gmail.com>2012-03-02 00:24:50 +1100
commitf025d788d011403ef6740e777aef5ee289b35b0c (patch)
treead61305fa3625da31aed1cbadf49de187ba665da /source4/scripting
parentbcaa278e32a1fb334253638f24d6f23378c6119c (diff)
downloadsamba-f025d788d011403ef6740e777aef5ee289b35b0c.tar.gz
samba-f025d788d011403ef6740e777aef5ee289b35b0c.tar.bz2
samba-f025d788d011403ef6740e777aef5ee289b35b0c.zip
samba-tool: dns: Copy string data when creating DNS_RPC_RECORD
Diffstat (limited to 'source4/scripting')
-rw-r--r--source4/scripting/python/samba/netcmd/dns.py41
1 files changed, 23 insertions, 18 deletions
diff --git a/source4/scripting/python/samba/netcmd/dns.py b/source4/scripting/python/samba/netcmd/dns.py
index b84f29b4fb..15a6122883 100644
--- a/source4/scripting/python/samba/netcmd/dns.py
+++ b/source4/scripting/python/samba/netcmd/dns.py
@@ -363,6 +363,11 @@ def print_dnsrecords(outf, records):
print_dns_record(outf, dns_rec)
+#
+# Always create a copy of strings when creating DNS_RPC_RECORDs
+# to overcome the bug in pidl generated python bindings.
+#
+
class ARecord(dnsserver.DNS_RPC_RECORD):
def __init__(self, ip_addr, serial=1, ttl=900, rank=dnsp.DNS_RANK_ZONE,
node_flag=0):
@@ -371,7 +376,8 @@ class ARecord(dnsserver.DNS_RPC_RECORD):
self.dwFlags = rank | node_flag
self.dwSerial = serial
self.dwTtlSeconds = ttl
- self.data = ip_addr
+ self._ip_addr = ip_addr[:]
+ self.data = self._ip_addr
class AAAARecord(dnsserver.DNS_RPC_RECORD):
def __init__(self, ip6_addr, serial=1, ttl=900, rank=dnsp.DNS_RANK_ZONE,
@@ -381,7 +387,8 @@ class AAAARecord(dnsserver.DNS_RPC_RECORD):
self.dwFlags = rank | node_flag
self.dwSerial = serial
self.dwTtlSeconds = ttl
- self.data = ip6_addr
+ self._ip6_addr = ip6_addr[:]
+ self.data = self._ip6_addr
class PTRRecord(dnsserver.DNS_RPC_RECORD):
def __init__(self, ptr, serial=1, ttl=900, rank=dnsp.DNS_RANK_ZONE,
@@ -391,8 +398,9 @@ class PTRRecord(dnsserver.DNS_RPC_RECORD):
self.dwFlags = rank | node_flag
self.dwSerial = serial
self.dwTtleSeconds = ttl
+ self._ptr = ptr[:]
ptr_name = dnsserver.DNS_RPC_NAME()
- ptr_name.str = ptr
+ ptr_name.str = self._ptr
ptr_name.len = len(ptr)
self.data = ptr_name
@@ -404,8 +412,9 @@ class CNameRecord(dnsserver.DNS_RPC_RECORD):
self.dwFlags = rank | node_flag
self.dwSerial = serial
self.dwTtlSeconds = ttl
+ self._cname = cname[:]
cname_name = dnsserver.DNS_RPC_NAME()
- cname_name.str = cname
+ cname_name.str = self._cname
cname_name.len = len(cname)
self.data = cname_name
@@ -417,16 +426,12 @@ class NSRecord(dnsserver.DNS_RPC_RECORD):
self.dwFlags = rank | node_flag
self.dwSerial = serial
self.dwTtlSeconds = ttl
+ self._dns_server = dns_server[:]
ns = dnsserver.DNS_RPC_NAME()
- ns.str = dns_server
+ ns.str = self._dns_server
ns.len = len(dns_server)
self.data = ns
-#
-# FIXME: In MXRecord, SOARecord, SRVRecord keep a reference to strings
-# to overcome the bug in pidl generated python bindings.
-#
-
class MXRecord(dnsserver.DNS_RPC_RECORD):
def __init__(self, mail_server, preference, serial=1, ttl=900,
rank=dnsp.DNS_RANK_ZONE, node_flag=0):
@@ -435,11 +440,11 @@ class MXRecord(dnsserver.DNS_RPC_RECORD):
self.dwFlags = rank | node_flag
self.dwSerial = serial
self.dwTtlSeconds = ttl
+ self._mail_server = mail_server[:]
mx = dnsserver.DNS_RPC_RECORD_NAME_PREFERENCE()
mx.wPreference = preference
- self._mail_server = mail_server
mx.nameExchange.str = self._mail_server
- mx.nameExchange.len = len(self._mail_server)
+ mx.nameExchange.len = len(mail_server)
self.data = mx
class SOARecord(dnsserver.DNS_RPC_RECORD):
@@ -451,17 +456,17 @@ class SOARecord(dnsserver.DNS_RPC_RECORD):
self.dwFlags = rank | node_flag
self.dwSerial = serial
self.dwTtlSeconds = ttl
+ self._mname = mname[:]
+ self._rname = rname[:]
soa = dnsserver.DNS_RPC_RECORD_SOA()
soa.dwSerialNo = serial
soa.dwRefresh = refresh
soa.dwRetry = retry
soa.dwExpire = expire
- self._mname = mname
soa.NamePrimaryServer.str = self._mname
- soa.NamePrimaryServer.len = len(self._mname)
- self._rname = rname
+ soa.NamePrimaryServer.len = len(mname)
soa.ZoneAdministratorEmail.str = self._rname
- soa.ZoneAdministratorEmail.len = len(self._rname)
+ soa.ZoneAdministratorEmail.len = len(rname)
self.data = soa
class SRVRecord(dnsserver.DNS_RPC_RECORD):
@@ -472,13 +477,13 @@ class SRVRecord(dnsserver.DNS_RPC_RECORD):
self.dwFlags = rank | node_flag
self.dwSerial = serial
self.dwTtlSeconds = ttl
+ self._target = target[:]
srv = dnsserver.DNS_RPC_RECORD_SRV()
srv.wPriority = priority
srv.wWeight = weight
srv.wPort = port
- self._target = target
srv.nameTarget.str = self._target
- srv.nameTarget.len = len(self._target)
+ srv.nameTarget.len = len(target)
self.data = srv