[SCM] Samba Shared Repository - branch master updated -
release-4-0-0alpha7-2281-g6e4c57c
Volker Lendecke
vlendec at samba.org
Fri Jun 12 13:04:56 GMT 2009
The branch, master has been updated
via 6e4c57ced543e7b572beb567526df21a4c880eef (commit)
via baa6ebddcb45fd817a7ff9b7986afbe3fc4c4b6c (commit)
via a36a3e4c838275d33b2ed087b037ed3708b04749 (commit)
from 718f9be8a2530a11e1cb16b68511b4c910a1c320 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 6e4c57ced543e7b572beb567526df21a4c880eef
Author: Volker Lendecke <vl at samba.org>
Date: Fri Jun 12 15:02:01 2009 +0200
Activate tldap tracing in pdb_ads
commit baa6ebddcb45fd817a7ff9b7986afbe3fc4c4b6c
Author: Volker Lendecke <vl at samba.org>
Date: Fri Jun 12 14:52:35 2009 +0200
Add basic tracing of tldap messages
commit a36a3e4c838275d33b2ed087b037ed3708b04749
Author: Volker Lendecke <vl at samba.org>
Date: Fri Jun 12 14:50:46 2009 +0200
Add debugging facility to tldap, analogous to tevent
-----------------------------------------------------------------------
Summary of changes:
source3/include/tldap.h | 15 +++++++++++++++
source3/lib/tldap.c | 42 ++++++++++++++++++++++++++++++++++++++++++
source3/passdb/pdb_ads.c | 34 ++++++++++++++++++++++++++++++++++
3 files changed, 91 insertions(+), 0 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/include/tldap.h b/source3/include/tldap.h
index c79a142..d57484c 100644
--- a/source3/include/tldap.h
+++ b/source3/include/tldap.h
@@ -145,6 +145,21 @@ const char *tldap_ctx_diagnosticmessage(struct tldap_context *ctx);
const char *tldap_ctx_referral(struct tldap_context *ctx);
const char *tldap_err2string(int rc);
+/* DEBUG */
+enum tldap_debug_level {
+ TLDAP_DEBUG_FATAL,
+ TLDAP_DEBUG_ERROR,
+ TLDAP_DEBUG_WARNING,
+ TLDAP_DEBUG_TRACE
+};
+
+void tldap_set_debug(struct tldap_context *ld,
+ void (*log_fn)(void *log_private,
+ enum tldap_debug_level level,
+ const char *fmt,
+ va_list ap) PRINTF_ATTRIBUTE(3,0),
+ void *log_private);
+
/*
* "+ 0x60" is from ASN1_APPLICATION
*/
diff --git a/source3/lib/tldap.c b/source3/lib/tldap.c
index df86f95..c70b8ca 100644
--- a/source3/lib/tldap.c
+++ b/source3/lib/tldap.c
@@ -59,6 +59,11 @@ struct tldap_context {
char *res_matcheddn;
char *res_diagnosticmessage;
char *res_referral;
+
+ /* debug */
+ void (*log_fn)(void *context, enum tldap_debug_level level,
+ const char *fmt, va_list ap);
+ void *log_private;
};
struct tldap_message {
@@ -72,6 +77,33 @@ struct tldap_message {
struct tldap_attribute *attribs;
};
+void tldap_set_debug(struct tldap_context *ld,
+ void (*log_fn)(void *log_private,
+ enum tldap_debug_level level,
+ const char *fmt,
+ va_list ap) PRINTF_ATTRIBUTE(3,0),
+ void *log_private)
+{
+ ld->log_fn = log_fn;
+ ld->log_private = log_private;
+}
+
+static void tldap_debug(struct tldap_context *ld,
+ enum tldap_debug_level level,
+ const char *fmt, ...)
+{
+ va_list ap;
+ if (!ld) {
+ return;
+ }
+ if (ld->log_fn == NULL) {
+ return;
+ }
+ va_start(ap, fmt);
+ ld->log_fn(ld->log_private, level, fmt, ap);
+ va_end(ap);
+}
+
static int tldap_next_msgid(struct tldap_context *ld)
{
int result;
@@ -249,6 +281,9 @@ static struct tevent_req *tldap_msg_send(TALLOC_CTX *mem_ctx,
struct tldap_msg_state *state;
DATA_BLOB blob;
+ tldap_debug(ld, TLDAP_DEBUG_TRACE, "tldap_msg_send: sending msg %d\n",
+ id);
+
req = tevent_req_create(mem_ctx, &state, struct tldap_msg_state);
if (req == NULL) {
return NULL;
@@ -404,6 +439,7 @@ static void tldap_msg_received(struct tevent_req *subreq)
size_t num_pending;
int i, err, status;
int id;
+ uint8_t type;
bool ok;
received = read_ldap_recv(subreq, talloc_tos(), &inbuf, &err);
@@ -423,12 +459,16 @@ static void tldap_msg_received(struct tevent_req *subreq)
ok = true;
ok &= asn1_start_tag(data, ASN1_SEQUENCE(0));
ok &= asn1_read_Integer(data, &id);
+ ok &= asn1_peek_uint8(data, &type);
if (!ok) {
status = TLDAP_PROTOCOL_ERROR;
goto fail;
}
+ tldap_debug(ld, TLDAP_DEBUG_TRACE, "tldap_msg_received: got msg %d "
+ "type %d\n", id, (int)type);
+
num_pending = talloc_array_length(ld->pending);
for (i=0; i<num_pending; i++) {
@@ -438,6 +478,8 @@ static void tldap_msg_received(struct tevent_req *subreq)
}
if (i == num_pending) {
/* Dump unexpected reply */
+ tldap_debug(ld, TLDAP_DEBUG_WARNING, "tldap_msg_received: "
+ "No request pending for msg %d\n", id);
TALLOC_FREE(inbuf);
goto done;
}
diff --git a/source3/passdb/pdb_ads.c b/source3/passdb/pdb_ads.c
index 9494915..0811082 100644
--- a/source3/passdb/pdb_ads.c
+++ b/source3/passdb/pdb_ads.c
@@ -1947,6 +1947,39 @@ static void free_private_data(void **vp)
return;
}
+/*
+ this is used to catch debug messages from events
+*/
+static void s3_tldap_debug(void *context, enum tldap_debug_level level,
+ const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0);
+
+static void s3_tldap_debug(void *context, enum tldap_debug_level level,
+ const char *fmt, va_list ap)
+{
+ int samba_level = -1;
+ char *s = NULL;
+ switch (level) {
+ case TLDAP_DEBUG_FATAL:
+ samba_level = 0;
+ break;
+ case TLDAP_DEBUG_ERROR:
+ samba_level = 1;
+ break;
+ case TLDAP_DEBUG_WARNING:
+ samba_level = 2;
+ break;
+ case TLDAP_DEBUG_TRACE:
+ samba_level = 10;
+ break;
+
+ };
+ if (vasprintf(&s, fmt, ap) == -1) {
+ return;
+ }
+ DEBUG(samba_level, ("tldap: %s", s));
+ free(s);
+}
+
static NTSTATUS pdb_ads_connect(struct pdb_ads_state *state,
const char *location)
{
@@ -1979,6 +2012,7 @@ static NTSTATUS pdb_ads_connect(struct pdb_ads_state *state,
status = NT_STATUS_NO_MEMORY;
goto done;
}
+ tldap_set_debug(state->ld, s3_tldap_debug, NULL);
rc = tldap_search_fmt(
state->ld, "", TLDAP_SCOPE_BASE,
--
Samba Shared Repository
More information about the samba-cvs
mailing list