From 82e2f1834380c226eed203a70eaec21b73c0d10a Mon Sep 17 00:00:00 2001 From: Karolin Seeger Date: Mon, 26 Sep 2011 21:10:46 +0200 Subject: [PATCH] Revert "s3-libnet: allow to use default krb5 ccache in libnet_Join/libnet_Unjoin." This reverts commit 050123d9b6ae8fd69ed58380d8bdf210c38556fc. This commit seems to break the build. --- source3/libnet/libnet_join.c | 30 ++++++++++++++++++++++++++++++ source3/rpc_server/wkssvc/srv_wkssvc_nt.c | 4 ---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 25f1adc0dbe..6750120fc99 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -1764,10 +1764,17 @@ static WERROR libnet_join_post_processing(TALLOC_CTX *mem_ctx, static int libnet_destroy_JoinCtx(struct libnet_JoinCtx *r) { + const char *krb5_cc_env = NULL; + if (r->in.ads) { ads_destroy(&r->in.ads); } + krb5_cc_env = getenv(KRB5_ENV_CCNAME); + if (krb5_cc_env && StrCaseCmp(krb5_cc_env, "MEMORY:libnetjoin")) { + unsetenv(KRB5_ENV_CCNAME); + } + return 0; } @@ -1776,10 +1783,17 @@ static int libnet_destroy_JoinCtx(struct libnet_JoinCtx *r) static int libnet_destroy_UnjoinCtx(struct libnet_UnjoinCtx *r) { + const char *krb5_cc_env = NULL; + if (r->in.ads) { ads_destroy(&r->in.ads); } + krb5_cc_env = getenv(KRB5_ENV_CCNAME); + if (krb5_cc_env && StrCaseCmp(krb5_cc_env, "MEMORY:libnetjoin")) { + unsetenv(KRB5_ENV_CCNAME); + } + return 0; } @@ -1790,6 +1804,7 @@ WERROR libnet_init_JoinCtx(TALLOC_CTX *mem_ctx, struct libnet_JoinCtx **r) { struct libnet_JoinCtx *ctx; + const char *krb5_cc_env = NULL; ctx = talloc_zero(mem_ctx, struct libnet_JoinCtx); if (!ctx) { @@ -1801,6 +1816,13 @@ WERROR libnet_init_JoinCtx(TALLOC_CTX *mem_ctx, ctx->in.machine_name = talloc_strdup(mem_ctx, global_myname()); W_ERROR_HAVE_NO_MEMORY(ctx->in.machine_name); + krb5_cc_env = getenv(KRB5_ENV_CCNAME); + if (!krb5_cc_env || (strlen(krb5_cc_env) == 0)) { + krb5_cc_env = talloc_strdup(mem_ctx, "MEMORY:libnetjoin"); + W_ERROR_HAVE_NO_MEMORY(krb5_cc_env); + setenv(KRB5_ENV_CCNAME, krb5_cc_env, 1); + } + ctx->in.secure_channel_type = SEC_CHAN_WKSTA; *r = ctx; @@ -1815,6 +1837,7 @@ WERROR libnet_init_UnjoinCtx(TALLOC_CTX *mem_ctx, struct libnet_UnjoinCtx **r) { struct libnet_UnjoinCtx *ctx; + const char *krb5_cc_env = NULL; ctx = talloc_zero(mem_ctx, struct libnet_UnjoinCtx); if (!ctx) { @@ -1826,6 +1849,13 @@ WERROR libnet_init_UnjoinCtx(TALLOC_CTX *mem_ctx, ctx->in.machine_name = talloc_strdup(mem_ctx, global_myname()); W_ERROR_HAVE_NO_MEMORY(ctx->in.machine_name); + krb5_cc_env = getenv(KRB5_ENV_CCNAME); + if (!krb5_cc_env || (strlen(krb5_cc_env) == 0)) { + krb5_cc_env = talloc_strdup(mem_ctx, "MEMORY:libnetjoin"); + W_ERROR_HAVE_NO_MEMORY(krb5_cc_env); + setenv(KRB5_ENV_CCNAME, krb5_cc_env, 1); + } + *r = ctx; return WERR_OK; diff --git a/source3/rpc_server/wkssvc/srv_wkssvc_nt.c b/source3/rpc_server/wkssvc/srv_wkssvc_nt.c index 247f9ff8bde..0dd89aed364 100644 --- a/source3/rpc_server/wkssvc/srv_wkssvc_nt.c +++ b/source3/rpc_server/wkssvc/srv_wkssvc_nt.c @@ -867,9 +867,7 @@ WERROR _wkssvc_NetrJoinDomain2(struct pipes_struct *p, j->in.msg_ctx = p->msg_ctx; become_root(); - setenv(KRB5_ENV_CCNAME, "MEMORY:_wkssvc_NetrJoinDomain2", 1); werr = libnet_Join(p->mem_ctx, j); - unsetenv(KRB5_ENV_CCNAME); unbecome_root(); if (!W_ERROR_IS_OK(werr)) { @@ -935,9 +933,7 @@ WERROR _wkssvc_NetrUnjoinDomain2(struct pipes_struct *p, u->in.msg_ctx = p->msg_ctx; become_root(); - setenv(KRB5_ENV_CCNAME, "MEMORY:_wkssvc_NetrUnjoinDomain2", 1); werr = libnet_Unjoin(p->mem_ctx, u); - unsetenv(KRB5_ENV_CCNAME); unbecome_root(); if (!W_ERROR_IS_OK(werr)) { -- 2.11.4.GIT