summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorTim Beale <timbeale@catalyst.net.nz>2019-01-16 15:17:38 +1300
committerKarolin Seeger <kseeger@samba.org>2019-02-05 20:41:24 +0100
commit334f1e6f56a10097ce918620dc484e9eb0a5b83b (patch)
tree12c2379c489fc97662365cf2e8b974218af14a54 /python
parent9ae7ffa5f053c5f39691dd881d1adb290859bcad (diff)
downloadsamba-334f1e6f56a10097ce918620dc484e9eb0a5b83b.tar.gz
join: Fix TypeError when handling exception
When we can't resolve a domain name, we were inadvertently throwing a TypeError whilst trying to output a helpful message. E.g. ERROR(<class 'TypeError'>): uncaught exception - 'NTSTATUSError' object does not support indexing Instead of indexing the object, we want to index the Exception.args so that we just display the string portion of the exception error. The same problem is also present for the domain trust commands. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13747 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Rowland Penny <rpenny@samba.org> Reviewed-by: Jeremy Allison <rpenny@samba.org> (cherry picked from commit 3bb7808984c163a7bba66fb983411d1281589722)
Diffstat (limited to 'python')
-rw-r--r--python/samba/join.py2
-rw-r--r--python/samba/netcmd/domain.py2
2 files changed, 2 insertions, 2 deletions
diff --git a/python/samba/join.py b/python/samba/join.py
index cf5d1b92b66..28b7f0b8300 100644
--- a/python/samba/join.py
+++ b/python/samba/join.py
@@ -346,7 +346,7 @@ class DCJoinContext(object):
ctx.cldap_ret = ctx.net.finddc(domain=domain, flags=nbt.NBT_SERVER_LDAP | nbt.NBT_SERVER_DS | nbt.NBT_SERVER_WRITABLE)
except NTSTATUSError as error:
raise Exception("Failed to find a writeable DC for domain '%s': %s" %
- (domain, error[1]))
+ (domain, error.args[1]))
except Exception:
raise Exception("Failed to find a writeable DC for domain '%s'" % domain)
if ctx.cldap_ret.client_site is not None and ctx.cldap_ret.client_site != "":
diff --git a/python/samba/netcmd/domain.py b/python/samba/netcmd/domain.py
index 9c5ae21fdd7..b7aedc16a91 100644
--- a/python/samba/netcmd/domain.py
+++ b/python/samba/netcmd/domain.py
@@ -1802,7 +1802,7 @@ class DomainTrustCommand(Command):
remote_info = remote_net.finddc(flags=remote_flags, domain=domain, address=remote_server)
except NTSTATUSError as error:
raise CommandError("Failed to find a writeable DC for domain '%s': %s" %
- (domain, error[1]))
+ (domain, error.args[1]))
except Exception:
raise CommandError("Failed to find a writeable DC for domain '%s'" % domain)
flag_map = {