From 2129d3c711a109b47c3c1596a6a639520d2f72d2 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 17 Jun 2005 15:35:31 +0000 Subject: r7691: * add .gdbinit to the svn:ignore files * start adding write support to the Samba registry Flesh out the server implementations of RegCreateKey(), RegSetValue(), RegDeleteKey() and RegDeleteValue() I can create a new key using regedit.exe now but the 'New Key #1' key cannot be deleted yet. (This used to be commit e188fdbef8f0ad202b0ecf3c30be2941ebe6d5b1) --- source3/registry/reg_db.c | 44 +++++++++++++++++++++++++++++++++++++---- source3/registry/reg_frontend.c | 2 -- source3/registry/reg_objects.c | 10 ++++++---- 3 files changed, 46 insertions(+), 10 deletions(-) (limited to 'source3/registry') 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; @@ -236,6 +234,44 @@ done: return ret; } +/*********************************************************************** + 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; iname)); - 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); } /*********************************************************************** -- cgit