From c424c2b857fe08587eb81a5c5e3625545119d1c2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 4 Apr 2004 16:24:08 +0000 Subject: r20: Add the registry library. Still needs a lot of work, see source/lib/registry/TODO for details. (This used to be commit 7cab3a00d7b4b1d95a3bfa6b28f318b4aaa5d493) --- source4/lib/registry/tools/regshell.c | 243 ++++++++++++++++++++++++++++++++++ 1 file changed, 243 insertions(+) create mode 100644 source4/lib/registry/tools/regshell.c (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c new file mode 100644 index 0000000000..9074d1c716 --- /dev/null +++ b/source4/lib/registry/tools/regshell.c @@ -0,0 +1,243 @@ +/* + Unix SMB/CIFS implementation. + simple registry frontend + + Copyright (C) Jelmer Vernooij 2004 + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/* + * ck/cd - change key + * ls - list values/keys + * rmval/rm - remove value + * rmkey/rmdir - remove key + * mkkey/mkdir - make key + * help + * exit + */ + +static REG_KEY *cmd_set(REG_KEY *cur, int argc, char **argv) +{ + /* FIXME */ + return NULL; +} + +static REG_KEY *cmd_ck(REG_KEY *cur, int argc, char **argv) +{ + REG_KEY *new; + if(argc < 2) { + new = cur; + } else { + new = reg_open_key(cur, argv[1]); + } + + if(!new) new = cur; + + printf("Current path is: %s\n", reg_key_get_path(new)); + + return new; +} + +static REG_KEY *cmd_ls(REG_KEY *cur, int argc, char **argv) +{ + int i, num; + num = reg_key_num_subkeys(cur); + for(i = 0; i < num; i++) { + REG_KEY *sub = reg_key_get_subkey_by_index(cur, i); + printf("K %s\n", reg_key_name(sub)); + } + + num = reg_key_num_values(cur); + for(i = 0; i < num; i++) { + REG_VAL *sub = reg_key_get_value_by_index(cur, i); + printf("V %s %s %s\n", reg_val_name(sub), str_regtype(reg_val_type(sub)), reg_val_data_string(sub)); + } + + return NULL; +} +static REG_KEY *cmd_mkkey(REG_KEY *cur, int argc, char **argv) +{ + if(argc < 2) { + fprintf(stderr, "Usage: mkkey \n"); + return NULL; + } + + if(!reg_key_add_name(cur, argv[1])) { + fprintf(stderr, "Error adding new subkey '%s'\n", argv[1]); + return NULL; + } + + fprintf(stderr, "Successfully added new subkey '%s' to '%s'\n", argv[1], reg_key_get_path(cur)); + + return NULL; +} + +static REG_KEY *cmd_rmkey(REG_KEY *cur, int argc, char **argv) +{ + REG_KEY *key; + if(argc < 2) { + fprintf(stderr, "Usage: rmkey \n"); + return NULL; + } + + key = reg_open_key(cur, argv[1]); + if(!key) { + fprintf(stderr, "No such subkey '%s'\n", argv[1]); + return NULL; + } + + if(!reg_key_del(key)) { + fprintf(stderr, "Error deleting '%s'\n", argv[1]); + } else { + fprintf(stderr, "Successfully deleted '%s'\n", argv[1]); + } + + return NULL; +} + +static REG_KEY *cmd_rmval(REG_KEY *cur, int argc, char **argv) +{ + REG_VAL *val; + if(argc < 2) { + fprintf(stderr, "Usage: rmval \n"); + return NULL; + } + + val = reg_key_get_value_by_name(cur, argv[1]); + if(!val) { + fprintf(stderr, "No such value '%s'\n", argv[1]); + return NULL; + } + + if(!reg_val_del(val)) { + fprintf(stderr, "Error deleting value '%s'\n", argv[1]); + } else { + fprintf(stderr, "Successfully deleted value '%s'\n", argv[1]); + } + + return NULL; +} + +static REG_KEY *cmd_exit(REG_KEY *cur, int argc, char **argv) +{ + exit(0); + return NULL; +} + +static REG_KEY *cmd_help(REG_KEY *, int, char **); + +struct { + const char *name; + const char *alias; + const char *help; + REG_KEY *(*handle)(REG_KEY *, int argc, char **argv); +} regshell_cmds[] = { + {"ck", "cd", "Change current key", cmd_ck }, + {"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 }, + {"set", "update", "Update value", cmd_set }, + {"help", "?", "Help", cmd_help }, + {"exit", "quit", "Exit", cmd_exit }, + {NULL } +}; + +static REG_KEY *cmd_help(REG_KEY *cur, int argc, char **argv) +{ + int i; + printf("Available commands:\n"); + for(i = 0; regshell_cmds[i].name; i++) { + printf("%s - %s\n", regshell_cmds[i].name, regshell_cmds[i].help); + } + return NULL; +} + +REG_KEY *process_cmd(REG_KEY *k, char *line) +{ + int argc; + char **argv = NULL; + int ret, i; + + if ((ret = poptParseArgvString(line, &argc, (const char ***) &argv)) != 0) { + fprintf(stderr, "regshell: %s\n", poptStrerror(ret)); + return k; + } + + for(i = 0; regshell_cmds[i].name; i++) { + if(!strcmp(regshell_cmds[i].name, argv[0]) || + (regshell_cmds[i].alias && !strcmp(regshell_cmds[i].alias, argv[0]))) { + return regshell_cmds[i].handle(k, argc, argv); + } + } + + fprintf(stderr, "No such command '%s'\n", argv[0]); + + return k; +} + +int main (int argc, char **argv) +{ + uint32 setparms, checkparms; + int opt; + char *backend = "dir"; + REG_KEY *curkey = NULL;; + poptContext pc; + REG_HANDLE *h; + struct poptOption long_options[] = { + POPT_AUTOHELP + {"backend", 'b', POPT_ARG_STRING, &backend, 0, "backend to use", NULL}, + POPT_TABLEEND + }; + + pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0); + + while((opt = poptGetNextOpt(pc)) != -1) { + } + + h = reg_open(backend, poptPeekArg(pc), True); + if(!h) { + fprintf(stderr, "Unable to open '%s' with backend '%s'\n", poptGetArg(pc), backend); + return 1; + } + poptFreeContext(pc); + + setup_logging("regtree", True); + + curkey = reg_get_root(h); + + if(!curkey) return 1; + + while(True) { + char *line, *prompt; + + asprintf(&prompt, "%s> ", reg_key_get_path(curkey)); + + line = smb_readline(prompt, NULL, NULL); + + if(!line) + break; + + if(line[0] != '\n') { + REG_KEY *new = process_cmd(curkey, line); + if(new)curkey = new; + } + } + + return 0; +} -- cgit From aebfb3b9f415d3c1f6b2a39aee27b072d48893cb Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 8 Apr 2004 22:39:47 +0000 Subject: r128: Another registry update. Changes: - Start with the LDB backend - The API is now more windows-like, which should make it easier to use in rpc_server - Added a GTK+ front-end - Added some more IDL More updates will follow, especially in the RPC field.. (This used to be commit 3adffa021779b26047a20f16a3c0b53d74751560) --- source4/lib/registry/tools/regshell.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 9074d1c716..e6b5fa51ee 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -201,6 +201,7 @@ int main (int argc, char **argv) REG_HANDLE *h; struct poptOption long_options[] = { POPT_AUTOHELP + POPT_COMMON_SAMBA {"backend", 'b', POPT_ARG_STRING, &backend, 0, "backend to use", NULL}, POPT_TABLEEND }; -- cgit From 9cbbf2d55253783adaeceac9bc2f8c9ffe40aa94 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 9 Apr 2004 00:02:20 +0000 Subject: r129: Convert other utilities to new API (This used to be commit 95c9852b1607335eb24025081a251139449fb695) --- source4/lib/registry/tools/regshell.c | 47 +++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 19 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index e6b5fa51ee..d60ca1ff46 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -40,10 +40,14 @@ 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; + WERROR error; if(argc < 2) { new = cur; } else { - new = reg_open_key(cur, argv[1]); + error = reg_open_key(cur, argv[1], &new); + if(!W_ERROR_IS_OK(error)) { + DEBUG(0, ("Error opening specified key\n")); + } } if(!new) new = cur; @@ -56,28 +60,32 @@ static REG_KEY *cmd_ck(REG_KEY *cur, int argc, char **argv) static REG_KEY *cmd_ls(REG_KEY *cur, int argc, char **argv) { int i, num; - num = reg_key_num_subkeys(cur); - for(i = 0; i < num; i++) { - REG_KEY *sub = reg_key_get_subkey_by_index(cur, i); + WERROR error; + REG_VAL *value; + REG_KEY *sub; + for(i = 0; W_ERROR_IS_OK(error = reg_key_get_subkey_by_index(cur, i, &sub)); i++) { printf("K %s\n", reg_key_name(sub)); } - num = reg_key_num_values(cur); - for(i = 0; i < num; i++) { - REG_VAL *sub = reg_key_get_value_by_index(cur, i); - printf("V %s %s %s\n", reg_val_name(sub), str_regtype(reg_val_type(sub)), reg_val_data_string(sub)); + if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) { + DEBUG(0, ("Error occured while browsing thru keys\n")); + } + + for(i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(cur, i, &value)); i++) { + printf("V \"%s\" %s %s\n", reg_val_name(value), str_regtype(reg_val_type(value)), reg_val_data_string(value)); } return NULL; } static REG_KEY *cmd_mkkey(REG_KEY *cur, int argc, char **argv) { + REG_KEY *tmp; if(argc < 2) { fprintf(stderr, "Usage: mkkey \n"); return NULL; } - if(!reg_key_add_name(cur, argv[1])) { + if(!W_ERROR_IS_OK(reg_key_add_name(cur, argv[1], 0, NULL, &tmp))) { fprintf(stderr, "Error adding new subkey '%s'\n", argv[1]); return NULL; } @@ -95,13 +103,12 @@ static REG_KEY *cmd_rmkey(REG_KEY *cur, int argc, char **argv) return NULL; } - key = reg_open_key(cur, argv[1]); - if(!key) { + if(!W_ERROR_IS_OK(reg_open_key(cur, argv[1], &key))) { fprintf(stderr, "No such subkey '%s'\n", argv[1]); return NULL; } - if(!reg_key_del(key)) { + if(!W_ERROR_IS_OK(reg_key_del(key))) { fprintf(stderr, "Error deleting '%s'\n", argv[1]); } else { fprintf(stderr, "Successfully deleted '%s'\n", argv[1]); @@ -118,13 +125,12 @@ static REG_KEY *cmd_rmval(REG_KEY *cur, int argc, char **argv) return NULL; } - val = reg_key_get_value_by_name(cur, argv[1]); - if(!val) { + if(!W_ERROR_IS_OK(reg_key_get_value_by_name(cur, argv[1], &val))) { fprintf(stderr, "No such value '%s'\n", argv[1]); return NULL; } - if(!reg_val_del(val)) { + if(!W_ERROR_IS_OK(reg_val_del(val))) { fprintf(stderr, "Error deleting value '%s'\n", argv[1]); } else { fprintf(stderr, "Successfully deleted value '%s'\n", argv[1]); @@ -196,13 +202,16 @@ int main (int argc, char **argv) uint32 setparms, checkparms; int opt; char *backend = "dir"; + char *credentials = NULL; REG_KEY *curkey = NULL;; poptContext pc; + WERROR error; REG_HANDLE *h; struct poptOption long_options[] = { POPT_AUTOHELP POPT_COMMON_SAMBA {"backend", 'b', POPT_ARG_STRING, &backend, 0, "backend to use", NULL}, + {"credentials", 'c', POPT_ARG_STRING, &credentials, 0, "credentials", NULL}, POPT_TABLEEND }; @@ -211,8 +220,8 @@ int main (int argc, char **argv) while((opt = poptGetNextOpt(pc)) != -1) { } - h = reg_open(backend, poptPeekArg(pc), True); - if(!h) { + error = reg_open(backend, poptPeekArg(pc), credentials, &h); + if(!W_ERROR_IS_OK(error)) { fprintf(stderr, "Unable to open '%s' with backend '%s'\n", poptGetArg(pc), backend); return 1; } @@ -220,9 +229,9 @@ int main (int argc, char **argv) setup_logging("regtree", True); - curkey = reg_get_root(h); + error = reg_get_root(h, &curkey); - if(!curkey) return 1; + if(!W_ERROR_IS_OK(error)) return 1; while(True) { char *line, *prompt; -- cgit From b4d6cbd380b09d0638102137b589555cb4e1c285 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 12 Apr 2004 18:46:48 +0000 Subject: r183: More bugfixes (This used to be commit 88911bbcca574adbf6ea4f0759a68f2961b05d6b) --- source4/lib/registry/tools/regshell.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') 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)); -- cgit From f3d3b3c8091ad4540c330c07662540440affb96e Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 25 Apr 2004 22:15:48 +0000 Subject: r355: Fix a bunch of compiler warnings in the registry code. (This used to be commit 0be7a866dc39e2d63c9c114d0f668287259e7c9e) --- source4/lib/registry/tools/regshell.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 18399b5bda..8ee2a65d06 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -58,7 +58,7 @@ static REG_KEY *cmd_ck(REG_KEY *cur, int argc, char **argv) static REG_KEY *cmd_ls(REG_KEY *cur, int argc, char **argv) { - int i, num; + int i; WERROR error; REG_VAL *value; REG_KEY *sub; @@ -198,7 +198,6 @@ REG_KEY *process_cmd(REG_KEY *k, char *line) int main (int argc, char **argv) { - uint32 setparms, checkparms; int opt; char *backend = "dir"; char *credentials = NULL; -- cgit From 6a8355a6282563e3198c05dd6eb82107e449682c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 4 May 2004 13:18:29 +0000 Subject: r467: hopefully get the buildfarm compiling fine now... metze (This used to be commit d15f0e18bb43608c611cfe78fc79db9ee10e1eb2) --- source4/lib/registry/tools/regshell.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 8ee2a65d06..b78f4256f0 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -199,9 +199,9 @@ REG_KEY *process_cmd(REG_KEY *k, char *line) int main (int argc, char **argv) { int opt; - char *backend = "dir"; - char *credentials = NULL; - REG_KEY *curkey = NULL;; + const char *backend = "dir"; + const char *credentials = NULL; + REG_KEY *curkey = NULL; poptContext pc; WERROR error; REG_HANDLE *h; -- cgit From f236700ef67d4f93ec56ec7808584552e94e0dfe Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 13 May 2004 10:20:53 +0000 Subject: r665: merge over the new build system from my tmp branch to the main SAMBA_4_0 tree. NOTE: that it's not completely ready, but it's functional:-) metze (This used to be commit c78a2ddb28ec50d6570a83b1f66f18a5c3621731) --- source4/lib/registry/tools/regshell.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index b78f4256f0..e8b01081e8 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -173,7 +173,7 @@ static REG_KEY *cmd_help(REG_KEY *cur, int argc, char **argv) return NULL; } -REG_KEY *process_cmd(REG_KEY *k, char *line) +static REG_KEY *process_cmd(REG_KEY *k, char *line) { int argc; char **argv = NULL; @@ -196,7 +196,7 @@ REG_KEY *process_cmd(REG_KEY *k, char *line) return k; } -int main (int argc, char **argv) + int main(int argc, char **argv) { int opt; const char *backend = "dir"; -- cgit From bf52e242f53aeaac33eea69fbdfb3477634b90fb Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 22 May 2004 18:49:25 +0000 Subject: r825: - Introduce support for multiple roots (or 'hives') - Clean up rpc backend (possible now that multiple hives are supported) (This used to be commit 8cd1b6bc70510fe576135a66351e9e3ea895c9ff) --- source4/lib/registry/tools/regshell.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index e8b01081e8..26312ad4bc 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -27,6 +27,7 @@ * rmval/rm - remove value * rmkey/rmdir - remove key * mkkey/mkdir - make key + * ch - change hive * help * exit */ @@ -227,7 +228,7 @@ static REG_KEY *process_cmd(REG_KEY *k, char *line) setup_logging("regtree", True); - error = reg_get_root(h, &curkey); + error = reg_get_hive(h, 0, &curkey); if(!W_ERROR_IS_OK(error)) return 1; -- cgit From f371d2454298b0e64978c04056da5635d7e72921 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 23 May 2004 12:01:20 +0000 Subject: r828: Some fixes in the core and regshell concerning hives and unicode (This used to be commit 25c27b176c9905f3968e955f33a6db41b0102a38) --- source4/lib/registry/tools/regshell.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') 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); -- cgit From 4a137a7cf154955db5d1b1bb67017575a428d737 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 23 May 2004 12:12:50 +0000 Subject: r829: Implement 'hive' command (This used to be commit 2a87981bd0a79f0d685441d690e2f810d6ed86d0) --- source4/lib/registry/tools/regshell.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index dbddaa5dcf..b843e91120 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -147,7 +147,21 @@ static REG_KEY *cmd_rmval(REG_KEY *cur, int argc, char **argv) static REG_KEY *cmd_hive(REG_KEY *cur, int argc, char **argv) { - /* FIXME */ + int i; + WERROR error = WERR_OK; + for(i = 0; W_ERROR_IS_OK(error); i++) { + REG_KEY *hive; + error = reg_get_hive(reg_key_handle(cur), i, &hive); + if(!W_ERROR_IS_OK(error)) break; + + if(argc == 1) { + printf("%s\n", reg_key_name(hive)); + } else if(!strcmp(reg_key_name(hive), argv[1])) { + return hive; + } + reg_key_free(hive); + } + return NULL; } static REG_KEY *cmd_exit(REG_KEY *cur, int argc, char **argv) -- cgit From 93454ff3d8177fb71443808f01740dbbe7e46dd8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 8 Sep 2004 13:44:45 +0000 Subject: r2257: Tab completion support in regshell (complete command names and key names in the current key) (This used to be commit 83f9f8eaa4825bb49e2b160a1a810080ecae4d39) --- source4/lib/registry/tools/regshell.c | 116 +++++++++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index b843e91120..638ed70d5e 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -28,10 +28,23 @@ * rmkey/rmdir - remove key * mkkey/mkdir - make key * ch - change hive + * info - show key info * help * exit */ +static REG_KEY *cmd_info(REG_KEY *cur, int argc, char **argv) +{ + time_t last_mod; + printf("Name: %s\n", reg_key_name(cur)); + printf("Full path: %s\n", reg_key_get_path(cur)); + printf("Key Class: %s\n", reg_key_class(cur)); + last_mod = nt_time_to_unix(reg_key_last_modified(cur)); + printf("Time Last Modified: %s\n", ctime(&last_mod)); + /* FIXME: Security info */ + return cur; +} + static REG_KEY *cmd_pwd(REG_KEY *cur, int argc, char **argv) { printf("%s\n", reg_key_get_path_abs(cur)); @@ -180,6 +193,7 @@ struct { } regshell_cmds[] = { {"ck", "cd", "Change current key", cmd_ck }, {"ch", "hive", "Change current hive", cmd_hive }, + {"info", "i", "Show detailed information of a key", cmd_info }, {"list", "ls", "List values/keys in current key", cmd_ls }, {"mkkey", "mkdir", "Make new key", cmd_mkkey }, {"rmval", "rm", "Remove value", cmd_rmval }, @@ -224,6 +238,104 @@ static REG_KEY *process_cmd(REG_KEY *k, char *line) return k; } +#define MAX_COMPLETIONS 100 + +static REG_KEY *current_key = NULL; + +static char **reg_complete_command(const char *text, int end) +{ + /* Complete command */ + char **matches; + int i, len, samelen, count=1; + + matches = (char **)malloc(sizeof(matches[0])*MAX_COMPLETIONS); + if (!matches) return NULL; + matches[0] = NULL; + + len = strlen(text); + for (i=0;regshell_cmds[i].handle && count < MAX_COMPLETIONS-1;i++) { + if (strncmp(text, regshell_cmds[i].name, len) == 0) { + matches[count] = strdup(regshell_cmds[i].name); + if (!matches[count]) + goto cleanup; + if (count == 1) + samelen = strlen(matches[count]); + else + while (strncmp(matches[count], matches[count-1], samelen) != 0) + samelen--; + count++; + } + } + + switch (count) { + case 0: /* should never happen */ + case 1: + goto cleanup; + case 2: + matches[0] = strdup(matches[1]); + break; + default: + matches[0] = malloc(samelen+1); + if (!matches[0]) + goto cleanup; + strncpy(matches[0], matches[1], samelen); + matches[0][samelen] = 0; + } + matches[count] = NULL; + return matches; + +cleanup: + while (i >= 0) { + free(matches[i]); + i--; + } + free(matches); + return NULL; +} + +static char **reg_complete_key(const char *text, int end) +{ + REG_KEY *subkey; + int i, j = 0; + int len; + char **matches; + /* Complete argument */ + + matches = (char **)malloc(sizeof(matches[0])*MAX_COMPLETIONS); + if (!matches) return NULL; + matches[0] = NULL; + + len = strlen(text); + for(i = 0; j < MAX_COMPLETIONS-1; i++) { + WERROR status = reg_key_get_subkey_by_index(current_key, i, &subkey); + if(W_ERROR_IS_OK(status)) { + if(!strncmp(text, reg_key_name(subkey), len)) { + matches[j] = strdup(reg_key_name(subkey)); + j++; + } + reg_key_free(subkey); + } else if(W_ERROR_EQUAL(status, WERR_NO_MORE_ITEMS)) { + break; + } else { + printf("Error creating completion list: %s\n", win_errstr(status)); + return NULL; + } + } + matches[j] = NULL; + return matches; +} + +static char **reg_completion(const char *text, int start, int end) +{ + smb_readline_ca_char(' '); + + if (start == 0) { + return reg_complete_command(text, end); + } else { + return reg_complete_key(text, end); + } +} + int main(int argc, char **argv) { int opt; @@ -264,7 +376,9 @@ static REG_KEY *process_cmd(REG_KEY *k, char *line) asprintf(&prompt, "%s> ", reg_key_get_path_abs(curkey)); - line = smb_readline(prompt, NULL, NULL); + current_key = curkey; /* No way to pass a void * pointer + via readline :-( */ + line = smb_readline(prompt, NULL, reg_completion); if(!line) break; -- cgit From 369a5d64e462e084e6c5fe4984d56da18b2c92d9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 22 Sep 2004 12:32:31 +0000 Subject: r2518: Some long overdue changes: - Samba4-style code in lib/registry (struct registry_key instead of REG_KEY, etc) - Use hives (like Windows has drives) instead of one root key (like a Unix FS) - usability fixes in the GTK utilities (autodetect the username, enable/disable options, etc) - fix gwsam compile - several bugfixes in the registry rpc code - do charset conversion in nt4 registry backend (This used to be commit 2762ed3b9bf1d67dd54d63e02cddbfd71ea89892) --- source4/lib/registry/tools/regshell.c | 128 ++++++++++++++++++---------------- 1 file changed, 68 insertions(+), 60 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 638ed70d5e..78fe36f1a0 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -33,96 +33,96 @@ * exit */ -static REG_KEY *cmd_info(REG_KEY *cur, int argc, char **argv) +static struct registry_key *cmd_info(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) { time_t last_mod; - printf("Name: %s\n", reg_key_name(cur)); - printf("Full path: %s\n", reg_key_get_path(cur)); - printf("Key Class: %s\n", reg_key_class(cur)); - last_mod = nt_time_to_unix(reg_key_last_modified(cur)); + printf("Name: %s\n", cur->name); + printf("Full path: %s\n", cur->path); + printf("Key Class: %s\n", cur->class_name); + last_mod = nt_time_to_unix(cur->last_mod); printf("Time Last Modified: %s\n", ctime(&last_mod)); /* FIXME: Security info */ return cur; } -static REG_KEY *cmd_pwd(REG_KEY *cur, int argc, char **argv) +static struct registry_key *cmd_pwd(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) { - printf("%s\n", reg_key_get_path_abs(cur)); + printf("%s\n", cur->path); return cur; } -static REG_KEY *cmd_set(REG_KEY *cur, int argc, char **argv) +static struct registry_key *cmd_set(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) { /* FIXME */ return NULL; } -static REG_KEY *cmd_ck(REG_KEY *cur, int argc, char **argv) +static struct registry_key *cmd_ck(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) { - REG_KEY *new = NULL; + struct registry_key *new = NULL; WERROR error; if(argc < 2) { new = cur; } else { - error = reg_open_key(cur, argv[1], &new); + error = reg_open_key(mem_ctx, cur, argv[1], &new); if(!W_ERROR_IS_OK(error)) { DEBUG(0, ("Error opening specified key: %s\n", win_errstr(error))); return NULL; } } - printf("Current path is: %s\n", reg_key_get_path_abs(new)); + printf("Current path is: %s\n", new->path); return new; } -static REG_KEY *cmd_ls(REG_KEY *cur, int argc, char **argv) +static struct registry_key *cmd_ls(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) { int i; WERROR error; - REG_VAL *value; - REG_KEY *sub; - for(i = 0; W_ERROR_IS_OK(error = reg_key_get_subkey_by_index(cur, i, &sub)); i++) { - printf("K %s\n", reg_key_name(sub)); + struct registry_value *value; + struct registry_key *sub; + for(i = 0; W_ERROR_IS_OK(error = reg_key_get_subkey_by_index(mem_ctx, cur, i, &sub)); i++) { + printf("K %s\n", sub->name); } if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) { 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++) { - printf("V \"%s\" %s %s\n", reg_val_name(value), str_regtype(reg_val_type(value)), reg_val_data_string(value)); + for(i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(mem_ctx, cur, i, &value)); i++) { + printf("V \"%s\" %s %s\n", value->name, str_regtype(value->data_type), reg_val_data_string(mem_ctx, value)); } return NULL; } -static REG_KEY *cmd_mkkey(REG_KEY *cur, int argc, char **argv) +static struct registry_key *cmd_mkkey(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) { - REG_KEY *tmp; + struct registry_key *tmp; if(argc < 2) { fprintf(stderr, "Usage: mkkey \n"); return NULL; } - if(!W_ERROR_IS_OK(reg_key_add_name(cur, argv[1], 0, NULL, &tmp))) { + if(!W_ERROR_IS_OK(reg_key_add_name(mem_ctx, cur, argv[1], 0, NULL, &tmp))) { fprintf(stderr, "Error adding new subkey '%s'\n", argv[1]); return NULL; } - fprintf(stderr, "Successfully added new subkey '%s' to '%s'\n", argv[1], reg_key_get_path_abs(cur)); + fprintf(stderr, "Successfully added new subkey '%s' to '%s'\n", argv[1], cur->path); return NULL; } -static REG_KEY *cmd_rmkey(REG_KEY *cur, int argc, char **argv) +static struct registry_key *cmd_rmkey(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) { - REG_KEY *key; + struct registry_key *key; if(argc < 2) { fprintf(stderr, "Usage: rmkey \n"); return NULL; } - if(!W_ERROR_IS_OK(reg_open_key(cur, argv[1], &key))) { + if(!W_ERROR_IS_OK(reg_open_key(mem_ctx, cur, argv[1], &key))) { fprintf(stderr, "No such subkey '%s'\n", argv[1]); return NULL; } @@ -136,20 +136,20 @@ static REG_KEY *cmd_rmkey(REG_KEY *cur, int argc, char **argv) return NULL; } -static REG_KEY *cmd_rmval(REG_KEY *cur, int argc, char **argv) +static struct registry_key *cmd_rmval(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) { - REG_VAL *val; + struct registry_value *val; if(argc < 2) { fprintf(stderr, "Usage: rmval \n"); return NULL; } - if(!W_ERROR_IS_OK(reg_key_get_value_by_name(cur, argv[1], &val))) { + if(!W_ERROR_IS_OK(reg_key_get_value_by_name(mem_ctx, cur, argv[1], &val))) { fprintf(stderr, "No such value '%s'\n", argv[1]); return NULL; } - if(!W_ERROR_IS_OK(reg_val_del(val))) { + if(!W_ERROR_IS_OK(reg_del_value(val))) { fprintf(stderr, "Error deleting value '%s'\n", argv[1]); } else { fprintf(stderr, "Successfully deleted value '%s'\n", argv[1]); @@ -158,38 +158,33 @@ 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) +static struct registry_key *cmd_hive(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) { int i; - WERROR error = WERR_OK; - for(i = 0; W_ERROR_IS_OK(error); i++) { - REG_KEY *hive; - error = reg_get_hive(reg_key_handle(cur), i, &hive); - if(!W_ERROR_IS_OK(error)) break; + for(i = 0; i < cur->hive->reg_ctx->num_hives; i++) { if(argc == 1) { - printf("%s\n", reg_key_name(hive)); - } else if(!strcmp(reg_key_name(hive), argv[1])) { - return hive; + printf("%s\n", cur->hive->reg_ctx->hives[i]->name); + } else if(!strcmp(cur->hive->reg_ctx->hives[i]->name, argv[1])) { + return cur->hive->reg_ctx->hives[i]->root; } - reg_key_free(hive); } return NULL; } -static REG_KEY *cmd_exit(REG_KEY *cur, int argc, char **argv) +static struct registry_key *cmd_exit(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) { exit(0); return NULL; } -static REG_KEY *cmd_help(REG_KEY *, int, char **); +static struct registry_key *cmd_help(TALLOC_CTX *mem_ctx, struct registry_key *, int, char **); struct { const char *name; const char *alias; const char *help; - REG_KEY *(*handle)(REG_KEY *, int argc, char **argv); + struct registry_key *(*handle)(TALLOC_CTX *mem_ctx, struct registry_key *, int argc, char **argv); } regshell_cmds[] = { {"ck", "cd", "Change current key", cmd_ck }, {"ch", "hive", "Change current hive", cmd_hive }, @@ -205,7 +200,7 @@ struct { {NULL } }; -static REG_KEY *cmd_help(REG_KEY *cur, int argc, char **argv) +static struct registry_key *cmd_help(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) { int i; printf("Available commands:\n"); @@ -215,7 +210,7 @@ static REG_KEY *cmd_help(REG_KEY *cur, int argc, char **argv) return NULL; } -static REG_KEY *process_cmd(REG_KEY *k, char *line) +static struct registry_key *process_cmd(TALLOC_CTX *mem_ctx, struct registry_key *k, char *line) { int argc; char **argv = NULL; @@ -229,7 +224,7 @@ static REG_KEY *process_cmd(REG_KEY *k, char *line) for(i = 0; regshell_cmds[i].name; i++) { if(!strcmp(regshell_cmds[i].name, argv[0]) || (regshell_cmds[i].alias && !strcmp(regshell_cmds[i].alias, argv[0]))) { - return regshell_cmds[i].handle(k, argc, argv); + return regshell_cmds[i].handle(mem_ctx, k, argc, argv); } } @@ -240,7 +235,7 @@ static REG_KEY *process_cmd(REG_KEY *k, char *line) #define MAX_COMPLETIONS 100 -static REG_KEY *current_key = NULL; +static struct registry_key *current_key = NULL; static char **reg_complete_command(const char *text, int end) { @@ -295,10 +290,11 @@ cleanup: static char **reg_complete_key(const char *text, int end) { - REG_KEY *subkey; + struct registry_key *subkey; int i, j = 0; int len; char **matches; + TALLOC_CTX *mem_ctx; /* Complete argument */ matches = (char **)malloc(sizeof(matches[0])*MAX_COMPLETIONS); @@ -306,22 +302,24 @@ static char **reg_complete_key(const char *text, int end) matches[0] = NULL; len = strlen(text); + mem_ctx = talloc_init("completion"); for(i = 0; j < MAX_COMPLETIONS-1; i++) { - WERROR status = reg_key_get_subkey_by_index(current_key, i, &subkey); + WERROR status = reg_key_get_subkey_by_index(mem_ctx, current_key, i, &subkey); if(W_ERROR_IS_OK(status)) { - if(!strncmp(text, reg_key_name(subkey), len)) { - matches[j] = strdup(reg_key_name(subkey)); + if(!strncmp(text, subkey->name, len)) { + matches[j] = strdup(subkey->name); j++; } - reg_key_free(subkey); } else if(W_ERROR_EQUAL(status, WERR_NO_MORE_ITEMS)) { break; } else { printf("Error creating completion list: %s\n", win_errstr(status)); + talloc_destroy(mem_ctx); return NULL; } } matches[j] = NULL; + talloc_destroy(mem_ctx); return matches; } @@ -341,10 +339,11 @@ static char **reg_completion(const char *text, int start, int end) int opt; const char *backend = "dir"; const char *credentials = NULL; - REG_KEY *curkey = NULL; + struct registry_key *curkey = NULL; poptContext pc; WERROR error; - REG_HANDLE *h; + TALLOC_CTX *mem_ctx = talloc_init("cmd"); + struct registry_context *h; struct poptOption long_options[] = { POPT_AUTOHELP POPT_COMMON_SAMBA @@ -352,13 +351,19 @@ static char **reg_completion(const char *text, int start, int end) {"credentials", 'c', POPT_ARG_STRING, &credentials, 0, "credentials", NULL}, POPT_TABLEEND }; + + + if (!lp_load(dyn_CONFIGFILE,True,False,False)) { + fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE); + } + pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0); while((opt = poptGetNextOpt(pc)) != -1) { } - error = reg_open(backend, poptPeekArg(pc), credentials, &h); + error = reg_open(&h, backend, poptPeekArg(pc), credentials); if(!W_ERROR_IS_OK(error)) { fprintf(stderr, "Unable to open '%s' with backend '%s'\n", poptGetArg(pc), backend); return 1; @@ -367,14 +372,16 @@ static char **reg_completion(const char *text, int start, int end) setup_logging("regtree", True); - error = reg_get_hive(h, 0, &curkey); - - if(!W_ERROR_IS_OK(error)) return 1; + curkey = h->hives[0]->root; while(True) { char *line, *prompt; - asprintf(&prompt, "%s> ", reg_key_get_path_abs(curkey)); + if(curkey->hive->name) { + asprintf(&prompt, "%s:%s> ", curkey->hive->name, curkey->path); + } else { + asprintf(&prompt, "%s> ", curkey->path); + } current_key = curkey; /* No way to pass a void * pointer via readline :-( */ @@ -384,10 +391,11 @@ static char **reg_completion(const char *text, int start, int end) break; if(line[0] != '\n') { - REG_KEY *new = process_cmd(curkey, line); + struct registry_key *new = process_cmd(mem_ctx, curkey, line); if(new)curkey = new; } } + talloc_destroy(mem_ctx); return 0; } -- cgit From 9ba6c3885acb79d9c35e600f9a67f8ed0200edfd Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 29 Oct 2004 12:12:24 +0000 Subject: r3368: Default to rpc backend with binding "ncalrpc:" if no backend was specified in the various registry tools. Allow opening a remote registry to partly fail (I.e. if not all hives could be opened) (This used to be commit 313034b10d7a70d079e2bec1af38cf2a7cd918c1) --- source4/lib/registry/tools/regshell.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 78fe36f1a0..db7af9d5b6 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -337,7 +337,7 @@ static char **reg_completion(const char *text, int start, int end) int main(int argc, char **argv) { int opt; - const char *backend = "dir"; + const char *backend = "rpc"; const char *credentials = NULL; struct registry_key *curkey = NULL; poptContext pc; @@ -363,6 +363,8 @@ static char **reg_completion(const char *text, int start, int end) while((opt = poptGetNextOpt(pc)) != -1) { } + setup_logging("regtree", True); + error = reg_open(&h, backend, poptPeekArg(pc), credentials); if(!W_ERROR_IS_OK(error)) { fprintf(stderr, "Unable to open '%s' with backend '%s'\n", poptGetArg(pc), backend); @@ -370,8 +372,6 @@ static char **reg_completion(const char *text, int start, int end) } poptFreeContext(pc); - setup_logging("regtree", True); - curkey = h->hives[0]->root; while(True) { -- cgit From ead3508ac81ff3ed2a48753f3b5e23537ba6ec73 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 00:24:21 +0000 Subject: r3447: more include/system/XXX.h include files (This used to be commit 264ce9181089922547e8f6f67116f2d7277a5105) --- source4/lib/registry/tools/regshell.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index db7af9d5b6..8449446c86 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -20,6 +20,7 @@ */ #include "includes.h" +#include "system/time.h" /* * ck/cd - change key -- cgit From edbfc0f6e70150e321822365bf0eead2821551bd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 02:57:18 +0000 Subject: r3453: - split out the auth and popt includes - tidied up some of the system includes - moved a few more structures back from misc.idl to netlogon.idl and samr.idl now that pidl knows about inter-IDL dependencies (This used to be commit 7b7477ac42d96faac1b0ff361525d2c63cedfc64) --- source4/lib/registry/tools/regshell.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 8449446c86..fcc7204423 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -20,6 +20,7 @@ */ #include "includes.h" +#include "lib/cmdline/popt_common.h" #include "system/time.h" /* -- cgit From a42142439aee9e75796e25cdf05e042174926abf Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 06:52:59 +0000 Subject: r3464: split out registry.h, rap.h and ldap_server.h (This used to be commit 70d2090f6bf2c7e0caf1e9c020f330de88871f8e) --- source4/lib/registry/tools/regshell.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index fcc7204423..583624fbab 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -20,6 +20,7 @@ */ #include "includes.h" +#include "registry.h" #include "lib/cmdline/popt_common.h" #include "system/time.h" -- cgit From 6f214cc510a59b7a65ee9d4486baf14a3e579f73 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 3 Nov 2004 00:17:12 +0000 Subject: r3494: got rid of include/rewrite.h, and split out the dynconfig.h header (This used to be commit 558de54ec6432a4ae90aa14a585f32c6cd03ced2) --- source4/lib/registry/tools/regshell.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 583624fbab..d705a0b802 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -20,6 +20,7 @@ */ #include "includes.h" +#include "dynconfig.h" #include "registry.h" #include "lib/cmdline/popt_common.h" #include "system/time.h" -- cgit From 71db46ea665606384f2be1be708c74c97c9adfb2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Nov 2004 23:23:15 +0000 Subject: r3586: Fix some of the issues with the module init functions. Both subsystems and modules can now have init functions, which can be specified in .mk files (INIT_FUNCTION = ...) The build system will define : - SUBSYSTEM_init_static_modules that calls the init functions of all statically compiled modules. Failing to load will generate an error which is not fatal - BINARY_init_subsystems that calls the init functions (if defined) for the subsystems the binary depends on This removes the hack with the "static bool Initialised = " and the "lazy_init" functions (This used to be commit 7a8244761bfdfdfb48f8264d76951ebdfbf7bd8a) --- source4/lib/registry/tools/regshell.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index d705a0b802..8d044f6fa2 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -356,6 +356,7 @@ static char **reg_completion(const char *text, int start, int end) POPT_TABLEEND }; + regshell_init_subsystems; if (!lp_load(dyn_CONFIGFILE,True,False,False)) { fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE); -- cgit From 4183b2ac3832cdc2055d7eb3ed7121a9ea91085c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 2 Dec 2004 04:51:56 +0000 Subject: r4037: fixed a bunch of "might be uninitialised" warnings after enabling -O1 in my compile (This used to be commit 0928b1f5b68c858922c3ea6c27ed03b5091c6221) --- source4/lib/registry/tools/regshell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 8d044f6fa2..3333299088 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -245,7 +245,7 @@ static char **reg_complete_command(const char *text, int end) { /* Complete command */ char **matches; - int i, len, samelen, count=1; + int i, len, samelen=0, count=1; matches = (char **)malloc(sizeof(matches[0])*MAX_COMPLETIONS); if (!matches) return NULL; -- cgit From 6e6374cb5bcffb4df8bdb0a83327fff92b61ac84 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 3 Dec 2004 07:20:30 +0000 Subject: r4055: fixed more places to use type safe allocation macros (This used to be commit eec698254f67365f27b4b7569fa982e22472aca1) --- source4/lib/registry/tools/regshell.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 3333299088..f18b012720 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -247,7 +247,7 @@ static char **reg_complete_command(const char *text, int end) char **matches; int i, len, samelen=0, count=1; - matches = (char **)malloc(sizeof(matches[0])*MAX_COMPLETIONS); + matches = malloc_array_p(char *, MAX_COMPLETIONS); if (!matches) return NULL; matches[0] = NULL; @@ -301,7 +301,7 @@ static char **reg_complete_key(const char *text, int end) TALLOC_CTX *mem_ctx; /* Complete argument */ - matches = (char **)malloc(sizeof(matches[0])*MAX_COMPLETIONS); + matches = malloc_array_p(char *, MAX_COMPLETIONS); if (!matches) return NULL; matches[0] = NULL; -- cgit From 444a86792471c0bef33dde15c7a4a33e16a951b4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 10 Dec 2004 20:07:04 +0000 Subject: r4132: - Bunch of rather large fixes in the registry - Added some README files Not everything works yet, e.g. the EnumValue test appears to be broken. (This used to be commit c169e86c1f52763b83e77e509f89cb91f9b69071) --- source4/lib/registry/tools/regshell.c | 87 ++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 27 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index f18b012720..3fd9dab268 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -164,15 +164,23 @@ static struct registry_key *cmd_rmval(TALLOC_CTX *mem_ctx, struct registry_key * static struct registry_key *cmd_hive(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) { - int i; - for(i = 0; i < cur->hive->reg_ctx->num_hives; i++) { + if (!cur->hive->reg_ctx) { + fprintf(stderr, "Only one hive loaded\n"); + return cur; + } - if(argc == 1) { - printf("%s\n", cur->hive->reg_ctx->hives[i]->name); - } else if(!strcmp(cur->hive->reg_ctx->hives[i]->name, argv[1])) { - return cur->hive->reg_ctx->hives[i]->root; - } + if (argc == 1) { + printf("%s\n", cur->hive->root->name); + } else { + struct registry_key *newroot; + WERROR error = reg_get_hive_by_name(cur->hive->reg_ctx, argv[1], &newroot); + if (W_ERROR_IS_OK(error)) { + return newroot; + } else { + fprintf(stderr, "Can't switch to hive %s: %s\n", cur->hive->root->name, win_errstr(error)); + } } + return NULL; } @@ -274,11 +282,7 @@ static char **reg_complete_command(const char *text, int end) matches[0] = strdup(matches[1]); break; default: - matches[0] = malloc(samelen+1); - if (!matches[0]) - goto cleanup; - strncpy(matches[0], matches[1], samelen); - matches[0][samelen] = 0; + matches[0] = strndup(matches[1], samelen); } matches[count] = NULL; return matches; @@ -295,11 +299,11 @@ cleanup: static char **reg_complete_key(const char *text, int end) { struct registry_key *subkey; - int i, j = 0; + int i, j = 1; + int samelen = 0; int len; char **matches; TALLOC_CTX *mem_ctx; - /* Complete argument */ matches = malloc_array_p(char *, MAX_COMPLETIONS); if (!matches) return NULL; @@ -313,6 +317,12 @@ static char **reg_complete_key(const char *text, int end) if(!strncmp(text, subkey->name, len)) { matches[j] = strdup(subkey->name); j++; + + if (j == 1) + samelen = strlen(matches[j]); + else + while (strncmp(matches[j], matches[j-1], samelen) != 0) + samelen--; } } else if(W_ERROR_EQUAL(status, WERR_NO_MORE_ITEMS)) { break; @@ -322,8 +332,20 @@ static char **reg_complete_key(const char *text, int end) return NULL; } } - matches[j] = NULL; talloc_destroy(mem_ctx); + + if (j == 1) { /* No matches at all */ + SAFE_FREE(matches); + return NULL; + } + + if (j == 2) { /* Exact match */ + matches[0] = strdup(matches[1]); + } else { + matches[0] = strndup(matches[1], samelen); + } + + matches[j] = NULL; return matches; } @@ -341,18 +363,18 @@ static char **reg_completion(const char *text, int start, int end) int main(int argc, char **argv) { int opt; - const char *backend = "rpc"; - const char *credentials = NULL; + const char *backend = NULL; struct registry_key *curkey = NULL; poptContext pc; WERROR error; TALLOC_CTX *mem_ctx = talloc_init("cmd"); - struct registry_context *h; + const char *remote = NULL; + struct registry_context *h = NULL; struct poptOption long_options[] = { POPT_AUTOHELP - POPT_COMMON_SAMBA + POPT_COMMON_CREDENTIALS {"backend", 'b', POPT_ARG_STRING, &backend, 0, "backend to use", NULL}, - {"credentials", 'c', POPT_ARG_STRING, &credentials, 0, "credentials", NULL}, + {"remote", 'R', POPT_ARG_STRING, &remote, 0, "connect to specified remote server", NULL}, POPT_TABLEEND }; @@ -370,20 +392,31 @@ static char **reg_completion(const char *text, int start, int end) setup_logging("regtree", True); - error = reg_open(&h, backend, poptPeekArg(pc), credentials); + if (remote) { + error = reg_open_remote (&h, cmdline_get_username(), cmdline_get_userpassword(), remote); + } else if (backend) { + error = reg_open_hive(NULL, backend, poptGetArg(pc), NULL, &curkey); + } else { + error = reg_open_local(&h); + } + if(!W_ERROR_IS_OK(error)) { - fprintf(stderr, "Unable to open '%s' with backend '%s'\n", poptGetArg(pc), backend); + fprintf(stderr, "Unable to open registry\n"); return 1; } - poptFreeContext(pc); - - curkey = h->hives[0]->root; + if (h) { + /*FIXME: What if HKEY_CLASSES_ROOT is not present ? */ + reg_get_hive(h, HKEY_CLASSES_ROOT, &curkey); + } + + poptFreeContext(pc); + while(True) { char *line, *prompt; - if(curkey->hive->name) { - asprintf(&prompt, "%s:%s> ", curkey->hive->name, curkey->path); + if(curkey->hive->root->name) { + asprintf(&prompt, "%s:%s> ", curkey->hive->root->name, curkey->path); } else { asprintf(&prompt, "%s> ", curkey->path); } -- cgit From 969e14eae941427cf36c71b5588d7dd8e1f3c615 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 11 Dec 2004 20:06:40 +0000 Subject: r4155: More destinction between hives and predefined keys (This used to be commit c37d6f3c581673d74e7ec6a644ab6a7d13a55535) --- source4/lib/registry/tools/regshell.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 3fd9dab268..47d84c1f62 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -162,28 +162,6 @@ static struct registry_key *cmd_rmval(TALLOC_CTX *mem_ctx, struct registry_key * return NULL; } -static struct registry_key *cmd_hive(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) -{ - if (!cur->hive->reg_ctx) { - fprintf(stderr, "Only one hive loaded\n"); - return cur; - } - - if (argc == 1) { - printf("%s\n", cur->hive->root->name); - } else { - struct registry_key *newroot; - WERROR error = reg_get_hive_by_name(cur->hive->reg_ctx, argv[1], &newroot); - if (W_ERROR_IS_OK(error)) { - return newroot; - } else { - fprintf(stderr, "Can't switch to hive %s: %s\n", cur->hive->root->name, win_errstr(error)); - } - } - - return NULL; -} - static struct registry_key *cmd_exit(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) { exit(0); @@ -199,7 +177,6 @@ struct { struct registry_key *(*handle)(TALLOC_CTX *mem_ctx, struct registry_key *, int argc, char **argv); } regshell_cmds[] = { {"ck", "cd", "Change current key", cmd_ck }, - {"ch", "hive", "Change current hive", cmd_hive }, {"info", "i", "Show detailed information of a key", cmd_info }, {"list", "ls", "List values/keys in current key", cmd_ls }, {"mkkey", "mkdir", "Make new key", cmd_mkkey }, @@ -407,7 +384,7 @@ static char **reg_completion(const char *text, int start, int end) if (h) { /*FIXME: What if HKEY_CLASSES_ROOT is not present ? */ - reg_get_hive(h, HKEY_CLASSES_ROOT, &curkey); + reg_get_predefined_key(h, HKEY_CLASSES_ROOT, &curkey); } poptFreeContext(pc); -- cgit From 47fa1d33e4a6b9aeaf06ad2c12d9744bdf967bb9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 13 Dec 2004 00:45:29 +0000 Subject: r4166: More small API fixes, keep registry structs as small as possible. Implement DelValue in the RPC server (This used to be commit f6b9ec89af934e837069fb26c0e3491fc78ebc12) --- source4/lib/registry/tools/regshell.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 47d84c1f62..0a09708869 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -142,18 +142,12 @@ static struct registry_key *cmd_rmkey(TALLOC_CTX *mem_ctx, struct registry_key * static struct registry_key *cmd_rmval(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) { - struct registry_value *val; if(argc < 2) { fprintf(stderr, "Usage: rmval \n"); return NULL; } - if(!W_ERROR_IS_OK(reg_key_get_value_by_name(mem_ctx, cur, argv[1], &val))) { - fprintf(stderr, "No such value '%s'\n", argv[1]); - return NULL; - } - - if(!W_ERROR_IS_OK(reg_del_value(val))) { + if(!W_ERROR_IS_OK(reg_del_value(cur, argv[1]))) { fprintf(stderr, "Error deleting value '%s'\n", argv[1]); } else { fprintf(stderr, "Successfully deleted value '%s'\n", argv[1]); -- cgit From 1a340869c43f9ce741e8a4bd28ea01ec63301df5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 14 Dec 2004 20:49:18 +0000 Subject: r4204: Arguments to reg_del_key more like the RPC for more efficient usage Fix small bug in regpatch Fix segfault in regshell cmdline completion Implement set_value and del_value in ldb backend (This used to be commit 8e2aa58abeafa78afe7dafb9723f5f365e756527) --- source4/lib/registry/tools/regshell.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 0a09708869..6de8b25c9c 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -120,18 +120,12 @@ static struct registry_key *cmd_mkkey(TALLOC_CTX *mem_ctx, struct registry_key * static struct registry_key *cmd_rmkey(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) { - struct registry_key *key; if(argc < 2) { fprintf(stderr, "Usage: rmkey \n"); return NULL; } - if(!W_ERROR_IS_OK(reg_open_key(mem_ctx, cur, argv[1], &key))) { - fprintf(stderr, "No such subkey '%s'\n", argv[1]); - return NULL; - } - - if(!W_ERROR_IS_OK(reg_key_del(key))) { + if(!W_ERROR_IS_OK(reg_key_del(cur, argv[1]))) { fprintf(stderr, "Error deleting '%s'\n", argv[1]); } else { fprintf(stderr, "Successfully deleted '%s'\n", argv[1]); @@ -259,9 +253,10 @@ static char **reg_complete_command(const char *text, int end) return matches; cleanup: - while (i >= 0) { - free(matches[i]); - i--; + count--; + while (count >= 0) { + free(matches[count]); + count--; } free(matches); return NULL; -- cgit From d8c3428b3bb10075cec3b37adbca54db634d3b00 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 15 Dec 2004 00:16:54 +0000 Subject: r4209: Fix several smaller bugs Add "predef" and "set" commands in regshell Some of the remote calls from a Windows box work now. (This used to be commit f3e05782804fe4b4942fa966f1b9650c64bc234d) --- source4/lib/registry/tools/regshell.c | 92 ++++++++++++++++++++++++----------- 1 file changed, 64 insertions(+), 28 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 6de8b25c9c..1dd0e04561 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -37,7 +37,7 @@ * exit */ -static struct registry_key *cmd_info(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) +static struct registry_key *cmd_info(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) { time_t last_mod; printf("Name: %s\n", cur->name); @@ -49,19 +49,50 @@ static struct registry_key *cmd_info(TALLOC_CTX *mem_ctx, struct registry_key *c return cur; } -static struct registry_key *cmd_pwd(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) +static struct registry_key *cmd_predef(TALLOC_CTX *mem_ctx, struct registry_context *ctx, struct registry_key *cur, int argc, char **argv) +{ + struct registry_key *ret = NULL; + if (argc < 2) { + fprintf(stderr, "Usage: predef predefined-key-name\n"); + } else if (!ctx) { + fprintf(stderr, "No full registry loaded, no predefined keys defined\n"); + } else { + WERROR error = reg_get_predefined_key_by_name(ctx, argv[1], &ret); + + if (!W_ERROR_IS_OK(error)) { + fprintf(stderr, "Error opening predefined key %s: %s\n", argv[1], win_errstr(error)); + ret = NULL; + } + } + return ret; +} + +static struct registry_key *cmd_pwd(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) { printf("%s\n", cur->path); return cur; } -static struct registry_key *cmd_set(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) +static struct registry_key *cmd_set(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) { - /* FIXME */ - return NULL; + if (argc < 4) { + fprintf(stderr, "Usage: set value-name type value\n"); + } else { + struct registry_value *val; + if (reg_string_to_val(mem_ctx, argv[2], argv[3], &val)) { + WERROR error = reg_val_set(cur, argv[1], val->data_type, val->data_blk, val->data_len); + if (!W_ERROR_IS_OK(error)) { + fprintf(stderr, "Error setting value: %s\n", win_errstr(error)); + return NULL; + } + } else { + fprintf(stderr, "Unable to interpret data\n"); + } + } + return cur; } -static struct registry_key *cmd_ck(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) +static struct registry_key *cmd_ck(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) { struct registry_key *new = NULL; WERROR error; @@ -80,7 +111,7 @@ static struct registry_key *cmd_ck(TALLOC_CTX *mem_ctx, struct registry_key *cur return new; } -static struct registry_key *cmd_ls(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) +static struct registry_key *cmd_ls(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) { int i; WERROR error; @@ -100,7 +131,7 @@ static struct registry_key *cmd_ls(TALLOC_CTX *mem_ctx, struct registry_key *cur return NULL; } -static struct registry_key *cmd_mkkey(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) +static struct registry_key *cmd_mkkey(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) { struct registry_key *tmp; if(argc < 2) { @@ -113,12 +144,10 @@ static struct registry_key *cmd_mkkey(TALLOC_CTX *mem_ctx, struct registry_key * return NULL; } - fprintf(stderr, "Successfully added new subkey '%s' to '%s'\n", argv[1], cur->path); - return NULL; } -static struct registry_key *cmd_rmkey(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) +static struct registry_key *cmd_rmkey(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) { if(argc < 2) { fprintf(stderr, "Usage: rmkey \n"); @@ -134,7 +163,7 @@ static struct registry_key *cmd_rmkey(TALLOC_CTX *mem_ctx, struct registry_key * return NULL; } -static struct registry_key *cmd_rmval(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) +static struct registry_key *cmd_rmval(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) { if(argc < 2) { fprintf(stderr, "Usage: rmval \n"); @@ -150,19 +179,19 @@ static struct registry_key *cmd_rmval(TALLOC_CTX *mem_ctx, struct registry_key * return NULL; } -static struct registry_key *cmd_exit(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) +static struct registry_key *cmd_exit(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) { exit(0); return NULL; } -static struct registry_key *cmd_help(TALLOC_CTX *mem_ctx, struct registry_key *, int, char **); +static struct registry_key *cmd_help(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *, int, char **); struct { const char *name; const char *alias; const char *help; - struct registry_key *(*handle)(TALLOC_CTX *mem_ctx, struct registry_key *, int argc, char **argv); + struct registry_key *(*handle)(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *, int argc, char **argv); } regshell_cmds[] = { {"ck", "cd", "Change current key", cmd_ck }, {"info", "i", "Show detailed information of a key", cmd_info }, @@ -174,10 +203,11 @@ struct { {"set", "update", "Update value", cmd_set }, {"help", "?", "Help", cmd_help }, {"exit", "quit", "Exit", cmd_exit }, + {"predef", "predefined", "Go to predefined key", cmd_predef }, {NULL } }; -static struct registry_key *cmd_help(TALLOC_CTX *mem_ctx, struct registry_key *cur, int argc, char **argv) +static struct registry_key *cmd_help(TALLOC_CTX *mem_ctx, struct registry_context *ctx, struct registry_key *cur, int argc, char **argv) { int i; printf("Available commands:\n"); @@ -187,7 +217,7 @@ static struct registry_key *cmd_help(TALLOC_CTX *mem_ctx, struct registry_key *c return NULL; } -static struct registry_key *process_cmd(TALLOC_CTX *mem_ctx, struct registry_key *k, char *line) +static struct registry_key *process_cmd(TALLOC_CTX *mem_ctx, struct registry_context *ctx, struct registry_key *k, char *line) { int argc; char **argv = NULL; @@ -201,7 +231,7 @@ static struct registry_key *process_cmd(TALLOC_CTX *mem_ctx, struct registry_key for(i = 0; regshell_cmds[i].name; i++) { if(!strcmp(regshell_cmds[i].name, argv[0]) || (regshell_cmds[i].alias && !strcmp(regshell_cmds[i].alias, argv[0]))) { - return regshell_cmds[i].handle(mem_ctx, k, argc, argv); + return regshell_cmds[i].handle(mem_ctx, ctx, k, argc, argv); } } @@ -214,7 +244,7 @@ static struct registry_key *process_cmd(TALLOC_CTX *mem_ctx, struct registry_key static struct registry_key *current_key = NULL; -static char **reg_complete_command(const char *text, int end) +static char **reg_complete_command(const char *text, int start, int end) { /* Complete command */ char **matches; @@ -262,23 +292,28 @@ cleanup: return NULL; } -static char **reg_complete_key(const char *text, int end) +static char **reg_complete_key(const char *text, int start, int end) { + struct registry_key *base; struct registry_key *subkey; int i, j = 1; int samelen = 0; int len; char **matches; + const char *base_n = ""; TALLOC_CTX *mem_ctx; + WERROR status; matches = malloc_array_p(char *, MAX_COMPLETIONS); if (!matches) return NULL; matches[0] = NULL; + mem_ctx = talloc_init("completion"); + + base = current_key; len = strlen(text); - mem_ctx = talloc_init("completion"); for(i = 0; j < MAX_COMPLETIONS-1; i++) { - WERROR status = reg_key_get_subkey_by_index(mem_ctx, current_key, i, &subkey); + status = reg_key_get_subkey_by_index(mem_ctx, base, i, &subkey); if(W_ERROR_IS_OK(status)) { if(!strncmp(text, subkey->name, len)) { matches[j] = strdup(subkey->name); @@ -298,18 +333,19 @@ static char **reg_complete_key(const char *text, int end) return NULL; } } - talloc_destroy(mem_ctx); if (j == 1) { /* No matches at all */ SAFE_FREE(matches); + talloc_destroy(mem_ctx); return NULL; } if (j == 2) { /* Exact match */ - matches[0] = strdup(matches[1]); + asprintf(&matches[0], "%s%s", base_n, matches[1]); } else { - matches[0] = strndup(matches[1], samelen); + asprintf(&matches[0], "%s%s", base_n, talloc_strndup(mem_ctx, matches[1], samelen)); } + talloc_destroy(mem_ctx); matches[j] = NULL; return matches; @@ -320,9 +356,9 @@ static char **reg_completion(const char *text, int start, int end) smb_readline_ca_char(' '); if (start == 0) { - return reg_complete_command(text, end); + return reg_complete_command(text, start, end); } else { - return reg_complete_key(text, end); + return reg_complete_key(text, start, end); } } @@ -395,7 +431,7 @@ static char **reg_completion(const char *text, int start, int end) break; if(line[0] != '\n') { - struct registry_key *new = process_cmd(mem_ctx, curkey, line); + struct registry_key *new = process_cmd(mem_ctx, h, curkey, line); if(new)curkey = new; } } -- cgit From 759da3b915e2006d4c87b5ace47f399accd9ce91 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 27 Jan 2005 07:08:20 +0000 Subject: r5037: got rid of all of the TALLOC_DEPRECATED stuff. My apologies for the large commit. I thought this was worthwhile to get done for consistency. (This used to be commit ec32b22ed5ec224f6324f5e069d15e92e38e15c0) --- source4/lib/registry/tools/regshell.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 1dd0e04561..ac7dbca49b 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -329,14 +329,14 @@ static char **reg_complete_key(const char *text, int start, int end) break; } else { printf("Error creating completion list: %s\n", win_errstr(status)); - talloc_destroy(mem_ctx); + talloc_free(mem_ctx); return NULL; } } if (j == 1) { /* No matches at all */ SAFE_FREE(matches); - talloc_destroy(mem_ctx); + talloc_free(mem_ctx); return NULL; } @@ -345,7 +345,7 @@ static char **reg_complete_key(const char *text, int start, int end) } else { asprintf(&matches[0], "%s%s", base_n, talloc_strndup(mem_ctx, matches[1], samelen)); } - talloc_destroy(mem_ctx); + talloc_free(mem_ctx); matches[j] = NULL; return matches; @@ -435,7 +435,7 @@ static char **reg_completion(const char *text, int start, int end) if(new)curkey = new; } } - talloc_destroy(mem_ctx); + talloc_free(mem_ctx); return 0; } -- cgit From 3e88cae57bd473b492735f90be86940e44e0e78d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 7 Mar 2005 12:02:48 +0000 Subject: r5680: Don't crash if none of the predefined keys is available (reported by Alexander) (This used to be commit 0d789872a890062b0b95aa039bb853bb6c07b2d0) --- source4/lib/registry/tools/regshell.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index ac7dbca49b..ee80837bab 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -408,8 +408,34 @@ static char **reg_completion(const char *text, int start, int end) } if (h) { - /*FIXME: What if HKEY_CLASSES_ROOT is not present ? */ - reg_get_predefined_key(h, HKEY_CLASSES_ROOT, &curkey); + enum reg_predefined_key try_hkeys[] = { + HKEY_CLASSES_ROOT, + HKEY_CURRENT_USER, + HKEY_LOCAL_MACHINE, + HKEY_USERS, + HKEY_PERFORMANCE_DATA, + HKEY_CURRENT_CONFIG, + HKEY_DYN_DATA, + HKEY_PERFORMANCE_TEXT, + HKEY_PERFORMANCE_NLSTEXT, + 0 + }; + int i; + + for (i = 0; try_hkeys[i]; i++) { + WERROR err; + err = reg_get_predefined_key(h, HKEY_CLASSES_ROOT, &curkey); + if (W_ERROR_IS_OK(err)) { + break; + } else { + curkey = NULL; + } + } + } + + if (!curkey) { + fprintf(stderr, "Unable to access any of the predefined keys\n"); + return -1; } poptFreeContext(pc); -- cgit From 02075be0bbc2095073f8898350fded64a7c97c79 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 21 Mar 2005 02:08:38 +0000 Subject: r5917: First step in using the new cli_credentials structure. This patch puts support for it into popt_common, adds a few utility functions (in lib/credentials.c) and the callback functions for the command-line (lib/cmdline/credentials.c). Comments are welcome :-) (This used to be commit 1d49b57c50fe8c2683ea23e9df41ce8ad774db98) --- source4/lib/registry/tools/regshell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index ee80837bab..cab2c5e34b 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -395,7 +395,7 @@ static char **reg_completion(const char *text, int start, int end) setup_logging("regtree", True); if (remote) { - error = reg_open_remote (&h, cmdline_get_username(), cmdline_get_userpassword(), remote); + error = reg_open_remote (&h, cli_credentials_get_username(cmdline_credentials), cli_credentials_get_password(cmdline_credentials), remote); } else if (backend) { error = reg_open_hive(NULL, backend, poptGetArg(pc), NULL, &curkey); } else { -- cgit From 05bc2d7b2c11a3583a6d1221cfbd618eb6730518 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 21 Mar 2005 21:22:07 +0000 Subject: r5928: Use cli_credentials in: - gtk+ (returned by GtkHostBindingDialog as well now) - torture/ - librpc/ - lib/com/dcom/ (This used to be commit ccefd782335e01e8e6ecb2bcd28a4f999c53b1a6) --- source4/lib/registry/tools/regshell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index cab2c5e34b..bb7533e55e 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -395,7 +395,7 @@ static char **reg_completion(const char *text, int start, int end) setup_logging("regtree", True); if (remote) { - error = reg_open_remote (&h, cli_credentials_get_username(cmdline_credentials), cli_credentials_get_password(cmdline_credentials), remote); + error = reg_open_remote (&h, cmdline_credentials, remote); } else if (backend) { error = reg_open_hive(NULL, backend, poptGetArg(pc), NULL, &curkey); } else { -- cgit From 5b18cf22680c76abb1262a6b75a30b8a37899467 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 15 May 2005 20:16:26 +0000 Subject: r6795: Make some functions static and remove some unused ones. (This used to be commit 46509eb89980bfe6dabd71264d570ea356ee5a22) --- source4/lib/registry/tools/regshell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index bb7533e55e..ecc2bfc7aa 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -187,7 +187,7 @@ static struct registry_key *cmd_exit(TALLOC_CTX *mem_ctx, struct registry_contex static struct registry_key *cmd_help(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *, int, char **); -struct { +static struct { const char *name; const char *alias; const char *help; -- cgit From 4867378592656d812fcd02d1ea24ccb2c99bf9b7 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 24 May 2005 05:51:20 +0000 Subject: r6951: Fix all calls to setup_logging() that use 'True' as a second argument. In Samba4 this is now an enum. Possibly by accident, True just happens to map to the right value in this case. (-: (This used to be commit affacc539864435cbc749a4c1a6b848c61b7182b) --- source4/lib/registry/tools/regshell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index ecc2bfc7aa..f1fd740830 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -392,7 +392,7 @@ static char **reg_completion(const char *text, int start, int end) while((opt = poptGetNextOpt(pc)) != -1) { } - setup_logging("regtree", True); + setup_logging("regtree", DEBUG_STDOUT); if (remote) { error = reg_open_remote (&h, cmdline_credentials, remote); -- cgit From 77c3d463c88af9f41f5f76446d380c80262ce712 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 3 Jun 2005 20:44:46 +0000 Subject: r7248: Remove enum that is causing trouble on AIX (This used to be commit 512536c9165eb4a630c8bf4e43e71def26006047) --- source4/lib/registry/tools/regshell.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index f1fd740830..03cb09c443 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -408,7 +408,7 @@ static char **reg_completion(const char *text, int start, int end) } if (h) { - enum reg_predefined_key try_hkeys[] = { + uint32_t try_hkeys[] = { HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, @@ -424,7 +424,7 @@ static char **reg_completion(const char *text, int start, int end) for (i = 0; try_hkeys[i]; i++) { WERROR err; - err = reg_get_predefined_key(h, HKEY_CLASSES_ROOT, &curkey); + err = reg_get_predefined_key(h, try_hkeys[i], &curkey); if (W_ERROR_IS_OK(err)) { break; } else { -- cgit From 2b4791ae733488845b2c36bca64db695203de571 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 13 Jun 2005 08:12:39 +0000 Subject: r7525: Unify lp_load(), load_interfaces and logging setup into popt(). There is now a new --debug-stderr option to enable debug to STDERR. popt isn't perfect, but the callbacks are used in all the main Samba binaries, and should be used in the rest. This avoids duplicated code, and ensures every binary is setup correctly. This also ensures the setup happens early enough to have -s function, and have a correct impact on the credentials code. (Fixing a bug that frustrated tridge earlier today). The only 'subtle' aspect of all this is that I'm pretty sure that the SAMBA_COMMON popt code must be above the CREDENTIALS code, in the popt tables. Andrew Bartlett (This used to be commit 50f3c2b3a22971f40e0d3a88127b5120bfc47591) --- source4/lib/registry/tools/regshell.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 03cb09c443..0c53f737b8 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -374,26 +374,21 @@ static char **reg_completion(const char *text, int start, int end) struct registry_context *h = NULL; struct poptOption long_options[] = { POPT_AUTOHELP - POPT_COMMON_CREDENTIALS {"backend", 'b', POPT_ARG_STRING, &backend, 0, "backend to use", NULL}, {"remote", 'R', POPT_ARG_STRING, &remote, 0, "connect to specified remote server", NULL}, + POPT_COMMON_SAMBA + POPT_COMMON_CREDENTIALS + POPT_COMMON_VERSION POPT_TABLEEND }; regshell_init_subsystems; - if (!lp_load(dyn_CONFIGFILE,True,False,False)) { - fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE); - } - - pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0); while((opt = poptGetNextOpt(pc)) != -1) { } - setup_logging("regtree", DEBUG_STDOUT); - if (remote) { error = reg_open_remote (&h, cmdline_credentials, remote); } else if (backend) { -- cgit From af237084ecd4f9928c6c282b9c5c73598d5c73d6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 16 Jun 2005 11:36:09 +0000 Subject: r7633: this patch started as an attempt to make the dcerpc code use a given event_context for the socket_connect() call, so that when things that use dcerpc are running alongside anything else it doesn't block the whole process during a connect. Then of course I needed to change any code that created a dcerpc connection (such as the auth code) to also take an event context, and anything that called that and so on .... thus the size of the patch. There were 3 places where I punted: - abartlet wanted me to add a gensec_set_event_context() call instead of adding it to the gensec init calls. Andrew, my apologies for not doing this. I didn't do it as adding a new parameter allowed me to catch all the callers with the compiler. Now that its done, we could go back and use gensec_set_event_context() - the ejs code calls auth initialisation, which means it should pass in the event context from the web server. I punted on that. Needs fixing. - I used a NULL event context in dcom_get_pipe(). This is equivalent to what we did already, but should be fixed to use a callers event context. Jelmer, can you think of a clean way to do that? I also cleaned up a couple of things: - libnet_context_destroy() makes no sense. I removed it. - removed some unused vars in various places (This used to be commit 3a3025485bdb8f600ab528c0b4b4eef0c65e3fc9) --- source4/lib/registry/tools/regshell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 0c53f737b8..108cc17336 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -390,7 +390,7 @@ static char **reg_completion(const char *text, int start, int end) } if (remote) { - error = reg_open_remote (&h, cmdline_credentials, remote); + error = reg_open_remote (&h, cmdline_credentials, remote, NULL); } else if (backend) { error = reg_open_hive(NULL, backend, poptGetArg(pc), NULL, &curkey); } else { -- cgit From 02b3abec25ed0b303906c5dae9dd527171762d9a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 3 Sep 2005 17:17:30 +0000 Subject: r10007: Merge data_blk and data_len member of registry_value into a DATA_BLOB. Fix handling of REG_DWORD in the LDB backend. Fix a couple of warnings (This used to be commit 709fdc7ebf5a77cfb50359fad978884777decc3b) --- source4/lib/registry/tools/regshell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 108cc17336..496b9dc7e5 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -80,7 +80,7 @@ static struct registry_key *cmd_set(TALLOC_CTX *mem_ctx, struct registry_context } else { struct registry_value *val; if (reg_string_to_val(mem_ctx, argv[2], argv[3], &val)) { - WERROR error = reg_val_set(cur, argv[1], val->data_type, val->data_blk, val->data_len); + WERROR error = reg_val_set(cur, argv[1], val->data_type, val->data); if (!W_ERROR_IS_OK(error)) { fprintf(stderr, "Error setting value: %s\n", win_errstr(error)); return NULL; -- cgit From ff7342a4ad1cc1ac8571c86466c197b6a8fa6b41 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 4 Sep 2005 14:47:19 +0000 Subject: r10026: Move registry header file to lib/registry Add support for showing security descriptor in regshell Add support for saving files in NT4 registry backend (This used to be commit 47cecd4726e6568f1aafb404646d2664f630a9bb) --- source4/lib/registry/tools/regshell.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 496b9dc7e5..08da5ae2fd 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -21,9 +21,10 @@ #include "includes.h" #include "dynconfig.h" -#include "registry.h" +#include "lib/registry/registry.h" #include "lib/cmdline/popt_common.h" #include "system/time.h" +#include "librpc/gen_ndr/ndr_security.h" /* * ck/cd - change key @@ -33,19 +34,30 @@ * mkkey/mkdir - make key * ch - change hive * info - show key info + * save - save hive * help * exit */ static struct registry_key *cmd_info(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) { + struct security_descriptor *sec_desc = NULL; time_t last_mod; + WERROR error; + printf("Name: %s\n", cur->name); printf("Full path: %s\n", cur->path); printf("Key Class: %s\n", cur->class_name); last_mod = nt_time_to_unix(cur->last_mod); printf("Time Last Modified: %s\n", ctime(&last_mod)); - /* FIXME: Security info */ + + error = reg_get_sec_desc(mem_ctx, cur, &sec_desc); + if (!W_ERROR_IS_OK(error)) { + printf("Error getting security descriptor\n"); + } else { + ndr_print_debug((ndr_print_fn_t)ndr_print_security_descriptor, "Security", sec_desc); + } + talloc_free(sec_desc); return cur; } -- cgit From db400b4a58d834cca165f1fc6ad84e9f5ace280f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 6 Sep 2005 15:44:08 +0000 Subject: r10052: Add 'print' command (This used to be commit d99c9e2817fbbe2a0a34910672c8473889bc6176) --- source4/lib/registry/tools/regshell.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 08da5ae2fd..24979943b3 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -35,6 +35,7 @@ * ch - change hive * info - show key info * save - save hive + * print - print value * help * exit */ @@ -123,6 +124,26 @@ static struct registry_key *cmd_ck(TALLOC_CTX *mem_ctx, struct registry_context return new; } +static struct registry_key *cmd_print(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) +{ + struct registry_value *value; + WERROR error; + + if (argc != 2) { + fprintf(stderr, "Usage: print "); + return NULL; + } + + error = reg_key_get_value_by_name(mem_ctx, cur, argv[1], &value); + if (!W_ERROR_IS_OK(error)) { + fprintf(stderr, "No such value '%s'\n", argv[1]); + return NULL; + } + + printf("%s\n%s\n", str_regtype(value->data_type), reg_val_data_string(mem_ctx, value)); + return NULL; +} + static struct registry_key *cmd_ls(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) { int i; @@ -208,6 +229,7 @@ static struct { {"ck", "cd", "Change current key", cmd_ck }, {"info", "i", "Show detailed information of a key", cmd_info }, {"list", "ls", "List values/keys in current key", cmd_ls }, + {"print", "p", "Print value", cmd_print }, {"mkkey", "mkdir", "Make new key", cmd_mkkey }, {"rmval", "rm", "Remove value", cmd_rmval }, {"rmkey", "rmdir", "Remove key", cmd_rmkey }, -- cgit From 5e7a0fb5349422cfb782c0348f98505011d27391 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 29 Sep 2005 11:51:06 +0000 Subject: r10604: Put in the new registry "patchfile" code (similar to ldif for LDB); not finished yet. (This used to be commit b405b27ba4bf4ddbaff9ca58926d94d1b2fd09f6) --- source4/lib/registry/tools/regshell.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 24979943b3..cd67f09c33 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -92,7 +92,7 @@ static struct registry_key *cmd_set(TALLOC_CTX *mem_ctx, struct registry_context fprintf(stderr, "Usage: set value-name type value\n"); } else { struct registry_value *val; - if (reg_string_to_val(mem_ctx, argv[2], argv[3], &val)) { + if (reg_string_to_val(mem_ctx, argv[2], argv[3], &val->data_type, &val->data)) { WERROR error = reg_val_set(cur, argv[1], val->data_type, val->data); if (!W_ERROR_IS_OK(error)) { fprintf(stderr, "Error setting value: %s\n", win_errstr(error)); @@ -140,7 +140,7 @@ static struct registry_key *cmd_print(TALLOC_CTX *mem_ctx, struct registry_conte return NULL; } - printf("%s\n%s\n", str_regtype(value->data_type), reg_val_data_string(mem_ctx, value)); + printf("%s\n%s\n", str_regtype(value->data_type), reg_val_data_string(mem_ctx, value->data_type, &value->data)); return NULL; } @@ -159,7 +159,7 @@ static struct registry_key *cmd_ls(TALLOC_CTX *mem_ctx, struct registry_context } for(i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(mem_ctx, cur, i, &value)); i++) { - printf("V \"%s\" %s %s\n", value->name, str_regtype(value->data_type), reg_val_data_string(mem_ctx, value)); + printf("V \"%s\" %s %s\n", value->name, str_regtype(value->data_type), reg_val_data_string(mem_ctx, value->data_type, &value->data)); } return NULL; -- cgit From 6aafed9600a3fa05932668c70fc0e20f3724dab6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 Dec 2005 18:48:23 +0000 Subject: r12499: Move smb_build.h out of includes.h (This used to be commit c92ace494f92084ddf178626cdf392d151043bc7) --- source4/lib/registry/tools/regshell.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index cd67f09c33..ef5c598989 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -25,6 +25,7 @@ #include "lib/cmdline/popt_common.h" #include "system/time.h" #include "librpc/gen_ndr/ndr_security.h" +#include "smb_build.h" /* * ck/cd - change key -- cgit From 09c44f6cae89621871d2e5475b0c0f99c25804b4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 Dec 2005 21:58:31 +0000 Subject: r12500: Use init functions explicitly in a few more places. 'gensec' and 'librpc' are the only two subsystems left to convert. (This used to be commit f6bbc72996aeee8607fc583140fd60be0e06e969) --- source4/lib/registry/tools/regshell.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index ef5c598989..52bda8aa42 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -419,6 +419,8 @@ static char **reg_completion(const char *text, int start, int end) regshell_init_subsystems; + registry_init(); + pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0); while((opt = poptGetNextOpt(pc)) != -1) { -- cgit From d4de4c2d210d2e8c9b5aedf70695594809ad6a0b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 Dec 2005 13:16:54 +0000 Subject: r12608: Remove some unused #include lines. (This used to be commit 70e7449318aa0e9d2639c76730a7d1683b2f4981) --- source4/lib/registry/tools/regshell.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 52bda8aa42..c858b37f4a 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -20,11 +20,9 @@ */ #include "includes.h" -#include "dynconfig.h" #include "lib/registry/registry.h" #include "lib/cmdline/popt_common.h" #include "system/time.h" -#include "librpc/gen_ndr/ndr_security.h" #include "smb_build.h" /* -- cgit From aa9f67163cd2df2a815ef585edad1951343b82c8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 Dec 2005 22:46:16 +0000 Subject: r12620: Get rid of automatically generated lists of init functions of subsystems. This allows Samba libraries to be used by other projects (and parts of Samba to be built as shared libraries). (This used to be commit 44f0aba715bfedc7e1ee3d07e9a101a91dbd84b3) --- source4/lib/registry/tools/regshell.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index c858b37f4a..89493c761e 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -23,7 +23,6 @@ #include "lib/registry/registry.h" #include "lib/cmdline/popt_common.h" #include "system/time.h" -#include "smb_build.h" /* * ck/cd - change key @@ -415,8 +414,6 @@ static char **reg_completion(const char *text, int start, int end) POPT_TABLEEND }; - regshell_init_subsystems; - registry_init(); pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0); -- cgit From f8fdbc967c774a1d62f87a534e4990d83ecc6b67 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 7 Mar 2006 14:34:32 +0000 Subject: r13944: Yet another round of splitups. (This used to be commit f87debeb12cebd734b47314554ab671c9e06237e) --- source4/lib/registry/tools/regshell.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 89493c761e..4d1bb95f35 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -22,6 +22,7 @@ #include "includes.h" #include "lib/registry/registry.h" #include "lib/cmdline/popt_common.h" +#include "lib/registry/reg_backend_rpc.h" #include "system/time.h" /* -- cgit From 7a121583b496a8fc0c1fcf44504d814700273e40 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 13 Mar 2006 22:36:07 +0000 Subject: r14349: Kill proto.h! Prototypes are now spread over multiple headers, usually one per subsystem. This change is required to allow proper header dependencies later on, without recompiling Samba each time the mtime of any source file changes. (This used to be commit 3da79bf909f801386a52e6013db399c384d0401c) --- source4/lib/registry/tools/regshell.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 4d1bb95f35..8829d862d3 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -24,6 +24,7 @@ #include "lib/cmdline/popt_common.h" #include "lib/registry/reg_backend_rpc.h" #include "system/time.h" +#include "lib/replace/readline.h" /* * ck/cd - change key -- cgit From 8528016978b084213ef53d66e1b6e831b1a01acc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 16 Mar 2006 00:23:11 +0000 Subject: r14464: Don't include ndr_BASENAME.h files unless strictly required, instead try to include just the BASENAME.h files (containing only structs) (This used to be commit 3dd477ca5147f28a962b8437e2611a8222d706bd) --- source4/lib/registry/tools/regshell.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 8829d862d3..c0bffa78e5 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -25,6 +25,7 @@ #include "lib/registry/reg_backend_rpc.h" #include "system/time.h" #include "lib/replace/readline.h" +#include "librpc/gen_ndr/ndr_security.h" /* * ck/cd - change key -- cgit From 35349a58df5b69446607fbd742a05f57f3515319 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 18 Mar 2006 15:42:57 +0000 Subject: r14542: Remove librpc, libndr and libnbt from includes.h (This used to be commit 51b4270513752d2eafbe77f9de598de16ef84a1f) --- source4/lib/registry/tools/regshell.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index c0bffa78e5..0812cad73f 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -22,6 +22,7 @@ #include "includes.h" #include "lib/registry/registry.h" #include "lib/cmdline/popt_common.h" +#include "lib/events/events.h" #include "lib/registry/reg_backend_rpc.h" #include "system/time.h" #include "lib/replace/readline.h" -- cgit From d64ccc01769ce274c74d8458f9ef81cdcc8986f6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 21 Mar 2006 01:30:22 +0000 Subject: r14599: Pass ACLs down the registry layer. (This used to be commit 6cdefd8945eee5513a6993350ea71f12d4dbd6fa) --- source4/lib/registry/tools/regshell.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 0812cad73f..19f544bccf 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -426,11 +426,11 @@ static char **reg_completion(const char *text, int start, int end) } if (remote) { - error = reg_open_remote (&h, cmdline_credentials, remote, NULL); + error = reg_open_remote (&h, NULL, cmdline_credentials, remote, NULL); } else if (backend) { - error = reg_open_hive(NULL, backend, poptGetArg(pc), NULL, &curkey); + error = reg_open_hive(NULL, backend, poptGetArg(pc), NULL, cmdline_credentials, &curkey); } else { - error = reg_open_local(&h); + error = reg_open_local(&h, NULL, cmdline_credentials); } if(!W_ERROR_IS_OK(error)) { -- cgit From 5f64fcf473f5cdb4b560fa672097c7cc144a67bb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 8 Apr 2006 02:58:36 +0000 Subject: r14981: fixed a use of a wild ptr in regshell (This used to be commit 868deaf89f34124a2a7ba2798fad83ffdabe316d) --- source4/lib/registry/tools/regshell.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 19f544bccf..b71c15cb67 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -93,9 +93,9 @@ static struct registry_key *cmd_set(TALLOC_CTX *mem_ctx, struct registry_context if (argc < 4) { fprintf(stderr, "Usage: set value-name type value\n"); } else { - struct registry_value *val; - if (reg_string_to_val(mem_ctx, argv[2], argv[3], &val->data_type, &val->data)) { - WERROR error = reg_val_set(cur, argv[1], val->data_type, val->data); + struct registry_value val; + if (reg_string_to_val(mem_ctx, argv[2], argv[3], &val.data_type, &val.data)) { + WERROR error = reg_val_set(cur, argv[1], val.data_type, val.data); if (!W_ERROR_IS_OK(error)) { fprintf(stderr, "Error setting value: %s\n", win_errstr(error)); return NULL; -- cgit From ad53de9d599d9ca1b935754d93b455a89198fa37 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 30 Apr 2006 19:22:56 +0000 Subject: r15364: Use global list of predefined keys (This used to be commit eee9e33442f846d278f0fc545480cc2ec8ea295b) --- source4/lib/registry/tools/regshell.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index b71c15cb67..6bcaf42b6c 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -439,23 +439,11 @@ static char **reg_completion(const char *text, int start, int end) } if (h) { - uint32_t try_hkeys[] = { - HKEY_CLASSES_ROOT, - HKEY_CURRENT_USER, - HKEY_LOCAL_MACHINE, - HKEY_USERS, - HKEY_PERFORMANCE_DATA, - HKEY_CURRENT_CONFIG, - HKEY_DYN_DATA, - HKEY_PERFORMANCE_TEXT, - HKEY_PERFORMANCE_NLSTEXT, - 0 - }; int i; - for (i = 0; try_hkeys[i]; i++) { + for (i = 0; reg_predefined_keys[i].handle; i++) { WERROR err; - err = reg_get_predefined_key(h, try_hkeys[i], &curkey); + err = reg_get_predefined_key(h, reg_predefined_keys[i].handle, &curkey); if (W_ERROR_IS_OK(err)) { break; } else { -- cgit From 47bf79eac5c5c23394778b7e20a5263be71a9c66 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 1 May 2006 01:34:04 +0000 Subject: r15370: Fix more dependencies for shared libs (This used to be commit 9a518661fbb76bf1c153afc6f581e888186dc165) --- source4/lib/registry/tools/regshell.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 6bcaf42b6c..dc8ff7723f 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -418,13 +418,13 @@ static char **reg_completion(const char *text, int start, int end) POPT_TABLEEND }; - registry_init(); - pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0); while((opt = poptGetNextOpt(pc)) != -1) { } + registry_init(); + if (remote) { error = reg_open_remote (&h, NULL, cmdline_credentials, remote, NULL); } else if (backend) { -- cgit From e595ede02fe9c80a88b5a7da4721c3c01808c276 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 1 May 2006 13:20:05 +0000 Subject: r15375: Rename readline.h to smbreadline.h avoid clashes with system header. (This used to be commit ccc3d8a95441e7a7015f0cf0e622ec9e38347d33) --- source4/lib/registry/tools/regshell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index dc8ff7723f..6da64d14a8 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -25,7 +25,7 @@ #include "lib/events/events.h" #include "lib/registry/reg_backend_rpc.h" #include "system/time.h" -#include "lib/replace/readline.h" +#include "lib/replace/smbreadline.h" #include "librpc/gen_ndr/ndr_security.h" /* -- cgit From 72a5cbadc1498b58bc7873a450de4b50e322a676 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 3 May 2006 09:07:38 +0000 Subject: r15406: Move 'smbreadline' out of libreplace as it doesn't replace functionality not available on some platforms but is a Samba-specific library. (This used to be commit e9d3660fa6678424e5159708a1aa572824926c8e) --- source4/lib/registry/tools/regshell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 6da64d14a8..a1a88378c9 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -25,7 +25,7 @@ #include "lib/events/events.h" #include "lib/registry/reg_backend_rpc.h" #include "system/time.h" -#include "lib/replace/smbreadline.h" +#include "lib/smbreadline/smbreadline.h" #include "librpc/gen_ndr/ndr_security.h" /* -- cgit From 73da6bf6dad7e047fbadf22a04b2f62d22ede4bf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 22 May 2006 16:21:52 +0000 Subject: r15806: Remove some unnecessary nesting making the function harder to read. (This used to be commit 2e1ce0189961335f654202074101819d8d933748) --- source4/lib/registry/tools/regshell.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index a1a88378c9..5aa16d2e98 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -90,19 +90,23 @@ static struct registry_key *cmd_pwd(TALLOC_CTX *mem_ctx, struct registry_context static struct registry_key *cmd_set(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) { + struct registry_value val; + WERROR error; + if (argc < 4) { fprintf(stderr, "Usage: set value-name type value\n"); - } else { - struct registry_value val; - if (reg_string_to_val(mem_ctx, argv[2], argv[3], &val.data_type, &val.data)) { - WERROR error = reg_val_set(cur, argv[1], val.data_type, val.data); - if (!W_ERROR_IS_OK(error)) { - fprintf(stderr, "Error setting value: %s\n", win_errstr(error)); - return NULL; - } - } else { - fprintf(stderr, "Unable to interpret data\n"); - } + return cur; + } + + if (!reg_string_to_val(mem_ctx, argv[2], argv[3], &val.data_type, &val.data)) { + fprintf(stderr, "Unable to interpret data\n"); + return cur; + } + + error = reg_val_set(cur, argv[1], val.data_type, val.data); + if (!W_ERROR_IS_OK(error)) { + fprintf(stderr, "Error setting value: %s\n", win_errstr(error)); + return NULL; } return cur; } -- cgit From 873749f2189ecf1fbfdc681df4dd304a17716279 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 6 Sep 2006 12:28:01 +0000 Subject: r18168: Use {NULL} rather than POPT_TABLEEND, which is not always available. (This used to be commit 8b622c5ded0732df0eaf9f6226f52a27b6eacd73) --- source4/lib/registry/tools/regshell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 5aa16d2e98..0bc1cfe324 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -419,7 +419,7 @@ static char **reg_completion(const char *text, int start, int end) POPT_COMMON_SAMBA POPT_COMMON_CREDENTIALS POPT_COMMON_VERSION - POPT_TABLEEND + { NULL } }; pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0); -- cgit From 655b710204e7a7d8e486da7ba675fcbeed116fea Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 16 Sep 2006 16:59:37 +0000 Subject: r18584: found one of the fd leaks. The registry backend was using a talloc(NULL, xxx) to allocate the registry context. That had two consequences 1) it was a massive memory leak, as all winreg operations leaked their entire context (including an open ldb database) every time 2) event_context_find() never found the exsting event context, so we used a new event context each time, which called epoll_create() each time, which caused a fd to be allocated (This used to be commit 1c0a3de39828b43149d8981fc7f10e7c8b59a392) --- source4/lib/registry/tools/regshell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 0bc1cfe324..8436a3f505 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -434,7 +434,7 @@ static char **reg_completion(const char *text, int start, int end) } else if (backend) { error = reg_open_hive(NULL, backend, poptGetArg(pc), NULL, cmdline_credentials, &curkey); } else { - error = reg_open_local(&h, NULL, cmdline_credentials); + error = reg_open_local(NULL, &h, NULL, cmdline_credentials); } if(!W_ERROR_IS_OK(error)) { -- cgit From 4f0c0997ce39ecb2920c1d52b03d77e1d50cd5bf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 13 Mar 2007 22:03:04 +0000 Subject: r21834: Remove unnecessary includes (This used to be commit 7d10e192caa60b816466a9deddf736afd2445080) --- source4/lib/registry/tools/regshell.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 8436a3f505..ac41a99765 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -23,7 +23,6 @@ #include "lib/registry/registry.h" #include "lib/cmdline/popt_common.h" #include "lib/events/events.h" -#include "lib/registry/reg_backend_rpc.h" #include "system/time.h" #include "lib/smbreadline/smbreadline.h" #include "librpc/gen_ndr/ndr_security.h" -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/lib/registry/tools/regshell.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index ac41a99765..f431c81bf8 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -6,7 +6,7 @@ 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 - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -15,8 +15,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From b409d4120f9ae451f93a2322267c0f346531d9f3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 26 Aug 2007 15:16:40 +0000 Subject: r24667: Finally merge the registry improvements that Wilco Baan Hofman and I have been working on for at least half a year now. Contains the following improvements: * proper layering (finally!) for the registry library. Distinction is now made between 'real' backends (local, remote, wine, etc) and the low-level hive backends (regf, creg, ldb, ...) that are only used by the local registry backend * tests for all important hive and registry operations * re-enable RPC-WINREG tests (still needs more work though, as some return values aren't checked yet) * write support for REGF files * dir backend now supports setting/reading values, creating keys * support for storing security descriptors * remove CREG backend as it was incomplete, didn't match the data model and wasn't used at all anyway * support for parsing ADM files as used by the policy editor (see lib/policy) * support for parsing PREG files (format used by .POL files) * new streaming interface for registry diffs (improves speed and memory usage for regdiff/regpatch significantly) ... and fixes a large number of bugs in the registry code (This used to be commit 7a1eec6358bc863dfc671c542b7185d3e39d7b5a) --- source4/lib/registry/tools/regshell.c | 266 ++++++++++++++++++++-------------- 1 file changed, 157 insertions(+), 109 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index f431c81bf8..0887bc91f3 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -2,7 +2,7 @@ Unix SMB/CIFS implementation. simple registry frontend - Copyright (C) Jelmer Vernooij 2004 + Copyright (C) Jelmer Vernooij 2004-2007 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 @@ -25,8 +25,15 @@ #include "system/time.h" #include "lib/smbreadline/smbreadline.h" #include "librpc/gen_ndr/ndr_security.h" +#include "lib/registry/tools/common.h" -/* +struct regshell_context { + struct registry_context *registry; + const char *path; + struct registry_key *current; +}; + +/* * * ck/cd - change key * ls - list values/keys * rmval/rm - remove value @@ -40,29 +47,40 @@ * exit */ -static struct registry_key *cmd_info(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) +static WERROR cmd_info(struct regshell_context *ctx, int argc, char **argv) { struct security_descriptor *sec_desc = NULL; time_t last_mod; WERROR error; + const char *classname; + NTTIME last_change; + + error = reg_key_get_info(ctx, ctx->current, &classname, NULL, NULL, &last_change); + if (!W_ERROR_IS_OK(error)) { + printf("Error getting key info: %s\n", win_errstr(error)); + return error; + } + - printf("Name: %s\n", cur->name); - printf("Full path: %s\n", cur->path); - printf("Key Class: %s\n", cur->class_name); - last_mod = nt_time_to_unix(cur->last_mod); + printf("Name: %s\n", strchr(ctx->path, '\\')?strrchr(ctx->path, '\\')+1: + ctx->path); + printf("Full path: %s\n", ctx->path); + printf("Key Class: %s\n", classname); + last_mod = nt_time_to_unix(last_change); printf("Time Last Modified: %s\n", ctime(&last_mod)); - error = reg_get_sec_desc(mem_ctx, cur, &sec_desc); + error = reg_get_sec_desc(ctx, ctx->current, &sec_desc); if (!W_ERROR_IS_OK(error)) { printf("Error getting security descriptor\n"); - } else { - ndr_print_debug((ndr_print_fn_t)ndr_print_security_descriptor, "Security", sec_desc); - } + return error; + } + ndr_print_debug((ndr_print_fn_t)ndr_print_security_descriptor, "Security", sec_desc); talloc_free(sec_desc); - return cur; + + return WERR_OK; } -static struct registry_key *cmd_predef(TALLOC_CTX *mem_ctx, struct registry_context *ctx, struct registry_key *cur, int argc, char **argv) +static WERROR cmd_predef(struct regshell_context *ctx, int argc, char **argv) { struct registry_key *ret = NULL; if (argc < 2) { @@ -70,165 +88,195 @@ static struct registry_key *cmd_predef(TALLOC_CTX *mem_ctx, struct registry_cont } else if (!ctx) { fprintf(stderr, "No full registry loaded, no predefined keys defined\n"); } else { - WERROR error = reg_get_predefined_key_by_name(ctx, argv[1], &ret); + WERROR error = reg_get_predefined_key_by_name(ctx->registry, argv[1], &ret); if (!W_ERROR_IS_OK(error)) { fprintf(stderr, "Error opening predefined key %s: %s\n", argv[1], win_errstr(error)); - ret = NULL; + return error; } } - return ret; + + return WERR_OK; } -static struct registry_key *cmd_pwd(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) +static WERROR cmd_pwd(struct regshell_context *ctx, + int argc, char **argv) { - printf("%s\n", cur->path); - return cur; + printf("%s\n", ctx->path); + return WERR_OK; } -static struct registry_key *cmd_set(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) +static WERROR cmd_set(struct regshell_context *ctx, int argc, char **argv) { struct registry_value val; WERROR error; if (argc < 4) { fprintf(stderr, "Usage: set value-name type value\n"); - return cur; + return WERR_INVALID_PARAM; } - if (!reg_string_to_val(mem_ctx, argv[2], argv[3], &val.data_type, &val.data)) { + if (!reg_string_to_val(ctx, argv[2], argv[3], &val.data_type, + &val.data)) { fprintf(stderr, "Unable to interpret data\n"); - return cur; + return WERR_INVALID_PARAM; } - error = reg_val_set(cur, argv[1], val.data_type, val.data); + error = reg_val_set(ctx->current, argv[1], val.data_type, val.data); if (!W_ERROR_IS_OK(error)) { fprintf(stderr, "Error setting value: %s\n", win_errstr(error)); - return NULL; + return error; } - return cur; + + return WERR_OK; } -static struct registry_key *cmd_ck(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) +static WERROR cmd_ck(struct regshell_context *ctx, int argc, char **argv) { struct registry_key *new = NULL; WERROR error; + if(argc < 2) { - new = cur; + new = ctx->current; } else { - error = reg_open_key(mem_ctx, cur, argv[1], &new); + error = reg_open_key(ctx->registry, ctx->current, argv[1], &new); if(!W_ERROR_IS_OK(error)) { DEBUG(0, ("Error opening specified key: %s\n", win_errstr(error))); - return NULL; + return error; } } - printf("Current path is: %s\n", new->path); + ctx->path = talloc_asprintf(ctx, "%s\\%s", ctx->path, argv[1]); + printf("Current path is: %s\n", ctx->path); + ctx->current = new; - return new; + return WERR_OK; } -static struct registry_key *cmd_print(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) +static WERROR cmd_print(struct regshell_context *ctx, int argc, char **argv) { - struct registry_value *value; + uint32_t value_type; + DATA_BLOB value_data; WERROR error; if (argc != 2) { fprintf(stderr, "Usage: print "); - return NULL; + return WERR_INVALID_PARAM; } - error = reg_key_get_value_by_name(mem_ctx, cur, argv[1], &value); + error = reg_key_get_value_by_name(ctx, ctx->current, argv[1], + &value_type, &value_data); if (!W_ERROR_IS_OK(error)) { fprintf(stderr, "No such value '%s'\n", argv[1]); - return NULL; + return error; } - printf("%s\n%s\n", str_regtype(value->data_type), reg_val_data_string(mem_ctx, value->data_type, &value->data)); - return NULL; + printf("%s\n%s\n", str_regtype(value_type), + reg_val_data_string(ctx, value_type, value_data)); + + return WERR_OK; } -static struct registry_key *cmd_ls(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) +static WERROR cmd_ls(struct regshell_context *ctx, int argc, char **argv) { int i; WERROR error; struct registry_value *value; - struct registry_key *sub; - for(i = 0; W_ERROR_IS_OK(error = reg_key_get_subkey_by_index(mem_ctx, cur, i, &sub)); i++) { - printf("K %s\n", sub->name); + uint32_t data_type; + DATA_BLOB data; + const char *name; + + for (i = 0; W_ERROR_IS_OK(error = reg_key_get_subkey_by_index(ctx, ctx->current, i, &name, NULL, NULL)); i++) { + printf("K %s\n", name); } - if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) { + if (!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) { 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(mem_ctx, cur, i, &value)); i++) { - printf("V \"%s\" %s %s\n", value->name, str_regtype(value->data_type), reg_val_data_string(mem_ctx, value->data_type, &value->data)); + 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", value->name, str_regtype(data_type), + reg_val_data_string(ctx, data_type, data)); } - return NULL; + return WERR_OK; } -static struct registry_key *cmd_mkkey(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) +static WERROR cmd_mkkey(struct regshell_context *ctx, int argc, char **argv) { struct registry_key *tmp; + WERROR error; + if(argc < 2) { fprintf(stderr, "Usage: mkkey \n"); - return NULL; + return WERR_INVALID_PARAM; } + + error = reg_key_add_name(ctx, ctx->current, argv[1], 0, NULL, &tmp); - if(!W_ERROR_IS_OK(reg_key_add_name(mem_ctx, cur, argv[1], 0, NULL, &tmp))) { + if (!W_ERROR_IS_OK(error)) { fprintf(stderr, "Error adding new subkey '%s'\n", argv[1]); - return NULL; + return error; } - return NULL; + return WERR_OK; } -static struct registry_key *cmd_rmkey(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) +static WERROR cmd_rmkey(struct regshell_context *ctx, + int argc, char **argv) { + WERROR error; + if(argc < 2) { fprintf(stderr, "Usage: rmkey \n"); - return NULL; + return WERR_INVALID_PARAM; } - if(!W_ERROR_IS_OK(reg_key_del(cur, argv[1]))) { + error = reg_key_del(ctx->current, argv[1]); + if(!W_ERROR_IS_OK(error)) { fprintf(stderr, "Error deleting '%s'\n", argv[1]); + return error; } else { fprintf(stderr, "Successfully deleted '%s'\n", argv[1]); } - return NULL; + return WERR_OK; } -static struct registry_key *cmd_rmval(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) +static WERROR cmd_rmval(struct regshell_context *ctx, int argc, char **argv) { + WERROR error; + if(argc < 2) { fprintf(stderr, "Usage: rmval \n"); - return NULL; + return WERR_INVALID_PARAM; } - if(!W_ERROR_IS_OK(reg_del_value(cur, argv[1]))) { + error = reg_del_value(ctx->current, argv[1]); + if(!W_ERROR_IS_OK(error)) { fprintf(stderr, "Error deleting value '%s'\n", argv[1]); + return error; } else { fprintf(stderr, "Successfully deleted value '%s'\n", argv[1]); } - return NULL; + return WERR_OK; } -static struct registry_key *cmd_exit(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *cur, int argc, char **argv) +static WERROR cmd_exit(struct regshell_context *ctx, + int argc, char **argv) { exit(0); - return NULL; + return WERR_OK; } -static struct registry_key *cmd_help(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *, int, char **); +static WERROR cmd_help(struct regshell_context *ctx, int, char **); static struct { const char *name; const char *alias; const char *help; - struct registry_key *(*handle)(TALLOC_CTX *mem_ctx, struct registry_context *ctx,struct registry_key *, int argc, char **argv); + WERROR (*handle)(struct regshell_context *ctx, + int argc, char **argv); } regshell_cmds[] = { {"ck", "cd", "Change current key", cmd_ck }, {"info", "i", "Show detailed information of a key", cmd_info }, @@ -245,17 +293,19 @@ static struct { {NULL } }; -static struct registry_key *cmd_help(TALLOC_CTX *mem_ctx, struct registry_context *ctx, struct registry_key *cur, int argc, char **argv) +static WERROR cmd_help(struct regshell_context *ctx, + int argc, char **argv) { int i; printf("Available commands:\n"); for(i = 0; regshell_cmds[i].name; i++) { printf("%s - %s\n", regshell_cmds[i].name, regshell_cmds[i].help); } - return NULL; + return WERR_OK; } -static struct registry_key *process_cmd(TALLOC_CTX *mem_ctx, struct registry_context *ctx, struct registry_key *k, char *line) +static WERROR process_cmd(struct regshell_context *ctx, + char *line) { int argc; char **argv = NULL; @@ -263,19 +313,19 @@ static struct registry_key *process_cmd(TALLOC_CTX *mem_ctx, struct registry_con if ((ret = poptParseArgvString(line, &argc, (const char ***) &argv)) != 0) { fprintf(stderr, "regshell: %s\n", poptStrerror(ret)); - return k; + return WERR_INVALID_PARAM; } for(i = 0; regshell_cmds[i].name; i++) { if(!strcmp(regshell_cmds[i].name, argv[0]) || (regshell_cmds[i].alias && !strcmp(regshell_cmds[i].alias, argv[0]))) { - return regshell_cmds[i].handle(mem_ctx, ctx, k, argc, argv); + return regshell_cmds[i].handle(ctx, argc, argv); } } fprintf(stderr, "No such command '%s'\n", argv[0]); - return k; + return WERR_INVALID_PARAM; } #define MAX_COMPLETIONS 100 @@ -333,7 +383,7 @@ cleanup: static char **reg_complete_key(const char *text, int start, int end) { struct registry_key *base; - struct registry_key *subkey; + const char *subkeyname; int i, j = 1; int samelen = 0; int len; @@ -351,10 +401,11 @@ 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, &subkey); + status = reg_key_get_subkey_by_index(mem_ctx, base, i, &subkeyname, + NULL, NULL); if(W_ERROR_IS_OK(status)) { - if(!strncmp(text, subkey->name, len)) { - matches[j] = strdup(subkey->name); + if(!strncmp(text, subkeyname, len)) { + matches[j] = strdup(subkeyname); j++; if (j == 1) @@ -381,7 +432,8 @@ static char **reg_complete_key(const char *text, int start, int end) if (j == 2) { /* Exact match */ asprintf(&matches[0], "%s%s", base_n, matches[1]); } else { - asprintf(&matches[0], "%s%s", base_n, talloc_strndup(mem_ctx, matches[1], samelen)); + asprintf(&matches[0], "%s%s", base_n, + talloc_strndup(mem_ctx, matches[1], samelen)); } talloc_free(mem_ctx); @@ -400,19 +452,17 @@ static char **reg_completion(const char *text, int start, int end) } } - int main(int argc, char **argv) +int main(int argc, char **argv) { int opt; - const char *backend = NULL; - struct registry_key *curkey = NULL; + const char *file = NULL; poptContext pc; - WERROR error; - TALLOC_CTX *mem_ctx = talloc_init("cmd"); const char *remote = NULL; - struct registry_context *h = NULL; + struct regshell_context *ctx; + bool ret = true; struct poptOption long_options[] = { POPT_AUTOHELP - {"backend", 'b', POPT_ARG_STRING, &backend, 0, "backend to use", NULL}, + {"file", 'F', POPT_ARG_STRING, &file, 0, "open hive file", NULL }, {"remote", 'R', POPT_ARG_STRING, &remote, 0, "connect to specified remote server", NULL}, POPT_COMMON_SAMBA POPT_COMMON_CREDENTIALS @@ -425,64 +475,62 @@ static char **reg_completion(const char *text, int start, int end) while((opt = poptGetNextOpt(pc)) != -1) { } - registry_init(); + ctx = talloc_zero(NULL, struct regshell_context); - if (remote) { - error = reg_open_remote (&h, NULL, cmdline_credentials, remote, NULL); - } else if (backend) { - error = reg_open_hive(NULL, backend, poptGetArg(pc), NULL, cmdline_credentials, &curkey); + if (remote != NULL) { + ctx->registry = reg_common_open_remote(remote, cmdline_credentials); + } else if (file != NULL) { + ctx->current = reg_common_open_file(file, cmdline_credentials); + ctx->registry = ctx->current->context; + ctx->path = talloc_strdup(ctx, ""); } else { - error = reg_open_local(NULL, &h, NULL, cmdline_credentials); + ctx->registry = reg_common_open_local(cmdline_credentials); } - if(!W_ERROR_IS_OK(error)) { - fprintf(stderr, "Unable to open registry\n"); + if (ctx->registry == NULL) return 1; - } - if (h) { + if (ctx->current == NULL) { int i; for (i = 0; reg_predefined_keys[i].handle; i++) { WERROR err; - err = reg_get_predefined_key(h, reg_predefined_keys[i].handle, &curkey); + err = reg_get_predefined_key(ctx->registry, + reg_predefined_keys[i].handle, + &ctx->current); if (W_ERROR_IS_OK(err)) { + ctx->path = talloc_strdup(ctx, reg_predefined_keys[i].name); break; } else { - curkey = NULL; + ctx->current = NULL; } } } - if (!curkey) { + if (ctx->current == NULL) { fprintf(stderr, "Unable to access any of the predefined keys\n"); return -1; } poptFreeContext(pc); - while(True) { + while (true) { char *line, *prompt; - if(curkey->hive->root->name) { - asprintf(&prompt, "%s:%s> ", curkey->hive->root->name, curkey->path); - } else { - asprintf(&prompt, "%s> ", curkey->path); - } + asprintf(&prompt, "%s> ", ctx->path); - current_key = curkey; /* No way to pass a void * pointer - via readline :-( */ + current_key = ctx->current; /* No way to pass a void * pointer + via readline :-( */ line = smb_readline(prompt, NULL, reg_completion); - if(!line) + if (line == NULL) break; - if(line[0] != '\n') { - struct registry_key *new = process_cmd(mem_ctx, h, curkey, line); - if(new)curkey = new; + if (line[0] != '\n') { + ret = W_ERROR_IS_OK(process_cmd(ctx, line)); } } - talloc_free(mem_ctx); + talloc_free(ctx); - return 0; + return (ret?0:1); } -- cgit From 2cd9215e777820eec2cd6952aaa80c594facba32 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 27 Aug 2007 21:24:44 +0000 Subject: r24725: Don't segfault if hive file can't be found (This used to be commit 2daa8fa88dbc80a7c54c4b489b1037658d95755c) --- source4/lib/registry/tools/regshell.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 0887bc91f3..131d76fff5 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -481,6 +481,8 @@ int main(int argc, char **argv) ctx->registry = reg_common_open_remote(remote, cmdline_credentials); } else if (file != NULL) { ctx->current = reg_common_open_file(file, cmdline_credentials); + if (ctx->current == NULL) + return 1; ctx->registry = ctx->current->context; ctx->path = talloc_strdup(ctx, ""); } else { -- cgit From cd962355abad90a2161765a7be7d26e63572cab7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 7 Sep 2007 15:08:14 +0000 Subject: r25000: Fix some more C++ compatibility warnings. (This used to be commit 08bb1ef643ab906f1645cf6f32763dc73b1884e4) --- source4/lib/registry/tools/regshell.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 131d76fff5..cdf688b39e 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -262,8 +262,7 @@ static WERROR cmd_rmval(struct regshell_context *ctx, int argc, char **argv) return WERR_OK; } -static WERROR cmd_exit(struct regshell_context *ctx, - int argc, char **argv) +_NORETURN_ static WERROR cmd_exit(struct regshell_context *ctx, int argc, char **argv) { exit(0); return WERR_OK; @@ -275,8 +274,7 @@ static struct { const char *name; const char *alias; const char *help; - WERROR (*handle)(struct regshell_context *ctx, - int argc, char **argv); + WERROR (*handle)(struct regshell_context *ctx, int argc, char **argv); } regshell_cmds[] = { {"ck", "cd", "Change current key", cmd_ck }, {"info", "i", "Show detailed information of a key", cmd_info }, -- cgit From 33032276f532f5344d56ca6c436befb2e3b74fc5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 10 Oct 2007 12:27:24 +0200 Subject: r25603: More reformat. Guenther (This used to be commit 176614423ea57e853211c43b9853203243c6a978) --- source4/lib/registry/tools/regshell.c | 146 +++++++++++++++++++--------------- 1 file changed, 84 insertions(+), 62 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index cdf688b39e..7dbcf2f875 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -1,19 +1,19 @@ -/* +/* Unix SMB/CIFS implementation. simple registry frontend - + Copyright (C) Jelmer Vernooij 2004-2007 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 the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -55,14 +55,15 @@ static WERROR cmd_info(struct regshell_context *ctx, int argc, char **argv) const char *classname; NTTIME last_change; - error = reg_key_get_info(ctx, ctx->current, &classname, NULL, NULL, &last_change); + error = reg_key_get_info(ctx, ctx->current, &classname, NULL, NULL, + &last_change); if (!W_ERROR_IS_OK(error)) { printf("Error getting key info: %s\n", win_errstr(error)); return error; } - - printf("Name: %s\n", strchr(ctx->path, '\\')?strrchr(ctx->path, '\\')+1: + + printf("Name: %s\n", strchr(ctx->path, '\\')?strrchr(ctx->path, '\\')+1: ctx->path); printf("Full path: %s\n", ctx->path); printf("Key Class: %s\n", classname); @@ -73,8 +74,9 @@ static WERROR cmd_info(struct regshell_context *ctx, int argc, char **argv) if (!W_ERROR_IS_OK(error)) { printf("Error getting security descriptor\n"); return error; - } - ndr_print_debug((ndr_print_fn_t)ndr_print_security_descriptor, "Security", sec_desc); + } + ndr_print_debug((ndr_print_fn_t)ndr_print_security_descriptor, + "Security", sec_desc); talloc_free(sec_desc); return WERR_OK; @@ -88,10 +90,12 @@ static WERROR cmd_predef(struct regshell_context *ctx, int argc, char **argv) } else if (!ctx) { fprintf(stderr, "No full registry loaded, no predefined keys defined\n"); } else { - WERROR error = reg_get_predefined_key_by_name(ctx->registry, argv[1], &ret); + WERROR error = reg_get_predefined_key_by_name(ctx->registry, + argv[1], &ret); if (!W_ERROR_IS_OK(error)) { - fprintf(stderr, "Error opening predefined key %s: %s\n", argv[1], win_errstr(error)); + fprintf(stderr, "Error opening predefined key %s: %s\n", + argv[1], win_errstr(error)); return error; } } @@ -100,7 +104,7 @@ static WERROR cmd_predef(struct regshell_context *ctx, int argc, char **argv) } static WERROR cmd_pwd(struct regshell_context *ctx, - int argc, char **argv) + int argc, char **argv) { printf("%s\n", ctx->path); return WERR_OK; @@ -114,10 +118,10 @@ static WERROR cmd_set(struct regshell_context *ctx, int argc, char **argv) if (argc < 4) { fprintf(stderr, "Usage: set value-name type value\n"); return WERR_INVALID_PARAM; - } + } - if (!reg_string_to_val(ctx, argv[2], argv[3], &val.data_type, - &val.data)) { + if (!reg_string_to_val(ctx, argv[2], argv[3], &val.data_type, + &val.data)) { fprintf(stderr, "Unable to interpret data\n"); return WERR_INVALID_PARAM; } @@ -132,24 +136,26 @@ static WERROR cmd_set(struct regshell_context *ctx, int argc, char **argv) } static WERROR cmd_ck(struct regshell_context *ctx, int argc, char **argv) -{ +{ struct registry_key *new = NULL; WERROR error; if(argc < 2) { new = ctx->current; } else { - error = reg_open_key(ctx->registry, ctx->current, argv[1], &new); + error = reg_open_key(ctx->registry, ctx->current, argv[1], + &new); if(!W_ERROR_IS_OK(error)) { - DEBUG(0, ("Error opening specified key: %s\n", win_errstr(error))); + DEBUG(0, ("Error opening specified key: %s\n", + win_errstr(error))); return error; } - } + } ctx->path = talloc_asprintf(ctx, "%s\\%s", ctx->path, argv[1]); printf("Current path is: %s\n", ctx->path); ctx->current = new; - + return WERR_OK; } @@ -163,15 +169,15 @@ static WERROR cmd_print(struct regshell_context *ctx, int argc, char **argv) fprintf(stderr, "Usage: print "); return WERR_INVALID_PARAM; } - - error = reg_key_get_value_by_name(ctx, ctx->current, argv[1], - &value_type, &value_data); + + error = reg_key_get_value_by_name(ctx, ctx->current, argv[1], + &value_type, &value_data); if (!W_ERROR_IS_OK(error)) { fprintf(stderr, "No such value '%s'\n", argv[1]); return error; } - printf("%s\n%s\n", str_regtype(value_type), + printf("%s\n%s\n", str_regtype(value_type), reg_val_data_string(ctx, value_type, value_data)); return WERR_OK; @@ -186,23 +192,34 @@ static WERROR cmd_ls(struct regshell_context *ctx, int argc, char **argv) DATA_BLOB data; const char *name; - for (i = 0; W_ERROR_IS_OK(error = reg_key_get_subkey_by_index(ctx, ctx->current, i, &name, NULL, NULL)); i++) { + for (i = 0; W_ERROR_IS_OK(error = reg_key_get_subkey_by_index(ctx, + ctx->current, + i, + &name, + NULL, + NULL)); i++) { printf("K %s\n", name); } if (!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) { - DEBUG(0, ("Error occured while browsing thru keys: %s\n", win_errstr(error))); + 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(ctx, ctx->current, i, &name, &data_type, &data)); i++) { - printf("V \"%s\" %s %s\n", value->name, str_regtype(data_type), + 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", value->name, str_regtype(data_type), reg_val_data_string(ctx, data_type, data)); } - - return WERR_OK; + + return WERR_OK; } static WERROR cmd_mkkey(struct regshell_context *ctx, int argc, char **argv) -{ +{ struct registry_key *tmp; WERROR error; @@ -212,18 +229,18 @@ 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]); return error; } - return WERR_OK; + return WERR_OK; } static WERROR cmd_rmkey(struct regshell_context *ctx, - int argc, char **argv) -{ + int argc, char **argv) +{ WERROR error; if(argc < 2) { @@ -238,12 +255,12 @@ static WERROR cmd_rmkey(struct regshell_context *ctx, } else { fprintf(stderr, "Successfully deleted '%s'\n", argv[1]); } - + return WERR_OK; } static WERROR cmd_rmval(struct regshell_context *ctx, int argc, char **argv) -{ +{ WERROR error; if(argc < 2) { @@ -259,10 +276,11 @@ static WERROR cmd_rmval(struct regshell_context *ctx, int argc, char **argv) fprintf(stderr, "Successfully deleted value '%s'\n", argv[1]); } - return WERR_OK; + return WERR_OK; } -_NORETURN_ static WERROR cmd_exit(struct regshell_context *ctx, int argc, char **argv) +_NORETURN_ static WERROR cmd_exit(struct regshell_context *ctx, + int argc, char **argv) { exit(0); return WERR_OK; @@ -292,18 +310,19 @@ static struct { }; static WERROR cmd_help(struct regshell_context *ctx, - int argc, char **argv) + int argc, char **argv) { int i; printf("Available commands:\n"); for(i = 0; regshell_cmds[i].name; i++) { - printf("%s - %s\n", regshell_cmds[i].name, regshell_cmds[i].help); + printf("%s - %s\n", regshell_cmds[i].name, + regshell_cmds[i].help); } return WERR_OK; -} +} static WERROR process_cmd(struct regshell_context *ctx, - char *line) + char *line) { int argc; char **argv = NULL; @@ -315,14 +334,14 @@ static WERROR process_cmd(struct regshell_context *ctx, } for(i = 0; regshell_cmds[i].name; i++) { - if(!strcmp(regshell_cmds[i].name, argv[0]) || + if(!strcmp(regshell_cmds[i].name, argv[0]) || (regshell_cmds[i].alias && !strcmp(regshell_cmds[i].alias, argv[0]))) { return regshell_cmds[i].handle(ctx, argc, argv); } } fprintf(stderr, "No such command '%s'\n", argv[0]); - + return WERR_INVALID_PARAM; } @@ -399,8 +418,8 @@ 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); + status = reg_key_get_subkey_by_index(mem_ctx, base, i, + &subkeyname, NULL, NULL); if(W_ERROR_IS_OK(status)) { if(!strncmp(text, subkeyname, len)) { matches[j] = strdup(subkeyname); @@ -415,7 +434,8 @@ static char **reg_complete_key(const char *text, int start, int end) } else if(W_ERROR_EQUAL(status, WERR_NO_MORE_ITEMS)) { break; } else { - printf("Error creating completion list: %s\n", win_errstr(status)); + printf("Error creating completion list: %s\n", + win_errstr(status)); talloc_free(mem_ctx); return NULL; } @@ -430,9 +450,9 @@ static char **reg_complete_key(const char *text, int start, int end) if (j == 2) { /* Exact match */ asprintf(&matches[0], "%s%s", base_n, matches[1]); } else { - asprintf(&matches[0], "%s%s", base_n, + asprintf(&matches[0], "%s%s", base_n, talloc_strndup(mem_ctx, matches[1], samelen)); - } + } talloc_free(mem_ctx); matches[j] = NULL; @@ -469,14 +489,15 @@ int main(int argc, char **argv) }; pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0); - + while((opt = poptGetNextOpt(pc)) != -1) { } ctx = talloc_zero(NULL, struct regshell_context); if (remote != NULL) { - ctx->registry = reg_common_open_remote(remote, cmdline_credentials); + ctx->registry = reg_common_open_remote(remote, + cmdline_credentials); } else if (file != NULL) { ctx->current = reg_common_open_file(file, cmdline_credentials); if (ctx->current == NULL) @@ -495,11 +516,12 @@ int main(int argc, char **argv) for (i = 0; reg_predefined_keys[i].handle; i++) { WERROR err; - err = reg_get_predefined_key(ctx->registry, - reg_predefined_keys[i].handle, - &ctx->current); + err = reg_get_predefined_key(ctx->registry, + reg_predefined_keys[i].handle, + &ctx->current); if (W_ERROR_IS_OK(err)) { - ctx->path = talloc_strdup(ctx, reg_predefined_keys[i].name); + ctx->path = talloc_strdup(ctx, + reg_predefined_keys[i].name); break; } else { ctx->current = NULL; @@ -511,16 +533,16 @@ int main(int argc, char **argv) fprintf(stderr, "Unable to access any of the predefined keys\n"); return -1; } - + poptFreeContext(pc); - + while (true) { char *line, *prompt; - + asprintf(&prompt, "%s> ", ctx->path); - - current_key = ctx->current; /* No way to pass a void * pointer - via readline :-( */ + + current_key = ctx->current; /* No way to pass a void * pointer + via readline :-( */ line = smb_readline(prompt, NULL, reg_completion); if (line == NULL) -- cgit From 6c999cd12344f2bb8b1d2941210b4c205b3e0aad Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 2 Dec 2007 22:32:11 +0100 Subject: r26236: Remove more uses of global_loadparm or specify loadparm_context explicitly. (This used to be commit 5b29ef7c03d9ae76b0ca909e9f03a58e1bad3521) --- source4/lib/registry/tools/regshell.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 7dbcf2f875..9b582c3c02 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -26,6 +26,7 @@ #include "lib/smbreadline/smbreadline.h" #include "librpc/gen_ndr/ndr_security.h" #include "lib/registry/tools/common.h" +#include "param/param.h" struct regshell_context { struct registry_context *registry; @@ -505,7 +506,7 @@ int main(int argc, char **argv) ctx->registry = ctx->current->context; ctx->path = talloc_strdup(ctx, ""); } else { - ctx->registry = reg_common_open_local(cmdline_credentials); + ctx->registry = reg_common_open_local(cmdline_credentials, global_loadparm); } if (ctx->registry == NULL) -- cgit From bca631be1f4cefeec3d64cd552ec6d9ee9cc1971 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 7 Dec 2007 03:01:41 +0100 Subject: r26329: Fix more loadparm_context references. Only about a 100 left now. (This used to be commit ddf233346d848e91bc6a6a572f0f6120540503b7) --- source4/lib/registry/tools/regshell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 9b582c3c02..7169d7c9f8 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -497,7 +497,7 @@ int main(int argc, char **argv) ctx = talloc_zero(NULL, struct regshell_context); if (remote != NULL) { - ctx->registry = reg_common_open_remote(remote, + ctx->registry = reg_common_open_remote(remote, global_loadparm, cmdline_credentials); } else if (file != NULL) { ctx->current = reg_common_open_file(file, cmdline_credentials); -- cgit From b65dba2245bf382c47d65c95ac9b1efa43918fc0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 10 Dec 2007 04:33:16 +0100 Subject: r26355: Eliminate global_loadparm in more places. (This used to be commit 5d589a0d94bd76a9b4c9fc748854e8098ea43c4d) --- source4/lib/registry/tools/regshell.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 7169d7c9f8..2c692952fb 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -497,7 +497,7 @@ int main(int argc, char **argv) ctx = talloc_zero(NULL, struct regshell_context); if (remote != NULL) { - ctx->registry = reg_common_open_remote(remote, global_loadparm, + ctx->registry = reg_common_open_remote(remote, cmdline_lp_ctx, cmdline_credentials); } else if (file != NULL) { ctx->current = reg_common_open_file(file, cmdline_credentials); @@ -506,7 +506,7 @@ int main(int argc, char **argv) ctx->registry = ctx->current->context; ctx->path = talloc_strdup(ctx, ""); } else { - ctx->registry = reg_common_open_local(cmdline_credentials, global_loadparm); + ctx->registry = reg_common_open_local(cmdline_credentials, cmdline_lp_ctx); } if (ctx->registry == NULL) -- cgit From 96a200511e884a88dcf48fa5b313b2cddb2df566 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 14 Dec 2007 00:27:31 +0100 Subject: r26443: Remove global_loadparm instances. (This used to be commit 8242c696235d1bfb402b5c276a57f36d93610545) --- source4/lib/registry/tools/regshell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 2c692952fb..1c5157e937 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -500,7 +500,7 @@ int main(int argc, char **argv) ctx->registry = reg_common_open_remote(remote, cmdline_lp_ctx, cmdline_credentials); } else if (file != NULL) { - ctx->current = reg_common_open_file(file, cmdline_credentials); + ctx->current = reg_common_open_file(file, cmdline_lp_ctx, cmdline_credentials); if (ctx->current == NULL) return 1; ctx->registry = ctx->current->context; -- cgit From 43ac3d9b44b98d44db9b1550c47e8f96a410d1e9 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Fri, 14 Dec 2007 14:04:56 +0100 Subject: r26453: Janitorial: Don't use a static char[] in smb_readline_replacement. Fix up callers to free the memory returned, as that is needed if we use the original readline function as well. (This used to be commit c81ead1c38f417d442157b21d0d389f6a540c6f9) --- source4/lib/registry/tools/regshell.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 1c5157e937..329d6ab670 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -546,12 +546,16 @@ int main(int argc, char **argv) via readline :-( */ line = smb_readline(prompt, NULL, reg_completion); - if (line == NULL) + if (line == NULL) { + free(prompt); break; + } if (line[0] != '\n') { ret = W_ERROR_IS_OK(process_cmd(ctx, line)); } + free(line); + free(prompt); } talloc_free(ctx); -- cgit From 47f6bbf8cf5bdd03c72c59d00e3e1eab8895590e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 7 Jan 2008 14:11:29 -0600 Subject: r26689: registry: Return max_subkeynamelen, max_valnamelen and max_valbufsize in getkeyinfo(). (This used to be commit b06896d2378e536f5044dbe500a5232a89d6d0b5) --- source4/lib/registry/tools/regshell.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 329d6ab670..93f28f3e5a 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -53,11 +53,16 @@ static WERROR cmd_info(struct regshell_context *ctx, int argc, char **argv) struct security_descriptor *sec_desc = NULL; time_t last_mod; WERROR error; - const char *classname; + const char *classname = NULL; NTTIME last_change; - - error = reg_key_get_info(ctx, ctx->current, &classname, NULL, NULL, - &last_change); + uint32_t max_subkeynamelen; + uint32_t max_valnamelen; + uint32_t max_valbufsize; + uint32_t num_subkeys; + uint32_t num_values; + + error = reg_key_get_info(ctx, ctx->current, &classname, &num_subkeys, &num_values, + &last_change, &max_subkeynamelen, &max_valnamelen, &max_valbufsize); if (!W_ERROR_IS_OK(error)) { printf("Error getting key info: %s\n", win_errstr(error)); return error; @@ -67,9 +72,21 @@ static WERROR cmd_info(struct regshell_context *ctx, int argc, char **argv) printf("Name: %s\n", strchr(ctx->path, '\\')?strrchr(ctx->path, '\\')+1: ctx->path); printf("Full path: %s\n", ctx->path); - printf("Key Class: %s\n", classname); + if (classname != NULL) + printf("Key Class: %s\n", classname); last_mod = nt_time_to_unix(last_change); printf("Time Last Modified: %s\n", ctime(&last_mod)); + printf("Number of subkeys: %d\n", num_subkeys); + printf("Number of values: %d\n", num_values); + + if (max_valnamelen > 0) + printf("Maximum value name length: %d\n", max_valnamelen); + + if (max_valbufsize > 0) + printf("Maximum value data length: %d\n", max_valbufsize); + + if (max_subkeynamelen > 0) + printf("Maximum sub key name length: %d\n", max_subkeynamelen); error = reg_get_sec_desc(ctx, ctx->current, &sec_desc); if (!W_ERROR_IS_OK(error)) { @@ -188,10 +205,9 @@ static WERROR cmd_ls(struct regshell_context *ctx, int argc, char **argv) { int i; WERROR error; - struct registry_value *value; uint32_t data_type; DATA_BLOB data; - const char *name; + const char *name = NULL; for (i = 0; W_ERROR_IS_OK(error = reg_key_get_subkey_by_index(ctx, ctx->current, @@ -213,7 +229,7 @@ static WERROR cmd_ls(struct regshell_context *ctx, int argc, char **argv) &name, &data_type, &data)); i++) { - printf("V \"%s\" %s %s\n", value->name, str_regtype(data_type), + printf("V \"%s\" %s %s\n", name, str_regtype(data_type), reg_val_data_string(ctx, data_type, data)); } -- cgit From d82b6dd09adc0b30567ffcc9e47553eb3ed51b2a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 11 Feb 2008 11:47:31 +0100 Subject: Fix switching of hives in regshell (#5254) (This used to be commit 5f33545c78e13871d622c0a5a0ded789bf624869) --- source4/lib/registry/tools/regshell.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 93f28f3e5a..d5c506ab31 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -116,6 +116,9 @@ static WERROR cmd_predef(struct regshell_context *ctx, int argc, char **argv) argv[1], win_errstr(error)); return error; } + + ctx->path = strupper_talloc(ctx, argv[1]); + ctx->current = ret; } return WERR_OK; -- cgit From 48307b54f95395fbd201d92d738b482f80cd15ef Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 21 Feb 2008 16:01:19 +0100 Subject: Remove more uses of global_loadparm. (This used to be commit 3430cc60972b94d0d238bc39f473feed96949c5d) --- source4/lib/registry/tools/regshell.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index d5c506ab31..58f64cb049 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -141,7 +141,8 @@ static WERROR cmd_set(struct regshell_context *ctx, int argc, char **argv) return WERR_INVALID_PARAM; } - if (!reg_string_to_val(ctx, argv[2], argv[3], &val.data_type, + if (!reg_string_to_val(ctx, lp_iconv_convenience(cmdline_lp_ctx), + argv[2], argv[3], &val.data_type, &val.data)) { fprintf(stderr, "Unable to interpret data\n"); return WERR_INVALID_PARAM; @@ -199,7 +200,7 @@ static WERROR cmd_print(struct regshell_context *ctx, int argc, char **argv) } printf("%s\n%s\n", str_regtype(value_type), - reg_val_data_string(ctx, value_type, value_data)); + reg_val_data_string(ctx, lp_iconv_convenience(cmdline_lp_ctx), value_type, value_data)); return WERR_OK; } @@ -233,7 +234,7 @@ static WERROR cmd_ls(struct regshell_context *ctx, int argc, char **argv) &data_type, &data)); i++) { printf("V \"%s\" %s %s\n", name, str_regtype(data_type), - reg_val_data_string(ctx, data_type, data)); + reg_val_data_string(ctx, lp_iconv_convenience(cmdline_lp_ctx), data_type, data)); } return WERR_OK; -- cgit From 21fc7673780aa1d7c0caab7b17ff9171238913ba Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 17 Apr 2008 12:23:44 +0200 Subject: Specify event_context to ldb_wrap_connect explicitly. (This used to be commit b4e1ae07a284c044704322446c94351c2decff91) --- source4/lib/registry/tools/regshell.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 58f64cb049..80eafcc4a2 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -498,6 +498,7 @@ int main(int argc, char **argv) poptContext pc; const char *remote = NULL; struct regshell_context *ctx; + struct event_context *ev_ctx; bool ret = true; struct poptOption long_options[] = { POPT_AUTOHELP @@ -516,17 +517,19 @@ int main(int argc, char **argv) ctx = talloc_zero(NULL, struct regshell_context); + ev_ctx = event_context_init(ctx); + if (remote != NULL) { ctx->registry = reg_common_open_remote(remote, cmdline_lp_ctx, cmdline_credentials); } else if (file != NULL) { - ctx->current = reg_common_open_file(file, cmdline_lp_ctx, cmdline_credentials); + ctx->current = reg_common_open_file(file, ev_ctx, cmdline_lp_ctx, cmdline_credentials); if (ctx->current == NULL) return 1; ctx->registry = ctx->current->context; ctx->path = talloc_strdup(ctx, ""); } else { - ctx->registry = reg_common_open_local(cmdline_credentials, cmdline_lp_ctx); + ctx->registry = reg_common_open_local(cmdline_credentials, ev_ctx, cmdline_lp_ctx); } if (ctx->registry == NULL) -- cgit From 2daf2897d5c70c0efbeba9b827c62700b9a9537c Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 14 Jun 2008 13:00:53 -0400 Subject: Use a custom init function for samba4 that sets a samba4 specific debug function. By default do not debug, this is the most appropriate action for a library as we cannot assume what stderr is use for in the main app. The main app is responsible to set ev_debug_stderr if they so desire. (This used to be commit e566a2f308ac6fb4b526a744f7059b565670aea5) --- source4/lib/registry/tools/regshell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 80eafcc4a2..4e859df3f6 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -517,7 +517,7 @@ int main(int argc, char **argv) ctx = talloc_zero(NULL, struct regshell_context); - ev_ctx = event_context_init(ctx); + ev_ctx = s4_event_context_init(ctx); if (remote != NULL) { ctx->registry = reg_common_open_remote(remote, cmdline_lp_ctx, -- cgit From 8b6b8513909fb0c5acabea060921ed2034b3284d Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Tue, 9 Sep 2008 18:01:20 +0200 Subject: Two useful "regshell" improvements This patch corrects the "change key" command (Follow up isn't supported yet) and adds a newline in a error message. (This used to be commit d1052dc42ef591208cfbf7059b28a078f6d4f0bf) --- source4/lib/registry/tools/regshell.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 4e859df3f6..ee8f366e6e 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -162,9 +162,7 @@ static WERROR cmd_ck(struct regshell_context *ctx, int argc, char **argv) struct registry_key *new = NULL; WERROR error; - if(argc < 2) { - new = ctx->current; - } else { + if(argc == 2) { error = reg_open_key(ctx->registry, ctx->current, argv[1], &new); if(!W_ERROR_IS_OK(error)) { @@ -172,11 +170,11 @@ static WERROR cmd_ck(struct regshell_context *ctx, int argc, char **argv) win_errstr(error))); return error; } - } - ctx->path = talloc_asprintf(ctx, "%s\\%s", ctx->path, argv[1]); - printf("Current path is: %s\n", ctx->path); - ctx->current = new; + ctx->path = talloc_asprintf(ctx, "%s\\%s", ctx->path, argv[1]); + ctx->current = new; + } + printf("New path is: %s\n", ctx->path); return WERR_OK; } @@ -188,7 +186,7 @@ static WERROR cmd_print(struct regshell_context *ctx, int argc, char **argv) WERROR error; if (argc != 2) { - fprintf(stderr, "Usage: print "); + fprintf(stderr, "Usage: print \n"); return WERR_INVALID_PARAM; } -- cgit From 3911808323c964c36c2639f68d59d7aca1a2a96b Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Tue, 9 Sep 2008 18:03:54 +0200 Subject: Fix up the "reg_common_open_remote" call This fixes up the "reg_common_open_remote" call because it didn't work anymore without the event context. (This used to be commit 42ab865fc937a625d1eece45abe96bf354ddff8b) --- source4/lib/registry/tools/regshell.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regshell.c') diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index ee8f366e6e..98f7f02c38 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -518,8 +518,8 @@ int main(int argc, char **argv) ev_ctx = s4_event_context_init(ctx); if (remote != NULL) { - ctx->registry = reg_common_open_remote(remote, cmdline_lp_ctx, - cmdline_credentials); + ctx->registry = reg_common_open_remote(remote, ev_ctx, + cmdline_lp_ctx, cmdline_credentials); } else if (file != NULL) { ctx->current = reg_common_open_file(file, ev_ctx, cmdline_lp_ctx, cmdline_credentials); if (ctx->current == NULL) -- cgit