summaryrefslogtreecommitdiff
path: root/nsswitch
diff options
context:
space:
mode:
authorMatthew Newton <matthew-git@newtoncomputing.co.uk>2015-02-21 00:19:32 +0000
committerJeremy Allison <jra@samba.org>2015-03-10 00:50:10 +0100
commitbc75e723ce063149278c95327ef91959718d27be (patch)
tree9d72a83972e52ef163bae1651620bbf14226abba /nsswitch
parent83cfb84b78ce7141652f1fdc7f01978cdb69343f (diff)
downloadsamba-bc75e723ce063149278c95327ef91959718d27be.tar.gz
Add wbcContext struct, create and free functions
The basic context structure and functions for libwbclient so that libwbclient can be made thread-safe. Signed-off-by: Matthew Newton <matthew-git@newtoncomputing.co.uk> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'nsswitch')
-rw-r--r--nsswitch/libwbclient/wbclient.c44
-rw-r--r--nsswitch/libwbclient/wbclient.h30
-rw-r--r--nsswitch/libwbclient/wbclient_internal.h4
3 files changed, 78 insertions, 0 deletions
diff --git a/nsswitch/libwbclient/wbclient.c b/nsswitch/libwbclient/wbclient.c
index 93c0318e5e9..e6b3e4e9e17 100644
--- a/nsswitch/libwbclient/wbclient.c
+++ b/nsswitch/libwbclient/wbclient.c
@@ -4,6 +4,7 @@
Winbind client API
Copyright (C) Gerald (Jerry) Carter 2007
+ Copyright (C) Matthew Newton 2015
This library is free software; you can redistribute it and/or
@@ -27,6 +28,8 @@
/* From wb_common.c */
+struct winbindd_context;
+
NSS_STATUS winbindd_request_response(struct winbindd_context *wbctx,
int req_type,
struct winbindd_request *request,
@@ -35,6 +38,9 @@ NSS_STATUS winbindd_priv_request_response(struct winbindd_context *wbctx,
int req_type,
struct winbindd_request *request,
struct winbindd_response *response);
+struct winbindd_context *winbindd_ctx_create(void);
+void winbindd_ctx_free(struct winbindd_context *ctx);
+
/*
result == NSS_STATUS_UNAVAIL: winbind not around
@@ -259,3 +265,41 @@ wbcErr wbcLibraryDetails(struct wbcLibraryDetails **_details)
*_details = info;
return WBC_ERR_SUCCESS;
}
+
+/* Context handling functions */
+
+static void wbcContextDestructor(void *ptr)
+{
+ struct wbcContext *ctx = (struct wbcContext *)ptr;
+
+ winbindd_ctx_free(ctx->winbindd_ctx);
+}
+
+struct wbcContext *wbcCtxCreate(void)
+{
+ struct wbcContext *ctx;
+ struct winbindd_context *wbctx;
+
+ ctx = (struct wbcContext *)wbcAllocateMemory(
+ 1, sizeof(struct wbcContext), wbcContextDestructor);
+
+ if (!ctx) {
+ return NULL;
+ }
+
+ wbctx = winbindd_ctx_create();
+
+ if (!wbctx) {
+ wbcFreeMemory(ctx);
+ return NULL;
+ }
+
+ ctx->winbindd_ctx = wbctx;
+
+ return ctx;
+}
+
+void wbcCtxFree(struct wbcContext *ctx)
+{
+ wbcFreeMemory(ctx);
+}
diff --git a/nsswitch/libwbclient/wbclient.h b/nsswitch/libwbclient/wbclient.h
index dc3e822b7e7..265cf43b966 100644
--- a/nsswitch/libwbclient/wbclient.h
+++ b/nsswitch/libwbclient/wbclient.h
@@ -5,6 +5,7 @@
Copyright (C) Gerald (Jerry) Carter 2007
Copyright (C) Volker Lendecke 2009
+ Copyright (C) Matthew Newton 2015
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -94,6 +95,13 @@ struct wbcInterfaceDetails {
char *dns_domain;
};
+/**
+ * @brief Library context data
+ *
+ **/
+
+struct wbcContext;
+
/*
* Data types used by the Winbind Client API
*/
@@ -523,6 +531,28 @@ struct wbcDomainControllerInfoEx {
void wbcFreeMemory(void*);
+/**********************************************************
+ * Context Management
+ **********************************************************/
+
+/**
+ * @brief Create a new wbcContext context
+ *
+ * @return wbcContext
+ **/
+struct wbcContext *wbcCtxCreate(void);
+
+/**
+ * @brief Free a library context
+ *
+ * @param ctx wbcContext to free
+ *
+ * @return void
+ **/
+void wbcCtxFree(struct wbcContext *ctx);
+
+
+
/*
* Utility functions for dealing with SIDs
*/
diff --git a/nsswitch/libwbclient/wbclient_internal.h b/nsswitch/libwbclient/wbclient_internal.h
index 31f413057e0..e55bf27c0d7 100644
--- a/nsswitch/libwbclient/wbclient_internal.h
+++ b/nsswitch/libwbclient/wbclient_internal.h
@@ -22,6 +22,10 @@
#ifndef _WBCLIENT_INTERNAL_H
#define _WBCLIENT_INTERNAL_H
+struct wbcContext {
+ struct winbindd_context *winbindd_ctx;
+};
+
/* Private functions */
wbcErr wbcRequestResponse(int cmd,