summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/registry/common/reg_interface.c14
-rw-r--r--source4/lib/registry/common/reg_objects.c2
-rw-r--r--source4/lib/registry/common/registry.h2
-rw-r--r--source4/lib/registry/reg_backend_nt4/reg_backend_nt4.c5
-rw-r--r--source4/lib/registry/tools/regshell.c21
-rw-r--r--source4/lib/registry/tools/regtree.c6
6 files changed, 33 insertions, 17 deletions
diff --git a/source4/lib/registry/common/reg_interface.c b/source4/lib/registry/common/reg_interface.c
index 3e5a545f9a..e748c836cf 100644
--- a/source4/lib/registry/common/reg_interface.c
+++ b/source4/lib/registry/common/reg_interface.c
@@ -176,15 +176,15 @@ WERROR reg_open_key(REG_KEY *parent, const char *name, REG_KEY **result)
return WERR_OK;
}
- mem_ctx = talloc_init("mem_ctx");
-
- fullname = talloc_asprintf(mem_ctx, "%s%s%s", parent->path, parent->path[strlen(parent->path)-1] == '\\'?"":"\\", name);
-
if(!parent->handle->functions->open_key) {
DEBUG(0, ("Registry backend doesn't have get_subkey_by_name nor open_key!\n"));
return WERR_NOT_SUPPORTED;
}
+ mem_ctx = talloc_init("mem_ctx");
+
+ fullname = talloc_asprintf(mem_ctx, "%s%s%s", reg_key_get_path(parent), strlen(reg_key_get_path(parent))?"\\":"", name);
+
error = parent->handle->functions->open_key(parent->handle, parent->hive, fullname, result);
if(!W_ERROR_IS_OK(error)) {
@@ -193,7 +193,7 @@ WERROR reg_open_key(REG_KEY *parent, const char *name, REG_KEY **result)
}
(*result)->handle = parent->handle;
- (*result)->path = fullname;
+ (*result)->path = talloc_asprintf((*result)->mem_ctx, "%s\\%s", reg_key_get_path_abs(parent), (*result)->name);
(*result)->hive = parent->hive;
talloc_steal(mem_ctx, (*result)->mem_ctx, fullname);
@@ -303,7 +303,7 @@ WERROR reg_key_get_subkey_by_index(REG_KEY *key, int idx, REG_KEY **subkey)
return WERR_NOT_SUPPORTED;
}
- (*subkey)->path = talloc_asprintf((*subkey)->mem_ctx, "%s%s%s", key->path, key->path[strlen(key->path)-1] == '\\'?"":"\\", (*subkey)->name);
+ (*subkey)->path = talloc_asprintf((*subkey)->mem_ctx, "%s\\%s", reg_key_get_path_abs(key), (*subkey)->name);
(*subkey)->handle = key->handle;
(*subkey)->hive = key->hive;
@@ -334,7 +334,7 @@ WERROR reg_key_get_subkey_by_name(REG_KEY *key, const char *name, REG_KEY **subk
if(!W_ERROR_IS_OK(error)) return error;
- (*subkey)->path = talloc_asprintf((*subkey)->mem_ctx, "%s%s%s", key->path, key->path[strlen(key->path)-1] == '\\'?"":"\\", (*subkey)->name);
+ (*subkey)->path = talloc_asprintf((*subkey)->mem_ctx, "%s\\%s", reg_key_get_path_abs(key), (*subkey)->name);
(*subkey)->handle = key->handle;
(*subkey)->hive = key->hive;
diff --git a/source4/lib/registry/common/reg_objects.c b/source4/lib/registry/common/reg_objects.c
index 7a92f413ff..0109a1f8fe 100644
--- a/source4/lib/registry/common/reg_objects.c
+++ b/source4/lib/registry/common/reg_objects.c
@@ -141,7 +141,7 @@ char *reg_val_get_path(REG_VAL *v)
const char *reg_key_get_path(REG_KEY *k)
{
SMB_REG_ASSERT(k);
- return strchr(k->path, '\\')?strchr(k->path, '\\')+1:k->path;
+ return strchr(k->path, '\\')?strchr(k->path, '\\')+1:"";
}
const char *reg_key_get_path_abs(REG_KEY *k)
diff --git a/source4/lib/registry/common/registry.h b/source4/lib/registry/common/registry.h
index d4e8cccade..5325a89086 100644
--- a/source4/lib/registry/common/registry.h
+++ b/source4/lib/registry/common/registry.h
@@ -31,7 +31,7 @@
struct reg_key_s {
char *name; /* Name of the key */
char *path; /* Full path to the key */
- smb_ucs2_t *class_name; /* Name of key class */
+ char *class_name; /* Name of key class */
NTTIME last_mod; /* Time last modified */
SEC_DESC *security;
REG_HANDLE *handle;
diff --git a/source4/lib/registry/reg_backend_nt4/reg_backend_nt4.c b/source4/lib/registry/reg_backend_nt4/reg_backend_nt4.c
index 255389624e..a28f1880db 100644
--- a/source4/lib/registry/reg_backend_nt4/reg_backend_nt4.c
+++ b/source4/lib/registry/reg_backend_nt4/reg_backend_nt4.c
@@ -1085,12 +1085,15 @@ static WERROR nk_to_key(REG_HANDLE *h, NK_HDR *nk_hdr, int size, REG_KEY *parent
if (clsname_len) { /* Just print in Ascii for now */
smb_ucs2_t *clsnamep;
int clsnam_off;
+ char *clsnameu;
clsnam_off = IVAL(&nk_hdr->clsnam_off,0);
clsnamep = (smb_ucs2_t *)LOCN(regf->base, clsnam_off);
DEBUG(2, ("Class Name Offset: %0X\n", clsnam_off));
- tmp->class_name = talloc_strdup_w(h->mem_ctx, clsnamep);
+ clsnameu = acnv_u2ux(clsnamep);
+ tmp->class_name = talloc_strdup(tmp->mem_ctx, clsnameu);
+ SAFE_FREE(clsnameu);
DEBUGADD(2,(" Class Name: %s\n", cls_name));
diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c
index 26312ad4bc..dbddaa5dcf 100644
--- a/source4/lib/registry/tools/regshell.c
+++ b/source4/lib/registry/tools/regshell.c
@@ -32,6 +32,12 @@
* exit
*/
+static REG_KEY *cmd_pwd(REG_KEY *cur, int argc, char **argv)
+{
+ printf("%s\n", reg_key_get_path_abs(cur));
+ return cur;
+}
+
static REG_KEY *cmd_set(REG_KEY *cur, int argc, char **argv)
{
/* FIXME */
@@ -52,7 +58,7 @@ static REG_KEY *cmd_ck(REG_KEY *cur, int argc, char **argv)
}
}
- printf("Current path is: %s\n", reg_key_get_path(new));
+ printf("Current path is: %s\n", reg_key_get_path_abs(new));
return new;
}
@@ -68,7 +74,7 @@ static REG_KEY *cmd_ls(REG_KEY *cur, int argc, char **argv)
}
if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) {
- DEBUG(0, ("Error occured while browsing thru keys\n"));
+ DEBUG(0, ("Error occured while browsing thru keys: %s\n", win_errstr(error)));
}
for(i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(cur, i, &value)); i++) {
@@ -90,7 +96,7 @@ static REG_KEY *cmd_mkkey(REG_KEY *cur, int argc, char **argv)
return NULL;
}
- fprintf(stderr, "Successfully added new subkey '%s' to '%s'\n", argv[1], reg_key_get_path(cur));
+ fprintf(stderr, "Successfully added new subkey '%s' to '%s'\n", argv[1], reg_key_get_path_abs(cur));
return NULL;
}
@@ -139,6 +145,11 @@ static REG_KEY *cmd_rmval(REG_KEY *cur, int argc, char **argv)
return NULL;
}
+static REG_KEY *cmd_hive(REG_KEY *cur, int argc, char **argv)
+{
+ /* FIXME */
+}
+
static REG_KEY *cmd_exit(REG_KEY *cur, int argc, char **argv)
{
exit(0);
@@ -154,10 +165,12 @@ struct {
REG_KEY *(*handle)(REG_KEY *, int argc, char **argv);
} regshell_cmds[] = {
{"ck", "cd", "Change current key", cmd_ck },
+ {"ch", "hive", "Change current hive", cmd_hive },
{"list", "ls", "List values/keys in current key", cmd_ls },
{"mkkey", "mkdir", "Make new key", cmd_mkkey },
{"rmval", "rm", "Remove value", cmd_rmval },
{"rmkey", "rmdir", "Remove key", cmd_rmkey },
+ {"pwd", "pwk", "Printing current key", cmd_pwd },
{"set", "update", "Update value", cmd_set },
{"help", "?", "Help", cmd_help },
{"exit", "quit", "Exit", cmd_exit },
@@ -235,7 +248,7 @@ static REG_KEY *process_cmd(REG_KEY *k, char *line)
while(True) {
char *line, *prompt;
- asprintf(&prompt, "%s> ", reg_key_get_path(curkey));
+ asprintf(&prompt, "%s> ", reg_key_get_path_abs(curkey));
line = smb_readline(prompt, NULL, NULL);
diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c
index e583194a56..b1ca9b3fb2 100644
--- a/source4/lib/registry/tools/regtree.c
+++ b/source4/lib/registry/tools/regtree.c
@@ -29,7 +29,7 @@ static void print_tree(int l, REG_KEY *p, int fullpath, int novals)
int i;
for(i = 0; i < l; i++) putchar(' ');
- if(fullpath) printf("%s\n", reg_key_get_path(p));
+ if(fullpath) printf("%s\n", reg_key_get_path_abs(p));
else printf("%s\n", reg_key_name(p));
for(i = 0; W_ERROR_IS_OK(error = reg_key_get_subkey_by_index(p, i, &subkey)); i++) {
@@ -38,7 +38,7 @@ static void print_tree(int l, REG_KEY *p, int fullpath, int novals)
}
if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) {
- DEBUG(0, ("Error occured while fetching subkeys for '%s': %s\n", reg_key_get_path(p), win_errstr(error)));
+ DEBUG(0, ("Error occured while fetching subkeys for '%s': %s\n", reg_key_get_path_abs(p), win_errstr(error)));
}
if(!novals) {
@@ -53,7 +53,7 @@ static void print_tree(int l, REG_KEY *p, int fullpath, int novals)
}
if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) {
- DEBUG(0, ("Error occured while fetching values for '%s': %s\n", reg_key_get_path(p), win_errstr(error)));
+ DEBUG(0, ("Error occured while fetching values for '%s': %s\n", reg_key_get_path_abs(p), win_errstr(error)));
}
}
}