summaryrefslogtreecommitdiff
path: root/source3/registry
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-12-02 10:52:37 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:16:19 -0500
commit9690500e57596dcf41888626cbb8d31cfea24926 (patch)
tree30389d675774754f8c1c92bc73c0c07055d731ac /source3/registry
parent1a66ed34cd2d608b911c121bb512c050d2d59cd8 (diff)
downloadsamba-9690500e57596dcf41888626cbb8d31cfea24926.tar.gz
samba-9690500e57596dcf41888626cbb8d31cfea24926.tar.bz2
samba-9690500e57596dcf41888626cbb8d31cfea24926.zip
r20005: reg_open_path should become the replacement for regkey_open_internal.
(This used to be commit a6039eb46c6506b4e55e816d50edb618e800007f)
Diffstat (limited to 'source3/registry')
-rw-r--r--source3/registry/reg_frontend.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/source3/registry/reg_frontend.c b/source3/registry/reg_frontend.c
index aefd2b6f51..3bbbe79a32 100644
--- a/source3/registry/reg_frontend.c
+++ b/source3/registry/reg_frontend.c
@@ -490,3 +490,61 @@ WERROR regkey_set_secdesc(REGISTRY_KEY *key,
return WERR_ACCESS_DENIED;
}
+
+/*
+ * Utility function to open a complete registry path including the hive
+ * prefix. This should become the replacement function for
+ * regkey_open_internal.
+ */
+
+WERROR reg_open_path(TALLOC_CTX *mem_ctx, const char *orig_path,
+ uint32 desired_access, const struct nt_user_token *token,
+ struct registry_key **pkey)
+{
+ struct registry_key *hive, *key;
+ char *path, *p;
+ WERROR err;
+
+ if (!(path = SMB_STRDUP(orig_path))) {
+ return WERR_NOMEM;
+ }
+
+ p = strchr(path, '\\');
+
+ if ((p == NULL) || (p[1] == '\0')) {
+ /*
+ * No key behind the hive, just return the hive
+ */
+
+ err = reg_openhive(mem_ctx, path, desired_access, token,
+ &hive);
+ if (!W_ERROR_IS_OK(err)) {
+ SAFE_FREE(path);
+ return err;
+ }
+ *pkey = hive;
+ SAFE_FREE(path);
+ return WERR_OK;
+ }
+
+ *p = '\0';
+
+ err = reg_openhive(mem_ctx, path, SEC_RIGHTS_ENUM_SUBKEYS, token,
+ &hive);
+ if (!W_ERROR_IS_OK(err)) {
+ SAFE_FREE(path);
+ return err;
+ }
+
+ err = reg_openkey(mem_ctx, hive, p+1, desired_access, &key);
+
+ TALLOC_FREE(hive);
+ SAFE_FREE(path);
+
+ if (!W_ERROR_IS_OK(err)) {
+ return err;
+ }
+
+ *pkey = key;
+ return WERR_OK;
+}