[SCM] Samba Shared Repository - branch master updated - febd55b1bfb3a93d905bb1a1903fc28e88d2a497

Jelmer Vernooij jelmer at samba.org
Tue Oct 21 13:55:11 GMT 2008


The branch, master has been updated
       via  febd55b1bfb3a93d905bb1a1903fc28e88d2a497 (commit)
       via  fdf0d9bbb89155e5bd793729468dc457448054e5 (commit)
       via  19aec78aec846e5f66b3930a4053beea30318c4a (commit)
       via  d4d4a9da832a4c0c5bb080eb3b7c837fc57da31d (commit)
       via  5209a846a9157e649fcdcb561f7eaf19c8c0e465 (commit)
       via  625359b2e266105022309df8985720108ecd6f67 (commit)
       via  fcc93f68a0d87d3f938bdd6ecd6dc91c6ab648d5 (commit)
       via  80af62652b268c9a85fe30ede503924743cfdbde (commit)
       via  828b033345a93d8d4273dd32265f14b4164fc1e0 (commit)
       via  47868196b8f989492e0e5c47f384a713791be683 (commit)
       via  2a267e6da524c5dc69b3e2d97114f17461567856 (commit)
       via  f10227958bef70df7609aeec5dcc834a601bd945 (commit)
       via  f9d7af8569eb7163ab9fe301d759c0c35e68a9bc (commit)
       via  254eb51c4cc1273ada1182f052f8e66fd9124e25 (commit)
       via  083785c0919b635601fdfc23c6dcc9368fa14a0d (commit)
       via  c26cb44e0328aaba1d81cb4bd09b37252c7a725b (commit)
       via  b23c3c24c2ffa8c8fa73ae90947d7e0a01b796c0 (commit)
       via  5f2ab665bd8d17ca7c204a9720e06895874ad2ef (commit)
       via  ac4808c11f1dced2757deda9ebf28c6cb4e3ba57 (commit)
       via  e23e99764436b9a8432dd6552d12c3ad82a27362 (commit)
       via  f58f74949d1c596a9c696dc71b325f7d4475fc5f (commit)
       via  036b650ee4b4b32859c8ccfa797b20bbaa9a23e6 (commit)
       via  1938cb1e834499aa6e6c8290861dbd233184156a (commit)
       via  d7be73eea2c8a55b3dbe95c9c576701e4b1c7f7d (commit)
       via  ad778c00e7307c2e14271f641d75ff05f3ec5d1e (commit)
       via  16ab396d526546c2a55114cbac0e779aa6420601 (commit)
      from  5cc4a84583d027b54e26a9c42a89b7b8a6b6c67d (commit)

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


- Log -----------------------------------------------------------------
commit febd55b1bfb3a93d905bb1a1903fc28e88d2a497
Merge: fdf0d9bbb89155e5bd793729468dc457448054e5 5cc4a84583d027b54e26a9c42a89b7b8a6b6c67d
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Oct 21 15:53:28 2008 +0200

    Merge branch 'master' of ssh://git.samba.org/data/git/samba into regsrv

commit fdf0d9bbb89155e5bd793729468dc457448054e5
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Oct 21 15:51:04 2008 +0200

    Fix double free.

commit 19aec78aec846e5f66b3930a4053beea30318c4a
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Oct 21 15:47:34 2008 +0200

    Fix the build.

commit d4d4a9da832a4c0c5bb080eb3b7c837fc57da31d
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Oct 21 14:57:41 2008 +0200

    Revert "Registry server LDB backend: Don't make copies of the same type"
    
    The original data pointer may go away so we do want to make copies in
    this case.
    
    This reverts commit 625359b2e266105022309df8985720108ecd6f67.

commit 5209a846a9157e649fcdcb561f7eaf19c8c0e465
Merge: 625359b2e266105022309df8985720108ecd6f67 2ee8d29d22bcb1c350ab59d71b0aee548489bc9c
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Oct 21 14:51:13 2008 +0200

    Merge branch 'master' of ssh://git.samba.org/data/git/samba into regsrv
    
    Conflicts:
    	source4/lib/registry/ldb.c
    	source4/rpc_server/winreg/rpc_winreg.c

commit 625359b2e266105022309df8985720108ecd6f67
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Fri Sep 19 12:48:15 2008 +0200

    Registry server LDB backend: Don't make copies of the same type

commit fcc93f68a0d87d3f938bdd6ecd6dc91c6ab648d5
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Fri Sep 19 12:39:53 2008 +0200

    Registry server LDB backend REG_BINARY type: Save it directly in LDB
    
    With this patch the REG_BINARY type is saved directly in a LDB registry database rather than converted in a hex-string.

commit 80af62652b268c9a85fe30ede503924743cfdbde
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Fri Sep 19 12:29:38 2008 +0200

    Registry RPC server: Reintroduce the "key" variable for better readability
    
    The "key" variable points to our working key in the hive (h->data).

commit 828b033345a93d8d4273dd32265f14b4164fc1e0
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Thu Sep 18 19:52:52 2008 +0200

    Registry server LDB backend REG_SZ type: Always use UTF8 encoding
    
    We should save data OS independent in the LDB files.

commit 47868196b8f989492e0e5c47f384a713791be683
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Thu Sep 18 16:51:48 2008 +0200

    Registry server LDB backend REG_SZ type: Fix up the empty string problem
    
    This fixes up the empty string problem in a better way without the need of changing the character conversion code.

commit 2a267e6da524c5dc69b3e2d97114f17461567856
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Thu Sep 18 16:15:05 2008 +0200

    Revert "Fix for the empty string (REG_SZ) problem"
    
    This reverts commit d994520885301f1dfd04363bab05c9238ce5ae05.
    This shouldn't be fixed in the general character conversion library but directly in the registry library.

commit f10227958bef70df7609aeec5dcc834a601bd945
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Mon Sep 15 19:21:38 2008 +0200

    Registry server: Fixes up the patch with "type" != NULL (used in "EnumValue" and "QueryValue")
    
    This prevents the server to segfault if the input data type is NULL.

commit f9d7af8569eb7163ab9fe301d759c0c35e68a9bc
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Mon Sep 15 19:14:31 2008 +0200

    Revert "Registry server: Enhances commit "type" != NULL (when getting values)"
    
    This reverts commit 32d00f5e2c5a67dac806ee07f030f3ac2ad108f9.
    This patch hasn't been right. Repost it in the right way.

commit 254eb51c4cc1273ada1182f052f8e66fd9124e25
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Mon Sep 15 18:28:11 2008 +0200

    Registry server: Enhances commit "type" != NULL (when getting values)

commit 083785c0919b635601fdfc23c6dcc9368fa14a0d
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Mon Sep 15 18:21:45 2008 +0200

    Registry server "reg_ldb_unpack_value": Tests demonstrate that also "type" doesn't has to be NULL

commit c26cb44e0328aaba1d81cb4bd09b37252c7a725b
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Mon Sep 15 17:21:35 2008 +0200

    Revert "Registry server "reg_ldb_unpack_value": Let "data" pointer be NULL"
    
    This reverts commit 82f50ea69f3aece4ac654ffdfa627babd8aadc25.
    Cause: Windows (2000) doesn't accept the "data" pointer set to NULL

commit b23c3c24c2ffa8c8fa73ae90947d7e0a01b796c0
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Mon Sep 15 15:13:25 2008 +0200

    Registry server "reg_ldb_unpack_value": Let "data" pointer be NULL
    
    Prevent segfaults in some client applications (e.g. regdiff)

commit 5f2ab665bd8d17ca7c204a9720e06895874ad2ef
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Mon Sep 15 12:27:10 2008 +0200

    Registry server: Cosmetic corrections

commit ac4808c11f1dced2757deda9ebf28c6cb4e3ba57
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Sun Sep 14 03:51:35 2008 +0200

    Cleanups of server files
    
    Cosmetic corrections

commit e23e99764436b9a8432dd6552d12c3ad82a27362
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Sat Sep 13 13:32:39 2008 +0200

    Registry server: More work to be compatible
    
    Some fixup's and assure, that we send only initialized values.

commit f58f74949d1c596a9c696dc71b325f7d4475fc5f
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Sat Sep 13 12:10:00 2008 +0200

    ldb_get_value_by_id: Fix the return of the default value
    
    The return of the values of a certain key has been broken since I've introduced the default value.
    Now the behaviour is correct: If no default value exists, start with index zero to fetch the other values. Otherwise let zero be the default value and enumerate the others starting with one.

commit 036b650ee4b4b32859c8ccfa797b20bbaa9a23e6
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Fri Sep 12 18:36:04 2008 +0200

    reg_ldb_unpack_value: Change "CH_UTF8" in "CH_UNIX"
    
    It's better to use "CH_UNIX" for unpacking, because the system charset doesn't have to be UTF8 and we should be compatible with "reg_ldb_pack_value".

commit 1938cb1e834499aa6e6c8290861dbd233184156a
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Fri Sep 12 16:31:57 2008 +0200

    ldb_del_value: Free key data also when removing the default attribute

commit d7be73eea2c8a55b3dbe95c9c576701e4b1c7f7d
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Tue Sep 9 17:54:08 2008 +0200

    Fixes for the WINREG RPC server
    
    This changes the WINREG RPC server through some corrections into the Windows-like behaviour.
    Compared with Windows 2000 and tested through Windows 2000 Registry Editor.

commit ad778c00e7307c2e14271f641d75ff05f3ec5d1e
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Tue Sep 9 17:49:41 2008 +0200

    Fix for allowing the REG_BINARY type and introducing the default attribute
    
    The REG_BINARY type is converted and stored in the LDB database as a leaf object with string-data.
    The default attribute is saved directly in the hive object as the "data"-string.

commit 16ab396d526546c2a55114cbac0e779aa6420601
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Tue Sep 9 17:44:41 2008 +0200

    Fix for the empty string (REG_SZ) problem
    
    I enhanced the "utf8_push" function, who finally accepts now also the char sequence "" with length 1 as valid UTF8 string.

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

Summary of changes:
 source4/lib/registry/ldb.c             |  222 ++++++++++++++++++++++++--------
 source4/rpc_server/winreg/rpc_winreg.c |  206 +++++++++++++++++-------------
 2 files changed, 284 insertions(+), 144 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c
index 25b8c58..7d78ba1 100644
--- a/source4/lib/registry/ldb.c
+++ b/source4/lib/registry/ldb.c
@@ -1,7 +1,8 @@
 /*
    Unix SMB/CIFS implementation.
    Registry interface
-   Copyright (C) Jelmer Vernooij  2004-2007.
+   Copyright (C) 2004-2007, Jelmer Vernooij, jelmer at samba.org
+   Copyright (C) 2008 Matthias Dieter Wallnöfer, mwallnoefer at yahoo.de
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -51,17 +52,31 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx,
 				      NULL));
 
 	value_type = ldb_msg_find_attr_as_uint(msg, "type", 0);
-	if (type != NULL)
-		*type = value_type; 
+	*type = value_type; 
+
 	val = ldb_msg_find_ldb_val(msg, "data");
 
 	switch (value_type)
 	{
 	case REG_SZ:
 	case REG_EXPAND_SZ:
-		data->length = convert_string_talloc(mem_ctx, iconv_convenience, CH_UTF8, CH_UTF16,
+		if (val != NULL)
+			data->length = convert_string_talloc(mem_ctx, iconv_convenience, CH_UTF8, CH_UTF16,
 						     val->data, val->length,
 						     (void **)&data->data);
+		else {
+			data->data = NULL;
+			data->length = 0;
+		}
+		break;
+
+	case REG_BINARY:
+		if (val != NULL)
+			*data = data_blob_talloc(mem_ctx, val->data, val->length);
+		else {
+			data->data = NULL;
+			data->length = 0;
+		}
 		break;
 
 	case REG_DWORD: {
@@ -90,11 +105,22 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx,
 	switch (type) {
 	case REG_SZ:
 	case REG_EXPAND_SZ:
-		val.length = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX,
+		if (data.data[0] != '\0') {
+			val.length = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UTF8,
 						   (void *)data.data,
 						   data.length,
 						   (void **)&val.data);
-		ldb_msg_add_value(msg, "data", &val, NULL);
+			ldb_msg_add_value(msg, "data", &val, NULL);
+		} else {
+			ldb_msg_add_empty(msg, "data", LDB_FLAG_MOD_DELETE, NULL);
+		}
+		break;
+
+	case REG_BINARY:
+		if (data.length > 0)
+			ldb_msg_add_value(msg, "data", &data, NULL);
+		else
+			ldb_msg_add_empty(msg, "data", LDB_FLAG_MOD_DELETE, NULL);
 		break;
 
 	case REG_DWORD:
@@ -228,9 +254,11 @@ static WERROR cache_values(struct ldb_key_data *kd)
 			ldb_dn_get_linearized(kd->dn), ldb_errstring(c)));
 		return WERR_FOOBAR;
 	}
+
 	kd->value_count = res->count;
 	kd->values = talloc_steal(kd, res->msgs);
 	talloc_free(res);
+
 	return WERR_OK;
 }
 
@@ -243,6 +271,15 @@ static WERROR ldb_get_subkey_by_id(TALLOC_CTX *mem_ctx,
 {
 	struct ldb_message_element *el;
 	struct ldb_key_data *kd = talloc_get_type(k, struct ldb_key_data);
+	
+	/* Initialization */
+	if (name != NULL)
+		*name = NULL;
+	if (classname != NULL)
+		*classname = NULL; /* TODO: Store properly */
+	if (last_mod_time != NULL)
+		*last_mod_time = 0; /* TODO: we need to add this to the
+						ldb backend properly */
 
 	/* Do a search if necessary */
 	if (kd->subkeys == NULL) {
@@ -259,12 +296,34 @@ static WERROR ldb_get_subkey_by_id(TALLOC_CTX *mem_ctx,
 	if (name != NULL)
 		*name = talloc_strdup(mem_ctx, (char *)el->values[0].data);
 
-	if (classname != NULL)
-		*classname = NULL; /* TODO: Store properly */
+	return WERR_OK;
+}
 
-	if (last_mod_time != NULL)
-		*last_mod_time = 0; /* TODO: we need to add this to the
-						ldb backend properly */
+static WERROR ldb_get_default_value(TALLOC_CTX *mem_ctx, struct hive_key *k,
+				  const char **name, uint32_t *data_type,
+				   DATA_BLOB *data)
+{
+	struct ldb_key_data *kd = talloc_get_type(k, struct ldb_key_data);
+	struct ldb_context *c = kd->ldb;
+	const char* attrs[] = { "data", "type", NULL };
+	struct ldb_result *res;
+	int ret;
+
+	ret = ldb_search(c, mem_ctx, &res, kd->dn, LDB_SCOPE_BASE, attrs, "%s", "");
+
+	if (ret != LDB_SUCCESS) {
+		DEBUG(0, ("Error getting default value for '%s': %s\n",
+			ldb_dn_get_linearized(kd->dn), ldb_errstring(c)));
+		return WERR_FOOBAR;
+	}
+
+	if (res->count == 0 || res->msgs[0]->num_elements == 0)
+		return WERR_BADFILE;
+
+	reg_ldb_unpack_value(mem_ctx, lp_iconv_convenience(global_loadparm),
+		 res->msgs[0], name, data_type, data);
+
+	talloc_free(res);
 
 	return WERR_OK;
 }
@@ -275,6 +334,15 @@ static WERROR ldb_get_value_by_id(TALLOC_CTX *mem_ctx, struct hive_key *k,
 {
 	struct ldb_key_data *kd = talloc_get_type(k, struct ldb_key_data);
 
+	/* if default value exists, give it back */
+	if (W_ERROR_IS_OK(ldb_get_default_value(mem_ctx, k, name, data_type,
+		data))) {
+		if (idx == 0)
+			return WERR_OK;
+		else
+			--idx;
+	}
+
 	/* Do the search if necessary */
 	if (kd->values == NULL) {
 		W_ERROR_NOT_OK_RETURN(cache_values(kd));
@@ -283,8 +351,8 @@ static WERROR ldb_get_value_by_id(TALLOC_CTX *mem_ctx, struct hive_key *k,
 	if (idx >= kd->value_count)
 		return WERR_NO_MORE_ITEMS;
 
-	reg_ldb_unpack_value(mem_ctx, lp_iconv_convenience(global_loadparm), kd->values[idx],
-			     name, data_type, data);
+	reg_ldb_unpack_value(mem_ctx, lp_iconv_convenience(global_loadparm),
+			 kd->values[idx], name, data_type, data);
 
 	return WERR_OK;
 }
@@ -297,27 +365,32 @@ static WERROR ldb_get_value(TALLOC_CTX *mem_ctx, struct hive_key *k,
 	struct ldb_context *c = kd->ldb;
 	struct ldb_result *res;
 	int ret;
-	char *query = talloc_asprintf(mem_ctx, "(value=%s)", name);
+	char *query;
 
-	ret = ldb_search(c, mem_ctx, &res, kd->dn, LDB_SCOPE_ONELEVEL, NULL, "%s", query);
+	if (strlen(name) == 0) {
+		/* default value */
+		return ldb_get_default_value(mem_ctx, k, NULL, data_type, data);
+	} else {
+		/* normal value */
+		query = talloc_asprintf(mem_ctx, "(value=%s)", name);
+		ret = ldb_search(c, mem_ctx, &res, kd->dn, LDB_SCOPE_ONELEVEL, NULL, "%s", query);
+		talloc_free(query);
+
+		if (ret != LDB_SUCCESS) {
+			DEBUG(0, ("Error getting values for '%s': %s\n",
+				ldb_dn_get_linearized(kd->dn), ldb_errstring(c)));
+			return WERR_FOOBAR;
+		}
 
-	talloc_free(query);
+		if (res->count == 0)
+			return WERR_BADFILE;
 
-	if (ret != LDB_SUCCESS) {
-		DEBUG(0, ("Error getting values for '%s': %s\n",
-			ldb_dn_get_linearized(kd->dn), ldb_errstring(c)));
-		talloc_free(res);
-		return WERR_FOOBAR;
-	}
+		reg_ldb_unpack_value(mem_ctx, lp_iconv_convenience(global_loadparm),
+			 res->msgs[0], NULL, data_type, data);
 
-	if (res->count == 0) {
 		talloc_free(res);
-		return WERR_BADFILE;
 	}
 
-	reg_ldb_unpack_value(mem_ctx, lp_iconv_convenience(global_loadparm), res->msgs[0], NULL, data_type, data);
-
-	talloc_free(res);
 	return WERR_OK;
 }
 
@@ -353,8 +426,6 @@ static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h,
 
 	*key = (struct hive_key *)newkd;
 
-	talloc_free(res);
-
 	return WERR_OK;
 }
 
@@ -451,25 +522,47 @@ static WERROR ldb_del_value (struct hive_key *key, const char *child)
 {
 	int ret;
 	struct ldb_key_data *kd = talloc_get_type(key, struct ldb_key_data);
+	TALLOC_CTX *mem_ctx;
+	struct ldb_message *msg;
 	struct ldb_dn *childdn;
 
-	childdn = ldb_dn_copy(kd->ldb, kd->dn);
-	if (!ldb_dn_add_child_fmt(childdn, "value=%s",
+	if (strlen(child) == 0) {
+		/* default value */
+		mem_ctx = talloc_init("ldb_del_value");
+
+		msg = talloc_zero(mem_ctx, struct ldb_message);
+		msg->dn = ldb_dn_copy(msg, kd->dn);
+		ldb_msg_add_empty(msg, "data", LDB_FLAG_MOD_DELETE, NULL);
+		ldb_msg_add_empty(msg, "type", LDB_FLAG_MOD_DELETE, NULL);
+
+		ret = ldb_modify(kd->ldb, msg);
+		if (ret != LDB_SUCCESS) {
+			DEBUG(1, ("ldb_del_value: %s\n", ldb_errstring(kd->ldb)));
+			talloc_free(mem_ctx);
+			return WERR_FOOBAR;
+		}
+
+		talloc_free(mem_ctx);
+	} else {
+		/* normal value */
+		childdn = ldb_dn_copy(kd->ldb, kd->dn);
+		if (!ldb_dn_add_child_fmt(childdn, "value=%s",
 				  reg_ldb_escape(childdn, child)))
-	{
-		talloc_free(childdn);
-		return WERR_FOOBAR;
-	}
+		{
+			talloc_free(childdn);
+			return WERR_FOOBAR;
+		}
 
-	ret = ldb_delete(kd->ldb, childdn);
+		ret = ldb_delete(kd->ldb, childdn);
 
-	talloc_free(childdn);
+		talloc_free(childdn);
 
-	if (ret == LDB_ERR_NO_SUCH_OBJECT) {
-		return WERR_BADFILE;
-	} else if (ret != LDB_SUCCESS) {
-		DEBUG(1, ("ldb_del_value: %s\n", ldb_errstring(kd->ldb)));
-		return WERR_FOOBAR;
+		if (ret == LDB_ERR_NO_SUCH_OBJECT) {
+			return WERR_BADFILE;
+		} else if (ret != LDB_SUCCESS) {
+			DEBUG(1, ("ldb_del_value: %s\n", ldb_errstring(kd->ldb)));
+			return WERR_FOOBAR;
+		}
 	}
 
 	/* reset cache */
@@ -605,26 +698,31 @@ static WERROR ldb_set_value(struct hive_key *parent,
 	TALLOC_CTX *mem_ctx = talloc_init("ldb_set_value");
 
 	msg = reg_ldb_pack_value(kd->ldb, mem_ctx, name, type, data);
-
 	msg->dn = ldb_dn_copy(msg, kd->dn);
-	if (!ldb_dn_add_child_fmt(msg->dn, "value=%s",
+	
+	if (strlen(name) > 0) {
+		/* For a default value, we add/overwrite the attributes to/of the hive.
+ 		   For a normal value, we create new childs. */
+		if (!ldb_dn_add_child_fmt(msg->dn, "value=%s",
 				  reg_ldb_escape(mem_ctx, name)))
-	{
-		talloc_free(mem_ctx);
-		return WERR_FOOBAR;
+		{
+			talloc_free(mem_ctx);
+			return WERR_FOOBAR;
+		}
 	}
 
 	ret = ldb_add(kd->ldb, msg);
 	if (ret == LDB_ERR_ENTRY_ALREADY_EXISTS) {
 		int i;
 		for (i = 0; i < msg->num_elements; i++) {
-			msg->elements[i].flags = LDB_FLAG_MOD_REPLACE;
+			if (msg->elements[i].flags != LDB_FLAG_MOD_DELETE)
+				msg->elements[i].flags = LDB_FLAG_MOD_REPLACE;
 		}
 		ret = ldb_modify(kd->ldb, msg);
 	}
 
 	if (ret != LDB_SUCCESS) {
-		DEBUG(1, ("ldb_msg_add: %s\n", ldb_errstring(kd->ldb)));
+		DEBUG(1, ("ldb_set_value: %s\n", ldb_errstring(kd->ldb)));
 		talloc_free(mem_ctx);
 		return WERR_FOOBAR;
 	}
@@ -649,6 +747,22 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx,
 {
 	struct ldb_key_data *kd = talloc_get_type(key, struct ldb_key_data);
 
+	/* Initialization */
+	if (classname != NULL)
+		*classname = NULL;
+	if (num_subkeys != NULL)
+		*num_subkeys = 0;
+	if (num_values != NULL)
+		*num_values = 0;
+	if (last_change_time != NULL)
+		*last_change_time = 0;
+	if (max_subkeynamelen != NULL)
+		*max_subkeynamelen = 0;
+	if (max_valnamelen != NULL)
+		*max_valnamelen = 0;
+	if (max_valbufsize != NULL)
+		*max_valbufsize = 0;
+
 	if (kd->subkeys == NULL) {
 		W_ERROR_NOT_OK_RETURN(cache_subkeys(kd));
 	}
@@ -657,20 +771,13 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx,
 		W_ERROR_NOT_OK_RETURN(cache_values(kd));
 	}
 
-	/* FIXME */
-	if (classname != NULL)
-		*classname = NULL;
-
 	if (num_subkeys != NULL) {
 		*num_subkeys = kd->subkey_count;
 	}
-
 	if (num_values != NULL) {
 		*num_values = kd->value_count;
 	}
 
-	if (last_change_time != NULL)
-		*last_change_time = 0;
 
 	if (max_subkeynamelen != NULL) {
 		int i;
@@ -702,11 +809,12 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx,
 			}
 
 			if (max_valbufsize != NULL) {
+				uint32_t data_type;
 				DATA_BLOB data;
 				reg_ldb_unpack_value(mem_ctx, 
 						     lp_iconv_convenience(global_loadparm),
 						     kd->values[i], NULL, 
-						     NULL, &data);
+						     &data_type, &data);
 				*max_valbufsize = MAX(*max_valbufsize, data.length);
 				talloc_free(data.data);
 			}
diff --git a/source4/rpc_server/winreg/rpc_winreg.c b/source4/rpc_server/winreg/rpc_winreg.c
index e295634..aa94505 100644
--- a/source4/rpc_server/winreg/rpc_winreg.c
+++ b/source4/rpc_server/winreg/rpc_winreg.c
@@ -3,7 +3,8 @@
 
    endpoint server for the winreg pipe
 
-   Copyright (C) Jelmer Vernooij 2004
+   Copyright (C) 2004 Jelmer Vernooij, jelmer at samba.org
+   Copyright (C) 2008 Matthias Dieter Wallnöfer, mwallnoefer at yahoo.de
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -58,19 +59,18 @@ static WERROR dcesrv_winreg_openhive(struct dcesrv_call_state *dce_call,
 {
 	struct registry_context *ctx = dce_call->context->private;
 	struct dcesrv_handle *h;
-	WERROR error;
+	WERROR result;
 
 	h = dcesrv_handle_new(dce_call->context, HTYPE_REGKEY);
 
-	error = reg_get_predefined_key(ctx, hkey,
+	result = reg_get_predefined_key(ctx, hkey,
 				       (struct registry_key **)&h->data);
-	if (!W_ERROR_IS_OK(error)) {
-		return error;
+	if (!W_ERROR_IS_OK(result)) {
+		return result;
 	}
-
 	*outh = &h->wire_handle;
 
-	return error;
+	return result;
 }
 
 #define func_winreg_OpenHive(k,n) static WERROR dcesrv_winreg_Open ## k (struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct winreg_Open ## k *r) \
@@ -114,10 +114,12 @@ static WERROR dcesrv_winreg_CreateKey(struct dcesrv_call_state *dce_call,
 				      struct winreg_CreateKey *r)
 {
 	struct dcesrv_handle *h, *newh;
-	WERROR error;
 	struct security_descriptor sd;
+	struct registry_key *key;
+	WERROR result;
 
 	DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
+	key = h->data;
 
 	newh = dcesrv_handle_new(dce_call->context, HTYPE_REGKEY);
 
@@ -141,16 +143,15 @@ static WERROR dcesrv_winreg_CreateKey(struct dcesrv_call_state *dce_call,
 			}
 		}
 		
-		error = reg_key_add_name(newh, (struct registry_key *)h->data,
-					 r->in.name.name, NULL, r->in.secdesc?&sd:NULL,
-					 (struct registry_key **)&newh->data);
-		if (W_ERROR_IS_OK(error)) {
+		result = reg_key_add_name(newh, key, r->in.name.name, NULL,
+			r->in.secdesc?&sd:NULL, (struct registry_key **)&newh->data);
+		if (W_ERROR_IS_OK(result)) {
 			r->out.new_handle = &newh->wire_handle;
 		} else {
 			talloc_free(newh);
 		}
 		
-		return error;
+		return result;
 	default:
 		return WERR_ACCESS_DENIED;
 	}
@@ -165,14 +166,16 @@ static WERROR dcesrv_winreg_DeleteKey(struct dcesrv_call_state *dce_call,
 				      struct winreg_DeleteKey *r)
 {
 	struct dcesrv_handle *h;
+	struct registry_key *key;
 
 	DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
+	key = h->data;
 
 	switch (security_session_user_level(dce_call->conn->auth_state.session_info))
 	{
 	case SECURITY_SYSTEM:
 	case SECURITY_ADMINISTRATOR:
-		return reg_key_del((struct registry_key *)h->data, r->in.key.name);
+		return reg_key_del(key, r->in.key.name);
 	default:
 		return WERR_ACCESS_DENIED;
 	}
@@ -190,13 +193,12 @@ static WERROR dcesrv_winreg_DeleteValue(struct dcesrv_call_state *dce_call,
 	struct registry_key *key;
 
 	DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
+	key = h->data;
 
 	switch (security_session_user_level(dce_call->conn->auth_state.session_info))
 	{
 	case SECURITY_SYSTEM:
 	case SECURITY_ADMINISTRATOR:
-		key = h->data;
-		
 		return reg_del_value(key, r->in.value.name);
 	default:
 		return WERR_ACCESS_DENIED;
@@ -212,29 +214,44 @@ static WERROR dcesrv_winreg_EnumKey(struct dcesrv_call_state *dce_call,
 				    struct winreg_EnumKey *r)
 {
 	struct dcesrv_handle *h;
-	const char *name;
+	struct registry_key *key;
+	const char *name, *classname;
 	NTTIME last_mod;
+	WERROR result;
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list