summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/build/smb_build/main.pl2
-rw-r--r--source4/configure.ac2
-rw-r--r--source4/lib/events/tevent_s4.c2
-rw-r--r--source4/lib/ldb/common/ldb.c37
-rw-r--r--source4/scripting/python/samba/samdb.py27
-rw-r--r--source4/torture/ldap/cldapbench.c85
-rw-r--r--source4/torture/rpc/spoolss.c2
7 files changed, 135 insertions, 22 deletions
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 792e90131a..a1eb4f4b46 100644
--- a/source4/configure.ac
+++ b/source4/configure.ac
@@ -59,7 +59,7 @@ 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 = 0.9.4,
[],[m4_include(../lib/tevent/samba.m4)]
)
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/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/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];