s3:winbindd_samr Do not use static contexts
authorSimo Sorce <idra@samba.org>
Thu, 8 Jul 2010 03:43:47 +0000 (23:43 -0400)
committerSimo Sorce <idra@samba.org>
Thu, 8 Jul 2010 03:45:50 +0000 (23:45 -0400)
It is a very bad idea to use a static context within the open function.
Use the memory hierarchy to keep track of a client connection.

source3/winbindd/winbindd_samr.c

index f8004d976f5b11065ea287f465226d58058fb4ec..a2865a0bca8d9f08dbde73c44f0ca25802998033 100644 (file)
@@ -40,7 +40,7 @@
 static NTSTATUS open_internal_samr_pipe(TALLOC_CTX *mem_ctx,
                                        struct rpc_pipe_client **samr_pipe)
 {
-       static struct rpc_pipe_client *cli = NULL;
+       struct rpc_pipe_client *cli = NULL;
        struct auth_serversupplied_info *server_info = NULL;
        NTSTATUS status;
 
@@ -58,7 +58,7 @@ static NTSTATUS open_internal_samr_pipe(TALLOC_CTX *mem_ctx,
        }
 
        /* create a samr connection */
-       status = rpc_pipe_open_internal(talloc_autofree_context(),
+       status = rpc_pipe_open_internal(mem_ctx,
                                        &ndr_table_samr.syntax_id,
                                        rpc_samr_dispatch,
                                        server_info,
@@ -112,7 +112,7 @@ NTSTATUS open_internal_samr_conn(TALLOC_CTX *mem_ctx,
 static NTSTATUS open_internal_lsa_pipe(TALLOC_CTX *mem_ctx,
                                       struct rpc_pipe_client **lsa_pipe)
 {
-       static struct rpc_pipe_client *cli = NULL;
+       struct rpc_pipe_client *cli = NULL;
        struct auth_serversupplied_info *server_info = NULL;
        NTSTATUS status;
 
@@ -130,7 +130,7 @@ static NTSTATUS open_internal_lsa_pipe(TALLOC_CTX *mem_ctx,
        }
 
        /* create a samr connection */
-       status = rpc_pipe_open_internal(talloc_autofree_context(),
+       status = rpc_pipe_open_internal(mem_ctx,
                                        &ndr_table_lsarpc.syntax_id,
                                        rpc_lsarpc_dispatch,
                                        server_info,