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/samba.c | 85 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 source4/lib/registry/samba.c (limited to 'source4/lib/registry/samba.c') diff --git a/source4/lib/registry/samba.c b/source4/lib/registry/samba.c new file mode 100644 index 0000000000..244c467a2c --- /dev/null +++ b/source4/lib/registry/samba.c @@ -0,0 +1,85 @@ +/* + Unix SMB/CIFS implementation. + Copyright (C) Jelmer Vernooij 2004-2007. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "includes.h" +#include "registry.h" + +/** + * @file + * @brief Samba-specific registry functions + */ + +WERROR mount_samba_hive(struct registry_context *ctx, + struct auth_session_info *auth_info, + struct cli_credentials *creds, + const char *name, + uint32_t hive_id) +{ + WERROR error; + struct hive_key *hive; + const char *location; + + location = talloc_asprintf(ctx, "%s/%s.ldb", lp_private_dir(), name); + + error = reg_open_hive(ctx, location, auth_info, creds, &hive); + if (!W_ERROR_IS_OK(error)) + return error; + + return reg_mount_hive(ctx, hive, hive_id, NULL); +} + + +_PUBLIC_ WERROR reg_open_samba (TALLOC_CTX *mem_ctx, + struct registry_context **ctx, + struct auth_session_info *session_info, + struct cli_credentials *credentials) +{ + WERROR result; + + result = reg_open_local(mem_ctx, ctx, session_info, credentials); + if (!W_ERROR_IS_OK(result)) { + return result; + } + + mount_samba_hive(*ctx, session_info, credentials, + "hklm", HKEY_LOCAL_MACHINE); + + mount_samba_hive(*ctx, session_info, credentials, + "hkcr", HKEY_CLASSES_ROOT); + + /* FIXME: Should be mounted from NTUSER.DAT in the home directory of the + * current user */ + mount_samba_hive(*ctx, session_info, credentials, + "hkcu", HKEY_CURRENT_USER); + + mount_samba_hive(*ctx, session_info, credentials, + "hku", HKEY_USERS); + + /* FIXME: Different hive backend for HKEY_CLASSES_ROOT: merged view of HKEY_LOCAL_MACHINE\Software\Classes + * and HKEY_CURRENT_USER\Software\Classes */ + + /* FIXME: HKEY_CURRENT_CONFIG is an alias for HKEY_LOCAL_MACHINE\System\CurrentControlSet\Hardware Profiles\Current */ + + /* FIXME: HKEY_PERFORMANCE_DATA is dynamically generated */ + + /* FIXME: HKEY_LOCAL_MACHINE\Hardware is autogenerated */ + + /* FIXME: HKEY_LOCAL_MACHINE\Security\SAM is an alias for HKEY_LOCAL_MACHINE\SAM */ + + return WERR_OK; +} -- cgit From 2edf63b6d647eba131e213bd9dbc543100396930 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 27 Aug 2007 13:13:08 +0000 Subject: r24703: Use standard registry diff files when provisioning rather than LDIF files for the registry files. (This used to be commit 67ad556b7388e5d82756e0a3cfc596e44136329c) --- source4/lib/registry/samba.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/registry/samba.c') diff --git a/source4/lib/registry/samba.c b/source4/lib/registry/samba.c index 244c467a2c..6aaaa118d0 100644 --- a/source4/lib/registry/samba.c +++ b/source4/lib/registry/samba.c @@ -36,7 +36,12 @@ WERROR mount_samba_hive(struct registry_context *ctx, location = talloc_asprintf(ctx, "%s/%s.ldb", lp_private_dir(), name); + error = reg_open_hive(ctx, location, auth_info, creds, &hive); + + if (W_ERROR_EQUAL(error, WERR_NOT_FOUND)) + error = reg_open_ldb_file(ctx, location, auth_info, creds, &hive); + if (!W_ERROR_IS_OK(error)) return error; -- 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/samba.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/samba.c') diff --git a/source4/lib/registry/samba.c b/source4/lib/registry/samba.c index 6aaaa118d0..a5d6f76459 100644 --- a/source4/lib/registry/samba.c +++ b/source4/lib/registry/samba.c @@ -24,7 +24,7 @@ * @brief Samba-specific registry functions */ -WERROR mount_samba_hive(struct registry_context *ctx, +static WERROR mount_samba_hive(struct registry_context *ctx, struct auth_session_info *auth_info, struct cli_credentials *creds, const char *name, -- cgit From ffeee68e4b72dd94fee57366bd8d38b8c284c3d4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 12:42:09 +0000 Subject: r25026: Move param/param.h out of includes.h (This used to be commit abe8349f9b4387961ff3665d8c589d61cd2edf31) --- source4/lib/registry/samba.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/registry/samba.c') diff --git a/source4/lib/registry/samba.c b/source4/lib/registry/samba.c index a5d6f76459..dfb69abb33 100644 --- a/source4/lib/registry/samba.c +++ b/source4/lib/registry/samba.c @@ -18,6 +18,7 @@ #include "includes.h" #include "registry.h" +#include "param/param.h" /** * @file -- cgit From 37d53832a4623653f706e77985a79d84bd7c6694 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 28 Sep 2007 01:17:46 +0000 Subject: r25398: Parse loadparm context to all lp_*() functions. (This used to be commit 3fcc960839c6e5ca4de2c3c042f12f369ac5f238) --- source4/lib/registry/samba.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/samba.c') diff --git a/source4/lib/registry/samba.c b/source4/lib/registry/samba.c index dfb69abb33..48eb043306 100644 --- a/source4/lib/registry/samba.c +++ b/source4/lib/registry/samba.c @@ -35,7 +35,7 @@ static WERROR mount_samba_hive(struct registry_context *ctx, struct hive_key *hive; const char *location; - location = talloc_asprintf(ctx, "%s/%s.ldb", lp_private_dir(), name); + location = talloc_asprintf(ctx, "%s/%s.ldb", lp_private_dir(global_loadparm), name); error = reg_open_hive(ctx, location, auth_info, creds, &hive); -- cgit From 2f3551ca7cee59d4d053cceb87abdf1da1b3a1ad Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 1 Oct 2007 18:52:55 +0000 Subject: r25446: Merge some changes I made on the way home from SFO: 2007-09-29 More higher-level passing around of lp_ctx. 2007-09-29 Fix warning. 2007-09-29 Pass loadparm contexts on a higher level. 2007-09-29 Avoid using global loadparm context. (This used to be commit 3468952e771ab31f90b6c374ade01c5550810f42) --- source4/lib/registry/samba.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/lib/registry/samba.c') diff --git a/source4/lib/registry/samba.c b/source4/lib/registry/samba.c index 48eb043306..18bbcb8299 100644 --- a/source4/lib/registry/samba.c +++ b/source4/lib/registry/samba.c @@ -25,11 +25,11 @@ * @brief Samba-specific registry functions */ -static WERROR mount_samba_hive(struct registry_context *ctx, - struct auth_session_info *auth_info, - struct cli_credentials *creds, - const char *name, - uint32_t hive_id) +static WERROR mount_samba_hive(struct registry_context *ctx, + struct auth_session_info *auth_info, + struct cli_credentials *creds, + const char *name, + uint32_t hive_id) { WERROR error; struct hive_key *hive; -- cgit From cc8f4eb3cd9b3bc4e3f3d61bfad240147e8a4e5e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 6 Oct 2007 00:17:44 +0000 Subject: r25544: Cleanup some more indents in lib/registry. Guenther (This used to be commit 0d9826dc54057db2cfebcb806e5442c4dcf60daa) --- source4/lib/registry/samba.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'source4/lib/registry/samba.c') diff --git a/source4/lib/registry/samba.c b/source4/lib/registry/samba.c index 18bbcb8299..2397432f0b 100644 --- a/source4/lib/registry/samba.c +++ b/source4/lib/registry/samba.c @@ -1,4 +1,4 @@ -/* +/* Unix SMB/CIFS implementation. Copyright (C) Jelmer Vernooij 2004-2007. @@ -25,23 +25,25 @@ * @brief Samba-specific registry functions */ -static WERROR mount_samba_hive(struct registry_context *ctx, +static WERROR mount_samba_hive(struct registry_context *ctx, struct auth_session_info *auth_info, struct cli_credentials *creds, - const char *name, + const char *name, uint32_t hive_id) { WERROR error; struct hive_key *hive; const char *location; - location = talloc_asprintf(ctx, "%s/%s.ldb", lp_private_dir(global_loadparm), name); - + location = talloc_asprintf(ctx, "%s/%s.ldb", + lp_private_dir(global_loadparm), + name); error = reg_open_hive(ctx, location, auth_info, creds, &hive); if (W_ERROR_EQUAL(error, WERR_NOT_FOUND)) - error = reg_open_ldb_file(ctx, location, auth_info, creds, &hive); + error = reg_open_ldb_file(ctx, location, auth_info, + creds, &hive); if (!W_ERROR_IS_OK(error)) return error; @@ -50,10 +52,10 @@ static WERROR mount_samba_hive(struct registry_context *ctx, } -_PUBLIC_ WERROR reg_open_samba (TALLOC_CTX *mem_ctx, - struct registry_context **ctx, - struct auth_session_info *session_info, - struct cli_credentials *credentials) +_PUBLIC_ WERROR reg_open_samba(TALLOC_CTX *mem_ctx, + struct registry_context **ctx, + struct auth_session_info *session_info, + struct cli_credentials *credentials) { WERROR result; @@ -62,19 +64,19 @@ _PUBLIC_ WERROR reg_open_samba (TALLOC_CTX *mem_ctx, return result; } - mount_samba_hive(*ctx, session_info, credentials, - "hklm", HKEY_LOCAL_MACHINE); + mount_samba_hive(*ctx, session_info, credentials, + "hklm", HKEY_LOCAL_MACHINE); - mount_samba_hive(*ctx, session_info, credentials, - "hkcr", HKEY_CLASSES_ROOT); + mount_samba_hive(*ctx, session_info, credentials, + "hkcr", HKEY_CLASSES_ROOT); - /* FIXME: Should be mounted from NTUSER.DAT in the home directory of the + /* FIXME: Should be mounted from NTUSER.DAT in the home directory of the * current user */ - mount_samba_hive(*ctx, session_info, credentials, - "hkcu", HKEY_CURRENT_USER); + mount_samba_hive(*ctx, session_info, credentials, + "hkcu", HKEY_CURRENT_USER); - mount_samba_hive(*ctx, session_info, credentials, - "hku", HKEY_USERS); + mount_samba_hive(*ctx, session_info, credentials, + "hku", HKEY_USERS); /* FIXME: Different hive backend for HKEY_CLASSES_ROOT: merged view of HKEY_LOCAL_MACHINE\Software\Classes * and HKEY_CURRENT_USER\Software\Classes */ @@ -86,6 +88,6 @@ _PUBLIC_ WERROR reg_open_samba (TALLOC_CTX *mem_ctx, /* FIXME: HKEY_LOCAL_MACHINE\Hardware is autogenerated */ /* FIXME: HKEY_LOCAL_MACHINE\Security\SAM is an alias for HKEY_LOCAL_MACHINE\SAM */ - + return WERR_OK; } -- 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/samba.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source4/lib/registry/samba.c') diff --git a/source4/lib/registry/samba.c b/source4/lib/registry/samba.c index 2397432f0b..a5a60ba610 100644 --- a/source4/lib/registry/samba.c +++ b/source4/lib/registry/samba.c @@ -26,6 +26,7 @@ */ static WERROR mount_samba_hive(struct registry_context *ctx, + struct loadparm_context *lp_ctx, struct auth_session_info *auth_info, struct cli_credentials *creds, const char *name, @@ -36,7 +37,7 @@ static WERROR mount_samba_hive(struct registry_context *ctx, const char *location; location = talloc_asprintf(ctx, "%s/%s.ldb", - lp_private_dir(global_loadparm), + lp_private_dir(lp_ctx), name); error = reg_open_hive(ctx, location, auth_info, creds, &hive); @@ -54,6 +55,7 @@ static WERROR mount_samba_hive(struct registry_context *ctx, _PUBLIC_ WERROR reg_open_samba(TALLOC_CTX *mem_ctx, struct registry_context **ctx, + struct loadparm_context *lp_ctx, struct auth_session_info *session_info, struct cli_credentials *credentials) { @@ -64,18 +66,18 @@ _PUBLIC_ WERROR reg_open_samba(TALLOC_CTX *mem_ctx, return result; } - mount_samba_hive(*ctx, session_info, credentials, + mount_samba_hive(*ctx, lp_ctx, session_info, credentials, "hklm", HKEY_LOCAL_MACHINE); - mount_samba_hive(*ctx, session_info, credentials, + mount_samba_hive(*ctx, lp_ctx, session_info, credentials, "hkcr", HKEY_CLASSES_ROOT); /* FIXME: Should be mounted from NTUSER.DAT in the home directory of the * current user */ - mount_samba_hive(*ctx, session_info, credentials, + mount_samba_hive(*ctx, lp_ctx, session_info, credentials, "hkcu", HKEY_CURRENT_USER); - mount_samba_hive(*ctx, session_info, credentials, + mount_samba_hive(*ctx, lp_ctx, session_info, credentials, "hku", HKEY_USERS); /* FIXME: Different hive backend for HKEY_CLASSES_ROOT: merged view of HKEY_LOCAL_MACHINE\Software\Classes -- 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/samba.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry/samba.c') diff --git a/source4/lib/registry/samba.c b/source4/lib/registry/samba.c index a5a60ba610..02f3363bab 100644 --- a/source4/lib/registry/samba.c +++ b/source4/lib/registry/samba.c @@ -40,11 +40,11 @@ static WERROR mount_samba_hive(struct registry_context *ctx, lp_private_dir(lp_ctx), name); - error = reg_open_hive(ctx, location, auth_info, creds, &hive); + error = reg_open_hive(ctx, location, auth_info, creds, lp_ctx, &hive); if (W_ERROR_EQUAL(error, WERR_NOT_FOUND)) error = reg_open_ldb_file(ctx, location, auth_info, - creds, &hive); + creds, lp_ctx, &hive); if (!W_ERROR_IS_OK(error)) return error; -- cgit From b5ba4910120e5350e48927cc0f5f06742ee02eb8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 18 Jan 2008 03:00:00 +0100 Subject: registry: Avoid mapping registry return codes: return the right value in the first place. (This used to be commit 434e4857cec17d6d9e8983e151c170eed59fc6d1) --- source4/lib/registry/samba.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/samba.c') diff --git a/source4/lib/registry/samba.c b/source4/lib/registry/samba.c index 02f3363bab..599385e73c 100644 --- a/source4/lib/registry/samba.c +++ b/source4/lib/registry/samba.c @@ -42,7 +42,7 @@ static WERROR mount_samba_hive(struct registry_context *ctx, error = reg_open_hive(ctx, location, auth_info, creds, lp_ctx, &hive); - if (W_ERROR_EQUAL(error, WERR_NOT_FOUND)) + if (W_ERROR_EQUAL(error, WERR_BADFILE)) error = reg_open_ldb_file(ctx, location, auth_info, creds, lp_ctx, &hive); -- 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/samba.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/registry/samba.c') diff --git a/source4/lib/registry/samba.c b/source4/lib/registry/samba.c index 599385e73c..59693dde8e 100644 --- a/source4/lib/registry/samba.c +++ b/source4/lib/registry/samba.c @@ -61,7 +61,7 @@ _PUBLIC_ WERROR reg_open_samba(TALLOC_CTX *mem_ctx, { WERROR result; - result = reg_open_local(mem_ctx, ctx, session_info, credentials); + result = reg_open_local(mem_ctx, ctx); if (!W_ERROR_IS_OK(result)) { return result; } -- 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/samba.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'source4/lib/registry/samba.c') diff --git a/source4/lib/registry/samba.c b/source4/lib/registry/samba.c index 59693dde8e..84a8112f17 100644 --- a/source4/lib/registry/samba.c +++ b/source4/lib/registry/samba.c @@ -26,6 +26,7 @@ */ static WERROR mount_samba_hive(struct registry_context *ctx, + struct event_context *event_ctx, struct loadparm_context *lp_ctx, struct auth_session_info *auth_info, struct cli_credentials *creds, @@ -40,11 +41,11 @@ static WERROR mount_samba_hive(struct registry_context *ctx, lp_private_dir(lp_ctx), name); - error = reg_open_hive(ctx, location, auth_info, creds, lp_ctx, &hive); + error = reg_open_hive(ctx, location, auth_info, creds, event_ctx, lp_ctx, &hive); if (W_ERROR_EQUAL(error, WERR_BADFILE)) error = reg_open_ldb_file(ctx, location, auth_info, - creds, lp_ctx, &hive); + creds, event_ctx, lp_ctx, &hive); if (!W_ERROR_IS_OK(error)) return error; @@ -55,6 +56,7 @@ static WERROR mount_samba_hive(struct registry_context *ctx, _PUBLIC_ WERROR reg_open_samba(TALLOC_CTX *mem_ctx, struct registry_context **ctx, + struct event_context *ev_ctx, struct loadparm_context *lp_ctx, struct auth_session_info *session_info, struct cli_credentials *credentials) @@ -66,18 +68,18 @@ _PUBLIC_ WERROR reg_open_samba(TALLOC_CTX *mem_ctx, return result; } - mount_samba_hive(*ctx, lp_ctx, session_info, credentials, + mount_samba_hive(*ctx, ev_ctx, lp_ctx, session_info, credentials, "hklm", HKEY_LOCAL_MACHINE); - mount_samba_hive(*ctx, lp_ctx, session_info, credentials, + mount_samba_hive(*ctx, ev_ctx, lp_ctx, session_info, credentials, "hkcr", HKEY_CLASSES_ROOT); /* FIXME: Should be mounted from NTUSER.DAT in the home directory of the * current user */ - mount_samba_hive(*ctx, lp_ctx, session_info, credentials, + mount_samba_hive(*ctx, ev_ctx, lp_ctx, session_info, credentials, "hkcu", HKEY_CURRENT_USER); - mount_samba_hive(*ctx, lp_ctx, session_info, credentials, + mount_samba_hive(*ctx, ev_ctx, lp_ctx, session_info, credentials, "hku", HKEY_USERS); /* FIXME: Different hive backend for HKEY_CLASSES_ROOT: merged view of HKEY_LOCAL_MACHINE\Software\Classes -- cgit