summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2012-02-15 20:45:48 +1100
committerAmitay Isaacs <amitay@gmail.com>2012-02-21 18:24:30 +1100
commitb45d6a6d690b20e348336b9d5db678f3e574ad62 (patch)
tree438e7bbaa72f22de4de1245e078feadd59a045c1 /source4
parenta8a6b27e06b97edb70f171cd881f0dd24c82b92e (diff)
downloadsamba-b45d6a6d690b20e348336b9d5db678f3e574ad62.tar.gz
samba-b45d6a6d690b20e348336b9d5db678f3e574ad62.tar.bz2
samba-b45d6a6d690b20e348336b9d5db678f3e574ad62.zip
samba-tool: dns: Add extra references for string objects as workaround
This is a workaround for bug in pidl generated python bindings, where C object hold a pointer to python string without increasing reference count in python. So when the python string goes out of scope, the C pointer loses the value.
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/python/samba/netcmd/dns.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/source4/scripting/python/samba/netcmd/dns.py b/source4/scripting/python/samba/netcmd/dns.py
index d260dcf93f..31529c7ded 100644
--- a/source4/scripting/python/samba/netcmd/dns.py
+++ b/source4/scripting/python/samba/netcmd/dns.py
@@ -421,6 +421,11 @@ class NSRecord(dnsserver.DNS_RPC_RECORD):
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):
@@ -431,8 +436,9 @@ class MXRecord(dnsserver.DNS_RPC_RECORD):
self.dwTtlSeconds = ttl
mx = dnsserver.DNS_RPC_RECORD_NAME_PREFERENCE()
mx.wPreference = preference
- mx.nameExchange.str = mail_server
- mx.nameExchange.len = len(mail_server)
+ self._mail_server = mail_server
+ mx.nameExchange.str = self._mail_server
+ mx.nameExchange.len = len(self._mail_server)
self.data = mx
class SOARecord(dnsserver.DNS_RPC_RECORD):
@@ -449,10 +455,12 @@ class SOARecord(dnsserver.DNS_RPC_RECORD):
soa.dwRefresh = refresh
soa.dwRetry = retry
soa.dwExpire = expire
- soa.NamePrimaryServer.str = mname
- soa.NamePrimaryServer.len = len(mname)
- soa.ZoneAdministratorEmail.str = rname
- soa.ZoneAdministratorEmail.len = len(rname)
+ self._mname = mname
+ soa.NamePrimaryServer.str = self._mname
+ soa.NamePrimaryServer.len = len(self._mname)
+ self._rname = rname
+ soa.ZoneAdministratorEmail.str = self._rname
+ soa.ZoneAdministratorEmail.len = len(self._rname)
self.data = soa
class SRVRecord(dnsserver.DNS_RPC_RECORD):
@@ -467,8 +475,9 @@ class SRVRecord(dnsserver.DNS_RPC_RECORD):
srv.wPriority = priority
srv.wWeight = weight
srv.wPort = port
- srv.nameTarget.str = target
- srv.nameTarget.len = len(target)
+ self._target = target
+ srv.nameTarget.str = self._target
+ srv.nameTarget.len = len(self._target)
self.data = srv