summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/Makefile2
-rw-r--r--source4/auth/config.m41
-rw-r--r--source4/build/m4/public.m44
-rw-r--r--source4/build/smb_build/main.pl2
-rw-r--r--source4/configure.ac10
-rw-r--r--source4/headermap.txt2
-rw-r--r--source4/include/includes.h4
-rw-r--r--source4/lib/events/tevent_s4.c2
-rw-r--r--source4/lib/ldb/common/ldb.c37
-rw-r--r--source4/lib/tdr/TODO1
-rw-r--r--source4/lib/tdr/config.mk9
-rw-r--r--source4/lib/tdr/tdr.c397
-rw-r--r--source4/lib/tdr/tdr.h67
-rw-r--r--source4/lib/tdr/testsuite.c186
-rw-r--r--source4/main.mk2
-rw-r--r--source4/min_versions.m46
-rw-r--r--source4/scripting/python/samba/samdb.py27
-rw-r--r--source4/torture/ldap/cldapbench.c85
-rw-r--r--source4/torture/local/config.mk2
-rw-r--r--source4/torture/rpc/spoolss.c2
20 files changed, 154 insertions, 694 deletions
diff --git a/source4/Makefile b/source4/Makefile
index 15b1b8ba40..c42f0ba9ff 100644
--- a/source4/Makefile
+++ b/source4/Makefile
@@ -77,7 +77,7 @@ nsswrappersrcdir := ../lib/nss_wrapper
appwebsrcdir := lib/appweb
libstreamsrcdir := lib/stream
libutilsrcdir := ../lib/util
-libtdrsrcdir := lib/tdr
+libtdrsrcdir := ../lib/tdr
libcryptosrcdir := ../lib/crypto
libtorturesrcdir := ../lib/torture
smb_serversrcdir := smb_server
diff --git a/source4/auth/config.m4 b/source4/auth/config.m4
index a271a9f6fe..fb9ee58c60 100644
--- a/source4/auth/config.m4
+++ b/source4/auth/config.m4
@@ -27,6 +27,7 @@ if test x"$ac_cv_header_sasl_sasl_h" = x"yes" -a x"$ac_cv_lib_ext_sasl2_sasl_cli
SASL_CFLAGS="$CFLAGS"
SASL_CPPFLAGS="$CPPFLAGS"
SASL_LDFLAGS="$LDFLAGS"
+ LIB_REMOVE_USR_LIB(SASL_LDFLAGS)
else
SMB_ENABLE(cyrus_sasl,NO)
fi
diff --git a/source4/build/m4/public.m4 b/source4/build/m4/public.m4
index ffdf92f784..6860e56e7f 100644
--- a/source4/build/m4/public.m4
+++ b/source4/build/m4/public.m4
@@ -99,11 +99,13 @@ AC_DEFUN([SMB_EXT_LIB_FROM_PKGCONFIG],
AC_MSG_WARN([cannot run when cross-compiling]))
CFLAGS="$OLD_CFLAGS"
+ ac_cv_$1_libs_only_other="`$PKG_CONFIG --libs-only-other '$2'` `$PKG_CONFIG --libs-only-L '$2'`"
+ LIB_REMOVE_USR_LIB(ac_cv_$1_libs_only_other)
SMB_EXT_LIB($1,
[`$PKG_CONFIG --libs-only-l '$2'`],
[`$PKG_CONFIG --cflags-only-other '$2'`],
[`$PKG_CONFIG --cflags-only-I '$2'`],
- [`$PKG_CONFIG --libs-only-other '$2'` `$PKG_CONFIG --libs-only-L '$2'`])
+ [$ac_cv_$1_libs_only_other])
ac_cv_$1_found=yes
else
diff --git a/source4/build/smb_build/main.pl b/source4/build/smb_build/main.pl
index 3c84a91a59..0d19e41827 100644
--- a/source4/build/smb_build/main.pl
+++ b/source4/build/smb_build/main.pl
@@ -73,7 +73,7 @@ foreach my $key (values %$OUTPUT) {
$shared_libs_used = 1;
}
if ($key->{TYPE} eq "MODULE" and @{$key->{OUTPUT_TYPE}}[0] eq "MERGED_OBJ" and defined($key->{INIT_FUNCTION})) {
- $mkenv->output("$key->{SUBSYSTEM}_INIT_FUNCTIONS += $key->{INIT_FUNCTION},\n");
+ $mkenv->output("$key->{SUBSYSTEM}_INIT_FUNCTIONS +=$key->{INIT_FUNCTION},\n");
}
$mkenv->CFlags($key);
}
diff --git a/source4/configure.ac b/source4/configure.ac
index d33df08406..065a3300ca 100644
--- a/source4/configure.ac
+++ b/source4/configure.ac
@@ -42,14 +42,16 @@ AC_CONFIG_FILES(param/samba-hostconfig.pc)
AC_CONFIG_FILES(librpc/dcerpc_samr.pc)
AC_CONFIG_FILES(librpc/dcerpc_atsvc.pc)
-SMB_INCLUDED_LIB_PKGCONFIG(LIBTALLOC, talloc >= 1.2.1, [],
+m4_include(min_versions.m4)
+
+SMB_INCLUDED_LIB_PKGCONFIG(LIBTALLOC, talloc >= $TALLOC_MIN_VERSION, [],
[
m4_include(../lib/talloc/libtalloc.m4)
SMB_INCLUDE_MK(../lib/talloc/config.mk)
]
)
-SMB_INCLUDED_LIB_PKGCONFIG(LIBTDB, tdb >= 1.1.3,
+SMB_INCLUDED_LIB_PKGCONFIG(LIBTDB, tdb >= $TDB_MIN_VERSION,
[],
[
m4_include(../lib/tdb/libtdb.m4)
@@ -59,13 +61,13 @@ SMB_INCLUDED_LIB_PKGCONFIG(LIBTDB, tdb >= 1.1.3,
SMB_INCLUDE_MK(../lib/tdb/python.mk)
-SMB_INCLUDED_LIB_PKGCONFIG(LIBTEVENT, tevent = 0.9.3,
+SMB_INCLUDED_LIB_PKGCONFIG(LIBTEVENT, tevent = TEVENT_REQUIRED_VERSION,
[],[m4_include(../lib/tevent/samba.m4)]
)
SMB_INCLUDE_MK(../lib/tevent/python.mk)
-SMB_INCLUDED_LIB_PKGCONFIG(LIBLDB, ldb = 0.9.3,
+SMB_INCLUDED_LIB_PKGCONFIG(LIBLDB, ldb = $LDB_REQUIRED_VERSION,
[
SMB_INCLUDE_MK(lib/ldb/ldb_ildap/config.mk)
SMB_INCLUDE_MK(lib/ldb/tools/config.mk)
diff --git a/source4/headermap.txt b/source4/headermap.txt
index 8287044622..9de5b1cc0c 100644
--- a/source4/headermap.txt
+++ b/source4/headermap.txt
@@ -9,7 +9,7 @@
../lib/util/memory.h: util/memory.h
../lib/util/talloc_stack.h: util/talloc_stack.h
../lib/util/xfile.h: util/xfile.h
-lib/tdr/tdr.h: tdr.h
+../lib/tdr/tdr.h: tdr.h
librpc/rpc/dcerpc.h: dcerpc.h
lib/ldb/include/ldb.h: ldb.h
lib/ldb/include/ldb_errors.h: ldb_errors.h
diff --git a/source4/include/includes.h b/source4/include/includes.h
index ddda21f9d8..d9b7759e7e 100644
--- a/source4/include/includes.h
+++ b/source4/include/includes.h
@@ -64,10 +64,6 @@
/* String routines */
#include "../lib/util/safe_string.h"
-#ifndef CONST_DISCARD
-#define CONST_DISCARD(type, ptr) ((type) ((void *) (ptr)))
-#endif
-
#if 0
/* darn, we can't do this now that we don't link the ldb tools to all the smb libs */
#define TALLOC_ABORT(reason) smb_panic(reason)
diff --git a/source4/lib/events/tevent_s4.c b/source4/lib/events/tevent_s4.c
index 89ca7bbe5c..06bfbf61ed 100644
--- a/source4/lib/events/tevent_s4.c
+++ b/source4/lib/events/tevent_s4.c
@@ -17,6 +17,7 @@
*/
#include "includes.h"
+#define TEVENT_DEPRECATED 1
#include "lib/events/events.h"
/*
@@ -65,6 +66,7 @@ struct tevent_context *s4_event_context_init(TALLOC_CTX *mem_ctx)
ev = tevent_context_init_byname(mem_ctx, NULL);
if (ev) {
tevent_set_debug(ev, ev_wrap_debug, NULL);
+ tevent_loop_allow_nesting(ev);
}
return ev;
}
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index f1b28b6819..86ce2069a5 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -32,6 +32,7 @@
* Author: Andrew Tridgell
*/
+#define TEVENT_DEPRECATED 1
#include "ldb_private.h"
static int ldb_context_destructor(void *ptr)
@@ -48,6 +49,40 @@ static int ldb_context_destructor(void *ptr)
}
/*
+ this is used to catch debug messages from events
+*/
+static void ldb_tevent_debug(void *context, enum tevent_debug_level level,
+ const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0);
+
+static void ldb_tevent_debug(void *context, enum tevent_debug_level level,
+ const char *fmt, va_list ap)
+{
+ struct ldb_context *ldb = talloc_get_type(context, struct ldb_context);
+ enum ldb_debug_level ldb_level = LDB_DEBUG_FATAL;
+ char *s = NULL;
+
+ switch (level) {
+ case TEVENT_DEBUG_FATAL:
+ ldb_level = LDB_DEBUG_FATAL;
+ break;
+ case TEVENT_DEBUG_ERROR:
+ ldb_level = LDB_DEBUG_ERROR;
+ break;
+ case TEVENT_DEBUG_WARNING:
+ ldb_level = LDB_DEBUG_WARNING;
+ break;
+ case TEVENT_DEBUG_TRACE:
+ ldb_level = LDB_DEBUG_TRACE;
+ break;
+ };
+
+ vasprintf(&s, fmt, ap);
+ if (!s) return;
+ ldb_debug(ldb, ldb_level, "tevent: %s", s);
+ free(s);
+}
+
+/*
initialise a ldb context
The mem_ctx is required
The event_ctx is required
@@ -62,6 +97,8 @@ struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx)
* until we have them all converted */
if (ev_ctx == NULL) {
ev_ctx = tevent_context_init(talloc_autofree_context());
+ tevent_set_debug(ev_ctx, ldb_tevent_debug, ldb);
+ tevent_loop_allow_nesting(ev_ctx);
}
ret = ldb_setup_wellknown_attributes(ldb);
diff --git a/source4/lib/tdr/TODO b/source4/lib/tdr/TODO
deleted file mode 100644
index 5093afd438..0000000000
--- a/source4/lib/tdr/TODO
+++ /dev/null
@@ -1 +0,0 @@
-- Support read/write (to fd) as well as push/pull (to DATA_BLOB)
diff --git a/source4/lib/tdr/config.mk b/source4/lib/tdr/config.mk
deleted file mode 100644
index 07506ec647..0000000000
--- a/source4/lib/tdr/config.mk
+++ /dev/null
@@ -1,9 +0,0 @@
-[SUBSYSTEM::TDR]
-CFLAGS = -Ilib/tdr
-PUBLIC_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL
-
-TDR_OBJ_FILES = $(libtdrsrcdir)/tdr.o
-
-$(eval $(call proto_header_template,$(libtdrsrcdir)/tdr_proto.h,$(TDR_OBJ_FILES:.o=.c)))
-
-PUBLIC_HEADERS += $(libtdrsrcdir)/tdr.h
diff --git a/source4/lib/tdr/tdr.c b/source4/lib/tdr/tdr.c
deleted file mode 100644
index 8b62ea0c2b..0000000000
--- a/source4/lib/tdr/tdr.c
+++ /dev/null
@@ -1,397 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- TDR (Trivial Data Representation) helper functions
- Based loosely on ndr.c by Andrew Tridgell.
-
- Copyright (C) Jelmer Vernooij 2005
-
- 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/>.
-*/
-
-#include "includes.h"
-#include "system/filesys.h"
-#include "system/network.h"
-#include "tdr/tdr.h"
-
-#define TDR_BASE_MARSHALL_SIZE 1024
-
-#define TDR_PUSH_NEED_BYTES(tdr, n) TDR_CHECK(tdr_push_expand(tdr, tdr->data.length+(n)))
-
-#define TDR_PULL_NEED_BYTES(tdr, n) do { \
- if ((n) > tdr->data.length || tdr->offset + (n) > tdr->data.length) { \
- return NT_STATUS_BUFFER_TOO_SMALL; \
- } \
-} while(0)
-
-#define TDR_BE(tdr) ((tdr)->flags & TDR_BIG_ENDIAN)
-
-#define TDR_CVAL(tdr, ofs) CVAL(tdr->data.data,ofs)
-#define TDR_SVAL(tdr, ofs) (TDR_BE(tdr)?RSVAL(tdr->data.data,ofs):SVAL(tdr->data.data,ofs))
-#define TDR_IVAL(tdr, ofs) (TDR_BE(tdr)?RIVAL(tdr->data.data,ofs):IVAL(tdr->data.data,ofs))
-#define TDR_SCVAL(tdr, ofs, v) SCVAL(tdr->data.data,ofs,v)
-#define TDR_SSVAL(tdr, ofs, v) do { if (TDR_BE(tdr)) { RSSVAL(tdr->data.data,ofs,v); } else SSVAL(tdr->data.data,ofs,v); } while (0)
-#define TDR_SIVAL(tdr, ofs, v) do { if (TDR_BE(tdr)) { RSIVAL(tdr->data.data,ofs,v); } else SIVAL(tdr->data.data,ofs,v); } while (0)
-
-/**
- expand the available space in the buffer to 'size'
-*/
-NTSTATUS tdr_push_expand(struct tdr_push *tdr, uint32_t size)
-{
- if (talloc_get_size(tdr->data.data) >= size) {
- return NT_STATUS_OK;
- }
-
- tdr->data.data = talloc_realloc(tdr, tdr->data.data, uint8_t, tdr->data.length + TDR_BASE_MARSHALL_SIZE);
-
- if (tdr->data.data == NULL)
- return NT_STATUS_NO_MEMORY;
-
- return NT_STATUS_OK;
-}
-
-
-NTSTATUS tdr_pull_uint8(struct tdr_pull *tdr, TALLOC_CTX *ctx, uint8_t *v)
-{
- TDR_PULL_NEED_BYTES(tdr, 1);
- *v = TDR_CVAL(tdr, tdr->offset);
- tdr->offset += 1;
- return NT_STATUS_OK;
-}
-
-NTSTATUS tdr_push_uint8(struct tdr_push *tdr, const uint8_t *v)
-{
- TDR_PUSH_NEED_BYTES(tdr, 1);
- TDR_SCVAL(tdr, tdr->data.length, *v);
- tdr->data.length += 1;
- return NT_STATUS_OK;
-}
-
-NTSTATUS tdr_print_uint8(struct tdr_print *tdr, const char *name, uint8_t *v)
-{
- tdr->print(tdr, "%-25s: 0x%02x (%u)", name, *v, *v);
- return NT_STATUS_OK;
-}
-
-NTSTATUS tdr_pull_uint16(struct tdr_pull *tdr, TALLOC_CTX *ctx, uint16_t *v)
-{
- TDR_PULL_NEED_BYTES(tdr, 2);
- *v = TDR_SVAL(tdr, tdr->offset);
- tdr->offset += 2;
- return NT_STATUS_OK;
-}
-
-NTSTATUS tdr_push_uint16(struct tdr_push *tdr, const uint16_t *v)
-{
- TDR_PUSH_NEED_BYTES(tdr, 2);
- TDR_SSVAL(tdr, tdr->data.length, *v);
- tdr->data.length += 2;
- return NT_STATUS_OK;
-}
-
-NTSTATUS tdr_print_uint16(struct tdr_print *tdr, const char *name, uint16_t *v)
-{
- tdr->print(tdr, "%-25s: 0x%02x (%u)", name, *v, *v);
- return NT_STATUS_OK;
-}
-
-NTSTATUS tdr_pull_uint32(struct tdr_pull *tdr, TALLOC_CTX *ctx, uint32_t *v)
-{
- TDR_PULL_NEED_BYTES(tdr, 4);
- *v = TDR_IVAL(tdr, tdr->offset);
- tdr->offset += 4;
- return NT_STATUS_OK;
-}
-
-NTSTATUS tdr_push_uint32(struct tdr_push *tdr, const uint32_t *v)
-{
- TDR_PUSH_NEED_BYTES(tdr, 4);
- TDR_SIVAL(tdr, tdr->data.length, *v);
- tdr->data.length += 4;
- return NT_STATUS_OK;
-}
-
-NTSTATUS tdr_print_uint32(struct tdr_print *tdr, const char *name, uint32_t *v)
-{
- tdr->print(tdr, "%-25s: 0x%02x (%u)", name, *v, *v);
- return NT_STATUS_OK;
-}
-
-NTSTATUS tdr_pull_charset(struct tdr_pull *tdr, TALLOC_CTX *ctx, const char **v, uint32_t length, uint32_t el_size, charset_t chset)
-{
- size_t ret;
-
- if (length == -1) {
- switch (chset) {
- case CH_DOS:
- length = ascii_len_n((const char*)tdr->data.data+tdr->offset, tdr->data.length-tdr->offset);
- break;
- case CH_UTF16:
- length = utf16_len_n(tdr->data.data+tdr->offset, tdr->data.length-tdr->offset);
- break;
-
- default:
- return NT_STATUS_INVALID_PARAMETER;
- }
- }
-
- if (length == 0) {
- *v = talloc_strdup(ctx, "");
- return NT_STATUS_OK;
- }
-
- TDR_PULL_NEED_BYTES(tdr, el_size*length);
-
- if (!convert_string_talloc_convenience(ctx, tdr->iconv_convenience, chset, CH_UNIX, tdr->data.data+tdr->offset, el_size*length, discard_const_p(void *, v), &ret, false)) {
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- tdr->offset += length * el_size;
-
- return NT_STATUS_OK;
-}
-
-NTSTATUS tdr_push_charset(struct tdr_push *tdr, const char **v, uint32_t length, uint32_t el_size, charset_t chset)
-{
- size_t ret, required;
-
- if (length == -1) {
- length = strlen(*v) + 1; /* Extra element for null character */
- }
-
- required = el_size * length;
- TDR_PUSH_NEED_BYTES(tdr, required);
-
- if (!convert_string_convenience(tdr->iconv_convenience, CH_UNIX, chset, *v, strlen(*v), tdr->data.data+tdr->data.length, required, &ret, false)) {
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- /* Make sure the remaining part of the string is filled with zeroes */
- if (ret < required) {
- memset(tdr->data.data+tdr->data.length+ret, 0, required-ret);
- }
-
- tdr->data.length += required;
-
- return NT_STATUS_OK;
-}
-
-NTSTATUS tdr_print_charset(struct tdr_print *tdr, const char *name, const char **v, uint32_t length, uint32_t el_size, charset_t chset)
-{
- tdr->print(tdr, "%-25s: %s", name, *v);
- return NT_STATUS_OK;
-}
-
-/**
- parse a hyper
-*/
-NTSTATUS tdr_pull_hyper(struct tdr_pull *tdr, TALLOC_CTX *ctx, uint64_t *v)
-{
- TDR_PULL_NEED_BYTES(tdr, 8);
- *v = TDR_IVAL(tdr, tdr->offset);
- *v |= (uint64_t)(TDR_IVAL(tdr, tdr->offset+4)) << 32;
- tdr->offset += 8;
- return NT_STATUS_OK;
-}
-
-/**
- push a hyper
-*/
-NTSTATUS tdr_push_hyper(struct tdr_push *tdr, uint64_t *v)
-{
- TDR_PUSH_NEED_BYTES(tdr, 8);
- TDR_SIVAL(tdr, tdr->data.length, ((*v) & 0xFFFFFFFF));
- TDR_SIVAL(tdr, tdr->data.length+4, ((*v)>>32));
- tdr->data.length += 8;
- return NT_STATUS_OK;
-}
-
-/**
- push a NTTIME
-*/
-NTSTATUS tdr_push_NTTIME(struct tdr_push *tdr, NTTIME *t)
-{
- TDR_CHECK(tdr_push_hyper(tdr, t));
- return NT_STATUS_OK;
-}
-
-/**
- pull a NTTIME
-*/
-NTSTATUS tdr_pull_NTTIME(struct tdr_pull *tdr, TALLOC_CTX *ctx, NTTIME *t)
-{
- TDR_CHECK(tdr_pull_hyper(tdr, ctx, t));
- return NT_STATUS_OK;
-}
-
-/**
- push a time_t
-*/
-NTSTATUS tdr_push_time_t(struct tdr_push *tdr, time_t *t)
-{
- return tdr_push_uint32(tdr, (uint32_t *)t);
-}
-
-/**
- pull a time_t
-*/
-NTSTATUS tdr_pull_time_t(struct tdr_pull *tdr, TALLOC_CTX *ctx, time_t *t)
-{
- uint32_t tt;
- TDR_CHECK(tdr_pull_uint32(tdr, ctx, &tt));
- *t = tt;
- return NT_STATUS_OK;
-}
-
-NTSTATUS tdr_print_time_t(struct tdr_print *tdr, const char *name, time_t *t)
-{
- if (*t == (time_t)-1 || *t == 0) {
- tdr->print(tdr, "%-25s: (time_t)%d", name, (int)*t);
- } else {
- tdr->print(tdr, "%-25s: %s", name, timestring(tdr, *t));
- }
-
- return NT_STATUS_OK;
-}
-
-NTSTATUS tdr_print_NTTIME(struct tdr_print *tdr, const char *name, NTTIME *t)
-{
- tdr->print(tdr, "%-25s: %s", name, nt_time_string(tdr, *t));
-
- return NT_STATUS_OK;
-}
-
-NTSTATUS tdr_print_DATA_BLOB(struct tdr_print *tdr, const char *name, DATA_BLOB *r)
-{
- tdr->print(tdr, "%-25s: DATA_BLOB length=%u", name, r->length);
- if (r->length) {
- dump_data(10, r->data, r->length);
- }
-
- return NT_STATUS_OK;
-}
-
-#define TDR_ALIGN(l,n) (((l) & ((n)-1)) == 0?0:((n)-((l)&((n)-1))))
-
-/*
- push a DATA_BLOB onto the wire.
-*/
-NTSTATUS tdr_push_DATA_BLOB(struct tdr_push *tdr, DATA_BLOB *blob)
-{
- if (tdr->flags & TDR_ALIGN2) {
- blob->length = TDR_ALIGN(tdr->data.length, 2);
- } else if (tdr->flags & TDR_ALIGN4) {
- blob->length = TDR_ALIGN(tdr->data.length, 4);
- } else if (tdr->flags & TDR_ALIGN8) {
- blob->length = TDR_ALIGN(tdr->data.length, 8);
- }
-
- TDR_PUSH_NEED_BYTES(tdr, blob->length);
-
- memcpy(tdr->data.data+tdr->data.length, blob->data, blob->length);
- return NT_STATUS_OK;
-}
-
-/*
- pull a DATA_BLOB from the wire.
-*/
-NTSTATUS tdr_pull_DATA_BLOB(struct tdr_pull *tdr, TALLOC_CTX *ctx, DATA_BLOB *blob)
-{
- uint32_t length;
-
- if (tdr->flags & TDR_ALIGN2) {
- length = TDR_ALIGN(tdr->offset, 2);
- } else if (tdr->flags & TDR_ALIGN4) {
- length = TDR_ALIGN(tdr->offset, 4);
- } else if (tdr->flags & TDR_ALIGN8) {
- length = TDR_ALIGN(tdr->offset, 8);
- } else if (tdr->flags & TDR_REMAINING) {
- length = tdr->data.length - tdr->offset;
- } else {
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- if (tdr->data.length - tdr->offset < length) {
- length = tdr->data.length - tdr->offset;
- }
-
- TDR_PULL_NEED_BYTES(tdr, length);
-
- *blob = data_blob_talloc(tdr, tdr->data.data+tdr->offset, length);
- tdr->offset += length;
- return NT_STATUS_OK;
-}
-
-struct tdr_push *tdr_push_init(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *ic)
-{
- struct tdr_push *push = talloc_zero(mem_ctx, struct tdr_push);
-
- if (push == NULL)
- return NULL;
-
- push->iconv_convenience = talloc_reference(push, ic);
-
- return push;
-}
-
-struct tdr_pull *tdr_pull_init(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *ic)
-{
- struct tdr_pull *pull = talloc_zero(mem_ctx, struct tdr_pull);
-
- if (pull == NULL)
- return NULL;
-
- pull->iconv_convenience = talloc_reference(pull, ic);
-
- return pull;
-}
-
-NTSTATUS tdr_push_to_fd(int fd, struct smb_iconv_convenience *iconv_convenience, tdr_push_fn_t push_fn, const void *p)
-{
- struct tdr_push *push = tdr_push_init(NULL, iconv_convenience);
-
- if (push == NULL)
- return NT_STATUS_NO_MEMORY;
-
- if (NT_STATUS_IS_ERR(push_fn(push, p))) {
- DEBUG(1, ("Error pushing data\n"));
- talloc_free(push);
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- if (write(fd, push->data.data, push->data.length) < push->data.length) {
- DEBUG(1, ("Error writing all data\n"));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- talloc_free(push);
-
- return NT_STATUS_OK;
-}
-
-void tdr_print_debug_helper(struct tdr_print *tdr, const char *format, ...) _PRINTF_ATTRIBUTE(2,3)
-{
- va_list ap;
- char *s = NULL;
- int i;
-
- va_start(ap, format);
- vasprintf(&s, format, ap);
- va_end(ap);
-
- for (i=0;i<tdr->level;i++) { DEBUG(0,(" ")); }
-
- DEBUG(0,("%s\n", s));
- free(s);
-}
diff --git a/source4/lib/tdr/tdr.h b/source4/lib/tdr/tdr.h
deleted file mode 100644
index c983cd35c1..0000000000
--- a/source4/lib/tdr/tdr.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- TDR definitions
- Copyright (C) Jelmer Vernooij 2005
-
- 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/>.
-*/
-
-#ifndef __TDR_H__
-#define __TDR_H__
-
-#include <talloc.h>
-#include "../lib/util/charset/charset.h"
-
-#define TDR_BIG_ENDIAN 0x01
-#define TDR_ALIGN2 0x02
-#define TDR_ALIGN4 0x04
-#define TDR_ALIGN8 0x08
-#define TDR_REMAINING 0x10
-
-struct tdr_pull {
- DATA_BLOB data;
- uint32_t offset;
- int flags;
- struct smb_iconv_convenience *iconv_convenience;
-};
-
-struct tdr_push {
- DATA_BLOB data;
- int flags;
- struct smb_iconv_convenience *iconv_convenience;
-};
-
-struct tdr_print {
- int level;
- void (*print)(struct tdr_print *, const char *, ...);
- int flags;
-};
-
-#define TDR_CHECK(call) do { NTSTATUS _status; \
- _status = call; \
- if (!NT_STATUS_IS_OK(_status)) \
- return _status; \
- } while (0)
-
-#define TDR_ALLOC(ctx, s, n) do { \
- (s) = talloc_array_size(ctx, sizeof(*(s)), n); \
- if ((n) && !(s)) return NT_STATUS_NO_MEMORY; \
- } while (0)
-
-typedef NTSTATUS (*tdr_push_fn_t) (struct tdr_push *, const void *);
-typedef NTSTATUS (*tdr_pull_fn_t) (struct tdr_pull *, TALLOC_CTX *, void *);
-
-#include "lib/tdr/tdr_proto.h"
-
-#endif /* __TDR_H__ */
diff --git a/source4/lib/tdr/testsuite.c b/source4/lib/tdr/testsuite.c
deleted file mode 100644
index 44c5810f90..0000000000
--- a/source4/lib/tdr/testsuite.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- test suite for basic tdr functions
-
- Copyright (C) Jelmer Vernooij 2007
-
- 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/>.
-*/
-
-#include "includes.h"
-#include "torture/torture.h"
-#include "lib/tdr/tdr.h"
-#include "param/param.h"
-
-static bool test_push_uint8(struct torture_context *tctx)
-{
- uint8_t v = 4;
- struct tdr_push *tdr = tdr_push_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
-
- torture_assert_ntstatus_ok(tctx, tdr_push_uint8(tdr, &v), "push failed");
- torture_assert_int_equal(tctx, tdr->data.length, 1, "length incorrect");
- torture_assert_int_equal(tctx, tdr->data.data[0], 4, "data incorrect");
- return true;
-}
-
-static bool test_pull_uint8(struct torture_context *tctx)
-{
- uint8_t d = 2;
- uint8_t l;
- struct tdr_pull *tdr = tdr_pull_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
- tdr->data.data = &d;
- tdr->data.length = 1;
- tdr->offset = 0;
- tdr->flags = 0;
- torture_assert_ntstatus_ok(tctx, tdr_pull_uint8(tdr, tctx, &l),
- "pull failed");
- torture_assert_int_equal(tctx, 1, tdr->offset,
- "offset invalid");
- return true;
-}
-
-static bool test_push_uint16(struct torture_context *tctx)
-{
- uint16_t v = 0xF32;
- struct tdr_push *tdr = tdr_push_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
-
- torture_assert_ntstatus_ok(tctx, tdr_push_uint16(tdr, &v), "push failed");
- torture_assert_int_equal(tctx, tdr->data.length, 2, "length incorrect");
- torture_assert_int_equal(tctx, tdr->data.data[0], 0x32, "data incorrect");
- torture_assert_int_equal(tctx, tdr->data.data[1], 0x0F, "data incorrect");
- return true;
-}
-
-static bool test_pull_uint16(struct torture_context *tctx)
-{
- uint8_t d[2] = { 782 & 0xFF, (782 & 0xFF00) / 0x100 };
- uint16_t l;
- struct tdr_pull *tdr = tdr_pull_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
- tdr->data.data = d;
- tdr->data.length = 2;
- tdr->offset = 0;
- tdr->flags = 0;
- torture_assert_ntstatus_ok(tctx, tdr_pull_uint16(tdr, tctx, &l),
- "pull failed");
- torture_assert_int_equal(tctx, 2, tdr->offset, "offset invalid");
- torture_assert_int_equal(tctx, 782, l, "right int read");
- return true;
-}
-
-static bool test_push_uint32(struct torture_context *tctx)
-{
- uint32_t v = 0x100F32;
- struct tdr_push *tdr = tdr_push_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
-
- torture_assert_ntstatus_ok(tctx, tdr_push_uint32(tdr, &v), "push failed");
- torture_assert_int_equal(tctx, tdr->data.length, 4, "length incorrect");
- torture_assert_int_equal(tctx, tdr->data.data[0], 0x32, "data incorrect");
- torture_assert_int_equal(tctx, tdr->data.data[1], 0x0F, "data incorrect");
- torture_assert_int_equal(tctx, tdr->data.data[2], 0x10, "data incorrect");
- torture_assert_int_equal(tctx, tdr->data.data[3], 0x00, "data incorrect");
- return true;
-}
-
-static bool test_pull_uint32(struct torture_context *tctx)
-{
- uint8_t d[4] = { 782 & 0xFF, (782 & 0xFF00) / 0x100, 0, 0 };
- uint32_t l;
- struct tdr_pull *tdr = tdr_pull_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
- tdr->data.data = d;
- tdr->data.length = 4;
- tdr->offset = 0;
- tdr->flags = 0;
- torture_assert_ntstatus_ok(tctx, tdr_pull_uint32(tdr, tctx, &l),
- "pull failed");
- torture_assert_int_equal(tctx, 4, tdr->offset, "offset invalid");
- torture_assert_int_equal(tctx, 782, l, "right int read");
- return true;
-}
-
-static bool test_pull_charset(struct torture_context *tctx)
-{
- struct tdr_pull *tdr = tdr_pull_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
- const char *l = NULL;
- tdr->data.data = (uint8_t *)talloc_strdup(tctx, "bla");
- tdr->data.length = 4;
- tdr->offset = 0;
- tdr->flags = 0;
- torture_assert_ntstatus_ok(tctx, tdr_pull_charset(tdr, tctx, &l, -1, 1, CH_DOS),
- "pull failed");
- torture_assert_int_equal(tctx, 4, tdr->offset, "offset invalid");
- torture_assert_str_equal(tctx, "bla", l, "right int read");
-
- tdr->offset = 0;
- torture_assert_ntstatus_ok(tctx, tdr_pull_charset(tdr, tctx, &l, 2, 1, CH_UNIX),
- "pull failed");
- torture_assert_int_equal(tctx, 2, tdr->offset, "offset invalid");
- torture_assert_str_equal(tctx, "bl", l, "right int read");
-
- return true;
-}
-
-static bool test_pull_charset_empty(struct torture_context *tctx)
-{
- struct tdr_pull *tdr = tdr_pull_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
- const char *l = NULL;
- tdr->data.data = (uint8_t *)talloc_strdup(tctx, "bla");
- tdr->data.length = 4;
- tdr->offset = 0;
- tdr->flags = 0;
- torture_assert_ntstatus_ok(tctx, tdr_pull_charset(tdr, tctx, &l, 0, 1, CH_DOS),
- "pull failed");
- torture_assert_int_equal(tctx, 0, tdr->offset, "offset invalid");
- torture_assert_str_equal(tctx, "", l, "right string read");
-
- return true;
-}
-
-
-
-static bool test_push_charset(struct torture_context *tctx)
-{
- const char *l = "bloe";
- struct tdr_push *tdr = tdr_push_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
- torture_assert_ntstatus_ok(tctx, tdr_push_charset(tdr, &l, 4, 1, CH_UTF8),
- "push failed");
- torture_assert_int_equal(tctx, 4, tdr->data.length, "offset invalid");
- torture_assert(tctx, strcmp("bloe", (const char *)tdr->data.data) == 0, "right string push");
-
- torture_assert_ntstatus_ok(tctx, tdr_push_charset(tdr, &l, -1, 1, CH_UTF8),
- "push failed");
- torture_assert_int_equal(tctx, 9, tdr->data.length, "offset invalid");
- torture_assert_str_equal(tctx, "bloe", (const char *)tdr->data.data+4, "right string read");
-
- return true;
-}
-
-struct torture_suite *torture_local_tdr(TALLOC_CTX *mem_ctx)
-{
- struct torture_suite *suite = torture_suite_create(mem_ctx, "TDR");
-
- torture_suite_add_simple_test(suite, "pull_uint8", test_pull_uint8);
- torture_suite_add_simple_test(suite, "push_uint8", test_push_uint8);
-
- torture_suite_add_simple_test(suite, "pull_uint16", test_pull_uint16);
- torture_suite_add_simple_test(suite, "push_uint16", test_push_uint16);
-
- torture_suite_add_simple_test(suite, "pull_uint32", test_pull_uint32);
- torture_suite_add_simple_test(suite, "push_uint32", test_push_uint32);
-
- torture_suite_add_simple_test(suite, "pull_charset", test_pull_charset);
- torture_suite_add_simple_test(suite, "pull_charset", test_pull_charset_empty);
- torture_suite_add_simple_test(suite, "push_charset", test_push_charset);
-
- return suite;
-}
diff --git a/source4/main.mk b/source4/main.mk
index ee2018fb69..8ea9727ed3 100644
--- a/source4/main.mk
+++ b/source4/main.mk
@@ -20,7 +20,7 @@ mkinclude ../lib/socket_wrapper/config.mk
mkinclude ../lib/nss_wrapper/config.mk
mkinclude lib/stream/config.mk
mkinclude ../lib/util/config.mk
-mkinclude lib/tdr/config.mk
+mkinclude ../lib/tdr/config.mk
mkinclude ../lib/crypto/config.mk
mkinclude ../lib/torture/config.mk
mkinclude lib/basic.mk
diff --git a/source4/min_versions.m4 b/source4/min_versions.m4
new file mode 100644
index 0000000000..46f45a1bf3
--- /dev/null
+++ b/source4/min_versions.m4
@@ -0,0 +1,6 @@
+# Minimum and exact required versions for various libraries
+# if we use the ones installed in the system.
+TDB_MIN_VERSION=1.1.3
+TALLOC_MIN_VERSION=1.3.0
+LDB_REQUIRED_VERSION=0.9.3
+TEVENT_REQUIRED_VERSION=0.9.4
diff --git a/source4/scripting/python/samba/samdb.py b/source4/scripting/python/samba/samdb.py
index 614970d3ec..b92a91e2ef 100644
--- a/source4/scripting/python/samba/samdb.py
+++ b/source4/scripting/python/samba/samdb.py
@@ -28,6 +28,7 @@ import ldb
from samba.idmap import IDmapDB
import pwd
import time
+import base64
__docformat__ = "restructuredText"
@@ -59,7 +60,7 @@ dn: CN=%s,CN=ForeignSecurityPrincipals,%s
objectClass: top
objectClass: foreignSecurityPrincipal
description: %s
- """ % (sid, domaindn, desc)
+""" % (sid, domaindn, desc)
# deliberately ignore errors from this, as the records may
# already exist
for msg in self.parse_ldif(add):
@@ -175,11 +176,11 @@ userAccountControl: %u
user_dn = res[0].dn
setpw = """
- dn: %s
- changetype: modify
- replace: userPassword
- userPassword: %s
- """ % (user_dn, password)
+dn: %s
+changetype: modify
+replace: userPassword
+userPassword:: %s
+""" % (user_dn, base64.b64encode(password))
self.modify_ldif(setpw)
@@ -229,13 +230,13 @@ userAccountControl: %u
accountExpires = glue.unix2nttime(expiry_seconds + int(time.time()))
mod = """
- dn: %s
- changetype: modify
- replace: userAccountControl
- userAccountControl: %u
- replace: accountExpires
- accountExpires: %u
- """ % (res[0].dn, userAccountControl, accountExpires)
+dn: %s
+changetype: modify
+replace: userAccountControl
+userAccountControl: %u
+replace: accountExpires
+accountExpires: %u
+""" % (res[0].dn, userAccountControl, accountExpires)
# now change the database
self.modify_ldif(mod)
except:
diff --git a/source4/torture/ldap/cldapbench.c b/source4/torture/ldap/cldapbench.c
index 1fcfe5a050..ae2cb80836 100644
--- a/source4/torture/ldap/cldapbench.c
+++ b/source4/torture/ldap/cldapbench.c
@@ -30,7 +30,7 @@ struct bench_state {
int pass_count, fail_count;
};
-static void request_handler(struct cldap_request *req)
+static void request_netlogon_handler(struct cldap_request *req)
{
struct cldap_netlogon io;
struct bench_state *state = talloc_get_type(req->async.private_data, struct bench_state);
@@ -47,9 +47,9 @@ static void request_handler(struct cldap_request *req)
}
/*
- benchmark cldap calls
+ benchmark cldap netlogon calls
*/
-static bool bench_cldap(struct torture_context *tctx, const char *address)
+static bool bench_cldap_netlogon(struct torture_context *tctx, const char *address)
{
struct cldap_socket *cldap;
int num_sent=0;
@@ -69,14 +69,14 @@ static bool bench_cldap(struct torture_context *tctx, const char *address)
search.in.acct_control = -1;
search.in.version = 6;
- printf("Running for %d seconds\n", timelimit);
+ printf("Running CLDAP/netlogon for %d seconds\n", timelimit);
while (timeval_elapsed(&tv) < timelimit) {
while (num_sent - (state->pass_count+state->fail_count) < 10) {
struct cldap_request *req;
req = cldap_netlogon_send(cldap, &search);
req->async.private_data = state;
- req->async.fn = request_handler;
+ req->async.fn = request_netlogon_handler;
num_sent++;
if (num_sent % 50 == 0) {
if (torture_setting_bool(tctx, "progress", true)) {
@@ -103,6 +103,78 @@ static bool bench_cldap(struct torture_context *tctx, const char *address)
return ret;
}
+static void request_rootdse_handler(struct cldap_request *req)
+{
+ struct cldap_search io;
+ struct bench_state *state = talloc_get_type(req->async.private_data, struct bench_state);
+ NTSTATUS status;
+ TALLOC_CTX *tmp_ctx = talloc_new(NULL);
+ status = cldap_search_recv(req, tmp_ctx, &io);
+ if (NT_STATUS_IS_OK(status)) {
+ state->pass_count++;
+ } else {
+ state->fail_count++;
+ }
+ talloc_free(tmp_ctx);
+}
+
+/*
+ benchmark cldap netlogon calls
+*/
+static bool bench_cldap_rootdse(struct torture_context *tctx, const char *address)
+{
+ struct cldap_socket *cldap;
+ int num_sent=0;
+ struct timeval tv = timeval_current();
+ bool ret = true;
+ int timelimit = torture_setting_int(tctx, "timelimit", 10);
+ struct cldap_search search;
+ struct bench_state *state;
+
+ cldap = cldap_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+
+ state = talloc_zero(tctx, struct bench_state);
+
+ ZERO_STRUCT(search);
+ search.in.dest_address = address;
+ search.in.dest_port = lp_cldap_port(tctx->lp_ctx);
+ search.in.filter = "(objectClass=*)";
+ search.in.timeout = 2;
+ search.in.retries = 1;
+
+ printf("Running CLDAP/rootdse for %d seconds\n", timelimit);
+ while (timeval_elapsed(&tv) < timelimit) {
+ while (num_sent - (state->pass_count+state->fail_count) < 10) {
+ struct cldap_request *req;
+ req = cldap_search_send(cldap, &search);
+
+ req->async.private_data = state;
+ req->async.fn = request_rootdse_handler;
+ num_sent++;
+ if (num_sent % 50 == 0) {
+ if (torture_setting_bool(tctx, "progress", true)) {
+ printf("%.1f queries per second (%d failures) \r",
+ state->pass_count / timeval_elapsed(&tv),
+ state->fail_count);
+ fflush(stdout);
+ }
+ }
+ }
+
+ tevent_loop_once(tctx->ev);
+ }
+
+ while (num_sent != (state->pass_count + state->fail_count)) {
+ tevent_loop_once(tctx->ev);
+ }
+
+ printf("%.1f queries per second (%d failures) \n",
+ state->pass_count / timeval_elapsed(&tv),
+ state->fail_count);
+
+ talloc_free(cldap);
+ return ret;
+}
/*
benchmark how fast a CLDAP server can respond to a series of parallel
@@ -125,7 +197,8 @@ bool torture_bench_cldap(struct torture_context *torture)
return false;
}
- ret &= bench_cldap(torture, address);
+ ret &= bench_cldap_netlogon(torture, address);
+ ret &= bench_cldap_rootdse(torture, address);
return ret;
}
diff --git a/source4/torture/local/config.mk b/source4/torture/local/config.mk
index 36f4f08072..967e545225 100644
--- a/source4/torture/local/config.mk
+++ b/source4/torture/local/config.mk
@@ -44,7 +44,7 @@ TORTURE_LOCAL_OBJ_FILES = \
$(torturesrcdir)/../../lib/compression/testsuite.o \
$(torturesrcdir)/../../lib/util/charset/tests/charset.o \
$(torturesrcdir)/../libcli/security/tests/sddl.o \
- $(torturesrcdir)/../lib/tdr/testsuite.o \
+ $(libtdrsrcdir)/testsuite.o \
$(torturesrcdir)/../../lib/tevent/testsuite.o \
$(torturesrcdir)/../param/tests/share.o \
$(torturesrcdir)/../param/tests/loadparm.o \
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index ad8158d956..f8029b246b 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -575,7 +575,7 @@ static bool test_EnumPrintProcDataTypes(struct torture_context *tctx,
NTSTATUS status;
struct spoolss_EnumPrintProcDataTypes r;
uint16_t levels[] = { 1 };
- int i, j;
+ int i;
for (i=0;i<ARRAY_SIZE(levels);i++) {
int level = levels[i];