summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2004-12-21 00:31:18 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:07:32 -0500
commit9547649006770022bdcddcc319b81b555222f1c4 (patch)
treec3bd1f666fa05d9b14cb278a8281e2b433db0292
parent616cf701281331bf0bcad56cbfd22ca22576e3d1 (diff)
downloadsamba-9547649006770022bdcddcc319b81b555222f1c4.tar.gz
samba-9547649006770022bdcddcc319b81b555222f1c4.tar.bz2
samba-9547649006770022bdcddcc319b81b555222f1c4.zip
r4299: Store REG_SZ, REG_EXPAND_SZ and REG_DWORD values in human-readable (and human-editable) format in
the ldb registry backend. (This used to be commit 6eafd055d1a7d45734a0112228e18ee59d1f7867)
-rw-r--r--source4/lib/registry/common/reg_util.c2
-rw-r--r--source4/lib/registry/reg_backend_ldb.c40
-rw-r--r--source4/registry.ldif2
3 files changed, 37 insertions, 7 deletions
diff --git a/source4/lib/registry/common/reg_util.c b/source4/lib/registry/common/reg_util.c
index 3da875ca0b..3a17369144 100644
--- a/source4/lib/registry/common/reg_util.c
+++ b/source4/lib/registry/common/reg_util.c
@@ -124,7 +124,7 @@ BOOL reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str, const char *da
case REG_DWORD:
(*value)->data_len = sizeof(uint32);
(*value)->data_blk = talloc_p(mem_ctx, uint32);
- *((uint32 *)(*value)->data_blk) = atol(data_str);
+ *((uint32 *)(*value)->data_blk) = strtol(data_str, NULL, 0);
break;
case REG_NONE:
diff --git a/source4/lib/registry/reg_backend_ldb.c b/source4/lib/registry/reg_backend_ldb.c
index 9435da5dd6..f7b743fd72 100644
--- a/source4/lib/registry/reg_backend_ldb.c
+++ b/source4/lib/registry/reg_backend_ldb.c
@@ -42,8 +42,25 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, struct ldb_message *msg, c
*name = talloc_strdup(mem_ctx, ldb_msg_find_string(msg, "value", NULL));
*type = ldb_msg_find_uint(msg, "type", 0);
val = ldb_msg_find_ldb_val(msg, "data");
- *data = talloc_memdup(mem_ctx, val->data, val->length);
- *len = val->length;
+
+ switch (*type)
+ {
+ case REG_SZ:
+ case REG_EXPAND_SZ:
+ *len = convert_string_talloc(mem_ctx, CH_UTF8, CH_UTF16, val->data, val->length, data);
+ break;
+
+ case REG_DWORD_LE:
+ *len = 4;
+ *data = talloc_p(mem_ctx, uint32);
+ SIVAL(*data, 0, strtol(val->data, NULL, 0));
+ break;
+
+ default:
+ *data = talloc_memdup(mem_ctx, val->data, val->length);
+ *len = val->length;
+ break;
+ }
}
static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx, TALLOC_CTX *mem_ctx, const char *name, uint32 type, void *data, int len)
@@ -53,9 +70,22 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx, TALLOC_CT
char *type_s;
ldb_msg_add_string(ctx, msg, "value", talloc_strdup(mem_ctx, name));
- val.length = len;
- val.data = data;
- ldb_msg_add_value(ctx, msg, "data", &val);
+
+ switch (type) {
+ case REG_SZ:
+ case REG_EXPAND_SZ:
+ val.length = convert_string_talloc(mem_ctx, CH_UTF16, CH_UTF8, data, len, &val.data);
+ ldb_msg_add_value(ctx, msg, "data", &val);
+ break;
+ case REG_DWORD_LE:
+ ldb_msg_add_string(ctx, msg, "data", talloc_asprintf(mem_ctx, "0x%x", IVAL(data, 0)));
+ break;
+ default:
+ val.length = len;
+ val.data = data;
+ ldb_msg_add_value(ctx, msg, "data", &val);
+ }
+
type_s = talloc_asprintf(mem_ctx, "%u", type);
ldb_msg_add_string(ctx, msg, "type", type_s);
diff --git a/source4/registry.ldif b/source4/registry.ldif
index 6775d19e07..833ae9bafa 100644
--- a/source4/registry.ldif
+++ b/source4/registry.ldif
@@ -6,7 +6,7 @@ key: services
dn: value=ProductType,key=productoptions,key=control,key=currentcontrolset,key=system,hive=
value: ProductType
-data:: VwBpAG4ATgBUAA=
+data: WinNT
type: 1
dn: key=productoptions,key=control,key=currentcontrolset,key=system,hive=