[SCM] Samba Shared Repository - branch master updated

Günther Deschner gd at samba.org
Tue Mar 2 11:03:31 MST 2010


The branch, master has been updated
       via  f36dafd... s4-smbtorture: fix WINBIND-STRUCT assumptions about getpwent() for s3.
       via  8492f92... s3:ads fix dn parsing name was always null
       via  74703e4... testprogs: make sure to do the same tests as in smbtorture in test_PrinterData().
       via  f73c271... testprogs: fix REG_SZ in print_printer_data.
      from  e50c982... LDB:NSS - make LDB "signed-safe" on counter variables

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit f36dafd852b1ed608e0c988c3c5f8823e909a4d6
Author: Günther Deschner <gd at samba.org>
Date:   Tue Mar 2 18:35:01 2010 +0100

    s4-smbtorture: fix WINBIND-STRUCT assumptions about getpwent() for s3.
    
    In samba3 it is not an error when no users are returned in getpwent() calls
    (e.g. on a DC w/o interdomain trusts).
    
    Kai, please check.
    
    Guenther

commit 8492f92843aa17eaf4a3ea9d5a9c6319afc97854
Author: Simo Sorce <idra at samba.org>
Date:   Mon Mar 1 14:50:50 2010 -0500

    s3:ads fix dn parsing name was always null
    
    While there also use ldap_exploded_dn instead of ldb_dn_validate()
    so we can remove a huge dependency that is hanging there only for one very
    minor marginal use.
    
    Signed-off-by: Günther Deschner <gd at samba.org>

commit 74703e4897028db72242d9187d726c6f0ebd1540
Author: Günther Deschner <gd at samba.org>
Date:   Tue Mar 2 17:25:35 2010 +0100

    testprogs: make sure to do the same tests as in smbtorture in test_PrinterData().
    
    Guenther

commit f73c27116c60e492158c6d40823691c38a290a94
Author: Günther Deschner <gd at samba.org>
Date:   Tue Mar 2 17:24:14 2010 +0100

    testprogs: fix REG_SZ in print_printer_data.
    
    Guenther

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

Summary of changes:
 source3/libads/ldap.c                    |   35 ++++++-------
 source4/torture/winbind/struct_based.c   |   21 ++++++--
 testprogs/win32/spoolss/printlib.c       |   14 ++++-
 testprogs/win32/spoolss/printlib_proto.h |    1 +
 testprogs/win32/spoolss/spoolss.c        |   78 +++++++++++++++++++++--------
 5 files changed, 100 insertions(+), 49 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index df45be5..19a37c7 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -3856,39 +3856,36 @@ ADS_STATUS ads_check_ou_dn(TALLOC_CTX *mem_ctx,
 			   ADS_STRUCT *ads,
 			   const char **account_ou)
 {
-	struct ldb_dn *name_dn = NULL;
-	const char *name = NULL;
-	char *ou_string = NULL;
-	struct ldb_context *ldb = ldb_init(mem_ctx, NULL);
-
-	name_dn = ldb_dn_new(mem_ctx, ldb, *account_ou);
-	if (name_dn && ldb_dn_validate(name_dn)) {
-		talloc_free(ldb);
+	char **exploded_dn;
+	const char *name;
+	char *ou_string;
+
+	exploded_dn = ldap_explode_dn(*account_ou, 0);
+	if (exploded_dn) {
+		ldap_value_free(exploded_dn);
 		return ADS_SUCCESS;
 	}
 
 	ou_string = ads_ou_string(ads, *account_ou);
 	if (!ou_string) {
-		talloc_free(ldb);
 		return ADS_ERROR_LDAP(LDAP_INVALID_DN_SYNTAX);
 	}
 
-	name_dn = ldb_dn_new_fmt(mem_ctx, ldb, "%s,%s", ou_string,
-				 ads->config.bind_path);
+	name = talloc_asprintf(mem_ctx, "%s,%s", ou_string,
+			       ads->config.bind_path);
 	SAFE_FREE(ou_string);
 
-	if (!name_dn || !ldb_dn_validate(name_dn)) {
-		talloc_free(ldb);
-		return ADS_ERROR_LDAP(LDAP_INVALID_DN_SYNTAX);
+	if (!name) {
+		return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
 	}
 
-	*account_ou = talloc_strdup(mem_ctx, name);
-	if (!*account_ou) {
-		talloc_free(ldb);
-		return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
+	exploded_dn = ldap_explode_dn(name, 0);
+	if (!exploded_dn) {
+		return ADS_ERROR_LDAP(LDAP_INVALID_DN_SYNTAX);
 	}
+	ldap_value_free(exploded_dn);
 
-	talloc_free(ldb);
+	*account_ou = name;
 	return ADS_SUCCESS;
 }
 
diff --git a/source4/torture/winbind/struct_based.c b/source4/torture/winbind/struct_based.c
index 872e17b..5a621bc 100644
--- a/source4/torture/winbind/struct_based.c
+++ b/source4/torture/winbind/struct_based.c
@@ -849,12 +849,23 @@ static bool torture_winbind_struct_getpwent(struct torture_context *torture)
 	ZERO_STRUCT(req);
 	ZERO_STRUCT(rep);
 	req.data.num_entries = 1;
-	DO_STRUCT_REQ_REP(WINBINDD_GETPWENT, &req, &rep);
+	if (torture_setting_bool(torture, "samba3", false)) {
+		bool __noop = false;
+		DO_STRUCT_REQ_REP_EXT(WINBINDD_GETPWENT, &req, &rep,
+				      NSS_STATUS_SUCCESS, false, __noop=true,
+				      NULL);
+	} else {
+		DO_STRUCT_REQ_REP(WINBINDD_GETPWENT, &req, &rep);
+	}
 	pwent = (struct winbindd_pw *)rep.extra_data.data;
-	torture_assert(torture, (pwent != NULL), "NULL pwent");
-	torture_comment(torture, "name: %s, uid: %d, gid: %d, shell: %s\n",
-			pwent->pw_name, pwent->pw_uid, pwent->pw_gid,
-			pwent->pw_shell);
+	if (!torture_setting_bool(torture, "samba3", false)) {
+		torture_assert(torture, (pwent != NULL), "NULL pwent");
+	}
+	if (pwent) {
+		torture_comment(torture, "name: %s, uid: %d, gid: %d, shell: %s\n",
+				pwent->pw_name, pwent->pw_uid, pwent->pw_gid,
+				pwent->pw_shell);
+	}
 
 	return true;
 }
diff --git a/testprogs/win32/spoolss/printlib.c b/testprogs/win32/spoolss/printlib.c
index c1eaeeb..f3541c8 100644
--- a/testprogs/win32/spoolss/printlib.c
+++ b/testprogs/win32/spoolss/printlib.c
@@ -1142,7 +1142,7 @@ void print_printer_keys(LPSTR buffer)
 	}
 }
 
-static LPSTR reg_type_str(DWORD type)
+LPSTR reg_type_str(DWORD type)
 {
 	switch (type) {
 	case REG_DWORD:
@@ -1168,12 +1168,20 @@ void print_printer_data(LPSTR keyname, LPSTR valuename, DWORD size, LPBYTE buffe
 	}
 
 	printf("\tValue Name:\t%s\n", valuename);
-	printf("\tSize: 0x%x (%d)\n", size, size);
+	printf("\tSize:\t\t0x%x (%d)\n", size, size);
 	printf("\tType:\t\t%s\n", reg_type_str(type));
 
+	if (buffer == NULL || size == 0) {
+		return;
+	}
+
 	switch (type) {
 	case REG_SZ:
-		printf("\t\t%s\n", (LPSTR)buffer);
+		printf("\t\t");
+		for (i=0; i < size; i++) {
+			printf("%c", buffer[i]);
+		}
+		printf("\n");
 		break;
 	case REG_MULTI_SZ:
 		p = (LPSTR)buffer;
diff --git a/testprogs/win32/spoolss/printlib_proto.h b/testprogs/win32/spoolss/printlib_proto.h
index 688b317..5a43999 100644
--- a/testprogs/win32/spoolss/printlib_proto.h
+++ b/testprogs/win32/spoolss/printlib_proto.h
@@ -54,6 +54,7 @@ void print_driver_info_8(PDRIVER_INFO_8 info);
 void print_driver_info_bylevel(DWORD level, LPBYTE buffer, DWORD count);
 void print_doc_info_1(PDOC_INFO_1 info);
 void print_printer_keys(LPSTR buffer);
+LPSTR reg_type_str(DWORD type);
 void print_printer_data(LPSTR keyname, LPSTR valuename, DWORD size, LPBYTE buffer, DWORD type);
 void print_printer_enum_values(PRINTER_ENUM_VALUES *info);
 #undef _PRINTF_ATTRIBUTE
diff --git a/testprogs/win32/spoolss/spoolss.c b/testprogs/win32/spoolss/spoolss.c
index 49bcc59..97bf5eb 100644
--- a/testprogs/win32/spoolss/spoolss.c
+++ b/testprogs/win32/spoolss/spoolss.c
@@ -1375,35 +1375,69 @@ static BOOL test_PrinterData(struct torture_context *tctx,
 			     LPSTR printername,
 			     HANDLE handle)
 {
+	char tmp[1024];
 	LPSTR keyname = "torture_key";
 	LPSTR valuename = "torture_value";
 	BOOL ret = TRUE;
-	DWORD type, type_ex;
-	LPBYTE buffer, buffer_ex;
-	DWORD size, size_ex;
+	DWORD types[] = {
+		REG_SZ,
+		REG_DWORD,
+		REG_BINARY
+	};
+	DWORD value = 12345678;
+	LPSTR str = "abcdefghijklmnopqrstuvwxzy";
+	DWORD t, s;
 
-	torture_comment(tctx, "Testing PrinterData");
+	for (t=0; t < ARRAY_SIZE(types); t++) {
+	for (s=0; s < strlen(str); s++) {
 
-	type = REG_SZ;
-	size = 4;
-	buffer = malloc(size);
-	if (!buffer) {
-		return FALSE;
+		DWORD type, type_ex;
+		LPBYTE buffer, buffer_ex;
+		DWORD size, size_ex;
+
+		if (types[t] == REG_DWORD) {
+			s = 0xffff;
+		}
+
+		switch (types[t]) {
+		case REG_BINARY:
+			buffer = malloc(s);
+			memcpy(buffer, str, s);
+			size = s;
+			break;
+		case REG_DWORD:
+			buffer = malloc(4);
+			size = 4;
+			break;
+		case REG_SZ:
+			buffer = malloc(s);
+			memcpy(buffer, str, s);
+			size = s;
+			break;
+		default:
+			sprintf(tmp, "type %d untested\n", types[t]);
+			torture_fail(tctx, tmp);
+			break;
+		}
+
+		type = types[t];
+
+		torture_comment(tctx, "Testing PrinterData (type: %s, size: 0x%08x)", reg_type_str(type), size);
+
+		ret &= test_SetPrinterDataEx(tctx, printername, keyname, valuename, handle, type, buffer, size);
+		ret &= test_GetPrinterDataEx(tctx, printername, keyname, valuename, handle, &type_ex, &buffer_ex, &size_ex);
+		if (ret == TRUE) {
+			if (!PrinterDataEqual(tctx, type_ex, type, size_ex, size, buffer_ex, buffer)) {
+				torture_warning(tctx, "GetPrinterDataEx does not return the same info as we set with SetPrinterDataEx");
+				ret = FALSE;
+			}
+		}
+		ret &= test_DeletePrinterDataEx(tctx, printername, keyname, valuename, handle);
+		ret &= test_DeletePrinterKey(tctx, printername, keyname, handle);
+
+		free(buffer);
 	}
-	buffer[0] = 'c';
-	buffer[1] = 'r';
-	buffer[2] = 'a';
-	buffer[3] = 'p';
-
-	ret &= test_SetPrinterDataEx(tctx, printername, keyname, valuename, handle, type, buffer, size);
-	ret &= test_GetPrinterDataEx(tctx, printername, keyname, valuename, handle, &type_ex, &buffer_ex, &size_ex);
-	if (ret == TRUE) {
-		ret &= PrinterDataEqual(tctx, type_ex, type, size_ex, size, buffer_ex, buffer);
 	}
-	ret &= test_DeletePrinterDataEx(tctx, printername, keyname, valuename, handle);
-	ret &= test_DeletePrinterKey(tctx, printername, keyname, handle);
-
-	free(buffer);
 
 	return TRUE;
 }


-- 
Samba Shared Repository


More information about the samba-cvs mailing list