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:
parent
83cfb84b78
commit
bc75e723ce
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user