summaryrefslogtreecommitdiff
path: root/source4/ldap_server
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2017-06-13 15:02:41 +0200
committerAndrew Bartlett <abartlet@samba.org>2017-06-15 09:13:22 +0200
commitc6e27794d629b71671474f8044535bf04b60921d (patch)
treedb504bdf48b2a4bcee6f2884c87ef8dd112ce027 /source4/ldap_server
parent900ab851a77ca0cb272fa1a6b0894cac7c41510f (diff)
downloadsamba-c6e27794d629b71671474f8044535bf04b60921d.tar.gz
s4:ldap_server: improve ldapsrv_UnbindRequest implementation
We should abandon outstanding requests and disconnect the connection. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/ldap_server')
-rw-r--r--source4/ldap_server/ldap_bind.c68
1 files changed, 67 insertions, 1 deletions
diff --git a/source4/ldap_server/ldap_bind.c b/source4/ldap_server/ldap_bind.c
index 986ecbfcebb..bb6b04997a6 100644
--- a/source4/ldap_server/ldap_bind.c
+++ b/source4/ldap_server/ldap_bind.c
@@ -23,6 +23,7 @@
#include "smbd/service.h"
#include <ldb.h>
#include <ldb_errors.h>
+#include "../lib/util/dlinklist.h"
#include "dsdb/samdb/samdb.h"
#include "auth/gensec/gensec.h"
#include "auth/gensec/gensec_tstream.h"
@@ -481,8 +482,73 @@ NTSTATUS ldapsrv_BindRequest(struct ldapsrv_call *call)
return NT_STATUS_OK;
}
+struct ldapsrv_unbind_wait_context {
+ uint8_t dummy;
+};
+
+struct ldapsrv_unbind_wait_state {
+ uint8_t dummy;
+};
+
+static struct tevent_req *ldapsrv_unbind_wait_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ void *private_data)
+{
+ struct ldapsrv_unbind_wait_context *unbind_wait =
+ talloc_get_type_abort(private_data,
+ struct ldapsrv_unbind_wait_context);
+ struct tevent_req *req;
+ struct ldapsrv_unbind_wait_state *state;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct ldapsrv_unbind_wait_state);
+ if (req == NULL) {
+ return NULL;
+ }
+
+ (void)unbind_wait;
+
+ tevent_req_nterror(req, NT_STATUS_LOCAL_DISCONNECT);
+ return tevent_req_post(req, ev);
+}
+
+static NTSTATUS ldapsrv_unbind_wait_recv(struct tevent_req *req)
+{
+ return tevent_req_simple_recv_ntstatus(req);
+}
+
+static NTSTATUS ldapsrv_unbind_wait_setup(struct ldapsrv_call *call)
+{
+ struct ldapsrv_unbind_wait_context *unbind_wait = NULL;
+
+ if (call->wait_private != NULL) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
+ unbind_wait = talloc_zero(call, struct ldapsrv_unbind_wait_context);
+ if (unbind_wait == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ call->wait_private = unbind_wait;
+ call->wait_send = ldapsrv_unbind_wait_send;
+ call->wait_recv = ldapsrv_unbind_wait_recv;
+ return NT_STATUS_OK;
+}
+
NTSTATUS ldapsrv_UnbindRequest(struct ldapsrv_call *call)
{
+ struct ldapsrv_call *c = NULL;
+ struct ldapsrv_call *n = NULL;
+
DEBUG(10, ("UnbindRequest\n"));
- return NT_STATUS_OK;
+
+ for (c = call->conn->pending_calls; c != NULL; c = n) {
+ n = c->next;
+
+ DLIST_REMOVE(call->conn->pending_calls, c);
+ TALLOC_FREE(c);
+ }
+
+ return ldapsrv_unbind_wait_setup(call);
}