[PATCH] don't build AD DC-specific dns and dsdb modules without AD DC

Alexander Bokovoy ab at samba.org
Sat Jul 21 10:40:25 UTC 2018


On pe, 20 heinä 2018, Jeremy Allison wrote:
> On Fri, Jul 20, 2018 at 02:43:40PM -0700, Jeremy Allison via samba-technical wrote:
> > On Fri, Jul 20, 2018 at 01:01:49PM +0300, Alexander Bokovoy via samba-technical wrote:
> > > Hi,
> > > 
> > > small patchset to make sure we don't build packages which couldn't be
> > > used without AD DC when no AD DC is compiled in.
> > 
> > LGTM. Thanks Alexander. RB+ and pushed !
> 
> Sorry Alexander, failing in autobuild with:
> 
>    samba-systemkrb5: [test] failed 'make test FAIL_IMMEDIATELY=1 TESTS='--include-env=ktest'' with status 2
> 
> [17(19)/19 at 9s] samba3.blackbox.smbclient_krb5 new ccache -e(ktest:local)
> [18(20)/19 at 9s] samba3.blackbox.smbclient_large_file -e krb5(ktest:local)
> [19(22)/19 at 13s] samba.tests.ntlmdisabled.python(ktest)(ktest)
> Traceback (most recent call last):
>   File "/memdisk/jra/a/b657055/samba-systemkrb5/source4/scripting/bin/subunitrun", line 42, in <module>
>     from samba.tests.subunitrun import TestProgram, SubunitOptions
>   File "bin/python/samba/tests/__init__.py", line 41, in <module>
>     from samba.samdb import SamDB
>   File "bin/python/samba/samdb.py", line 31, in <module>
>     from samba import dsdb, dsdb_dns
> ImportError: cannot import name dsdb
> command: PYTHONPATH=$PYTHONPATH:/memdisk/jra/a/b657055/samba-systemkrb5/python/samba/tests python /memdisk/jra/a/b657055/sam
> +ba-systemkrb5/source4/scripting/bin/subunitrun  $LOADLIST ntlmdisabled 2>&1  | /memdisk/jra/a/b657055/samba-systemkrb5/self
> +test/filter-subunit --fail-on-empty --prefix="samba.tests.ntlmdisabled.python(ktest)." --suffix="(ktest)"
> expanded command: PYTHONPATH=/memdisk/jra/a/b657055/samba-systemkrb5/bin/python:/memdisk/jra/a/b657055/samba-systemkrb5/pyth
> +on/samba/tests python /memdisk/jra/a/b657055/samba-systemkrb5/source4/scripting/bin/subunitrun  $LOADLIST ntlmdisabled 2>&1
> +  | /memdisk/jra/a/b657055/samba-systemkrb5/selftest/filter-subunit --fail-on-empty --prefix="samba.tests.ntlmdisabled.pyth
> +on(ktest)." --suffix="(ktest)"
> ERROR: Testsuite[samba.tests.ntlmdisabled.python(ktest)(ktest)]
> REASON: Exit code was 1
Thanks, Jeremy. This is due to us using samba.tests Python library for
both Samba AD DC-enabled and disabled tests. An easiest change is simply
to not fail when SamDB couldn't be imported -- in those test scenarious
we aren't callling to SamDB anyway.

A pipeline https://gitlab.com/samba-team/devel/samba/pipelines/26220496
demonstrates that it is indeed true.

New patchset is attached.
-- 
/ Alexander Bokovoy
-------------- next part --------------
>From 3b5215e86d227d0ea971822ed107ec6841a1a0a0 Mon Sep 17 00:00:00 2001
From: Alexander Bokovoy <ab at samba.org>
Date: Fri, 20 Jul 2018 12:31:20 +0300
Subject: [PATCH 1/3] s4-dns_server: Only build dns server Python code for AD
 DC

Signed-off-by: Alexander Bokovoy <ab at samba.org>
---
 source4/dns_server/wscript_build | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/source4/dns_server/wscript_build b/source4/dns_server/wscript_build
index c24f45584a4..c01e618b561 100644
--- a/source4/dns_server/wscript_build
+++ b/source4/dns_server/wscript_build
@@ -71,6 +71,8 @@ for env in bld.gen_python_environments():
     pytalloc_util = bld.pyembed_libname('pytalloc-util')
 
     bld.SAMBA_PYTHON('python_dsdb_dns',
-	         source='pydns.c',
-	         deps='samdb %s %s dnsserver_common %s' % (pyldb_util, pyrpc_util, pytalloc_util),
-	         realname='samba/dsdb_dns.so')
+                     source='pydns.c',
+                     deps='samdb %s %s dnsserver_common %s' % (
+                         pyldb_util, pyrpc_util, pytalloc_util),
+                     realname='samba/dsdb_dns.so',
+                     enabled=bld.AD_DC_BUILD_IS_ENABLED())
-- 
2.17.1


>From e6548b4359e3bf50366881b039186992aa31ccd4 Mon Sep 17 00:00:00 2001
From: Alexander Bokovoy <ab at samba.org>
Date: Fri, 20 Jul 2018 12:32:20 +0300
Subject: [PATCH 2/3] s4-dsdb: only build dsdb Python modules for AD DC

Signed-off-by: Alexander Bokovoy <ab at samba.org>
---
 source4/dsdb/wscript_build | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/source4/dsdb/wscript_build b/source4/dsdb/wscript_build
index be99e9950ef..34ba8edb44a 100644
--- a/source4/dsdb/wscript_build
+++ b/source4/dsdb/wscript_build
@@ -40,12 +40,14 @@ bld.SAMBA_MODULE('service_drepl',
 bld.SAMBA_LIBRARY('dsdb_garbage_collect_tombstones',
                   source='kcc/garbage_collect_tombstones.c',
                   deps='samdb RPC_NDR_DRSUAPI',
-                  private_library=True)
+                  private_library=True,
+                  enabled=bld.AD_DC_BUILD_IS_ENABLED())
 
 bld.SAMBA_LIBRARY('scavenge_dns_records',
                   source='kcc/scavenge_dns_records.c',
                   deps='samdb RPC_NDR_DRSUAPI dnsserver_common',
-                  private_library=True)
+                  private_library=True,
+                  enabled=bld.AD_DC_BUILD_IS_ENABLED())
 
 bld.SAMBA_MODULE('service_kcc',
 	source='kcc/kcc_service.c kcc/kcc_connection.c kcc/kcc_periodic.c kcc/kcc_drs_replica_info.c',
@@ -78,5 +80,6 @@ for env in bld.gen_python_environments():
 		# removes it so we end up with unresolved symbols.
 		deps='samdb %s dcerpc com_err %s %s dsdb_garbage_collect_tombstones scavenge_dns_records' %\
 			 (pyldb_util, pyrpc_util, pyparam_util),
-		realname='samba/dsdb.so'
-		)
+		realname='samba/dsdb.so',
+                enabled=bld.AD_DC_BUILD_IS_ENABLED()
+                )
-- 
2.17.1


>From 5b95c31ccdce94cfd315dcd41d13cc894b54e5fe Mon Sep 17 00:00:00 2001
From: Alexander Bokovoy <ab at samba.org>
Date: Sat, 21 Jul 2018 12:05:15 +0300
Subject: [PATCH 3/3] python/samba/tests: make sure samba.tests can be imported
 without SamDB

We are using samba.tests Python module __init__.py file as a catch-all
for all types of helpers. Some of these helpers are only usable with
Samba AD DC targets.

When SamDB is not available in a non-Samba AD DC target, provide a
dummy replacement that simply returns None. This allows to complete
initialization for non-Samba AD DC target tests which do not use
connect_samdb() helper.

Signed-off-by: Alexander Bokovoy <ab at samba.org>
---
 python/samba/tests/__init__.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/python/samba/tests/__init__.py b/python/samba/tests/__init__.py
index 1d507102095..dcee691e6e9 100644
--- a/python/samba/tests/__init__.py
+++ b/python/samba/tests/__init__.py
@@ -38,7 +38,12 @@ import samba.dcerpc.base
 from samba.compat import PY3, text_type
 from samba.compat import string_types
 from random import randint
-from samba.samdb import SamDB
+try:
+    from samba.samdb import SamDB
+except ImportError:
+    # We are built without samdb support,
+    # imitate it so that connect_samdb() can recover
+    SamDB = lambda *x: None
 import samba.ndr
 import samba.dcerpc.dcerpc
 import samba.dcerpc.epmapper
-- 
2.17.1



More information about the samba-technical mailing list