summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2013-07-19 15:10:05 +0200
committerGünther Deschner <gd@samba.org>2013-07-19 17:53:08 +0200
commit44429f948b72e7bcf968da492592c57864f211c7 (patch)
tree336ea190de14139bfcc1369ccc1086529ff57fc2 /source3/printing
parentbb21fc51e42c830d7fab4e89d83f8ef4d122fa1a (diff)
downloadsamba-44429f948b72e7bcf968da492592c57864f211c7.tar.gz
samba-44429f948b72e7bcf968da492592c57864f211c7.tar.bz2
samba-44429f948b72e7bcf968da492592c57864f211c7.zip
s3-printing: avoid KRB5CCNAME overwrite in printer publishing (Bug #7444).
Guenther Signed-off-by: Günther Deschner <gd@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Günther Deschner <gd@samba.org> Autobuild-Date(master): Fri Jul 19 17:53:08 CEST 2013 on sn-devel-104
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/nt_printing_ads.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/source3/printing/nt_printing_ads.c b/source3/printing/nt_printing_ads.c
index dcd31b76ac..5d5f5646da 100644
--- a/source3/printing/nt_printing_ads.c
+++ b/source3/printing/nt_printing_ads.c
@@ -417,6 +417,7 @@ WERROR nt_printer_publish(TALLOC_CTX *mem_ctx,
ADS_STATUS ads_rc;
ADS_STRUCT *ads = NULL;
WERROR win_rc;
+ char *old_krb5ccname = NULL;
sinfo2 = talloc_zero(mem_ctx, struct spoolss_SetPrinterInfo2);
if (!sinfo2) {
@@ -454,6 +455,7 @@ WERROR nt_printer_publish(TALLOC_CTX *mem_ctx,
win_rc = WERR_SERVER_UNAVAILABLE;
goto done;
}
+ old_krb5ccname = getenv(KRB5_ENV_CCNAME);
setenv(KRB5_ENV_CCNAME, "MEMORY:prtpub_cache", 1);
SAFE_FREE(ads->auth.password);
ads->auth.password = secrets_fetch_machine_password(lp_workgroup(),
@@ -479,6 +481,11 @@ WERROR nt_printer_publish(TALLOC_CTX *mem_ctx,
done:
ads_destroy(&ads);
+ ads_kdestroy("MEMORY:prtpub_cache");
+ unsetenv(KRB5_ENV_CCNAME);
+ if (old_krb5ccname) {
+ setenv(KRB5_ENV_CCNAME, old_krb5ccname, 0);
+ }
return win_rc;
}
@@ -493,6 +500,7 @@ WERROR check_published_printers(struct messaging_context *msg_ctx)
struct spoolss_PrinterInfo2 *pinfo2;
NTSTATUS status;
WERROR result;
+ char *old_krb5ccname = NULL;
tmp_ctx = talloc_new(NULL);
if (!tmp_ctx) return WERR_NOMEM;
@@ -502,6 +510,7 @@ WERROR check_published_printers(struct messaging_context *msg_ctx)
DEBUG(3, ("ads_init() failed\n"));
return WERR_SERVER_UNAVAILABLE;
}
+ old_krb5ccname = getenv(KRB5_ENV_CCNAME);
setenv(KRB5_ENV_CCNAME, "MEMORY:prtpub_cache", 1);
SAFE_FREE(ads->auth.password);
ads->auth.password = secrets_fetch_machine_password(lp_workgroup(),
@@ -546,6 +555,10 @@ WERROR check_published_printers(struct messaging_context *msg_ctx)
done:
ads_destroy(&ads);
ads_kdestroy("MEMORY:prtpub_cache");
+ unsetenv(KRB5_ENV_CCNAME);
+ if (old_krb5ccname) {
+ setenv(KRB5_ENV_CCNAME, old_krb5ccname, 0);
+ }
talloc_free(tmp_ctx);
return result;
}