winbindd: winbindd_ccache_ntlm_auth() -> bool_dispatch_table
[samba.git] / nsswitch / wb_common.c
index 139f0106669cc499d7d09cc6b3ef1c24256b5d02..6768fde535b052210d897e8b74a46fb6e2a0ba86 100644 (file)
@@ -88,7 +88,7 @@ static void winbind_close_sock(struct winbindd_context *ctx)
 
 /* Destructor for global context to ensure fd is closed */
 
-#if HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR
+#if HAVE_DESTRUCTOR_ATTRIBUTE
 __attribute__((destructor))
 #endif
 static void winbind_destructor(void)
@@ -195,7 +195,7 @@ static int make_safe_fd(int fd)
  * @brief Check if we talk to the priviliged pipe which should be owned by root.
  *
  * This checks if we have uid_wrapper running and if this is the case it will
- * allow to connect to the winbind privileged pipe even it is not owned by root.
+ * allow one to connect to the winbind privileged pipe even it is not owned by root.
  *
  * @param[in]  uid      The uid to check if we can safely talk to the pipe.
  *
@@ -401,6 +401,10 @@ static int winbind_open_pipe_sock(struct winbindd_context *ctx,
                return -1;
        }
 
+       if (need_priv == 0) {
+               return ctx->winbindd_fd;
+       }
+
        /* try and get priv pipe */
 
        request.wb_flags = WBFLAG_RECURSE;
@@ -420,14 +424,14 @@ static int winbind_open_pipe_sock(struct winbindd_context *ctx,
                        ctx->winbindd_fd = fd;
                        ctx->is_privileged = 1;
                }
+
+               SAFE_FREE(response.extra_data.data);
        }
 
-       if ((need_priv != 0) && (ctx->is_privileged == 0)) {
+       if (ctx->is_privileged == 0) {
                return -1;
        }
 
-       SAFE_FREE(response.extra_data.data);
-
        return ctx->winbindd_fd;
 #else
        return -1;
@@ -719,16 +723,15 @@ NSS_STATUS winbindd_request_response(struct winbindd_context *ctx,
                                     struct winbindd_response *response)
 {
        NSS_STATUS status = NSS_STATUS_UNAVAIL;
-       struct winbindd_context *wb_ctx = ctx;
 
        if (ctx == NULL) {
-               wb_ctx = &wb_global_ctx;
+               ctx = &wb_global_ctx;
        }
 
-       status = winbindd_send_request(wb_ctx, req_type, 0, request);
+       status = winbindd_send_request(ctx, req_type, 0, request);
        if (status != NSS_STATUS_SUCCESS)
                return (status);
-       status = winbindd_get_response(wb_ctx, response);
+       status = winbindd_get_response(ctx, response);
 
        return status;
 }
@@ -739,16 +742,15 @@ NSS_STATUS winbindd_priv_request_response(struct winbindd_context *ctx,
                                          struct winbindd_response *response)
 {
        NSS_STATUS status = NSS_STATUS_UNAVAIL;
-       struct winbindd_context *wb_ctx = ctx;
 
        if (ctx == NULL) {
-               wb_ctx = &wb_global_ctx;
+               ctx = &wb_global_ctx;
        }
 
-       status = winbindd_send_request(wb_ctx, req_type, 1, request);
+       status = winbindd_send_request(ctx, req_type, 1, request);
        if (status != NSS_STATUS_SUCCESS)
                return (status);
-       status = winbindd_get_response(wb_ctx, response);
+       status = winbindd_get_response(ctx, response);
 
        return status;
 }