diff options
Diffstat (limited to 'source/lib/netapi/netapi.c')
-rw-r--r-- | source/lib/netapi/netapi.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/source/lib/netapi/netapi.c b/source/lib/netapi/netapi.c index cf1be00849..889388173f 100644 --- a/source/lib/netapi/netapi.c +++ b/source/lib/netapi/netapi.c @@ -30,8 +30,30 @@ static bool libnetapi_initialized = false; /**************************************************************** ****************************************************************/ +static NET_API_STATUS libnetapi_init_private_context(struct libnetapi_ctx *ctx) +{ + struct libnetapi_private_ctx *priv; + + if (!ctx) { + return W_ERROR_V(WERR_INVALID_PARAM); + } + + priv = TALLOC_ZERO_P(ctx, struct libnetapi_private_ctx); + if (!priv) { + return W_ERROR_V(WERR_NOMEM); + } + + ctx->private_data = priv; + + return NET_API_STATUS_SUCCESS; +} + +/**************************************************************** +****************************************************************/ + NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context) { + NET_API_STATUS status; struct libnetapi_ctx *ctx = NULL; char *krb5_cc_env = NULL; @@ -96,6 +118,12 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context) return W_ERROR_V(WERR_NOMEM); } + status = libnetapi_init_private_context(ctx); + if (status != 0) { + TALLOC_FREE(frame); + return status; + } + libnetapi_initialized = true; *context = stat_ctx = ctx; @@ -125,6 +153,8 @@ NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx) return NET_API_STATUS_SUCCESS; } + libnetapi_samr_free(ctx); + libnetapi_shutdown_cm(ctx); if (ctx->krb5_cc_env) { @@ -279,6 +309,33 @@ const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx, /**************************************************************** ****************************************************************/ +NET_API_STATUS NetApiBufferAllocate(uint32_t byte_count, + void **buffer) +{ + void *buf = NULL; + + if (!buffer) { + return W_ERROR_V(WERR_INSUFFICIENT_BUFFER); + } + + if (byte_count == 0) { + goto done; + } + + buf = talloc_size(NULL, byte_count); + if (!buf) { + return W_ERROR_V(WERR_NOMEM); + } + + done: + *buffer = buf; + + return NET_API_STATUS_SUCCESS; +} + +/**************************************************************** +****************************************************************/ + NET_API_STATUS NetApiBufferFree(void *buffer) { if (!buffer) { |