mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
samba-tool dns: use bytes for inet_ntop
From Python's point of view, array.AddrArray is a list of byte-valued integers. In Python 3 we can convert directly using the likes of bytes(array.AddrArray[i].MaxSa[8:24]) but in 4.10 we need to support both, so we use struct. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org> Autobuild-User(master): Noel Power <npower@samba.org> Autobuild-Date(master): Wed May 29 11:29:17 UTC 2019 on sn-devel-184
This commit is contained in:
parent
32b282d55e
commit
0ae585db26
@ -26,6 +26,7 @@ from socket import inet_ntop
|
||||
from socket import AF_INET
|
||||
from socket import AF_INET6
|
||||
import shlex
|
||||
import struct
|
||||
|
||||
from samba import remove_dc
|
||||
from samba.samdb import SamDB
|
||||
@ -153,10 +154,10 @@ def dns_addr_array_string(array):
|
||||
return ret
|
||||
for i in range(array.AddrCount):
|
||||
if array.AddrArray[i].MaxSa[0] == 0x02:
|
||||
x = "".join([chr(b) for b in array.AddrArray[i].MaxSa])[4:8]
|
||||
x = struct.pack('4B', *array.AddrArray[i].MaxSa[4:8])
|
||||
addr = inet_ntop(AF_INET, x)
|
||||
elif array.AddrArray[i].MaxSa[0] == 0x17:
|
||||
x = "".join([chr(b) for b in array.AddrArray[i].MaxSa])[8:24]
|
||||
x = struct.pack('16B', *array.AddrArray[i].MaxSa[8:24])
|
||||
addr = inet_ntop(AF_INET6, x)
|
||||
else:
|
||||
addr = 'UNKNOWN'
|
||||
|
@ -1 +0,0 @@
|
||||
samba.tests.samba_tool.dnscmd.samba.tests.samba_tool.dnscmd.DnsCmdTestCase.test_serverinfo
|
Loading…
Reference in New Issue
Block a user