pid_t our_pid; /* calling process pid */
};
-static struct winbindd_context wb_global_ctx = {
- .winbindd_fd = -1,
- .is_privileged = false,
- .our_pid = 0
-};
+static struct winbindd_context *get_wb_global_ctx(void)
+{
+ static struct winbindd_context wb_global_ctx = {
+ .winbindd_fd = -1,
+ .is_privileged = false,
+ .our_pid = 0
+ };
+
+ return &wb_global_ctx;
+}
+
+static void put_wb_global_ctx(void)
+{
+ /* noop for now */
+ return;
+}
/* Free a response structure */
#endif
static void winbind_destructor(void)
{
- winbind_close_sock(&wb_global_ctx);
+ struct winbindd_context *ctx;
+
+ ctx = get_wb_global_ctx();
+ winbind_close_sock(ctx);
+ put_wb_global_ctx();
}
#define CONNECT_TIMEOUT 30
struct winbindd_response *response)
{
NSS_STATUS status = NSS_STATUS_UNAVAIL;
+ bool release_global_ctx = false;
if (ctx == NULL) {
- ctx = &wb_global_ctx;
+ ctx = get_wb_global_ctx();
+ release_global_ctx = true;
}
status = winbindd_send_request(ctx, req_type, 0, request);
status = winbindd_get_response(ctx, response);
out:
+ if (release_global_ctx) {
+ put_wb_global_ctx();
+ }
return status;
}
struct winbindd_response *response)
{
NSS_STATUS status = NSS_STATUS_UNAVAIL;
+ bool release_global_ctx = false;
if (ctx == NULL) {
- ctx = &wb_global_ctx;
+ ctx = get_wb_global_ctx();
+ release_global_ctx = true;
}
status = winbindd_send_request(ctx, req_type, 1, request);
status = winbindd_get_response(ctx, response);
out:
+ if (release_global_ctx) {
+ put_wb_global_ctx();
+ }
return status;
}