]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:rpc_server: Initialize global dcesrv_context for embedded services
authorSamuel Cabrero <scabrero@suse.de>
Tue, 26 Feb 2019 12:58:43 +0000 (13:58 +0100)
committerSamuel Cabrero <scabrero@sn-devel-184>
Fri, 20 Mar 2020 15:36:32 +0000 (15:36 +0000)
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/rpc_server/rpc_service_setup.c
source3/rpc_server/rpc_service_setup.h
source3/smbd/globals.h
source3/smbd/process.c
source3/smbd/proto.h
source3/smbd/server.c
source3/smbd/server_exit.c

index 0c8ee6bcf78d082b95bca20a3cd4f13fdfed2582..c2175c4a99d2536199c000264ce45144e04eab6e 100644 (file)
@@ -776,8 +776,10 @@ static NTSTATUS rpc_setup_initshutdown(struct tevent_context *ev_ctx,
        return NT_STATUS_OK;
 }
 
-NTSTATUS dcesrv_ep_setup(struct tevent_context *ev_ctx,
-                        struct messaging_context *msg_ctx)
+NTSTATUS dcesrv_init(TALLOC_CTX *mem_ctx,
+                    struct tevent_context *ev_ctx,
+                    struct messaging_context *msg_ctx,
+                    struct dcesrv_context *dce_ctx)
 {
        TALLOC_CTX *tmp_ctx;
        bool ok;
@@ -897,6 +899,8 @@ NTSTATUS dcesrv_ep_setup(struct tevent_context *ev_ctx,
                goto done;
        }
 
+       /* TODO Initialize endpoints for registered endpoint servers */
+
        status = NT_STATUS_OK;
 done:
        talloc_free(tmp_ctx);
index d7bc4be4167b9b354d15fceecca22c9a5d68d935..197eca918934086ed4bc84d23584bbdc151b3a4c 100644 (file)
 
 struct ndr_interface_table;
 struct rpc_srv_callbacks;
+struct dcesrv_context;
 
-NTSTATUS dcesrv_ep_setup(struct tevent_context *ev_ctx,
-                        struct messaging_context *msg_ctx);
+NTSTATUS dcesrv_init(TALLOC_CTX *mem_ctx,
+                    struct tevent_context *ev_ctx,
+                    struct messaging_context *msg_ctx,
+                    struct dcesrv_context *dce_ctx);
 
 NTSTATUS rpc_setup_embedded(struct tevent_context *ev_ctx,
                            struct messaging_context *msg_ctx,
index 7b26d04ed0f192d85e7c6112bec84a9b6741606f..cbd66e99ac82f245a6ea8737bccc85d9f46c0c86 100644 (file)
@@ -845,6 +845,7 @@ struct pending_message_list;
 struct pending_auth_data;
 
 struct pthreadpool_tevent;
+struct dcesrv_context;
 
 struct smbd_server_connection {
        const struct tsocket_address *local_address;
@@ -852,6 +853,7 @@ struct smbd_server_connection {
        const char *remote_hostname;
        struct tevent_context *ev_ctx;
        struct messaging_context *msg_ctx;
+       struct dcesrv_context *dce_ctx;
        struct notify_context *notify_ctx;
        bool using_smb2;
        int trans_num;
index 70398b4967e329512646380a07abdff3d453b449..8ffe35556375e219b7e300d9f08d087f905147c0 100644 (file)
@@ -3928,6 +3928,7 @@ NTSTATUS smbd_add_connection(struct smbXsrv_client *client, int sock_fd,
 
 void smbd_process(struct tevent_context *ev_ctx,
                  struct messaging_context *msg_ctx,
+                 struct dcesrv_context *dce_ctx,
                  int sock_fd,
                  bool interactive)
 {
@@ -3970,6 +3971,7 @@ void smbd_process(struct tevent_context *ev_ctx,
 
        sconn->ev_ctx = ev_ctx;
        sconn->msg_ctx = msg_ctx;
+       sconn->dce_ctx = dce_ctx;
 
        ret = pthreadpool_tevent_init(sconn, lp_aio_max_threads(),
                                      &sconn->pool);
index 0f773c06225ae49148aa59eda43bee5ffeaa4672..24d43e455bf3721108a46a1553efdf5a82f1c4f6 100644 (file)
@@ -49,6 +49,7 @@
 /* The following definitions come from smbd/signing.c  */
 
 struct smbXsrv_connection;
+struct dcesrv_context;
 
 bool srv_check_sign_mac(struct smbXsrv_connection *conn,
                        const char *inbuf, uint32_t *seqnum, bool trusted_channel);
@@ -883,6 +884,7 @@ bool smb1_parse_chain(TALLOC_CTX *mem_ctx, const uint8_t *buf,
 bool req_is_in_chain(const struct smb_request *req);
 void smbd_process(struct tevent_context *ev_ctx,
                  struct messaging_context *msg_ctx,
+                 struct dcesrv_context *dce_ctx,
                  int sock_fd,
                  bool interactive);
 bool fork_echo_handler(struct smbXsrv_connection *xconn);
index caa28e0a772d908c17c0f6908cd4d856257cbf4e..0ddc9bbd438a70c0a75b67f103c9fea741b31ee2 100644 (file)
@@ -70,6 +70,7 @@ struct smbd_parent_context {
 
        struct tevent_context *ev_ctx;
        struct messaging_context *msg_ctx;
+       struct dcesrv_context *dce_ctx;
 
        /* the list of listening sockets */
        struct smbd_open_socket *sockets;
@@ -942,6 +943,7 @@ static void smbd_accept_connection(struct tevent_context *ev,
        struct smbd_open_socket *s = talloc_get_type_abort(private_data,
                                     struct smbd_open_socket);
        struct messaging_context *msg_ctx = s->parent->msg_ctx;
+       struct dcesrv_context *dce_ctx = s->parent->dce_ctx;
        struct sockaddr_storage addr;
        socklen_t in_addrlen = sizeof(addr);
        int fd;
@@ -960,7 +962,7 @@ static void smbd_accept_connection(struct tevent_context *ev,
 
        if (s->parent->interactive) {
                reinit_after_fork(msg_ctx, ev, true, NULL);
-               smbd_process(ev, msg_ctx, fd, true);
+               smbd_process(ev, msg_ctx, dce_ctx, fd, true);
                exit_server_cleanly("end of interactive mode");
                return;
        }
@@ -1009,7 +1011,7 @@ static void smbd_accept_connection(struct tevent_context *ev,
                        smb_panic("reinit_after_fork() failed");
                }
 
-               smbd_process(ev, msg_ctx, fd, false);
+               smbd_process(ev, msg_ctx, dce_ctx, fd, false);
         exit:
                exit_server_cleanly("end of child");
                return;
@@ -1627,6 +1629,7 @@ extern void build_options(bool screen);
        NTSTATUS status;
        struct tevent_context *ev_ctx;
        struct messaging_context *msg_ctx;
+       struct dcesrv_context *dce_ctx = NULL;
        struct server_id server_id;
        struct tevent_signal *se;
        int profiling_level;
@@ -1830,6 +1833,11 @@ extern void build_options(bool screen);
                exit(1);
        }
 
+       dce_ctx = global_dcesrv_context();
+       if (dce_ctx == NULL) {
+               exit(1);
+       }
+
        /*
         * Reloading of the printers will not work here as we don't have a
         * server info and rpc services set up. It will be called later.
@@ -1925,6 +1933,7 @@ extern void build_options(bool screen);
        parent->interactive = interactive;
        parent->ev_ctx = ev_ctx;
        parent->msg_ctx = msg_ctx;
+       parent->dce_ctx = dce_ctx;
        am_parent = parent;
 
        se = tevent_add_signal(parent->ev_ctx,
@@ -2087,7 +2096,7 @@ extern void build_options(bool screen);
                }
        }
 
-       status = dcesrv_ep_setup(ev_ctx, msg_ctx);
+       status = dcesrv_init(ev_ctx, ev_ctx, msg_ctx, dce_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                DBG_ERR("Failed to setup RPC server: %s\n", nt_errstr(status));
                exit_daemon("Samba cannot setup ep pipe", EACCES);
@@ -2153,7 +2162,7 @@ extern void build_options(bool screen);
                /* Stop zombies */
                smbd_setup_sig_chld_handler(parent);
 
-               smbd_process(ev_ctx, msg_ctx, sock, true);
+               smbd_process(ev_ctx, msg_ctx, dce_ctx, sock, true);
 
                exit_server_cleanly(NULL);
                return(0);
index d51b73d5131db2aeca746a1057f5509a3699f904..effe818a14d1a64d092f1ac1f3b3838a9f3e1d6d 100644 (file)
@@ -51,6 +51,7 @@
 #include "smbprofile.h"
 #include "libcli/auth/netlogon_creds_cli.h"
 #include "lib/gencache.h"
+#include "rpc_server/rpc_config.h"
 
 static struct files_struct *log_writeable_file_fn(
        struct files_struct *fsp, void *private_data)
@@ -217,6 +218,8 @@ static void exit_server_common(enum server_exit_reason how,
                rpc_FileServerVssAgent_shutdown();
 
                rpc_epmapper_shutdown();
+
+               global_dcesrv_context_free();
        }
 
        /*