Bug 13881 - samba-tool domain level show crash
Summary: samba-tool domain level show crash
Status: RESOLVED WORKSFORME
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Tools (show other bugs)
Version: 4.8.3
Hardware: x86 Linux
: P5 normal (vote)
Target Milestone: ---
Assignee: Jo Sutton
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-03 06:59 UTC by Amit Kumar
Modified: 2022-08-31 09:40 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Amit Kumar 2019-04-03 06:59:29 UTC
Fedora-28 box:

Joined to ad using 'net ads join -U <>'
# net ads testjoin
Join is OK

# samba-tool domain level show
ERROR(ldb): uncaught exception - ldb_search: invalid basedn '(null)'
  File "/usr/lib64/python2.7/site-packages/samba/netcmd/__init__.py", line 176, in _run
    return self.run(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/samba/netcmd/domain.py", line 1055, in run
    scope=ldb.SCOPE_BASE, attrs=["msDS-Behavior-Version"])
# samba-tool domain level raise --domain-level=2012_R2 --forest-level=2012_R2
ERROR(ldb): uncaught exception - ldb_search: invalid basedn '(null)'
  File "/usr/lib64/python2.7/site-packages/samba/netcmd/__init__.py", line 176, in _run
    return self.run(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/samba/netcmd/domain.py", line 1055, in run
    scope=ldb.SCOPE_BASE, attrs=["msDS-Behavior-Version"])


On Window's 2008 AD:
PS C:\Users\root.ATEST> $dse = ([ADSI] "LDAP://RootDSE")
PS C:\Users\root.ATEST>
PS C:\Users\root.ATEST> # Domain Controller Functional Level
PS C:\Users\root.ATEST> $dse.domainControllerFunctionality
4
PS C:\Users\root.ATEST>
PS C:\Users\root.ATEST> # Domain Functional Level
PS C:\Users\root.ATEST> $dse.domainFunctionality
4
PS C:\Users\root.ATEST>
PS C:\Users\root.ATEST> # Forest Functional Level
PS C:\Users\root.ATEST> $dse.forestFunctionalit

Even # man samba-tool does not guides how to use 'domain level show|raise' correctly. What are prerequisites of using it.
Comment 1 Rowland Penny 2020-12-28 21:23:22 UTC
This isn't really a samba-tool problem, it is a samba-tool command misconfiguration, not helped by the fact that the samba-tool manpage doesn't mention '-H URL, --URL=URL'. The lack of the URL is why Amit's attempt to use 'samba-tool domain level show' failed.

The fix would have been to run 'samba-tool domain level show --help' which would have shown (amongst others) this:

  -H URL, --URL=URL     LDB URL for database or target server

However, the samba-tool manpage does need fixing.
Comment 2 Andrew Bartlett 2021-03-18 22:41:17 UTC
It should now show an error failing to open the (default to local) DB file, rather than creating an empty file and then spewing silly errors from that.
Comment 3 Douglas Bagnall 2022-08-31 03:18:37 UTC
(In reply to Andrew Bartlett from comment #2)
> It should now show an error failing to open the (default to local) DB file, rather than creating an empty file and then spewing silly errors from that.


I think Andrew refers to https://gitlab.com/samba-team/samba/-/commit/7009479b7a91715543e228412435ab2fdb6221ae which is 4.9-ish, and from his description, it does not constitute much of a fix.

but Rowland, you're suggesting in https://lists.samba.org/archive/samba-technical/2022-August/137560.html that the old behaviour persists? Clearly you're not running 4.8.

> Running: sudo samba-tool domain level show -d0
> 
> Gets you:
> 
> ERROR(ldb): uncaught exception - ldb_search: invalid basedn '(null)'
>    File "/usr/lib/python3/dist-packages/samba/netcmd/__init__.py", line
> 186, in _run
>      return self.run(*args, **kwargs)
>    File "/usr/lib/python3/dist-packages/samba/netcmd/domain.py", line
> 1051, in run
>      scope=ldb.SCOPE_BASE, attrs=["msDS-Behavior-Version"])

Could you add 

     print(lp.samdb_url())

to /usr/lib/python3/dist-packages/samba/netcmd/domain.py, a few lines up from that, before samdb = SamDB(...)?


I haven't managed to replicate this in a testenv. All kinds of other uncaught exceptions.
Comment 4 Rowland Penny 2022-08-31 07:13:16 UTC
(In reply to Douglas Bagnall from comment #3)
Er, no, I am running a much later version, but I was aware of this bug and you asked for samba-tool bugs to fix.
If it was fixed (even if it wasn't much of a fix), Andrew should have closed this bug.
Comment 5 Björn Jacke 2022-08-31 09:40:52 UTC
never was an issue for me either. Also no more feedback from the initial reporter. Closing now.