r4299: Store REG_SZ, REG_EXPAND_SZ and REG_DWORD values in human-readable (and human...
authorJelmer Vernooij <jelmer@samba.org>
Tue, 21 Dec 2004 00:31:18 +0000 (00:31 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:07:32 +0000 (13:07 -0500)
the ldb registry backend.
(This used to be commit 6eafd055d1a7d45734a0112228e18ee59d1f7867)

source4/lib/registry/common/reg_util.c
source4/lib/registry/reg_backend_ldb.c
source4/registry.ldif

index 3da875ca0b62f9f6823974be1aefe0a1cb3a22a9..3a1736914408f3b2e181fe89ab923ee25f9513ef 100644 (file)
@@ -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:
index 9435da5dd6697f620dbb38e1eb74fb8670473960..f7b743fd7270cd7abfef5dc81c776eeb2947c785 100644 (file)
@@ -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); 
index 6775d19e07a80e28f2131f46da88d9cd37caea00..833ae9bafa93a5388a88505bcaf1d7bd62810726 100644 (file)
@@ -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=