[SCM] Samba Shared Repository - branch v3-2-test updated - initial-v3-2-unstable-1274-g9cc0d87

Günther Deschner gd at samba.org
Fri Jan 11 14:11:15 GMT 2008


The branch, v3-2-test has been updated
       via  9cc0d874f6c064e8752d36e72fcc85bf4c85e656 (commit)
       via  01690f85bc7d052d4c57181d74aef27d1776169c (commit)
       via  23b92a6fa57858c8a23c737a9cd00c076ef5dadd (commit)
       via  3b450a8bcc97b6d03c4b7b9373a3a382c0fcea30 (commit)
       via  2e2d058b7e90a158612af4b0a489578431f748e5 (commit)
       via  ed4960baccf687b77c2b0f4ee64cbce2005f3abb (commit)
       via  9707a5eb008788460937104575b7afd733a9f741 (commit)
       via  16ca8d2746a5c2fc7a583d1cf2ebb4d3aa003842 (commit)
      from  767e0164adf8803df50b0b7bd8e81d25af72bb78 (commit)

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


- Log -----------------------------------------------------------------
commit 9cc0d874f6c064e8752d36e72fcc85bf4c85e656
Author: Günther Deschner <gd at samba.org>
Date:   Fri Jan 11 15:03:31 2008 +0100

    Remove '\n' from error strings in libnet_join context.
    
    Guenther

commit 01690f85bc7d052d4c57181d74aef27d1776169c
Author: Günther Deschner <gd at samba.org>
Date:   Fri Jan 11 14:50:10 2008 +0100

    Set error string when ads_leave_realm() has failed in libnetjoin.
    
    Guenther

commit 23b92a6fa57858c8a23c737a9cd00c076ef5dadd
Author: Günther Deschner <gd at samba.org>
Date:   Fri Jan 11 14:47:52 2008 +0100

    Include some basic headers in netapi.h.
    
    Guenther

commit 3b450a8bcc97b6d03c4b7b9373a3a382c0fcea30
Author: Günther Deschner <gd at samba.org>
Date:   Fri Jan 11 14:47:23 2008 +0100

    Refactor libnetapi error string functions a bit.
    
    Guenther

commit 2e2d058b7e90a158612af4b0a489578431f748e5
Author: Günther Deschner <gd at samba.org>
Date:   Fri Jan 11 14:43:56 2008 +0100

    Ignore result of libnet_conf_delete_parameter here, as realm may be not there.
    
    Guenther

commit ed4960baccf687b77c2b0f4ee64cbce2005f3abb
Author: Günther Deschner <gd at samba.org>
Date:   Fri Jan 11 14:42:48 2008 +0100

    Remove some more references to global_myname() in libnet_join.
    
    Guenther

commit 9707a5eb008788460937104575b7afd733a9f741
Author: Günther Deschner <gd at samba.org>
Date:   Fri Jan 11 14:41:34 2008 +0100

    Use domain_is_ad bool.
    
    Guenther

commit 16ca8d2746a5c2fc7a583d1cf2ebb4d3aa003842
Author: Günther Deschner <gd at samba.org>
Date:   Fri Jan 11 14:40:06 2008 +0100

    Add domain_is_ad bool to libnetjoin ctx.
    
    Guenther

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

Summary of changes:
 source/lib/netapi/netapi.c  |   21 +++++++++++++++---
 source/lib/netapi/netapi.h  |   15 +++++++++++-
 source/libnet/libnet_join.c |   49 ++++++++++++++++++++++++------------------
 source/libnet/libnet_join.h |    1 +
 4 files changed, 59 insertions(+), 27 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/lib/netapi/netapi.c b/source/lib/netapi/netapi.c
index d4cb3a9..ce00054 100644
--- a/source/lib/netapi/netapi.c
+++ b/source/lib/netapi/netapi.c
@@ -192,8 +192,7 @@ NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx,
 /****************************************************************
 ****************************************************************/
 
-const char *libnetapi_errstr(struct libnetapi_ctx *ctx,
-			     NET_API_STATUS status)
+const char *libnetapi_errstr(NET_API_STATUS status)
 {
 	if (status & 0xc0000000) {
 		return get_friendly_nt_error_msg(NT_STATUS(status));
@@ -220,9 +219,23 @@ NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx,
 /****************************************************************
 ****************************************************************/
 
-const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx)
+const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx,
+				       NET_API_STATUS status)
 {
-	return ctx->error_string;
+	struct libnetapi_ctx *tmp_ctx = ctx;
+
+	if (!tmp_ctx) {
+		status = libnetapi_getctx(&tmp_ctx);
+		if (status != 0) {
+			return NULL;
+		}
+	}
+
+	if (tmp_ctx->error_string) {
+		return tmp_ctx->error_string;
+	}
+
+	return libnetapi_errstr(status);
 }
 
 /****************************************************************
diff --git a/source/lib/netapi/netapi.h b/source/lib/netapi/netapi.h
index 4a40b32..274a167 100644
--- a/source/lib/netapi/netapi.h
+++ b/source/lib/netapi/netapi.h
@@ -20,6 +20,16 @@
 #ifndef __LIB_NETAPI_H__
 #define __LIB_NETAPI_H__
 
+/****************************************************************
+ include some basic headers
+****************************************************************/
+
+#include <inttypes.h>
+
+/****************************************************************
+ NET_API_STATUS
+****************************************************************/
+
 #define NET_API_STATUS uint32_t
 #define NET_API_STATUS_SUCCESS 0
 
@@ -46,9 +56,10 @@ NET_API_STATUS libnetapi_get_debuglevel(struct libnetapi_ctx *ctx, char **debugl
 NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx, const char *username);
 NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx, const char *password);
 NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx, const char *workgroup);
-const char *libnetapi_errstr(struct libnetapi_ctx *ctx, NET_API_STATUS status);
+const char *libnetapi_errstr(NET_API_STATUS status);
 NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx, const char *error_string);
-const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx);
+const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx, NET_API_STATUS status);
+
 
 /****************************************************************
 ****************************************************************/
diff --git a/source/libnet/libnet_join.c b/source/libnet/libnet_join.c
index 8e6d91b..1df85eb 100644
--- a/source/libnet/libnet_join.c
+++ b/source/libnet/libnet_join.c
@@ -120,7 +120,7 @@ static ADS_STATUS libnet_join_connect_ads(TALLOC_CTX *mem_ctx,
 				    &r->in.ads);
 	if (!ADS_ERR_OK(status)) {
 		libnet_join_set_error_string(mem_ctx, r,
-			"failed to connect to AD: %s\n",
+			"failed to connect to AD: %s",
 			ads_errstr(status));
 	}
 
@@ -147,7 +147,7 @@ static ADS_STATUS libnet_unjoin_connect_ads(TALLOC_CTX *mem_ctx,
 				    &r->in.ads);
 	if (!ADS_ERR_OK(status)) {
 		libnet_unjoin_set_error_string(mem_ctx, r,
-			"failed to connect to AD: %s\n",
+			"failed to connect to AD: %s",
 			ads_errstr(status));
 	}
 
@@ -202,7 +202,15 @@ static ADS_STATUS libnet_unjoin_remove_machine_acct(TALLOC_CTX *mem_ctx,
 		}
 	}
 
-	return ads_leave_realm(r->in.ads, r->in.machine_name);
+	status = ads_leave_realm(r->in.ads, r->in.machine_name);
+	if (!ADS_ERR_OK(status)) {
+		libnet_unjoin_set_error_string(mem_ctx, r,
+			"failed to leave realm: %s",
+			ads_errstr(status));
+		return status;
+	}
+
+	return ADS_SUCCESS;
 }
 
 /****************************************************************
@@ -453,14 +461,14 @@ static bool libnet_join_derive_salting_principal(TALLOC_CTX *mem_ctx,
 	status = ads_domain_func_level(r->in.ads, &domain_func);
 	if (!ADS_ERR_OK(status)) {
 		libnet_join_set_error_string(mem_ctx, r,
-			"Failed to determine domain functional level!\n");
+			"Failed to determine domain functional level!");
 		return false;
 	}
 
 	std_salt = kerberos_standard_des_salt();
 	if (!std_salt) {
 		libnet_join_set_error_string(mem_ctx, r,
-			"failed to obtain standard DES salt\n");
+			"failed to obtain standard DES salt");
 		return false;
 	}
 
@@ -575,6 +583,10 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx,
 					       NULL,
 					       &r->out.domain_sid);
 
+	if (NT_STATUS_IS_OK(status)) {
+		r->out.domain_is_ad = true;
+	}
+
 	if (!NT_STATUS_IS_OK(status)) {
 		status = rpccli_lsa_query_info_policy(pipe_hnd, mem_ctx, &lsa_pol,
 						      5,
@@ -607,7 +619,7 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx,
 		goto done;
 	}
 
-	acct_name = talloc_asprintf(mem_ctx, "%s$", global_myname());
+	acct_name = talloc_asprintf(mem_ctx, "%s$", r->in.machine_name);
 	strlower_m(acct_name);
 	const_acct_name = acct_name;
 
@@ -769,7 +781,7 @@ static NTSTATUS libnet_join_unjoindomain_rpc(TALLOC_CTX *mem_ctx,
 		goto done;
 	}
 
-	acct_name = talloc_asprintf(mem_ctx, "%s$", global_myname());
+	acct_name = talloc_asprintf(mem_ctx, "%s$", r->in.machine_name);
 	strlower_m(acct_name);
 	const_acct_name = acct_name;
 
@@ -833,7 +845,6 @@ done:
 static WERROR do_join_modify_vals_config(struct libnet_JoinCtx *r)
 {
 	WERROR werr;
-	bool is_ad = false;
 
 	if (!(r->in.join_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE)) {
 
@@ -845,10 +856,6 @@ static WERROR do_join_modify_vals_config(struct libnet_JoinCtx *r)
 		return werr;
 	}
 
-	if (r->out.dns_domain_name) {
-		is_ad = true;
-	}
-
 	werr = libnet_conf_set_global_parameter("security", "domain");
 	W_ERROR_NOT_OK_RETURN(werr);
 
@@ -856,7 +863,7 @@ static WERROR do_join_modify_vals_config(struct libnet_JoinCtx *r)
 						r->out.netbios_domain_name);
 	W_ERROR_NOT_OK_RETURN(werr);
 
-	if (is_ad) {
+	if (r->out.domain_is_ad) {
 		werr = libnet_conf_set_global_parameter("security", "ads");
 		W_ERROR_NOT_OK_RETURN(werr);
 
@@ -881,7 +888,7 @@ static WERROR do_unjoin_modify_vals_config(struct libnet_UnjoinCtx *r)
 		W_ERROR_NOT_OK_RETURN(werr);
 	}
 
-	werr = libnet_conf_delete_parameter(GLOBAL_NAME, "realm");
+	libnet_conf_delete_parameter(GLOBAL_NAME, "realm");
 
 	return werr;
 }
@@ -1026,7 +1033,7 @@ static WERROR libnet_DomainJoin(TALLOC_CTX *mem_ctx,
 		ads_status = libnet_join_precreate_machine_acct(mem_ctx, r);
 		if (!ADS_ERR_OK(ads_status)) {
 			libnet_join_set_error_string(mem_ctx, r,
-				"failed to precreate account in ou %s: %s\n",
+				"failed to precreate account in ou %s: %s",
 				r->in.account_ou,
 				ads_errstr(ads_status));
 			return WERR_GENERAL_FAILURE;
@@ -1051,7 +1058,7 @@ static WERROR libnet_DomainJoin(TALLOC_CTX *mem_ctx,
 	ads_status = libnet_join_set_machine_spn(mem_ctx, r);
 	if (!ADS_ERR_OK(ads_status)) {
 		libnet_join_set_error_string(mem_ctx, r,
-			"failed to set machine spn: %s\n",
+			"failed to set machine spn: %s",
 			ads_errstr(ads_status));
 		return WERR_GENERAL_FAILURE;
 	}
@@ -1059,7 +1066,7 @@ static WERROR libnet_DomainJoin(TALLOC_CTX *mem_ctx,
 	ads_status = libnet_join_set_os_attributes(mem_ctx, r);
 	if (!ADS_ERR_OK(ads_status)) {
 		libnet_join_set_error_string(mem_ctx, r,
-			"failed to set machine os attributes: %s\n",
+			"failed to set machine os attributes: %s",
 			ads_errstr(ads_status));
 		return WERR_GENERAL_FAILURE;
 	}
@@ -1067,7 +1074,7 @@ static WERROR libnet_DomainJoin(TALLOC_CTX *mem_ctx,
 	ads_status = libnet_join_set_machine_upn(mem_ctx, r);
 	if (!ADS_ERR_OK(ads_status)) {
 		libnet_join_set_error_string(mem_ctx, r,
-			"failed to set machine upn: %s\n",
+			"failed to set machine upn: %s",
 			ads_errstr(ads_status));
 		return WERR_GENERAL_FAILURE;
 	}
@@ -1081,7 +1088,7 @@ static WERROR libnet_DomainJoin(TALLOC_CTX *mem_ctx,
 #endif /* HAVE_LDAP */
 	if (!libnet_join_create_keytab(mem_ctx, r)) {
 		libnet_join_set_error_string(mem_ctx, r,
-			"failed to create kerberos keytab\n");
+			"failed to create kerberos keytab");
 		return WERR_GENERAL_FAILURE;
 	}
 
@@ -1134,7 +1141,7 @@ static WERROR libnet_DomainUnjoin(TALLOC_CTX *mem_ctx,
 	status = libnet_join_unjoindomain_rpc(mem_ctx, r);
 	if (!NT_STATUS_IS_OK(status)) {
 		libnet_unjoin_set_error_string(mem_ctx, r,
-			"failed to unjoin domain: %s\n",
+			"failed to unjoin domain: %s",
 			nt_errstr(status));
 		if (NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_USER)) {
 			return WERR_SETUP_NOT_JOINED;
@@ -1149,7 +1156,7 @@ static WERROR libnet_DomainUnjoin(TALLOC_CTX *mem_ctx,
 		ads_status = libnet_unjoin_remove_machine_acct(mem_ctx, r);
 		if (!ADS_ERR_OK(ads_status)) {
 			libnet_unjoin_set_error_string(mem_ctx, r,
-				"failed to remove machine account from AD: %s\n",
+				"failed to remove machine account from AD: %s",
 				ads_errstr(ads_status));
 		}
 	}
diff --git a/source/libnet/libnet_join.h b/source/libnet/libnet_join.h
index c6a0cd1..95b9657 100644
--- a/source/libnet/libnet_join.h
+++ b/source/libnet/libnet_join.h
@@ -47,6 +47,7 @@ struct libnet_JoinCtx {
 		bool modified_config;
 		WERROR result;
 		char *error_string;
+		bool domain_is_ad;
 	} out;
 };
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list