1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

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>
This commit is contained in:
Matthew Newton 2015-02-21 00:19:32 +00:00 committed by Jeremy Allison
parent 83cfb84b78
commit bc75e723ce
3 changed files with 78 additions and 0 deletions

View File

@ -4,6 +4,7 @@
Winbind client API Winbind client API
Copyright (C) Gerald (Jerry) Carter 2007 Copyright (C) Gerald (Jerry) Carter 2007
Copyright (C) Matthew Newton 2015
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
@ -27,6 +28,8 @@
/* From wb_common.c */ /* From wb_common.c */
struct winbindd_context;
NSS_STATUS winbindd_request_response(struct winbindd_context *wbctx, NSS_STATUS winbindd_request_response(struct winbindd_context *wbctx,
int req_type, int req_type,
struct winbindd_request *request, struct winbindd_request *request,
@ -35,6 +38,9 @@ NSS_STATUS winbindd_priv_request_response(struct winbindd_context *wbctx,
int req_type, int req_type,
struct winbindd_request *request, struct winbindd_request *request,
struct winbindd_response *response); 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 result == NSS_STATUS_UNAVAIL: winbind not around
@ -259,3 +265,41 @@ wbcErr wbcLibraryDetails(struct wbcLibraryDetails **_details)
*_details = info; *_details = info;
return WBC_ERR_SUCCESS; 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);
}

View File

@ -5,6 +5,7 @@
Copyright (C) Gerald (Jerry) Carter 2007 Copyright (C) Gerald (Jerry) Carter 2007
Copyright (C) Volker Lendecke 2009 Copyright (C) Volker Lendecke 2009
Copyright (C) Matthew Newton 2015
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
@ -94,6 +95,13 @@ struct wbcInterfaceDetails {
char *dns_domain; char *dns_domain;
}; };
/**
* @brief Library context data
*
**/
struct wbcContext;
/* /*
* Data types used by the Winbind Client API * Data types used by the Winbind Client API
*/ */
@ -523,6 +531,28 @@ struct wbcDomainControllerInfoEx {
void wbcFreeMemory(void*); 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 * Utility functions for dealing with SIDs
*/ */

View File

@ -22,6 +22,10 @@
#ifndef _WBCLIENT_INTERNAL_H #ifndef _WBCLIENT_INTERNAL_H
#define _WBCLIENT_INTERNAL_H #define _WBCLIENT_INTERNAL_H
struct wbcContext {
struct winbindd_context *winbindd_ctx;
};
/* Private functions */ /* Private functions */
wbcErr wbcRequestResponse(int cmd, wbcErr wbcRequestResponse(int cmd,