s4:rpc_server/winreg: don't cache an ldb connection per presentation context
authorStefan Metzmacher <metze@samba.org>
Wed, 21 Nov 2018 19:05:01 +0000 (20:05 +0100)
committerJeremy Allison <jra@samba.org>
Sat, 12 Jan 2019 02:13:39 +0000 (03:13 +0100)
We should do this per context handle, as these are available on all
connections of the association group.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/rpc_server/winreg/rpc_winreg.c

index d7ae5ac..3adaafe 100644 (file)
 
 enum handle_types { HTYPE_REGVAL, HTYPE_REGKEY };
 
-static NTSTATUS dcerpc_winreg_bind(struct dcesrv_call_state *dce_call,
-                                  const struct dcesrv_interface *iface)
-{
-       struct auth_session_info *session_info =
-               dcesrv_call_session_info(dce_call);
-       struct registry_context *ctx;
-       WERROR err;
-
-       err = reg_open_samba(dce_call->context,
-                            &ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx,
-                            session_info,
-                            NULL);
-
-       if (!W_ERROR_IS_OK(err)) {
-               DEBUG(0, ("Error opening registry: %s\n", win_errstr(err)));
-               return werror_to_ntstatus(err);
-       }
-
-       dce_call->context->private_data = ctx;
-
-       return NT_STATUS_OK;
-}
-
-#define DCESRV_INTERFACE_WINREG_BIND dcerpc_winreg_bind
-
 static WERROR dcesrv_winreg_openhive(struct dcesrv_call_state *dce_call,
                                     TALLOC_CTX *mem_ctx, uint32_t hkey,
                                     struct policy_handle **outh)
 {
-       struct registry_context *ctx = dce_call->context->private_data;
+       struct auth_session_info *session_info =
+               dcesrv_call_session_info(dce_call);
+       struct registry_context *ctx = NULL;
        struct dcesrv_handle *h;
        WERROR result;
 
        h = dcesrv_handle_create(dce_call, HTYPE_REGKEY);
        W_ERROR_HAVE_NO_MEMORY(h);
 
+       result = reg_open_samba(h, &ctx,
+                               dce_call->event_ctx,
+                               dce_call->conn->dce_ctx->lp_ctx,
+                               session_info,
+                               NULL);
+       if (!W_ERROR_IS_OK(result)) {
+               DEBUG(0, ("Error opening registry: %s\n", win_errstr(result)));
+               return result;
+       }
+
        result = reg_get_predefined_key(ctx, hkey,
                                       (struct registry_key **)&h->data);
        if (!W_ERROR_IS_OK(result)) {