s4:rpc_server: only pass context to op_bind() hooks
[gd/samba-autobuild/.git] / source4 / rpc_server / dnsserver / dcerpc_dnsserver.c
index ce01c9c258fa08e1b6601477d033a366f9ddbfff..841557814a0290d4fbc39ee41a950285f3f679d3 100644 (file)
 #include "dns_server/dnsserver_common.h"
 #include "dnsserver.h"
 
-#define DCESRV_INTERFACE_DNSSERVER_BIND(call, iface) \
-       dcesrv_interface_dnsserver_bind(call, iface)
-static NTSTATUS dcesrv_interface_dnsserver_bind(struct dcesrv_call_state *dce_call,
+#define DCESRV_INTERFACE_DNSSERVER_BIND(context, iface) \
+       dcesrv_interface_dnsserver_bind(context, iface)
+static NTSTATUS dcesrv_interface_dnsserver_bind(struct dcesrv_connection_context *context,
                                                const struct dcesrv_interface *iface)
 {
-       return dcesrv_interface_bind_require_integrity(dce_call, iface);
+       return dcesrv_interface_bind_require_integrity(context, iface);
 }
 
+#define DNSSERVER_STATE_MAGIC 0xc9657ab4
 struct dnsserver_state {
        struct loadparm_context *lp_ctx;
        struct ldb_context *samdb;
@@ -103,16 +104,21 @@ static void dnsserver_reload_zones(struct dnsserver_state *dsstate)
 
 static struct dnsserver_state *dnsserver_connect(struct dcesrv_call_state *dce_call)
 {
+       struct auth_session_info *session_info =
+               dcesrv_call_session_info(dce_call);
        struct dnsserver_state *dsstate;
        struct dnsserver_zone *zones, *z, *znext;
        struct dnsserver_partition *partitions, *p;
+       NTSTATUS status;
 
-       dsstate = talloc_get_type(dce_call->context->private_data, struct dnsserver_state);
+       dsstate = dcesrv_iface_state_find_conn(dce_call,
+                                              DNSSERVER_STATE_MAGIC,
+                                              struct dnsserver_state);
        if (dsstate != NULL) {
                return dsstate;
        }
 
-       dsstate = talloc_zero(dce_call->context, struct dnsserver_state);
+       dsstate = talloc_zero(dce_call, struct dnsserver_state);
        if (dsstate == NULL) {
                return NULL;
        }
@@ -123,7 +129,7 @@ static struct dnsserver_state *dnsserver_connect(struct dcesrv_call_state *dce_c
        dsstate->samdb = samdb_connect(dsstate,
                                       dce_call->event_ctx,
                                       dsstate->lp_ctx,
-                                      dce_call->conn->auth_state.session_info,
+                                      session_info,
                                       dce_call->conn->remote_address,
                                       0);
        if (dsstate->samdb == NULL) {
@@ -171,7 +177,12 @@ static struct dnsserver_state *dnsserver_connect(struct dcesrv_call_state *dce_c
                }
        }
 
-       dce_call->context->private_data = dsstate;
+       status = dcesrv_iface_state_store_conn(dce_call,
+                                              DNSSERVER_STATE_MAGIC,
+                                              dsstate);
+       if (!NT_STATUS_IS_OK(status)) {
+               goto failed;
+       }
 
        return dsstate;