From 8244b4c0717b64b9effc27781f3d05fd816c5e5e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 12 Feb 2008 00:35:11 +0100 Subject: Manually compile python files rather than using setup.py. (This used to be commit 94dfeb5e89a641e2af3d7426d9d25c87952198d2) --- source4/lib/tdb/Makefile.in | 5 ++++- source4/lib/tdb/configure.ac | 4 ++++ source4/lib/tdb/setup.py | 11 ----------- source4/lib/tdb/tdb.mk | 18 ++++++++++-------- 4 files changed, 18 insertions(+), 20 deletions(-) delete mode 100755 source4/lib/tdb/setup.py diff --git a/source4/lib/tdb/Makefile.in b/source4/lib/tdb/Makefile.in index 9730dffe60..f900469afa 100644 --- a/source4/lib/tdb/Makefile.in +++ b/source4/lib/tdb/Makefile.in @@ -22,8 +22,11 @@ PACKAGE_VERSION = @PACKAGE_VERSION@ PICFLAG = @PICFLAG@ SHLIBEXT = @SHLIBEXT@ SWIG = swig +PYTHON_CONFIG = @PYTHON_CONFIG@ PYTHON_BUILD_TARGET = @PYTHON_BUILD_TARGET@ PYTHON_INSTALL_TARGET = @PYTHON_INSTALL_TARGET@ +PYTHON_CHECK_TARGET = @PYTHON_CHECK_TARGET@ +LIB_PATH_VAR = @LIB_PATH_VAR@ tdbdir = @tdbdir@ TDB_OBJ = @TDB_OBJ@ @LIBREPLACEOBJ@ @@ -39,7 +42,7 @@ $(SOLIB): $(TDB_OBJ) check: test -test:: +test:: $(PYTHON_CHECK_TARGET) installcheck:: test install clean:: diff --git a/source4/lib/tdb/configure.ac b/source4/lib/tdb/configure.ac index 5747107f38..36d409ac11 100644 --- a/source4/lib/tdb/configure.ac +++ b/source4/lib/tdb/configure.ac @@ -11,15 +11,19 @@ AC_LD_PICFLAG AC_LD_SHLIBEXT AC_LIBREPLACE_SHLD AC_LIBREPLACE_SHLD_FLAGS +AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR m4_include(libtdb.m4) AC_PATH_PROGS([PYTHON_CONFIG], [python2.6-config python2.5-config python2.4-config python-config]) PYTHON_BUILD_TARGET="build-python" PYTHON_INSTALL_TARGET="install-python" +PYTHON_CHECK_TARGET="check-python" AC_SUBST(PYTHON_BUILD_TARGET) AC_SUBST(PYTHON_INSTALL_TARGET) +AC_SUBST(PYTHON_CHECK_TARGET) if test -z "$PYTHON_CONFIG"; then PYTHON_BUILD_TARGET="" PYTHON_INSTALL_TARGET="" + PYTHON_CHECK_TARGET="" fi AC_OUTPUT(Makefile tdb.pc) diff --git a/source4/lib/tdb/setup.py b/source4/lib/tdb/setup.py deleted file mode 100755 index 8be0c67e0b..0000000000 --- a/source4/lib/tdb/setup.py +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/python -from distutils.core import setup -from distutils.extension import Extension - -setup(name='tdb', - version='1.0', - url="http://tdb.samba.org/", - py_modules=["tdb"], - ext_modules=[Extension('_tdb', ['tdb_wrap.c'], include_dirs=['include'], - library_dirs=["."], libraries=['tdb'])], -) diff --git a/source4/lib/tdb/tdb.mk b/source4/lib/tdb/tdb.mk index d6118dd38f..10b7c6a92d 100644 --- a/source4/lib/tdb/tdb.mk +++ b/source4/lib/tdb/tdb.mk @@ -33,8 +33,13 @@ clean:: rm -f $(SONAME) $(SOLIB) libtdb.a libtdb.$(SHLIBEXT) rm -f $(ALL_PROGS) tdb.pc -build-python:: libtdb.$(SHLIBEXT) tdb_wrap.c - $(tdbdir)/setup.py build +build-python:: _tdb.$(SHLIBEXT) + +tdb_wrap.o: tdb_wrap.c + $(CC) -c $< $(CFLAGS) `$(PYTHON_CONFIG) --cflags` + +_tdb.$(SHLIBEXT): libtdb.$(SHLIBEXT) tdb_wrap.o + $(SHLD) $(SHLD_FLAGS) -o $@ tdb_wrap.o -L. -ltdb `$(PYTHON_CONFIG) --libs` install:: installdirs installbin installheaders installlibs \ $(PYTHON_INSTALL_TARGET) @@ -43,15 +48,14 @@ installpython:: build-python ./setup.py install --prefix=$(DESTDIR)$(prefix) check-python:: build-python - # FIXME: Should be more portable: - LD_LIBRARY_PATH=. PYTHONPATH=.:build/lib.linux-i686-2.4 trial python/tests/simple.py + $(LIB_PATH_VAR)=. PYTHONPATH=".:$(tdbdir)" trial $(tdbdir)/python/tests/simple.py install-swig:: mkdir -p $(DESTDIR)`$(SWIG) -swiglib` cp tdb.i $(DESTDIR)`$(SWIG) -swiglib` -clean-python:: - ./setup.py clean +clean:: + rm -f _tdb.$(SHLIBEXT) installdirs:: mkdir -p $(DESTDIR)$(bindir) @@ -77,5 +81,3 @@ libtdb.$(SHLIBEXT): $(SOLIB) $(SONAME): $(SOLIB) ln -fs $< $@ - - -- cgit From aa2fd8ee50d8e416a503fb920f0195cd89c4c93b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 12 Feb 2008 00:49:36 +0100 Subject: Manually compile python files rather than use setup.py. (This used to be commit 056843a5c2ca9e0ec59fd7e371852ecb5362ee32) --- source4/lib/ldb/Makefile.in | 3 ++- source4/lib/ldb/configure.ac | 3 +++ source4/lib/ldb/ldb.mk | 16 ++++++++++------ source4/lib/ldb/setup.py | 15 --------------- 4 files changed, 15 insertions(+), 22 deletions(-) delete mode 100755 source4/lib/ldb/setup.py diff --git a/source4/lib/ldb/Makefile.in b/source4/lib/ldb/Makefile.in index 738ffe1adb..d3e027425b 100644 --- a/source4/lib/ldb/Makefile.in +++ b/source4/lib/ldb/Makefile.in @@ -19,6 +19,7 @@ SWIG = swig EXTRA_OBJ=@EXTRA_OBJ@ TESTS=test-tdb.sh @TESTS@ PACKAGE_VERSION = @PACKAGE_VERSION@ +PYTHON_CONFIG = @PYTHON_CONFIG@ tdbdir = @tdbdir@ ldbdir = $(srcdir) tallocdir = @tallocdir@ @@ -121,7 +122,7 @@ distclean:: clean realdistclean:: distclean rm -f configure.in include/config.h.in -check:: test +check:: test @PYTHON_CHECK_TARGET@ check-soloading: sample_module.$(SHLIBEXT) LDB_MODULES_PATH=$(builddir) $(srcdir)/tests/test-soloading.sh diff --git a/source4/lib/ldb/configure.ac b/source4/lib/ldb/configure.ac index 176cef0f3e..1435536373 100644 --- a/source4/lib/ldb/configure.ac +++ b/source4/lib/ldb/configure.ac @@ -81,11 +81,14 @@ AC_PATH_PROGS([PYTHON_CONFIG], [python2.6-config python2.5-config python2.4-conf PYTHON_BUILD_TARGET="build-python" PYTHON_INSTALL_TARGET="install-python" +PYTHON_CHECK_TARGET="check-python" AC_SUBST(PYTHON_BUILD_TARGET) AC_SUBST(PYTHON_INSTALL_TARGET) +AC_SUBST(PYTHON_CHECK_TARGET) if test -z "$PYTHON_CONFIG"; then PYTHON_BUILD_TARGET="" + PYTHON_CHECK_TARGET="" PYTHON_INSTALL_TARGET="" fi diff --git a/source4/lib/ldb/ldb.mk b/source4/lib/ldb/ldb.mk index b9aa24b276..69c1bf6ad9 100644 --- a/source4/lib/ldb/ldb.mk +++ b/source4/lib/ldb/ldb.mk @@ -65,8 +65,13 @@ examples/ldifreader: examples/ldifreader.o $(LIBS) $(CC) -o examples/ldifreader examples/ldifreader.o $(LIB_FLAGS) # Python bindings -build-python:: lib/libldb.$(SHLIBEXT) ldb_wrap.c - $(ldbdir)/setup.py build +build-python:: _ldb.$(SHLIBEXT) + +ldb_wrap.o: $(ldbdir)/ldb_wrap.c + $(CC) -c $(ldbdir)/ldb_wrap.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags` + +_ldb.$(SHLIBEXT): $(LIBS) ldb_wrap.o + $(SHLD) $(SHLD_FLAGS) -o _ldb.$(SHLIBEXT) ldb_wrap.o $(LIB_FLAGS) install-python:: build-python $(ldbdir)/setup.py install --prefix=$(DESTDIR)$(prefix) @@ -75,8 +80,7 @@ install-swig:: cp ldb.i `$(SWIG) -swiglib` check-python:: build-python - # FIXME: This isn't portable - LD_LIBRARY_PATH=lib PYTHONPATH=.:build/lib.linux-i686-2.4/ trial tests/python/api.py + LD_LIBRARY_PATH=lib PYTHONPATH=.:$(ldbdir) trial $(ldbdir)/tests/python/api.py -clean-python:: - $(ldbdir)/setup.py clean +clean:: + rm -f _ldb.$(SHLIBEXT) diff --git a/source4/lib/ldb/setup.py b/source4/lib/ldb/setup.py deleted file mode 100755 index b04f3b09f1..0000000000 --- a/source4/lib/ldb/setup.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/python -from distutils.core import setup -from distutils.extension import Extension - -setup(name="ldb", - version="1.0", - url="http://ldb.samba.org/", - author="LDB Developers", - author_email="ldb@samba.org", - license="LGPLv3", - keywords=["ldap","ldb","db","ldif"], - py_modules=["ldb"], - ext_modules=[Extension('_ldb', ['ldb_wrap.c'], include_dirs=['include'], - library_dirs=["lib"], libraries=['ldb'])], - ) -- cgit From 1529331b97cc67869f07c2cfa8c73616f3247b73 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 12 Feb 2008 01:21:10 +0100 Subject: Avoid using setup.py for intsallation. (This used to be commit 7b93e43dad55454e9107a38e67764e08f51392d3) --- source4/lib/ldb/configure.ac | 1 + source4/lib/ldb/ldb.mk | 5 +++-- source4/lib/ldb/tests/python/api.py | 3 +++ source4/lib/tdb/Makefile.in | 1 + source4/lib/tdb/configure.ac | 1 + source4/lib/tdb/python/tests/simple.py | 5 +++++ source4/lib/tdb/tdb.mk | 11 ++++++----- 7 files changed, 20 insertions(+), 7 deletions(-) diff --git a/source4/lib/ldb/configure.ac b/source4/lib/ldb/configure.ac index 1435536373..4d9444ad10 100644 --- a/source4/lib/ldb/configure.ac +++ b/source4/lib/ldb/configure.ac @@ -78,6 +78,7 @@ AC_LIBREPLACE_MDLD_FLAGS AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR AC_PATH_PROGS([PYTHON_CONFIG], [python2.6-config python2.5-config python2.4-config python-config]) +AC_PATH_PROGS([PYTHON], [python2.6 python2.5 python2.4 python]) PYTHON_BUILD_TARGET="build-python" PYTHON_INSTALL_TARGET="install-python" diff --git a/source4/lib/ldb/ldb.mk b/source4/lib/ldb/ldb.mk index 69c1bf6ad9..6d0ad44d38 100644 --- a/source4/lib/ldb/ldb.mk +++ b/source4/lib/ldb/ldb.mk @@ -74,13 +74,14 @@ _ldb.$(SHLIBEXT): $(LIBS) ldb_wrap.o $(SHLD) $(SHLD_FLAGS) -o _ldb.$(SHLIBEXT) ldb_wrap.o $(LIB_FLAGS) install-python:: build-python - $(ldbdir)/setup.py install --prefix=$(DESTDIR)$(prefix) + cp $(ldbdir)/ldb.py $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0)"` + cp _ldb.$(SHLIBEXT) $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1)"` install-swig:: cp ldb.i `$(SWIG) -swiglib` check-python:: build-python - LD_LIBRARY_PATH=lib PYTHONPATH=.:$(ldbdir) trial $(ldbdir)/tests/python/api.py + LD_LIBRARY_PATH=lib PYTHONPATH=.:$(ldbdir) $(PYTHON) $(ldbdir)/tests/python/api.py clean:: rm -f _ldb.$(SHLIBEXT) diff --git a/source4/lib/ldb/tests/python/api.py b/source4/lib/ldb/tests/python/api.py index d5346c30b0..5f3f727b5d 100755 --- a/source4/lib/ldb/tests/python/api.py +++ b/source4/lib/ldb/tests/python/api.py @@ -418,3 +418,6 @@ class ModuleTests(unittest.TestCase): def test_register_module(self): ldb.register_module(ExampleModule()) +if __name__ == '__main__': + import unittest + unittest.TestProgram() diff --git a/source4/lib/tdb/Makefile.in b/source4/lib/tdb/Makefile.in index f900469afa..8c79f6e24c 100644 --- a/source4/lib/tdb/Makefile.in +++ b/source4/lib/tdb/Makefile.in @@ -22,6 +22,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@ PICFLAG = @PICFLAG@ SHLIBEXT = @SHLIBEXT@ SWIG = swig +PYTHON = @PYTHON@ PYTHON_CONFIG = @PYTHON_CONFIG@ PYTHON_BUILD_TARGET = @PYTHON_BUILD_TARGET@ PYTHON_INSTALL_TARGET = @PYTHON_INSTALL_TARGET@ diff --git a/source4/lib/tdb/configure.ac b/source4/lib/tdb/configure.ac index 36d409ac11..9b16a82c33 100644 --- a/source4/lib/tdb/configure.ac +++ b/source4/lib/tdb/configure.ac @@ -14,6 +14,7 @@ AC_LIBREPLACE_SHLD_FLAGS AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR m4_include(libtdb.m4) AC_PATH_PROGS([PYTHON_CONFIG], [python2.6-config python2.5-config python2.4-config python-config]) +AC_PATH_PROGS([PYTHON], [python2.6 python2.5 python2.4 python]) PYTHON_BUILD_TARGET="build-python" PYTHON_INSTALL_TARGET="install-python" diff --git a/source4/lib/tdb/python/tests/simple.py b/source4/lib/tdb/python/tests/simple.py index 1cc51aea07..94407b6398 100644 --- a/source4/lib/tdb/python/tests/simple.py +++ b/source4/lib/tdb/python/tests/simple.py @@ -142,3 +142,8 @@ class SimpleTdbTests(TestCase): self.assertEquals(0, len(self.tdb)) self.tdb["entry"] = "value" self.assertEquals(1, len(self.tdb)) + + +if __name__ == '__main__': + import unittest + unittest.TestProgram() diff --git a/source4/lib/tdb/tdb.mk b/source4/lib/tdb/tdb.mk index 10b7c6a92d..976589fd0f 100644 --- a/source4/lib/tdb/tdb.mk +++ b/source4/lib/tdb/tdb.mk @@ -35,8 +35,8 @@ clean:: build-python:: _tdb.$(SHLIBEXT) -tdb_wrap.o: tdb_wrap.c - $(CC) -c $< $(CFLAGS) `$(PYTHON_CONFIG) --cflags` +tdb_wrap.o: $(tdbdir)/tdb_wrap.c + $(CC) -c $(tdbdir)/tdb_wrap.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags` _tdb.$(SHLIBEXT): libtdb.$(SHLIBEXT) tdb_wrap.o $(SHLD) $(SHLD_FLAGS) -o $@ tdb_wrap.o -L. -ltdb `$(PYTHON_CONFIG) --libs` @@ -44,11 +44,12 @@ _tdb.$(SHLIBEXT): libtdb.$(SHLIBEXT) tdb_wrap.o install:: installdirs installbin installheaders installlibs \ $(PYTHON_INSTALL_TARGET) -installpython:: build-python - ./setup.py install --prefix=$(DESTDIR)$(prefix) +install-python:: build-python + cp $(tdbdir)/tdb.py $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0)"` + cp _tdb.$(SHLIBEXT) $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1)"` check-python:: build-python - $(LIB_PATH_VAR)=. PYTHONPATH=".:$(tdbdir)" trial $(tdbdir)/python/tests/simple.py + $(LIB_PATH_VAR)=. PYTHONPATH=".:$(tdbdir)" $(PYTHON) $(tdbdir)/python/tests/simple.py install-swig:: mkdir -p $(DESTDIR)`$(SWIG) -swiglib` -- cgit From 0f4c940919de6203595b8eaeb12eb9c2ea887f8c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 12 Feb 2008 01:39:31 +0100 Subject: Add blackbox test for provisioning code to make sure it can be run more than once in a row. (This used to be commit 42466d960c86b692ef5e03c045ba24591c5c6f84) --- source4/selftest/samba4_tests.sh | 2 +- source4/setup/tests/blackbox_provision.sh | 39 +++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100755 source4/setup/tests/blackbox_provision.sh diff --git a/source4/selftest/samba4_tests.sh b/source4/selftest/samba4_tests.sh index fba9e8603e..f2895304cf 100755 --- a/source4/selftest/samba4_tests.sh +++ b/source4/selftest/samba4_tests.sh @@ -327,5 +327,5 @@ then rm -rf $PREFIX/upgrade plantest "blackbox.upgrade" none $PYTHON setup/upgrade.py $CONFIGURATION --targetdir=$PREFIX/upgrade ../testdata/samba3 ../testdata/samba3/smb.conf rm -rf $PREFIX/provision - plantest "blackbox.provision.py" none $PYTHON ./setup/provision.py $CONFIGURATION --domain=FOO --realm=foo.example.com --targetdir=$PREFIX/provision + plantest "blackbox.provision.py" none PYTHON="$PYTHON" $samba4srcdir/setup/tests/blackbox_provision.sh "$PREFIX" "$CONFIGURATION" fi diff --git a/source4/setup/tests/blackbox_provision.sh b/source4/setup/tests/blackbox_provision.sh new file mode 100755 index 0000000000..57b11eae5f --- /dev/null +++ b/source4/setup/tests/blackbox_provision.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +if [ $# -lt 2 ]; then +cat < Date: Tue, 12 Feb 2008 01:42:58 +0100 Subject: Reintroduce samba3sam EJS test, at least until the Python test is ready. (This used to be commit 13deb25214b2711836e243a87166b63a4a87270b) --- source4/selftest/samba4_tests.sh | 2 + testprogs/ejs/samba3sam.js | 1255 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 1257 insertions(+) create mode 100644 testprogs/ejs/samba3sam.js diff --git a/source4/selftest/samba4_tests.sh b/source4/selftest/samba4_tests.sh index f2895304cf..8296633137 100755 --- a/source4/selftest/samba4_tests.sh +++ b/source4/selftest/samba4_tests.sh @@ -262,6 +262,8 @@ done DATADIR=$samba4srcdir/../testdata +plantest "js.samba3sam" none $SCRIPTDIR/samba3sam.js $CONFIGURATION `pwd` $DATADIR/samba3/ + # Domain Member Tests plantest "RPC-ECHO against member server with local creds" member $VALGRIND $smb4torture ncacn_np:"\$NETBIOSNAME" -U"\$NETBIOSNAME/\$USERNAME"%"\$PASSWORD" RPC-ECHO "$*" diff --git a/testprogs/ejs/samba3sam.js b/testprogs/ejs/samba3sam.js new file mode 100644 index 0000000000..e5639b8ec8 --- /dev/null +++ b/testprogs/ejs/samba3sam.js @@ -0,0 +1,1255 @@ +#!/usr/bin/env smbscript +/* + (C) Jelmer Vernooij 2005 + (C) Martin Kuehl 2006 + Published under the GNU GPL + Sponsored by Google Summer of Code + */ + +var sys; +var options = GetOptions(ARGV, "POPT_AUTOHELP", "POPT_COMMON_SAMBA"); +if (options == undefined) { + println("Failed to parse options"); + return -1; +} + +libinclude("base.js"); + +if (options.ARGV.length != 2) { + println("Usage: samba3sam.js "); + return -1; +} + +var prefix = options.ARGV[0]; +var datadir = options.ARGV[1]; + +function setup_data(obj, ldif) +{ + assert(ldif != undefined); + ldif = substitute_var(ldif, obj); + assert(ldif != undefined); + var ok = obj.db.add(ldif); + assert(ok.error == 0); +} + +function setup_modules(ldb, s3, s4, ldif) +{ + assert(ldif != undefined); + ldif = substitute_var(ldif, s4); + assert(ldif != undefined); + var ok = ldb.add(ldif); + assert(ok.error == 0); + + var ldif = " +dn: @MAP=samba3sam +@FROM: " + s4.BASEDN + " +@TO: sambaDomainName=TESTS," + s3.BASEDN + " + +dn: @MODULES +@LIST: rootdse,paged_results,server_sort,extended_dn,asq,samldb,password_hash,operational,objectguid,rdn_name,samba3sam,partition + +dn: @PARTITION +partition: " + s4.BASEDN + ":" + s4.url + " +partition: " + s3.BASEDN + ":" + s3.url + " +replicateEntries: @SUBCLASSES +replicateEntries: @ATTRIBUTES +replicateEntries: @INDEXLIST +"; + var ok = ldb.add(ldif); + assert(ok.error == 0); +} + +function test_s3sam_search(ldb) +{ + println("Looking up by non-mapped attribute"); + var msg = ldb.search("(cn=Administrator)"); + assert(msg.error == 0); + assert(msg.msgs.length == 1); + assert(msg.msgs[0].cn == "Administrator"); + + println("Looking up by mapped attribute"); + var msg = ldb.search("(name=Backup Operators)"); + assert(msg.error == 0); + assert(msg.msgs.length == 1); + assert(msg.msgs[0].name == "Backup Operators"); + + println("Looking up by old name of renamed attribute"); + var msg = ldb.search("(displayName=Backup Operators)"); + assert(msg.msgs.length == 0); + + println("Looking up mapped entry containing SID"); + var msg = ldb.search("(cn=Replicator)"); + assert(msg.error == 0); + assert(msg.msgs.length == 1); + println(msg.msgs[0].dn); + assert(msg.msgs[0].dn == "cn=Replicator,ou=Groups,dc=vernstok,dc=nl"); + assert(msg.msgs[0].objectSid == "S-1-5-21-4231626423-2410014848-2360679739-552"); + + println("Checking mapping of objectClass"); + var oc = msg.msgs[0].objectClass; + assert(oc != undefined); + for (var i in oc) { + assert(oc[i] == "posixGroup" || oc[i] == "group"); + } + + println("Looking up by objectClass"); + var msg = ldb.search("(|(objectClass=user)(cn=Administrator))"); + assert(msg.error == 0); + assert(msg.msgs.length == 2); + for (var i = 0; i < msg.msgs.length; i++) { + assert((msg.msgs[i].dn == "unixName=Administrator,ou=Users,dc=vernstok,dc=nl") || + (msg.msgs[i].dn == "unixName=nobody,ou=Users,dc=vernstok,dc=nl")); + } +} + +function test_s3sam_modify(ldb, s3) +{ + var msg, ok; + println("Adding a record that will be fallbacked"); + ok = ldb.add(" +dn: cn=Foo +foo: bar +blah: Blie +cn: Foo +showInAdvancedViewOnly: TRUE +"); + if (ok.error != 0) { + println(ok.errstr); + assert(ok.error == 0); + } + + println("Checking for existence of record (local)"); + /* TODO: This record must be searched in the local database, which is currently only supported for base searches + * msg = ldb.search("(cn=Foo)", new Array('foo','blah','cn','showInAdvancedViewOnly')); + * TODO: Actually, this version should work as well but doesn't... + * + */ + var attrs = new Array('foo','blah','cn','showInAdvancedViewOnly'); + msg = ldb.search("(cn=Foo)", "cn=Foo", ldb.LDB_SCOPE_BASE, attrs); + assert(msg.error == 0); + assert(msg.msgs.length == 1); + assert(msg.msgs[0].showInAdvancedViewOnly == "TRUE"); + assert(msg.msgs[0].foo == "bar"); + assert(msg.msgs[0].blah == "Blie"); + + println("Adding record that will be mapped"); + ok = ldb.add(" +dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl +objectClass: user +unixName: bin +sambaUnicodePwd: geheim +cn: Niemand +"); + if (ok.error != 0) { + println(ok.errstr); + assert(ok.error == 0); + } + assert(ok.error == 0); + + println("Checking for existence of record (remote)"); + msg = ldb.search("(unixName=bin)", new Array('unixName','cn','dn', 'sambaUnicodePwd')); + assert(msg.error == 0); + assert(msg.msgs.length == 1); + assert(msg.msgs[0].cn == "Niemand"); + assert(msg.msgs[0].sambaUnicodePwd == "geheim"); + + println("Checking for existence of record (local && remote)"); + msg = ldb.search("(&(unixName=bin)(sambaUnicodePwd=geheim))", new Array('unixName','cn','dn', 'sambaUnicodePwd')); + assert(msg.error == 0); + assert(msg.msgs.length == 1); // TODO: should check with more records + assert(msg.msgs[0].cn == "Niemand"); + assert(msg.msgs[0].unixName == "bin"); + assert(msg.msgs[0].sambaUnicodePwd == "geheim"); + + println("Checking for existence of record (local || remote)"); + msg = ldb.search("(|(unixName=bin)(sambaUnicodePwd=geheim))", new Array('unixName','cn','dn', 'sambaUnicodePwd')); + println("got " + msg.msgs.length + " replies"); + assert(msg.error == 0); + assert(msg.msgs.length == 1); // TODO: should check with more records + assert(msg.msgs[0].cn == "Niemand"); + assert(msg.msgs[0].unixName == "bin" || msg.msgs[0].sambaUnicodePwd == "geheim"); + + println("Checking for data in destination database"); + msg = s3.db.search("(cn=Niemand)"); + assert(msg.error == 0); + assert(msg.msgs.length >= 1); + assert(msg.msgs[0].sambaSID == "S-1-5-21-4231626423-2410014848-2360679739-2001"); + assert(msg.msgs[0].displayName == "Niemand"); + + println("Adding attribute..."); + ok = ldb.modify(" +dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl +changetype: modify +add: description +description: Blah +"); + if (ok.error != 0) { + println(ok.errstr); + assert(ok.error == 0); + } + assert(ok.error == 0); + + println("Checking whether changes are still there..."); + msg = ldb.search("(cn=Niemand)"); + assert(msg.error == 0); + assert(msg.msgs.length >= 1); + assert(msg.msgs[0].cn == "Niemand"); + assert(msg.msgs[0].description == "Blah"); + + println("Modifying attribute..."); + ok = ldb.modify(" +dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl +changetype: modify +replace: description +description: Blie +"); + if (ok.error != 0) { + println(ok.errstr); + assert(ok.error == 0); + } + assert(ok.error == 0); + + println("Checking whether changes are still there..."); + msg = ldb.search("(cn=Niemand)"); + assert(msg.error == 0); + assert(msg.msgs.length >= 1); + assert(msg.msgs[0].description == "Blie"); + + println("Deleting attribute..."); + ok = ldb.modify(" +dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl +changetype: modify +delete: description +"); + if (ok.error != 0) { + println(ok.errstr); + assert(ok.error == 0); + } + assert(ok.error == 0); + + println("Checking whether changes are no longer there..."); + msg = ldb.search("(cn=Niemand)"); + assert(msg.error == 0); + assert(msg.msgs.length >= 1); + assert(msg.msgs[0].description == undefined); + + println("Renaming record..."); + ok = ldb.rename("cn=Niemand,cn=Users,dc=vernstok,dc=nl", "cn=Niemand2,cn=Users,dc=vernstok,dc=nl"); + assert(ok.error == 0); + + println("Checking whether DN has changed..."); + msg = ldb.search("(cn=Niemand2)"); + assert(msg.error == 0); + assert(msg.msgs.length == 1); + assert(msg.msgs[0].dn == "cn=Niemand2,cn=Users,dc=vernstok,dc=nl"); + + println("Deleting record..."); + ok = ldb.del("cn=Niemand2,cn=Users,dc=vernstok,dc=nl"); + if (ok.error != 0) { + println(ok.errstr); + assert(ok.error == 0); + } + + println("Checking whether record is gone..."); + msg = ldb.search("(cn=Niemand2)"); + assert(msg.error == 0); + assert(msg.msgs.length == 0); +} + +function test_map_search(ldb, s3, s4) +{ + println("Running search tests on mapped data"); + var res; + var dn; + var attrs; + + + var ldif = " +dn: " + "sambaDomainName=TESTS," + s3.BASEDN + " +objectclass: sambaDomain +objectclass: top +sambaSID: S-1-5-21-4231626423-2410014848-2360679739 +sambaNextRid: 2000 +sambaDomainName: TESTS" + ldif = substitute_var(ldif, s3); + assert(ldif != undefined); + var ok = s3.db.add(ldif); + assert(ok.error == 0); + + printf("Add a set of split records"); + var ldif = " +dn: " + s4.dn("cn=X") + " +objectClass: user +cn: X +codePage: x +revision: x +dnsHostName: x +nextRid: y +lastLogon: x +description: x +objectSid: S-1-5-21-4231626423-2410014848-2360679739-552 +primaryGroupID: 1-5-21-4231626423-2410014848-2360679739-512 + +dn: " + s4.dn("cn=Y") + " +objectClass: top +cn: Y +codePage: x +revision: x +dnsHostName: y +nextRid: y +lastLogon: y +description: x + +dn: " + s4.dn("cn=Z") + " +objectClass: top +cn: Z +codePage: x +revision: y +dnsHostName: z +nextRid: y +lastLogon: z +description: y +"; + + ldif = substitute_var(ldif, s4); + assert(ldif != undefined); + var ok = ldb.add(ldif); + if (ok.error != 0) { + println(ok.errstr); + assert(ok.error == 0); + } + + println("Add a set of remote records"); + + var ldif = " +dn: " + s3.dn("cn=A") + " +objectClass: posixAccount +cn: A +sambaNextRid: x +sambaBadPasswordCount: x +sambaLogonTime: x +description: x +sambaSID: S-1-5-21-4231626423-2410014848-2360679739-552 +sambaPrimaryGroupSID: S-1-5-21-4231626423-2410014848-2360679739-512 + +dn: " + s3.dn("cn=B") + " +objectClass: top +cn:B +sambaNextRid: x +sambaBadPasswordCount: x +sambaLogonTime: y +description: x + +dn: " + s3.dn("cn=C") + " +objectClass: top +cn: C +sambaNextRid: x +sambaBadPasswordCount: y +sambaLogonTime: z +description: y +"; + ldif = substitute_var(ldif, s3); + assert(ldif != undefined); + var ok = s3.db.add(ldif); + assert(ok.error == 0); + + println("Testing search by DN"); + + /* Search remote record by local DN */ + dn = s4.dn("cn=A"); + attrs = new Array("dnsHostName", "lastLogon"); + res = ldb.search("", dn, ldb.SCOPE_BASE, attrs); + assert(res.error == 0); + assert(res.msgs.length == 1); + assert(res.msgs[0].dn == dn); + assert(res.msgs[0].dnsHostName == undefined); + assert(res.msgs[0].lastLogon == "x"); + + /* Search remote record by remote DN */ + dn = s3.dn("cn=A"); + attrs = new Array("dnsHostName", "lastLogon", "sambaLogonTime"); + res = s3.db.search("", dn, ldb.SCOPE_BASE, attrs); + assert(res.error == 0); + assert(res.msgs.length == 1); + assert(res.msgs[0].dn == dn); + assert(res.msgs[0].dnsHostName == undefined); + assert(res.msgs[0].lastLogon == undefined); + assert(res.msgs[0].sambaLogonTime == "x"); + + /* Search split record by local DN */ + dn = s4.dn("cn=X"); + attrs = new Array("dnsHostName", "lastLogon"); + res = ldb.search("", dn, ldb.SCOPE_BASE, attrs); + assert(res.error == 0); + assert(res.msgs.length == 1); + assert(res.msgs[0].dn == dn); + assert(res.msgs[0].dnsHostName == "x"); + assert(res.msgs[0].lastLogon == "x"); + + /* Search split record by remote DN */ + dn = s3.dn("cn=X"); + attrs = new Array("dnsHostName", "lastLogon", "sambaLogonTime"); + res = s3.db.search("", dn, ldb.SCOPE_BASE, attrs); + assert(res.error == 0); + assert(res.msgs.length == 1); + assert(res.msgs[0].dn == dn); + assert(res.msgs[0].dnsHostName == undefined); + assert(res.msgs[0].lastLogon == undefined); + assert(res.msgs[0].sambaLogonTime == "x"); + + println("Testing search by attribute"); + + /* Search by ignored attribute */ + attrs = new Array("dnsHostName", "lastLogon"); + res = ldb.search("(revision=x)", NULL, ldb. SCOPE_DEFAULT, attrs); + assert(res.error == 0); + assert(res.msgs.length == 2); + assert(res.msgs[0].dn == s4.dn("cn=Y")); + assert(res.msgs[0].dnsHostName == "y"); + assert(res.msgs[0].lastLogon == "y"); + assert(res.msgs[1].dn == s4.dn("cn=X")); + assert(res.msgs[1].dnsHostName == "x"); + assert(res.msgs[1].lastLogon == "x"); + + /* Search by kept attribute */ + attrs = new Array("dnsHostName", "lastLogon"); + res = ldb.search("(description=y)", NULL, ldb. SCOPE_DEFAULT, attrs); + assert(res.error == 0); + assert(res.msgs.length == 2); + assert(res.msgs[0].dn == s4.dn("cn=Z")); + assert(res.msgs[0].dnsHostName == "z"); + assert(res.msgs[0].lastLogon == "z"); + assert(res.msgs[1].dn == s4.dn("cn=C")); + assert(res.msgs[1].dnsHostName == undefined); + assert(res.msgs[1].lastLogon == "z"); + + /* Search by renamed attribute */ + attrs = new Array("dnsHostName", "lastLogon"); + res = ldb.search("(badPwdCount=x)", NULL, ldb. SCOPE_DEFAULT, attrs); + assert(res.error == 0); + assert(res.msgs.length == 2); + assert(res.msgs[0].dn == s4.dn("cn=B")); + assert(res.msgs[0].dnsHostName == undefined); + assert(res.msgs[0].lastLogon == "y"); + assert(res.msgs[1].dn == s4.dn("cn=A")); + assert(res.msgs[1].dnsHostName == undefined); + assert(res.msgs[1].lastLogon == "x"); + + /* Search by converted attribute */ + attrs = new Array("dnsHostName", "lastLogon", "objectSid"); + /* TODO: + Using the SID directly in the parse tree leads to conversion + errors, letting the search fail with no results. + res = ldb.search("(objectSid=S-1-5-21-4231626423-2410014848-2360679739-552)", NULL, ldb. SCOPE_DEFAULT, attrs); + */ + res = ldb.search("(objectSid=*)", NULL, ldb. SCOPE_DEFAULT, attrs); + assert(res.error == 0); + assert(res.msgs.length == 3); + assert(res.msgs[0].dn == s4.dn("cn=X")); + assert(res.msgs[0].dnsHostName == "x"); + assert(res.msgs[0].lastLogon == "x"); + assert(res.msgs[0].objectSid == "S-1-5-21-4231626423-2410014848-2360679739-552"); + assert(res.msgs[1].dn == s4.dn("cn=A")); + assert(res.msgs[1].dnsHostName == undefined); + assert(res.msgs[1].lastLogon == "x"); + assert(res.msgs[1].objectSid == "S-1-5-21-4231626423-2410014848-2360679739-552"); + + /* Search by generated attribute */ + /* In most cases, this even works when the mapping is missing + * a `convert_operator' by enumerating the remote db. */ + attrs = new Array("dnsHostName", "lastLogon", "primaryGroupID"); + res = ldb.search("(primaryGroupID=512)", NULL, ldb. SCOPE_DEFAULT, attrs); + assert(res.error == 0); + assert(res.msgs.length == 1); + assert(res.msgs[0].dn == s4.dn("cn=A")); + assert(res.msgs[0].dnsHostName == undefined); + assert(res.msgs[0].lastLogon == "x"); + assert(res.msgs[0].primaryGroupID == "512"); + + /* TODO: There should actually be two results, A and X. The + * primaryGroupID of X seems to get corrupted somewhere, and the + * objectSid isn't available during the generation of remote (!) data, + * which can be observed with the following search. Also note that Xs + * objectSid seems to be fine in the previous search for objectSid... */ + /* + res = ldb.search("(primaryGroupID=*)", NULL, ldb. SCOPE_DEFAULT, attrs); + println(res.msgs.length + " results found"); + for (i=0;i Date: Tue, 12 Feb 2008 01:52:07 +0100 Subject: Mark the reprovision test as known failing for now. (This used to be commit 5d4396ae232525be139a91b36f8c7177e46627ae) --- source4/samba4-knownfail | 2 +- source4/selftest/samba4_tests.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source4/samba4-knownfail b/source4/samba4-knownfail index cf5f97ca74..ab03145354 100644 --- a/source4/samba4-knownfail +++ b/source4/samba4-knownfail @@ -35,4 +35,4 @@ BASE-CHARSET.*.Testing partial surrogate .*NET-API-DELSHARE.* # DelShare isn't implemented yet RAP.*netservergetinfo kinit with pkinit # fails with: salt type 3 not supported - +samba4.blackbox.provision.py.reprovision # Fails with entry already exists diff --git a/source4/selftest/samba4_tests.sh b/source4/selftest/samba4_tests.sh index 8296633137..c90373e446 100755 --- a/source4/selftest/samba4_tests.sh +++ b/source4/selftest/samba4_tests.sh @@ -329,5 +329,6 @@ then rm -rf $PREFIX/upgrade plantest "blackbox.upgrade" none $PYTHON setup/upgrade.py $CONFIGURATION --targetdir=$PREFIX/upgrade ../testdata/samba3 ../testdata/samba3/smb.conf rm -rf $PREFIX/provision - plantest "blackbox.provision.py" none PYTHON="$PYTHON" $samba4srcdir/setup/tests/blackbox_provision.sh "$PREFIX" "$CONFIGURATION" + mkdir $PREFIX/provision + plantest "blackbox.provision.py" none PYTHON="$PYTHON" $samba4srcdir/setup/tests/blackbox_provision.sh "$PREFIX/provision" "$CONFIGURATION" fi -- cgit From 95225866951c834bdde91fb0f0fa1f2ee367fe0a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 12 Feb 2008 01:58:42 +0100 Subject: Create the required directories when installing Python code. (This used to be commit 8ef36fe54555cc0c5ac0d1f118d0a1a7b770c2fd) --- source4/lib/ldb/ldb.mk | 2 ++ source4/lib/tdb/tdb.mk | 2 ++ 2 files changed, 4 insertions(+) diff --git a/source4/lib/ldb/ldb.mk b/source4/lib/ldb/ldb.mk index 6d0ad44d38..0b42e6ffcf 100644 --- a/source4/lib/ldb/ldb.mk +++ b/source4/lib/ldb/ldb.mk @@ -74,6 +74,8 @@ _ldb.$(SHLIBEXT): $(LIBS) ldb_wrap.o $(SHLD) $(SHLD_FLAGS) -o _ldb.$(SHLIBEXT) ldb_wrap.o $(LIB_FLAGS) install-python:: build-python + mkdir -p $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0)"` \ + $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1)"` cp $(ldbdir)/ldb.py $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0)"` cp _ldb.$(SHLIBEXT) $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1)"` diff --git a/source4/lib/tdb/tdb.mk b/source4/lib/tdb/tdb.mk index 976589fd0f..22e7e295fb 100644 --- a/source4/lib/tdb/tdb.mk +++ b/source4/lib/tdb/tdb.mk @@ -45,6 +45,8 @@ install:: installdirs installbin installheaders installlibs \ $(PYTHON_INSTALL_TARGET) install-python:: build-python + mkdir -p $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0)"` \ + $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1)"` cp $(tdbdir)/tdb.py $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0)"` cp _tdb.$(SHLIBEXT) $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1)"` -- cgit From e84cd8d38bcb6756c5066c7c75f3220a15e5ad1b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 12 Feb 2008 02:15:09 +0100 Subject: tdb/ldb: Use prefix in case DESTDIR is not set. (This used to be commit ab19a8f62719eb0f347696a2e5f34f8847fd82cb) --- source4/lib/ldb/ldb.mk | 8 ++++---- source4/lib/tdb/tdb.mk | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source4/lib/ldb/ldb.mk b/source4/lib/ldb/ldb.mk index 0b42e6ffcf..ec4c34f6d8 100644 --- a/source4/lib/ldb/ldb.mk +++ b/source4/lib/ldb/ldb.mk @@ -74,10 +74,10 @@ _ldb.$(SHLIBEXT): $(LIBS) ldb_wrap.o $(SHLD) $(SHLD_FLAGS) -o _ldb.$(SHLIBEXT) ldb_wrap.o $(LIB_FLAGS) install-python:: build-python - mkdir -p $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0)"` \ - $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1)"` - cp $(ldbdir)/ldb.py $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0)"` - cp _ldb.$(SHLIBEXT) $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1)"` + mkdir -p $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"` \ + $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='$(prefix)')"` + cp $(ldbdir)/ldb.py $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"` + cp _ldb.$(SHLIBEXT) $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='$(prefix)')"` install-swig:: cp ldb.i `$(SWIG) -swiglib` diff --git a/source4/lib/tdb/tdb.mk b/source4/lib/tdb/tdb.mk index 22e7e295fb..fe77a0492d 100644 --- a/source4/lib/tdb/tdb.mk +++ b/source4/lib/tdb/tdb.mk @@ -45,10 +45,10 @@ install:: installdirs installbin installheaders installlibs \ $(PYTHON_INSTALL_TARGET) install-python:: build-python - mkdir -p $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0)"` \ - $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1)"` - cp $(tdbdir)/tdb.py $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0)"` - cp _tdb.$(SHLIBEXT) $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1)"` + mkdir -p $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"` \ + $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='$(prefix)')"` + cp $(tdbdir)/tdb.py $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"` + cp _tdb.$(SHLIBEXT) $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='$(prefix)')"` check-python:: build-python $(LIB_PATH_VAR)=. PYTHONPATH=".:$(tdbdir)" $(PYTHON) $(tdbdir)/python/tests/simple.py -- cgit