Move reg_create_path() and reg_delete_path() to reg_api.c
authorMichael Adam <obnox@samba.org>
Thu, 17 Jan 2008 09:19:12 +0000 (10:19 +0100)
committerMichael Adam <obnox@samba.org>
Thu, 17 Jan 2008 15:25:11 +0000 (16:25 +0100)
Michael
(This used to be commit 4d82cc586c089a16d1d2db214f5e198062890b58)

source3/registry/reg_api.c
source3/registry/reg_frontend.c

index 744e5eb6e307ae4ad06de62acfb7da13c72f35f8..83c5f1a634c6bed6ce993dce5178ada81a2613ba 100644 (file)
@@ -794,3 +794,98 @@ WERROR reg_deletesubkeys_recursive(TALLOC_CTX *ctx,
 {
        return reg_deletekey_recursive_internal(ctx, parent, path, false);
 }
+
+/*
+ * Utility function to create a registry key without opening the hive
+ * before. Assumes the hive already exists.
+ */
+
+WERROR reg_create_path(TALLOC_CTX *mem_ctx, const char *orig_path,
+                      uint32 desired_access,
+                      const struct nt_user_token *token,
+                      enum winreg_CreateAction *paction,
+                      struct registry_key **pkey)
+{
+       struct registry_key *hive;
+       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;
+               }
+               SAFE_FREE(path);
+               *pkey = hive;
+               *paction = REG_OPENED_EXISTING_KEY;
+               return WERR_OK;
+       }
+
+       *p = '\0';
+
+       err = reg_openhive(mem_ctx, path,
+                          (strchr(p+1, '\\') != NULL) ?
+                          SEC_RIGHTS_ENUM_SUBKEYS : SEC_RIGHTS_CREATE_SUBKEY,
+                          token, &hive);
+       if (!W_ERROR_IS_OK(err)) {
+               SAFE_FREE(path);
+               return err;
+       }
+
+       err = reg_createkey(mem_ctx, hive, p+1, desired_access, pkey, paction);
+       SAFE_FREE(path);
+       TALLOC_FREE(hive);
+       return err;
+}
+
+/*
+ * Utility function to create a registry key without opening the hive
+ * before. Will not delete a hive.
+ */
+
+WERROR reg_delete_path(const struct nt_user_token *token,
+                      const char *orig_path)
+{
+       struct registry_key *hive;
+       char *path, *p;
+       WERROR err;
+
+       if (!(path = SMB_STRDUP(orig_path))) {
+               return WERR_NOMEM;
+       }
+
+       p = strchr(path, '\\');
+
+       if ((p == NULL) || (p[1] == '\0')) {
+               SAFE_FREE(path);
+               return WERR_INVALID_PARAM;
+       }
+
+       *p = '\0';
+
+       err = reg_openhive(NULL, path,
+                          (strchr(p+1, '\\') != NULL) ?
+                          SEC_RIGHTS_ENUM_SUBKEYS : SEC_RIGHTS_CREATE_SUBKEY,
+                          token, &hive);
+       if (!W_ERROR_IS_OK(err)) {
+               SAFE_FREE(path);
+               return err;
+       }
+
+       err = reg_deletekey(hive, p+1);
+       SAFE_FREE(path);
+       TALLOC_FREE(hive);
+       return err;
+}
index 40d9192b08b321407829cb7053f8a6637ba15695..9e84d3a8c41e7f45d50f56291c794ff4ae4f527d 100644 (file)
@@ -105,98 +105,3 @@ WERROR regkey_open_internal( TALLOC_CTX *ctx, REGISTRY_KEY **regkey,
        TALLOC_FREE(key);
        return WERR_OK;
 }
-
-/*
- * Utility function to create a registry key without opening the hive
- * before. Assumes the hive already exists.
- */
-
-WERROR reg_create_path(TALLOC_CTX *mem_ctx, const char *orig_path,
-                      uint32 desired_access,
-                      const struct nt_user_token *token,
-                      enum winreg_CreateAction *paction,
-                      struct registry_key **pkey)
-{
-       struct registry_key *hive;
-       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;
-               }
-               SAFE_FREE(path);
-               *pkey = hive;
-               *paction = REG_OPENED_EXISTING_KEY;
-               return WERR_OK;
-       }
-
-       *p = '\0';
-
-       err = reg_openhive(mem_ctx, path,
-                          (strchr(p+1, '\\') != NULL) ?
-                          SEC_RIGHTS_ENUM_SUBKEYS : SEC_RIGHTS_CREATE_SUBKEY,
-                          token, &hive);
-       if (!W_ERROR_IS_OK(err)) {
-               SAFE_FREE(path);
-               return err;
-       }
-
-       err = reg_createkey(mem_ctx, hive, p+1, desired_access, pkey, paction);
-       SAFE_FREE(path);
-       TALLOC_FREE(hive);
-       return err;
-}
-
-/*
- * Utility function to create a registry key without opening the hive
- * before. Will not delete a hive.
- */
-
-WERROR reg_delete_path(const struct nt_user_token *token,
-                      const char *orig_path)
-{
-       struct registry_key *hive;
-       char *path, *p;
-       WERROR err;
-
-       if (!(path = SMB_STRDUP(orig_path))) {
-               return WERR_NOMEM;
-       }
-
-       p = strchr(path, '\\');
-
-       if ((p == NULL) || (p[1] == '\0')) {
-               SAFE_FREE(path);
-               return WERR_INVALID_PARAM;
-       }
-
-       *p = '\0';
-
-       err = reg_openhive(NULL, path,
-                          (strchr(p+1, '\\') != NULL) ?
-                          SEC_RIGHTS_ENUM_SUBKEYS : SEC_RIGHTS_CREATE_SUBKEY,
-                          token, &hive);
-       if (!W_ERROR_IS_OK(err)) {
-               SAFE_FREE(path);
-               return err;
-       }
-
-       err = reg_deletekey(hive, p+1);
-       SAFE_FREE(path);
-       TALLOC_FREE(hive);
-       return err;
-}