diff options
Diffstat (limited to 'source3/registry')
-rw-r--r-- | source3/registry/reg_db.c | 44 | ||||
-rw-r--r-- | source3/registry/reg_frontend.c | 2 | ||||
-rw-r--r-- | source3/registry/reg_objects.c | 10 |
3 files changed, 46 insertions, 10 deletions
diff --git a/source3/registry/reg_db.c b/source3/registry/reg_db.c index 7efa032e39..a459aa5f5f 100644 --- a/source3/registry/reg_db.c +++ b/source3/registry/reg_db.c @@ -68,8 +68,6 @@ static BOOL init_registry_data( void ) int i; const char *p, *p2; - ZERO_STRUCTP( &subkeys ); - /* loop over all of the predefined paths and add each component */ for ( i=0; builtin_registry_paths[i] != NULL; i++ ) { @@ -168,10 +166,10 @@ BOOL init_registry_db( void ) The full path to the registry key is used as database after the \'s are converted to /'s. Key string is also normalized to UPPER - case. + case. ***********************************************************************/ -static BOOL regdb_store_reg_keys( char *key, REGSUBKEY_CTR *ctr ) +static BOOL regdb_store_reg_keys_internal( char *key, REGSUBKEY_CTR *ctr ) { TDB_DATA kbuf, dbuf; char *buffer, *tmpbuf; @@ -237,6 +235,44 @@ done: } /*********************************************************************** + Store the new subkey record and create any child key records that + do not currently exist + ***********************************************************************/ + +static BOOL regdb_store_reg_keys( char *key, REGSUBKEY_CTR *ctr ) +{ + int num_subkeys, i; + pstring path; + REGSUBKEY_CTR subkeys; + + /* store the subkey list for the parent */ + + if ( !regdb_store_reg_keys_internal( key, ctr ) ) { + DEBUG(0,("regdb_store_reg_keys: Failed to store new subkey list for parent [%s}\n", key )); + return False; + } + + /* now create records for any subkeys that don't already exist */ + + num_subkeys = regsubkey_ctr_numkeys( ctr ); + for ( i=0; i<num_subkeys; i++ ) { + pstr_sprintf( path, "%s%c%s", key, '/', regsubkey_ctr_specific_key( ctr, i ) ); + regsubkey_ctr_init( &subkeys ); + if ( regdb_fetch_reg_keys( path, &subkeys ) == -1 ) { + /* create a record with 0 subkeys */ + if ( !regdb_store_reg_keys_internal( path, &subkeys ) ) { + DEBUG(0,("regdb_store_reg_keys: Failed to store new record for key [%s}\n", path )); + return False; + } + } + regsubkey_ctr_destroy( &subkeys ); + } + + return True; +} + + +/*********************************************************************** Retrieve an array of strings containing subkeys. Memory should be released by the caller. The subkeys are stored in a catenated string of null terminated character strings diff --git a/source3/registry/reg_frontend.c b/source3/registry/reg_frontend.c index ab8a02812f..9c7420ef86 100644 --- a/source3/registry/reg_frontend.c +++ b/source3/registry/reg_frontend.c @@ -134,7 +134,6 @@ BOOL fetch_reg_keys_specific( REGISTRY_KEY *key, char** subkey, uint32 key_index if ( !ctr_init ) { DEBUG(8,("fetch_reg_keys_specific: Initializing cache of subkeys for [%s]\n", key->name)); - ZERO_STRUCTP( &ctr ); regsubkey_ctr_init( &ctr ); pstrcpy( save_path, key->name ); @@ -202,7 +201,6 @@ BOOL fetch_reg_values_specific( REGISTRY_KEY *key, REGISTRY_VALUE **val, uint32 if ( !ctr_init ) { DEBUG(8,("fetch_reg_values_specific: Initializing cache of values for [%s]\n", key->name)); - ZERO_STRUCTP( &ctr ); regval_ctr_init( &ctr ); pstrcpy( save_path, key->name ); diff --git a/source3/registry/reg_objects.c b/source3/registry/reg_objects.c index add82ae0d4..2dd61f515f 100644 --- a/source3/registry/reg_objects.c +++ b/source3/registry/reg_objects.c @@ -28,12 +28,13 @@ /*********************************************************************** Init the talloc context held by a REGSUBKEY_CTR structure + This now zero's the structure **********************************************************************/ void regsubkey_ctr_init( REGSUBKEY_CTR *ctr ) { - if ( !ctr->ctx ) - ctr->ctx = talloc_init("regsubkey_ctr_init for ctr %p", ctr); + ZERO_STRUCTP( ctr ); + ctr->ctx = talloc_init("regsubkey_ctr_init for ctr %p", ctr); } /*********************************************************************** @@ -117,12 +118,13 @@ void regsubkey_ctr_destroy( REGSUBKEY_CTR *ctr ) /*********************************************************************** Init the talloc context held by a REGSUBKEY_CTR structure + This now zero's the structure **********************************************************************/ void regval_ctr_init( REGVAL_CTR *ctr ) { - if ( ctr && !ctr->ctx ) - ctr->ctx = talloc_init("regval_ctr_init for ctr %p", ctr); + ZERO_STRUCTP( ctr ); + ctr->ctx = talloc_init("regval_ctr_init for ctr %p", ctr); } /*********************************************************************** |