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/regdiff.c | 148 +++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 source4/lib/registry/tools/regdiff.c (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c new file mode 100644 index 0000000000..070516b798 --- /dev/null +++ b/source4/lib/registry/tools/regdiff.c @@ -0,0 +1,148 @@ +/* + 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" + +void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) +{ + int i, numvals1, numvals2, numkeys2; + + numkeys2 = reg_key_num_subkeys(newkey); + for(i = 0; i < numkeys2; i++) { + REG_KEY *t1 = reg_key_get_subkey_by_index(newkey, i); + REG_KEY *t2 = reg_key_get_subkey_by_name(oldkey, reg_key_name(t1)); + if(!t2) { + fprintf(out, "[%s]\n", reg_key_get_path(t1)); + } + writediff(t2, t1, out); + } + + numvals2 = reg_key_num_values(newkey); + for(i = 0; i < numvals2; i++) { + REG_VAL *t1 = reg_key_get_value_by_index(newkey, i); + REG_VAL *t2 = reg_key_get_value_by_name(oldkey, reg_val_name(t1)); + if(!t2 || reg_val_size(t2) != reg_val_size(t1) || memcmp(reg_val_data_blk(t1), reg_val_data_blk(t2), reg_val_size(t1))) { + fprintf(out, "\"%s\"=%s:%s\n", reg_val_name(t1), str_regtype(reg_val_type(t1)), reg_val_data_string(t1)); + } + } + + numvals1 = reg_key_num_values(oldkey); + for(i = 0; i < numvals1; i++) { + REG_VAL *t1 = reg_key_get_value_by_index(oldkey, i); + if(!reg_key_get_value_by_name(newkey, reg_val_name(t1))) { + fprintf(out, "\"%s\"=-\n", reg_val_name(t1)); + } + } +} + +int main (int argc, char **argv) +{ + uint32 setparms, checkparms; + int opt; + poptContext pc; + REG_KEY *root; + const char *backend1 = NULL, *backend2 = NULL; + const char *location2; + char *outputfile = NULL; + FILE *fd = stdout; + REG_HANDLE *h2; + REG_KEY *root1 = NULL, *root2; + int from_null = 0; + int fullpath = 0, no_values = 0; + struct poptOption long_options[] = { + POPT_AUTOHELP + {"backend", 'b', POPT_ARG_STRING, NULL, 'b', "backend to use", NULL}, + {"output", 'o', POPT_ARG_STRING, &outputfile, 'o', "output file to use", NULL }, + {"null", 'n', POPT_ARG_NONE, &from_null, 'n', "Diff from NULL" }, + POPT_TABLEEND + }; + + pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0); + + while((opt = poptGetNextOpt(pc)) != -1) { + switch(opt) { + case 'b': + if(!backend1 && !from_null) backend1 = poptGetOptArg(pc); + else if(!backend2) backend2 = poptGetOptArg(pc); + break; + } + } + setup_logging(argv[0], True); + + if(!from_null) { + REG_HANDLE *h1; + const char *location1; + location1 = poptGetArg(pc); + if(!location1) { + poptPrintUsage(pc, stderr, 0); + return 1; + } + + if(!backend1) backend1 = "dir"; + + h1 = reg_open(backend1, location1, True); + if(!h1) { + fprintf(stderr, "Unable to open '%s' with backend '%s'\n", location1, backend1); + return 1; + } + + root1 = reg_get_root(h1); + } + + location2 = poptGetArg(pc); + if(!location2) { + poptPrintUsage(pc, stderr, 0); + return 2; + } + + if(!backend2) backend2 = "dir"; + + h2 = reg_open(backend2, location2, True); + if(!h2) { + fprintf(stderr, "Unable to open '%s' with backend '%s'\n", location2, backend2); + return 1; + } + + root2 = reg_get_root(h2); + if(!root2) { + fprintf(stderr, "Can't open root key for '%s:%s'\n", backend2, location2); + return 1; + } + + poptFreeContext(pc); + + if(outputfile) { + fd = fopen(outputfile, "w+"); + if(!fd) { + fprintf(stderr, "Unable to open '%s'\n", outputfile); + return 1; + } + } + + fprintf(fd, "REGEDIT4\n\n"); + fprintf(fd, "; Generated using regdiff\n"); + + writediff(root1, root2, fd); + + fclose(fd); + + return 0; +} -- cgit From 69c19afb6226e93a244490fa582200364a3b7069 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 5 Apr 2004 09:17:11 +0000 Subject: r31: More registry updates. regdiff/regpatch work now. (This used to be commit 98224f5436695eb265f5d997cf4bc9cf735a4fb9) --- source4/lib/registry/tools/regdiff.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 070516b798..5e2b97cb98 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -23,14 +23,22 @@ void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) { - int i, numvals1, numvals2, numkeys2; + int i, numkeys1, numvals1, numvals2, numkeys2; + + numkeys1 = reg_key_num_subkeys(oldkey); + for(i = 0; i < numkeys1; i++) { + REG_KEY *t1 = reg_key_get_subkey_by_index(oldkey, i); + if(!reg_key_get_subkey_by_name(newkey, reg_key_name(t1))) { + fprintf(out, "-%s\n", reg_key_get_path(t1)+1); + } + } numkeys2 = reg_key_num_subkeys(newkey); for(i = 0; i < numkeys2; i++) { REG_KEY *t1 = reg_key_get_subkey_by_index(newkey, i); REG_KEY *t2 = reg_key_get_subkey_by_name(oldkey, reg_key_name(t1)); if(!t2) { - fprintf(out, "[%s]\n", reg_key_get_path(t1)); + fprintf(out, "\n[%s]\n", reg_key_get_path(t1)+1); } writediff(t2, t1, out); } -- 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/regdiff.c | 93 +++++++++++++++++++++++++----------- 1 file changed, 65 insertions(+), 28 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 5e2b97cb98..94cdf8c8af 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -24,41 +24,71 @@ void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) { int i, numkeys1, numvals1, numvals2, numkeys2; + REG_KEY *t1,*t2; + REG_VAL *v1, *v2; + WERROR error1, error2; - numkeys1 = reg_key_num_subkeys(oldkey); - for(i = 0; i < numkeys1; i++) { - REG_KEY *t1 = reg_key_get_subkey_by_index(oldkey, i); - if(!reg_key_get_subkey_by_name(newkey, reg_key_name(t1))) { + for(i = 0; W_ERROR_IS_OK(error1 = reg_key_get_subkey_by_index(oldkey, i, &t1)); i++) { + error2 = reg_key_get_subkey_by_name(newkey, reg_key_name(t1), &t2); + if(W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { fprintf(out, "-%s\n", reg_key_get_path(t1)+1); + } else if(!W_ERROR_IS_OK(error2)) { + DEBUG(0, ("Error occured while getting subkey by name: %d\n", error2)); } } - numkeys2 = reg_key_num_subkeys(newkey); - for(i = 0; i < numkeys2; i++) { - REG_KEY *t1 = reg_key_get_subkey_by_index(newkey, i); - REG_KEY *t2 = reg_key_get_subkey_by_name(oldkey, reg_key_name(t1)); - if(!t2) { + if(!W_ERROR_EQUAL(error1, WERR_NO_MORE_ITEMS)) { + DEBUG(0, ("Error occured while getting subkey by index: %d\n", error1)); + return; + } + + for(i = 0; W_ERROR_IS_OK(error1 = reg_key_get_subkey_by_index(newkey, i, &t1)); i++) { + error2 = reg_key_get_subkey_by_name(oldkey, reg_key_name(t1), &t2); + if(W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { fprintf(out, "\n[%s]\n", reg_key_get_path(t1)+1); + } else if(!W_ERROR_IS_OK(error2)) { + DEBUG(0, ("Error occured while getting subkey by name: %d\n", error2)); } writediff(t2, t1, out); } - numvals2 = reg_key_num_values(newkey); - for(i = 0; i < numvals2; i++) { - REG_VAL *t1 = reg_key_get_value_by_index(newkey, i); - REG_VAL *t2 = reg_key_get_value_by_name(oldkey, reg_val_name(t1)); - if(!t2 || reg_val_size(t2) != reg_val_size(t1) || memcmp(reg_val_data_blk(t1), reg_val_data_blk(t2), reg_val_size(t1))) { - fprintf(out, "\"%s\"=%s:%s\n", reg_val_name(t1), str_regtype(reg_val_type(t1)), reg_val_data_string(t1)); + if(!W_ERROR_EQUAL(error1, WERR_NO_MORE_ITEMS)) { + DEBUG(0, ("Error occured while getting subkey by index: %d\n", error1)); + return; + } + + for(i = 0; W_ERROR_IS_OK(error1 = reg_key_get_value_by_index(newkey, i, &v1)); i++) { + error2 = reg_key_get_value_by_name(oldkey, reg_val_name(v1), &v2); + if ((W_ERROR_IS_OK(error2) && reg_val_size(v2) != reg_val_size(v1) || memcmp(reg_val_data_blk(v1), reg_val_data_blk(v2), reg_val_size(v1))) + || W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { + fprintf(out, "\"%s\"=%s:%s\n", reg_val_name(v1), str_regtype(reg_val_type(v1)), reg_val_data_string(v1)); + } + + if(!W_ERROR_IS_OK(error2) && !W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { + DEBUG(0, ("Error occured while getting value by name: %d\n", error2)); } } - numvals1 = reg_key_num_values(oldkey); - for(i = 0; i < numvals1; i++) { - REG_VAL *t1 = reg_key_get_value_by_index(oldkey, i); - if(!reg_key_get_value_by_name(newkey, reg_val_name(t1))) { - fprintf(out, "\"%s\"=-\n", reg_val_name(t1)); + if(!W_ERROR_EQUAL(error1, WERR_NO_MORE_ITEMS)) { + DEBUG(0, ("Error occured while getting value by index: %d\n", error1)); + return; + } + + + for(i = 0; W_ERROR_IS_OK(error1 = reg_key_get_value_by_index(oldkey, i, &v1)); i++) { + error2 = reg_key_get_value_by_name(newkey, reg_val_name(v1), &v2); + if(W_ERROR_IS_OK(error2)) { + } else if(W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { + fprintf(out, "\"%s\"=-\n", reg_val_name(v1)); + } else { + DEBUG(0, ("Error occured while getting value by name: %d\n", error2)); } } + + if(!W_ERROR_EQUAL(error1, WERR_NO_MORE_ITEMS)) { + DEBUG(0, ("Error occured while getting value by index: %d\n", error1)); + return; + } } int main (int argc, char **argv) @@ -69,15 +99,18 @@ int main (int argc, char **argv) REG_KEY *root; const char *backend1 = NULL, *backend2 = NULL; const char *location2; + const char *credentials1= NULL, *credentials2 = NULL; char *outputfile = NULL; FILE *fd = stdout; REG_HANDLE *h2; REG_KEY *root1 = NULL, *root2; int from_null = 0; int fullpath = 0, no_values = 0; + WERROR error; struct poptOption long_options[] = { POPT_AUTOHELP {"backend", 'b', POPT_ARG_STRING, NULL, 'b', "backend to use", NULL}, + {"credentials", 'c', POPT_ARG_STRING, NULL, 'c', "credentials", NULL}, {"output", 'o', POPT_ARG_STRING, &outputfile, 'o', "output file to use", NULL }, {"null", 'n', POPT_ARG_NONE, &from_null, 'n', "Diff from NULL" }, POPT_TABLEEND @@ -87,7 +120,11 @@ int main (int argc, char **argv) while((opt = poptGetNextOpt(pc)) != -1) { switch(opt) { - case 'b': + case 'c': + if(!credentials1 && !from_null) credentials1 = poptGetOptArg(pc); + else if(!credentials2) credentials2 = poptGetOptArg(pc); + break; + case 'b': if(!backend1 && !from_null) backend1 = poptGetOptArg(pc); else if(!backend2) backend2 = poptGetOptArg(pc); break; @@ -106,13 +143,13 @@ int main (int argc, char **argv) if(!backend1) backend1 = "dir"; - h1 = reg_open(backend1, location1, True); - if(!h1) { + error = reg_open(backend1, location1, credentials1, &h1); + if(!W_ERROR_IS_OK(error)) { fprintf(stderr, "Unable to open '%s' with backend '%s'\n", location1, backend1); return 1; } - root1 = reg_get_root(h1); + if(!W_ERROR_IS_OK(reg_get_root(h1, &root1))) return 1; } location2 = poptGetArg(pc); @@ -123,14 +160,14 @@ int main (int argc, char **argv) if(!backend2) backend2 = "dir"; - h2 = reg_open(backend2, location2, True); - if(!h2) { + error = reg_open(backend2, location2, credentials2, &h2); + if(!W_ERROR_IS_OK(error)) { fprintf(stderr, "Unable to open '%s' with backend '%s'\n", location2, backend2); return 1; } - root2 = reg_get_root(h2); - if(!root2) { + error = reg_get_root(h2, &root2); + if(!W_ERROR_IS_OK(error)) { fprintf(stderr, "Can't open root key for '%s:%s'\n", backend2, location2); return 1; } -- 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/regdiff.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 94cdf8c8af..305a7a1e46 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -23,7 +23,7 @@ void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) { - int i, numkeys1, numvals1, numvals2, numkeys2; + int i; REG_KEY *t1,*t2; REG_VAL *v1, *v2; WERROR error1, error2; @@ -33,12 +33,12 @@ void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) if(W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { fprintf(out, "-%s\n", reg_key_get_path(t1)+1); } else if(!W_ERROR_IS_OK(error2)) { - DEBUG(0, ("Error occured while getting subkey by name: %d\n", error2)); + DEBUG(0, ("Error occured while getting subkey by name: %d\n", W_ERROR_V(error2))); } } if(!W_ERROR_EQUAL(error1, WERR_NO_MORE_ITEMS)) { - DEBUG(0, ("Error occured while getting subkey by index: %d\n", error1)); + DEBUG(0, ("Error occured while getting subkey by index: %d\n", W_ERROR_V(error1))); return; } @@ -47,13 +47,13 @@ void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) if(W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { fprintf(out, "\n[%s]\n", reg_key_get_path(t1)+1); } else if(!W_ERROR_IS_OK(error2)) { - DEBUG(0, ("Error occured while getting subkey by name: %d\n", error2)); + DEBUG(0, ("Error occured while getting subkey by name: %d\n", W_ERROR_V(error2))); } writediff(t2, t1, out); } if(!W_ERROR_EQUAL(error1, WERR_NO_MORE_ITEMS)) { - DEBUG(0, ("Error occured while getting subkey by index: %d\n", error1)); + DEBUG(0, ("Error occured while getting subkey by index: %d\n", W_ERROR_V(error1))); return; } @@ -65,12 +65,12 @@ void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) } if(!W_ERROR_IS_OK(error2) && !W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { - DEBUG(0, ("Error occured while getting value by name: %d\n", error2)); + DEBUG(0, ("Error occured while getting value by name: %d\n", W_ERROR_V(error2))); } } if(!W_ERROR_EQUAL(error1, WERR_NO_MORE_ITEMS)) { - DEBUG(0, ("Error occured while getting value by index: %d\n", error1)); + DEBUG(0, ("Error occured while getting value by index: %d\n", W_ERROR_V(error1))); return; } @@ -81,22 +81,20 @@ void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) } else if(W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { fprintf(out, "\"%s\"=-\n", reg_val_name(v1)); } else { - DEBUG(0, ("Error occured while getting value by name: %d\n", error2)); + DEBUG(0, ("Error occured while getting value by name: %d\n", W_ERROR_V(error2))); } } if(!W_ERROR_EQUAL(error1, WERR_NO_MORE_ITEMS)) { - DEBUG(0, ("Error occured while getting value by index: %d\n", error1)); + DEBUG(0, ("Error occured while getting value by index: %d\n", W_ERROR_V(error1))); return; } } int main (int argc, char **argv) { - uint32 setparms, checkparms; int opt; poptContext pc; - REG_KEY *root; const char *backend1 = NULL, *backend2 = NULL; const char *location2; const char *credentials1= NULL, *credentials2 = NULL; @@ -105,7 +103,6 @@ int main (int argc, char **argv) REG_HANDLE *h2; REG_KEY *root1 = NULL, *root2; int from_null = 0; - int fullpath = 0, no_values = 0; WERROR error; struct poptOption long_options[] = { POPT_AUTOHELP -- 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/regdiff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 305a7a1e46..c3633ef0af 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -59,7 +59,7 @@ void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) for(i = 0; W_ERROR_IS_OK(error1 = reg_key_get_value_by_index(newkey, i, &v1)); i++) { error2 = reg_key_get_value_by_name(oldkey, reg_val_name(v1), &v2); - if ((W_ERROR_IS_OK(error2) && reg_val_size(v2) != reg_val_size(v1) || memcmp(reg_val_data_blk(v1), reg_val_data_blk(v2), reg_val_size(v1))) + if (((W_ERROR_IS_OK(error2) && reg_val_size(v2) != reg_val_size(v1)) || memcmp(reg_val_data_blk(v1), reg_val_data_blk(v2), reg_val_size(v1))) || W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { fprintf(out, "\"%s\"=%s:%s\n", reg_val_name(v1), str_regtype(reg_val_type(v1)), reg_val_data_string(v1)); } @@ -91,7 +91,7 @@ void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) } } -int main (int argc, char **argv) + int main(int argc, char **argv) { int opt; poptContext pc; -- cgit From b2d1f7890765fca5a119d43f4906e885c245005f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 12 May 2004 16:13:32 +0000 Subject: r655: Fix if() logic (This used to be commit 09096cfc3e1b35b4ac944cf84bfdec6ee44e06bf) --- source4/lib/registry/tools/regdiff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index c3633ef0af..888270f61f 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -24,7 +24,7 @@ void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) { int i; - REG_KEY *t1,*t2; + REG_KEY *t1, *t2; REG_VAL *v1, *v2; WERROR error1, error2; @@ -59,7 +59,7 @@ void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) for(i = 0; W_ERROR_IS_OK(error1 = reg_key_get_value_by_index(newkey, i, &v1)); i++) { error2 = reg_key_get_value_by_name(oldkey, reg_val_name(v1), &v2); - if (((W_ERROR_IS_OK(error2) && reg_val_size(v2) != reg_val_size(v1)) || memcmp(reg_val_data_blk(v1), reg_val_data_blk(v2), reg_val_size(v1))) + if ((W_ERROR_IS_OK(error2) && (reg_val_size(v2) != reg_val_size(v1) || memcmp(reg_val_data_blk(v1), reg_val_data_blk(v2), reg_val_size(v1)))) || W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { fprintf(out, "\"%s\"=%s:%s\n", reg_val_name(v1), str_regtype(reg_val_type(v1)), reg_val_data_string(v1)); } -- 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/regdiff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 888270f61f..d9419208cd 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -21,7 +21,7 @@ #include "includes.h" -void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) +static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) { int i; REG_KEY *t1, *t2; -- 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/regdiff.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index d9419208cd..7520e653bb 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -100,10 +100,11 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) const char *credentials1= NULL, *credentials2 = NULL; char *outputfile = NULL; FILE *fd = stdout; - REG_HANDLE *h2; + REG_HANDLE *h1, *h2; REG_KEY *root1 = NULL, *root2; int from_null = 0; - WERROR error; + int i; + WERROR error, error2; struct poptOption long_options[] = { POPT_AUTOHELP {"backend", 'b', POPT_ARG_STRING, NULL, 'b', "backend to use", NULL}, @@ -130,7 +131,6 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) setup_logging(argv[0], True); if(!from_null) { - REG_HANDLE *h1; const char *location1; location1 = poptGetArg(pc); if(!location1) { @@ -145,8 +145,6 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) fprintf(stderr, "Unable to open '%s' with backend '%s'\n", location1, backend1); return 1; } - - if(!W_ERROR_IS_OK(reg_get_root(h1, &root1))) return 1; } location2 = poptGetArg(pc); @@ -163,12 +161,6 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) return 1; } - error = reg_get_root(h2, &root2); - if(!W_ERROR_IS_OK(error)) { - fprintf(stderr, "Can't open root key for '%s:%s'\n", backend2, location2); - return 1; - } - poptFreeContext(pc); if(outputfile) { @@ -182,7 +174,23 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) fprintf(fd, "REGEDIT4\n\n"); fprintf(fd, "; Generated using regdiff\n"); - writediff(root1, root2, fd); + error2 = error = WERR_OK; + + for(i = 0; ; i++) { + if(backend1) error = reg_get_hive(h1, i, &root1); + else root1 = NULL; + + if(!W_ERROR_IS_OK(error)) break; + + if(backend2) error2 = reg_get_hive(h2, i, &root2); + else root2 = NULL; + + if(!W_ERROR_IS_OK(error2)) break; + + writediff(root1, root2, fd); + + if(!root1 && !root2) break; + } fclose(fd); -- cgit From 39e465a0965b7974c95f318db240d47cced37874 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 5 Jun 2004 19:30:13 +0000 Subject: r1035: Support shared modules again (This used to be commit 7949dc25ab05f7d5ad6217a6304e1f50b8b5dc41) --- source4/lib/registry/tools/regdiff.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 7520e653bb..b599a54c2e 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -91,7 +91,7 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) } } - int main(int argc, char **argv) +int main(int argc, char **argv) { int opt; poptContext pc; @@ -115,7 +115,7 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) }; pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0); - + while((opt = poptGetNextOpt(pc)) != -1) { switch(opt) { case 'c': @@ -123,9 +123,9 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) else if(!credentials2) credentials2 = poptGetOptArg(pc); break; case 'b': - if(!backend1 && !from_null) backend1 = poptGetOptArg(pc); - else if(!backend2) backend2 = poptGetOptArg(pc); - break; + if(!backend1 && !from_null) backend1 = poptGetOptArg(pc); + else if(!backend2) backend2 = poptGetOptArg(pc); + break; } } setup_logging(argv[0], True); @@ -154,13 +154,13 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) } if(!backend2) backend2 = "dir"; - + error = reg_open(backend2, location2, credentials2, &h2); if(!W_ERROR_IS_OK(error)) { fprintf(stderr, "Unable to open '%s' with backend '%s'\n", location2, backend2); return 1; } - + poptFreeContext(pc); if(outputfile) { @@ -175,24 +175,24 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) fprintf(fd, "; Generated using regdiff\n"); error2 = error = WERR_OK; - + for(i = 0; ; i++) { if(backend1) error = reg_get_hive(h1, i, &root1); else root1 = NULL; if(!W_ERROR_IS_OK(error)) break; - + if(backend2) error2 = reg_get_hive(h2, i, &root2); else root2 = NULL; - + if(!W_ERROR_IS_OK(error2)) break; - + writediff(root1, root2, fd); if(!root1 && !root2) break; } fclose(fd); - + return 0; } -- cgit From 7ea6a0b1fc3e5f35e5096ad820053d54c4496a09 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 6 Jun 2004 07:10:58 +0000 Subject: r1040: make sure main() doesn't get auto-prototyped (This used to be commit 7c2279e4bc631d88e402ac82c6c17fb811785394) --- source4/lib/registry/tools/regdiff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index b599a54c2e..c46411ae31 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -91,7 +91,7 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) } } -int main(int argc, char **argv) + int main(int argc, char **argv) { int opt; poptContext pc; -- 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/regdiff.c | 76 ++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 34 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index c46411ae31..524e538591 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -21,47 +21,57 @@ #include "includes.h" -static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) +static void writediff(struct registry_key *oldkey, struct registry_key *newkey, FILE *out) { int i; - REG_KEY *t1, *t2; - REG_VAL *v1, *v2; + struct registry_key *t1, *t2; + struct registry_value *v1, *v2; WERROR error1, error2; + TALLOC_CTX *mem_ctx = talloc_init("writediff"); - for(i = 0; W_ERROR_IS_OK(error1 = reg_key_get_subkey_by_index(oldkey, i, &t1)); i++) { - error2 = reg_key_get_subkey_by_name(newkey, reg_key_name(t1), &t2); + for(i = 0; W_ERROR_IS_OK(error1 = reg_key_get_subkey_by_index(mem_ctx, oldkey, i, &t1)); i++) { + error2 = reg_key_get_subkey_by_name(mem_ctx, newkey, t1->name, &t2); if(W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { - fprintf(out, "-%s\n", reg_key_get_path(t1)+1); + fprintf(out, "-%s\n", t1->path+1); } else if(!W_ERROR_IS_OK(error2)) { DEBUG(0, ("Error occured while getting subkey by name: %d\n", W_ERROR_V(error2))); } } + talloc_destroy(mem_ctx); + if(!W_ERROR_EQUAL(error1, WERR_NO_MORE_ITEMS)) { DEBUG(0, ("Error occured while getting subkey by index: %d\n", W_ERROR_V(error1))); return; } - for(i = 0; W_ERROR_IS_OK(error1 = reg_key_get_subkey_by_index(newkey, i, &t1)); i++) { - error2 = reg_key_get_subkey_by_name(oldkey, reg_key_name(t1), &t2); + mem_ctx = talloc_init("writediff"); + + for(i = 0; W_ERROR_IS_OK(error1 = reg_key_get_subkey_by_index(mem_ctx, newkey, i, &t1)); i++) { + error2 = reg_key_get_subkey_by_name(mem_ctx, oldkey, t1->name, &t2); if(W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { - fprintf(out, "\n[%s]\n", reg_key_get_path(t1)+1); + fprintf(out, "\n[%s]\n", t1->path+1); } else if(!W_ERROR_IS_OK(error2)) { DEBUG(0, ("Error occured while getting subkey by name: %d\n", W_ERROR_V(error2))); } writediff(t2, t1, out); } + talloc_destroy(mem_ctx); + if(!W_ERROR_EQUAL(error1, WERR_NO_MORE_ITEMS)) { DEBUG(0, ("Error occured while getting subkey by index: %d\n", W_ERROR_V(error1))); return; } - for(i = 0; W_ERROR_IS_OK(error1 = reg_key_get_value_by_index(newkey, i, &v1)); i++) { - error2 = reg_key_get_value_by_name(oldkey, reg_val_name(v1), &v2); - if ((W_ERROR_IS_OK(error2) && (reg_val_size(v2) != reg_val_size(v1) || memcmp(reg_val_data_blk(v1), reg_val_data_blk(v2), reg_val_size(v1)))) + + mem_ctx = talloc_init("writediff"); + + for(i = 0; W_ERROR_IS_OK(error1 = reg_key_get_value_by_index(mem_ctx, newkey, i, &v1)); i++) { + error2 = reg_key_get_value_by_name(mem_ctx, oldkey, v1->name, &v2); + if ((W_ERROR_IS_OK(error2) && (v2->data_len != v1->data_len || memcmp(v1->data_blk, v2->data_blk, v1->data_len))) || W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { - fprintf(out, "\"%s\"=%s:%s\n", reg_val_name(v1), str_regtype(reg_val_type(v1)), reg_val_data_string(v1)); + fprintf(out, "\"%s\"=%s:%s\n", v1->name, str_regtype(v1->data_type), reg_val_data_string(mem_ctx, v1)); } if(!W_ERROR_IS_OK(error2) && !W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { @@ -69,22 +79,27 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) } } + talloc_destroy(mem_ctx); + if(!W_ERROR_EQUAL(error1, WERR_NO_MORE_ITEMS)) { DEBUG(0, ("Error occured while getting value by index: %d\n", W_ERROR_V(error1))); return; } + mem_ctx = talloc_init("writediff"); - for(i = 0; W_ERROR_IS_OK(error1 = reg_key_get_value_by_index(oldkey, i, &v1)); i++) { - error2 = reg_key_get_value_by_name(newkey, reg_val_name(v1), &v2); + for(i = 0; W_ERROR_IS_OK(error1 = reg_key_get_value_by_index(mem_ctx, oldkey, i, &v1)); i++) { + error2 = reg_key_get_value_by_name(mem_ctx, newkey, v1->name, &v2); if(W_ERROR_IS_OK(error2)) { } else if(W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { - fprintf(out, "\"%s\"=-\n", reg_val_name(v1)); + fprintf(out, "\"%s\"=-\n", v1->name); } else { DEBUG(0, ("Error occured while getting value by name: %d\n", W_ERROR_V(error2))); } } + talloc_destroy(mem_ctx); + if(!W_ERROR_EQUAL(error1, WERR_NO_MORE_ITEMS)) { DEBUG(0, ("Error occured while getting value by index: %d\n", W_ERROR_V(error1))); return; @@ -100,8 +115,7 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) const char *credentials1= NULL, *credentials2 = NULL; char *outputfile = NULL; FILE *fd = stdout; - REG_HANDLE *h1, *h2; - REG_KEY *root1 = NULL, *root2; + struct registry_context *h1, *h2; int from_null = 0; int i; WERROR error, error2; @@ -114,6 +128,12 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) 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) { @@ -140,7 +160,7 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) if(!backend1) backend1 = "dir"; - error = reg_open(backend1, location1, credentials1, &h1); + error = reg_open(&h1, backend1, location1, credentials1); if(!W_ERROR_IS_OK(error)) { fprintf(stderr, "Unable to open '%s' with backend '%s'\n", location1, backend1); return 1; @@ -155,7 +175,7 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) if(!backend2) backend2 = "dir"; - error = reg_open(backend2, location2, credentials2, &h2); + error = reg_open(&h2, backend2, location2, credentials2); if(!W_ERROR_IS_OK(error)) { fprintf(stderr, "Unable to open '%s' with backend '%s'\n", location2, backend2); return 1; @@ -176,20 +196,8 @@ static void writediff(REG_KEY *oldkey, REG_KEY *newkey, FILE *out) error2 = error = WERR_OK; - for(i = 0; ; i++) { - if(backend1) error = reg_get_hive(h1, i, &root1); - else root1 = NULL; - - if(!W_ERROR_IS_OK(error)) break; - - if(backend2) error2 = reg_get_hive(h2, i, &root2); - else root2 = NULL; - - if(!W_ERROR_IS_OK(error2)) break; - - writediff(root1, root2, fd); - - if(!root1 && !root2) break; + for(i = 0; i < h1->num_hives && i < h2->num_hives; i++) { + writediff(h1->hives[i]->root, h2->hives[i]->root, fd); } fclose(fd); -- 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/regdiff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 524e538591..41a29e46d3 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -158,7 +158,7 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, return 1; } - if(!backend1) backend1 = "dir"; + if(!backend1) backend1 = "rpc"; error = reg_open(&h1, backend1, location1, credentials1); if(!W_ERROR_IS_OK(error)) { @@ -173,7 +173,7 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, return 2; } - if(!backend2) backend2 = "dir"; + if(!backend2) backend2 = "rpc"; error = reg_open(&h2, backend2, location2, credentials2); if(!W_ERROR_IS_OK(error)) { -- cgit From def0a74030714d07ed852178d9a8f2ec4ed16bab Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 29 Oct 2004 14:53:23 +0000 Subject: r3370: Initial work on Add Key/Delete Key/Add Value/Mod Value/Del Value support in gregedit (This used to be commit 33f429c61f2859e3ad60fa38823174bbd331d91a) --- source4/lib/registry/tools/regdiff.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 41a29e46d3..bedf3222d1 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -115,7 +115,7 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, const char *credentials1= NULL, *credentials2 = NULL; char *outputfile = NULL; FILE *fd = stdout; - struct registry_context *h1, *h2; + struct registry_context *h1 = NULL, *h2; int from_null = 0; int i; WERROR error, error2; @@ -165,7 +165,7 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, fprintf(stderr, "Unable to open '%s' with backend '%s'\n", location1, backend1); return 1; } - } + } location2 = poptGetArg(pc); if(!location2) { @@ -196,8 +196,8 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, error2 = error = WERR_OK; - for(i = 0; i < h1->num_hives && i < h2->num_hives; i++) { - writediff(h1->hives[i]->root, h2->hives[i]->root, fd); + for(i = 0; (!h1 || i < h1->num_hives) && i < h2->num_hives; i++) { + writediff(h1?h1->hives[i]->root:NULL, h2->hives[i]->root, fd); } fclose(fd); -- 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/regdiff.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index bedf3222d1..1d69734f21 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -20,6 +20,7 @@ */ #include "includes.h" +#include "lib/cmdline/popt_common.h" static void writediff(struct registry_key *oldkey, struct registry_key *newkey, FILE *out) { -- 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/regdiff.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 1d69734f21..c1b8d2949e 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -20,6 +20,7 @@ */ #include "includes.h" +#include "registry.h" #include "lib/cmdline/popt_common.h" static void writediff(struct registry_key *oldkey, struct registry_key *newkey, FILE *out) -- 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/regdiff.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index c1b8d2949e..80f4a5c49f 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -20,6 +20,7 @@ */ #include "includes.h" +#include "dynconfig.h" #include "registry.h" #include "lib/cmdline/popt_common.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/regdiff.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 80f4a5c49f..55c8f1e72f 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -131,6 +131,7 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, POPT_TABLEEND }; + regdiff_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 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/regdiff.c | 76 +++++++++++++++--------------------- 1 file changed, 31 insertions(+), 45 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 55c8f1e72f..fc2954b6af 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -113,21 +113,19 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, { int opt; poptContext pc; - const char *backend1 = NULL, *backend2 = NULL; - const char *location2; - const char *credentials1= NULL, *credentials2 = NULL; char *outputfile = NULL; FILE *fd = stdout; - struct registry_context *h1 = NULL, *h2; + struct registry_context *h1 = NULL, *h2 = NULL; int from_null = 0; int i; WERROR error, error2; struct poptOption long_options[] = { POPT_AUTOHELP - {"backend", 'b', POPT_ARG_STRING, NULL, 'b', "backend to use", NULL}, - {"credentials", 'c', POPT_ARG_STRING, NULL, 'c', "credentials", NULL}, + POPT_COMMON_CREDENTIALS {"output", 'o', POPT_ARG_STRING, &outputfile, 'o', "output file to use", NULL }, - {"null", 'n', POPT_ARG_NONE, &from_null, 'n', "Diff from NULL" }, + {"null", 'n', POPT_ARG_NONE, &from_null, 'n', "Diff from NULL", NULL }, + {"remote", 'R', POPT_ARG_STRING, NULL, 0, "Connect to remote server" , NULL }, + {"local", 'L', POPT_ARG_NONE, NULL, 0, "Open local registry", NULL }, POPT_TABLEEND }; @@ -141,49 +139,24 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0); while((opt = poptGetNextOpt(pc)) != -1) { + error = WERR_OK; switch(opt) { - case 'c': - if(!credentials1 && !from_null) credentials1 = poptGetOptArg(pc); - else if(!credentials2) credentials2 = poptGetOptArg(pc); + case 'L': + if (!h1 && !from_null) error = reg_open_local(&h1); + else if (!h2) error = reg_open_local(&h2); break; - case 'b': - if(!backend1 && !from_null) backend1 = poptGetOptArg(pc); - else if(!backend2) backend2 = poptGetOptArg(pc); + case 'R': + if (!h1 && !from_null) error = reg_open_remote(&h1, cmdline_get_username(), cmdline_get_userpassword(), poptGetOptArg(pc)); + else if (!h2) error = reg_open_remote(&h2, cmdline_get_username(), cmdline_get_userpassword(), poptGetOptArg(pc)); break; } - } - setup_logging(argv[0], True); - if(!from_null) { - const char *location1; - location1 = poptGetArg(pc); - if(!location1) { - poptPrintUsage(pc, stderr, 0); + if (!W_ERROR_IS_OK(error)) { + fprintf(stderr, "Error: %s\n", win_errstr(error)); return 1; } - - if(!backend1) backend1 = "rpc"; - - error = reg_open(&h1, backend1, location1, credentials1); - if(!W_ERROR_IS_OK(error)) { - fprintf(stderr, "Unable to open '%s' with backend '%s'\n", location1, backend1); - return 1; - } - } - - location2 = poptGetArg(pc); - if(!location2) { - poptPrintUsage(pc, stderr, 0); - return 2; - } - - if(!backend2) backend2 = "rpc"; - - error = reg_open(&h2, backend2, location2, credentials2); - if(!W_ERROR_IS_OK(error)) { - fprintf(stderr, "Unable to open '%s' with backend '%s'\n", location2, backend2); - return 1; } + setup_logging(argv[0], True); poptFreeContext(pc); @@ -196,12 +169,25 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, } fprintf(fd, "REGEDIT4\n\n"); - fprintf(fd, "; Generated using regdiff\n"); + fprintf(fd, "; Generated using regdiff, part of Samba\n"); error2 = error = WERR_OK; - for(i = 0; (!h1 || i < h1->num_hives) && i < h2->num_hives; i++) { - writediff(h1?h1->hives[i]->root:NULL, h2->hives[i]->root, fd); + for(i = HKEY_CLASSES_ROOT; i <= HKEY_PN; i++) { + struct registry_key *r1, *r2; + error = reg_get_hive(h1, i, &r1); + if (!W_ERROR_IS_OK(error)) { + DEBUG(0, ("Unable to open hive %s for backend 1\n", reg_get_hkey_name(i))); + continue; + } + + error = reg_get_hive(h2, i, &r2); + if (!W_ERROR_IS_OK(error)) { + DEBUG(0, ("Unable to open hive %s for backend 2\n", reg_get_hkey_name(i))); + continue; + } + + writediff(r1, r2, fd); } fclose(fd); -- cgit From 6cf13f4d72beee3df0432d0898c5981ce8bced43 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 11 Dec 2004 17:12:16 +0000 Subject: r4154: Add definitions for HKEY_PERFORMANCE_TEXT and HKEY_PERFORMANCE_NLSTEXT Hives and predefined keys (HKEY_*) are not necessarily the same thing. (This used to be commit 217e4e5841cfedb2b18dce3f89dd88ea4a36fe8f) --- source4/lib/registry/tools/regdiff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index fc2954b6af..dfa85d636f 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -173,7 +173,7 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, error2 = error = WERR_OK; - for(i = HKEY_CLASSES_ROOT; i <= HKEY_PN; i++) { + for(i = HKEY_CLASSES_ROOT; i <= HKEY_PERFORMANCE_NLSTEXT; i++) { struct registry_key *r1, *r2; error = reg_get_hive(h1, i, &r1); if (!W_ERROR_IS_OK(error)) { -- 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/regdiff.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index dfa85d636f..8d88cafe59 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -175,15 +175,15 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, for(i = HKEY_CLASSES_ROOT; i <= HKEY_PERFORMANCE_NLSTEXT; i++) { struct registry_key *r1, *r2; - error = reg_get_hive(h1, i, &r1); + error = reg_get_predefined_key(h1, i, &r1); if (!W_ERROR_IS_OK(error)) { - DEBUG(0, ("Unable to open hive %s for backend 1\n", reg_get_hkey_name(i))); + DEBUG(0, ("Unable to open hive %s for backend 1\n", reg_get_predef_name(i))); continue; } - error = reg_get_hive(h2, i, &r2); + error = reg_get_predefined_key(h2, i, &r2); if (!W_ERROR_IS_OK(error)) { - DEBUG(0, ("Unable to open hive %s for backend 2\n", reg_get_hkey_name(i))); + DEBUG(0, ("Unable to open hive %s for backend 2\n", reg_get_predef_name(i))); continue; } -- 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/regdiff.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 8d88cafe59..ceae3a427e 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -41,7 +41,7 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, } } - talloc_destroy(mem_ctx); + talloc_free(mem_ctx); if(!W_ERROR_EQUAL(error1, WERR_NO_MORE_ITEMS)) { DEBUG(0, ("Error occured while getting subkey by index: %d\n", W_ERROR_V(error1))); @@ -60,7 +60,7 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, writediff(t2, t1, out); } - talloc_destroy(mem_ctx); + talloc_free(mem_ctx); if(!W_ERROR_EQUAL(error1, WERR_NO_MORE_ITEMS)) { DEBUG(0, ("Error occured while getting subkey by index: %d\n", W_ERROR_V(error1))); @@ -82,7 +82,7 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, } } - talloc_destroy(mem_ctx); + talloc_free(mem_ctx); if(!W_ERROR_EQUAL(error1, WERR_NO_MORE_ITEMS)) { DEBUG(0, ("Error occured while getting value by index: %d\n", W_ERROR_V(error1))); @@ -101,7 +101,7 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, } } - talloc_destroy(mem_ctx); + talloc_free(mem_ctx); if(!W_ERROR_EQUAL(error1, WERR_NO_MORE_ITEMS)) { DEBUG(0, ("Error occured while getting value by index: %d\n", W_ERROR_V(error1))); -- 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/regdiff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index ceae3a427e..7206e1e44d 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -146,8 +146,8 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, else if (!h2) error = reg_open_local(&h2); break; case 'R': - if (!h1 && !from_null) error = reg_open_remote(&h1, cmdline_get_username(), cmdline_get_userpassword(), poptGetOptArg(pc)); - else if (!h2) error = reg_open_remote(&h2, cmdline_get_username(), cmdline_get_userpassword(), poptGetOptArg(pc)); + if (!h1 && !from_null) error = reg_open_remote(&h1, cli_credentials_get_username(cmdline_credentials), cli_credentials_get_password(cmdline_credentials), poptGetOptArg(pc)); + else if (!h2) error = reg_open_remote(&h2, cli_credentials_get_username(cmdline_credentials), cli_credentials_get_password(cmdline_credentials), poptGetOptArg(pc)); break; } -- 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/regdiff.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 7206e1e44d..dfc8be13ca 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -146,8 +146,9 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, else if (!h2) error = reg_open_local(&h2); break; case 'R': - if (!h1 && !from_null) error = reg_open_remote(&h1, cli_credentials_get_username(cmdline_credentials), cli_credentials_get_password(cmdline_credentials), poptGetOptArg(pc)); - else if (!h2) error = reg_open_remote(&h2, cli_credentials_get_username(cmdline_credentials), cli_credentials_get_password(cmdline_credentials), poptGetOptArg(pc)); + if (!h1 && !from_null) + error = reg_open_remote(&h1, cmdline_credentials, poptGetOptArg(pc)); + else if (!h2) error = reg_open_remote(&h2, cmdline_credentials, poptGetOptArg(pc)); break; } -- 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/regdiff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index dfc8be13ca..4260a56142 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -157,7 +157,7 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, return 1; } } - setup_logging(argv[0], True); + setup_logging(argv[0], DEBUG_STDOUT); poptFreeContext(pc); -- 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/regdiff.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 4260a56142..f86c0ae383 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -121,21 +121,18 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, WERROR error, error2; struct poptOption long_options[] = { POPT_AUTOHELP - POPT_COMMON_CREDENTIALS {"output", 'o', POPT_ARG_STRING, &outputfile, 'o', "output file to use", NULL }, {"null", 'n', POPT_ARG_NONE, &from_null, 'n', "Diff from NULL", NULL }, {"remote", 'R', POPT_ARG_STRING, NULL, 0, "Connect to remote server" , NULL }, {"local", 'L', POPT_ARG_NONE, NULL, 0, "Open local registry", NULL }, + POPT_COMMON_SAMBA + POPT_COMMON_CREDENTIALS + POPT_COMMON_VERSION POPT_TABLEEND }; regdiff_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) { @@ -157,7 +154,6 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, return 1; } } - setup_logging(argv[0], DEBUG_STDOUT); poptFreeContext(pc); -- 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/regdiff.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index f86c0ae383..a9d189c033 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -144,8 +144,10 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, break; case 'R': if (!h1 && !from_null) - error = reg_open_remote(&h1, cmdline_credentials, poptGetOptArg(pc)); - else if (!h2) error = reg_open_remote(&h2, cmdline_credentials, poptGetOptArg(pc)); + error = reg_open_remote(&h1, cmdline_credentials, + poptGetOptArg(pc), NULL); + else if (!h2) error = reg_open_remote(&h2, cmdline_credentials, + poptGetOptArg(pc), NULL); break; } -- 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/regdiff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index a9d189c033..307ec3793e 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -72,7 +72,7 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, for(i = 0; W_ERROR_IS_OK(error1 = reg_key_get_value_by_index(mem_ctx, newkey, i, &v1)); i++) { error2 = reg_key_get_value_by_name(mem_ctx, oldkey, v1->name, &v2); - if ((W_ERROR_IS_OK(error2) && (v2->data_len != v1->data_len || memcmp(v1->data_blk, v2->data_blk, v1->data_len))) + if ((W_ERROR_IS_OK(error2) && data_blob_equal(&v1->data, &v2->data)) || W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { fprintf(out, "\"%s\"=%s:%s\n", v1->name, str_regtype(v1->data_type), reg_val_data_string(mem_ctx, v1)); } -- 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/regdiff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 307ec3793e..3d8201330e 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -21,7 +21,7 @@ #include "includes.h" #include "dynconfig.h" -#include "registry.h" +#include "lib/registry/registry.h" #include "lib/cmdline/popt_common.h" static void writediff(struct registry_key *oldkey, struct registry_key *newkey, FILE *out) -- 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/regdiff.c | 128 +++-------------------------------- 1 file changed, 9 insertions(+), 119 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 3d8201330e..92fe53ff67 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -2,7 +2,7 @@ Unix SMB/CIFS implementation. simple registry frontend - Copyright (C) Jelmer Vernooij 2004 + Copyright (C) Jelmer Vernooij 2004-2005 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 @@ -24,101 +24,15 @@ #include "lib/registry/registry.h" #include "lib/cmdline/popt_common.h" -static void writediff(struct registry_key *oldkey, struct registry_key *newkey, FILE *out) -{ - int i; - struct registry_key *t1, *t2; - struct registry_value *v1, *v2; - WERROR error1, error2; - TALLOC_CTX *mem_ctx = talloc_init("writediff"); - - for(i = 0; W_ERROR_IS_OK(error1 = reg_key_get_subkey_by_index(mem_ctx, oldkey, i, &t1)); i++) { - error2 = reg_key_get_subkey_by_name(mem_ctx, newkey, t1->name, &t2); - if(W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { - fprintf(out, "-%s\n", t1->path+1); - } else if(!W_ERROR_IS_OK(error2)) { - DEBUG(0, ("Error occured while getting subkey by name: %d\n", W_ERROR_V(error2))); - } - } - - talloc_free(mem_ctx); - - if(!W_ERROR_EQUAL(error1, WERR_NO_MORE_ITEMS)) { - DEBUG(0, ("Error occured while getting subkey by index: %d\n", W_ERROR_V(error1))); - return; - } - - mem_ctx = talloc_init("writediff"); - - for(i = 0; W_ERROR_IS_OK(error1 = reg_key_get_subkey_by_index(mem_ctx, newkey, i, &t1)); i++) { - error2 = reg_key_get_subkey_by_name(mem_ctx, oldkey, t1->name, &t2); - if(W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { - fprintf(out, "\n[%s]\n", t1->path+1); - } else if(!W_ERROR_IS_OK(error2)) { - DEBUG(0, ("Error occured while getting subkey by name: %d\n", W_ERROR_V(error2))); - } - writediff(t2, t1, out); - } - - talloc_free(mem_ctx); - - if(!W_ERROR_EQUAL(error1, WERR_NO_MORE_ITEMS)) { - DEBUG(0, ("Error occured while getting subkey by index: %d\n", W_ERROR_V(error1))); - return; - } - - - mem_ctx = talloc_init("writediff"); - - for(i = 0; W_ERROR_IS_OK(error1 = reg_key_get_value_by_index(mem_ctx, newkey, i, &v1)); i++) { - error2 = reg_key_get_value_by_name(mem_ctx, oldkey, v1->name, &v2); - if ((W_ERROR_IS_OK(error2) && data_blob_equal(&v1->data, &v2->data)) - || W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { - fprintf(out, "\"%s\"=%s:%s\n", v1->name, str_regtype(v1->data_type), reg_val_data_string(mem_ctx, v1)); - } - - if(!W_ERROR_IS_OK(error2) && !W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { - DEBUG(0, ("Error occured while getting value by name: %d\n", W_ERROR_V(error2))); - } - } - - talloc_free(mem_ctx); - - if(!W_ERROR_EQUAL(error1, WERR_NO_MORE_ITEMS)) { - DEBUG(0, ("Error occured while getting value by index: %d\n", W_ERROR_V(error1))); - return; - } - - mem_ctx = talloc_init("writediff"); - - for(i = 0; W_ERROR_IS_OK(error1 = reg_key_get_value_by_index(mem_ctx, oldkey, i, &v1)); i++) { - error2 = reg_key_get_value_by_name(mem_ctx, newkey, v1->name, &v2); - if(W_ERROR_IS_OK(error2)) { - } else if(W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) { - fprintf(out, "\"%s\"=-\n", v1->name); - } else { - DEBUG(0, ("Error occured while getting value by name: %d\n", W_ERROR_V(error2))); - } - } - - talloc_free(mem_ctx); - - if(!W_ERROR_EQUAL(error1, WERR_NO_MORE_ITEMS)) { - DEBUG(0, ("Error occured while getting value by index: %d\n", W_ERROR_V(error1))); - return; - } -} - - int main(int argc, char **argv) +int main(int argc, char **argv) { int opt; poptContext pc; char *outputfile = NULL; - FILE *fd = stdout; struct registry_context *h1 = NULL, *h2 = NULL; int from_null = 0; - int i; - WERROR error, error2; + WERROR error; + struct reg_diff *diff; struct poptOption long_options[] = { POPT_AUTOHELP {"output", 'o', POPT_ARG_STRING, &outputfile, 'o', "output file to use", NULL }, @@ -159,37 +73,13 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey, poptFreeContext(pc); - if(outputfile) { - fd = fopen(outputfile, "w+"); - if(!fd) { - fprintf(stderr, "Unable to open '%s'\n", outputfile); - return 1; - } - } - - fprintf(fd, "REGEDIT4\n\n"); - fprintf(fd, "; Generated using regdiff, part of Samba\n"); - - error2 = error = WERR_OK; - - for(i = HKEY_CLASSES_ROOT; i <= HKEY_PERFORMANCE_NLSTEXT; i++) { - struct registry_key *r1, *r2; - error = reg_get_predefined_key(h1, i, &r1); - if (!W_ERROR_IS_OK(error)) { - DEBUG(0, ("Unable to open hive %s for backend 1\n", reg_get_predef_name(i))); - continue; - } - - error = reg_get_predefined_key(h2, i, &r2); - if (!W_ERROR_IS_OK(error)) { - DEBUG(0, ("Unable to open hive %s for backend 2\n", reg_get_predef_name(i))); - continue; - } - - writediff(r1, r2, fd); + diff = reg_generate_diff(NULL, h1, h2); + if (!diff) { + fprintf(stderr, "Unable to generate diff between keys\n"); + return -1; } - fclose(fd); + reg_diff_save(diff, outputfile); return 0; } -- 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/regdiff.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 92fe53ff67..7c6a5d75ae 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -23,6 +23,7 @@ #include "dynconfig.h" #include "lib/registry/registry.h" #include "lib/cmdline/popt_common.h" +#include "smb_build.h" int main(int argc, char **argv) { -- 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/regdiff.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 7c6a5d75ae..3720298df8 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -48,6 +48,8 @@ int main(int argc, char **argv) regdiff_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/regdiff.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 3720298df8..68cc56f9dd 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -20,7 +20,6 @@ */ #include "includes.h" -#include "dynconfig.h" #include "lib/registry/registry.h" #include "lib/cmdline/popt_common.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/regdiff.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 68cc56f9dd..5b876ca025 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -22,7 +22,6 @@ #include "includes.h" #include "lib/registry/registry.h" #include "lib/cmdline/popt_common.h" -#include "smb_build.h" int main(int argc, char **argv) { @@ -45,8 +44,6 @@ int main(int argc, char **argv) POPT_TABLEEND }; - regdiff_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/regdiff.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 5b876ca025..f1c5db1598 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -21,6 +21,7 @@ #include "includes.h" #include "lib/registry/registry.h" +#include "lib/registry/reg_backend_rpc.h" #include "lib/cmdline/popt_common.h" int main(int argc, char **argv) -- 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/regdiff.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index f1c5db1598..ae617bbe84 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -21,6 +21,7 @@ #include "includes.h" #include "lib/registry/registry.h" +#include "lib/events/events.h" #include "lib/registry/reg_backend_rpc.h" #include "lib/cmdline/popt_common.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/regdiff.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index ae617bbe84..c7e6f87792 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -54,14 +54,14 @@ int main(int argc, char **argv) error = WERR_OK; switch(opt) { case 'L': - if (!h1 && !from_null) error = reg_open_local(&h1); - else if (!h2) error = reg_open_local(&h2); + if (!h1 && !from_null) error = reg_open_local(&h1, NULL, cmdline_credentials); + else if (!h2) error = reg_open_local(&h2, NULL, cmdline_credentials); break; case 'R': if (!h1 && !from_null) - error = reg_open_remote(&h1, cmdline_credentials, + error = reg_open_remote(&h1, NULL, cmdline_credentials, poptGetOptArg(pc), NULL); - else if (!h2) error = reg_open_remote(&h2, cmdline_credentials, + else if (!h2) error = reg_open_remote(&h2, NULL, cmdline_credentials, poptGetOptArg(pc), NULL); break; } -- 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/regdiff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index c7e6f87792..dbbe555ad6 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -43,7 +43,7 @@ int main(int argc, char **argv) POPT_COMMON_SAMBA POPT_COMMON_CREDENTIALS POPT_COMMON_VERSION - POPT_TABLEEND + { NULL } }; registry_init(); -- 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/regdiff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index dbbe555ad6..b8bf654a6b 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -54,8 +54,8 @@ int main(int argc, char **argv) error = WERR_OK; switch(opt) { case 'L': - if (!h1 && !from_null) error = reg_open_local(&h1, NULL, cmdline_credentials); - else if (!h2) error = reg_open_local(&h2, NULL, cmdline_credentials); + if (!h1 && !from_null) error = reg_open_local(NULL, &h1, NULL, cmdline_credentials); + else if (!h2) error = reg_open_local(NULL, &h2, NULL, cmdline_credentials); break; case 'R': if (!h1 && !from_null) -- 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/regdiff.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index b8bf654a6b..ab6f7c1a57 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -22,7 +22,6 @@ #include "includes.h" #include "lib/registry/registry.h" #include "lib/events/events.h" -#include "lib/registry/reg_backend_rpc.h" #include "lib/cmdline/popt_common.h" int main(int argc, char **argv) -- 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/regdiff.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index ab6f7c1a57..6eb8a78caf 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.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/regdiff.c | 103 ++++++++++++++++++++++++++--------- 1 file changed, 78 insertions(+), 25 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 6eb8a78caf..8030457f5c 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -2,7 +2,8 @@ Unix SMB/CIFS implementation. simple registry frontend - Copyright (C) Jelmer Vernooij 2004-2005 + Copyright (C) Jelmer Vernooij 2004-2007 + Copyright (C) Wilco Baan Hofman 2006 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 @@ -22,63 +23,115 @@ #include "lib/registry/registry.h" #include "lib/events/events.h" #include "lib/cmdline/popt_common.h" +#include "lib/registry/tools/common.h" -int main(int argc, char **argv) +enum reg_backend { REG_UNKNOWN, REG_LOCAL, REG_REMOTE, REG_NULL }; + +static struct registry_context *open_backend(poptContext pc, enum reg_backend backend, const char *remote_host) +{ + WERROR error; + struct registry_context *ctx; + + switch (backend) { + case REG_UNKNOWN: + poptPrintUsage(pc, stderr, 0); + return NULL; + case REG_LOCAL: + error = reg_open_samba(NULL, &ctx, NULL, cmdline_credentials); + break; + case REG_REMOTE: + error = reg_open_remote(&ctx, NULL, cmdline_credentials, remote_host, NULL); + break; + case REG_NULL: + error = reg_open_local(NULL, &ctx, NULL, cmdline_credentials); + break; + } + + if (!W_ERROR_IS_OK(error)) { + fprintf(stderr, "Error: %s\n", win_errstr(error)); + return NULL; + } + + return ctx; +} + +int main(int argc, const char **argv) { int opt; poptContext pc; char *outputfile = NULL; + enum reg_backend backend1 = REG_UNKNOWN, backend2 = REG_UNKNOWN; + const char *remote1 = NULL, *remote2 = NULL; struct registry_context *h1 = NULL, *h2 = NULL; - int from_null = 0; WERROR error; - struct reg_diff *diff; struct poptOption long_options[] = { POPT_AUTOHELP - {"output", 'o', POPT_ARG_STRING, &outputfile, 'o', "output file to use", NULL }, - {"null", 'n', POPT_ARG_NONE, &from_null, 'n', "Diff from NULL", NULL }, - {"remote", 'R', POPT_ARG_STRING, NULL, 0, "Connect to remote server" , NULL }, - {"local", 'L', POPT_ARG_NONE, NULL, 0, "Open local registry", NULL }, + {"output", 'o', POPT_ARG_STRING, &outputfile, 0, "output file to use", NULL }, + {"null", 'n', POPT_ARG_NONE, NULL, 'n', "Diff from NULL", NULL }, + {"remote", 'R', POPT_ARG_STRING, NULL, 'R', "Connect to remote server" , NULL }, + {"local", 'L', POPT_ARG_NONE, NULL, 'L', "Open local registry", NULL }, POPT_COMMON_SAMBA POPT_COMMON_CREDENTIALS POPT_COMMON_VERSION { NULL } }; + TALLOC_CTX *ctx; + void *callback_data; + struct reg_diff_callbacks *callbacks; - registry_init(); + ctx = talloc_init("regdiff"); - pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0); + pc = poptGetContext(argv[0], argc, argv, long_options,0); while((opt = poptGetNextOpt(pc)) != -1) { error = WERR_OK; switch(opt) { case 'L': - if (!h1 && !from_null) error = reg_open_local(NULL, &h1, NULL, cmdline_credentials); - else if (!h2) error = reg_open_local(NULL, &h2, NULL, cmdline_credentials); + if (backend1 == REG_UNKNOWN) + backend1 = REG_LOCAL; + else if (backend2 == REG_UNKNOWN) + backend2 = REG_LOCAL; + break; + case 'n': + if (backend1 == REG_UNKNOWN) + backend1 = REG_NULL; + else if (backend2 == REG_UNKNOWN) + backend2 = REG_NULL; break; case 'R': - if (!h1 && !from_null) - error = reg_open_remote(&h1, NULL, cmdline_credentials, - poptGetOptArg(pc), NULL); - else if (!h2) error = reg_open_remote(&h2, NULL, cmdline_credentials, - poptGetOptArg(pc), NULL); + if (backend1 == REG_UNKNOWN) { + backend1 = REG_REMOTE; + remote1 = poptGetOptArg(pc); + } else if (backend2 == REG_UNKNOWN) { + backend2 = REG_REMOTE; + remote2 = poptGetOptArg(pc); + } break; } - if (!W_ERROR_IS_OK(error)) { - fprintf(stderr, "Error: %s\n", win_errstr(error)); - return 1; - } } + h1 = open_backend(pc, backend1, remote1); + if (h1 == NULL) + return 1; + + h2 = open_backend(pc, backend2, remote2); + if (h2 == NULL) + return 1; + poptFreeContext(pc); - diff = reg_generate_diff(NULL, h1, h2); - if (!diff) { - fprintf(stderr, "Unable to generate diff between keys\n"); + error = reg_dotreg_diff_save(ctx, outputfile, &callbacks, &callback_data); + if (!W_ERROR_IS_OK(error)) { + fprintf(stderr, "Problem saving registry diff to '%s': %s\n", outputfile, win_errstr(error)); return -1; } - reg_diff_save(diff, outputfile); + error = reg_generate_diff(h1, h2, callbacks, callback_data); + if (!W_ERROR_IS_OK(error)) { + fprintf(stderr, "Unable to generate diff between keys: %s\n", win_errstr(error)); + return -1; + } return 0; } -- 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/regdiff.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 8030457f5c..f96761cda0 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -1,7 +1,7 @@ -/* +/* Unix SMB/CIFS implementation. simple registry frontend - + Copyright (C) Jelmer Vernooij 2004-2007 Copyright (C) Wilco Baan Hofman 2006 @@ -9,12 +9,12 @@ 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 . */ @@ -27,11 +27,13 @@ enum reg_backend { REG_UNKNOWN, REG_LOCAL, REG_REMOTE, REG_NULL }; -static struct registry_context *open_backend(poptContext pc, enum reg_backend backend, const char *remote_host) +static struct registry_context *open_backend(poptContext pc, + enum reg_backend backend, + const char *remote_host) { WERROR error; struct registry_context *ctx; - + switch (backend) { case REG_UNKNOWN: poptPrintUsage(pc, stderr, 0); @@ -40,7 +42,8 @@ static struct registry_context *open_backend(poptContext pc, enum reg_backend ba error = reg_open_samba(NULL, &ctx, NULL, cmdline_credentials); break; case REG_REMOTE: - error = reg_open_remote(&ctx, NULL, cmdline_credentials, remote_host, NULL); + error = reg_open_remote(&ctx, NULL, cmdline_credentials, + remote_host, NULL); break; case REG_NULL: error = reg_open_local(NULL, &ctx, NULL, cmdline_credentials); @@ -121,15 +124,18 @@ int main(int argc, const char **argv) poptFreeContext(pc); - error = reg_dotreg_diff_save(ctx, outputfile, &callbacks, &callback_data); + error = reg_dotreg_diff_save(ctx, outputfile, &callbacks, + &callback_data); if (!W_ERROR_IS_OK(error)) { - fprintf(stderr, "Problem saving registry diff to '%s': %s\n", outputfile, win_errstr(error)); + fprintf(stderr, "Problem saving registry diff to '%s': %s\n", + outputfile, win_errstr(error)); return -1; } error = reg_generate_diff(h1, h2, callbacks, callback_data); if (!W_ERROR_IS_OK(error)) { - fprintf(stderr, "Unable to generate diff between keys: %s\n", win_errstr(error)); + fprintf(stderr, "Unable to generate diff between keys: %s\n", + win_errstr(error)); return -1; } -- 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/regdiff.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index f96761cda0..1996861a2a 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -24,10 +24,12 @@ #include "lib/events/events.h" #include "lib/cmdline/popt_common.h" #include "lib/registry/tools/common.h" +#include "param/param.h" enum reg_backend { REG_UNKNOWN, REG_LOCAL, REG_REMOTE, REG_NULL }; static struct registry_context *open_backend(poptContext pc, + struct loadparm_context *lp_ctx, enum reg_backend backend, const char *remote_host) { @@ -39,7 +41,7 @@ static struct registry_context *open_backend(poptContext pc, poptPrintUsage(pc, stderr, 0); return NULL; case REG_LOCAL: - error = reg_open_samba(NULL, &ctx, NULL, cmdline_credentials); + error = reg_open_samba(NULL, &ctx, lp_ctx, NULL, cmdline_credentials); break; case REG_REMOTE: error = reg_open_remote(&ctx, NULL, cmdline_credentials, @@ -114,11 +116,11 @@ int main(int argc, const char **argv) } - h1 = open_backend(pc, backend1, remote1); + h1 = open_backend(pc, global_loadparm, backend1, remote1); if (h1 == NULL) return 1; - h2 = open_backend(pc, backend2, remote2); + h2 = open_backend(pc, global_loadparm, backend2, remote2); if (h2 == NULL) return 1; -- cgit From 4c4323009fa83f00ed319de59a3aad48fcd65994 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 7 Dec 2007 02:37:04 +0100 Subject: r26327: Explicit loadparm_context for RPC client functions. (This used to be commit eeb2251d22b3d6e0379444a73af69d1014692b07) --- source4/lib/registry/tools/regdiff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 1996861a2a..ea4b754fe7 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -44,7 +44,7 @@ static struct registry_context *open_backend(poptContext pc, error = reg_open_samba(NULL, &ctx, lp_ctx, NULL, cmdline_credentials); break; case REG_REMOTE: - error = reg_open_remote(&ctx, NULL, cmdline_credentials, + error = reg_open_remote(&ctx, NULL, cmdline_credentials, lp_ctx, remote_host, NULL); break; case REG_NULL: -- 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/regdiff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index ea4b754fe7..406eaeea3d 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -116,11 +116,11 @@ int main(int argc, const char **argv) } - h1 = open_backend(pc, global_loadparm, backend1, remote1); + h1 = open_backend(pc, cmdline_lp_ctx, backend1, remote1); if (h1 == NULL) return 1; - h2 = open_backend(pc, global_loadparm, backend2, remote2); + h2 = open_backend(pc, cmdline_lp_ctx, backend2, remote2); if (h2 == NULL) return 1; -- cgit From 3101cb888d5cbad785050b8491b138d683d444fb Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 25 Feb 2008 12:51:55 +0100 Subject: Remove uses of global_loadparm. (This used to be commit a16c9a2129ce92e7e1a613b2badd168e42ead436) --- source4/lib/registry/tools/regdiff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 406eaeea3d..c94380efd2 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -126,7 +126,7 @@ int main(int argc, const char **argv) poptFreeContext(pc); - error = reg_dotreg_diff_save(ctx, outputfile, &callbacks, + error = reg_dotreg_diff_save(ctx, outputfile, lp_iconv_convenience(cmdline_lp_ctx), &callbacks, &callback_data); if (!W_ERROR_IS_OK(error)) { fprintf(stderr, "Problem saving registry diff to '%s': %s\n", -- cgit From 2ef07ad551d398c39a595494aaa083a932ef79aa Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 16 Apr 2008 01:32:54 +0200 Subject: Remove unused arguments from reg_open_local(). (This used to be commit fee7ea7080ec40182efc6ffe57b267444eb9389a) --- source4/lib/registry/tools/regdiff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index c94380efd2..69fcfc2493 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -48,7 +48,7 @@ static struct registry_context *open_backend(poptContext pc, remote_host, NULL); break; case REG_NULL: - error = reg_open_local(NULL, &ctx, NULL, cmdline_credentials); + error = reg_open_local(NULL, &ctx); break; } -- 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/regdiff.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 69fcfc2493..9b49799bed 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -29,6 +29,7 @@ enum reg_backend { REG_UNKNOWN, REG_LOCAL, REG_REMOTE, REG_NULL }; static struct registry_context *open_backend(poptContext pc, + struct event_context *ev_ctx, struct loadparm_context *lp_ctx, enum reg_backend backend, const char *remote_host) @@ -41,7 +42,7 @@ static struct registry_context *open_backend(poptContext pc, poptPrintUsage(pc, stderr, 0); return NULL; case REG_LOCAL: - error = reg_open_samba(NULL, &ctx, lp_ctx, NULL, cmdline_credentials); + error = reg_open_samba(NULL, &ctx, ev_ctx, lp_ctx, NULL, cmdline_credentials); break; case REG_REMOTE: error = reg_open_remote(&ctx, NULL, cmdline_credentials, lp_ctx, @@ -82,6 +83,7 @@ int main(int argc, const char **argv) }; TALLOC_CTX *ctx; void *callback_data; + struct event_context *ev_ctx; struct reg_diff_callbacks *callbacks; ctx = talloc_init("regdiff"); @@ -116,11 +118,13 @@ int main(int argc, const char **argv) } - h1 = open_backend(pc, cmdline_lp_ctx, backend1, remote1); + ev_ctx = event_context_init(NULL); + + h1 = open_backend(pc, ev_ctx, cmdline_lp_ctx, backend1, remote1); if (h1 == NULL) return 1; - h2 = open_backend(pc, cmdline_lp_ctx, backend2, remote2); + h2 = open_backend(pc, ev_ctx, cmdline_lp_ctx, backend2, remote2); if (h2 == NULL) return 1; -- 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/regdiff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/regdiff.c') diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 9b49799bed..240c582340 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -118,7 +118,7 @@ int main(int argc, const char **argv) } - ev_ctx = event_context_init(NULL); + ev_ctx = s4_event_context_init(NULL); h1 = open_backend(pc, ev_ctx, cmdline_lp_ctx, backend1, remote1); if (h1 == NULL) -- cgit