s4:rpc_server: only pass dcesrv_auth to auth_state.session_key_fn()
authorStefan Metzmacher <metze@samba.org>
Thu, 8 Nov 2018 10:14:41 +0000 (11:14 +0100)
committerJeremy Allison <jra@samba.org>
Sat, 12 Jan 2019 02:13:34 +0000 (03:13 +0100)
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/common/reply.c
source4/rpc_server/dcerpc_server.c
source4/rpc_server/dcerpc_server.h

index ef2906e..d0d81fe 100644 (file)
@@ -272,16 +272,3 @@ _PUBLIC_ NTSTATUS dcesrv_reply(struct dcesrv_call_state *call)
 
        return NT_STATUS_OK;
 }
-
-NTSTATUS dcesrv_generic_session_key(struct dcesrv_connection *c,
-                                   DATA_BLOB *session_key)
-{
-       enum dcerpc_transport_t transport =
-               dcerpc_binding_get_transport(c->endpoint->ep_description);
-
-       if (transport != NCALRPC && transport != NCACN_UNIX_STREAM) {
-               return NT_STATUS_NO_USER_SESSION_KEY;
-       }
-
-       return dcerpc_generic_session_key(NULL, session_key);
-}
index 5d7dfaf..7ceaf03 100644 (file)
@@ -474,11 +474,9 @@ static NTSTATUS dcesrv_session_info_session_key(struct dcesrv_auth *auth,
        return NT_STATUS_OK;
 }
 
-NTSTATUS dcesrv_inherited_session_key(struct dcesrv_connection *p,
-                                     DATA_BLOB *session_key)
+static NTSTATUS dcesrv_remote_session_key(struct dcesrv_auth *auth,
+                                         DATA_BLOB *session_key)
 {
-       struct dcesrv_auth *auth = &p->auth_state;
-
        if (auth->auth_type != DCERPC_AUTH_TYPE_NONE) {
                return NT_STATUS_NO_USER_SESSION_KEY;
        }
@@ -486,6 +484,20 @@ NTSTATUS dcesrv_inherited_session_key(struct dcesrv_connection *p,
        return dcesrv_session_info_session_key(auth, session_key);
 }
 
+static NTSTATUS dcesrv_local_fixed_session_key(struct dcesrv_auth *auth,
+                                              DATA_BLOB *session_key)
+{
+       return dcerpc_generic_session_key(NULL, session_key);
+}
+
+NTSTATUS dcesrv_inherited_session_key(struct dcesrv_connection *p,
+                                     DATA_BLOB *session_key)
+{
+       struct dcesrv_auth *auth = &p->auth_state;
+
+       return dcesrv_remote_session_key(auth, session_key);
+}
+
 /*
  * Fetch the authentication session key if available.
  *
@@ -511,11 +523,11 @@ _PUBLIC_ NTSTATUS dcesrv_fetch_session_key(struct dcesrv_connection *p,
        struct dcesrv_auth *auth = &p->auth_state;
        NTSTATUS status;
 
-       if (auth->session_key == NULL) {
+       if (auth->session_key_fn == NULL) {
                return NT_STATUS_NO_USER_SESSION_KEY;
        }
 
-       status = auth->session_key(p, session_key);
+       status = auth->session_key_fn(auth, session_key);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -582,11 +594,11 @@ static NTSTATUS dcesrv_endpoint_connect(struct dcesrv_context *dce_ctx,
        p->auth_state.session_info = session_info;
        switch (transport) {
        case NCACN_NP:
-               p->auth_state.session_key = dcesrv_inherited_session_key;
+               p->auth_state.session_key_fn = dcesrv_remote_session_key;
                break;
        case NCALRPC:
        case NCACN_UNIX_STREAM:
-               p->auth_state.session_key = dcesrv_generic_session_key;
+               p->auth_state.session_key_fn = dcesrv_local_fixed_session_key;
                break;
        default:
                /*
index f6f4954..1d80a2f 100644 (file)
@@ -199,7 +199,7 @@ struct dcesrv_auth {
        uint32_t auth_context_id;
        struct gensec_security *gensec_security;
        struct auth_session_info *session_info;
-       NTSTATUS (*session_key)(struct dcesrv_connection *, DATA_BLOB *session_key);
+       NTSTATUS (*session_key_fn)(struct dcesrv_auth *, DATA_BLOB *session_key);
        bool client_hdr_signing;
        bool hdr_signing;
        bool auth_finished;