svn commit: samba r4299 - in branches/SAMBA_4_0/source: . lib/registry lib/registry/common

jelmer at samba.org jelmer at samba.org
Tue Dec 21 00:31:19 GMT 2004


Author: jelmer
Date: 2004-12-21 00:31:18 +0000 (Tue, 21 Dec 2004)
New Revision: 4299

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4299

Log:
Store REG_SZ, REG_EXPAND_SZ and REG_DWORD values in human-readable (and human-editable) format in
the ldb registry backend.

Modified:
   branches/SAMBA_4_0/source/lib/registry/common/reg_util.c
   branches/SAMBA_4_0/source/lib/registry/reg_backend_ldb.c
   branches/SAMBA_4_0/source/registry.ldif


Changeset:
Modified: branches/SAMBA_4_0/source/lib/registry/common/reg_util.c
===================================================================
--- branches/SAMBA_4_0/source/lib/registry/common/reg_util.c	2004-12-21 00:01:02 UTC (rev 4298)
+++ branches/SAMBA_4_0/source/lib/registry/common/reg_util.c	2004-12-21 00:31:18 UTC (rev 4299)
@@ -124,7 +124,7 @@
 		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:

Modified: branches/SAMBA_4_0/source/lib/registry/reg_backend_ldb.c
===================================================================
--- branches/SAMBA_4_0/source/lib/registry/reg_backend_ldb.c	2004-12-21 00:01:02 UTC (rev 4298)
+++ branches/SAMBA_4_0/source/lib/registry/reg_backend_ldb.c	2004-12-21 00:31:18 UTC (rev 4299)
@@ -42,8 +42,25 @@
 	*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,10 +70,23 @@
 	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); 
 

Modified: branches/SAMBA_4_0/source/registry.ldif
===================================================================
--- branches/SAMBA_4_0/source/registry.ldif	2004-12-21 00:01:02 UTC (rev 4298)
+++ branches/SAMBA_4_0/source/registry.ldif	2004-12-21 00:31:18 UTC (rev 4299)
@@ -6,7 +6,7 @@
 
 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=



More information about the samba-cvs mailing list