summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/lib/netapi/netapi.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c
index 33ca67ec85..6d27b99d96 100644
--- a/source3/lib/netapi/netapi.c
+++ b/source3/lib/netapi/netapi.c
@@ -26,9 +26,13 @@ struct libnetapi_ctx *stat_ctx = NULL;
TALLOC_CTX *frame = NULL;
static bool libnetapi_initialized = false;
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
{
struct libnetapi_ctx *ctx = NULL;
+ char *krb5_cc_env = NULL;
if (stat_ctx && libnetapi_initialized) {
*context = stat_ctx;
@@ -65,6 +69,12 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
BlockSignals(True, SIGPIPE);
+ krb5_cc_env = getenv(KRB5_ENV_CCNAME);
+ if (!krb5_cc_env || (strlen(krb5_cc_env) == 0)) {
+ ctx->krb5_cc_env = talloc_strdup(frame, "MEMORY:libnetapi");
+ setenv(KRB5_ENV_CCNAME, ctx->krb5_cc_env, 1);
+ }
+
libnetapi_initialized = true;
*context = stat_ctx = ctx;
@@ -72,6 +82,9 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
return NET_API_STATUS_SUCCESS;
}
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx)
{
if (stat_ctx) {
@@ -82,6 +95,9 @@ NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx)
return libnetapi_init(ctx);
}
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx)
{
gfree_names();
@@ -94,6 +110,11 @@ NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx)
secrets_shutdown();
regdb_close();
+ if (ctx->krb5_cc_env &&
+ (strequal(ctx->krb5_cc_env, getenv(KRB5_ENV_CCNAME)))) {
+ unsetenv(KRB5_ENV_CCNAME);
+ }
+
TALLOC_FREE(ctx);
TALLOC_FREE(frame);
@@ -102,6 +123,9 @@ NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx)
return NET_API_STATUS_SUCCESS;
}
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx,
const char *debuglevel)
{
@@ -113,6 +137,9 @@ NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx,
return NET_API_STATUS_SUCCESS;
}
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_get_debuglevel(struct libnetapi_ctx *ctx,
const char **debuglevel)
{
@@ -120,6 +147,9 @@ NET_API_STATUS libnetapi_get_debuglevel(struct libnetapi_ctx *ctx,
return NET_API_STATUS_SUCCESS;
}
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx,
const char *username)
{
@@ -153,6 +183,9 @@ NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx,
return NET_API_STATUS_SUCCESS;
}
+/****************************************************************
+****************************************************************/
+
const char *libnetapi_errstr(struct libnetapi_ctx *ctx,
NET_API_STATUS status)
{