libcli/util Rename common map_nt_error_from_unix to avoid duplicate symbol
[sfrench/samba-autobuild/.git] / source4 / rpc_server / dcerpc_server.c
index 1371ad9b360821c152d538304fa458a0f046012c..cbba5e24085958ba42dc8330cc67a1033571815a 100644 (file)
@@ -38,6 +38,7 @@
 #include "lib/socket/socket.h"
 #include "smbd/process_model.h"
 #include "lib/messaging/irpc.h"
+#include "librpc/rpc/rpc_common.h"
 
 /* this is only used when the client asks for an unknown interface */
 #define DUMMY_ASSOC_GROUP 0x0FFFFFFF
@@ -365,7 +366,7 @@ _PUBLIC_ NTSTATUS dcesrv_endpoint_connect(struct dcesrv_context *dce_ctx,
                                 const struct dcesrv_endpoint *ep,
                                 struct auth_session_info *session_info,
                                 struct tevent_context *event_ctx,
-                                struct messaging_context *msg_ctx,
+                                struct imessaging_context *msg_ctx,
                                 struct server_id server_id,
                                 uint32_t state_flags,
                                 struct dcesrv_connection **_p)
@@ -1234,7 +1235,7 @@ void dcerpc_server_init(struct loadparm_context *lp_ctx)
        }
        initialized = true;
 
-       shared_init = load_samba_modules(NULL, lp_ctx, "dcerpc_server");
+       shared_init = load_samba_modules(NULL, "dcerpc_server");
 
        run_init_functions(static_init);
        run_init_functions(shared_init);
@@ -1352,7 +1353,7 @@ static void dcesrv_sock_reply_done(struct tevent_req *subreq)
        ret = tstream_writev_queue_recv(subreq, &sys_errno);
        TALLOC_FREE(subreq);
        if (ret == -1) {
-               status = map_nt_error_from_unix(sys_errno);
+               status = map_nt_error_from_unix_common(sys_errno);
                dcesrv_terminate_connection(substate->dce_conn, nt_errstr(status));
                return;
        }
@@ -1435,7 +1436,7 @@ static void dcesrv_sock_accept(struct stream_connection *srv_conn)
                                                  socket_get_fd(srv_conn->socket),
                                                  &dcesrv_conn->stream);
                if (ret == -1) {
-                       status = map_nt_error_from_unix(errno);
+                       status = map_nt_error_from_unix_common(errno);
                        DEBUG(0, ("dcesrv_sock_accept: "
                                  "failed to setup tstream: %s\n",
                                  nt_errstr(status)));
@@ -1647,7 +1648,7 @@ static NTSTATUS add_socket_rpc_tcp_iface(struct dcesrv_context *dce_ctx, struct
 
        status = stream_setup_socket(dcesrv_sock, event_ctx, dce_ctx->lp_ctx,
                                     model_ops, &dcesrv_stream_ops, 
-                                    "ipv4", address, &port, 
+                                    "ip", address, &port,
                                     lpcfg_socket_options(dce_ctx->lp_ctx),
                                     dcesrv_sock);
        if (!NT_STATUS_IS_OK(status)) {
@@ -1677,18 +1678,24 @@ static NTSTATUS dcesrv_add_ep_tcp(struct dcesrv_context *dce_ctx,
                int i;
                struct interface *ifaces;
 
-               load_interfaces(dce_ctx, lpcfg_interfaces(lp_ctx), &ifaces);
+               load_interface_list(dce_ctx, lp_ctx, &ifaces);
 
-               num_interfaces = iface_count(ifaces);
+               num_interfaces = iface_list_count(ifaces);
                for(i = 0; i < num_interfaces; i++) {
-                       const char *address = iface_n_ip(ifaces, i);
+                       const char *address = iface_list_n_ip(ifaces, i);
                        status = add_socket_rpc_tcp_iface(dce_ctx, e, event_ctx, model_ops, address);
                        NT_STATUS_NOT_OK_RETURN(status);
                }
        } else {
-               status = add_socket_rpc_tcp_iface(dce_ctx, e, event_ctx, model_ops, 
-                                                 lpcfg_socket_address(lp_ctx));
-               NT_STATUS_NOT_OK_RETURN(status);
+               const char **wcard;
+               int i;
+               wcard = iface_list_wildcard(dce_ctx, lp_ctx);
+               NT_STATUS_HAVE_NO_MEMORY(wcard);
+               for (i=0; wcard[i]; i++) {
+                       status = add_socket_rpc_tcp_iface(dce_ctx, e, event_ctx, model_ops, wcard[i]);
+                       NT_STATUS_NOT_OK_RETURN(status);
+               }
+               talloc_free(wcard);
        }
 
        return NT_STATUS_OK;
@@ -1717,3 +1724,30 @@ NTSTATUS dcesrv_add_ep(struct dcesrv_context *dce_ctx,
                return NT_STATUS_NOT_SUPPORTED;
        }
 }
+
+
+/**
+ * retrieve credentials from a dce_call
+ */
+_PUBLIC_ struct cli_credentials *dcesrv_call_credentials(struct dcesrv_call_state *dce_call)
+{
+       return dce_call->conn->auth_state.session_info->credentials;
+}
+
+/**
+ * returns true if this is an authenticated call
+ */
+_PUBLIC_ bool dcesrv_call_authenticated(struct dcesrv_call_state *dce_call)
+{
+       enum security_user_level level;
+       level = security_session_user_level(dce_call->conn->auth_state.session_info, NULL);
+       return level >= SECURITY_USER;
+}
+
+/**
+ * retrieve account_name for a dce_call
+ */
+_PUBLIC_ const char *dcesrv_call_account_name(struct dcesrv_call_state *dce_call)
+{
+       return dce_call->context->conn->auth_state.session_info->info->account_name;
+}