s4-rpc_server: Allow each interface to declare if it uses handles
authorAndrew Bartlett <abartlet@samba.org>
Sun, 13 Nov 2016 22:24:03 +0000 (11:24 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 20 Dec 2016 00:11:23 +0000 (01:11 +0100)
This will allow the NETLOGON server in the AD DC to declare that it does not use
handles, and so allow some more flexibility with association groups

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm
source4/rpc_server/dcerpc_server.h
source4/rpc_server/dcesrv_mgmt.c
source4/rpc_server/handles.c
source4/rpc_server/netlogon/dcerpc_netlogon.c
source4/rpc_server/remote/dcesrv_remote.c

index fe5ca0bc5e9bb157ba0c63a2dd4bdd6733f694c9..88c7705c3c21a9f1fd8b052bb2811c620d599842 100644 (file)
@@ -193,14 +193,19 @@ static NTSTATUS $name\__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_C
 }
 
 static const struct dcesrv_interface dcesrv\_$name\_interface = {
-       .name           = \"$name\",
-       .syntax_id  = {".print_uuid($uuid).",$if_version},
-       .bind           = $name\__op_bind,
-       .unbind         = $name\__op_unbind,
-       .ndr_pull       = $name\__op_ndr_pull,
-       .dispatch       = $name\__op_dispatch,
-       .reply          = $name\__op_reply,
-       .ndr_push       = $name\__op_ndr_push
+       .name               = \"$name\",
+       .syntax_id          = {".print_uuid($uuid).",$if_version},
+       .bind               = $name\__op_bind,
+       .unbind             = $name\__op_unbind,
+       .ndr_pull           = $name\__op_ndr_pull,
+       .dispatch           = $name\__op_dispatch,
+       .reply              = $name\__op_reply,
+       .ndr_push           = $name\__op_ndr_push,
+#ifdef DCESRV_INTERFACE_$uname\_FLAGS
+       .flags              = DCESRV_INTERFACE_$uname\_FLAGS
+#else
+       .flags              = 0
+#endif
 };
 
 ";
index a1eddbcd5ebc0f055e0abddab490475ffaf4b8d4..a6772f94f620d989650ba38c3289da1e8f34a39f 100644 (file)
@@ -67,8 +67,12 @@ struct dcesrv_interface {
 
        /* for any private use by the interface code */
        const void *private_data;
+
+       uint64_t flags;
 };
 
+#define DCESRV_INTERFACE_FLAGS_HANDLES_NOT_USED 0x00000001
+
 enum dcesrv_call_list {
        DCESRV_LIST_NONE,
        DCESRV_LIST_CALL_LIST,
index 577f0fbb3696dc226f85f1d9f3873227af011a6e..ecb90d8848e8179e63248370cca7e7ba4244760f 100644 (file)
 
 #define DCESRV_INTERFACE_MGMT_BIND(call, iface) \
        dcesrv_interface_mgmt_bind(call, iface)
+/*
+ * This #define allows the mgmt interface to accept invalid
+ * association groups, because association groups are to coordinate
+ * handles, and handles are not used in mgmt. This in turn avoids
+ * the need to coordinate these across multiple possible NETLOGON
+ * processes, as an mgmt interface is added to each
+ */
+
+#define DCESRV_INTERFACE_MGMT_FLAGS DCESRV_INTERFACE_FLAGS_HANDLES_NOT_USED
+
 static NTSTATUS dcesrv_interface_mgmt_bind(struct dcesrv_call_state *dce_call,
                                             const struct dcesrv_interface *iface)
 {
index 820da49c02d2d895caebed1829b3cefdeac70e24..af49f4caf1c5cf718855da6e4e074dd25c3491bc 100644 (file)
@@ -44,6 +44,11 @@ _PUBLIC_ struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection_contex
        struct dcesrv_handle *h;
        struct dom_sid *sid;
 
+       /*
+        * For simplicty, ensure we abort here for an interface that has no handles (programmer error)
+        */
+       SMB_ASSERT((context->iface->flags & DCESRV_INTERFACE_FLAGS_HANDLES_NOT_USED) == 0);
+
        sid = &context->conn->auth_state.session_info->security_token->sids[PRIMARY_USER_SID_INDEX];
 
        h = talloc_zero(context->conn->assoc_group, struct dcesrv_handle);
@@ -80,6 +85,11 @@ _PUBLIC_ struct dcesrv_handle *dcesrv_handle_fetch(
        struct dcesrv_handle *h;
        struct dom_sid *sid;
 
+       /*
+        * For simplicty, ensure we abort here for an interface that has no handles (programmer error)
+        */
+       SMB_ASSERT((context->iface->flags & DCESRV_INTERFACE_FLAGS_HANDLES_NOT_USED) == 0);
+
        sid = &context->conn->auth_state.session_info->security_token->sids[PRIMARY_USER_SID_INDEX];
 
        if (ndr_policy_handle_empty(p)) {
index 416acdc0ef3ffae0d9c8ef1a41550e8c38396d67..15f0a77739b24f9397e0c48008d6901d6f414596 100644 (file)
 #define DCESRV_INTERFACE_NETLOGON_BIND(call, iface) \
        dcesrv_interface_netlogon_bind(call, iface)
 
+/*
+ * This #define allows the netlogon interface to accept invalid
+ * association groups, because association groups are to coordinate
+ * handles, and handles are not used in NETLOGON. This in turn avoids
+ * the need to coordinate these across multiple possible NETLOGON
+ * processes
+ */
+#define DCESRV_INTERFACE_NETLOGON_FLAGS DCESRV_INTERFACE_FLAGS_HANDLES_NOT_USED
+
 static NTSTATUS dcesrv_interface_netlogon_bind(struct dcesrv_call_state *dce_call,
                                               const struct dcesrv_interface *iface)
 {
index c6ef75720f53d22bdc4549d76338d095a029e6ad..69ce08cd1f7e24b895d8c1e3aa14b79b471fba55 100644 (file)
@@ -374,6 +374,7 @@ static bool remote_fill_interface(struct dcesrv_interface *iface, const struct n
        iface->ndr_push = remote_op_ndr_push;
 
        iface->private_data = if_tabl;
+       iface->flags = 0;
 
        return true;
 }