From 1a993b800eca5dc8daccc715da46e7b84c604389 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 5 Jun 2004 01:29:20 +0000 Subject: r1016: - store the schannel session key after it is established - move to a centralised way of handling talloc/ldb interaction (This used to be commit 2b9b752875ba5e03e82f40e31f26bc1f245b3825) --- source4/rpc_server/config.mk | 2 ++ source4/rpc_server/netlogon/dcerpc_netlogon.c | 5 ++++- source4/rpc_server/samr/samdb.c | 30 ++++++++++----------------- 3 files changed, 17 insertions(+), 20 deletions(-) (limited to 'source4/rpc_server') diff --git a/source4/rpc_server/config.mk b/source4/rpc_server/config.mk index d532256c10..4a7b17cffb 100644 --- a/source4/rpc_server/config.mk +++ b/source4/rpc_server/config.mk @@ -97,6 +97,8 @@ REQUIRED_SUBSYSTEMS = \ [MODULE::dcerpc_netlogon] INIT_OBJ_FILES = \ rpc_server/netlogon/dcerpc_netlogon.o +ADD_OBJ_FILES = \ + rpc_server/netlogon/schannel_state.o REQUIRED_SUBSYSTEMS = \ SAMDB \ DCERPC_COMMON diff --git a/source4/rpc_server/netlogon/dcerpc_netlogon.c b/source4/rpc_server/netlogon/dcerpc_netlogon.c index f662e45246..ea76be44f5 100644 --- a/source4/rpc_server/netlogon/dcerpc_netlogon.c +++ b/source4/rpc_server/netlogon/dcerpc_netlogon.c @@ -251,7 +251,10 @@ static NTSTATUS netr_ServerAuthenticate3(struct dcesrv_call_state *dce_call, TAL pipe_state->computer_name = talloc_strdup(pipe_state->mem_ctx, r->in.computer_name); - return NT_STATUS_OK; + /* remember this session key state */ + nt_status = schannel_store_session_key(mem_ctx, pipe_state->computer_name, pipe_state->creds); + + return nt_status; } diff --git a/source4/rpc_server/samr/samdb.c b/source4/rpc_server/samr/samdb.c index e6862eb8f9..872ec82894 100644 --- a/source4/rpc_server/samr/samdb.c +++ b/source4/rpc_server/samr/samdb.c @@ -88,14 +88,6 @@ void samdb_close(void *ctx) free(sam_ctx); } -/* - a alloc function for ldb -*/ -static void *samdb_alloc(void *context, void *ptr, size_t size) -{ - return talloc_realloc((TALLOC_CTX *)context, ptr, size); -} - /* search the sam for the specified attributes - va_list varient */ @@ -116,7 +108,7 @@ int samdb_search_v(void *ctx, return -1; } - ldb_set_alloc(sam_ctx->ldb, samdb_alloc, mem_ctx); + ldb_set_alloc(sam_ctx->ldb, talloc_ldb_alloc, mem_ctx); count = ldb_search(sam_ctx->ldb, basedn, LDB_SCOPE_SUBTREE, expr, attrs, res); @@ -155,7 +147,7 @@ int samdb_search_free(void *ctx, TALLOC_CTX *mem_ctx, struct ldb_message **res) { struct samdb_context *sam_ctx = ctx; - ldb_set_alloc(sam_ctx->ldb, samdb_alloc, mem_ctx); + ldb_set_alloc(sam_ctx->ldb, talloc_ldb_alloc, mem_ctx); return ldb_search_free(sam_ctx->ldb, res); } @@ -772,7 +764,7 @@ int samdb_msg_add_string(void *ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg if (s == NULL || a == NULL) { return -1; } - ldb_set_alloc(sam_ctx->ldb, samdb_alloc, mem_ctx); + ldb_set_alloc(sam_ctx->ldb, talloc_ldb_alloc, mem_ctx); return ldb_msg_add_string(sam_ctx->ldb, msg, a, s); } @@ -787,7 +779,7 @@ int samdb_msg_add_delete(void *ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg if (a == NULL) { return -1; } - ldb_set_alloc(sam_ctx->ldb, samdb_alloc, mem_ctx); + ldb_set_alloc(sam_ctx->ldb, talloc_ldb_alloc, mem_ctx); /* we use an empty replace rather than a delete, as it allows for samdb_replace() to be used everywhere */ return ldb_msg_add_empty(sam_ctx->ldb, msg, a, LDB_FLAG_MOD_REPLACE); @@ -837,7 +829,7 @@ int samdb_msg_add_hash(void *ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg, return -1; } memcpy(val.data, hash.hash, 16); - ldb_set_alloc(sam_ctx->ldb, samdb_alloc, mem_ctx); + ldb_set_alloc(sam_ctx->ldb, talloc_ldb_alloc, mem_ctx); return ldb_msg_add_value(sam_ctx->ldb, msg, attr_name, &val); } @@ -858,7 +850,7 @@ int samdb_msg_add_hashes(void *ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg for (i=0;ildb, samdb_alloc, mem_ctx); + ldb_set_alloc(sam_ctx->ldb, talloc_ldb_alloc, mem_ctx); return ldb_msg_add_value(sam_ctx->ldb, msg, attr_name, &val); } @@ -881,7 +873,7 @@ int samdb_msg_add_logon_hours(void *ctx, TALLOC_CTX *mem_ctx, struct ldb_message struct ldb_val val; val.length = hours.units_per_week / 8; val.data = hours.bitmap; - ldb_set_alloc(sam_ctx->ldb, samdb_alloc, mem_ctx); + ldb_set_alloc(sam_ctx->ldb, talloc_ldb_alloc, mem_ctx); return ldb_msg_add_value(sam_ctx->ldb, msg, attr_name, &val); } @@ -894,7 +886,7 @@ int samdb_msg_set_string(void *ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg struct samdb_context *sam_ctx = ctx; struct ldb_message_element *el; - ldb_set_alloc(sam_ctx->ldb, samdb_alloc, mem_ctx); + ldb_set_alloc(sam_ctx->ldb, talloc_ldb_alloc, mem_ctx); el = ldb_msg_find_element(msg, attr_name); if (el) { @@ -923,7 +915,7 @@ int samdb_add(void *ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg) { struct samdb_context *sam_ctx = ctx; - ldb_set_alloc(sam_ctx->ldb, samdb_alloc, mem_ctx); + ldb_set_alloc(sam_ctx->ldb, talloc_ldb_alloc, mem_ctx); return ldb_add(sam_ctx->ldb, msg); } @@ -934,7 +926,7 @@ int samdb_delete(void *ctx, TALLOC_CTX *mem_ctx, const char *dn) { struct samdb_context *sam_ctx = ctx; - ldb_set_alloc(sam_ctx->ldb, samdb_alloc, mem_ctx); + ldb_set_alloc(sam_ctx->ldb, talloc_ldb_alloc, mem_ctx); return ldb_delete(sam_ctx->ldb, dn); } @@ -945,7 +937,7 @@ int samdb_modify(void *ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg) { struct samdb_context *sam_ctx = ctx; - ldb_set_alloc(sam_ctx->ldb, samdb_alloc, mem_ctx); + ldb_set_alloc(sam_ctx->ldb, talloc_ldb_alloc, mem_ctx); return ldb_modify(sam_ctx->ldb, msg); } -- cgit