The branch, v3-6-test has been updated
       via  73a5c6c s3-epmapper: Log error if we can't register the endpoint.
       via  f104a2e s3-epmapper: Setup epm in smbd to forward np requests. 
(cherry picked from commit b38517bbdc746fe53e0bd804623b2ea7b0e98cbc)
       via  9c1b0d4 s3-epmapper: Remove unregister on shutdown.
       via  dbcd022 s3-epmd: Cleanup endpoints on service pipe disconnect. 
(cherry picked from commit da1a18cd032760c33cf4573124c5b88507b84425)
       via  aeca46f s3-epmapper: Added function to delete endpoint entries. 
(cherry picked from commit 0d97741b9b825350e3e04b5dc49b4e039bd744dc)
       via  4b69a01 s3-rpc_server: Added disconnect callback function. (cherry 
picked from commit e69d92236744bb06d60faa4f21f3cd748ec5629d)
       via  8ddc9d8 s3-rpc_server: Rename req to subreq. (cherry picked from 
commit 044eabe425f9ae6e2fcea5ec1481b33c35b173f7)
       via  6544ce0 s3-rpc_server: Implement an endpoint monitor loop. (cherry 
picked from commit 73faa82bf9ebebdff9662e60715e9fd4f1614b9f)
       via  2344898 s3-rpc_server: Added a memory context to the ep regsiter 
state. (cherry picked from commit b2bdc20f65f0d5fda5b9fdb9dc6222e2f219bbea)
       via  e4e86e4 s3-librpc: Leave the epm registration connection open. 
(cherry picked from commit 81a2046879299a051e69fd4d78b3a8e49b690f1b)
       via  18bf416 s3-epmd: Cleanup endpoint mapper correctly. (cherry picked 
from commit d6a1469f4350fa24204e11bb9aee0e33f8d21c34)
       via  b61f076 s3-epmapper: Shutdown the embedded epmapper cleanly. 
(cherry picked from commit de775244a97b011fa34e52987a76ff81a5d36fb0)
       via  b516b1b s3-epmapper: Added a cleanup function. (cherry picked from 
commit 661ac49794a0594003463e1cf3ae1bf806f24213)
       via  ca14a20 s3-epmapper: Use DCERPC_AUTH_LEVEL_CONNECT for ep ncalrpc. 
(cherry picked from commit da718a5961c3404435f9bc64bebabb71b53455eb)
       via  4326555 s3-rpc_server: Rename system_user to ncalrpc_as_system. 
(cherry picked from commit 3766f3ec0e495277c79df8eb8918cb739bc14358)
      from  d513021 s3-prototypes: remove protos of some dead functions.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test


- Log -----------------------------------------------------------------
commit 73a5c6ce8f98f74c6c8571732eeb7c926bef8188
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Mar 21 16:14:19 2011 +0100

    s3-epmapper: Log error if we can't register the endpoint.
    
    Autobuild-User: Simo Sorce <i...@samba.org>
    Autobuild-Date: Wed Mar 23 18:06:54 CET 2011 on sn-devel-104
    (cherry picked from commit 7f1fd07fbe99fc167eb529d482b084142c39ea8a)

commit f104a2ea923755ed3e11b25b68cee7d879d085b8
Author: Andreas Schneider <a...@samba.org>
Date:   Thu Mar 17 17:56:37 2011 +0100

    s3-epmapper: Setup epm in smbd to forward np requests.
    (cherry picked from commit b38517bbdc746fe53e0bd804623b2ea7b0e98cbc)

commit 9c1b0d4f2dae7a54ed183bb9ba4f6579c0bdf209
Author: Andreas Schneider <a...@samba.org>
Date:   Thu Mar 17 16:59:10 2011 +0100

    s3-epmapper: Remove unregister on shutdown.
    
    This is done automatically now.
    (cherry picked from commit 73e985fe4b1b4c3e879f4d7fe7bc2f98851aee6e)

commit dbcd0220cf5863478f2bb3a179cc045e0f3a17d5
Author: Andreas Schneider <a...@samba.org>
Date:   Thu Mar 17 11:14:12 2011 +0100

    s3-epmd: Cleanup endpoints on service pipe disconnect.
    (cherry picked from commit da1a18cd032760c33cf4573124c5b88507b84425)

commit aeca46fcc485ac810ac9daaceb0f2e3884d0821a
Author: Andreas Schneider <a...@samba.org>
Date:   Wed Mar 16 13:42:26 2011 +0100

    s3-epmapper: Added function to delete endpoint entries.
    (cherry picked from commit 0d97741b9b825350e3e04b5dc49b4e039bd744dc)

commit 4b69a01b143c097f4b30d6de625f6a34748f0cb3
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Mar 14 12:29:49 2011 +0100

    s3-rpc_server: Added disconnect callback function.
    (cherry picked from commit e69d92236744bb06d60faa4f21f3cd748ec5629d)

commit 8ddc9d8512f634333f104898c1eaa991785ffc1d
Author: Andreas Schneider <a...@samba.org>
Date:   Thu Mar 10 13:02:31 2011 +0100

    s3-rpc_server: Rename req to subreq.
    (cherry picked from commit 044eabe425f9ae6e2fcea5ec1481b33c35b173f7)

commit 6544ce0f0b80eb548771de34c6c10c1484d48924
Author: Andreas Schneider <a...@samba.org>
Date:   Thu Mar 10 10:17:51 2011 +0100

    s3-rpc_server: Implement an endpoint monitor loop.
    (cherry picked from commit 73faa82bf9ebebdff9662e60715e9fd4f1614b9f)

commit 2344898ab29a973f8073467647f8a67fcb361dba
Author: Andreas Schneider <a...@samba.org>
Date:   Wed Mar 9 10:38:00 2011 +0100

    s3-rpc_server: Added a memory context to the ep regsiter state.
    (cherry picked from commit b2bdc20f65f0d5fda5b9fdb9dc6222e2f219bbea)

commit e4e86e4308d20fb0d87ef6590332945c0959f736
Author: Andreas Schneider <a...@samba.org>
Date:   Wed Mar 9 10:17:06 2011 +0100

    s3-librpc: Leave the epm registration connection open.
    (cherry picked from commit 81a2046879299a051e69fd4d78b3a8e49b690f1b)

commit 18bf41613de4507e4371c7c636ddc291efca4ab3
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Mar 14 14:50:09 2011 +0100

    s3-epmd: Cleanup endpoint mapper correctly.
    (cherry picked from commit d6a1469f4350fa24204e11bb9aee0e33f8d21c34)

commit b61f0767a61a68da7bba38d4015797a5b00886d1
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Mar 14 17:14:19 2011 +0100

    s3-epmapper: Shutdown the embedded epmapper cleanly.
    (cherry picked from commit de775244a97b011fa34e52987a76ff81a5d36fb0)

commit b516b1b3fe114b401269ec9f25f41a99deb86ff4
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Mar 14 14:49:51 2011 +0100

    s3-epmapper: Added a cleanup function.
    (cherry picked from commit 661ac49794a0594003463e1cf3ae1bf806f24213)

commit ca14a20460da5a8b29d908d5bba57d9d2b9bc9c2
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Mar 21 09:29:14 2011 +0100

    s3-epmapper: Use DCERPC_AUTH_LEVEL_CONNECT for ep ncalrpc.
    (cherry picked from commit da718a5961c3404435f9bc64bebabb71b53455eb)

commit 432655572fa87b6f2839aa05c594dff25796cad8
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Mar 14 10:47:41 2011 +0100

    s3-rpc_server: Rename system_user to ncalrpc_as_system.
    (cherry picked from commit 3766f3ec0e495277c79df8eb8918cb739bc14358)

-----------------------------------------------------------------------

Summary of changes:
 source3/include/ntdomain.h                         |    5 +-
 source3/librpc/rpc/dcerpc_ep.c                     |   50 ++-
 source3/librpc/rpc/dcerpc_ep.h                     |   18 +-
 source3/rpc_client/cli_pipe.c                      |    2 +-
 source3/rpc_server/epmapper/srv_epmapper.c         |   65 +++
 .../rpc_server/epmapper/srv_epmapper.h             |   27 +-
 source3/rpc_server/epmd.c                          |   19 +-
 source3/rpc_server/rpc_ep_setup.c                  |  549 ++++++++------------
 source3/rpc_server/rpc_server.c                    |   30 +-
 source3/rpc_server/rpc_server.h                    |    5 +-
 source3/rpc_server/srv_pipe.c                      |    5 +-
 11 files changed, 386 insertions(+), 389 deletions(-)
 copy lib/replace/socket.c => source3/rpc_server/epmapper/srv_epmapper.h (64%)


Changeset truncated at 500 lines:

diff --git a/source3/include/ntdomain.h b/source3/include/ntdomain.h
index ac06b25..8fb1248 100644
--- a/source3/include/ntdomain.h
+++ b/source3/include/ntdomain.h
@@ -109,6 +109,8 @@ struct pipe_auth_data {
        DATA_BLOB user_session_key;
 };
 
+struct dcesrv_ep_entry_list;
+
 /*
  * DCE/RPC-specific samba-internal-specific handling of data on
  * NamedPipes.
@@ -126,6 +128,7 @@ struct pipes_struct {
        struct messaging_context *msg_ctx;
 
        struct ndr_syntax_id syntax;
+       struct dcesrv_ep_entry_list *ep_entries;
 
        /* linked list of rpc dispatch tables associated 
           with the open rpc contexts */
@@ -134,7 +137,7 @@ struct pipes_struct {
 
        struct pipe_auth_data auth;
 
-       bool system_user;
+       bool ncalrpc_as_system;
 
        /*
         * Set to true when an RPC bind has been done on this pipe.
diff --git a/source3/librpc/rpc/dcerpc_ep.c b/source3/librpc/rpc/dcerpc_ep.c
index 764dc17..1fce63a 100644
--- a/source3/librpc/rpc/dcerpc_ep.c
+++ b/source3/librpc/rpc/dcerpc_ep.c
@@ -130,12 +130,14 @@ done:
        return status;
 }
 
-static NTSTATUS ep_register(const struct ndr_interface_table *iface,
+static NTSTATUS ep_register(TALLOC_CTX *mem_ctx,
+                           const struct ndr_interface_table *iface,
                            const struct dcerpc_binding_vector *bind_vec,
                            const struct GUID *object_guid,
                            const char *annotation,
                            uint32_t replace,
-                           uint32_t unregister)
+                           uint32_t unregister,
+                           struct dcerpc_binding_handle **pbh)
 {
        struct rpc_pipe_client *cli = NULL;
        struct dcerpc_binding_handle *h;
@@ -285,33 +287,63 @@ static NTSTATUS ep_register(const struct 
ndr_interface_table *iface,
                goto done;
        }
 
+       if (pbh != NULL) {
+               *pbh = talloc_move(mem_ctx, &h);
+               talloc_steal(*pbh, cli);
+       }
+
 done:
        talloc_free(tmp_ctx);
 
        return status;
 }
 
-NTSTATUS dcerpc_ep_register(const struct ndr_interface_table *iface,
+NTSTATUS dcerpc_ep_register(TALLOC_CTX *mem_ctx,
+                           const struct ndr_interface_table *iface,
                            const struct dcerpc_binding_vector *bind_vec,
                            const struct GUID *object_guid,
-                           const char *annotation)
+                           const char *annotation,
+                           struct dcerpc_binding_handle **ph)
 {
-       return ep_register(iface, bind_vec, object_guid, annotation, 1, 0);
+       return ep_register(mem_ctx,
+                          iface,
+                          bind_vec,
+                          object_guid,
+                          annotation,
+                          1,
+                          0,
+                          ph);
 }
 
-NTSTATUS dcerpc_ep_register_noreplace(const struct ndr_interface_table *iface,
+NTSTATUS dcerpc_ep_register_noreplace(TALLOC_CTX *mem_ctx,
+                                     const struct ndr_interface_table *iface,
                                      const struct dcerpc_binding_vector 
*bind_vec,
                                      const struct GUID *object_guid,
-                                     const char *annotation)
+                                     const char *annotation,
+                                     struct dcerpc_binding_handle **ph)
 {
-       return ep_register(iface, bind_vec, object_guid, annotation, 0, 0);
+       return ep_register(mem_ctx,
+                          iface,
+                          bind_vec,
+                          object_guid,
+                          annotation,
+                          0,
+                          0,
+                          ph);
 }
 
 NTSTATUS dcerpc_ep_unregister(const struct ndr_interface_table *iface,
                              const struct dcerpc_binding_vector *bind_vec,
                              const struct GUID *object_guid)
 {
-       return ep_register(iface, bind_vec, object_guid, NULL, 0, 1);
+       return ep_register(NULL,
+                          iface,
+                          bind_vec,
+                          object_guid,
+                          NULL,
+                          0,
+                          1,
+                          NULL);
 }
 
 /* vim: set ts=8 sw=8 noet cindent syntax=c.doxygen: */
diff --git a/source3/librpc/rpc/dcerpc_ep.h b/source3/librpc/rpc/dcerpc_ep.h
index 99682be..57b1d27 100644
--- a/source3/librpc/rpc/dcerpc_ep.h
+++ b/source3/librpc/rpc/dcerpc_ep.h
@@ -34,6 +34,8 @@ NTSTATUS dcerpc_binding_vector_create(TALLOC_CTX *mem_ctx,
 /**
  * @brief Adds server address information in the local endpoint map.
  *
+ * @param[in]  mem_ctx  The memory context to use for the binding handle.
+ *
  * @param[in]  iface    The interface specification to register with the local
  *                      endpoint map.
  *
@@ -55,17 +57,25 @@ NTSTATUS dcerpc_binding_vector_create(TALLOC_CTX *mem_ctx,
  *                         supplied, including an empty annotation string,
  *                         replaces any existing annotation string.
  *
+ * @param[out] ph          A pointer to store the binding handle. The memory
+ *                         context will be the give one. If you free this 
handle
+ *                         then the connection will be closed.
+ *
  * @return                 An NTSTATUS error code.
  */
-NTSTATUS dcerpc_ep_register(const struct ndr_interface_table *iface,
+NTSTATUS dcerpc_ep_register(TALLOC_CTX *mem_ctx,
+                           const struct ndr_interface_table *iface,
                            const struct dcerpc_binding_vector *bind_vec,
                            const struct GUID *object_guid,
-                           const char *annotation);
+                           const char *annotation,
+                           struct dcerpc_binding_handle **ph);
 
-NTSTATUS dcerpc_ep_register_noreplace(const struct ndr_interface_table *iface,
+NTSTATUS dcerpc_ep_register_noreplace(TALLOC_CTX *mem_ctx,
+                                     const struct ndr_interface_table *iface,
                                      const struct dcerpc_binding_vector 
*bind_vec,
                                      const struct GUID *object_guid,
-                                     const char *annotation);
+                                     const char *annotation,
+                                     struct dcerpc_binding_handle **ph);
 
 NTSTATUS dcerpc_ep_unregister(const struct ndr_interface_table *iface,
                              const struct dcerpc_binding_vector *bind_vec,
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index ebbe849..a92d10b 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -2262,7 +2262,7 @@ NTSTATUS rpccli_ncalrpc_bind_data(TALLOC_CTX *mem_ctx,
        }
 
        result->auth_type = DCERPC_AUTH_TYPE_NCALRPC_AS_SYSTEM;
-       result->auth_level = DCERPC_AUTH_LEVEL_NONE;
+       result->auth_level = DCERPC_AUTH_LEVEL_CONNECT;
 
        result->user_name = talloc_strdup(result, "");
        result->domain = talloc_strdup(result, "");
diff --git a/source3/rpc_server/epmapper/srv_epmapper.c 
b/source3/rpc_server/epmapper/srv_epmapper.c
index f0bd9c6..da998eb 100644
--- a/source3/rpc_server/epmapper/srv_epmapper.c
+++ b/source3/rpc_server/epmapper/srv_epmapper.c
@@ -23,6 +23,7 @@
 #include "../libcli/security/security.h"
 #include "librpc/gen_ndr/ndr_epmapper.h"
 #include "librpc/gen_ndr/srv_epmapper.h"
+#include "srv_epmapper.h"
 
 typedef uint32_t error_status_t;
 
@@ -58,6 +59,13 @@ struct dcesrv_endpoint {
        struct dcesrv_iface_list *iface_list;
 };
 
+struct dcesrv_ep_entry_list {
+       struct dcesrv_ep_entry_list *next, *prev;
+
+       uint32_t num_ents;
+       struct epm_entry_t *entries;
+};
+
 struct rpc_eps {
        struct dcesrv_ep_iface *e;
        uint32_t count;
@@ -219,6 +227,49 @@ static bool is_priviledged_pipe(struct 
auth_serversupplied_info *info) {
        return true;
 }
 
+bool srv_epmapper_delete_endpoints(struct pipes_struct *p)
+{
+       struct epm_Delete r;
+       struct dcesrv_ep_entry_list *el;
+       error_status_t result;
+
+       if (p->ep_entries == NULL) {
+               return true;
+       }
+
+       for (el = p->ep_entries;
+            el != NULL;
+            el = p->ep_entries) {
+               r.in.num_ents = el->num_ents;
+               r.in.entries = el->entries;
+
+               DEBUG(10, ("Delete_endpoints for: %s\n",
+                          el->entries[0].annotation));
+
+               result = _epm_Delete(p, &r);
+               if (result != EPMAPPER_STATUS_OK) {
+                       return false;
+               }
+
+               DLIST_REMOVE(p->ep_entries, el);
+               TALLOC_FREE(el);
+       }
+
+       return true;
+}
+
+void srv_epmapper_cleanup(void)
+{
+       struct dcesrv_endpoint *ep;
+
+       for (ep = endpoint_table;
+            ep != NULL;
+            ep = endpoint_table) {
+               DLIST_REMOVE(endpoint_table, ep);
+               TALLOC_FREE(ep);
+       }
+}
+
 /*
  * epm_Insert
  *
@@ -325,6 +376,20 @@ error_status_t _epm_Insert(struct pipes_struct *p,
                }
        }
 
+       if (r->in.num_ents > 0) {
+               struct dcesrv_ep_entry_list *el;
+
+               el = talloc_zero(p->mem_ctx, struct dcesrv_ep_entry_list);
+               if (el == NULL) {
+                       rc = EPMAPPER_STATUS_NO_MEMORY;
+                       goto done;
+               }
+               el->num_ents = r->in.num_ents;
+               el->entries = talloc_move(el, &r->in.entries);
+
+               DLIST_ADD(p->ep_entries, el);
+       }
+
        rc = EPMAPPER_STATUS_OK;
 done:
        talloc_free(tmp_ctx);
diff --git a/lib/replace/socket.c b/source3/rpc_server/epmapper/srv_epmapper.h
similarity index 64%
copy from lib/replace/socket.c
copy to source3/rpc_server/epmapper/srv_epmapper.h
index 35e975f..1abc583 100644
--- a/lib/replace/socket.c
+++ b/source3/rpc_server/epmapper/srv_epmapper.h
@@ -1,9 +1,9 @@
 /*
  * Unix SMB/CIFS implementation.
  *
- * Dummy replacements for socket functions.
+ * Endpoint server for the epmapper pipe
  *
- * Copyright (C) Michael Adam <ob...@samba.org> 2008
+ * Copyright (C) 2010-2011 Andreas Schneider <a...@samba.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -19,17 +19,16 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "replace.h"
-#include "system/network.h"
+#ifndef _SRV_EPMAPPER_H_
+#define _SRV_EPMAPPER_H_
 
-int rep_connect(int sockfd, const struct sockaddr *serv_addr, socklen_t 
addrlen)
-{
-       errno = ENOSYS;
-       return -1;
-}
+/**
+ * @brief Cleanup memory and other stuff.
+ */
+void srv_epmapper_cleanup(void);
+
+bool srv_epmapper_delete_endpoints(struct pipes_struct *p);
+
+#endif /*_SRV_EPMAPPER_H_ */
 
-struct hostent *rep_gethostbyname(const char *name)
-{
-       errno = ENOSYS;
-       return NULL;
-}
+/* vim: set ts=8 sw=8 noet cindent syntax=c.doxygen: */
diff --git a/source3/rpc_server/epmd.c b/source3/rpc_server/epmd.c
index 159c04c..0cafccb 100644
--- a/source3/rpc_server/epmd.c
+++ b/source3/rpc_server/epmd.c
@@ -25,6 +25,7 @@
 #include "../librpc/gen_ndr/messaging.h"
 #include "../librpc/gen_ndr/srv_epmapper.h"
 #include "rpc_server/rpc_server.h"
+#include "rpc_server/epmapper/srv_epmapper.h"
 
 #define DAEMON_NAME "epmd"
 
@@ -141,6 +142,8 @@ static void epmd_sig_term_handler(struct tevent_context *ev,
                                  void *siginfo,
                                  void *private_data)
 {
+       rpc_epmapper_shutdown();
+
        exit_server_cleanly("termination signal");
 }
 
@@ -186,14 +189,25 @@ static void epmd_setup_sig_hup_handler(struct 
tevent_context *ev_ctx,
        }
 }
 
+static bool epmapper_shutdown_cb(void *ptr) {
+       srv_epmapper_cleanup();
+
+       return true;
+}
+
 void start_epmd(struct tevent_context *ev_ctx,
                struct messaging_context *msg_ctx)
 {
+       struct rpc_srv_callbacks epmapper_cb;
        NTSTATUS status;
        pid_t pid;
        bool ok;
        int rc;
 
+       epmapper_cb.init = NULL;
+       epmapper_cb.shutdown = epmapper_shutdown_cb;
+       epmapper_cb.private_data = NULL;
+
        DEBUG(1, ("Forking Endpoint Mapper Daemon\n"));
 
        pid = sys_fork();
@@ -239,7 +253,7 @@ void start_epmd(struct tevent_context *ev_ctx,
                           MSG_SMB_CONF_UPDATED,
                           epmd_smb_conf_updated);
 
-       status = rpc_epmapper_init(NULL);
+       status = rpc_epmapper_init(&epmapper_cb);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("Failed to register epmd rpc inteface! (%s)\n",
                          nt_errstr(status)));
@@ -249,7 +263,8 @@ void start_epmd(struct tevent_context *ev_ctx,
        ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
                                         msg_ctx,
                                         ndr_table_epmapper.syntax_id,
-                                        "EPMAPPER");
+                                        "EPMAPPER",
+                                        srv_epmapper_delete_endpoints);
        if (!ok) {
                DEBUG(0, ("Failed to open epmd ncalrpc pipe!\n"));
                exit(1);
diff --git a/source3/rpc_server/rpc_ep_setup.c 
b/source3/rpc_server/rpc_ep_setup.c
index 3731915..9bed63d 100644
--- a/source3/rpc_server/rpc_ep_setup.c
+++ b/source3/rpc_server/rpc_ep_setup.c
@@ -21,6 +21,7 @@
 
 #include "includes.h"
 
+#include "../librpc/gen_ndr/ndr_epmapper_c.h"
 #include "../librpc/gen_ndr/srv_epmapper.h"
 #include "../librpc/gen_ndr/srv_srvsvc.h"
 #include "../librpc/gen_ndr/srv_winreg.h"
@@ -45,6 +46,7 @@
 
 #include "rpc_server/rpc_ep_setup.h"
 #include "rpc_server/rpc_server.h"
+#include "rpc_server/epmapper/srv_epmapper.h"
 
 struct dcesrv_ep_context {
        struct tevent_context *ev_ctx;
@@ -123,40 +125,19 @@ static uint16_t _open_sockets(struct tevent_context 
*ev_ctx,
        return p;
 }
 
-static NTSTATUS _rpc_ep_unregister(const struct ndr_interface_table *iface)
-{
-       struct dcerpc_binding_vector *v = NULL;
-       NTSTATUS status;
-
-       status = dcerpc_binding_vector_create(talloc_tos(),
-                                             iface,
-                                             0,
-                                             NULL,
-                                             &v);
-       if (!NT_STATUS_IS_OK(status)) {
-               return status;
-       }
-
-       status = dcerpc_ep_unregister(iface,
-                                     v,
-                                     &iface->syntax_id.uuid);
-       if (!NT_STATUS_IS_OK(status)) {
-               return status;
-       }
-
-       return status;
-}
-
 static void rpc_ep_setup_register_loop(struct tevent_req *subreq);
-static NTSTATUS rpc_ep_setup_try_register(struct tevent_context *ev_ctx,
+static NTSTATUS rpc_ep_setup_try_register(TALLOC_CTX *mem_ctx,
+                                         struct tevent_context *ev_ctx,
                                          struct messaging_context *msg_ctx,
                                          const struct ndr_interface_table 
*iface,
                                          const char *name,
-                                         uint16_t port);
+                                         uint16_t port,
+                                         struct dcerpc_binding_handle **pbh);
 
 struct rpc_ep_regsiter_state {
-       uint32_t wait_time;
+       struct dcerpc_binding_handle *h;
 
+       TALLOC_CTX *mem_ctx;
        struct tevent_context *ev_ctx;
        struct messaging_context *msg_ctx;
 
@@ -164,6 +145,8 @@ struct rpc_ep_regsiter_state {
 
        const char *ncalrpc;
        uint16_t port;
+
+       uint32_t wait_time;
 };
 
 static NTSTATUS rpc_ep_setup_register(struct tevent_context *ev_ctx,
@@ -180,6 +163,15 @@ static NTSTATUS rpc_ep_setup_register(struct 
tevent_context *ev_ctx,
                return NT_STATUS_NO_MEMORY;
        }
 
+       state->mem_ctx = talloc_named(state,
+                                     0,
+                                     "ep %s %p",
+                                     iface->name, state);
+       if (state->mem_ctx == NULL) {
+               talloc_free(state);
+               return NT_STATUS_NO_MEMORY;
+       }
+
        state->wait_time = 1;
        state->ev_ctx = ev_ctx;
        state->msg_ctx = msg_ctx;
@@ -187,8 +179,10 @@ static NTSTATUS rpc_ep_setup_register(struct 
tevent_context *ev_ctx,
        state->ncalrpc = talloc_strdup(state, ncalrpc);
        state->port = port;
 
-       req = tevent_wakeup_send(state, ev_ctx, timeval_current_ofs(1, 0));
-       if (tevent_req_nomem(state, req)) {
+       req = tevent_wakeup_send(state->mem_ctx,
+                                state->ev_ctx,
+                                timeval_current_ofs(1, 0));
+       if (tevent_req_nomem(state->mem_ctx, req)) {
                talloc_free(state);
                return NT_STATUS_NO_MEMORY;
        }
@@ -198,57 +192,75 @@ static NTSTATUS rpc_ep_setup_register(struct 
tevent_context *ev_ctx,
        return NT_STATUS_OK;
 }
 
-static void rpc_ep_setup_register_loop(struct tevent_req *req)
+#define MONITOR_WAIT_TIME 15


-- 
Samba Shared Repository

Reply via email to