smbd: pass tevent context to create_conn_struct_as_root()
authorRalph Boehme <slow@samba.org>
Tue, 15 Jun 2021 09:17:57 +0000 (11:17 +0200)
committerKarolin Seeger <kseeger@samba.org>
Mon, 12 Jul 2021 12:55:43 +0000 (12:55 +0000)
The next commit will add another caller of create_conn_struct_as_root() that is
going to pass a long-lived tevent context.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14740

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 16c39b81d6f2c7d75cfe72bbbe2f6a5bde42c7b0)

source3/smbd/msdfs.c

index dc07727f007b52fe415f5916fd4e51d083fa055e..f07cf75775b3f8eb895c6cf782bc778063d41da9 100644 (file)
@@ -242,6 +242,7 @@ static NTSTATUS parse_dfs_path(connection_struct *conn,
 *********************************************************/
 
 static NTSTATUS create_conn_struct_as_root(TALLOC_CTX *ctx,
+                           struct tevent_context *ev,
                            struct messaging_context *msg,
                            connection_struct **pconn,
                            int snum,
@@ -260,12 +261,7 @@ static NTSTATUS create_conn_struct_as_root(TALLOC_CTX *ctx,
                return NT_STATUS_NO_MEMORY;
        }
 
-       sconn->ev_ctx = samba_tevent_context_init(sconn);
-       if (sconn->ev_ctx == NULL) {
-               TALLOC_FREE(sconn);
-               return NT_STATUS_NO_MEMORY;
-       }
-
+       sconn->ev_ctx = ev;
        sconn->msg_ctx = msg;
 
        conn = conn_new(sconn);
@@ -401,6 +397,7 @@ NTSTATUS create_conn_struct_tos(struct messaging_context *msg,
                                struct conn_struct_tos **_c)
 {
        struct conn_struct_tos *c = NULL;
+       struct tevent_context *ev = NULL;
        NTSTATUS status;
 
        *_c = NULL;
@@ -410,8 +407,15 @@ NTSTATUS create_conn_struct_tos(struct messaging_context *msg,
                return NT_STATUS_NO_MEMORY;
        }
 
+       ev = samba_tevent_context_init(c);
+       if (ev == NULL) {
+               TALLOC_FREE(c);
+               return NT_STATUS_NO_MEMORY;
+       }
+
        become_root();
        status = create_conn_struct_as_root(c,
+                                           ev,
                                            msg,
                                            &c->conn,
                                            snum,