[SCM] Samba Shared Repository - branch v3-2-test updated - release-3-2-0pre2-906-g8331fbe

Günther Deschner gd at samba.org
Mon Apr 14 15:55:16 GMT 2008


The branch, v3-2-test has been updated
       via  8331fbe735e2bec386ab8fc1645dc371d45d3063 (commit)
       via  7fd237c545e0a7e0029195dbbb6691571abdfe84 (commit)
       via  9176057986be63c7ebebb56f7daabbc3883802c5 (commit)
      from  91a55fc27dc100cf193cfa2613771312f018449e (commit)

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


- Log -----------------------------------------------------------------
commit 8331fbe735e2bec386ab8fc1645dc371d45d3063
Author: Günther Deschner <gd at samba.org>
Date:   Mon Apr 14 16:16:25 2008 +0200

    net: exit early in net_ads_join() if the domain is not set.
    
    Guenther

commit 7fd237c545e0a7e0029195dbbb6691571abdfe84
Author: Günther Deschner <gd at samba.org>
Date:   Mon Apr 14 16:15:18 2008 +0200

    libnetjoin: Fix unjoining when no KRB5CCNAME is around.
    
    Guenther

commit 9176057986be63c7ebebb56f7daabbc3883802c5
Author: Günther Deschner <gd at samba.org>
Date:   Mon Apr 14 16:13:52 2008 +0200

    net: use WERROR for check_ads_config().
    
    Guenther

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

Summary of changes:
 source/libnet/libnet_join.c |   16 ++++++++++++++++
 source/utils/net_ads.c      |   22 +++++++++++++---------
 2 files changed, 29 insertions(+), 9 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/libnet/libnet_join.c b/source/libnet/libnet_join.c
index aff61d8..dda945e 100644
--- a/source/libnet/libnet_join.c
+++ b/source/libnet/libnet_join.c
@@ -1449,10 +1449,18 @@ 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;
 }
 
@@ -1496,6 +1504,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) {
@@ -1507,6 +1516,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/source/utils/net_ads.c b/source/utils/net_ads.c
index 9c8d1fb..b481452 100644
--- a/source/utils/net_ads.c
+++ b/source/utils/net_ads.c
@@ -918,27 +918,27 @@ int net_ads_testjoin(int argc, const char **argv)
   Simple configu checks before beginning the join
  ********************************************************************/
 
-static NTSTATUS check_ads_config( void )
+static WERROR check_ads_config( void )
 {
 	if (lp_server_role() != ROLE_DOMAIN_MEMBER ) {
 		d_printf("Host is not configured as a member server.\n");
-		return NT_STATUS_INVALID_DOMAIN_ROLE;
+		return WERR_INVALID_DOMAIN_ROLE;
 	}
 
 	if (strlen(global_myname()) > 15) {
 		d_printf("Our netbios name can be at most 15 chars long, "
 			 "\"%s\" is %u chars long\n", global_myname(),
 			 (unsigned int)strlen(global_myname()));
-		return NT_STATUS_NAME_TOO_LONG;
+		return WERR_INVALID_COMPUTER_NAME;
 	}
 
 	if ( lp_security() == SEC_ADS && !*lp_realm()) {
 		d_fprintf(stderr, "realm must be set in in %s for ADS "
 			"join to succeed.\n", get_dyn_CONFIGFILE());
-		return NT_STATUS_INVALID_PARAMETER;
+		return WERR_INVALID_PARAM;
 	}
 
-	return NT_STATUS_OK;
+	return WERR_OK;
 }
 
 /*******************************************************************
@@ -1096,7 +1096,6 @@ static int net_ads_join_usage(int argc, const char **argv)
 
 int net_ads_join(int argc, const char **argv)
 {
-	NTSTATUS nt_status;
 	TALLOC_CTX *ctx = NULL;
 	struct libnet_JoinCtx *r = NULL;
 	const char *domain = lp_realm();
@@ -1108,10 +1107,9 @@ int net_ads_join(int argc, const char **argv)
 	const char *os_name = NULL;
 	const char *os_version = NULL;
 
-	nt_status = check_ads_config();
-	if (!NT_STATUS_IS_OK(nt_status)) {
+	werr = check_ads_config();
+	if (!W_ERROR_IS_OK(werr)) {
 		d_fprintf(stderr, "Invalid configuration.  Exiting....\n");
-		werr = ntstatus_to_werror(nt_status);
 		goto fail;
 	}
 
@@ -1161,6 +1159,12 @@ int net_ads_join(int argc, const char **argv)
 		}
 	}
 
+	if (!*domain) {
+		d_fprintf(stderr, "Please supply a valid domain name\n");
+		werr = WERR_INVALID_PARAM;
+		goto fail;
+	}
+
 	/* Do the domain join here */
 
 	r->in.domain_name	= domain;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list