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/common.c | 75 +++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 source4/lib/registry/tools/common.c (limited to 'source4/lib/registry/tools/common.c') diff --git a/source4/lib/registry/tools/common.c b/source4/lib/registry/tools/common.c new file mode 100644 index 0000000000..c8b0945c2c --- /dev/null +++ b/source4/lib/registry/tools/common.c @@ -0,0 +1,75 @@ +/* + Unix SMB/CIFS implementation. + Popt routines specifically for registry + + Copyright (C) Jelmer Vernooij 2007 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "includes.h" +#include "auth/credentials/credentials.h" +#include "lib/registry/registry.h" + +struct registry_context *reg_common_open_remote(const char *remote, struct cli_credentials *creds) +{ + struct registry_context *h; + WERROR error; + + error = reg_open_remote(&h, NULL, creds, remote, NULL); + + if (!W_ERROR_IS_OK(error)) { + fprintf(stderr, "Unable to open remote registry at %s:%s \n", remote, win_errstr(error)); + return NULL; + } + + return h; +} + +struct registry_key *reg_common_open_file(const char *path, struct cli_credentials *creds) +{ + struct hive_key *hive_root; + struct registry_context *h; + WERROR error; + + error = reg_open_hive(NULL, path, NULL, creds, &hive_root); + + if(!W_ERROR_IS_OK(error)) { + fprintf(stderr, "Unable to open '%s': %s \n", path, win_errstr(error)); + return NULL; + } + + error = reg_open_local(NULL, &h, NULL, creds); + if (!W_ERROR_IS_OK(error)) { + fprintf(stderr, "Unable to initialize local registry: %s\n", win_errstr(error)); + return NULL; + } + + return reg_import_hive_key(h, hive_root, -1, NULL); +} + +struct registry_context *reg_common_open_local(struct cli_credentials *creds) +{ + WERROR error; + struct registry_context *h; + + error = reg_open_samba(NULL, &h, NULL, creds); + + if(!W_ERROR_IS_OK(error)) { + fprintf(stderr, "Unable to open local registry:%s \n", win_errstr(error)); + return NULL; + } + + return h; +} -- cgit From 6cf69fee189857ae6f85cd3f81a6a58364839942 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 7 Sep 2007 13:31:15 +0000 Subject: r24994: Fix some C++ warnings. (This used to be commit 925abf74fa1ed5ae726bae8781ec549302786b39) --- source4/lib/registry/tools/common.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/tools/common.c') diff --git a/source4/lib/registry/tools/common.c b/source4/lib/registry/tools/common.c index c8b0945c2c..aa11eccbee 100644 --- a/source4/lib/registry/tools/common.c +++ b/source4/lib/registry/tools/common.c @@ -21,6 +21,7 @@ #include "includes.h" #include "auth/credentials/credentials.h" #include "lib/registry/registry.h" +#include "lib/registry/tools/common.h" struct registry_context *reg_common_open_remote(const char *remote, struct cli_credentials *creds) { -- 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/common.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'source4/lib/registry/tools/common.c') diff --git a/source4/lib/registry/tools/common.c b/source4/lib/registry/tools/common.c index aa11eccbee..0233f27437 100644 --- a/source4/lib/registry/tools/common.c +++ b/source4/lib/registry/tools/common.c @@ -1,4 +1,4 @@ -/* +/* Unix SMB/CIFS implementation. Popt routines specifically for registry @@ -8,12 +8,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 . */ @@ -23,22 +23,25 @@ #include "lib/registry/registry.h" #include "lib/registry/tools/common.h" -struct registry_context *reg_common_open_remote(const char *remote, struct cli_credentials *creds) +struct registry_context *reg_common_open_remote(const char *remote, + struct cli_credentials *creds) { struct registry_context *h; WERROR error; - + error = reg_open_remote(&h, NULL, creds, remote, NULL); if (!W_ERROR_IS_OK(error)) { - fprintf(stderr, "Unable to open remote registry at %s:%s \n", remote, win_errstr(error)); + fprintf(stderr, "Unable to open remote registry at %s:%s \n", + remote, win_errstr(error)); return NULL; } return h; } -struct registry_key *reg_common_open_file(const char *path, struct cli_credentials *creds) +struct registry_key *reg_common_open_file(const char *path, + struct cli_credentials *creds) { struct hive_key *hive_root; struct registry_context *h; @@ -47,13 +50,15 @@ struct registry_key *reg_common_open_file(const char *path, struct cli_credentia error = reg_open_hive(NULL, path, NULL, creds, &hive_root); if(!W_ERROR_IS_OK(error)) { - fprintf(stderr, "Unable to open '%s': %s \n", path, win_errstr(error)); + fprintf(stderr, "Unable to open '%s': %s \n", + path, win_errstr(error)); return NULL; } error = reg_open_local(NULL, &h, NULL, creds); if (!W_ERROR_IS_OK(error)) { - fprintf(stderr, "Unable to initialize local registry: %s\n", win_errstr(error)); + fprintf(stderr, "Unable to initialize local registry: %s\n", + win_errstr(error)); return NULL; } @@ -64,11 +69,12 @@ struct registry_context *reg_common_open_local(struct cli_credentials *creds) { WERROR error; struct registry_context *h; - + error = reg_open_samba(NULL, &h, NULL, creds); if(!W_ERROR_IS_OK(error)) { - fprintf(stderr, "Unable to open local registry:%s \n", win_errstr(error)); + fprintf(stderr, "Unable to open local registry:%s \n", + win_errstr(error)); return NULL; } -- cgit From 6c999cd12344f2bb8b1d2941210b4c205b3e0aad Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 2 Dec 2007 22:32:11 +0100 Subject: r26236: Remove more uses of global_loadparm or specify loadparm_context explicitly. (This used to be commit 5b29ef7c03d9ae76b0ca909e9f03a58e1bad3521) --- source4/lib/registry/tools/common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/tools/common.c') diff --git a/source4/lib/registry/tools/common.c b/source4/lib/registry/tools/common.c index 0233f27437..6d766fd25c 100644 --- a/source4/lib/registry/tools/common.c +++ b/source4/lib/registry/tools/common.c @@ -65,12 +65,12 @@ struct registry_key *reg_common_open_file(const char *path, return reg_import_hive_key(h, hive_root, -1, NULL); } -struct registry_context *reg_common_open_local(struct cli_credentials *creds) +struct registry_context *reg_common_open_local(struct cli_credentials *creds, struct loadparm_context *lp_ctx) { WERROR error; struct registry_context *h; - error = reg_open_samba(NULL, &h, NULL, creds); + error = reg_open_samba(NULL, &h, lp_ctx, NULL, creds); if(!W_ERROR_IS_OK(error)) { fprintf(stderr, "Unable to open local registry:%s \n", -- cgit From bca631be1f4cefeec3d64cd552ec6d9ee9cc1971 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 7 Dec 2007 03:01:41 +0100 Subject: r26329: Fix more loadparm_context references. Only about a 100 left now. (This used to be commit ddf233346d848e91bc6a6a572f0f6120540503b7) --- source4/lib/registry/tools/common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/common.c') diff --git a/source4/lib/registry/tools/common.c b/source4/lib/registry/tools/common.c index 6d766fd25c..c9293cd310 100644 --- a/source4/lib/registry/tools/common.c +++ b/source4/lib/registry/tools/common.c @@ -24,12 +24,13 @@ #include "lib/registry/tools/common.h" struct registry_context *reg_common_open_remote(const char *remote, + struct loadparm_context *lp_ctx, struct cli_credentials *creds) { struct registry_context *h; WERROR error; - error = reg_open_remote(&h, NULL, creds, remote, NULL); + error = reg_open_remote(&h, NULL, creds, lp_ctx, remote, NULL); if (!W_ERROR_IS_OK(error)) { fprintf(stderr, "Unable to open remote registry at %s:%s \n", -- cgit From 96a200511e884a88dcf48fa5b313b2cddb2df566 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 14 Dec 2007 00:27:31 +0100 Subject: r26443: Remove global_loadparm instances. (This used to be commit 8242c696235d1bfb402b5c276a57f36d93610545) --- source4/lib/registry/tools/common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/common.c') diff --git a/source4/lib/registry/tools/common.c b/source4/lib/registry/tools/common.c index c9293cd310..29e96475e6 100644 --- a/source4/lib/registry/tools/common.c +++ b/source4/lib/registry/tools/common.c @@ -42,13 +42,14 @@ struct registry_context *reg_common_open_remote(const char *remote, } struct registry_key *reg_common_open_file(const char *path, + struct loadparm_context *lp_ctx, struct cli_credentials *creds) { struct hive_key *hive_root; struct registry_context *h; WERROR error; - error = reg_open_hive(NULL, path, NULL, creds, &hive_root); + error = reg_open_hive(NULL, path, NULL, creds, lp_ctx, &hive_root); if(!W_ERROR_IS_OK(error)) { fprintf(stderr, "Unable to open '%s': %s \n", -- cgit From 7f8276b06d5000d12c0d64167853a033b924af32 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 7 Jan 2008 14:11:25 -0600 Subject: r26688: Fix listing remote predefined keys and subkeys. This fixes bug 3431. (This used to be commit 846876ad32dc86fe7c367db084e76c670c61b389) --- source4/lib/registry/tools/common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/registry/tools/common.c') diff --git a/source4/lib/registry/tools/common.c b/source4/lib/registry/tools/common.c index 29e96475e6..cec0f8b906 100644 --- a/source4/lib/registry/tools/common.c +++ b/source4/lib/registry/tools/common.c @@ -27,7 +27,7 @@ struct registry_context *reg_common_open_remote(const char *remote, struct loadparm_context *lp_ctx, struct cli_credentials *creds) { - struct registry_context *h; + struct registry_context *h = NULL; WERROR error; error = reg_open_remote(&h, NULL, creds, lp_ctx, remote, NULL); @@ -46,7 +46,7 @@ struct registry_key *reg_common_open_file(const char *path, struct cli_credentials *creds) { struct hive_key *hive_root; - struct registry_context *h; + struct registry_context *h = NULL; WERROR error; error = reg_open_hive(NULL, path, NULL, creds, lp_ctx, &hive_root); @@ -70,7 +70,7 @@ struct registry_key *reg_common_open_file(const char *path, struct registry_context *reg_common_open_local(struct cli_credentials *creds, struct loadparm_context *lp_ctx) { WERROR error; - struct registry_context *h; + struct registry_context *h = NULL; error = reg_open_samba(NULL, &h, lp_ctx, NULL, creds); -- 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/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/common.c') diff --git a/source4/lib/registry/tools/common.c b/source4/lib/registry/tools/common.c index cec0f8b906..52f3c6f551 100644 --- a/source4/lib/registry/tools/common.c +++ b/source4/lib/registry/tools/common.c @@ -57,7 +57,7 @@ struct registry_key *reg_common_open_file(const char *path, return NULL; } - error = reg_open_local(NULL, &h, NULL, creds); + error = reg_open_local(NULL, &h); if (!W_ERROR_IS_OK(error)) { fprintf(stderr, "Unable to initialize local registry: %s\n", win_errstr(error)); -- 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/common.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source4/lib/registry/tools/common.c') diff --git a/source4/lib/registry/tools/common.c b/source4/lib/registry/tools/common.c index 52f3c6f551..3ea780de60 100644 --- a/source4/lib/registry/tools/common.c +++ b/source4/lib/registry/tools/common.c @@ -42,6 +42,7 @@ struct registry_context *reg_common_open_remote(const char *remote, } struct registry_key *reg_common_open_file(const char *path, + struct event_context *ev_ctx, struct loadparm_context *lp_ctx, struct cli_credentials *creds) { @@ -49,7 +50,7 @@ struct registry_key *reg_common_open_file(const char *path, struct registry_context *h = NULL; WERROR error; - error = reg_open_hive(NULL, path, NULL, creds, lp_ctx, &hive_root); + error = reg_open_hive(NULL, path, NULL, creds, ev_ctx, lp_ctx, &hive_root); if(!W_ERROR_IS_OK(error)) { fprintf(stderr, "Unable to open '%s': %s \n", @@ -67,12 +68,14 @@ struct registry_key *reg_common_open_file(const char *path, return reg_import_hive_key(h, hive_root, -1, NULL); } -struct registry_context *reg_common_open_local(struct cli_credentials *creds, struct loadparm_context *lp_ctx) +struct registry_context *reg_common_open_local(struct cli_credentials *creds, + struct event_context *ev_ctx, + struct loadparm_context *lp_ctx) { WERROR error; struct registry_context *h = NULL; - error = reg_open_samba(NULL, &h, lp_ctx, NULL, creds); + error = reg_open_samba(NULL, &h, ev_ctx, lp_ctx, NULL, creds); if(!W_ERROR_IS_OK(error)) { fprintf(stderr, "Unable to open local registry:%s \n", -- cgit From 3911808323c964c36c2639f68d59d7aca1a2a96b Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Tue, 9 Sep 2008 18:03:54 +0200 Subject: Fix up the "reg_common_open_remote" call This fixes up the "reg_common_open_remote" call because it didn't work anymore without the event context. (This used to be commit 42ab865fc937a625d1eece45abe96bf354ddff8b) --- source4/lib/registry/tools/common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/registry/tools/common.c') diff --git a/source4/lib/registry/tools/common.c b/source4/lib/registry/tools/common.c index 3ea780de60..f770f6a3ca 100644 --- a/source4/lib/registry/tools/common.c +++ b/source4/lib/registry/tools/common.c @@ -24,13 +24,14 @@ #include "lib/registry/tools/common.h" struct registry_context *reg_common_open_remote(const char *remote, + struct event_context *ev_ctx, struct loadparm_context *lp_ctx, struct cli_credentials *creds) { struct registry_context *h = NULL; WERROR error; - error = reg_open_remote(&h, NULL, creds, lp_ctx, remote, NULL); + error = reg_open_remote(&h, NULL, creds, lp_ctx, remote, ev_ctx); if (!W_ERROR_IS_OK(error)) { fprintf(stderr, "Unable to open remote registry at %s:%s \n", -- cgit