summaryrefslogtreecommitdiff
path: root/source4/lib/registry
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2004-04-12 18:46:48 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:51:15 -0500
commitb4d6cbd380b09d0638102137b589555cb4e1c285 (patch)
tree54d909e933a0d3e92524261a8b08b3fad39b3d3a /source4/lib/registry
parent4019324f7633c029c3cf461ed8d15433fc7609ea (diff)
downloadsamba-b4d6cbd380b09d0638102137b589555cb4e1c285.tar.gz
samba-b4d6cbd380b09d0638102137b589555cb4e1c285.tar.bz2
samba-b4d6cbd380b09d0638102137b589555cb4e1c285.zip
r183: More bugfixes
(This used to be commit 88911bbcca574adbf6ea4f0759a68f2961b05d6b)
Diffstat (limited to 'source4/lib/registry')
-rw-r--r--source4/lib/registry/common/reg_interface.c40
-rw-r--r--source4/lib/registry/tools/regshell.c9
2 files changed, 21 insertions, 28 deletions
diff --git a/source4/lib/registry/common/reg_interface.c b/source4/lib/registry/common/reg_interface.c
index 696a504d87..5753de1bca 100644
--- a/source4/lib/registry/common/reg_interface.c
+++ b/source4/lib/registry/common/reg_interface.c
@@ -124,8 +124,7 @@ WERROR reg_open(const char *backend, const char *location, const char *credentia
WERROR reg_open_key(REG_KEY *parent, const char *name, REG_KEY **result)
{
char *fullname;
- WERROR status;
- REG_KEY *ret = NULL;
+ WERROR error;
TALLOC_CTX *mem_ctx;
if(!parent) {
@@ -143,10 +142,10 @@ WERROR reg_open_key(REG_KEY *parent, const char *name, REG_KEY **result)
while(curbegin && *curbegin) {
if(curend)*curend = '\0';
- status = reg_key_get_subkey_by_name(curkey, curbegin, result);
- if(!NT_STATUS_IS_OK(status)) {
+ error = reg_key_get_subkey_by_name(curkey, curbegin, result);
+ if(!W_ERROR_IS_OK(error)) {
SAFE_FREE(orig);
- return status;
+ return error;
}
if(!curend) break;
curbegin = curend + 1;
@@ -168,21 +167,19 @@ WERROR reg_open_key(REG_KEY *parent, const char *name, REG_KEY **result)
return WERR_NOT_SUPPORTED;
}
- status = parent->handle->functions->open_key(parent->handle, fullname, result);
+ error = parent->handle->functions->open_key(parent->handle, fullname, result);
- if(!NT_STATUS_IS_OK(status)) {
+ if(!W_ERROR_IS_OK(error)) {
talloc_destroy(mem_ctx);
- return status;
+ return error;
}
- ret->handle = parent->handle;
- ret->path = fullname;
- talloc_steal(mem_ctx, ret->mem_ctx, fullname);
+ (*result)->handle = parent->handle;
+ (*result)->path = fullname;
+ talloc_steal(mem_ctx, (*result)->mem_ctx, fullname);
talloc_destroy(mem_ctx);
- *result = ret;
-
return WERR_OK;
}
@@ -294,32 +291,29 @@ WERROR reg_key_get_subkey_by_index(REG_KEY *key, int idx, REG_KEY **subkey)
WERROR reg_key_get_subkey_by_name(REG_KEY *key, const char *name, REG_KEY **subkey)
{
int i;
- REG_KEY *ret = NULL;
WERROR error = WERR_OK;
if(!key) return WERR_INVALID_PARAM;
if(key->handle->functions->get_subkey_by_name) {
error = key->handle->functions->get_subkey_by_name(key,name,subkey);
- } else {
+ } else if(key->handle->functions->get_subkey_by_index || key->handle->functions->fetch_subkeys) {
for(i = 0; W_ERROR_IS_OK(error); i++) {
error = reg_key_get_subkey_by_index(key, i, subkey);
if(W_ERROR_IS_OK(error) && !strcmp((*subkey)->name, name)) {
- break;
+ return error;
}
reg_key_free(*subkey);
}
-
+ } else {
+ return WERR_NOT_SUPPORTED;
}
- if(!W_ERROR_IS_OK(error) && W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS))
- return error;
+ if(!W_ERROR_IS_OK(error)) return error;
- ret->path = talloc_asprintf(ret->mem_ctx, "%s%s%s", key->path, key->path[strlen(key->path)-1] == '\\'?"":"\\", ret->name);
- ret->handle = key->handle;
+ (*subkey)->path = talloc_asprintf((*subkey)->mem_ctx, "%s%s%s", key->path, key->path[strlen(key->path)-1] == '\\'?"":"\\", (*subkey)->name);
+ (*subkey)->handle = key->handle;
- *subkey = ret;
-
return WERR_OK;
}
diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c
index d60ca1ff46..18399b5bda 100644
--- a/source4/lib/registry/tools/regshell.c
+++ b/source4/lib/registry/tools/regshell.c
@@ -39,18 +39,17 @@ static REG_KEY *cmd_set(REG_KEY *cur, int argc, char **argv)
static REG_KEY *cmd_ck(REG_KEY *cur, int argc, char **argv)
{
- REG_KEY *new;
+ REG_KEY *new = NULL;
WERROR error;
if(argc < 2) {
new = cur;
} else {
error = reg_open_key(cur, argv[1], &new);
if(!W_ERROR_IS_OK(error)) {
- DEBUG(0, ("Error opening specified key\n"));
+ DEBUG(0, ("Error opening specified key: %s\n", win_errstr(error)));
+ return NULL;
}
- }
-
- if(!new) new = cur;
+ }
printf("Current path is: %s\n", reg_key_get_path(new));