r23581: Move regkey_open_onelevel from reg_frontend to reg_api,
authorMichael Adam <obnox@samba.org>
Fri, 22 Jun 2007 11:03:48 +0000 (11:03 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:23:32 +0000 (12:23 -0500)
where it actually belongs, and make it static.

Michael

source/registry/reg_api.c
source/registry/reg_frontend_hilvl.c

index e163759dabcf6e371cde00abe2c25a266e36bf03..4fbf54e75376bc65df97c1a219645ca2f7aaddd1 100644 (file)
@@ -57,6 +57,116 @@ static WERROR fill_subkey_cache(struct registry_key *key)
        return WERR_OK;
 }
 
+static int regkey_destructor(REGISTRY_KEY *key)
+{
+       return regdb_close();
+}
+
+static WERROR regkey_open_onelevel(TALLOC_CTX *mem_ctx, 
+                                  struct registry_key *parent,
+                                  const char *name,
+                                  const struct nt_user_token *token,
+                                  uint32 access_desired,
+                                  struct registry_key **pregkey)
+{
+       WERROR          result = WERR_OK;
+       struct registry_key *regkey;
+       REGISTRY_KEY *key;
+       REGSUBKEY_CTR   *subkeys = NULL;
+
+       DEBUG(7,("regkey_open_onelevel: name = [%s]\n", name));
+
+       SMB_ASSERT(strchr(name, '\\') == NULL);
+
+       if (!(regkey = TALLOC_ZERO_P(mem_ctx, struct registry_key)) ||
+           !(regkey->token = dup_nt_token(regkey, token)) ||
+           !(regkey->key = TALLOC_ZERO_P(regkey, REGISTRY_KEY))) {
+               result = WERR_NOMEM;
+               goto done;
+       }
+
+       if ( !(W_ERROR_IS_OK(result = regdb_open())) ) {
+               goto done;
+       }
+
+       key = regkey->key;
+       talloc_set_destructor(key, regkey_destructor);
+               
+       /* initialization */
+       
+       key->type = REG_KEY_GENERIC;
+
+       if (name[0] == '\0') {
+               /*
+                * Open a copy of the parent key
+                */
+               if (!parent) {
+                       result = WERR_BADFILE;
+                       goto done;
+               }
+               key->name = talloc_strdup(key, parent->key->name);
+       }
+       else {
+               /*
+                * Normal subkey open
+                */
+               key->name = talloc_asprintf(key, "%s%s%s",
+                                           parent ? parent->key->name : "",
+                                           parent ? "\\": "",
+                                           name);
+       }
+
+       if (key->name == NULL) {
+               result = WERR_NOMEM;
+               goto done;
+       }
+
+       /* Tag this as a Performance Counter Key */
+
+       if( StrnCaseCmp(key->name, KEY_HKPD, strlen(KEY_HKPD)) == 0 )
+               key->type = REG_KEY_HKPD;
+       
+       /* Look up the table of registry I/O operations */
+
+       if ( !(key->hook = reghook_cache_find( key->name )) ) {
+               DEBUG(0,("reg_open_onelevel: Failed to assigned a "
+                        "REGISTRY_HOOK to [%s]\n", key->name ));
+               result = WERR_BADFILE;
+               goto done;
+       }
+       
+       /* check if the path really exists; failed is indicated by -1 */
+       /* if the subkey count failed, bail out */
+
+       if ( !(subkeys = TALLOC_ZERO_P( key, REGSUBKEY_CTR )) ) {
+               result = WERR_NOMEM;
+               goto done;
+       }
+
+       if ( fetch_reg_keys( key, subkeys ) == -1 )  {
+               result = WERR_BADFILE;
+               goto done;
+       }
+       
+       TALLOC_FREE( subkeys );
+
+       if ( !regkey_access_check( key, access_desired, &key->access_granted,
+                                  token ) ) {
+               result = WERR_ACCESS_DENIED;
+               goto done;
+       }
+
+       *pregkey = regkey;
+       result = WERR_OK;
+       
+done:
+       if ( !W_ERROR_IS_OK(result) ) {
+               TALLOC_FREE(regkey);
+       }
+
+       return result;
+}
+
 WERROR reg_openhive(TALLOC_CTX *mem_ctx, const char *hive,
                    uint32 desired_access,
                    const struct nt_user_token *token,
@@ -567,5 +677,3 @@ WERROR reg_open_path(TALLOC_CTX *mem_ctx, const char *orig_path,
        *pkey = key;
        return WERR_OK;
 }
-
-/* END */
index 72441535b5025ad08859ba3e91bfacfb14d6e66c..4c0ed0cc72ef0e033319d694fddc49e0bf2508c2 100644 (file)
@@ -176,118 +176,6 @@ BOOL regkey_access_check( REGISTRY_KEY *key, uint32 requested, uint32 *granted,
        return NT_STATUS_IS_OK(status);
 }
 
-/***********************************************************************
-***********************************************************************/
-
-static int regkey_destructor(REGISTRY_KEY *key)
-{
-       return regdb_close();
-}
-
-WERROR regkey_open_onelevel( TALLOC_CTX *mem_ctx, struct registry_key *parent,
-                            const char *name,
-                            const struct nt_user_token *token,
-                            uint32 access_desired,
-                            struct registry_key **pregkey)
-{
-       WERROR          result = WERR_OK;
-       struct registry_key *regkey;
-       REGISTRY_KEY *key;
-       REGSUBKEY_CTR   *subkeys = NULL;
-
-       DEBUG(7,("regkey_open_onelevel: name = [%s]\n", name));
-
-       SMB_ASSERT(strchr(name, '\\') == NULL);
-
-       if (!(regkey = TALLOC_ZERO_P(mem_ctx, struct registry_key)) ||
-           !(regkey->token = dup_nt_token(regkey, token)) ||
-           !(regkey->key = TALLOC_ZERO_P(regkey, REGISTRY_KEY))) {
-               result = WERR_NOMEM;
-               goto done;
-       }
-
-       if ( !(W_ERROR_IS_OK(result = regdb_open())) ) {
-               goto done;
-       }
-
-       key = regkey->key;
-       talloc_set_destructor(key, regkey_destructor);
-               
-       /* initialization */
-       
-       key->type = REG_KEY_GENERIC;
-
-       if (name[0] == '\0') {
-               /*
-                * Open a copy of the parent key
-                */
-               if (!parent) {
-                       result = WERR_BADFILE;
-                       goto done;
-               }
-               key->name = talloc_strdup(key, parent->key->name);
-       }
-       else {
-               /*
-                * Normal subkey open
-                */
-               key->name = talloc_asprintf(key, "%s%s%s",
-                                           parent ? parent->key->name : "",
-                                           parent ? "\\": "",
-                                           name);
-       }
-
-       if (key->name == NULL) {
-               result = WERR_NOMEM;
-               goto done;
-       }
-
-       /* Tag this as a Performance Counter Key */
-
-       if( StrnCaseCmp(key->name, KEY_HKPD, strlen(KEY_HKPD)) == 0 )
-               key->type = REG_KEY_HKPD;
-       
-       /* Look up the table of registry I/O operations */
-
-       if ( !(key->hook = reghook_cache_find( key->name )) ) {
-               DEBUG(0,("reg_open_onelevel: Failed to assigned a "
-                        "REGISTRY_HOOK to [%s]\n", key->name ));
-               result = WERR_BADFILE;
-               goto done;
-       }
-       
-       /* check if the path really exists; failed is indicated by -1 */
-       /* if the subkey count failed, bail out */
-
-       if ( !(subkeys = TALLOC_ZERO_P( key, REGSUBKEY_CTR )) ) {
-               result = WERR_NOMEM;
-               goto done;
-       }
-
-       if ( fetch_reg_keys( key, subkeys ) == -1 )  {
-               result = WERR_BADFILE;
-               goto done;
-       }
-       
-       TALLOC_FREE( subkeys );
-
-       if ( !regkey_access_check( key, access_desired, &key->access_granted,
-                                  token ) ) {
-               result = WERR_ACCESS_DENIED;
-               goto done;
-       }
-
-       *pregkey = regkey;
-       result = WERR_OK;
-       
-done:
-       if ( !W_ERROR_IS_OK(result) ) {
-               TALLOC_FREE(regkey);
-       }
-
-       return result;
-}
-
 WERROR regkey_get_secdesc(TALLOC_CTX *mem_ctx, REGISTRY_KEY *key,
                          struct security_descriptor **psecdesc)
 {
@@ -310,6 +198,3 @@ WERROR regkey_get_secdesc(TALLOC_CTX *mem_ctx, REGISTRY_KEY *key,
        *psecdesc = secdesc;
        return WERR_OK;
 }
-
-
-/* END */