libwbclient: Store the winbind socket dir to use in the wb_context
authorKai Blin <kai@samba.org>
Tue, 21 Apr 2009 07:58:42 +0000 (09:58 +0200)
committerKai Blin <kai@samba.org>
Sat, 30 May 2009 07:17:37 +0000 (09:17 +0200)
nsswitch/libwbclient/wbc_async.c
nsswitch/libwbclient/wbc_async.h
source3/torture/torture.c

index 141c9816aabfe5114146b9837ba3f866dfc775dd..6a572f4203c36ae31640e3595cada64c09a5c822 100644 (file)
@@ -88,6 +88,7 @@ struct wb_context {
        struct tevent_queue *queue;
        int fd;
        bool is_priv;
+       const char *dir;
 };
 
 static int make_nonstd_fd(int fd)
@@ -179,7 +180,10 @@ static int make_safe_fd(int fd)
        return -1;
 }
 
-struct wb_context *wb_context_init(TALLOC_CTX *mem_ctx)
+/* Just put a prototype to avoid moving the whole function around */
+static const char *winbindd_socket_dir(void);
+
+struct wb_context *wb_context_init(TALLOC_CTX *mem_ctx, const char* dir)
 {
        struct wb_context *result;
 
@@ -194,6 +198,12 @@ struct wb_context *wb_context_init(TALLOC_CTX *mem_ctx)
        }
        result->fd = -1;
        result->is_priv = false;
+
+       if (dir != NULL) {
+               result->dir = dir;
+       } else {
+               result->dir = winbindd_socket_dir();
+       }
        return result;
 }
 
@@ -351,7 +361,7 @@ static struct tevent_req *wb_open_pipe_send(TALLOC_CTX *mem_ctx,
                wb_ctx->fd = -1;
        }
 
-       subreq = wb_connect_send(state, ev, wb_ctx, winbindd_socket_dir());
+       subreq = wb_connect_send(state, ev, wb_ctx, wb_ctx->dir);
        if (subreq == NULL) {
                goto fail;
        }
index a2e0eed4480b4ff78643364d516125c9456d0416..607dd9de282dc4d1588c2c27f59fbc3f514a1be4 100644 (file)
@@ -38,7 +38,7 @@ struct tevent_req *wb_trans_send(TALLOC_CTX *mem_ctx,
                                 struct winbindd_request *wb_req);
 wbcErr wb_trans_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
                     struct winbindd_response **presponse);
-struct wb_context *wb_context_init(TALLOC_CTX *mem_ctx);
+struct wb_context *wb_context_init(TALLOC_CTX *mem_ctx, const char* dir);
 
 /* Definitions from wb_reqtrans.c */
 wbcErr map_wbc_err_from_errno(int error);
index 30e7e8cbc53ca8fe4e915a188b854b84706980b8..d185a71727539d1c2a4392aa87d17735b7e04924 100644 (file)
@@ -5985,7 +5985,7 @@ static bool run_local_wbclient(int dummy)
        d_printf("nprocs=%d, numops=%d\n", (int)nprocs, (int)torture_numops);
 
        for (i=0; i<nprocs; i++) {
-               wb_ctx[i] = wb_context_init(ev);
+               wb_ctx[i] = wb_context_init(ev, NULL);
                if (wb_ctx[i] == NULL) {
                        goto fail;
                }