Web lists-archives.com

Re: [Samba] samba-tool dns serverinfo command throws error




hi James,

> @dc1:~# samba-tool dns serverinfo dc1.domain.local -U administrator
> Password for [DOMAIN\administrator]:
>   dwVersion                   : 0xece0205
>   fBootMethod                 : DNS_BOOT_METHOD_DIRECTORY
>   fAdminConfigured            : FALSE
>   fAllowUpdate                : TRUE
>   fDsAvailable                : TRUE
>   pszServerName               : DC1.domain.local
>   pszDsContainer              :
> CN=MicrosoftDNS,DC=DomainDnsZones,DC=domain,DC=local
> ERROR(<class 'TypeError'>): uncaught exception - a bytes-like object is
> required, not 'str'
>   File
> "/usr/local/samba/lib/python3.5/site-packages/samba/netcmd/__init__.py",
> line 185, in _run
>     return self.run(*args, **kwargs)
>   File
> "/usr/local/samba/lib/python3.5/site-packages/samba/netcmd/dns.py", line
> 564, in run
>     print_serverinfo(self.outf, typeid, res)
>   File
> "/usr/local/samba/lib/python3.5/site-packages/samba/netcmd/dns.py", line
> 225, in print_serverinfo
>     dns_addr_array_string(serverinfo.aipServerAddrs))
>   File
> "/usr/local/samba/lib/python3.5/site-packages/samba/netcmd/dns.py", line
> 157, in dns_addr_array_string
>     addr = inet_ntop(AF_INET, x)
> 
> I'm not experiencing any DNS issues so I believe this may be a bug with
> the move to python3 Am I correct?

Yes, you are very likely correct.

Does the attached patch help?

If you can confirm this at
https://bugzilla.samba.org/show_bug.cgi?id=13965
it can get into the next 4.10 release.

Douglas
>From 393e8f6201d7f5657467e87ddf7c010327920f49 Mon Sep 17 00:00:00 2001
From: Douglas Bagnall <douglas.bagnall@xxxxxxxxxxxxxxx>
Date: Fri, 24 May 2019 09:58:12 +1200
Subject: [PATCH] samba-tool dns: use bytes for inet_ntop

Signed-off-by: Douglas Bagnall <douglas.bagnall@xxxxxxxxxxxxxxx>
---
 python/samba/netcmd/dns.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/python/samba/netcmd/dns.py b/python/samba/netcmd/dns.py
index b7459a71acd..ae51a99a638 100644
--- a/python/samba/netcmd/dns.py
+++ b/python/samba/netcmd/dns.py
@@ -153,10 +153,13 @@ 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]
+            # This could look more like
+            #   x = bytes(array.AddrArray[i].MaxSa[4:8])
+            # once we are pure Python 3.
+            x = b"".join(bytes(chr(b)) for b in 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 = b"".join(bytes(chr(b)) for b in array.AddrArray[i].MaxSa)[8:24]
             addr = inet_ntop(AF_INET6, x)
         else:
             addr = 'UNKNOWN'
-- 
2.17.1

-- 
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba