summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/ldap/ldap.c8
-rw-r--r--source4/libcli/ldap/ldap.h8
-rw-r--r--source4/libcli/ldap/ldap_client.c34
-rw-r--r--source4/libcli/ldap/ldap_client.h4
-rw-r--r--source4/libcli/ldap/ldap_controls.c49
-rw-r--r--source4/libcli/ldap/ldap_ildap.c14
6 files changed, 73 insertions, 44 deletions
diff --git a/source4/libcli/ldap/ldap.c b/source4/libcli/ldap/ldap.c
index 55f1361e16..42cad3a63e 100644
--- a/source4/libcli/ldap/ldap.c
+++ b/source4/libcli/ldap/ldap.c
@@ -1309,19 +1309,19 @@ BOOL ldap_decode(struct asn1_data *data, struct ldap_message *msg)
if (asn1_peek_tag(data, ASN1_CONTEXT(0))) {
int i;
- struct ldap_Control **ctrl = NULL;
+ struct ldb_control **ctrl = NULL;
asn1_start_tag(data, ASN1_CONTEXT(0));
for (i=0; asn1_peek_tag(data, ASN1_SEQUENCE(0)); i++) {
/* asn1_start_tag(data, ASN1_SEQUENCE(0)); */
- ctrl = talloc_realloc(msg, ctrl, struct ldap_Control *, i+2);
+ ctrl = talloc_realloc(msg, ctrl, struct ldb_control *, i+2);
if (!ctrl) {
return False;
}
- ctrl[i] = talloc(ctrl, struct ldap_Control);
+ ctrl[i] = talloc(ctrl, struct ldb_control);
if (!ctrl[i]) {
return False;
}
@@ -1348,7 +1348,7 @@ BOOL ldap_decode(struct asn1_data *data, struct ldap_message *msg)
return NT_STATUS_OK if a blob has enough bytes in it to be a full
ldap packet. Set packet_size if true.
*/
-NTSTATUS ldap_full_packet(void *private, DATA_BLOB blob, size_t *packet_size)
+NTSTATUS ldap_full_packet(void *private_data, DATA_BLOB blob, size_t *packet_size)
{
return asn1_full_tag(blob, ASN1_SEQUENCE(0), packet_size);
}
diff --git a/source4/libcli/ldap/ldap.h b/source4/libcli/ldap/ldap.h
index de284d23d1..1deabf0b10 100644
--- a/source4/libcli/ldap/ldap.h
+++ b/source4/libcli/ldap/ldap.h
@@ -240,17 +240,11 @@ union ldap_Request {
struct ldap_ExtendedResponse ExtendedResponse;
};
-struct ldap_Control {
- const char *oid;
- BOOL critical;
- void *value;
-};
-
struct ldap_message {
int messageid;
enum ldap_request_tag type;
union ldap_Request r;
- struct ldap_Control **controls;
+ struct ldb_control **controls;
};
#include "libcli/ldap/ldap_proto.h"
diff --git a/source4/libcli/ldap/ldap_client.c b/source4/libcli/ldap/ldap_client.c
index 9103e939e7..364961cf47 100644
--- a/source4/libcli/ldap/ldap_client.c
+++ b/source4/libcli/ldap/ldap_client.c
@@ -90,9 +90,9 @@ static void ldap_connection_dead(struct ldap_connection *conn)
/*
handle packet errors
*/
-static void ldap_error_handler(void *private, NTSTATUS status)
+static void ldap_error_handler(void *private_data, NTSTATUS status)
{
- struct ldap_connection *conn = talloc_get_type(private,
+ struct ldap_connection *conn = talloc_get_type(private_data,
struct ldap_connection);
ldap_connection_dead(conn);
}
@@ -155,14 +155,14 @@ static void ldap_match_message(struct ldap_connection *conn, struct ldap_message
check if a blob is a complete ldap packet
handle wrapper or unwrapped connections
*/
-NTSTATUS ldap_complete_packet(void *private, DATA_BLOB blob, size_t *size)
+NTSTATUS ldap_complete_packet(void *private_data, DATA_BLOB blob, size_t *size)
{
- struct ldap_connection *conn = talloc_get_type(private,
+ struct ldap_connection *conn = talloc_get_type(private_data,
struct ldap_connection);
if (conn->enable_wrap) {
- return packet_full_request_u32(private, blob, size);
+ return packet_full_request_u32(private_data, blob, size);
}
- return ldap_full_packet(private, blob, size);
+ return ldap_full_packet(private_data, blob, size);
}
/*
@@ -234,9 +234,9 @@ static NTSTATUS ldap_decode_wrapped(struct ldap_connection *conn, DATA_BLOB blob
/*
handle ldap recv events
*/
-static NTSTATUS ldap_recv_handler(void *private, DATA_BLOB blob)
+static NTSTATUS ldap_recv_handler(void *private_data, DATA_BLOB blob)
{
- struct ldap_connection *conn = talloc_get_type(private,
+ struct ldap_connection *conn = talloc_get_type(private_data,
struct ldap_connection);
if (conn->enable_wrap) {
return ldap_decode_wrapped(conn, blob);
@@ -250,9 +250,9 @@ static NTSTATUS ldap_recv_handler(void *private, DATA_BLOB blob)
handle ldap socket events
*/
static void ldap_io_handler(struct event_context *ev, struct fd_event *fde,
- uint16_t flags, void *private)
+ uint16_t flags, void *private_data)
{
- struct ldap_connection *conn = talloc_get_type(private,
+ struct ldap_connection *conn = talloc_get_type(private_data,
struct ldap_connection);
if (flags & EVENT_FD_WRITE) {
packet_queue_run(conn->packet);
@@ -433,9 +433,9 @@ static int ldap_request_destructor(void *ptr)
called on timeout of a ldap request
*/
static void ldap_request_timeout(struct event_context *ev, struct timed_event *te,
- struct timeval t, void *private)
+ struct timeval t, void *private_data)
{
- struct ldap_request *req = talloc_get_type(private, struct ldap_request);
+ struct ldap_request *req = talloc_get_type(private_data, struct ldap_request);
req->status = NT_STATUS_IO_TIMEOUT;
if (req->state == LDAP_REQUEST_PENDING) {
DLIST_REMOVE(req->conn->pending, req);
@@ -451,9 +451,9 @@ static void ldap_request_timeout(struct event_context *ev, struct timed_event *t
called on completion of a one-way ldap request
*/
static void ldap_request_complete(struct event_context *ev, struct timed_event *te,
- struct timeval t, void *private)
+ struct timeval t, void *private_data)
{
- struct ldap_request *req = talloc_get_type(private, struct ldap_request);
+ struct ldap_request *req = talloc_get_type(private_data, struct ldap_request);
if (req->async.fn) {
req->async.fn(req);
}
@@ -534,9 +534,9 @@ struct ldap_request *ldap_request_send(struct ldap_connection *conn,
DLIST_ADD(conn->pending, req);
/* put a timeout on the request */
- event_add_timed(conn->event.event_ctx, req,
- timeval_current_ofs(conn->timeout, 0),
- ldap_request_timeout, req);
+ req->time_event = event_add_timed(conn->event.event_ctx, req,
+ timeval_current_ofs(conn->timeout, 0),
+ ldap_request_timeout, req);
return req;
diff --git a/source4/libcli/ldap/ldap_client.h b/source4/libcli/ldap/ldap_client.h
index ee458dc5b0..3f71c42f22 100644
--- a/source4/libcli/ldap/ldap_client.h
+++ b/source4/libcli/ldap/ldap_client.h
@@ -42,8 +42,10 @@ struct ldap_request {
DATA_BLOB data;
struct {
void (*fn)(struct ldap_request *);
- void *private;
+ void *private_data;
} async;
+
+ struct timed_event *time_event;
};
diff --git a/source4/libcli/ldap/ldap_controls.c b/source4/libcli/ldap/ldap_controls.c
index 5bd46cf7a9..373b71d370 100644
--- a/source4/libcli/ldap/ldap_controls.c
+++ b/source4/libcli/ldap/ldap_controls.c
@@ -381,10 +381,14 @@ static BOOL decode_vlv_request(void *mem_ctx, DATA_BLOB in, void **out)
return False;
}
- if (asn1_peek_tag(&data, ASN1_SEQUENCE(0))) {
+ if (asn1_peek_tag(&data, ASN1_CONTEXT(0))) {
lvrc->type = 0;
+ if (!asn1_start_tag(&data, ASN1_CONTEXT(0))) {
+ return False;
+ }
+
if (!asn1_start_tag(&data, ASN1_SEQUENCE(0))) {
return False;
}
@@ -397,7 +401,11 @@ static BOOL decode_vlv_request(void *mem_ctx, DATA_BLOB in, void **out)
return False;
}
- if (!asn1_end_tag(&data)) {
+ if (!asn1_end_tag(&data)) { /*SEQUENCE*/
+ return False;
+ }
+
+ if (!asn1_end_tag(&data)) { /*CONTEXT*/
return False;
}
@@ -405,6 +413,10 @@ static BOOL decode_vlv_request(void *mem_ctx, DATA_BLOB in, void **out)
lvrc->type = 1;
+ if (!asn1_start_tag(&data, ASN1_CONTEXT(1))) {
+ return False;
+ }
+
if (!asn1_read_OctetString(&data, &assertion_value)) {
return False;
}
@@ -418,6 +430,10 @@ static BOOL decode_vlv_request(void *mem_ctx, DATA_BLOB in, void **out)
} else {
lvrc->match.gtOrEq.value = NULL;
}
+
+ if (!asn1_end_tag(&data)) { /*CONTEXT*/
+ return False;
+ }
}
if (asn1_peek_tag(&data, ASN1_OCTET_STRING)) {
@@ -755,6 +771,10 @@ static BOOL encode_vlv_request(void *mem_ctx, void *in, DATA_BLOB *out)
}
if (lvrc->type == 0) {
+ if (!asn1_push_tag(&data, ASN1_CONTEXT(0))) {
+ return False;
+ }
+
if (!asn1_push_tag(&data, ASN1_SEQUENCE(0))) {
return False;
}
@@ -767,14 +787,25 @@ static BOOL encode_vlv_request(void *mem_ctx, void *in, DATA_BLOB *out)
return False;
}
- if (!asn1_pop_tag(&data)) {
+ if (!asn1_pop_tag(&data)) { /*SEQUENCE*/
+ return False;
+ }
+
+ if (!asn1_pop_tag(&data)) { /*CONTEXT*/
return False;
}
} else {
+ if (!asn1_push_tag(&data, ASN1_CONTEXT(1))) {
+ return False;
+ }
if (!asn1_write_OctetString(&data, lvrc->match.gtOrEq.value, lvrc->match.gtOrEq.value_len)) {
return False;
}
+
+ if (!asn1_pop_tag(&data)) { /*CONTEXT*/
+ return False;
+ }
}
if (lvrc->ctxid_len) {
@@ -850,7 +881,7 @@ struct control_handler ldap_known_controls[] = {
{ NULL, NULL, NULL }
};
-BOOL ldap_decode_control(void *mem_ctx, struct asn1_data *data, struct ldap_Control *ctrl)
+BOOL ldap_decode_control(void *mem_ctx, struct asn1_data *data, struct ldb_control *ctrl)
{
int i;
DATA_BLOB oid;
@@ -876,7 +907,7 @@ BOOL ldap_decode_control(void *mem_ctx, struct asn1_data *data, struct ldap_Cont
ctrl->critical = False;
}
- ctrl->value = NULL;
+ ctrl->data = NULL;
if (!asn1_peek_tag(data, ASN1_OCTET_STRING)) {
goto end_tag;
@@ -888,7 +919,7 @@ BOOL ldap_decode_control(void *mem_ctx, struct asn1_data *data, struct ldap_Cont
for (i = 0; ldap_known_controls[i].oid != NULL; i++) {
if (strcmp(ldap_known_controls[i].oid, ctrl->oid) == 0) {
- if (!ldap_known_controls[i].decode(mem_ctx, value, &ctrl->value)) {
+ if (!ldap_known_controls[i].decode(mem_ctx, value, &ctrl->data)) {
return False;
}
break;
@@ -906,7 +937,7 @@ end_tag:
return True;
}
-BOOL ldap_encode_control(void *mem_ctx, struct asn1_data *data, struct ldap_Control *ctrl)
+BOOL ldap_encode_control(void *mem_ctx, struct asn1_data *data, struct ldb_control *ctrl)
{
DATA_BLOB value;
int i;
@@ -925,13 +956,13 @@ BOOL ldap_encode_control(void *mem_ctx, struct asn1_data *data, struct ldap_Cont
}
}
- if (!ctrl->value) {
+ if (!ctrl->data) {
goto pop_tag;
}
for (i = 0; ldap_known_controls[i].oid != NULL; i++) {
if (strcmp(ldap_known_controls[i].oid, ctrl->oid) == 0) {
- if (!ldap_known_controls[i].encode(mem_ctx, ctrl->value, &value)) {
+ if (!ldap_known_controls[i].encode(mem_ctx, ctrl->data, &value)) {
return False;
}
break;
diff --git a/source4/libcli/ldap/ldap_ildap.c b/source4/libcli/ldap/ldap_ildap.c
index a5227ec37f..f26fb7db78 100644
--- a/source4/libcli/ldap/ldap_ildap.c
+++ b/source4/libcli/ldap/ldap_ildap.c
@@ -152,13 +152,13 @@ int ildap_count_entries(struct ldap_connection *conn, struct ldap_message **res)
/*
- perform a ldap search
+ perform a synchronous ldap search
*/
NTSTATUS ildap_search_bytree(struct ldap_connection *conn, const char *basedn,
int scope, struct ldb_parse_tree *tree,
const char * const *attrs, BOOL attributesonly,
- struct ldap_Control **control_req,
- struct ldap_Control ***control_res,
+ struct ldb_control **control_req,
+ struct ldb_control ***control_res,
struct ldap_message ***results)
{
struct ldap_message *msg;
@@ -203,7 +203,9 @@ NTSTATUS ildap_search_bytree(struct ldap_connection *conn, const char *basedn,
break;
}
- if (res->type != LDAP_TAG_SearchResultEntry) continue;
+ if (res->type != LDAP_TAG_SearchResultEntry &&
+ res->type != LDAP_TAG_SearchResultReference)
+ continue;
(*results) = talloc_realloc(conn, *results, struct ldap_message *, n+2);
if (*results == NULL) {
@@ -228,8 +230,8 @@ NTSTATUS ildap_search_bytree(struct ldap_connection *conn, const char *basedn,
NTSTATUS ildap_search(struct ldap_connection *conn, const char *basedn,
int scope, const char *expression,
const char * const *attrs, BOOL attributesonly,
- struct ldap_Control **control_req,
- struct ldap_Control ***control_res,
+ struct ldb_control **control_req,
+ struct ldb_control ***control_res,
struct ldap_message ***results)
{
struct ldb_parse_tree *tree = ldb_parse_tree(conn, expression);