From faa4ac2a52cee89be66a11604dd65871b3b70a6b Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Fri, 12 Sep 2008 16:41:49 +0200 Subject: Registry tool "regtree": Handle the default attribute in the right way This commit introduces the default attribute in "regtree" --- source4/lib/registry/tools/regtree.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'source4/lib/registry/tools') diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c index 19e4a010b4..fef9c7ee49 100644 --- a/source4/lib/registry/tools/regtree.c +++ b/source4/lib/registry/tools/regtree.c @@ -40,8 +40,8 @@ static void print_tree(int level, struct registry_key *p, struct registry_key *subkey; const char *valuename; const char *keyname; - uint32_t value_type; - DATA_BLOB value_data; + uint32_t valuetype; + DATA_BLOB valuedata; struct security_descriptor *sec_desc; WERROR error; int i; @@ -73,18 +73,24 @@ static void print_tree(int level, struct registry_key *p, if (!novals) { mem_ctx = talloc_init("print_tree"); - for(i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(mem_ctx, - p, - i, - &valuename, - &value_type, - &value_data)); i++) { + /* default value */ + if (W_ERROR_IS_OK(reg_key_get_value_by_index(mem_ctx, p, 0, + &valuename, &valuetype, &valuedata))) { int j; - char *desc; for(j = 0; j < level+1; j++) putchar(' '); - desc = reg_val_description(mem_ctx, lp_iconv_convenience(cmdline_lp_ctx), valuename, - value_type, value_data); - printf("%s\n", desc); + printf("%s\n", reg_val_description(mem_ctx, + lp_iconv_convenience(cmdline_lp_ctx), + "(Default)", valuetype, valuedata)); + } + /* other values */ + for(i = 1; W_ERROR_IS_OK(error = reg_key_get_value_by_index( + mem_ctx, p, i, &valuename, &valuetype, &valuedata)); + i++) { + int j; + for(j = 0; j < level+1; j++) putchar(' '); + printf("%s\n", reg_val_description(mem_ctx, + lp_iconv_convenience(cmdline_lp_ctx), valuename, + valuetype, valuedata)); } talloc_free(mem_ctx); -- cgit From 965a12f5b8bb862bab9eb46fba6e95f3906bae7d Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Fri, 12 Sep 2008 16:57:22 +0200 Subject: Registry tool "regtree": Removing an error message The error message "Error occurred while fetching values" doesn't seem very useful, so remove it. --- source4/lib/registry/tools/regtree.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source4/lib/registry/tools') diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c index fef9c7ee49..17a9163adc 100644 --- a/source4/lib/registry/tools/regtree.c +++ b/source4/lib/registry/tools/regtree.c @@ -93,11 +93,6 @@ static void print_tree(int level, struct registry_key *p, valuetype, valuedata)); } talloc_free(mem_ctx); - - if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) { - DEBUG(0, ("Error occured while fetching values for '%s': %s\n", - name, win_errstr(error))); - } } mem_ctx = talloc_init("sec_desc"); -- cgit From a2d8ccad734b850a8e368408328c32b4f15e2525 Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Fri, 12 Sep 2008 17:02:30 +0200 Subject: Registry tool "regshell": Handle the default attribute in the right way This commit introduces the default attribute in "regshell" --- source4/lib/registry/tools/regshell.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'source4/lib/registry/tools') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 98f7f02c38..fb7a08e38f 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -207,8 +207,8 @@ static WERROR cmd_ls(struct regshell_context *ctx, int argc, char **argv) { int i; WERROR error; - uint32_t data_type; - DATA_BLOB data; + uint32_t valuetype; + DATA_BLOB valuedata; const char *name = NULL; for (i = 0; W_ERROR_IS_OK(error = reg_key_get_subkey_by_index(ctx, @@ -221,19 +221,21 @@ static WERROR cmd_ls(struct regshell_context *ctx, int argc, char **argv) } if (!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) { - DEBUG(0, ("Error occured while browsing thru keys: %s\n", - win_errstr(error))); + fprintf(stderr, "Error occured while browsing thru keys: %s\n", + win_errstr(error)); + return error; } - for (i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(ctx, - ctx->current, - i, - &name, - &data_type, - &data)); i++) { - printf("V \"%s\" %s %s\n", name, str_regtype(data_type), - reg_val_data_string(ctx, lp_iconv_convenience(cmdline_lp_ctx), data_type, data)); - } + /* default value */ + if (W_ERROR_IS_OK(reg_key_get_value_by_index(ctx, ctx->current, 0, + &name, &valuetype, &valuedata))) + printf("V \"(Default)\" %s %s\n", str_regtype(valuetype), + reg_val_data_string(ctx, lp_iconv_convenience(cmdline_lp_ctx), valuetype, valuedata)); + /* other values */ + for (i = 1; W_ERROR_IS_OK(error = reg_key_get_value_by_index(ctx, + ctx->current, i, &name, &valuetype, &valuedata)); i++) + printf("V \"%s\" %s %s\n", name, str_regtype(valuetype), + reg_val_data_string(ctx, lp_iconv_convenience(cmdline_lp_ctx), valuetype, valuedata)); return WERR_OK; } -- cgit From 92e1574d3ddb0edf3173e18c6e0dfc4974bedcf5 Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Sat, 13 Sep 2008 12:26:03 +0200 Subject: Registry tools "regshell" and "regtree": Small fixup's I fixed up my fault regarding the handling of the default value (if it doesn't exist it hasn't the index number zero and you get immediately the subvalues). Then I corrected an error in regshell to find the right registry context. --- source4/lib/registry/tools/regshell.c | 13 ++++--------- source4/lib/registry/tools/regtree.c | 15 ++------------- 2 files changed, 6 insertions(+), 22 deletions(-) (limited to 'source4/lib/registry/tools') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index fb7a08e38f..208b19fba8 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -226,13 +226,7 @@ static WERROR cmd_ls(struct regshell_context *ctx, int argc, char **argv) return error; } - /* default value */ - if (W_ERROR_IS_OK(reg_key_get_value_by_index(ctx, ctx->current, 0, - &name, &valuetype, &valuedata))) - printf("V \"(Default)\" %s %s\n", str_regtype(valuetype), - reg_val_data_string(ctx, lp_iconv_convenience(cmdline_lp_ctx), valuetype, valuedata)); - /* other values */ - for (i = 1; W_ERROR_IS_OK(error = reg_key_get_value_by_index(ctx, + for (i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(ctx, ctx->current, i, &name, &valuetype, &valuedata)); i++) printf("V \"%s\" %s %s\n", name, str_regtype(valuetype), reg_val_data_string(ctx, lp_iconv_convenience(cmdline_lp_ctx), valuetype, valuedata)); @@ -440,7 +434,7 @@ static char **reg_complete_key(const char *text, int start, int end) len = strlen(text); for(i = 0; j < MAX_COMPLETIONS-1; i++) { status = reg_key_get_subkey_by_index(mem_ctx, base, i, - &subkeyname, NULL, NULL); + &subkeyname, NULL, NULL); if(W_ERROR_IS_OK(status)) { if(!strncmp(text, subkeyname, len)) { matches[j] = strdup(subkeyname); @@ -538,7 +532,8 @@ int main(int argc, char **argv) if (ctx->current == NULL) { int i; - for (i = 0; reg_predefined_keys[i].handle; i++) { + for (i = 0; (reg_predefined_keys[i].handle != 0) && + (ctx->current == NULL); i++) { WERROR err; err = reg_get_predefined_key(ctx->registry, reg_predefined_keys[i].handle, diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c index 17a9163adc..2175f9c9d3 100644 --- a/source4/lib/registry/tools/regtree.c +++ b/source4/lib/registry/tools/regtree.c @@ -38,8 +38,7 @@ static void print_tree(int level, struct registry_key *p, bool fullpath, bool novals) { struct registry_key *subkey; - const char *valuename; - const char *keyname; + const char *valuename, *keyname; uint32_t valuetype; DATA_BLOB valuedata; struct security_descriptor *sec_desc; @@ -73,17 +72,7 @@ static void print_tree(int level, struct registry_key *p, if (!novals) { mem_ctx = talloc_init("print_tree"); - /* default value */ - if (W_ERROR_IS_OK(reg_key_get_value_by_index(mem_ctx, p, 0, - &valuename, &valuetype, &valuedata))) { - int j; - for(j = 0; j < level+1; j++) putchar(' '); - printf("%s\n", reg_val_description(mem_ctx, - lp_iconv_convenience(cmdline_lp_ctx), - "(Default)", valuetype, valuedata)); - } - /* other values */ - for(i = 1; W_ERROR_IS_OK(error = reg_key_get_value_by_index( + for(i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index( mem_ctx, p, i, &valuename, &valuetype, &valuedata)); i++) { int j; -- cgit From 04f29b84a4bf2378d326b86a983792095231922e Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Sat, 13 Sep 2008 15:02:56 +0200 Subject: Registry client library: Fixes the creation of new keys Giving the right permissions --- source4/lib/registry/tools/regshell.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/registry/tools') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 208b19fba8..5c308bfbda 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -246,7 +246,8 @@ static WERROR cmd_mkkey(struct regshell_context *ctx, int argc, char **argv) error = reg_key_add_name(ctx, ctx->current, argv[1], 0, NULL, &tmp); if (!W_ERROR_IS_OK(error)) { - fprintf(stderr, "Error adding new subkey '%s'\n", argv[1]); + fprintf(stderr, "Error adding new subkey '%s': %s\n", argv[1], + win_errstr(error)); return error; } -- cgit From db829f04adc27764a4a53ae94bc24c64e143e024 Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Sun, 14 Sep 2008 03:29:07 +0200 Subject: Registry tool "regdiff": Add the event context for remote connections Adds the event context for remote connections to make the tool working again. --- source4/lib/registry/tools/regdiff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 240c582340..fcf7c26237 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -46,7 +46,7 @@ static struct registry_context *open_backend(poptContext pc, break; case REG_REMOTE: error = reg_open_remote(&ctx, NULL, cmdline_credentials, lp_ctx, - remote_host, NULL); + remote_host, ev_ctx); break; case REG_NULL: error = reg_open_local(NULL, &ctx); -- cgit From 5c3e76eddd89d9af18bf2a00e7ee6021ab90b234 Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Fri, 19 Sep 2008 12:57:26 +0200 Subject: Revert "Registry tool "regtree": Removing an error message" This reverts commit f37a57fa366e2b0d77f9c1bd232d42a0f2cceb52. --- source4/lib/registry/tools/regtree.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/registry/tools') diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c index 2175f9c9d3..6d55a3eb84 100644 --- a/source4/lib/registry/tools/regtree.c +++ b/source4/lib/registry/tools/regtree.c @@ -82,6 +82,11 @@ static void print_tree(int level, struct registry_key *p, valuetype, valuedata)); } talloc_free(mem_ctx); + + if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) { + DEBUG(0, ("Error occured while fetching values for '%s': %s\n", + name, win_errstr(error))); + } } mem_ctx = talloc_init("sec_desc"); -- cgit