1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-13 13:18:06 +03:00

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 6eafd055d1)
This commit is contained in:
Jelmer Vernooij 2004-12-21 00:31:18 +00:00 committed by Gerald (Jerry) Carter
parent 616cf70128
commit 9547649006
3 changed files with 37 additions and 7 deletions

View 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:

View 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);

View 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=