[SCM] Samba Shared Repository - branch v3-6-test updated

Karolin Seeger kseeger at samba.org
Mon Sep 26 12:29:32 MDT 2011


The branch, v3-6-test has been updated
       via  1f9875f s3-netapi: allow to use default krb5 credential cache for libnetapi users.
       via  050123d s3-libnet: allow to use default krb5 ccache in libnet_Join/libnet_Unjoin.
       via  d7a691e s3-docs: document -k switch in net manpage.
      from  b60b85c Fix bug #8477 - Map to guest can return uninitialized blob of data.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test


- Log -----------------------------------------------------------------
commit 1f9875f435d1a9cf6d0476f476f8af9480b87bdb
Author: Günther Deschner <gd at samba.org>
Date:   Mon Sep 26 16:25:12 2011 +0200

    s3-netapi: allow to use default krb5 credential cache for libnetapi users.
    
    Guenther

commit 050123d9b6ae8fd69ed58380d8bdf210c38556fc
Author: Günther Deschner <gd at samba.org>
Date:   Wed Sep 21 17:28:58 2011 +0200

    s3-libnet: allow to use default krb5 ccache in libnet_Join/libnet_Unjoin.
    
    We force using a MEMORY ccache though in the wkssvc server.
    
    Guenther

commit d7a691e2d713aa37b13d88bab628f9b45f05d10d
Author: Günther Deschner <gd at samba.org>
Date:   Tue Sep 20 14:13:36 2011 +0200

    s3-docs: document -k switch in net manpage.
    
    Guenther
    
    Autobuild-User: Günther Deschner <gd at samba.org>
    Autobuild-Date: Tue Sep 20 15:47:00 CEST 2011 on sn-devel-104
    (cherry picked from commit 8dda773bd7eea1d163282b1f3c5e90cbff8a1003)

-----------------------------------------------------------------------

Summary of changes:
 docs-xml/manpages-3/net.8.xml             |    1 +
 source3/lib/netapi/netapi.c               |   24 ++++++++++++++++------
 source3/lib/netapi/netapi.h               |    6 +++++
 source3/libnet/libnet_join.c              |   30 -----------------------------
 source3/rpc_server/wkssvc/srv_wkssvc_nt.c |    4 +++
 5 files changed, 28 insertions(+), 37 deletions(-)


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages-3/net.8.xml b/docs-xml/manpages-3/net.8.xml
index fac9ba6..5c16408 100644
--- a/docs-xml/manpages-3/net.8.xml
+++ b/docs-xml/manpages-3/net.8.xml
@@ -61,6 +61,7 @@
 
 	<variablelist>
 		&stdarg.help;
+		&stdarg.kerberos;
 		
 		<varlistentry>
 		<term>-w target-workgroup</term>
diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c
index c04ca70..dc42049 100644
--- a/source3/lib/netapi/netapi.c
+++ b/source3/lib/netapi/netapi.c
@@ -103,7 +103,6 @@ NET_API_STATUS libnetapi_net_init(struct libnetapi_ctx **context)
 {
 	NET_API_STATUS status;
 	struct libnetapi_ctx *ctx = NULL;
-	char *krb5_cc_env = NULL;
 
 	frame = talloc_stackframe();
 
@@ -115,12 +114,6 @@ NET_API_STATUS libnetapi_net_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);
-	}
-
 	if (getenv("USER")) {
 		ctx->username = talloc_strdup(frame, getenv("USER"));
 	} else {
@@ -266,6 +259,23 @@ NET_API_STATUS libnetapi_set_use_kerberos(struct libnetapi_ctx *ctx)
 	return NET_API_STATUS_SUCCESS;
 }
 
+/****************************************************************
+****************************************************************/
+
+NET_API_STATUS libnetapi_set_use_memory_krb5_ccache(struct libnetapi_ctx *ctx)
+{
+	ctx->krb5_cc_env = talloc_strdup(ctx, "MEMORY:libnetapi");
+	if (!ctx->krb5_cc_env) {
+		return W_ERROR_V(WERR_NOMEM);
+	}
+	setenv(KRB5_ENV_CCNAME, ctx->krb5_cc_env, 1);
+	ctx->use_memory_krb5_ccache = 1;
+	return NET_API_STATUS_SUCCESS;
+}
+
+/****************************************************************
+****************************************************************/
+
 NET_API_STATUS libnetapi_set_use_ccache(struct libnetapi_ctx *ctx)
 {
 	ctx->use_ccache = true;
diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h
index 9e1549d..a55dc5e 100644
--- a/source3/lib/netapi/netapi.h
+++ b/source3/lib/netapi/netapi.h
@@ -1356,6 +1356,7 @@ struct libnetapi_ctx {
 	char *krb5_cc_env;
 	int use_kerberos;
 	int use_ccache;
+	int use_memory_krb5_ccache;
 	int disable_policy_handle_cache;
 
 	void *private_data;
@@ -1408,6 +1409,11 @@ NET_API_STATUS libnetapi_set_use_kerberos(struct libnetapi_ctx *ctx);
 /****************************************************************
 ****************************************************************/
 
+NET_API_STATUS libnetapi_set_use_memory_krb5_ccache(struct libnetapi_ctx *ctx);
+
+/****************************************************************
+****************************************************************/
+
 NET_API_STATUS libnetapi_set_use_ccache(struct libnetapi_ctx *ctx);
 
 /****************************************************************
diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c
index 6750120..25f1adc 100644
--- a/source3/libnet/libnet_join.c
+++ b/source3/libnet/libnet_join.c
@@ -1764,17 +1764,10 @@ 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;
 }
 
@@ -1783,17 +1776,10 @@ 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;
 }
 
@@ -1804,7 +1790,6 @@ 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) {
@@ -1816,13 +1801,6 @@ 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;
@@ -1837,7 +1815,6 @@ 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) {
@@ -1849,13 +1826,6 @@ 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 0dd89ae..247f9ff 100644
--- a/source3/rpc_server/wkssvc/srv_wkssvc_nt.c
+++ b/source3/rpc_server/wkssvc/srv_wkssvc_nt.c
@@ -867,7 +867,9 @@ 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)) {
@@ -933,7 +935,9 @@ 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)) {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list