Some tools in Samba fail to find modules, and a missing dependency

  • Open
  • quality assurance status badge
Details
2 participants
  • Maxim Cournoyer
  • Simon Streit
Owner
unassigned
Submitted by
Simon Streit
Severity
normal
S
S
Simon Streit wrote on 3 Jan 2022 14:07
(address . bug-guix@gnu.org)
yguk0fh7ytj.fsf@netpanic.org
While experimenting with Samba, I noticed that some tools, especially
samba-tools will not run, and crash:
Toggle snippet (9 lines)
root@motor ~# samba-tool
Traceback (most recent call last):
File "/run/current-system/profile/bin/samba-tool", line 33, in <module>
from samba.netcmd.main import cmd_sambatool
File "/gnu/store/78baaab8085rd5xnfrpdkxdf07zkmin9-samba-mod-4.13.14/lib/python3.9/site-packages/samba/__init__.py", line 29, in <module>
import samba.param
ModuleNotFoundError: No module named 'talloc'

Doing more testing, other tools appear to not find the libraries they
need too. The combination is as folows:
- samba-tool, fails when tdb missing.
- samba-gpupdate Idem.
- samba_dnsupdate requires dnspython, but fails when talloc missing.
- samba_downgrade_db" fails when tdb missing.
- samba_kcc Idem.
- samba_spnupdate" Idem.
- samba_upgradedns" dns not found when talloc missing.

I prepared a small patch to wrap up the inputs appropriately. I hope it
is acceptable that they are all combined in one wrap procedure.

dnspython was added as a new input too.


Kind regards
Simon
From 201dc8e01fa4484e24b3e088ab6a4211e9839f33 Mon Sep 17 00:00:00 2001
From: Simon Streit <simon@netpanic.org>
Date: Mon, 3 Jan 2022 13:08:23 +0100
Subject: [PATCH] gnu: samba: Use PYTHONPATH.

* gnu/packages/samba.scm (samba): Use PYTHONPATH in 'wrap-program phase..
---
gnu/packages/samba.scm | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)

Toggle diff (48 lines)
diff --git a/gnu/packages/samba.scm b/gnu/packages/samba.scm
index bb5b402eee..33a39eb3be 100644
--- a/gnu/packages/samba.scm
+++ b/gnu/packages/samba.scm
@@ -235,7 +235,30 @@ (define-public samba
(lambda _
(substitute* "dynconfig/wscript"
(("bld\\.INSTALL_DIR.*") ""))
- #t)))
+ #t))
+ (add-after 'install 'wrap-program
+ ;; Some samba tools selectively fail to find talloc, tdb
+ ;; and dnspython.
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let ((out (string-append (assoc-ref outputs "out")))
+ (talloc (string-append (assoc-ref inputs "talloc")
+ "/lib/python3.9/site-packages"))
+ (tdb (string-append (assoc-ref inputs "tdb")
+ "/lib/python3.9/site-packages"))
+ (python-dnspython (string-append
+ (assoc-ref inputs "python-dnspython")
+ "/lib/python3.9/site-packages")))
+ (for-each
+ (lambda (bin)
+ (wrap-program (string-append out bin)
+ `("PYTHONPATH" prefix (,talloc ,tdb ,python-dnspython))))
+ '("/bin/samba-tool"
+ "/sbin/samba-gpupdate"
+ "/sbin/samba_dnsupdate"
+ "/sbin/samba_downgrade_db"
+ "/sbin/samba_kcc"
+ "/sbin/samba_spnupdate"
+ "/sbin/samba_upgradedns"))))))
;; FIXME: The test suite seemingly hangs after failing to provision the
;; test environment.
#:tests? #f))
@@ -258,7 +281,8 @@ (define-public samba
python
popt
readline
- tdb))
+ tdb
+ python-dnspython))
(propagated-inputs
;; In Requires or Requires.private of pkg-config files.
(list ldb talloc tevent))
--
2.34.0
M
M
Maxim Cournoyer wrote on 14 Jan 2022 04:36
(name . Simon Streit)(address . simon@netpanic.org)(address . 52976@debbugs.gnu.org)
8735lrxa2g.fsf@gmail.com
Hello Simon,

Simon Streit <simon@netpanic.org> writes:

Toggle quote (24 lines)
> While experimenting with Samba, I noticed that some tools, especially
> samba-tools will not run, and crash:
>
> root@motor ~# samba-tool
> Traceback (most recent call last):
> File "/run/current-system/profile/bin/samba-tool", line 33, in <module>
> from samba.netcmd.main import cmd_sambatool
> File "/gnu/store/78baaab8085rd5xnfrpdkxdf07zkmin9-samba-mod-4.13.14/lib/python3.9/site-packages/samba/__init__.py", line 29, in <module>
> import samba.param
> ModuleNotFoundError: No module named 'talloc'
>
> Doing more testing, other tools appear to not find the libraries they
> need too. The combination is as folows:
> - samba-tool, fails when tdb missing.
> - samba-gpupdate Idem.
> - samba_dnsupdate requires dnspython, but fails when talloc missing.
> - samba_downgrade_db" fails when tdb missing.
> - samba_kcc Idem.
> - samba_spnupdate" Idem.
> - samba_upgradedns" dns not found when talloc missing.
>
> I prepared a small patch to wrap up the inputs appropriately. I hope it
> is acceptable that they are all combined in one wrap procedure.

Thanks for testing samba!

I've updated samba recently on the version-1.4.0 branch; but the problem
probably remains (I've only tested smbd and smbclient). It's now at
version 4.15.3 and I nedded to add the python-cryptogaphy,
python-dnspython, python-markdown and python-pyasn1 as native inputs.
Based on your findings it probably should be moved to an input.

Toggle quote (21 lines)
>>From 201dc8e01fa4484e24b3e088ab6a4211e9839f33 Mon Sep 17 00:00:00 2001
> From: Simon Streit <simon@netpanic.org>
> Date: Mon, 3 Jan 2022 13:08:23 +0100
> Subject: [PATCH] gnu: samba: Use PYTHONPATH.
>
> * gnu/packages/samba.scm (samba): Use PYTHONPATH in 'wrap-program phase..
> ---
> gnu/packages/samba.scm | 28 ++++++++++++++++++++++++++--
> 1 file changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/gnu/packages/samba.scm b/gnu/packages/samba.scm
> index bb5b402eee..33a39eb3be 100644
> --- a/gnu/packages/samba.scm
> +++ b/gnu/packages/samba.scm
> @@ -235,7 +235,30 @@ (define-public samba
> (lambda _
> (substitute* "dynconfig/wscript"
> (("bld\\.INSTALL_DIR.*") ""))
> - #t)))
> + #t))

Trailing #t are no longer needed.

Toggle quote (13 lines)
> + (add-after 'install 'wrap-program
> + ;; Some samba tools selectively fail to find talloc, tdb
> + ;; and dnspython.
> + (lambda* (#:key inputs outputs #:allow-other-keys)
> + (let ((out (string-append (assoc-ref outputs "out")))
> + (talloc (string-append (assoc-ref inputs "talloc")
> + "/lib/python3.9/site-packages"))
> + (tdb (string-append (assoc-ref inputs "tdb")
> + "/lib/python3.9/site-packages"))
> + (python-dnspython (string-append
> + (assoc-ref inputs "python-dnspython")
> + "/lib/python3.9/site-packages")))

We shouldn't hard code Python versions in the paths as it'd be too prone
to break. You could probably make good use of the recently introduced
search-input-directory procedure here :-).

Toggle quote (5 lines)
> + (for-each
> + (lambda (bin)
> + (wrap-program (string-append out bin)
> + `("PYTHONPATH" prefix (,talloc ,tdb ,python-dnspython))))

Make sure to run 'guix lint', it'll probably suggest to add minimal-bash
as an input because of the use of wrap-program.

Toggle quote (21 lines)
> + '("/bin/samba-tool"
> + "/sbin/samba-gpupdate"
> + "/sbin/samba_dnsupdate"
> + "/sbin/samba_downgrade_db"
> + "/sbin/samba_kcc"
> + "/sbin/samba_spnupdate"
> + "/sbin/samba_upgradedns"))))))
> ;; FIXME: The test suite seemingly hangs after failing to provision the
> ;; test environment.
> #:tests? #f))
> @@ -258,7 +281,8 @@ (define-public samba
> python
> popt
> readline
> - tdb))
> + tdb
> + python-dnspython))
> (propagated-inputs
> ;; In Requires or Requires.private of pkg-config files.
> (list ldb talloc tevent))

Otherwise it LGTM. Could you try to rebase this patch on top of the
version-1.4.0 branch? Otherwise, wait a few days and it should be
merged into master.

Thank you!

Maxim
S
S
Simon Streit wrote on 17 Jan 2022 14:10
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(address . 52976@debbugs.gnu.org)
ygumtjumrs3.fsf@netpanic.org
Hello Maxim,

thanks for having look at my patch.

Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:

Toggle quote (4 lines)
> We shouldn't hard code Python versions in the paths as it'd be too prone
> to break. You could probably make good use of the recently introduced
> search-input-directory procedure here :-).

I tried your suggestion, but unfortunately my attempt with modifying
the lines to as such:
Toggle snippet (10 lines)
(talloc (string-append
(search-input-directory inputs
"/lib/python3.9/site-packages")))
(tdb (string-append
(search-input-directory inputs
"/lib/python3.9/site-packages")))
(python-dnspython (string-append
(search-input-directory inputs
"/lib/python3.9/site-packages")))
compiles to a package. But ‘samba-tools’ fails again.

It is not quite clear to me now why this method is better? Is hard
coding being avoid now? Should I avoid the ‘3.9’ in the search path?
Sorry that I have to ask for an explanation.

And while we are at it. I noticed that you have already replaced
heimdal with mit-krb5, which I had done personally already without
proposing it yet. Thanks for that.

Point is that I was trying to pull up an AD DC, which is why I run these
problems.

And then, can I ask you to add avahi to inputs? Since some time Samba
has disabled SMBv1, which means host discovery with NetBIOS doesn’t work
any more. Now it is best to have Avahi running alongside Samba hosts,
so that Samba can publish it’s service over multicast. No extra
configuration is needed for this.

This doesn’t help much for Windows hosts though. I’ve already packaged
wsdd [1], and have prepared a service, which I haven’t made public
either yet. I haven’t completed the documentation for info so far.
Should really finish it now.

I will open another issue for this later, and will not hijack this
thread for it.


Kind regards
Simon


S
S
Simon Streit wrote on 17 Jan 2022 16:53
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(address . 52976@debbugs.gnu.org)
ygulezez7cu.fsf@netpanic.org
Simon Streit <simon@netpanic.org> writes:
Toggle quote (2 lines)
> compiles to a package. But ‘samba-tools’ fails again.

Just a quick follow up, samba-tools fails with ldb being missing:
Toggle snippet (3 lines)
ModuleNotFoundError: No module named 'ldb'

I put ldb into inputs, and wrapped it as well. That didn't help.


Kind regards
Simon
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 52976@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 52976
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch