[SCM] Samba Shared Repository - branch master updated

Matthias Dieter Wallnöfer mdw at samba.org
Mon Mar 15 06:34:43 MDT 2010


The branch, master has been updated
       via  cc3eec1... s4:registry - util.c - treat unsupported and binary values as the same in the conversion functions
       via  4e6c0e1... s4:registry - util.c - move the "REG_NONE" case in the conversion functions on top of the switch
       via  1e5010d... s4:registry - local testsuite - add a test for REG_QWORD
       via  00934d4... s4:registry - fix up the output of hexadecimal values
       via  80300af... s4:registry - add support for REG_QWORD values
      from  c3eb509... s4-smbtorture: fix torture_comment in RPC-SPOOLSS.

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


- Log -----------------------------------------------------------------
commit cc3eec1681bb6d614e688f51e48bd76f6d513e67
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Mon Mar 15 11:15:19 2010 +0100

    s4:registry - util.c - treat unsupported and binary values as the same in the conversion functions
    
    We don't need to provide an extra representation for all available registry types.
    But if we treat all unsupported types as binary we also get our tools (regtree,
    regshell, regdiff...) working with them in a basic manner.

commit 4e6c0e1f6f37a7e04d10dbf7abbf626f52232aaf
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Mon Mar 15 11:12:52 2010 +0100

    s4:registry - util.c - move the "REG_NONE" case in the conversion functions on top of the switch
    
    (As in the "reg_value_types" structure)

commit 1e5010d35313d851a3904b116d3a4c2d3f0e199f
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Mon Mar 15 11:52:24 2010 +0100

    s4:registry - local testsuite - add a test for REG_QWORD
    
    Change also here to fixed-length HEX values output to test for the right
    representation.

commit 00934d4c2fd449493ad52127616445673f0de5b5
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Mon Mar 15 11:51:42 2010 +0100

    s4:registry - fix up the output of hexadecimal values
    
    Use a fixed-length representation to avoid platform-specific issues.

commit 80300af278d346049f9bfd48f013bc2055dc104b
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Mon Mar 15 11:07:36 2010 +0100

    s4:registry - add support for REG_QWORD values
    
    Basically the same as REG_DWORD but these are eight byte long.

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

Summary of changes:
 source4/lib/registry/ldb.c           |   67 +++++++++++++++++++++++++++++++++-
 source4/lib/registry/tests/generic.c |   16 ++++++++-
 source4/lib/registry/util.c          |   52 ++++++++++++--------------
 3 files changed, 105 insertions(+), 30 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c
index 9e77f1f..6676193 100644
--- a/source4/lib/registry/ldb.c
+++ b/source4/lib/registry/ldb.c
@@ -110,6 +110,33 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx,
 		}
 		break;
 
+	case REG_QWORD:
+		if (val != NULL) {
+			if (val->data[0] != '\0') {
+				/* The data is a plain QWORD */
+				uint64_t tmp = strtoull((char *)val->data, NULL, 0);
+				data->data = talloc_size(mem_ctx, sizeof(uint64_t) + 1);
+				if (data->data != NULL) {
+					SBVAL(data->data, 0, tmp);
+				}
+				data->length = sizeof(uint64_t);
+			} else {
+				/* Provide a possibility to store also UTF8
+				 * REG_QWORD values. This is done by adding a
+				 * '\0' in front of the data */
+				data->data = talloc_size(mem_ctx, val->length - 1);
+				if (data->data != NULL) {
+					memcpy(data->data, val->data + 1,
+					       val->length - 1);
+				}
+				data->length = val->length - 1;
+			}
+		} else {
+			data->data = NULL;
+			data->length = 0;
+		}
+		break;
+
 	case REG_BINARY:
 	default:
 		if (val != NULL) {
@@ -198,7 +225,7 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx,
 			if (data.length == sizeof(uint32_t)) {
 				char *conv_str;
 
-				conv_str = talloc_asprintf(msg, "0x%x", IVAL(data.data, 0));
+				conv_str = talloc_asprintf(msg, "0x%8.8x", IVAL(data.data, 0));
 				if (conv_str == NULL) {
 					talloc_free(msg);
 					return NULL;
@@ -231,6 +258,44 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx,
 		}
 		break;
 
+	case REG_QWORD:
+		if ((data.length > 0) && (data.data != NULL)) {
+			if (data.length == sizeof(uint64_t)) {
+				char *conv_str;
+
+				conv_str = talloc_asprintf(msg, "0x%16.16llx", BVAL(data.data, 0));
+				if (conv_str == NULL) {
+					talloc_free(msg);
+					return NULL;
+				}
+				ret = ldb_msg_add_string(msg, "data", conv_str);
+			} else {
+				/* Provide a possibility to store also UTF8
+				 * REG_QWORD values. This is done by adding a
+				 * '\0' in front of the data */
+				struct ldb_val *val;
+
+				val = talloc_zero(msg, struct ldb_val);
+				if (val == NULL) {
+					talloc_free(msg);
+					return NULL;
+				}
+
+				val->data = talloc_size(msg, data.length + 1);
+				if (val->data == NULL) {
+					talloc_free(msg);
+					return NULL;
+				}
+				val->data[0] = '\0';
+				memcpy(val->data + 1, data.data, data.length);
+				val->length = data.length + 1;
+				ret = ldb_msg_add_value(msg, "data", val, NULL);
+			}
+		} else {
+			ret = ldb_msg_add_empty(msg, "data", LDB_FLAG_MOD_DELETE, NULL);
+		}
+		break;
+
 	case REG_BINARY:
 	default:
 		if ((data.length > 0) && (data.data != NULL)
diff --git a/source4/lib/registry/tests/generic.c b/source4/lib/registry/tests/generic.c
index 3de7602..a881c3d 100644
--- a/source4/lib/registry/tests/generic.c
+++ b/source4/lib/registry/tests/generic.c
@@ -35,6 +35,8 @@ static bool test_str_regtype(struct torture_context *ctx)
 				 "REG_SZ", "REG_SZ failed");
 	torture_assert_str_equal(ctx, str_regtype(4),
 				 "REG_DWORD", "REG_DWORD failed");
+	torture_assert_str_equal(ctx, str_regtype(11),
+				 "REG_QWORD", "REG_QWORD failed");
 
 	return true;
 }
@@ -44,12 +46,22 @@ static bool test_reg_val_data_string_dword(struct torture_context *ctx)
 {
 	uint32_t d = 0x20;
 	DATA_BLOB db = { (uint8_t *)&d, sizeof(d) };
-	torture_assert_str_equal(ctx, "0x20",
+	torture_assert_str_equal(ctx, "0x00000020",
 				 reg_val_data_string(ctx, lp_iconv_convenience(ctx->lp_ctx), REG_DWORD, db),
 				 "dword failed");
 	return true;
 }
 
+static bool test_reg_val_data_string_qword(struct torture_context *ctx)
+{
+	uint64_t d = 0x20;
+	DATA_BLOB db = { (uint8_t *)&d, sizeof(d) };
+	torture_assert_str_equal(ctx, "0x0000000000000020",
+				 reg_val_data_string(ctx, lp_iconv_convenience(ctx->lp_ctx), REG_QWORD, db),
+				 "qword failed");
+	return true;
+}
+
 static bool test_reg_val_data_string_sz(struct torture_context *ctx)
 {
 	DATA_BLOB db;
@@ -119,6 +131,8 @@ struct torture_suite *torture_registry(TALLOC_CTX *mem_ctx)
 				      test_str_regtype);
 	torture_suite_add_simple_test(suite, "reg_val_data_string dword",
 				      test_reg_val_data_string_dword);
+	torture_suite_add_simple_test(suite, "reg_val_data_string qword",
+				      test_reg_val_data_string_qword);
 	torture_suite_add_simple_test(suite, "reg_val_data_string sz",
 				      test_reg_val_data_string_sz);
 	torture_suite_add_simple_test(suite, "reg_val_data_string binary",
diff --git a/source4/lib/registry/util.c b/source4/lib/registry/util.c
index 6ff6194..fd75f91 100644
--- a/source4/lib/registry/util.c
+++ b/source4/lib/registry/util.c
@@ -69,6 +69,9 @@ _PUBLIC_ char *reg_val_data_string(TALLOC_CTX *mem_ctx,
 		return talloc_strdup(mem_ctx, "");
 
 	switch (type) {
+		case REG_NONE:
+			/* "NULL" is the right return value */
+			break;
 		case REG_EXPAND_SZ:
 		case REG_SZ:
 			if (data.length % 2 == 0) {
@@ -81,28 +84,21 @@ _PUBLIC_ char *reg_val_data_string(TALLOC_CTX *mem_ctx,
 								  NULL, false);
 			}
 			break;
-		case REG_BINARY:
-			ret = data_blob_hex_string_upper(mem_ctx, &data);
-			break;
 		case REG_DWORD:
 			if (data.length == sizeof(uint32_t)) {
-				if (IVAL(data.data, 0) == 0) {
-					ret = talloc_strdup(mem_ctx, "0");
-				} else {
-					ret = talloc_asprintf(mem_ctx, "0x%x",
-							      IVAL(data.data, 0));
-				}
+				ret = talloc_asprintf(mem_ctx, "0x%8.8x",
+						      IVAL(data.data, 0));
 			}
 			break;
-		case REG_NONE:
-			/* "NULL" is the right return value */
-			break;
-		case REG_MULTI_SZ:
-			/* FIXME: We don't support this yet */
+		case REG_QWORD:
+			if (data.length == sizeof(uint64_t)) {
+				ret = talloc_asprintf(mem_ctx, "0x%16.16llx",
+						      BVAL(data.data, 0));
+			}
 			break;
+		case REG_BINARY:
 		default:
-			/* FIXME */
-			/* Other datatypes aren't supported -> return "NULL" */
+			ret = data_blob_hex_string_upper(mem_ctx, &data);
 			break;
 	}
 
@@ -144,6 +140,9 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx,
 	/* Convert data appropriately */
 
 	switch (*type) {
+		case REG_NONE:
+			ZERO_STRUCTP(data);
+			break;
 		case REG_SZ:
 		case REG_EXPAND_SZ:
 			convert_string_talloc_convenience(mem_ctx,
@@ -154,25 +153,22 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx,
 							  (void **)&data->data,
 							  &data->length, false);
 			break;
-		case REG_BINARY:
-			*data = strhex_to_data_blob(mem_ctx, data_str);
-			break;
 		case REG_DWORD: {
 			uint32_t tmp = strtol(data_str, NULL, 0);
-			*data = data_blob_talloc(mem_ctx, NULL, 4);
+			*data = data_blob_talloc(mem_ctx, NULL, sizeof(uint32_t));
 			SIVAL(data->data, 0, tmp);
 			}
 			break;
-		case REG_NONE:
-			ZERO_STRUCTP(data);
+		case REG_QWORD: {
+			uint64_t tmp = strtoll(data_str, NULL, 0);
+			*data = data_blob_talloc(mem_ctx, NULL, sizeof(uint64_t));
+			SBVAL(data->data, 0, tmp);
+			}
 			break;
-		case REG_MULTI_SZ:
-			/* FIXME: We don't support this yet */
-			return false;
+		case REG_BINARY:
 		default:
-			/* FIXME */
-			/* Other datatypes aren't supported -> return no success */
-			return false;
+			*data = strhex_to_data_blob(mem_ctx, data_str);
+			break;
 	}
 	return true;
 }


-- 
Samba Shared Repository


More information about the samba-cvs mailing list