#include "rpc_server/rpc_ncacn_np.h"
#include "rpc_server/srv_pipe_hnd.h"
#include "rpc_server/srv_pipe.h"
+#include "libcli/security/security_token.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
struct dcerpc_ncacn_conn *ncacn_conn = tevent_req_callback_data(
subreq, struct dcerpc_ncacn_conn);
struct auth_session_info_transport *session_info_transport = NULL;
+ enum dcerpc_transport_t transport;
int error;
int ret;
ret = tstream_npa_accept_existing_recv(subreq, &error, ncacn_conn,
&ncacn_conn->tstream,
NULL,
- NULL,
+ &transport,
&ncacn_conn->remote_client_addr,
&ncacn_conn->remote_client_name,
&ncacn_conn->local_server_addr,
ncacn_conn->session_info = talloc_move(ncacn_conn,
&session_info_transport->session_info);
+ if (transport != NCACN_NP) {
+ ncacn_terminate_connection(
+ ncacn_conn,
+ "Only allow NCACN_NP transport on named pipes\n");
+ return;
+ }
+
+ if (security_token_is_system(
+ ncacn_conn->session_info->security_token)) {
+ ncacn_terminate_connection(
+ ncacn_conn,
+ "No system token via NCACN_NP allowed\n");
+ return;
+ }
+
TALLOC_FREE(subreq);
if (ret != 0) {
DBG_ERR("Failed to accept named pipe connection: %s\n",
goto out;
}
+ if (transport == NCACN_NP) {
+ if (security_token_is_system(conn->session_info->security_token)) {
+ reason = talloc_asprintf(
+ conn,
+ "System token not allowed on transport %d\n",
+ transport);
+ goto out;
+ }
+ } else if (transport == NCALRPC) {
+ /*
+ * TODO:
+ * we should somehow remember the given transport on
+ * the connection, but that's a task for another day
+ * as it's not trivial to do...
+ */
+ } else {
+ reason = talloc_asprintf(
+ conn,
+ "Only allow NCACN_NP or NCALRPC transport on named pipes, "
+ "got %d\n",
+ (int)transport);
+ goto out;
+ }
+
/*
* hand over to the real pipe implementation,
* now that we have setup the transport session_info