summaryrefslogtreecommitdiff
path: root/source3/registry/reg_backend_db.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/registry/reg_backend_db.c')
-rw-r--r--source3/registry/reg_backend_db.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c
index e162fb587f..518078a062 100644
--- a/source3/registry/reg_backend_db.c
+++ b/source3/registry/reg_backend_db.c
@@ -258,8 +258,11 @@ bool regdb_init( void )
const char *vstring = "INFO/version";
uint32 vers_id;
- if ( tdb_reg )
+ if ( tdb_reg ) {
+ DEBUG(10,("regdb_init: incrementing refcount (%d)\n", tdb_refcount));
+ tdb_refcount++;
return true;
+ }
if ( !(tdb_reg = tdb_wrap_open(NULL, state_path("registry.tdb"), 0, REG_TDB_FLAGS, O_RDWR, 0600)) )
{
@@ -451,7 +454,8 @@ bool regdb_store_keys(const char *key, REGSUBKEY_CTR *ctr)
regdb_fetch_keys(key, old_subkeys);
- if (ctr->num_subkeys == old_subkeys->num_subkeys) {
+ if ((ctr->num_subkeys && old_subkeys->num_subkeys) &&
+ (ctr->num_subkeys == old_subkeys->num_subkeys)) {
for (i = 0; i<ctr->num_subkeys; i++) {
if (strcmp(ctr->subkeys[i],
@@ -547,6 +551,22 @@ bool regdb_store_keys(const char *key, REGSUBKEY_CTR *ctr)
/* now create records for any subkeys that don't already exist */
num_subkeys = regsubkey_ctr_numkeys(ctr);
+
+ if (num_subkeys == 0) {
+ if (!(subkeys = TALLOC_ZERO_P(ctr, REGSUBKEY_CTR)) ) {
+ DEBUG(0,("regdb_store_keys: talloc() failure!\n"));
+ goto fail;
+ }
+
+ if (!regdb_store_keys_internal(key, subkeys)) {
+ DEBUG(0,("regdb_store_keys: Failed to store "
+ "new record for key [%s]\n", key));
+ goto fail;
+ }
+ TALLOC_FREE(subkeys);
+
+ }
+
for (i=0; i<num_subkeys; i++) {
path = talloc_asprintf(ctx, "%s/%s",
key,