*/
#include "includes.h"
+#include "events.h"
+#include "auth/auth.h"
+#include "dlinklist.h"
+#include "asn_1.h"
+#include "ldap_server/ldap_server.h"
/*
close the socket and shutdown a server_context
*/
static void add_socket(struct server_service *service,
const struct model_ops *model_ops,
- struct in_addr *ifip)
+ struct ipv4_addr *ifip)
{
struct server_socket *srv_sock;
uint16_t port = 389;
- char *ip_str = talloc_strdup(service, inet_ntoa(*ifip));
+ char *ip_str = talloc_strdup(service, sys_inet_ntoa(*ifip));
srv_sock = service_setup_socket(service, model_ops, "ipv4", ip_str, &port);
socket per interface and bind to only these.
*/
for(i = 0; i < num_interfaces; i++) {
- struct in_addr *ifip = iface_n_ip(i);
+ struct ipv4_addr *ifip = iface_n_ip(i);
if (ifip == NULL) {
DEBUG(0,("ldapsrv_init: interface %d has NULL "
add_socket(service, model_ops, ifip);
}
} else {
- struct in_addr ifip;
+ struct ipv4_addr ifip;
/* Just bind to lp_socket_address() (usually 0.0.0.0) */
ifip = interpret_addr2(lp_socket_address());
NTSTATUS status;
DATA_BLOB tmp_blob;
BOOL ret;
+ size_t nread;
- status = socket_recv(sock, sock, &tmp_blob, 1024, 0);
- if (!NT_STATUS_IS_OK(status)) {
+ tmp_blob = data_blob_talloc(sock, NULL, 1024);
+ if (tmp_blob.data == NULL) {
+ return False;
+ }
+
+ status = socket_recv(sock, tmp_blob.data, tmp_blob.length, &nread, 0);
+ if (NT_STATUS_IS_ERR(status)) {
DEBUG(10,("socket_recv: %s\n",nt_errstr(status)));
+ talloc_free(tmp_blob.data);
return False;
}
int buf_length, sasl_length;
struct socket_context *sock = conn->connection->socket;
TALLOC_CTX *mem_ctx;
+ size_t nread;
if (!conn->gensec || !conn->session_info ||
!(gensec_have_feature(conn->gensec, GENSEC_WANT_SIGN) &&
return False;
}
- status = socket_recv(sock, mem_ctx, &tmp_blob, 1024, 0);
- if (!NT_STATUS_IS_OK(status)) {
+ tmp_blob = data_blob_talloc(mem_ctx, NULL, 1024);
+ if (tmp_blob.data == NULL) {
+ talloc_free(mem_ctx);
+ return False;
+ }
+
+ status = socket_recv(sock, tmp_blob.data, tmp_blob.length, &nread, 0);
+ if (NT_STATUS_IS_ERR(status)) {
DEBUG(10,("socket_recv: %s\n",nt_errstr(status)));
talloc_free(mem_ctx);
return False;
}
+ tmp_blob.length = nread;
ret = ldapsrv_append_to_buf(&conn->sasl_in_buffer, tmp_blob.data, tmp_blob.length);
if (!ret) {
tmp_blob.data = buf->data;
tmp_blob.length = buf->length;
- status = socket_send(sock, sock, &tmp_blob, &sendlen, 0);
+ status = socket_send(sock, &tmp_blob, &sendlen, 0);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10,("socket_send() %s\n",nt_errstr(status)));
return False;
tmp_blob.data = conn->sasl_out_buffer.data;
tmp_blob.length = conn->sasl_out_buffer.length;
- status = socket_send(sock, mem_ctx, &tmp_blob, &sendlen, 0);
+ status = socket_send(sock, &tmp_blob, &sendlen, 0);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10,("socket_send() %s\n",nt_errstr(status)));
talloc_free(mem_ctx);
/*
called when a LDAP socket becomes readable
*/
-static void ldapsrv_recv(struct server_connection *conn, time_t t,
+static void ldapsrv_recv(struct server_connection *conn, struct timeval t,
uint16_t flags)
{
struct ldapsrv_connection *ldap_conn = conn->private_data;
uint8_t *buf;
int buf_length, msg_length;
DATA_BLOB blob;
- ASN1_DATA data;
+ struct asn1_data data;
struct ldapsrv_call *call;
NTSTATUS status;
/*
called when a LDAP socket becomes writable
*/
-static void ldapsrv_send(struct server_connection *conn, time_t t,
+static void ldapsrv_send(struct server_connection *conn, struct timeval t,
uint16_t flags)
{
struct ldapsrv_connection *ldap_conn = conn->private_data;
/*
called when connection is idle
*/
-static void ldapsrv_idle(struct server_connection *conn, time_t t)
+static void ldapsrv_idle(struct server_connection *conn, struct timeval t)
{
DEBUG(10,("ldapsrv_idle: not implemented!\n"));
return;