Bug 13747 - Untidy error handling in samba-tool domain join
Summary: Untidy error handling in samba-tool domain join
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: AD: LDB/DSDB/SAMDB (show other bugs)
Version: 4.9.0
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-16 02:27 UTC by Tim Beale
Modified: 2019-02-08 09:30 UTC (History)
1 user (show)

See Also:


Attachments
Fix backport for 4.8 (5.18 KB, text/plain)
2019-01-17 02:52 UTC, Tim Beale
dbagnall: review+
Details
Backport of fix for v4.9 (4.69 KB, text/plain)
2019-01-17 02:53 UTC, Tim Beale
dbagnall: review+
Details
Fix backport for v4.10 (4.74 KB, text/plain)
2019-01-17 02:53 UTC, Tim Beale
dbagnall: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Beale 2019-01-16 02:27:10 UTC
If you try to join a domain that can't be found (e.g. misspelt), then you get a TypeError and a nice stack trace.

bin/samba-tool domain join blah.dont.exist dc -UAdministrator%locDCpass1 --targetdir=/tmp/join
INFO 2019-01-16 15:12:40,926 pid:49872 bin/python/samba/join.py #102: Finding a writeable DC for domain 'blah.dont.exist'
ERROR(<class 'TypeError'>): uncaught exception - 'NTSTATUSError' object does not support indexing
  File "bin/python/samba/netcmd/__init__.py", line 184, in _run
    return self.run(*args, **kwargs)
  File "bin/python/samba/netcmd/domain.py", line 699, in run
    backend_store=backend_store)
  File "bin/python/samba/join.py", line 1515, in join_DC
    backend_store=backend_store)
  File "bin/python/samba/join.py", line 103, in __init__
    ctx.server = ctx.find_dc(domain)
  File "bin/python/samba/join.py", line 349, in find_dc
    (domain, error[1]))

Instead, what it should be trying to output is a more helpful message like this:
Failed to find a writeable DC for domain 'blah.dont.exist': The object name is not found.
Comment 1 Tim Beale 2019-01-17 02:52:56 UTC
Created attachment 14780 [details]
Fix backport for 4.8
Comment 2 Tim Beale 2019-01-17 02:53:20 UTC
Created attachment 14781 [details]
Backport of fix for v4.9
Comment 3 Tim Beale 2019-01-17 02:53:39 UTC
Created attachment 14782 [details]
Fix backport for v4.10
Comment 4 Douglas Bagnall 2019-01-17 04:43:35 UTC
Comment on attachment 14780 [details]
Fix backport for 4.8

The 4.8 patch is fixing one slight little thing more, importing NTSTATUSError, but that is OK.
Comment 5 Tim Beale 2019-01-17 04:52:51 UTC
Hi Karolin, patches are attached for v4.8, 4.9, and 4.10. It's just fixing up untidy error handling in a samba-tool command. Could you backport to the appropriate branches please?
Comment 6 Karolin Seeger 2019-02-05 14:26:37 UTC
(In reply to Tim Beale from comment #5)
Hi Tim,

sure. :-)
Pushed to autobuild-v4-{10,9,8}-test.
Comment 7 Karolin Seeger 2019-02-08 09:30:34 UTC
(In reply to Karolin Seeger from comment #6)
Pushed to all branches.
Closing out bug report.

Thanks!