[SCM] Samba Shared Repository - branch master updated
Stefan Metzmacher
metze at samba.org
Mon Sep 27 01:15:02 MDT 2010
The branch, master has been updated
via b32625b s4:torture/ldap: close connections with an UnbindRequest
via b1ffacb LDAP-BASIC: test AbandonRequest
via b65a164 s4:libcli/ldap: fix sending oneway requests
via 9d4df79 libcli/ldap: correctly marshall LDAP Unbind PDUs
from ff95491 s3-waf: fix dependencies to NDR_XATTR.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit b32625b79f0f1b67c3e7579f7a2e959e89343180
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Sep 27 08:14:54 2010 +0200
s4:torture/ldap: close connections with an UnbindRequest
metze
Autobuild-User: Stefan Metzmacher <metze at samba.org>
Autobuild-Date: Mon Sep 27 07:14:23 UTC 2010 on sn-devel-104
commit b1ffacb43736c2a2366fbcb0039384b7b8d1683e
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Sep 27 08:13:50 2010 +0200
LDAP-BASIC: test AbandonRequest
metze
commit b65a164f3e05a53c08998dc86eb6a899278f687a
Author: Stefan Metzmacher <metze at samba.org>
Date: Sun Sep 26 22:34:37 2010 +0200
s4:libcli/ldap: fix sending oneway requests
metze
commit 9d4df79080e43ca787b9c7f598aa5327b47e83f2
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Sep 27 06:46:33 2010 +0200
libcli/ldap: correctly marshall LDAP Unbind PDUs
metze
-----------------------------------------------------------------------
Summary of changes:
libcli/ldap/ldap_message.c | 2 +
source4/libcli/ldap/ldap_client.c | 44 +++++++++++++++++++++---------------
source4/torture/ldap/basic.c | 41 ++++++++++++++++++++++++++++++++++
source4/torture/ldap/common.c | 29 ++++++++++++++++++++++++
4 files changed, 98 insertions(+), 18 deletions(-)
Changeset truncated at 500 lines:
diff --git a/libcli/ldap/ldap_message.c b/libcli/ldap/ldap_message.c
index 3941518..e5b94b8 100644
--- a/libcli/ldap/ldap_message.c
+++ b/libcli/ldap/ldap_message.c
@@ -434,6 +434,8 @@ _PUBLIC_ bool ldap_encode(struct ldap_message *msg,
}
case LDAP_TAG_UnbindRequest: {
/* struct ldap_UnbindRequest *r = &msg->r.UnbindRequest; */
+ asn1_push_tag(data, ASN1_APPLICATION_SIMPLE(msg->type));
+ asn1_pop_tag(data);
break;
}
case LDAP_TAG_SearchRequest: {
diff --git a/source4/libcli/ldap/ldap_client.c b/source4/libcli/ldap/ldap_client.c
index 865ff6d..7c8bb03 100644
--- a/source4/libcli/ldap/ldap_client.c
+++ b/source4/libcli/ldap/ldap_client.c
@@ -565,10 +565,10 @@ static void ldap_request_timeout(struct tevent_context *ev, struct tevent_timer
/*
- called on completion of a one-way ldap request
+ called on completion of a failed ldap request
*/
-static void ldap_request_complete(struct tevent_context *ev, struct tevent_timer *te,
- struct timeval t, void *private_data)
+static void ldap_request_failed_complete(struct tevent_context *ev, struct tevent_timer *te,
+ struct timeval t, void *private_data)
{
struct ldap_request *req = talloc_get_type(private_data, struct ldap_request);
if (req->async.fn) {
@@ -577,6 +577,20 @@ static void ldap_request_complete(struct tevent_context *ev, struct tevent_timer
}
/*
+ called on completion of a one-way ldap request
+*/
+static void ldap_request_oneway_complete(void *private_data)
+{
+ struct ldap_request *req = talloc_get_type(private_data, struct ldap_request);
+ if (req->state == LDAP_REQUEST_PENDING) {
+ DLIST_REMOVE(req->conn->pending, req);
+ }
+ req->state = LDAP_REQUEST_DONE;
+ if (req->async.fn) {
+ req->async.fn(req);
+ }
+}
+/*
send a ldap message - async interface
*/
_PUBLIC_ struct ldap_request *ldap_request_send(struct ldap_connection *conn,
@@ -584,6 +598,7 @@ _PUBLIC_ struct ldap_request *ldap_request_send(struct ldap_connection *conn,
{
struct ldap_request *req;
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
+ packet_send_callback_fn_t send_callback = NULL;
req = talloc_zero(conn, struct ldap_request);
if (req == NULL) return NULL;
@@ -613,22 +628,15 @@ _PUBLIC_ struct ldap_request *ldap_request_send(struct ldap_connection *conn,
goto failed;
}
- status = packet_send(conn->packet, req->data);
- if (!NT_STATUS_IS_OK(status)) {
- goto failed;
- }
-
- /* some requests don't expect a reply, so don't add those to the
- pending queue */
if (req->type == LDAP_TAG_AbandonRequest ||
req->type == LDAP_TAG_UnbindRequest) {
- req->status = NT_STATUS_OK;
- req->state = LDAP_REQUEST_DONE;
- /* we can't call the async callback now, as it isn't setup, so
- call it as next event */
- tevent_add_timer(conn->event.event_ctx, req, timeval_zero(),
- ldap_request_complete, req);
- return req;
+ send_callback = ldap_request_oneway_complete;
+ }
+
+ status = packet_send_callback(conn->packet, req->data,
+ send_callback, req);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto failed;
}
req->state = LDAP_REQUEST_PENDING;
@@ -645,7 +653,7 @@ failed:
req->status = status;
req->state = LDAP_REQUEST_ERROR;
tevent_add_timer(conn->event.event_ctx, req, timeval_zero(),
- ldap_request_complete, req);
+ ldap_request_failed_complete, req);
return req;
}
diff --git a/source4/torture/ldap/basic.c b/source4/torture/ldap/basic.c
index a8e12dd..1efdc06 100644
--- a/source4/torture/ldap/basic.c
+++ b/source4/torture/ldap/basic.c
@@ -792,6 +792,43 @@ static bool test_referrals(struct torture_context *tctx, TALLOC_CTX *mem_ctx,
return true;
}
+static bool test_abandom_request(struct torture_context *tctx,
+ struct ldap_connection *conn, const char *basedn)
+{
+ struct ldap_message *msg;
+ struct ldap_request *req;
+ NTSTATUS status;
+
+ printf("Testing the AbandonRequest with an old message id!\n");
+
+ if (!basedn) {
+ return false;
+ }
+
+ msg = new_ldap_message(conn);
+ if (!msg) {
+ return false;
+ }
+
+ printf(" Try a AbandonRequest for an old message id\n");
+
+ msg->type = LDAP_TAG_AbandonRequest;
+ msg->r.AbandonRequest.messageid = 1;
+
+ req = ldap_request_send(conn, msg);
+ if (!req) {
+ return false;
+ }
+
+ status = ldap_request_wait(req);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("error in ldap abandon request - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ return true;
+}
+
bool torture_ldap_basic(struct torture_context *torture)
{
@@ -845,6 +882,10 @@ bool torture_ldap_basic(struct torture_context *torture)
ret = false;
}
+ if (!test_abandom_request(torture, conn, basedn)) {
+ ret = false;
+ }
+
/* if there are no more tests we are closing */
torture_ldap_close(conn);
talloc_free(mem_ctx);
diff --git a/source4/torture/ldap/common.c b/source4/torture/ldap/common.c
index 3891175..8c0eb02 100644
--- a/source4/torture/ldap/common.c
+++ b/source4/torture/ldap/common.c
@@ -96,6 +96,35 @@ NTSTATUS torture_ldap_connection2(struct torture_context *tctx, struct ldap_conn
/* close an ldap connection to a server */
NTSTATUS torture_ldap_close(struct ldap_connection *conn)
{
+ struct ldap_message *msg;
+ struct ldap_request *req;
+ NTSTATUS status;
+
+ printf("Testing the most important error code -> error message conversions!\n");
+
+ msg = new_ldap_message(conn);
+ if (!msg) {
+ talloc_free(conn);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ printf(" Try a AbandonRequest for an old message id\n");
+
+ msg->type = LDAP_TAG_UnbindRequest;
+
+ req = ldap_request_send(conn, msg);
+ if (!req) {
+ talloc_free(conn);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = ldap_request_wait(req);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("error in ldap unbind request - %s\n", nt_errstr(status));
+ talloc_free(conn);
+ return status;
+ }
+
talloc_free(conn);
return NT_STATUS_OK;
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list