summaryrefslogtreecommitdiffstats
path: root/python/samba
diff options
context:
space:
mode:
authorGuenter Kukkukk <linux@kukkukk.com>2014-11-21 03:55:25 +0100
committerAmitay Isaacs <amitay@samba.org>2014-11-26 01:22:05 +0100
commitd5af53c5372866a33a0195cabbd64232ac53bad4 (patch)
tree6bd32e70742e22c446a2266ef5dd80957b028efd /python/samba
parent4bda589c8e68cd66ca3b0ea9496cb1b11febcae6 (diff)
downloadsamba-d5af53c5372866a33a0195cabbd64232ac53bad4.tar.gz
samba-d5af53c5372866a33a0195cabbd64232ac53bad4.tar.xz
samba-d5af53c5372866a33a0195cabbd64232ac53bad4.zip
samba-tool: Fix the IP output of "samba-tool dns serverinfo <some_server>"
Avoid hardcoded IP-strings, use standard python IP functions to format IPv4 and IPv6 addresses correctly. I have removed the display of the port number. MS-DNSP 2.2.3.2.2.1 DNS_ADDR: (from May 15, 2014) Port Number (2bytes): Senders MUST set this to zero, and receivers MUST ignore it. Signed-off-by: Guenter Kukkukk <linux@kukkukk.com> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'python/samba')
-rw-r--r--python/samba/netcmd/dns.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/python/samba/netcmd/dns.py b/python/samba/netcmd/dns.py
index 775be9e560..2cf9a1f13c 100644
--- a/python/samba/netcmd/dns.py
+++ b/python/samba/netcmd/dns.py
@@ -19,6 +19,9 @@
import samba.getopt as options
from struct import pack
from socket import inet_ntoa
+from socket import inet_ntop
+from socket import AF_INET
+from socket import AF_INET6
import shlex
from samba.netcmd import (
@@ -126,7 +129,7 @@ def ip4_array_string(array):
if not array:
return ret
for i in xrange(array.AddrCount):
- addr = '%s' % inet_ntoa(pack('i', array.AddrArray[i]))
+ addr = inet_ntop(AF_INET, pack('I', array.AddrArray[i]))
ret.append(addr)
return ret
@@ -137,11 +140,11 @@ def dns_addr_array_string(array):
return ret
for i in xrange(array.AddrCount):
if array.AddrArray[i].MaxSa[0] == 0x02:
- addr = '%d.%d.%d.%d (%d)' % \
- tuple(array.AddrArray[i].MaxSa[4:8] + [array.AddrArray[i].MaxSa[3]])
+ x = "".join([chr(b) for b in array.AddrArray[i].MaxSa])[4:8]
+ addr = inet_ntop(AF_INET, x)
elif array.AddrArray[i].MaxSa[0] == 0x17:
- addr = '%x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x (%d)' % \
- tuple(array.AddrArray[i].MaxSa[4:20] + [array.AddrArray[i].MaxSa[3]])
+ x = "".join([chr(b) for b in array.AddrArray[i].MaxSa])[8:24]
+ addr = inet_ntop(AF_INET6, x)
else:
addr = 'UNKNOWN'
ret.append(addr)