1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-28 01:58:17 +03:00

Let libnetapi use it's own krb5 cred cache in memory if necessary.

Guenther
(This used to be commit 863fb30038e384585502f0154a742481594b99d0)
This commit is contained in:
Günther Deschner 2008-01-07 20:01:28 +01:00
parent d66118629c
commit 1fba8c8019

View File

@ -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)
{