s3-talloc Change TALLOC_ARRAY() to talloc_array()
[samba.git] / source3 / registry / reg_backend_db.c
index 43963db3c29a26d451b73141f56f73157fd655b6..05f3a5a0ab7c1f014da1e563be08bb1d34c2d986 100644 (file)
 /* Implementation of internal registry database functions. */
 
 #include "includes.h"
+#include "system/filesys.h"
+#include "registry.h"
+#include "reg_db.h"
+#include "reg_util_internal.h"
+#include "reg_backend_db.h"
+#include "reg_objects.h"
+#include "nt_printing.h"
+#include "util_tdb.h"
+#include "dbwrap.h"
+#include "../libcli/security/secdesc.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_REGISTRY
@@ -39,6 +49,8 @@ static int regdb_fetch_values_internal(struct db_context *db, const char* key,
 static bool regdb_store_values_internal(struct db_context *db, const char *key,
                                        struct regval_ctr *values);
 
+static NTSTATUS create_sorted_subkeys(const char *key);
+
 /* List the deepest path into the registry.  All part components will be created.*/
 
 /* If you want to have a part of the path controlled by the tdb and part by
@@ -53,6 +65,9 @@ static const char *builtin_registry_paths[] = {
        KEY_PRINTING_2K,
        KEY_PRINTING_PORTS,
        KEY_PRINTING,
+       KEY_PRINTING "\\Forms",
+       KEY_PRINTING "\\Printers",
+       KEY_PRINTING "\\Environments\\Windows NT x86\\Print Processors\\winprint",
        KEY_SHARES,
        KEY_EVENTLOG,
        KEY_SMBCONF,
@@ -65,7 +80,7 @@ static const char *builtin_registry_paths[] = {
        KEY_HKCU,
        KEY_GP_USER_POLICY,
        KEY_GP_USER_WIN_POLICY,
-       KEY_WINLOGON_GPEXT_PATH,
+       "HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\GPExtensions",
        "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Print\\Monitors",
        KEY_PROD_OPTIONS,
        "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Terminal Server\\DefaultUserConfiguration",
@@ -93,7 +108,7 @@ static struct builtin_regkey_value builtin_registry_values[] = {
        { KEY_PRINTING_2K,
                "DefaultSpoolDirectory", REG_SZ, { "C:\\Windows\\System32\\Spool\\Printers" } },
        { KEY_EVENTLOG,
-               "DisplayName", REG_SZ, { "Event Log" } }, 
+               "DisplayName", REG_SZ, { "Event Log" } },
        { KEY_EVENTLOG,
                "ErrorControl", REG_DWORD, { (char*)0x00000001 } },
        { NULL, NULL, 0, { NULL } }
@@ -253,7 +268,7 @@ static void regdb_ctr_add_value(struct regval_ctr *ctr,
        switch(value->type) {
        case REG_DWORD:
                regval_ctr_addvalue(ctr, value->valuename, REG_DWORD,
-                                   (char*)&value->data.dw_value,
+                                   (uint8_t *)&value->data.dw_value,
                                    sizeof(uint32));
                break;
 
@@ -292,10 +307,11 @@ static NTSTATUS init_registry_data_action(struct db_context *db,
        /* loop over all of the predefined values and add each component */
 
        for (i=0; builtin_registry_values[i].path != NULL; i++) {
+               WERROR werr;
 
-               values = TALLOC_ZERO_P(frame, struct regval_ctr);
-               if (values == NULL) {
-                       status = NT_STATUS_NO_MEMORY;
+               werr = regval_ctr_init(frame, &values);
+               if (!W_ERROR_IS_OK(werr)) {
+                       status = werror_to_ntstatus(werr);
                        goto done;
                }
 
@@ -343,11 +359,8 @@ WERROR init_registry_data(void)
        }
 
        for (i=0; builtin_registry_values[i].path != NULL; i++) {
-               values = TALLOC_ZERO_P(frame, struct regval_ctr);
-               if (values == NULL) {
-                       werr = WERR_NOMEM;
-                       goto done;
-               }
+               werr = regval_ctr_init(frame, &values);
+               W_ERROR_NOT_OK_GOTO_DONE(werr);
 
                regdb_fetch_values_internal(regdb,
                                            builtin_registry_values[i].path,
@@ -384,19 +397,112 @@ done:
        return werr;
 }
 
+static int regdb_normalize_keynames_fn(struct db_record *rec,
+                                      void *private_data)
+{
+       TALLOC_CTX *mem_ctx = talloc_tos();
+       const char *keyname;
+       NTSTATUS status;
+
+       if (rec->key.dptr == NULL || rec->key.dsize == 0) {
+               return 0;
+       }
+
+       keyname = strchr((const char *) rec->key.dptr, '/');
+       if (keyname) {
+               struct db_record new_rec;
+
+               keyname = talloc_string_sub(mem_ctx,
+                                           (const char *) rec->key.dptr,
+                                           "/",
+                                           "\\");
+
+               DEBUG(2, ("regdb_normalize_keynames_fn: Convert %s to %s\n",
+                         (const char *) rec->key.dptr,
+                         keyname));
+
+               new_rec.value = rec->value;
+               new_rec.key = string_term_tdb_data(keyname);
+               new_rec.private_data = rec->private_data;
+
+               /* Delete the original record and store the normalized key */
+               status = rec->delete_rec(rec);
+               if (!NT_STATUS_IS_OK(status)) {
+                       DEBUG(0,("regdb_normalize_keynames_fn: "
+                                "tdb_delete for [%s] failed!\n",
+                                rec->key.dptr));
+                       return 1;
+               }
+
+               status = rec->store(&new_rec, new_rec.value, TDB_REPLACE);
+               if (!NT_STATUS_IS_OK(status)) {
+                       DEBUG(0,("regdb_normalize_keynames_fn: "
+                                "failed to store new record for [%s]!\n",
+                                keyname));
+                       return 1;
+               }
+       }
+
+       return 0;
+}
+
+static WERROR regdb_store_regdb_version(uint32_t version)
+{
+       NTSTATUS status;
+       const char *version_keyname = "INFO/version";
+
+       if (!regdb) {
+               return WERR_CAN_NOT_COMPLETE;
+       }
+
+       status = dbwrap_trans_store_int32(regdb, version_keyname, version);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(1, ("regdb_store_regdb_version: error storing %s = %d: %s\n",
+                         version_keyname, version, nt_errstr(status)));
+               return ntstatus_to_werror(status);
+       } else {
+               DEBUG(10, ("regdb_store_regdb_version: stored %s = %d\n",
+                         version_keyname, version));
+               return WERR_OK;
+       }
+}
+
+static WERROR regdb_upgrade_v1_to_v2(void)
+{
+       TALLOC_CTX *mem_ctx;
+       int rc;
+       WERROR werr;
+
+       mem_ctx = talloc_stackframe();
+       if (mem_ctx == NULL) {
+               return WERR_NOMEM;
+       }
+
+       rc = regdb->traverse(regdb, regdb_normalize_keynames_fn, mem_ctx);
+
+       talloc_destroy(mem_ctx);
+
+       if (rc == -1) {
+               return WERR_REG_IO_FAILURE;
+       }
+
+       werr = regdb_store_regdb_version(REGVER_V2);
+       return werr;
+}
+
 /***********************************************************************
  Open the registry database
  ***********************************************************************/
+
 WERROR regdb_init(void)
 {
        const char *vstring = "INFO/version";
-       uint32 vers_id;
+       uint32 vers_id, expected_version;
        WERROR werr;
 
        if (regdb) {
-               DEBUG(10, ("regdb_init: incrementing refcount (%d)\n",
-                         regdb_refcount));
+               DEBUG(10, ("regdb_init: incrementing refcount (%d->%d)\n",
+                          regdb_refcount, regdb_refcount+1));
                regdb_refcount++;
                return WERR_OK;
        }
@@ -412,30 +518,56 @@ WERROR regdb_init(void)
                                state_path("registry.tdb"), strerror(errno) ));
                        return werr;
                }
-               
+
                DEBUG(10,("regdb_init: Successfully created registry tdb\n"));
        }
 
        regdb_refcount = 1;
+       DEBUG(10, ("regdb_init: registry db openend. refcount reset (%d)\n",
+                  regdb_refcount));
+
+       expected_version = REGVER_V2;
 
        vers_id = dbwrap_fetch_int32(regdb, vstring);
+       if (vers_id == -1) {
+               DEBUG(10, ("regdb_init: registry version uninitialized "
+                          "(got %d), initializing to version %d\n",
+                          vers_id, expected_version));
 
-       if ( vers_id != REGVER_V1 ) {
-               NTSTATUS status;
-               /* any upgrade code here if needed */
-               DEBUG(10, ("regdb_init: got %s = %d != %d\n", vstring,
-                          vers_id, REGVER_V1));
-               status = dbwrap_trans_store_int32(regdb, vstring, REGVER_V1);
-               if (!NT_STATUS_IS_OK(status)) {
-                       DEBUG(1, ("regdb_init: error storing %s = %d: %s\n",
-                                 vstring, REGVER_V1, nt_errstr(status)));
-                       return ntstatus_to_werror(status);
-               } else {
-                       DEBUG(10, ("regdb_init: stored %s = %d\n",
-                                 vstring, REGVER_V1));
+               werr = regdb_store_regdb_version(expected_version);
+               return werr;
+       }
+
+       if (vers_id > expected_version || vers_id == 0) {
+               DEBUG(1, ("regdb_init: unknown registry version %d "
+                         "(code version = %d), refusing initialization\n",
+                         vers_id, expected_version));
+               return WERR_CAN_NOT_COMPLETE;
+       }
+
+       if (vers_id == REGVER_V1) {
+               DEBUG(10, ("regdb_init: got registry db version %d, upgrading "
+                          "to version %d\n", REGVER_V1, REGVER_V2));
+
+               if (regdb->transaction_start(regdb) != 0) {
+                       return WERR_REG_IO_FAILURE;
+               }
+
+               werr = regdb_upgrade_v1_to_v2();
+               if (!W_ERROR_IS_OK(werr)) {
+                       regdb->transaction_cancel(regdb);
+                       return werr;
+               }
+
+               if (regdb->transaction_commit(regdb) != 0) {
+                       return WERR_REG_IO_FAILURE;
                }
+
+               vers_id = REGVER_V2;
        }
 
+       /* future upgrade code should go here */
+
        return WERR_OK;
 }
 
@@ -448,25 +580,27 @@ WERROR regdb_open( void )
        WERROR result = WERR_OK;
 
        if ( regdb ) {
-               DEBUG(10,("regdb_open: incrementing refcount (%d)\n", regdb_refcount));
+               DEBUG(10, ("regdb_open: incrementing refcount (%d->%d)\n",
+                          regdb_refcount, regdb_refcount+1));
                regdb_refcount++;
                return WERR_OK;
        }
-       
+
        become_root();
 
        regdb = db_open(NULL, state_path("registry.tdb"), 0,
                              REG_TDB_FLAGS, O_RDWR, 0600);
        if ( !regdb ) {
                result = ntstatus_to_werror( map_nt_error_from_unix( errno ) );
-               DEBUG(0,("regdb_open: Failed to open %s! (%s)\n", 
+               DEBUG(0,("regdb_open: Failed to open %s! (%s)\n",
                        state_path("registry.tdb"), strerror(errno) ));
        }
 
        unbecome_root();
 
        regdb_refcount = 1;
-       DEBUG(10,("regdb_open: refcount reset (%d)\n", regdb_refcount));
+       DEBUG(10, ("regdb_open: registry db opened. refcount reset (%d)\n",
+                  regdb_refcount));
 
        return result;
 }
@@ -482,7 +616,8 @@ int regdb_close( void )
 
        regdb_refcount--;
 
-       DEBUG(10,("regdb_close: decrementing refcount (%d)\n", regdb_refcount));
+       DEBUG(10, ("regdb_close: decrementing refcount (%d->%d)\n",
+                  regdb_refcount+1, regdb_refcount));
 
        if ( regdb_refcount > 0 )
                return 0;
@@ -538,7 +673,7 @@ static WERROR regdb_delete_key_with_prefix(struct db_context *db,
        if (prefix == NULL) {
                path = discard_const_p(char, keyname);
        } else {
-               path = talloc_asprintf(mem_ctx, "%s/%s", prefix, keyname);
+               path = talloc_asprintf(mem_ctx, "%s\\%s", prefix, keyname);
                if (path == NULL) {
                        goto done;
                }
@@ -583,14 +718,14 @@ static WERROR regdb_delete_key_lists(struct db_context *db, const char *keyname)
 
        werr = regdb_delete_values(db, keyname);
        if (!W_ERROR_IS_OK(werr)) {
-               DEBUG(1, (__location__ " Deleting %s/%s failed: %s\n",
+               DEBUG(1, (__location__ " Deleting %s\\%s failed: %s\n",
                          REG_VALUE_PREFIX, keyname, win_errstr(werr)));
                goto done;
        }
 
        werr = regdb_delete_secdesc(db, keyname);
        if (!W_ERROR_IS_OK(werr)) {
-               DEBUG(1, (__location__ " Deleting %s/%s failed: %s\n",
+               DEBUG(1, (__location__ " Deleting %s\\%s failed: %s\n",
                          REG_SECDESC_PREFIX, keyname, win_errstr(werr)));
                goto done;
        }
@@ -700,22 +835,9 @@ static WERROR regdb_store_keys_internal2(struct db_context *db,
        W_ERROR_NOT_OK_GOTO_DONE(werr);
 
        /*
-        * Delete a sorted subkey cache for regdb_key_exists, will be
-        * recreated automatically
+        * recreate the sorted subkey cache for regdb_key_exists()
         */
-       keyname = talloc_asprintf(ctx, "%s/%s", REG_SORTED_SUBKEYS_PREFIX,
-                                 keyname);
-       if (keyname == NULL) {
-               werr = WERR_NOMEM;
-               goto done;
-       }
-
-       werr = ntstatus_to_werror(dbwrap_delete_bystring(db, keyname));
-
-       /* don't treat WERR_NOT_FOUND as an error here */
-       if (W_ERROR_EQUAL(werr, WERR_NOT_FOUND)) {
-               werr = WERR_OK;
-       }
+       werr = ntstatus_to_werror(create_sorted_subkeys(keyname));
 
 done:
        TALLOC_FREE(ctx);
@@ -794,7 +916,7 @@ static NTSTATUS regdb_store_keys_action(struct db_context *db,
                        continue;
                }
 
-               path = talloc_asprintf(mem_ctx, "%s/%s", store_ctx->key,
+               path = talloc_asprintf(mem_ctx, "%s\\%s", store_ctx->key,
                                       oldkeyname);
                if (!path) {
                        werr = WERR_NOMEM;
@@ -838,7 +960,7 @@ static NTSTATUS regdb_store_keys_action(struct db_context *db,
        }
 
        for (i=0; i<num_subkeys; i++) {
-               path = talloc_asprintf(mem_ctx, "%s/%s", store_ctx->key,
+               path = talloc_asprintf(mem_ctx, "%s\\%s", store_ctx->key,
                                regsubkey_ctr_specific_key(store_ctx->ctr, i));
                if (!path) {
                        werr = WERR_NOMEM;
@@ -1081,7 +1203,7 @@ static WERROR regdb_delete_subkey(const char *key, const char *subkey)
                goto done;
        }
 
-       path = talloc_asprintf(mem_ctx, "%s/%s", key, subkey);
+       path = talloc_asprintf(mem_ctx, "%s\\%s", key, subkey);
        if (path == NULL) {
                werr = WERR_NOMEM;
                goto done;
@@ -1125,7 +1247,7 @@ static TDB_DATA regdb_fetch_key_internal(struct db_context *db,
 
 /**
  * check whether a given key name represents a base key,
- * i.e one without a subkey separator ('/' or '\').
+ * i.e one without a subkey separator ('\').
  */
 static bool regdb_key_is_base_key(const char *key)
 {
@@ -1147,7 +1269,7 @@ static bool regdb_key_is_base_key(const char *key)
                goto done;
        }
 
-       ret = (strrchr(path, '/') == NULL);
+       ret = (strrchr(path, '\\') == NULL);
 
 done:
        TALLOC_FREE(mem_ctx);
@@ -1177,9 +1299,9 @@ done:
  * recreated on demand.
  */
 
-static int cmp_keynames(const void *p1, const void *p2)
+static int cmp_keynames(char **p1, char **p2)
 {
-       return StrCaseCmp(*((char **)p1), *((char **)p2));
+       return strcasecmp_m(*p1, *p2);
 }
 
 struct create_sorted_subkeys_context {
@@ -1248,7 +1370,7 @@ static NTSTATUS create_sorted_subkeys_action(struct db_context *db,
                len += strlen(sorted_subkeys[i])+1;
        }
 
-       qsort(sorted_subkeys, num_subkeys, sizeof(char *), cmp_keynames);
+       TYPESAFE_QSORT(sorted_subkeys, num_subkeys, cmp_keynames);
 
        buf = talloc_array(ctr, char, len);
        if (buf == NULL) {
@@ -1276,7 +1398,8 @@ done:
        return status;
 }
 
-static bool create_sorted_subkeys(const char *key, const char *sorted_keyname)
+static NTSTATUS create_sorted_subkeys_internal(const char *key,
+                                              const char *sorted_keyname)
 {
        NTSTATUS status;
        struct create_sorted_subkeys_context sorted_ctx;
@@ -1288,7 +1411,26 @@ static bool create_sorted_subkeys(const char *key, const char *sorted_keyname)
                                 create_sorted_subkeys_action,
                                 &sorted_ctx);
 
-       return NT_STATUS_IS_OK(status);
+       return status;
+}
+
+static NTSTATUS create_sorted_subkeys(const char *key)
+{
+       char *sorted_subkeys_keyname;
+       NTSTATUS status;
+
+       sorted_subkeys_keyname = talloc_asprintf(talloc_tos(), "%s\\%s",
+                                                REG_SORTED_SUBKEYS_PREFIX,
+                                                key);
+       if (sorted_subkeys_keyname == NULL) {
+               status = NT_STATUS_NO_MEMORY;
+               goto done;
+       }
+
+       status = create_sorted_subkeys_internal(key, sorted_subkeys_keyname);
+
+done:
+       return status;
 }
 
 struct scan_subkey_state {
@@ -1350,7 +1492,7 @@ static bool scan_parent_subkeys(struct db_context *db, const char *parent,
                goto fail;
        }
 
-       key = talloc_asprintf(talloc_tos(), "%s/%s",
+       key = talloc_asprintf(talloc_tos(), "%s\\%s",
                              REG_SORTED_SUBKEYS_PREFIX, path);
        if (key == NULL) {
                goto fail;
@@ -1368,14 +1510,39 @@ static bool scan_parent_subkeys(struct db_context *db, const char *parent,
        if (state.scanned) {
                result = state.found;
        } else {
-               if (!create_sorted_subkeys(path, key)) {
+               NTSTATUS status;
+
+               res = db->transaction_start(db);
+               if (res != 0) {
+                       DEBUG(0, ("error starting transaction\n"));
                        goto fail;
                }
+
+               DEBUG(2, (__location__ " WARNING: recreating the sorted "
+                         "subkeys cache for key '%s' from scan_parent_subkeys "
+                         "this should not happen (too frequently)...\n",
+                         path));
+
+               status = create_sorted_subkeys_internal(path, key);
+               if (!NT_STATUS_IS_OK(status)) {
+                       res = db->transaction_cancel(db);
+                       if (res != 0) {
+                               smb_panic("Failed to cancel transaction.");
+                       }
+                       goto fail;
+               }
+
                res = db->parse_record(db, string_term_tdb_data(key),
                                       parent_subkey_scanner, &state);
                if ((res == 0) && (state.scanned)) {
                        result = state.found;
                }
+
+               res = db->transaction_commit(db);
+               if (res != 0) {
+                       DEBUG(0, ("error committing transaction\n"));
+                       result = false;
+               }
        }
 
  fail:
@@ -1413,7 +1580,7 @@ static bool regdb_key_exists(struct db_context *db, const char *key)
                goto done;
        }
 
-       p = strrchr(path, '/');
+       p = strrchr(path, '\\');
        if (p == NULL) {
                /* this is a base key */
                value = regdb_fetch_key_internal(db, mem_ctx, path);
@@ -1448,8 +1615,6 @@ static WERROR regdb_fetch_keys_internal(struct db_context *db, const char *key,
 
        DEBUG(11,("regdb_fetch_keys: Enter key => [%s]\n", key ? key : "NULL"));
 
-       frame = talloc_stackframe();
-
        if (!regdb_key_exists(db, key)) {
                DEBUG(10, ("key [%s] not found\n", key));
                werr = WERR_NOT_FOUND;
@@ -1539,12 +1704,8 @@ static int regdb_unpack_values(struct regval_ctr *values, uint8 *buf, int buflen
                                  &size,
                                  &data_p);
 
-               /* add the new value. Paranoid protective code -- make sure data_p is valid */
-
-               if (*valuename && size && data_p) {
-                       regval_ctr_addvalue(values, valuename, type,
-                                       (const char *)data_p, size);
-               }
+               regval_ctr_addvalue(values, valuename, type,
+                               (uint8_t *)data_p, size);
                SAFE_FREE(data_p); /* 'B' option to tdb_unpack does a malloc() */
 
                DEBUG(8,("specific: [%s], len: %d\n", valuename, size));
@@ -1599,6 +1760,7 @@ static int regdb_fetch_values_internal(struct db_context *db, const char* key,
        TALLOC_CTX *ctx = talloc_stackframe();
        int ret = 0;
        TDB_DATA value;
+       WERROR werr;
 
        DEBUG(10,("regdb_fetch_values: Looking for value of key [%s] \n", key));
 
@@ -1606,12 +1768,13 @@ static int regdb_fetch_values_internal(struct db_context *db, const char* key,
                goto done;
        }
 
-       keystr = talloc_asprintf(ctx, "%s/%s", REG_VALUE_PREFIX, key);
+       keystr = talloc_asprintf(ctx, "%s\\%s", REG_VALUE_PREFIX, key);
        if (!keystr) {
                goto done;
        }
 
-       values->seqnum = db->get_seqnum(db);
+       werr = regval_ctr_set_seqnum(values, db->get_seqnum(db));
+       W_ERROR_NOT_OK_GOTO_DONE(werr);
 
        value = regdb_fetch_key_internal(db, ctx, keystr);
 
@@ -1657,14 +1820,14 @@ static bool regdb_store_values_internal(struct db_context *db, const char *key,
                goto done;
        }
 
-       data.dptr = TALLOC_ARRAY(ctx, uint8, len);
+       data.dptr = talloc_array(ctx, uint8, len);
        data.dsize = len;
 
        len = regdb_pack_values(values, data.dptr, data.dsize);
 
        SMB_ASSERT( len == data.dsize );
 
-       keystr = talloc_asprintf(ctx, "%s/%s", REG_VALUE_PREFIX, key );
+       keystr = talloc_asprintf(ctx, "%s\\%s", REG_VALUE_PREFIX, key );
        if (!keystr) {
                goto done;
        }
@@ -1713,12 +1876,17 @@ static WERROR regdb_get_secdesc(TALLOC_CTX *mem_ctx, const char *key,
                goto done;
        }
 
-       tdbkey = talloc_asprintf(tmp_ctx, "%s/%s", REG_SECDESC_PREFIX, key);
+       tdbkey = talloc_asprintf(tmp_ctx, "%s\\%s", REG_SECDESC_PREFIX, key);
+       if (tdbkey == NULL) {
+               err = WERR_NOMEM;
+               goto done;
+       }
+
+       tdbkey = normalize_reg_path(tmp_ctx, tdbkey);
        if (tdbkey == NULL) {
                err = WERR_NOMEM;
                goto done;
        }
-       normalize_dbkey(tdbkey);
 
        data = dbwrap_fetch_bystring(regdb, tmp_ctx, tdbkey);
        if (data.dptr == NULL) {
@@ -1753,11 +1921,16 @@ static WERROR regdb_set_secdesc(const char *key,
                goto done;
        }
 
-       tdbkey = talloc_asprintf(mem_ctx, "%s/%s", REG_SECDESC_PREFIX, key);
+       tdbkey = talloc_asprintf(mem_ctx, "%s\\%s", REG_SECDESC_PREFIX, key);
        if (tdbkey == NULL) {
                goto done;
        }
-       normalize_dbkey(tdbkey);
+
+       tdbkey = normalize_reg_path(mem_ctx, tdbkey);
+       if (tdbkey == NULL) {
+               err = WERR_NOMEM;
+               goto done;
+       }
 
        if (secdesc == NULL) {
                /* assuming a delete */
@@ -1786,13 +1959,13 @@ bool regdb_subkeys_need_update(struct regsubkey_ctr *subkeys)
 
 bool regdb_values_need_update(struct regval_ctr *values)
 {
-       return (regdb_get_seqnum() != values->seqnum);
+       return (regdb_get_seqnum() != regval_ctr_get_seqnum(values));
 }
 
-/* 
+/*
  * Table of function pointers for default access
  */
+
 struct registry_ops regdb_ops = {
        .fetch_subkeys = regdb_fetch_keys,
        .fetch_values = regdb_fetch_values,