mirror of
https://github.com/samba-team/samba.git
synced 2025-11-23 20:23:50 +03:00
r10078: - add a 'struct data_blob_list_item'
- use this for the send_queue's of the different stream_servers to not redefine the same struct so often, and it maybe will be used in other places too metze
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
f3e0bf022f
commit
b6694f067a
@@ -192,6 +192,11 @@ typedef struct datablob {
|
|||||||
size_t length;
|
size_t length;
|
||||||
} DATA_BLOB;
|
} DATA_BLOB;
|
||||||
|
|
||||||
|
struct data_blob_list_item {
|
||||||
|
struct data_blob_list_item *prev,*next;
|
||||||
|
DATA_BLOB blob;
|
||||||
|
};
|
||||||
|
|
||||||
/* by making struct ldb_val and DATA_BLOB the same, we can simplify
|
/* by making struct ldb_val and DATA_BLOB the same, we can simplify
|
||||||
a fair bit of code */
|
a fair bit of code */
|
||||||
#define ldb_val datablob
|
#define ldb_val datablob
|
||||||
|
|||||||
@@ -40,8 +40,10 @@
|
|||||||
static void ldapsrv_terminate_connection(struct ldapsrv_connection *conn,
|
static void ldapsrv_terminate_connection(struct ldapsrv_connection *conn,
|
||||||
const char *reason)
|
const char *reason)
|
||||||
{
|
{
|
||||||
talloc_free(conn->tls);
|
if (conn->tls) {
|
||||||
conn->tls = NULL;
|
talloc_free(conn->tls);
|
||||||
|
conn->tls = NULL;
|
||||||
|
}
|
||||||
stream_terminate_connection(conn->connection, reason);
|
stream_terminate_connection(conn->connection, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +56,7 @@ static void ldapsrv_process_message(struct ldapsrv_connection *conn,
|
|||||||
struct ldapsrv_call *call;
|
struct ldapsrv_call *call;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
DATA_BLOB blob;
|
DATA_BLOB blob;
|
||||||
struct ldapsrv_send *q;
|
struct data_blob_list_item *q;
|
||||||
BOOL enable_wrap = conn->enable_wrap;
|
BOOL enable_wrap = conn->enable_wrap;
|
||||||
|
|
||||||
call = talloc(conn, struct ldapsrv_call);
|
call = talloc(conn, struct ldapsrv_call);
|
||||||
@@ -114,16 +116,16 @@ static void ldapsrv_process_message(struct ldapsrv_connection *conn,
|
|||||||
data_blob_free(&wrapped);
|
data_blob_free(&wrapped);
|
||||||
}
|
}
|
||||||
|
|
||||||
q = talloc(conn, struct ldapsrv_send);
|
q = talloc(conn, struct data_blob_list_item);
|
||||||
if (q == NULL) goto failed;
|
if (q == NULL) goto failed;
|
||||||
|
|
||||||
q->data = blob;
|
q->blob = blob;
|
||||||
talloc_steal(q, blob.data);
|
talloc_steal(q, blob.data);
|
||||||
|
|
||||||
if (conn->send_queue == NULL) {
|
if (conn->send_queue == NULL) {
|
||||||
EVENT_FD_WRITEABLE(conn->connection->event.fde);
|
EVENT_FD_WRITEABLE(conn->connection->event.fde);
|
||||||
}
|
}
|
||||||
DLIST_ADD_END(conn->send_queue, q, struct ldapsrv_send *);
|
DLIST_ADD_END(conn->send_queue, q, struct data_blob_list_item *);
|
||||||
talloc_free(call);
|
talloc_free(call);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -305,11 +307,11 @@ static void ldapsrv_send(struct stream_connection *c, uint16_t flags)
|
|||||||
struct ldapsrv_connection *conn =
|
struct ldapsrv_connection *conn =
|
||||||
talloc_get_type(c->private, struct ldapsrv_connection);
|
talloc_get_type(c->private, struct ldapsrv_connection);
|
||||||
while (conn->send_queue) {
|
while (conn->send_queue) {
|
||||||
struct ldapsrv_send *q = conn->send_queue;
|
struct data_blob_list_item *q = conn->send_queue;
|
||||||
size_t nsent;
|
size_t nsent;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
status = tls_socket_send(conn->tls, &q->data, &nsent);
|
status = tls_socket_send(conn->tls, &q->blob, &nsent);
|
||||||
if (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
|
if (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -318,9 +320,9 @@ static void ldapsrv_send(struct stream_connection *c, uint16_t flags)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
q->data.data += nsent;
|
q->blob.data += nsent;
|
||||||
q->data.length -= nsent;
|
q->blob.length -= nsent;
|
||||||
if (q->data.length == 0) {
|
if (q->blob.length == 0) {
|
||||||
DLIST_REMOVE(conn->send_queue, q);
|
DLIST_REMOVE(conn->send_queue, q);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -341,13 +343,16 @@ static void ldapsrv_accept(struct stream_connection *c)
|
|||||||
int port;
|
int port;
|
||||||
|
|
||||||
conn = talloc_zero(c, struct ldapsrv_connection);
|
conn = talloc_zero(c, struct ldapsrv_connection);
|
||||||
if (conn == NULL) goto failed;
|
if (!conn) {
|
||||||
|
stream_terminate_connection(c, "ldapsrv_accept: out of memory");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
conn->enable_wrap = False;
|
conn->enable_wrap = False;
|
||||||
conn->partial = data_blob(NULL, 0);
|
conn->partial = data_blob(NULL, 0);
|
||||||
conn->send_queue = NULL;
|
conn->send_queue = NULL;
|
||||||
conn->connection = c;
|
conn->connection = c;
|
||||||
conn->service = talloc_get_type(c->private, struct ldapsrv_service);
|
conn->service = ldapsrv_service;
|
||||||
conn->processing = False;
|
conn->processing = False;
|
||||||
c->private = conn;
|
c->private = conn;
|
||||||
|
|
||||||
@@ -357,14 +362,12 @@ static void ldapsrv_accept(struct stream_connection *c)
|
|||||||
any ldap connection */
|
any ldap connection */
|
||||||
conn->tls = tls_init_server(ldapsrv_service->tls_params, c->socket,
|
conn->tls = tls_init_server(ldapsrv_service->tls_params, c->socket,
|
||||||
c->event.fde, NULL, port != 389);
|
c->event.fde, NULL, port != 389);
|
||||||
if (conn->tls == NULL) goto failed;
|
if (!conn->tls) {
|
||||||
|
ldapsrv_terminate_connection(c, "ldapsrv_accept: tls_init_server() failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
irpc_add_name(c->msg_ctx, "ldap_server");
|
irpc_add_name(c->msg_ctx, "ldap_server");
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
failed:
|
|
||||||
talloc_free(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct stream_server_ops ldap_stream_ops = {
|
static const struct stream_server_ops ldap_stream_ops = {
|
||||||
|
|||||||
@@ -35,10 +35,7 @@ struct ldapsrv_connection {
|
|||||||
BOOL enable_wrap;
|
BOOL enable_wrap;
|
||||||
|
|
||||||
/* reply send queue */
|
/* reply send queue */
|
||||||
struct ldapsrv_send {
|
struct data_blob_list_item *send_queue;
|
||||||
struct ldapsrv_send *next, *prev;
|
|
||||||
DATA_BLOB data;
|
|
||||||
} *send_queue;
|
|
||||||
|
|
||||||
BOOL processing;
|
BOOL processing;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ static void dcesrv_init_hdr(struct ncacn_packet *pkt)
|
|||||||
static NTSTATUS dcesrv_fault(struct dcesrv_call_state *call, uint32_t fault_code)
|
static NTSTATUS dcesrv_fault(struct dcesrv_call_state *call, uint32_t fault_code)
|
||||||
{
|
{
|
||||||
struct ncacn_packet pkt;
|
struct ncacn_packet pkt;
|
||||||
struct dcesrv_call_reply *rep;
|
struct data_blob_list_item *rep;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
/* setup a bind_ack */
|
/* setup a bind_ack */
|
||||||
@@ -399,19 +399,19 @@ static NTSTATUS dcesrv_fault(struct dcesrv_call_state *call, uint32_t fault_code
|
|||||||
pkt.u.fault.cancel_count = 0;
|
pkt.u.fault.cancel_count = 0;
|
||||||
pkt.u.fault.status = fault_code;
|
pkt.u.fault.status = fault_code;
|
||||||
|
|
||||||
rep = talloc(call, struct dcesrv_call_reply);
|
rep = talloc(call, struct data_blob_list_item);
|
||||||
if (!rep) {
|
if (!rep) {
|
||||||
return NT_STATUS_NO_MEMORY;
|
return NT_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = ncacn_push_auth(&rep->data, call, &pkt, NULL);
|
status = ncacn_push_auth(&rep->blob, call, &pkt, NULL);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcerpc_set_frag_length(&rep->data, rep->data.length);
|
dcerpc_set_frag_length(&rep->blob, rep->blob.length);
|
||||||
|
|
||||||
DLIST_ADD_END(call->replies, rep, struct dcesrv_call_reply *);
|
DLIST_ADD_END(call->replies, rep, struct data_blob_list_item *);
|
||||||
DLIST_ADD_END(call->conn->call_list, call, struct dcesrv_call_state *);
|
DLIST_ADD_END(call->conn->call_list, call, struct dcesrv_call_state *);
|
||||||
|
|
||||||
return NT_STATUS_OK;
|
return NT_STATUS_OK;
|
||||||
@@ -424,7 +424,7 @@ static NTSTATUS dcesrv_fault(struct dcesrv_call_state *call, uint32_t fault_code
|
|||||||
static NTSTATUS dcesrv_bind_nak(struct dcesrv_call_state *call, uint32_t reason)
|
static NTSTATUS dcesrv_bind_nak(struct dcesrv_call_state *call, uint32_t reason)
|
||||||
{
|
{
|
||||||
struct ncacn_packet pkt;
|
struct ncacn_packet pkt;
|
||||||
struct dcesrv_call_reply *rep;
|
struct data_blob_list_item *rep;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
/* setup a bind_nak */
|
/* setup a bind_nak */
|
||||||
@@ -436,19 +436,19 @@ static NTSTATUS dcesrv_bind_nak(struct dcesrv_call_state *call, uint32_t reason)
|
|||||||
pkt.u.bind_nak.reject_reason = reason;
|
pkt.u.bind_nak.reject_reason = reason;
|
||||||
pkt.u.bind_nak.num_versions = 0;
|
pkt.u.bind_nak.num_versions = 0;
|
||||||
|
|
||||||
rep = talloc(call, struct dcesrv_call_reply);
|
rep = talloc(call, struct data_blob_list_item);
|
||||||
if (!rep) {
|
if (!rep) {
|
||||||
return NT_STATUS_NO_MEMORY;
|
return NT_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = ncacn_push_auth(&rep->data, call, &pkt, NULL);
|
status = ncacn_push_auth(&rep->blob, call, &pkt, NULL);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcerpc_set_frag_length(&rep->data, rep->data.length);
|
dcerpc_set_frag_length(&rep->blob, rep->blob.length);
|
||||||
|
|
||||||
DLIST_ADD_END(call->replies, rep, struct dcesrv_call_reply *);
|
DLIST_ADD_END(call->replies, rep, struct data_blob_list_item *);
|
||||||
DLIST_ADD_END(call->conn->call_list, call, struct dcesrv_call_state *);
|
DLIST_ADD_END(call->conn->call_list, call, struct dcesrv_call_state *);
|
||||||
|
|
||||||
return NT_STATUS_OK;
|
return NT_STATUS_OK;
|
||||||
@@ -463,7 +463,7 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call)
|
|||||||
const char *uuid, *transfer_syntax;
|
const char *uuid, *transfer_syntax;
|
||||||
uint32_t if_version, transfer_syntax_version;
|
uint32_t if_version, transfer_syntax_version;
|
||||||
struct ncacn_packet pkt;
|
struct ncacn_packet pkt;
|
||||||
struct dcesrv_call_reply *rep;
|
struct data_blob_list_item *rep;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
uint32_t result=0, reason=0;
|
uint32_t result=0, reason=0;
|
||||||
uint32_t context_id;
|
uint32_t context_id;
|
||||||
@@ -571,20 +571,20 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rep = talloc(call, struct dcesrv_call_reply);
|
rep = talloc(call, struct data_blob_list_item);
|
||||||
if (!rep) {
|
if (!rep) {
|
||||||
return NT_STATUS_NO_MEMORY;
|
return NT_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = ncacn_push_auth(&rep->data, call, &pkt,
|
status = ncacn_push_auth(&rep->blob, call, &pkt,
|
||||||
call->conn->auth_state.auth_info);
|
call->conn->auth_state.auth_info);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcerpc_set_frag_length(&rep->data, rep->data.length);
|
dcerpc_set_frag_length(&rep->blob, rep->blob.length);
|
||||||
|
|
||||||
DLIST_ADD_END(call->replies, rep, struct dcesrv_call_reply *);
|
DLIST_ADD_END(call->replies, rep, struct data_blob_list_item *);
|
||||||
DLIST_ADD_END(call->conn->call_list, call, struct dcesrv_call_state *);
|
DLIST_ADD_END(call->conn->call_list, call, struct dcesrv_call_state *);
|
||||||
|
|
||||||
return NT_STATUS_OK;
|
return NT_STATUS_OK;
|
||||||
@@ -664,7 +664,7 @@ static NTSTATUS dcesrv_alter_new_context(struct dcesrv_call_state *call, uint32_
|
|||||||
static NTSTATUS dcesrv_alter(struct dcesrv_call_state *call)
|
static NTSTATUS dcesrv_alter(struct dcesrv_call_state *call)
|
||||||
{
|
{
|
||||||
struct ncacn_packet pkt;
|
struct ncacn_packet pkt;
|
||||||
struct dcesrv_call_reply *rep;
|
struct data_blob_list_item *rep;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
uint32_t result=0, reason=0;
|
uint32_t result=0, reason=0;
|
||||||
uint32_t context_id;
|
uint32_t context_id;
|
||||||
@@ -713,20 +713,20 @@ static NTSTATUS dcesrv_alter(struct dcesrv_call_state *call)
|
|||||||
return dcesrv_bind_nak(call, 0);
|
return dcesrv_bind_nak(call, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
rep = talloc(call, struct dcesrv_call_reply);
|
rep = talloc(call, struct data_blob_list_item);
|
||||||
if (!rep) {
|
if (!rep) {
|
||||||
return NT_STATUS_NO_MEMORY;
|
return NT_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = ncacn_push_auth(&rep->data, call, &pkt,
|
status = ncacn_push_auth(&rep->blob, call, &pkt,
|
||||||
call->conn->auth_state.auth_info);
|
call->conn->auth_state.auth_info);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcerpc_set_frag_length(&rep->data, rep->data.length);
|
dcerpc_set_frag_length(&rep->blob, rep->blob.length);
|
||||||
|
|
||||||
DLIST_ADD_END(call->replies, rep, struct dcesrv_call_reply *);
|
DLIST_ADD_END(call->replies, rep, struct data_blob_list_item *);
|
||||||
DLIST_ADD_END(call->conn->call_list, call, struct dcesrv_call_state *);
|
DLIST_ADD_END(call->conn->call_list, call, struct dcesrv_call_state *);
|
||||||
|
|
||||||
return NT_STATUS_OK;
|
return NT_STATUS_OK;
|
||||||
@@ -843,10 +843,10 @@ NTSTATUS dcesrv_reply(struct dcesrv_call_state *call)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
struct dcesrv_call_reply *rep;
|
struct data_blob_list_item *rep;
|
||||||
struct ncacn_packet pkt;
|
struct ncacn_packet pkt;
|
||||||
|
|
||||||
rep = talloc(call, struct dcesrv_call_reply);
|
rep = talloc(call, struct data_blob_list_item);
|
||||||
NT_STATUS_HAVE_NO_MEMORY(rep);
|
NT_STATUS_HAVE_NO_MEMORY(rep);
|
||||||
|
|
||||||
length = stub.length;
|
length = stub.length;
|
||||||
@@ -874,13 +874,13 @@ NTSTATUS dcesrv_reply(struct dcesrv_call_state *call)
|
|||||||
pkt.u.response.stub_and_verifier.data = stub.data;
|
pkt.u.response.stub_and_verifier.data = stub.data;
|
||||||
pkt.u.response.stub_and_verifier.length = length;
|
pkt.u.response.stub_and_verifier.length = length;
|
||||||
|
|
||||||
if (!dcesrv_auth_response(call, &rep->data, &pkt)) {
|
if (!dcesrv_auth_response(call, &rep->blob, &pkt)) {
|
||||||
return dcesrv_fault(call, DCERPC_FAULT_OTHER);
|
return dcesrv_fault(call, DCERPC_FAULT_OTHER);
|
||||||
}
|
}
|
||||||
|
|
||||||
dcerpc_set_frag_length(&rep->data, rep->data.length);
|
dcerpc_set_frag_length(&rep->blob, rep->blob.length);
|
||||||
|
|
||||||
DLIST_ADD_END(call->replies, rep, struct dcesrv_call_reply *);
|
DLIST_ADD_END(call->replies, rep, struct data_blob_list_item *);
|
||||||
|
|
||||||
stub.data += length;
|
stub.data += length;
|
||||||
stub.length -= length;
|
stub.length -= length;
|
||||||
@@ -1116,7 +1116,7 @@ NTSTATUS dcesrv_output(struct dcesrv_connection *dce_conn,
|
|||||||
{
|
{
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
struct dcesrv_call_state *call;
|
struct dcesrv_call_state *call;
|
||||||
struct dcesrv_call_reply *rep;
|
struct data_blob_list_item *rep;
|
||||||
size_t nwritten;
|
size_t nwritten;
|
||||||
|
|
||||||
call = dce_conn->call_list;
|
call = dce_conn->call_list;
|
||||||
@@ -1132,13 +1132,13 @@ NTSTATUS dcesrv_output(struct dcesrv_connection *dce_conn,
|
|||||||
}
|
}
|
||||||
rep = call->replies;
|
rep = call->replies;
|
||||||
|
|
||||||
status = write_fn(private_data, &rep->data, &nwritten);
|
status = write_fn(private_data, &rep->blob, &nwritten);
|
||||||
NT_STATUS_IS_ERR_RETURN(status);
|
NT_STATUS_IS_ERR_RETURN(status);
|
||||||
|
|
||||||
rep->data.length -= nwritten;
|
rep->blob.length -= nwritten;
|
||||||
rep->data.data += nwritten;
|
rep->blob.data += nwritten;
|
||||||
|
|
||||||
if (rep->data.length == 0) {
|
if (rep->blob.length == 0) {
|
||||||
/* we're done with this section of the call */
|
/* we're done with this section of the call */
|
||||||
DLIST_REMOVE(call->replies, rep);
|
DLIST_REMOVE(call->replies, rep);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,10 +102,7 @@ struct dcesrv_call_state {
|
|||||||
|
|
||||||
DATA_BLOB input;
|
DATA_BLOB input;
|
||||||
|
|
||||||
struct dcesrv_call_reply {
|
struct data_blob_list_item *replies;
|
||||||
struct dcesrv_call_reply *next, *prev;
|
|
||||||
DATA_BLOB data;
|
|
||||||
} *replies;
|
|
||||||
|
|
||||||
/* this is used by the boilerplate code to generate DCERPC faults */
|
/* this is used by the boilerplate code to generate DCERPC faults */
|
||||||
uint32_t fault_code;
|
uint32_t fault_code;
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ static void dcesrv_sock_accept(struct stream_connection *srv_conn)
|
|||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
DEBUG(0,("dcesrv_sock_accept: dcesrv_endpoint_connect failed: %s\n",
|
DEBUG(0,("dcesrv_sock_accept: dcesrv_endpoint_connect failed: %s\n",
|
||||||
nt_errstr(status)));
|
nt_errstr(status)));
|
||||||
|
stream_terminate_connection(srv_conn, nt_errstr(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,11 +39,8 @@
|
|||||||
state of an open winbind connection
|
state of an open winbind connection
|
||||||
*/
|
*/
|
||||||
struct wbserver_connection {
|
struct wbserver_connection {
|
||||||
DATA_BLOB blob;
|
DATA_BLOB input;
|
||||||
struct send_queue {
|
struct data_blob_list_item *send_queue;
|
||||||
struct send_queue *next, *prev;
|
|
||||||
DATA_BLOB blob;
|
|
||||||
} *queue;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -55,7 +52,7 @@ static void winbind_accept(struct stream_connection *conn)
|
|||||||
struct wbserver_connection *wbconn;
|
struct wbserver_connection *wbconn;
|
||||||
|
|
||||||
wbconn = talloc_zero(conn, struct wbserver_connection);
|
wbconn = talloc_zero(conn, struct wbserver_connection);
|
||||||
wbconn->blob = data_blob_talloc(wbconn, NULL, 1024);
|
wbconn->input = data_blob_talloc(wbconn, NULL, 1024);
|
||||||
|
|
||||||
conn->private = wbconn;
|
conn->private = wbconn;
|
||||||
}
|
}
|
||||||
@@ -68,9 +65,9 @@ static void winbind_recv(struct stream_connection *conn, uint16_t flags)
|
|||||||
struct wbserver_connection *wbconn = talloc_get_type(conn->private, struct wbserver_connection);
|
struct wbserver_connection *wbconn = talloc_get_type(conn->private, struct wbserver_connection);
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
size_t nread;
|
size_t nread;
|
||||||
struct send_queue *q;
|
struct data_blob_list_item *q;
|
||||||
|
|
||||||
status = socket_recv(conn->socket, wbconn->blob.data, wbconn->blob.length, &nread, 0);
|
status = socket_recv(conn->socket, wbconn->input.data, wbconn->input.length, &nread, 0);
|
||||||
if (NT_STATUS_IS_ERR(status)) {
|
if (NT_STATUS_IS_ERR(status)) {
|
||||||
DEBUG(10,("socket_recv: %s\n",nt_errstr(status)));
|
DEBUG(10,("socket_recv: %s\n",nt_errstr(status)));
|
||||||
stream_terminate_connection(conn, "socket_recv: failed\n");
|
stream_terminate_connection(conn, "socket_recv: failed\n");
|
||||||
@@ -78,19 +75,19 @@ static void winbind_recv(struct stream_connection *conn, uint16_t flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* just reflect the data back down the socket */
|
/* just reflect the data back down the socket */
|
||||||
q = talloc(wbconn, struct send_queue);
|
q = talloc(wbconn, struct data_blob_list_item);
|
||||||
if (q == NULL) {
|
if (q == NULL) {
|
||||||
stream_terminate_connection(conn, "winbind_recv: out of memory\n");
|
stream_terminate_connection(conn, "winbind_recv: out of memory\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
q->blob = data_blob_talloc(q, wbconn->blob.data, nread);
|
q->blob = data_blob_talloc(q, wbconn->input.data, nread);
|
||||||
if (q->blob.data == NULL) {
|
if (q->blob.data == NULL) {
|
||||||
stream_terminate_connection(conn, "winbind_recv: out of memory\n");
|
stream_terminate_connection(conn, "winbind_recv: out of memory\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DLIST_ADD_END(wbconn->queue, q, struct send_queue *);
|
DLIST_ADD_END(wbconn->send_queue, q, struct data_blob_list_item *);
|
||||||
|
|
||||||
EVENT_FD_WRITEABLE(conn->event.fde);
|
EVENT_FD_WRITEABLE(conn->event.fde);
|
||||||
}
|
}
|
||||||
@@ -102,8 +99,8 @@ static void winbind_send(struct stream_connection *conn, uint16_t flags)
|
|||||||
{
|
{
|
||||||
struct wbserver_connection *wbconn = talloc_get_type(conn->private, struct wbserver_connection);
|
struct wbserver_connection *wbconn = talloc_get_type(conn->private, struct wbserver_connection);
|
||||||
|
|
||||||
while (wbconn->queue) {
|
while (wbconn->send_queue) {
|
||||||
struct send_queue *q = wbconn->queue;
|
struct data_blob_list_item *q = wbconn->send_queue;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
size_t sendlen;
|
size_t sendlen;
|
||||||
|
|
||||||
@@ -121,7 +118,7 @@ static void winbind_send(struct stream_connection *conn, uint16_t flags)
|
|||||||
q->blob.data += sendlen;
|
q->blob.data += sendlen;
|
||||||
|
|
||||||
if (q->blob.length == 0) {
|
if (q->blob.length == 0) {
|
||||||
DLIST_REMOVE(wbconn->queue, q);
|
DLIST_REMOVE(wbconn->send_queue, q);
|
||||||
talloc_free(q);
|
talloc_free(q);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user