summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-09-21 02:32:19 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-09-21 02:32:19 +0200
commit442d31c7f699628a603ee3bef3831441b43afb69 (patch)
treede39e7e9bcc74f45ec521d663bb4321e19afb1f8 /source4
parentf63c83deef52afcbe27c1664031a5eed009f3a44 (diff)
parent0e2928f94651c53d653a3ad83bbda5608b4d4c24 (diff)
downloadsamba-442d31c7f699628a603ee3bef3831441b43afb69.tar.gz
samba-442d31c7f699628a603ee3bef3831441b43afb69.tar.bz2
samba-442d31c7f699628a603ee3bef3831441b43afb69.zip
Merge branch 'master' of ssh://git.samba.org/data/git/samba into noejs
Diffstat (limited to 'source4')
-rw-r--r--source4/auth/ntlmssp/ntlmssp_server.c38
-rw-r--r--source4/ldap_server/ldap_bind.c3
-rw-r--r--source4/lib/events/Makefile.in35
-rwxr-xr-xsource4/lib/events/autogen.sh3
-rw-r--r--source4/lib/events/build_macros.m414
-rw-r--r--source4/lib/events/configure.ac9
-rw-r--r--source4/lib/events/events.mk4
-rw-r--r--source4/lib/events/libevents.m42
-rw-r--r--source4/lib/events/libtalloc.m47
-rw-r--r--source4/lib/events/pkg.m4156
-rw-r--r--source4/lib/ldb/Makefile.in42
-rwxr-xr-xsource4/lib/ldb/autogen.sh9
-rw-r--r--source4/lib/ldb/build_macros.m414
-rw-r--r--source4/lib/ldb/configure.ac4
-rw-r--r--source4/lib/ldb/external/libevents.m49
-rw-r--r--source4/lib/ldb/external/libtalloc.m49
-rw-r--r--source4/lib/ldb/external/libtdb.m49
-rw-r--r--source4/lib/ldb/ldb.i71
-rw-r--r--source4/lib/ldb/ldb.mk29
-rw-r--r--source4/lib/ldb/ldb_wrap.c220
-rwxr-xr-xsource4/lib/ldb/tests/python/api.py11
21 files changed, 526 insertions, 172 deletions
diff --git a/source4/auth/ntlmssp/ntlmssp_server.c b/source4/auth/ntlmssp/ntlmssp_server.c
index 838596ee98..bf91be3e24 100644
--- a/source4/auth/ntlmssp/ntlmssp_server.c
+++ b/source4/auth/ntlmssp/ntlmssp_server.c
@@ -25,7 +25,6 @@
#include "auth/ntlmssp/ntlmssp.h"
#include "auth/ntlmssp/msrpc_parse.h"
#include "lib/crypto/crypto.h"
-#include "system/filesys.h"
#include "libcli/auth/libcli_auth.h"
#include "auth/credentials/credentials.h"
#include "auth/gensec/gensec.h"
@@ -125,8 +124,6 @@ NTSTATUS ntlmssp_server_negotiate(struct gensec_security *gensec_security,
{
struct gensec_ntlmssp_state *gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
DATA_BLOB struct_blob;
- char dnsname[MAXHOSTNAMELEN], dnsdomname[MAXHOSTNAMELEN];
- const char *p;
uint32_t neg_flags = 0;
uint32_t ntlmssp_command, chal_flags;
const uint8_t *cryptkey;
@@ -183,25 +180,24 @@ NTSTATUS ntlmssp_server_negotiate(struct gensec_security *gensec_security,
gensec_ntlmssp_state->chal = data_blob_talloc(gensec_ntlmssp_state, cryptkey, 8);
gensec_ntlmssp_state->internal_chal = data_blob_talloc(gensec_ntlmssp_state, cryptkey, 8);
- dnsname[0] = '\0';
- if (gethostname(dnsname, sizeof(dnsname)) == -1) {
- DEBUG(0,("gethostname failed\n"));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- /* This should be a 'netbios domain -> DNS domain' mapping */
- p = strchr(dnsname, '.');
- if (p != NULL) {
- safe_strcpy(dnsdomname, p+1, sizeof(dnsdomname));
- strlower_m(dnsdomname);
- } else {
- dnsdomname[0] = '\0';
- }
-
/* This creates the 'blob' of names that appears at the end of the packet */
- if (chal_flags & NTLMSSP_CHAL_TARGET_INFO)
- {
+ if (chal_flags & NTLMSSP_CHAL_TARGET_INFO) {
+ char dnsdomname[MAXHOSTNAMELEN], dnsname[MAXHOSTNAMELEN];
const char *target_name_dns = "";
+
+ /* Find out the DNS domain name */
+ dnsdomname[0] = '\0';
+ safe_strcpy(dnsdomname, lp_realm(gensec_security->lp_ctx), sizeof(dnsdomname) - 1);
+ strlower_m(dnsdomname);
+
+ /* Find out the DNS host name */
+ safe_strcpy(dnsname, gensec_ntlmssp_state->server_name, sizeof(dnsname) - 1);
+ if (dnsdomname[0] != '\0') {
+ safe_strcat(dnsname, ".", sizeof(dnsname) - 1);
+ safe_strcat(dnsname, dnsdomname, sizeof(dnsname) - 1);
+ }
+ strlower_m(dnsname);
+
if (chal_flags |= NTLMSSP_TARGET_TYPE_DOMAIN) {
target_name_dns = dnsdomname;
} else if (chal_flags |= NTLMSSP_TARGET_TYPE_SERVER) {
@@ -221,7 +217,7 @@ NTSTATUS ntlmssp_server_negotiate(struct gensec_security *gensec_security,
}
{
- /* Marshel the packet in the right format, be it unicode or ASCII */
+ /* Marshal the packet in the right format, be it unicode or ASCII */
const char *gen_string;
if (gensec_ntlmssp_state->unicode) {
gen_string = "CdUdbddB";
diff --git a/source4/ldap_server/ldap_bind.c b/source4/ldap_server/ldap_bind.c
index f37ef31c0a..8357251a8f 100644
--- a/source4/ldap_server/ldap_bind.c
+++ b/source4/ldap_server/ldap_bind.c
@@ -180,9 +180,6 @@ static NTSTATUS ldapsrv_BindSASL(struct ldapsrv_call *call)
input = *req->creds.SASL.secblob;
}
- resp->SASL.secblob = talloc(reply, DATA_BLOB);
- NT_STATUS_HAVE_NO_MEMORY(resp->SASL.secblob);
-
status = gensec_update(conn->gensec, reply,
input, &output);
diff --git a/source4/lib/events/Makefile.in b/source4/lib/events/Makefile.in
index 0a0df9bef9..4257119849 100644
--- a/source4/lib/events/Makefile.in
+++ b/source4/lib/events/Makefile.in
@@ -9,9 +9,11 @@ exec_prefix = @exec_prefix@
bindir = @bindir@
includedir = @includedir@
libdir = @libdir@
-VPATH = @srcdir@:@tallocdir@:@libreplacedir@
+VPATH = @srcdir@:@libreplacedir@
srcdir = @srcdir@
builddir = @builddir@
+sharedbuilddir = @sharedbuilddir@
+INSTALLCMD = @INSTALL@
CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/include -Iinclude -I.
LDFLAGS = @LDFLAGS@
EXEEXT = @EXEEXT@
@@ -28,26 +30,40 @@ PYTHON_INSTALL_TARGET = @PYTHON_INSTALL_TARGET@
PYTHON_CHECK_TARGET = @PYTHON_CHECK_TARGET@
LIB_PATH_VAR = @LIB_PATH_VAR@
eventsdir = @eventsdir@
-tallocdir = @tallocdir@
-TALLOC_LIBS = @TALLOC_LIBS@
TALLOC_CFLAGS = @TALLOC_CFLAGS@
-TALLOC_OBJ = @TALLOC_OBJ@
+TALLOC_LDFLAGS = @TALLOC_CFLAGS@
+TALLOC_LIBS = @TALLOC_LIBS@
-CFLAGS = $(CPPFLAGS) $(TALLOC_CFLAGS) @CFLAGS@
+EVENTS_CFLAGS = @EVENTS_CFLAGS@
+EVENTS_LDFLAGS = @EVENTS_CFLAGS@
+EVENTS_LIBS = @EVENTS_LIBS@
-EVENTS_OBJ = @EVENTS_OBJ@ $(TALLOC_OBJ) @LIBREPLACEOBJ@
+CFLAGS = $(CPPFLAGS) $(TALLOC_CFLAGS) $(EVENTS_CFLAGS) @CFLAGS@
+LDFLAGS = $(TALLOC_LDFLAGS) $(EVENTS_LDFLAGS) @LDFLAGS@
+LIBS = $(TALLOC_LIBS) $(EVENTS_LIBS) @LIBS@
+
+EVENTS_OBJ = @EVENTS_OBJ@ @LIBREPLACEOBJ@
default: all
include $(eventsdir)/events.mk
include $(eventsdir)/rules.mk
-all:: showflags dirs $(PROGS) $(LIBEVENTS_SOLIB) libevents.a $(PYTHON_BUILD_TARGET)
+all:: showflags dirs $(PROGS) $(EVENTS_SOLIB) libevents.a $(PYTHON_BUILD_TARGET)
install:: all
-$(LIBEVENTS_SOLIB): $(EVENTS_OBJ)
- $(SHLD) $(SHLD_FLAGS) -o $@ $(EVENTS_OBJ) $(TALLOC_LIBS) @SONAMEFLAG@$(LIBEVENTS_SONAME)
+$(EVENTS_SOLIB): $(EVENTS_OBJ)
+ $(SHLD) $(SHLD_FLAGS) $(LDFLAGS) $(LIBS) -o $@ $(EVENTS_OBJ) @SONAMEFLAG@$(EVENTS_SONAME)
+
+shared-build: all
+ ${INSTALLCMD} -d $(sharedbuilddir)/lib
+ ${INSTALLCMD} -m 644 libevents.a $(sharedbuilddir)/lib
+ ${INSTALLCMD} -m 755 $(EVENTS_SOLIB) $(sharedbuilddir)/lib
+ ln -sf $(EVENTS_SOLIB) $(sharedbuilddir)/lib/$(EVENTS_SONAME)
+ ln -sf $(EVENTS_SOLIB) $(sharedbuilddir)/lib/libevents.so
+ ${INSTALLCMD} -d $(sharedbuilddir)/include
+ ${INSTALLCMD} -m 644 $(srcdir)/events.h $(sharedbuilddir)/include
check: test
@@ -56,7 +72,6 @@ installcheck:: test install
clean::
rm -f *.o *.a */*.o
- rm -f $(TALLOC_OBJ)
distclean:: clean
rm -f config.log config.status include/config.h config.cache
diff --git a/source4/lib/events/autogen.sh b/source4/lib/events/autogen.sh
index b13a4b685d..fec05f54d4 100755
--- a/source4/lib/events/autogen.sh
+++ b/source4/lib/events/autogen.sh
@@ -3,8 +3,7 @@
rm -rf autom4te.cache
rm -f configure config.h.in
-IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace"
-IPATHS="$IPATHS -I lib/talloc -I talloc -I ../talloc"
+IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace -I ../../../lib/replace"
autoconf $IPATHS || exit 1
autoheader $IPATHS || exit 1
diff --git a/source4/lib/events/build_macros.m4 b/source4/lib/events/build_macros.m4
new file mode 100644
index 0000000000..c036668cd1
--- /dev/null
+++ b/source4/lib/events/build_macros.m4
@@ -0,0 +1,14 @@
+AC_DEFUN(BUILD_WITH_SHARED_BUILD_DIR,
+ [ AC_ARG_WITH([shared-build-dir],
+ [AC_HELP_STRING([--with-shared-build-dir=DIR],
+ [temporary build directory where libraries are installed [$srcdir/sharedbuild]])])
+
+ sharedbuilddir="$srcdir/sharedbuild"
+ if test x"$with_shared_build_dir" != x; then
+ sharedbuilddir=$with_shared_build_dir
+ CFLAGS="$CFLAGS -I$with_shared_build_dir/include"
+ LDFLAGS="$LDFLAGS -L$with_shared_build_dir/lib"
+ fi
+ AC_SUBST(sharedbuilddir)
+ ])
+
diff --git a/source4/lib/events/configure.ac b/source4/lib/events/configure.ac
index fbd23b10e5..895f2a1daa 100644
--- a/source4/lib/events/configure.ac
+++ b/source4/lib/events/configure.ac
@@ -8,8 +8,6 @@ AC_CONFIG_SRCDIR([events.c])
AC_CONFIG_HEADER(config.h)
AC_LIBREPLACE_ALL_CHECKS
-m4_include(libtalloc.m4)
-
AC_LD_EXPORT_DYNAMIC
AC_LD_SONAMEFLAG
AC_LD_PICFLAG
@@ -17,6 +15,13 @@ AC_LD_SHLIBEXT
AC_LIBREPLACE_SHLD
AC_LIBREPLACE_SHLD_FLAGS
AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR
+
+m4_include(build_macros.m4)
+BUILD_WITH_SHARED_BUILD_DIR
+
+m4_include(pkg.m4)
+m4_include(libtalloc.m4)
+
m4_include(libevents.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])
diff --git a/source4/lib/events/events.mk b/source4/lib/events/events.mk
index f4b02eae83..2bc6221689 100644
--- a/source4/lib/events/events.mk
+++ b/source4/lib/events/events.mk
@@ -5,7 +5,7 @@ EVENTS_SOLIB = libevents.$(SHLIBEXT).$(PACKAGE_VERSION)
libevents.a: $(EVENTS_OBJ)
ar -rv libevents.a $(EVENTS_OBJ)
-libevents.$(SHLIBEXT): $(LIBEVENTS_SOLIB)
+libevents.$(SHLIBEXT): $(EVENTS_SOLIB)
ln -fs $< $@
$(EVENTS_SONAME): $(EVENTS_SOLIB)
@@ -24,7 +24,7 @@ installheaders:: installdirs
installlibs:: installdirs
cp events.pc $(DESTDIR)$(libdir)/pkgconfig
- cp libevents.a $(LIBEVENTS_SOLIB) $(DESTDIR)$(libdir)
+ cp libevents.a $(EVENTS_SOLIB) $(DESTDIR)$(libdir)
install:: all installdirs installheaders installlibs $(PYTHON_INSTALL_TARGET)
diff --git a/source4/lib/events/libevents.m4 b/source4/lib/events/libevents.m4
index d17da64b32..ed76b03d4f 100644
--- a/source4/lib/events/libevents.m4
+++ b/source4/lib/events/libevents.m4
@@ -43,7 +43,7 @@ SMB_EXT_LIB(LIBAIO_LINUX, $AIO_LIBS)
EVENTS_CFLAGS="-I$eventsdir"
AC_SUBST(EVENTS_CFLAGS)
-EVENTS_LIBS=""
+EVENTS_LIBS="$AIO_LIBS"
AC_SUBST(EVENTS_LIBS)
diff --git a/source4/lib/events/libtalloc.m4 b/source4/lib/events/libtalloc.m4
new file mode 100644
index 0000000000..a4c5b8a9d9
--- /dev/null
+++ b/source4/lib/events/libtalloc.m4
@@ -0,0 +1,7 @@
+AC_SUBST(TALLOC_OBJ)
+AC_SUBST(TALLOC_CFLAGS)
+AC_SUBST(TALLOC_LIBS)
+
+AC_CHECK_HEADER(talloc.h,
+ [AC_CHECK_LIB(talloc, talloc_init, [TALLOC_LIBS="-ltalloc"]) ],
+ [PKG_CHECK_MODULES(TALLOC, talloc)])
diff --git a/source4/lib/events/pkg.m4 b/source4/lib/events/pkg.m4
new file mode 100644
index 0000000000..a8b3d06c81
--- /dev/null
+++ b/source4/lib/events/pkg.m4
@@ -0,0 +1,156 @@
+# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
+#
+# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# PKG_PROG_PKG_CONFIG([MIN-VERSION])
+# ----------------------------------
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+ AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+ _pkg_min_version=m4_default([$1], [0.9.0])
+ AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ PKG_CONFIG=""
+ fi
+
+fi[]dnl
+])# PKG_PROG_PKG_CONFIG
+
+# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#
+# Check to see whether a particular set of modules exists. Similar
+# to PKG_CHECK_MODULES(), but does not set variables or print errors.
+#
+#
+# Similar to PKG_CHECK_MODULES, make sure that the first instance of
+# this or PKG_CHECK_MODULES is called, or make sure to call
+# PKG_CHECK_EXISTS manually
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+ m4_ifval([$2], [$2], [:])
+m4_ifvaln([$3], [else
+ $3])dnl
+fi])
+
+
+# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+# ---------------------------------------------
+m4_define([_PKG_CONFIG],
+[if test -n "$PKG_CONFIG"; then
+ if test -n "$$1"; then
+ pkg_cv_[]$1="$$1"
+ else
+ PKG_CHECK_EXISTS([$3],
+ [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
+ [pkg_failed=yes])
+ fi
+else
+ pkg_failed=untried
+fi[]dnl
+])# _PKG_CONFIG
+
+# _PKG_SHORT_ERRORS_SUPPORTED
+# -----------------------------
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
+else
+ _pkg_short_errors_supported=no
+fi[]dnl
+])# _PKG_SHORT_ERRORS_SUPPORTED
+
+
+# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+# [ACTION-IF-NOT-FOUND])
+#
+#
+# Note that if there is a possibility the first call to
+# PKG_CHECK_MODULES might not happen, you should be sure to include an
+# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+#
+#
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $1])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
+and $1[]_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.])
+
+if test $pkg_failed = yes; then
+ _PKG_SHORT_ERRORS_SUPPORTED
+ if test $_pkg_short_errors_supported = yes; then
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
+ else
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+ ifelse([$4], , [AC_MSG_ERROR(dnl
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT
+])],
+ [AC_MSG_RESULT([no])
+ $4])
+elif test $pkg_failed = untried; then
+ ifelse([$4], , [AC_MSG_FAILURE(dnl
+[The pkg-config script could not be found or is too old. Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+_PKG_TEXT
+
+To get pkg-config, see <http://www.freedesktop.org/software/pkgconfig>.])],
+ [$4])
+else
+ $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+ $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+ AC_MSG_RESULT([yes])
+ ifelse([$3], , :, [$3])
+fi[]dnl
+])# PKG_CHECK_MODULES
diff --git a/source4/lib/ldb/Makefile.in b/source4/lib/ldb/Makefile.in
index ecb6b6516b..8d95dae7ea 100644
--- a/source4/lib/ldb/Makefile.in
+++ b/source4/lib/ldb/Makefile.in
@@ -11,9 +11,11 @@ includedir = @includedir@
libdir = @libdir@
bindir = @bindir@
mandir = @mandir@
-VPATH = @srcdir@:@tdbdir@:@tallocdir@:@libreplacedir@:@poptdir@:@eventsdir@
+VPATH = @srcdir@:@libreplacedir@
srcdir = @srcdir@
builddir = @builddir@
+sharedbuilddir = @sharedbuilddir@
+INSTALLCMD = @INSTALL@
SLAPD = @SLAPD@
SWIG = swig
EXTRA_OBJ=@EXTRA_OBJ@
@@ -21,9 +23,7 @@ TESTS=test-tdb.sh @TESTS@
PACKAGE_VERSION = @PACKAGE_VERSION@
PYTHON = @PYTHON@
PYTHON_CONFIG = @PYTHON_CONFIG@
-tdbdir = @tdbdir@
ldbdir = $(srcdir)
-tallocdir = @tallocdir@
TALLOC_LIBS = @TALLOC_LIBS@
TALLOC_CFLAGS = @TALLOC_CFLAGS@
@@ -33,6 +33,7 @@ TDB_LIBS = @TDB_LIBS@
TDB_CFLAGS = @TDB_CFLAGS@
TDB_OBJ = @TDB_OBJ@
+EVENTS_LIBS = @EVENTS_LIBS@
EVENTS_CFLAGS = @EVENTS_CFLAGS@
EVENTS_OBJ = @EVENTS_OBJ@
@@ -65,7 +66,7 @@ OBJS = $(MODULES_OBJ) $(COMMON_OBJ) $(LDB_TDB_OBJ) $(TDB_OBJ) $(EVENTS_OBJ) $(TA
headers = $(srcdir)/include/ldb.h $(srcdir)/include/ldb_errors.h $(srcdir)/include/ldb_handlers.h
-BINS = bin/ldbadd bin/ldbsearch bin/ldbdel bin/ldbmodify bin/ldbedit bin/ldbrename bin/ldbtest bin/oLschema2ldif
+BINS = bin/ldbadd bin/ldbsearch bin/ldbdel bin/ldbmodify bin/ldbedit bin/ldbrename bin/ldbtest
EXAMPLES = examples/ldbreader examples/ldifreader
@@ -81,24 +82,37 @@ nssdir:
@mkdir -p $(NSSDIR)
SONAME = libldb.$(SHLIBEXT).0
-SOLIB = lib/libldb.$(SHLIBEXT).$(PACKAGE_VERSION)
+SOLIB = libldb.$(SHLIBEXT).$(PACKAGE_VERSION)
+LIBSOLIB = lib/$(SOLIB)
STATICLIB = lib/libldb.a
-lib/$(SONAME): $(SOLIB)
+lib/$(SONAME): $(LIBSOLIB)
ln -fs libldb.$(SHLIBEXT).$(PACKAGE_VERSION) $@
-lib/libldb.$(SHLIBEXT): $(SOLIB)
+lib/libldb.$(SHLIBEXT): $(LIBSOLIB)
ln -fs libldb.$(SHLIBEXT).$(PACKAGE_VERSION) $@
-lib/libnss_ldb.$(SHLIBEXT).2: $(NSS_OBJ) $(SOLIB)
- $(SHLD) $(SHLD_FLAGS) -o $@ $(NSS_OBJ) $(LDFLAGS) $(SOLIB) @SONAMEFLAG@libnss_ldb.$(SHLIBEXT).2
+lib/libnss_ldb.$(SHLIBEXT).2: $(NSS_OBJ) $(LIBSOLIB)
+ $(SHLD) $(SHLD_FLAGS) -o $@ $(NSS_OBJ) $(LDFLAGS) $(LIBSOLIB) @SONAMEFLAG@libnss_ldb.$(SHLIBEXT).2
-$(SOLIB): $(OBJS)
- $(SHLD) $(SHLD_FLAGS) -o $@ $(OBJS) $(LDFLAGS) $(LIBS) $(TALLOC_LIBS) $(TDB_LIBS) $(LIBDL) $(LDAP_LIBS) @SONAMEFLAG@$(SONAME)
+$(LIBSOLIB): $(OBJS)
+ $(SHLD) $(SHLD_FLAGS) -o $@ $(OBJS) $(LDFLAGS) $(LIBS) $(TALLOC_LIBS) $(TDB_LIBS) $(EVENTS_LIBS) $(LIBDL) $(LDAP_LIBS) @SONAMEFLAG@$(SONAME)
+ ln -sf libldb.$(SHLIBEXT).$(PACKAGE_VERSION) lib/libldb.$(SHLIBEXT)
-all: showflags dirs $(OBJS) $(STATICLIB) $(SOLIB) $(BINS) $(EXAMPLES) manpages \
+all: showflags dirs $(OBJS) $(STATICLIB) $(LIBSOLIB) $(BINS) $(EXAMPLES) manpages \
@PYTHON_BUILD_TARGET@
+shared-build: all
+ ${INSTALLCMD} -d $(sharedbuilddir)/lib
+ ${INSTALLCMD} -m 644 $(STATICLIB) $(sharedbuilddir)/lib
+ ${INSTALLCMD} -m 755 $(LIBSOLIB) $(sharedbuilddir)/lib
+ ln -sf $(SOLIB) $(sharedbuilddir)/lib/$(SONAME)
+ ln -sf $(SOLIB) $(sharedbuilddir)/lib/libldb.so
+ ${INSTALLCMD} -d $(sharedbuilddir)/include
+ ${INSTALLCMD} -m 644 $(srcdir)/include/ldb.h $(sharedbuilddir)/include
+ ${INSTALLCMD} -m 644 $(srcdir)/include/ldb_errors.h $(sharedbuilddir)/include
+ ${INSTALLCMD} -m 644 $(srcdir)/include/ldb_handlers.h $(sharedbuilddir)/include
+
dirs:
@mkdir -p $(DIRS)
@@ -110,7 +124,7 @@ doxygen::
clean::
rm -f *.o */*.o *.gcov */*.gc?? tdbtest.ldb*
- rm -f $(BINS) $(TDB_OBJ) $(TALLOC_OBJ) $(STATICLIB) $(NSS_LIB) $(SOLIB)
+ rm -f $(BINS) $(TDB_OBJ) $(TALLOC_OBJ) $(STATICLIB) $(NSS_LIB) $(LIBSOLIB)
rm -f $(POPT_OBJ)
rm -f man/*.1 man/*.3 man/*.html
rm -f $(EXAMPLES)
@@ -149,7 +163,7 @@ installheaders:: installdirs
cp $(headers) $(DESTDIR)$(includedir)
installlibs:: installdirs
- cp $(STATICLIB) $(SOLIB) $(DESTDIR)$(libdir)
+ cp $(STATICLIB) $(LIBSOLIB) $(DESTDIR)$(libdir)
cp ldb.pc $(DESTDIR)$(libdir)/pkgconfig
installbin:: installdirs
diff --git a/source4/lib/ldb/autogen.sh b/source4/lib/ldb/autogen.sh
index b81e5b094e..52fc8b63e2 100755
--- a/source4/lib/ldb/autogen.sh
+++ b/source4/lib/ldb/autogen.sh
@@ -3,14 +3,7 @@
rm -rf autom4te.cache
rm -f configure config.h.in
-IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace"
-IPATHS="$IPATHS -I lib/events -I events -I ../events"
-IPATHS="$IPATHS -I lib/talloc -I talloc -I ../talloc"
-IPATHS="$IPATHS -I lib/tdb -I tdb -I ../tdb"
-IPATHS="$IPATHS -I lib/popt -I popt -I ../popt"
-
-# Always keep this listed last, so the built-in versions of tdb and talloc
-# get used if available.
+IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace -I ../../../lib/replace"
IPATHS="$IPATHS -I ./external"
autoheader $IPATHS || exit 1
diff --git a/source4/lib/ldb/build_macros.m4 b/source4/lib/ldb/build_macros.m4
new file mode 100644
index 0000000000..c036668cd1
--- /dev/null
+++ b/source4/lib/ldb/build_macros.m4
@@ -0,0 +1,14 @@
+AC_DEFUN(BUILD_WITH_SHARED_BUILD_DIR,
+ [ AC_ARG_WITH([shared-build-dir],
+ [AC_HELP_STRING([--with-shared-build-dir=DIR],
+ [temporary build directory where libraries are installed [$srcdir/sharedbuild]])])
+
+ sharedbuilddir="$srcdir/sharedbuild"
+ if test x"$with_shared_build_dir" != x; then
+ sharedbuilddir=$with_shared_build_dir
+ CFLAGS="$CFLAGS -I$with_shared_build_dir/include"
+ LDFLAGS="$LDFLAGS -L$with_shared_build_dir/lib"
+ fi
+ AC_SUBST(sharedbuilddir)
+ ])
+
diff --git a/source4/lib/ldb/configure.ac b/source4/lib/ldb/configure.ac
index 4a703e8139..095caa5e92 100644
--- a/source4/lib/ldb/configure.ac
+++ b/source4/lib/ldb/configure.ac
@@ -43,6 +43,10 @@ AC_SUBST(LDB_MODULESDIR)
TESTS=""
EXTRA_OBJ=""
+m4_include(build_macros.m4)
+BUILD_WITH_SHARED_BUILD_DIR
+
+m4_include(pkg.m4)
m4_include(libpopt.m4)
m4_include(libtalloc.m4)
m4_include(libtdb.m4)
diff --git a/source4/lib/ldb/external/libevents.m4 b/source4/lib/ldb/external/libevents.m4
index f0f80e9d8e..4fd2e71ec2 100644
--- a/source4/lib/ldb/external/libevents.m4
+++ b/source4/lib/ldb/external/libevents.m4
@@ -1,4 +1,7 @@
-m4_include(pkg.m4)
-EVENTS_OBJ=""
AC_SUBST(EVENTS_OBJ)
-PKG_CHECK_MODULES(EVENTS, events)
+AC_SUBST(EVENTS_CFLAGS)
+AC_SUBST(EVENTS_LIBS)
+
+AC_CHECK_HEADER(events.h,
+ [AC_CHECK_LIB(events, event_context_init, [EVENTS_LIBS="-levents"]) ],
+ [PKG_CHECK_MODULES(EVENTS, events)])
diff --git a/source4/lib/ldb/external/libtalloc.m4 b/source4/lib/ldb/external/libtalloc.m4
index d08bd42065..a4c5b8a9d9 100644
--- a/source4/lib/ldb/external/libtalloc.m4
+++ b/source4/lib/ldb/external/libtalloc.m4
@@ -1,4 +1,7 @@
-m4_include(pkg.m4)
-TALLOC_OBJ=""
AC_SUBST(TALLOC_OBJ)
-PKG_CHECK_MODULES(TALLOC, talloc)
+AC_SUBST(TALLOC_CFLAGS)
+AC_SUBST(TALLOC_LIBS)
+
+AC_CHECK_HEADER(talloc.h,
+ [AC_CHECK_LIB(talloc, talloc_init, [TALLOC_LIBS="-ltalloc"]) ],
+ [PKG_CHECK_MODULES(TALLOC, talloc)])
diff --git a/source4/lib/ldb/external/libtdb.m4 b/source4/lib/ldb/external/libtdb.m4
index 4c1f4b530e..8c2cab702f 100644
--- a/source4/lib/ldb/external/libtdb.m4
+++ b/source4/lib/ldb/external/libtdb.m4
@@ -1,4 +1,7 @@
-m4_include(pkg.m4)
-TDB_OBJ=""
AC_SUBST(TDB_OBJ)
-PKG_CHECK_MODULES(TDB, tdb >= 1.1.0)
+AC_SUBST(TDB_CFLAGS)
+AC_SUBST(TDB_LIBS)
+
+AC_CHECK_HEADER(tdb.h,
+ [AC_CHECK_LIB(tdb, tdb_open, [TDB_LIBS="-ltdb"]) ],
+ [PKG_CHECK_MODULES(TDB, tdb >= 1.1.0)])
diff --git a/source4/lib/ldb/ldb.i b/source4/lib/ldb/ldb.i
index 8cd39b5690..e9496b503b 100644
--- a/source4/lib/ldb/ldb.i
+++ b/source4/lib/ldb/ldb.i
@@ -153,17 +153,21 @@ PyObject *ldb_val_to_py_object(struct ldb_context *ldb_ctx,
* Wrap struct ldb_result
*/
-%typemap(in,noblock=1,numinputs=0) struct ldb_result **OUT (struct ldb_result *temp_ldb_result) {
+%typemap(in,noblock=1,numinputs=0) struct ldb_result ** (struct ldb_result *temp_ldb_result) {
$1 = &temp_ldb_result;
}
#ifdef SWIGPYTHON
%typemap(argout,noblock=1) struct ldb_result ** (int i) {
- $result = PyList_New((*$1)->count);
- for (i = 0; i < (*$1)->count; i++) {
- PyList_SetItem($result, i,
- SWIG_NewPointerObj((*$1)->msgs[i], SWIGTYPE_p_ldb_message, 0)
- );
+ if ($1 == NULL) {
+ $result = Py_None;
+ } else {
+ $result = PyList_New((*$1)->count);
+ for (i = 0; i < (*$1)->count; i++) {
+ PyList_SetItem($result, i,
+ SWIG_NewPointerObj((*$1)->msgs[i], SWIGTYPE_p_ldb_message, 0)
+ );
+ }
}
}
@@ -944,20 +948,55 @@ typedef struct ldb_module {
return ret;
}
#endif
- int search(struct ldb_request *req) {
- return $self->ops->search($self, req);
+ int search(struct ldb_dn *base, enum ldb_scope scope, struct ldb_parse_tree *tree, const char * const * attrs, struct ldb_result **res) {
+ int ret;
+ struct ldb_request *req = talloc_zero(NULL, struct ldb_request);
+
+ req->operation = LDB_SEARCH;
+ req->op.search.base = base;
+ req->op.search.scope = scope;
+ req->op.search.tree = tree;
+ req->op.search.attrs = attrs;
+
+ req->op.search.res = talloc_zero(NULL, struct ldb_result);
+
+ ret = $self->ops->search($self, req);
+
+ *res = req->op.search.res;
+
+ talloc_free(req);
+
+ return ret;
}
- ldb_error add(struct ldb_request *req) {
- return $self->ops->add($self, req);
+ ldb_error add(struct ldb_message *message) {
+ struct ldb_request *req = talloc_zero(NULL, struct ldb_request);
+ req->operation = LDB_ADD;
+ req->op.add.message = message;
+
+ return $self->ops->add($self, &req);
}
- ldb_error modify(struct ldb_request *req) {
- return $self->ops->modify($self, req);
+ ldb_error modify(struct ldb_message *message) {
+ struct ldb_request *req = talloc_zero(NULL, struct ldb_request);
+ req->operation = LDB_MODIFY;
+ req->op.mod.message = message;
+
+ return $self->ops->modify($self, &req);
}
- ldb_error delete(struct ldb_request *req) {
- return $self->ops->del($self, req);
+ ldb_error delete(struct ldb_dn *dn) {
+ struct ldb_request *req = talloc_zero(NULL, struct ldb_request);
+ req->operation = LDB_DELETE;
+ req->op.del.dn = dn;
+
+ return $self->ops->del($self, &req);
+
}
- ldb_error rename(struct ldb_request *req) {
- return $self->ops->rename($self, req);
+ ldb_error rename(struct ldb_dn *olddn, struct ldb_dn *newdn) {
+ struct ldb_request *req = talloc_zero(NULL, struct ldb_request);
+ req->operation = LDB_RENAME;
+ req->op.rename.olddn = olddn;
+ req->op.rename.olddn = newdn;
+
+ return $self->ops->rename($self, &req);
}
ldb_error start_transaction() {
return $self->ops->start_transaction($self);
diff --git a/source4/lib/ldb/ldb.mk b/source4/lib/ldb/ldb.mk
index df11e9d2ab..a7b1cb0c69 100644
--- a/source4/lib/ldb/ldb.mk
+++ b/source4/lib/ldb/ldb.mk
@@ -1,7 +1,7 @@
-LDB_LIB = $(STATICLIB)
+LDB_LIB = -Llib -lldb
-LIB_FLAGS=$(LDFLAGS) -Llib $(LDB_LIB) $(LIBS) $(POPT_LIBS) $(TALLOC_LIBS) \
- $(TDB_LIBS) $(LDAP_LIBS) $(LIBDL)
+LIB_FLAGS=$(LDFLAGS) $(LIBS) $(LDB_LIB) $(POPT_LIBS) $(TALLOC_LIBS) \
+ $(TDB_LIBS) $(EVENTS_LIBS) $(LDAP_LIBS) $(LIBDL)
LDB_TDB_DIR=ldb_tdb
LDB_TDB_OBJ=$(LDB_TDB_DIR)/ldb_tdb.o \
@@ -34,34 +34,31 @@ lib/libldb.a: $(OBJS)
sample.$(SHLIBEXT): tests/sample_module.o
$(MDLD) $(MDLD_FLAGS) -o $@ tests/sample_module.o
-bin/ldbadd: tools/ldbadd.o tools/cmdline.o $(LIBS)
+bin/ldbadd: tools/ldbadd.o tools/cmdline.o
$(CC) -o bin/ldbadd tools/ldbadd.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
-bin/ldbsearch: tools/ldbsearch.o tools/cmdline.o $(LIBS)
+bin/ldbsearch: tools/ldbsearch.o tools/cmdline.o
$(CC) -o bin/ldbsearch tools/ldbsearch.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
-bin/ldbdel: tools/ldbdel.o tools/cmdline.o $(LIBS)
+bin/ldbdel: tools/ldbdel.o tools/cmdline.o
$(CC) -o bin/ldbdel tools/ldbdel.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
-bin/ldbmodify: tools/ldbmodify.o tools/cmdline.o $(LIBS)
+bin/ldbmodify: tools/ldbmodify.o tools/cmdline.o
$(CC) -o bin/ldbmodify tools/ldbmodify.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
-bin/ldbedit: tools/ldbedit.o tools/cmdline.o $(LIBS)
+bin/ldbedit: tools/ldbedit.o tools/cmdline.o
$(CC) -o bin/ldbedit tools/ldbedit.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
-bin/ldbrename: tools/ldbrename.o tools/cmdline.o $(LIBS)
+bin/ldbrename: tools/ldbrename.o tools/cmdline.o
$(CC) -o bin/ldbrename tools/ldbrename.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
-bin/ldbtest: tools/ldbtest.o tools/cmdline.o $(LIBS)
+bin/ldbtest: tools/ldbtest.o tools/cmdline.o
$(CC) -o bin/ldbtest tools/ldbtest.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
-bin/oLschema2ldif: tools/oLschema2ldif.o tools/cmdline.o tools/convert.o $(LIBS)
- $(CC) -o bin/oLschema2ldif tools/oLschema2ldif.o tools/cmdline.o tools/convert.o $(LIB_FLAGS)
-
-examples/ldbreader: examples/ldbreader.o $(LIBS)
+examples/ldbreader: examples/ldbreader.o
$(CC) -o examples/ldbreader examples/ldbreader.o $(LIB_FLAGS)
-examples/ldifreader: examples/ldifreader.o $(LIBS)
+examples/ldifreader: examples/ldifreader.o
$(CC) -o examples/ldifreader examples/ldifreader.o $(LIB_FLAGS)
# Python bindings
@@ -70,7 +67,7 @@ build-python:: _ldb.$(SHLIBEXT)
ldb_wrap.o: $(ldbdir)/ldb_wrap.c
$(CC) $(PICFLAG) -c $(ldbdir)/ldb_wrap.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags`
-_ldb.$(SHLIBEXT): $(LIBS) ldb_wrap.o
+_ldb.$(SHLIBEXT): ldb_wrap.o
$(SHLD) $(SHLD_FLAGS) -o _ldb.$(SHLIBEXT) ldb_wrap.o $(LIB_FLAGS) `$(PYTHON_CONFIG) --ldflags`
install-python:: build-python
diff --git a/source4/lib/ldb/ldb_wrap.c b/source4/lib/ldb/ldb_wrap.c
index 7a6d4517ce..84e68d460e 100644
--- a/source4/lib/ldb/ldb_wrap.c
+++ b/source4/lib/ldb/ldb_wrap.c
@@ -2495,23 +2495,22 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
#define SWIGTYPE_p_ldb_module swig_types[9]
#define SWIGTYPE_p_ldb_module_ops swig_types[10]
#define SWIGTYPE_p_ldb_parse_tree swig_types[11]
-#define SWIGTYPE_p_ldb_request swig_types[12]
-#define SWIGTYPE_p_ldb_result swig_types[13]
-#define SWIGTYPE_p_ldb_val swig_types[14]
-#define SWIGTYPE_p_long_long swig_types[15]
-#define SWIGTYPE_p_p_char swig_types[16]
-#define SWIGTYPE_p_p_ldb_control swig_types[17]
-#define SWIGTYPE_p_p_ldb_result swig_types[18]
-#define SWIGTYPE_p_short swig_types[19]
-#define SWIGTYPE_p_signed_char swig_types[20]
-#define SWIGTYPE_p_unsigned_char swig_types[21]
-#define SWIGTYPE_p_unsigned_int swig_types[22]
-#define SWIGTYPE_p_unsigned_long swig_types[23]
-#define SWIGTYPE_p_unsigned_long_long swig_types[24]
-#define SWIGTYPE_p_unsigned_short swig_types[25]
-#define SWIGTYPE_p_void swig_types[26]
-static swig_type_info *swig_types[28];
-static swig_module_info swig_module = {swig_types, 27, 0, 0, 0, 0};
+#define SWIGTYPE_p_ldb_result swig_types[12]
+#define SWIGTYPE_p_ldb_val swig_types[13]
+#define SWIGTYPE_p_long_long swig_types[14]
+#define SWIGTYPE_p_p_char swig_types[15]
+#define SWIGTYPE_p_p_ldb_control swig_types[16]
+#define SWIGTYPE_p_p_ldb_result swig_types[17]
+#define SWIGTYPE_p_short swig_types[18]
+#define SWIGTYPE_p_signed_char swig_types[19]
+#define SWIGTYPE_p_unsigned_char swig_types[20]
+#define SWIGTYPE_p_unsigned_int swig_types[21]
+#define SWIGTYPE_p_unsigned_long swig_types[22]
+#define SWIGTYPE_p_unsigned_long_long swig_types[23]
+#define SWIGTYPE_p_unsigned_short swig_types[24]
+#define SWIGTYPE_p_void swig_types[25]
+static swig_type_info *swig_types[27];
+static swig_module_info swig_module = {swig_types, 26, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
@@ -3238,20 +3237,55 @@ SWIGINTERN char *ldb_module___repr__(ldb_module *self){
asprintf(&ret, "<ldb module '%s'>", self->ops->name);
return ret;
}
-SWIGINTERN int ldb_module_search(ldb_module *self,struct ldb_request *req){
- return self->ops->search(self, req);
+SWIGINTERN int ldb_module_search(ldb_module *self,struct ldb_dn *base,enum ldb_scope scope,struct ldb_parse_tree *tree,char const *const *attrs,struct ldb_result **res){
+ int ret;
+ struct ldb_request *req = talloc_zero(NULL, struct ldb_request);
+
+ req->operation = LDB_SEARCH;
+ req->op.search.base = base;
+ req->op.search.scope = scope;
+ req->op.search.tree = tree;
+ req->op.search.attrs = attrs;
+
+ req->op.search.res = talloc_zero(NULL, struct ldb_result);
+
+ ret = self->ops->search(self, req);
+
+ *res = req->op.search.res;
+
+ talloc_free(req);
+
+ return ret;
}
-SWIGINTERN ldb_error ldb_module_add(ldb_module *self,struct ldb_request *req){
- return self->ops->add(self, req);
+SWIGINTERN ldb_error ldb_module_add(ldb_module *self,struct ldb_message *message){
+ struct ldb_request *req = talloc_zero(NULL, struct ldb_request);
+ req->operation = LDB_ADD;
+ req->op.add.message = message;
+
+ return self->ops->add(self, &req);
}
-SWIGINTERN ldb_error ldb_module_modify(ldb_module *self,struct ldb_request *req){
- return self->ops->modify(self, req);
+SWIGINTERN ldb_error ldb_module_modify(ldb_module *self,struct ldb_message *message){
+ struct ldb_request *req = talloc_zero(NULL, struct ldb_request);
+ req->operation = LDB_MODIFY;
+ req->op.mod.message = message;
+
+ return self->ops->modify(self, &req);
}
-SWIGINTERN ldb_error ldb_module_delete(ldb_module *self,struct ldb_request *req){
- return self->ops->del(self, req);
+SWIGINTERN ldb_error ldb_module_delete(ldb_module *self,struct ldb_dn *dn){
+ struct ldb_request *req = talloc_zero(NULL, struct ldb_request);
+ req->operation = LDB_DELETE;
+ req->op.del.dn = dn;
+
+ return self->ops->del(self, &req);
+
}
-SWIGINTERN ldb_error ldb_module_rename(ldb_module *self,struct ldb_request *req){
- return self->ops->rename(self, req);
+SWIGINTERN ldb_error ldb_module_rename(ldb_module *self,struct ldb_dn *olddn,struct ldb_dn *newdn){
+ struct ldb_request *req = talloc_zero(NULL, struct ldb_request);
+ req->operation = LDB_RENAME;
+ req->op.rename.olddn = olddn;
+ req->op.rename.olddn = newdn;
+
+ return self->ops->rename(self, &req);
}
SWIGINTERN ldb_error ldb_module_start_transaction(ldb_module *self){
return self->ops->start_transaction(self);
@@ -5000,11 +5034,15 @@ SWIGINTERN PyObject *_wrap_Ldb_search_ex(PyObject *SWIGUNUSEDPARM(self), PyObjec
SWIG_fail;
}
resultobj = Py_None;
- resultobj = PyList_New((*arg8)->count);
- for (i8 = 0; i8 < (*arg8)->count; i8++) {
- PyList_SetItem(resultobj, i8,
- SWIG_NewPointerObj((*arg8)->msgs[i8], SWIGTYPE_p_ldb_message, 0)
- );
+ if (arg8 == NULL) {
+ resultobj = Py_None;
+ } else {
+ resultobj = PyList_New((*arg8)->count);
+ for (i8 = 0; i8 < (*arg8)->count; i8++) {
+ PyList_SetItem(resultobj, i8,
+ SWIG_NewPointerObj((*arg8)->msgs[i8], SWIGTYPE_p_ldb_message, 0)
+ );
+ }
}
talloc_free(arg3);
if (alloc5 == SWIG_NEWOBJ) free((char*)buf5);
@@ -6235,33 +6273,80 @@ fail:
SWIGINTERN PyObject *_wrap_ldb_module_search(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
ldb_module *arg1 = (ldb_module *) 0 ;
- struct ldb_request *arg2 = (struct ldb_request *) 0 ;
+ struct ldb_dn *arg2 = (struct ldb_dn *) 0 ;
+ enum ldb_scope arg3 ;
+ struct ldb_parse_tree *arg4 = (struct ldb_parse_tree *) 0 ;
+ char **arg5 = (char **) 0 ;
+ struct ldb_result **arg6 = (struct ldb_result **) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 = 0 ;
int res2 = 0 ;
+ int val3 ;
+ int ecode3 = 0 ;
+ void *argp4 = 0 ;
+ int res4 = 0 ;
+ struct ldb_result *temp_ldb_result6 ;
+ int i6 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
char * kwnames[] = {
- (char *) "self",(char *) "req", NULL
+ (char *) "self",(char *) "base",(char *) "scope",(char *) "tree",(char *) "attrs", NULL
};
int result;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ldb_module_search",kwnames,&obj0,&obj1)) SWIG_fail;
+ arg6 = &temp_ldb_result6;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOO:ldb_module_search",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_module, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_search" "', argument " "1"" of type '" "ldb_module *""'");
}
arg1 = (ldb_module *)(argp1);
- res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_request, 0 | 0 );
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_dn, 0 | 0 );
if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_search" "', argument " "2"" of type '" "struct ldb_request *""'");
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_search" "', argument " "2"" of type '" "struct ldb_dn *""'");
}
- arg2 = (struct ldb_request *)(argp2);
- result = (int)ldb_module_search(arg1,arg2);
+ arg2 = (struct ldb_dn *)(argp2);
+ ecode3 = SWIG_AsVal_int(obj2, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "ldb_module_search" "', argument " "3"" of type '" "enum ldb_scope""'");
+ }
+ arg3 = (enum ldb_scope)(val3);
+ res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_ldb_parse_tree, 0 | 0 );
+ if (!SWIG_IsOK(res4)) {
+ SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "ldb_module_search" "', argument " "4"" of type '" "struct ldb_parse_tree *""'");
+ }
+ arg4 = (struct ldb_parse_tree *)(argp4);
+ if (obj4 == Py_None) {
+ arg5 = NULL;
+ } else if (PySequence_Check(obj4)) {
+ int i;
+ arg5 = talloc_array(NULL, char *, PySequence_Size(obj4)+1);
+ for(i = 0; i < PySequence_Size(obj4); i++)
+ arg5[i] = PyString_AsString(PySequence_GetItem(obj4, i));
+ arg5[i] = NULL;
+ } else {
+ SWIG_exception(SWIG_TypeError, "expected sequence");
+ }
+ result = (int)ldb_module_search(arg1,arg2,arg3,arg4,(char const *const *)arg5,arg6);
resultobj = SWIG_From_int((int)(result));
+ if (arg6 == NULL) {
+ resultobj = Py_None;
+ } else {
+ resultobj = PyList_New((*arg6)->count);
+ for (i6 = 0; i6 < (*arg6)->count; i6++) {
+ PyList_SetItem(resultobj, i6,
+ SWIG_NewPointerObj((*arg6)->msgs[i6], SWIGTYPE_p_ldb_message, 0)
+ );
+ }
+ }
+ talloc_free(arg5);
return resultobj;
fail:
+ talloc_free(arg5);
return NULL;
}
@@ -6269,7 +6354,7 @@ fail:
SWIGINTERN PyObject *_wrap_ldb_module_add(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
ldb_module *arg1 = (ldb_module *) 0 ;
- struct ldb_request *arg2 = (struct ldb_request *) 0 ;
+ struct ldb_message *arg2 = (struct ldb_message *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 = 0 ;
@@ -6277,7 +6362,7 @@ SWIGINTERN PyObject *_wrap_ldb_module_add(PyObject *SWIGUNUSEDPARM(self), PyObje
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
char * kwnames[] = {
- (char *) "self",(char *) "req", NULL
+ (char *) "self",(char *) "message", NULL
};
ldb_error result;
@@ -6287,11 +6372,11 @@ SWIGINTERN PyObject *_wrap_ldb_module_add(PyObject *SWIGUNUSEDPARM(self), PyObje
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_add" "', argument " "1"" of type '" "ldb_module *""'");
}
arg1 = (ldb_module *)(argp1);
- res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_request, 0 | 0 );
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_message, 0 | 0 );
if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_add" "', argument " "2"" of type '" "struct ldb_request *""'");
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_add" "', argument " "2"" of type '" "struct ldb_message *""'");
}
- arg2 = (struct ldb_request *)(argp2);
+ arg2 = (struct ldb_message *)(argp2);
result = ldb_module_add(arg1,arg2);
if (result != 0) {
PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1)));
@@ -6307,7 +6392,7 @@ fail:
SWIGINTERN PyObject *_wrap_ldb_module_modify(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
ldb_module *arg1 = (ldb_module *) 0 ;
- struct ldb_request *arg2 = (struct ldb_request *) 0 ;
+ struct ldb_message *arg2 = (struct ldb_message *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 = 0 ;
@@ -6315,7 +6400,7 @@ SWIGINTERN PyObject *_wrap_ldb_module_modify(PyObject *SWIGUNUSEDPARM(self), PyO
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
char * kwnames[] = {
- (char *) "self",(char *) "req", NULL
+ (char *) "self",(char *) "message", NULL
};
ldb_error result;
@@ -6325,11 +6410,11 @@ SWIGINTERN PyObject *_wrap_ldb_module_modify(PyObject *SWIGUNUSEDPARM(self), PyO
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_modify" "', argument " "1"" of type '" "ldb_module *""'");
}
arg1 = (ldb_module *)(argp1);
- res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_request, 0 | 0 );
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_message, 0 | 0 );
if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_modify" "', argument " "2"" of type '" "struct ldb_request *""'");
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_modify" "', argument " "2"" of type '" "struct ldb_message *""'");
}
- arg2 = (struct ldb_request *)(argp2);
+ arg2 = (struct ldb_message *)(argp2);
result = ldb_module_modify(arg1,arg2);
if (result != 0) {
PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1)));
@@ -6345,7 +6430,7 @@ fail:
SWIGINTERN PyObject *_wrap_ldb_module_delete(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
ldb_module *arg1 = (ldb_module *) 0 ;
- struct ldb_request *arg2 = (struct ldb_request *) 0 ;
+ struct ldb_dn *arg2 = (struct ldb_dn *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 = 0 ;
@@ -6353,7 +6438,7 @@ SWIGINTERN PyObject *_wrap_ldb_module_delete(PyObject *SWIGUNUSEDPARM(self), PyO
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
char * kwnames[] = {
- (char *) "self",(char *) "req", NULL
+ (char *) "self",(char *) "dn", NULL
};
ldb_error result;
@@ -6363,11 +6448,11 @@ SWIGINTERN PyObject *_wrap_ldb_module_delete(PyObject *SWIGUNUSEDPARM(self), PyO
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_delete" "', argument " "1"" of type '" "ldb_module *""'");
}
arg1 = (ldb_module *)(argp1);
- res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_request, 0 | 0 );
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_dn, 0 | 0 );
if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_delete" "', argument " "2"" of type '" "struct ldb_request *""'");
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_delete" "', argument " "2"" of type '" "struct ldb_dn *""'");
}
- arg2 = (struct ldb_request *)(argp2);
+ arg2 = (struct ldb_dn *)(argp2);
result = ldb_module_delete(arg1,arg2);
if (result != 0) {
PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1)));
@@ -6383,30 +6468,39 @@ fail:
SWIGINTERN PyObject *_wrap_ldb_module_rename(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
ldb_module *arg1 = (ldb_module *) 0 ;
- struct ldb_request *arg2 = (struct ldb_request *) 0 ;
+ struct ldb_dn *arg2 = (struct ldb_dn *) 0 ;
+ struct ldb_dn *arg3 = (struct ldb_dn *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 = 0 ;
int res2 = 0 ;
+ void *argp3 = 0 ;
+ int res3 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
char * kwnames[] = {
- (char *) "self",(char *) "req", NULL
+ (char *) "self",(char *) "olddn",(char *) "newdn", NULL
};
ldb_error result;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ldb_module_rename",kwnames,&obj0,&obj1)) SWIG_fail;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:ldb_module_rename",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_module, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_rename" "', argument " "1"" of type '" "ldb_module *""'");
}
arg1 = (ldb_module *)(argp1);
- res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_request, 0 | 0 );
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_dn, 0 | 0 );
if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_rename" "', argument " "2"" of type '" "struct ldb_request *""'");
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_rename" "', argument " "2"" of type '" "struct ldb_dn *""'");
+ }
+ arg2 = (struct ldb_dn *)(argp2);
+ res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_ldb_dn, 0 | 0 );
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ldb_module_rename" "', argument " "3"" of type '" "struct ldb_dn *""'");
}
- arg2 = (struct ldb_request *)(argp2);
- result = ldb_module_rename(arg1,arg2);
+ arg3 = (struct ldb_dn *)(argp3);
+ result = ldb_module_rename(arg1,arg2,arg3);
if (result != 0) {
PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1)));
SWIG_fail;
@@ -6788,7 +6882,6 @@ static swig_type_info _swigt__p_ldb_message_element = {"_p_ldb_message_element",
static swig_type_info _swigt__p_ldb_module = {"_p_ldb_module", "struct ldb_module *|ldb_module *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_module_ops = {"_p_ldb_module_ops", "struct ldb_module_ops *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_parse_tree = {"_p_ldb_parse_tree", "struct ldb_parse_tree *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_ldb_request = {"_p_ldb_request", "struct ldb_request *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_result = {"_p_ldb_result", "struct ldb_result *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_val = {"_p_ldb_val", "struct ldb_val *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_long_long = {"_p_long_long", "int_least64_t *|int_fast64_t *|int64_t *|long long *|intmax_t *", 0, 0, (void*)0, 0};
@@ -6817,7 +6910,6 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_ldb_module,
&_swigt__p_ldb_module_ops,
&_swigt__p_ldb_parse_tree,
- &_swigt__p_ldb_request,
&_swigt__p_ldb_result,
&_swigt__p_ldb_val,
&_swigt__p_long_long,
@@ -6846,7 +6938,6 @@ static swig_cast_info _swigc__p_ldb_message_element[] = { {&_swigt__p_ldb_messa
static swig_cast_info _swigc__p_ldb_module[] = { {&_swigt__p_ldb_module, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_ldb_module_ops[] = { {&_swigt__p_ldb_module_ops, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_ldb_parse_tree[] = { {&_swigt__p_ldb_parse_tree, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_ldb_request[] = { {&_swigt__p_ldb_request, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_ldb_result[] = { {&_swigt__p_ldb_result, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_ldb_val[] = { {&_swigt__p_ldb_val, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}};
@@ -6875,7 +6966,6 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_ldb_module,
_swigc__p_ldb_module_ops,
_swigc__p_ldb_parse_tree,
- _swigc__p_ldb_request,
_swigc__p_ldb_result,
_swigc__p_ldb_val,
_swigc__p_long_long,
diff --git a/source4/lib/ldb/tests/python/api.py b/source4/lib/ldb/tests/python/api.py
index bc3bbc1c8c..4b3501839f 100755
--- a/source4/lib/ldb/tests/python/api.py
+++ b/source4/lib/ldb/tests/python/api.py
@@ -2,7 +2,7 @@
# Simple tests for the ldb python bindings.
# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-import sys
+import os, sys
import unittest
# Required for the standalone LDB build
@@ -472,11 +472,16 @@ class ModuleTests(unittest.TestCase):
def __init__(self, ldb, next):
ops.append("init")
+ self.next = next
+
+ def search(self, *args, **kwargs):
+ return self.next.search(*args, **kwargs)
ldb.register_module(ExampleModule)
+ if os.path.exists("usemodule.ldb"):
+ os.unlink("usemodule.ldb")
l = ldb.Ldb("usemodule.ldb")
- l.add({"dn": "@MODULES",
- "@LIST": "bla"})
+ l.add({"dn": "@MODULES", "@LIST": "bla"})
self.assertEquals([], ops)
l = ldb.Ldb("usemodule.ldb")
self.assertEquals(["init"], ops)