Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

Location:
vendor/current/source3/registry
Files:
33 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/registry/reg_api.c

    r746 r988  
    7171#include "reg_objects.h"
    7272#include "../librpc/gen_ndr/ndr_security.h"
     73#include "reg_parse_internal.h"
    7374
    7475#undef DBGC_CLASS
     
    112113        }
    113114
     115        TALLOC_FREE(key->subkeys);
    114116        werr = regsubkey_ctr_init(key, &(key->subkeys));
    115117        W_ERROR_NOT_OK_RETURN(werr);
     
    132134                                   const char *name,
    133135                                   const struct security_token *token,
    134                                    uint32 access_desired,
     136                                   uint32_t access_desired,
    135137                                   struct registry_key **pregkey)
    136138{
     
    143145        SMB_ASSERT(strchr(name, '\\') == NULL);
    144146
    145         if (!(regkey = TALLOC_ZERO_P(mem_ctx, struct registry_key)) ||
     147        if (!(regkey = talloc_zero(mem_ctx, struct registry_key)) ||
    146148            !(regkey->token = dup_nt_token(regkey, token)) ||
    147             !(regkey->key = TALLOC_ZERO_P(regkey, struct registry_key_handle)))
     149            !(regkey->key = talloc_zero(regkey, struct registry_key_handle)))
    148150        {
    149151                result = WERR_NOMEM;
     
    190192        /* Tag this as a Performance Counter Key */
    191193
    192         if( StrnCaseCmp(key->name, KEY_HKPD, strlen(KEY_HKPD)) == 0 )
     194        if( strncasecmp_m(key->name, KEY_HKPD, strlen(KEY_HKPD)) == 0 )
    193195                key->type = REG_KEY_HKPD;
    194196
     
    228230
    229231WERROR reg_openhive(TALLOC_CTX *mem_ctx, const char *hive,
    230                     uint32 desired_access,
     232                    uint32_t desired_access,
    231233                    const struct security_token *token,
    232234                    struct registry_key **pkey)
    233235{
     236        const struct hive_info *hi;
    234237        SMB_ASSERT(hive != NULL);
    235         SMB_ASSERT(hive[0] != '\0');
    236238        SMB_ASSERT(strchr(hive, '\\') == NULL);
    237239
    238         return regkey_open_onelevel(mem_ctx, NULL, hive, token, desired_access,
    239                                     pkey);
     240        hi = hive_info(hive);
     241        if (hi == NULL) {
     242                return WERR_BADFILE;
     243        }
     244
     245        return regkey_open_onelevel(mem_ctx, NULL, hi->short_name, token,
     246                                    desired_access, pkey);
    240247}
    241248
     
    246253
    247254WERROR reg_openkey(TALLOC_CTX *mem_ctx, struct registry_key *parent,
    248                    const char *name, uint32 desired_access,
     255                   const char *name, uint32_t desired_access,
    249256                   struct registry_key **pkey)
    250257{
     
    298305
    299306WERROR reg_enumkey(TALLOC_CTX *mem_ctx, struct registry_key *key,
    300                    uint32 idx, char **name, NTTIME *last_write_time)
     307                   uint32_t idx, char **name, NTTIME *last_write_time)
    301308{
    302309        WERROR err;
     
    306313        }
    307314
    308         if (!W_ERROR_IS_OK(err = fill_subkey_cache(key))) {
     315        err = fill_subkey_cache(key);
     316        if (!W_ERROR_IS_OK(err)) {
    309317                return err;
    310318        }
     
    328336
    329337WERROR reg_enumvalue(TALLOC_CTX *mem_ctx, struct registry_key *key,
    330                      uint32 idx, char **pname, struct registry_value **pval)
     338                     uint32_t idx, char **pname, struct registry_value **pval)
    331339{
    332340        struct registry_value *val;
     
    338346        }
    339347
    340         if (!(W_ERROR_IS_OK(err = fill_value_cache(key)))) {
     348        err = fill_value_cache(key);
     349        if (!(W_ERROR_IS_OK(err))) {
    341350                return err;
    342351        }
     
    369378static WERROR reg_enumvalue_nocachefill(TALLOC_CTX *mem_ctx,
    370379                                        struct registry_key *key,
    371                                         uint32 idx, char **pname,
     380                                        uint32_t idx, char **pname,
    372381                                        struct registry_value **pval)
    373382{
     
    408417{
    409418        WERROR err;
    410         uint32 i;
     419        uint32_t i;
    411420
    412421        if (!(key->key->access_granted & KEY_QUERY_VALUE)) {
     
    492501                        NTTIME *last_changed_time)
    493502{
    494         uint32 i, max_size;
     503        uint32_t i, max_size;
    495504        size_t max_len;
    496505        TALLOC_CTX *mem_ctx;
     
    549558
    550559WERROR reg_createkey(TALLOC_CTX *ctx, struct registry_key *parent,
    551                      const char *subkeypath, uint32 desired_access,
     560                     const char *subkeypath, uint32_t desired_access,
    552561                     struct registry_key **pkey,
    553562                     enum winreg_CreateAction *paction)
    554563{
    555564        struct registry_key *key = parent;
    556         struct registry_key *create_parent;
    557565        TALLOC_CTX *mem_ctx;
    558566        char *path, *end;
     
    627635        {
    628636                err = WERR_ACCESS_DENIED;
    629                 goto done;
     637                goto trans_done;
    630638        }
    631639
     
    666674}
    667675
    668 WERROR reg_deletekey(struct registry_key *parent, const char *path)
     676static WERROR reg_deletekey_internal(TALLOC_CTX *mem_ctx,
     677                                     struct registry_key *parent,
     678                                     const char *path, bool lazy)
    669679{
    670680        WERROR err;
    671681        char *name, *end;
    672         struct registry_key *tmp_key, *key;
    673         TALLOC_CTX *mem_ctx = talloc_stackframe();
    674 
     682        struct registry_key *key;
    675683        name = talloc_strdup(mem_ctx, path);
    676684        if (name == NULL) {
     
    679687        }
    680688
     689        /* no subkeys - proceed with delete */
     690        end = strrchr(name, '\\');
     691        if (end != NULL) {
     692                *end = '\0';
     693
     694                err = reg_openkey(mem_ctx, parent, name,
     695                                  KEY_CREATE_SUB_KEY, &key);
     696                W_ERROR_NOT_OK_GOTO_DONE(err);
     697
     698                parent = key;
     699                name = end+1;
     700        }
     701
     702        if (name[0] == '\0') {
     703                err = WERR_INVALID_PARAM;
     704                goto done;
     705        }
     706
     707        err = delete_reg_subkey(parent->key, name, lazy);
     708
     709done:
     710        return err;
     711}
     712
     713WERROR reg_deletekey(struct registry_key *parent, const char *path)
     714{
     715        WERROR err;
     716        struct registry_key *key;
     717        TALLOC_CTX *mem_ctx = talloc_stackframe();
     718
    681719        /* check if the key has subkeys */
    682         err = reg_openkey(mem_ctx, parent, name, REG_KEY_READ, &key);
     720        err = reg_openkey(mem_ctx, parent, path, REG_KEY_READ, &key);
    683721        W_ERROR_NOT_OK_GOTO_DONE(err);
    684722
     
    691729
    692730        err = fill_subkey_cache(key);
    693         W_ERROR_NOT_OK_GOTO(err, trans_done);
     731        if (!W_ERROR_IS_OK(err)) {
     732                goto trans_done;
     733        }
    694734
    695735        if (regsubkey_ctr_numkeys(key->subkeys) > 0) {
     
    697737                goto trans_done;
    698738        }
    699 
    700         /* no subkeys - proceed with delete */
    701         end = strrchr(name, '\\');
    702         if (end != NULL) {
    703                 *end = '\0';
    704 
    705                 err = reg_openkey(mem_ctx, parent, name,
    706                                   KEY_CREATE_SUB_KEY, &tmp_key);
    707                 W_ERROR_NOT_OK_GOTO(err, trans_done);
    708 
    709                 parent = tmp_key;
    710                 name = end+1;
    711         }
    712 
    713         if (name[0] == '\0') {
    714                 err = WERR_INVALID_PARAM;
    715                 goto trans_done;
    716         }
    717 
    718         err = delete_reg_subkey(parent->key, name);
     739        err = reg_deletekey_internal(mem_ctx, parent, path, false);
    719740
    720741trans_done:
     
    735756        return err;
    736757}
     758
    737759
    738760WERROR reg_setvalue(struct registry_key *key, const char *name,
     
    932954static WERROR reg_deletekey_recursive_internal(struct registry_key *parent,
    933955                                               const char *path,
    934                                                bool del_key)
     956                                               bool del_key, bool lazy)
    935957{
    936958        WERROR werr = WERR_OK;
    937959        struct registry_key *key;
    938960        char *subkey_name = NULL;
    939         uint32 i;
     961        uint32_t i;
    940962        TALLOC_CTX *mem_ctx = talloc_stackframe();
     963
     964        DEBUG(5, ("reg_deletekey_recursive_internal: deleting '%s' from '%s'\n",
     965                  path, parent->key->name));
    941966
    942967        /* recurse through subkeys first */
    943968        werr = reg_openkey(mem_ctx, parent, path, REG_KEY_ALL, &key);
    944969        if (!W_ERROR_IS_OK(werr)) {
     970                DEBUG(3, ("reg_deletekey_recursive_internal: error opening "
     971                          "subkey '%s' of '%s': '%s'\n",
     972                          path, parent->key->name, win_errstr(werr)));
    945973                goto done;
    946974        }
     
    955983        for (i = regsubkey_ctr_numkeys(key->subkeys) ; i > 0; i--) {
    956984                subkey_name = regsubkey_ctr_specific_key(key->subkeys, i-1);
    957                 werr = reg_deletekey_recursive_internal(key, subkey_name, true);
     985                werr = reg_deletekey_recursive_internal(key, subkey_name, true, del_key);
    958986                W_ERROR_NOT_OK_GOTO_DONE(werr);
    959987        }
     
    961989        if (del_key) {
    962990                /* now delete the actual key */
    963                 werr = reg_deletekey(parent, path);
     991                werr = reg_deletekey_internal(mem_ctx, parent, path, lazy);
    964992        }
    965993
    966994done:
     995
     996        DEBUG(5, ("reg_deletekey_recursive_internal: done deleting '%s' from "
     997                  "'%s': %s\n",
     998                  path, parent->key->name, win_errstr(werr)));
    967999        TALLOC_FREE(mem_ctx);
    9681000        return werr;
     
    9831015        }
    9841016
    985         werr = reg_deletekey_recursive_internal(parent, path, del_key);
     1017        werr = reg_deletekey_recursive_internal(parent, path, del_key, false);
    9861018
    9871019        if (!W_ERROR_IS_OK(werr)) {
    9881020                WERROR werr2;
    989 
    990                 DEBUG(1, (__location__ " failed to delete key '%s' from key "
    991                           "'%s': %s\n", path, parent->key->name,
    992                           win_errstr(werr)));
     1021                DEBUG(W_ERROR_EQUAL(werr, WERR_BADFILE) ? 5 : 1,
     1022                      (__location__ ": failed to delete key '%s' from key "
     1023                       "'%s': %s\n", path, parent->key->name,
     1024                       win_errstr(werr)));
    9931025
    9941026                werr2 = regdb_transaction_cancel();
     
    10081040                                  "error committing transaction: %s\n",
    10091041                                  win_errstr(werr)));
     1042                } else {
     1043                        DEBUG(5, ("reg_deletekey_recursive_trans: deleted key '%s' from '%s'\n",
     1044                                  path, parent->key->name));
     1045
    10101046                }
    10111047        }
  • vendor/current/source3/registry/reg_api.h

    r740 r988  
    2525
    2626WERROR reg_openhive(TALLOC_CTX *mem_ctx, const char *hive,
    27                     uint32 desired_access,
     27                    uint32_t desired_access,
    2828                    const struct security_token *token,
    2929                    struct registry_key **pkey);
    3030WERROR reg_openkey(TALLOC_CTX *mem_ctx, struct registry_key *parent,
    31                    const char *name, uint32 desired_access,
     31                   const char *name, uint32_t desired_access,
    3232                   struct registry_key **pkey);
    3333WERROR reg_enumkey(TALLOC_CTX *mem_ctx, struct registry_key *key,
    34                    uint32 idx, char **name, NTTIME *last_write_time);
     34                   uint32_t idx, char **name, NTTIME *last_write_time);
    3535WERROR reg_enumvalue(TALLOC_CTX *mem_ctx, struct registry_key *key,
    36                      uint32 idx, char **pname, struct registry_value **pval);
     36                     uint32_t idx, char **pname, struct registry_value **pval);
    3737WERROR reg_queryvalue(TALLOC_CTX *mem_ctx, struct registry_key *key,
    3838                      const char *name, struct registry_value **pval);
     
    4949                        NTTIME *last_changed_time);
    5050WERROR reg_createkey(TALLOC_CTX *ctx, struct registry_key *parent,
    51                      const char *subkeypath, uint32 desired_access,
     51                     const char *subkeypath, uint32_t desired_access,
    5252                     struct registry_key **pkey,
    5353                     enum winreg_CreateAction *paction);
  • vendor/current/source3/registry/reg_api_util.c

    r740 r988  
    2727#include "reg_api.h"
    2828#include "reg_api_util.h"
     29#include "libcli/registry/util_reg.h"
    2930
    3031/**
     
    3233 */
    3334WERROR reg_open_path(TALLOC_CTX *mem_ctx, const char *orig_path,
    34                      uint32 desired_access, const struct security_token *token,
     35                     uint32_t desired_access, const struct security_token *token,
    3536                     struct registry_key **pkey)
    3637{
     
    8384}
    8485
    85 #if 0
    86 /* these two functions are unused. */
    87 
    8886/**
    8987 * Utility function to create a registry key without opening the hive
     
    9290
    9391WERROR reg_create_path(TALLOC_CTX *mem_ctx, const char *orig_path,
    94                        uint32 desired_access,
     92                       uint32_t desired_access,
    9593                       const struct security_token *token,
    9694                       enum winreg_CreateAction *paction,
     
    142140
    143141/*
    144  * Utility function to create a registry key without opening the hive
    145  * before. Will not delete a hive.
     142 * Utility function to recursively delete a registry key without opening the
     143 * hive before. Will not delete a hive.
    146144 */
    147145
     
    175173        }
    176174
    177         err = reg_deletekey(hive, p+1);
     175        err = reg_deletekey_recursive(hive, p+1);
    178176        SAFE_FREE(path);
    179177        TALLOC_FREE(hive);
    180178        return err;
    181179}
    182 #endif /* #if 0 */
     180
     181struct registry_value *registry_value_dw(TALLOC_CTX *mem_ctx, uint32_t dw)
     182{
     183        struct registry_value *ret;
     184
     185        ret = talloc_zero(mem_ctx, struct registry_value);
     186        if (ret == NULL) {
     187                return NULL;
     188        }
     189
     190        ret->data = data_blob_talloc(ret, NULL, sizeof(uint32_t));
     191        if (ret->data.data == NULL) {
     192                talloc_free(ret);
     193                return NULL;
     194        }
     195
     196        ret->type = REG_DWORD;
     197
     198        SIVAL(ret->data.data, 0, dw);
     199
     200        return ret;
     201}
     202
     203struct registry_value *registry_value_sz(TALLOC_CTX *mem_ctx, const char *str)
     204{
     205        struct registry_value *ret;
     206
     207        ret = talloc_zero(mem_ctx, struct registry_value);
     208        if (ret == NULL) {
     209                return NULL;
     210        }
     211
     212        if (!push_reg_sz(ret, &ret->data, str)) {
     213                talloc_free(ret);
     214                return NULL;
     215        }
     216
     217        ret->type = REG_SZ;
     218
     219        return ret;
     220}
     221
     222struct registry_value *registry_value_multi_sz(TALLOC_CTX *mem_ctx, const char **str)
     223{
     224        struct registry_value *ret;
     225
     226        ret = talloc_zero(mem_ctx, struct registry_value);
     227        if (ret == NULL) {
     228                return NULL;
     229        }
     230
     231        if (!push_reg_multi_sz(ret, &ret->data, str)) {
     232                talloc_free(ret);
     233                return NULL;
     234        }
     235
     236        ret->type = REG_MULTI_SZ;
     237
     238        return ret;
     239}
     240
     241int registry_value_cmp(const struct registry_value* v1, const struct registry_value* v2)
     242{
     243        if (v1->type == v2->type) {
     244                return data_blob_cmp(&v1->data, &v2->data);
     245        }
     246        return v1->type - v2->type;
     247}
  • vendor/current/source3/registry/reg_api_util.h

    r740 r988  
    3030 */
    3131WERROR reg_open_path(TALLOC_CTX *mem_ctx, const char *orig_path,
    32                      uint32 desired_access, const struct security_token *token,
     32                     uint32_t desired_access, const struct security_token *token,
    3333                     struct registry_key **pkey);
    3434
    35 #if 0
    36 /* currently unused */
    3735WERROR reg_create_path(TALLOC_CTX *mem_ctx, const char *orig_path,
    38                        uint32 desired_access,
     36                       uint32_t desired_access,
    3937                       const struct security_token *token,
    4038                       enum winreg_CreateAction *paction,
     
    4240WERROR reg_delete_path(const struct security_token *token,
    4341                       const char *orig_path);
    44 #endif
     42
     43struct registry_value *registry_value_dw(TALLOC_CTX *mem_ctx, uint32_t dw);
     44struct registry_value *registry_value_sz(TALLOC_CTX *mem_ctx, const char *str);
     45struct registry_value *registry_value_multi_sz(TALLOC_CTX *mem_ctx, const char **str);
     46
     47int registry_value_cmp(const struct registry_value *v1, const struct registry_value *v2);
    4548
    4649#endif /* _REG_API_UTIL_H */
  • vendor/current/source3/registry/reg_backend_current_version.c

    r740 r988  
    5959        regval_ctr_addvalue_sz(values, "SystemRoot", sysroot_string);
    6060
    61         fstr_sprintf(sysversion, "%d.%d", lp_major_announce_version(),
    62                      lp_minor_announce_version());
     61        fstr_sprintf(sysversion, "%d.%d", SAMBA_MAJOR_NBT_ANNOUNCE_VERSION,
     62                     SAMBA_MINOR_NBT_ANNOUNCE_VERSION);
    6363
    6464        regval_ctr_addvalue_sz(values, "CurrentVersion", sysversion);
  • vendor/current/source3/registry/reg_backend_db.c

    r746 r988  
    33 *  Virtual Windows Registry Layer
    44 *  Copyright (C) Gerald Carter                     2002-2005
    5  *  Copyright (C) Michael Adam                      2007-2009
     5 *  Copyright (C) Michael Adam                      2007-2011
     6 *  Copyright (C) Gregor Beck                       2011
    67 *
    78 *  This program is free software; you can redistribute it and/or modify
     
    2627#include "reg_db.h"
    2728#include "reg_util_internal.h"
     29#include "reg_parse_internal.h"
    2830#include "reg_backend_db.h"
    2931#include "reg_objects.h"
    3032#include "nt_printing.h"
    3133#include "util_tdb.h"
    32 #include "dbwrap.h"
     34#include "dbwrap/dbwrap.h"
     35#include "dbwrap/dbwrap_open.h"
     36#include "../libcli/security/secdesc.h"
    3337
    3438#undef DBGC_CLASS
    3539#define DBGC_CLASS DBGC_REGISTRY
    3640
     41#define REGDB_VERSION_KEYNAME "INFO/version"
     42
    3743static struct db_context *regdb = NULL;
    3844static int regdb_refcount;
    3945
    4046static bool regdb_key_exists(struct db_context *db, const char *key);
    41 static bool regdb_key_is_base_key(const char *key);
    4247static WERROR regdb_fetch_keys_internal(struct db_context *db, const char *key,
    4348                                        struct regsubkey_ctr *ctr);
     
    4651static int regdb_fetch_values_internal(struct db_context *db, const char* key,
    4752                                       struct regval_ctr *values);
    48 static bool regdb_store_values_internal(struct db_context *db, const char *key,
    49                                         struct regval_ctr *values);
    50 
    51 static NTSTATUS create_sorted_subkeys(const char *key);
     53static NTSTATUS regdb_store_values_internal(struct db_context *db, const char *key,
     54                                            struct regval_ctr *values);
     55static WERROR regdb_store_subkey_list(struct db_context *db, const char *parent,
     56                                      const char *key);
     57
     58static WERROR regdb_create_basekey(struct db_context *db, const char *key);
     59static WERROR regdb_create_subkey_internal(struct db_context *db,
     60                                           const char *key,
     61                                           const char *subkey);
     62
     63
     64struct regdb_trans_ctx {
     65        NTSTATUS (*action)(struct db_context *, void *);
     66        void *private_data;
     67};
     68
     69static NTSTATUS regdb_trans_do_action(struct db_context *db, void *private_data)
     70{
     71        NTSTATUS status;
     72        int32_t version_id;
     73        struct regdb_trans_ctx *ctx = (struct regdb_trans_ctx *)private_data;
     74
     75        status = dbwrap_fetch_int32_bystring(db, REGDB_VERSION_KEYNAME,
     76                                             &version_id);
     77
     78        if (!NT_STATUS_IS_OK(status)) {
     79                DEBUG(0, ("ERROR: could not fetch registry db version: %s. "
     80                          "Denying access.\n", nt_errstr(status)));
     81                return NT_STATUS_ACCESS_DENIED;
     82        }
     83
     84        if (version_id != REGDB_CODE_VERSION) {
     85                DEBUG(0, ("ERROR: changed registry version %d found while "
     86                          "trying to write to the registry. Version %d "
     87                          "expected.  Denying access.\n",
     88                          version_id, REGDB_CODE_VERSION));
     89                return NT_STATUS_ACCESS_DENIED;
     90        }
     91
     92        status = ctx->action(db,  ctx->private_data);
     93        return status;
     94}
     95
     96static WERROR regdb_trans_do(struct db_context *db,
     97                             NTSTATUS (*action)(struct db_context *, void *),
     98                             void *private_data)
     99{
     100        NTSTATUS status;
     101        struct regdb_trans_ctx ctx;
     102
     103
     104        ctx.action = action;
     105        ctx.private_data = private_data;
     106
     107        status = dbwrap_trans_do(db, regdb_trans_do_action, &ctx);
     108
     109        return ntstatus_to_werror(status);
     110}
    52111
    53112/* List the deepest path into the registry.  All part components will be created.*/
     
    95154        const char *path;
    96155        const char *valuename;
    97         uint32 type;
     156        uint32_t type;
    98157        union {
    99158                const char *string;
    100                 uint32 dw_value;
     159                uint32_t dw_value;
    101160        } data;
    102161};
     
    114173};
    115174
     175static WERROR create_key_recursive(struct db_context *db,
     176                                   char *path,
     177                                   const char *subkey)
     178{
     179        WERROR werr;
     180        char *p;
     181
     182        if (subkey == NULL) {
     183                return WERR_INVALID_PARAM;
     184        }
     185
     186        if (path == NULL) {
     187                return regdb_create_basekey(db, subkey);
     188        }
     189
     190        p = strrchr_m(path, '\\');
     191
     192        if (p == NULL) {
     193                werr = create_key_recursive(db, NULL, path);
     194        } else {
     195                *p = '\0';
     196                werr = create_key_recursive(db, path, p+1);
     197                *p = '\\';
     198        }
     199
     200        if (!W_ERROR_IS_OK(werr)) {
     201                goto done;
     202        }
     203
     204        werr = regdb_create_subkey_internal(db, path, subkey);
     205
     206done:
     207        return werr;
     208}
     209
    116210/**
    117211 * Initialize a key in the registry:
     
    121215                                         const char *add_path)
    122216{
     217        char *subkey, *key;
    123218        WERROR werr;
    124219        TALLOC_CTX *frame = talloc_stackframe();
    125         char *path = NULL;
    126         char *base = NULL;
    127         char *remaining = NULL;
    128         char *keyname;
    129         char *subkeyname;
    130         struct regsubkey_ctr *subkeys;
    131         const char *p, *p2;
    132 
    133         DEBUG(6, ("init_registry_key: Adding [%s]\n", add_path));
    134 
    135         path = talloc_strdup(frame, add_path);
    136         base = talloc_strdup(frame, "");
    137         if (!path || !base) {
    138                 werr = WERR_NOMEM;
    139                 goto fail;
    140         }
    141         p = path;
    142 
    143         while (next_token_talloc(frame, &p, &keyname, "\\")) {
    144 
    145                 /* build up the registry path from the components */
    146 
    147                 if (*base) {
    148                         base = talloc_asprintf(frame, "%s\\", base);
    149                         if (!base) {
    150                                 werr = WERR_NOMEM;
    151                                 goto fail;
    152                         }
    153                 }
    154                 base = talloc_asprintf_append(base, "%s", keyname);
    155                 if (!base) {
    156                         werr = WERR_NOMEM;
    157                         goto fail;
    158                 }
    159 
    160                 /* get the immediate subkeyname (if we have one ) */
    161 
    162                 subkeyname = talloc_strdup(frame, "");
    163                 if (!subkeyname) {
    164                         werr = WERR_NOMEM;
    165                         goto fail;
    166                 }
    167                 if (*p) {
    168                         remaining = talloc_strdup(frame, p);
    169                         if (!remaining) {
    170                                 werr = WERR_NOMEM;
    171                                 goto fail;
    172                         }
    173                         p2 = remaining;
    174 
    175                         if (!next_token_talloc(frame, &p2,
    176                                                 &subkeyname, "\\"))
    177                         {
    178                                 subkeyname = talloc_strdup(frame,p2);
    179                                 if (!subkeyname) {
    180                                         werr = WERR_NOMEM;
    181                                         goto fail;
    182                                 }
    183                         }
    184                 }
    185 
    186                 DEBUG(10,("init_registry_key: Storing key [%s] with "
    187                           "subkey [%s]\n", base,
    188                           *subkeyname ? subkeyname : "NULL"));
    189 
    190                 /* we don't really care if the lookup succeeds or not
    191                  * since we are about to update the record.
    192                  * We just want any subkeys already present */
    193 
    194                 werr = regsubkey_ctr_init(frame, &subkeys);
    195                 if (!W_ERROR_IS_OK(werr)) {
    196                         DEBUG(0,("talloc() failure!\n"));
    197                         goto fail;
    198                 }
    199 
    200                 werr = regdb_fetch_keys_internal(db, base, subkeys);
    201                 if (!W_ERROR_IS_OK(werr) &&
    202                     !W_ERROR_EQUAL(werr, WERR_NOT_FOUND))
    203                 {
    204                         goto fail;
    205                 }
    206 
    207                 if (*subkeyname) {
    208                         werr = regsubkey_ctr_addkey(subkeys, subkeyname);
    209                         if (!W_ERROR_IS_OK(werr)) {
    210                                 goto fail;
    211                         }
    212                 }
    213                 if (!regdb_store_keys_internal(db, base, subkeys)) {
    214                         werr = WERR_CAN_NOT_COMPLETE;
    215                         goto fail;
    216                 }
    217         }
    218 
    219         werr = WERR_OK;
    220 
    221 fail:
    222         TALLOC_FREE(frame);
     220
     221        if (add_path == NULL) {
     222                werr = WERR_INVALID_PARAM;
     223                goto done;
     224        }
     225
     226        key = talloc_strdup(frame, add_path);
     227
     228        subkey = strrchr_m(key, '\\');
     229        if (subkey == NULL) {
     230                subkey = key;
     231                key = NULL;
     232        } else {
     233                *subkey = '\0';
     234                subkey++;
     235        }
     236
     237        werr = create_key_recursive(db, key, subkey);
     238
     239done:
     240        talloc_free(frame);
    223241        return werr;
    224242}
     
    253271        init_ctx.add_path = add_path;
    254272
    255         return ntstatus_to_werror(dbwrap_trans_do(regdb,
    256                                                   init_registry_key_action,
    257                                                   &init_ctx));
     273        return regdb_trans_do(regdb,
     274                              init_registry_key_action,
     275                              &init_ctx);
    258276}
    259277
     
    269287                regval_ctr_addvalue(ctr, value->valuename, REG_DWORD,
    270288                                    (uint8_t *)&value->data.dw_value,
    271                                     sizeof(uint32));
     289                                    sizeof(uint32_t));
    272290                break;
    273291
     
    326344                        regdb_ctr_add_value(values,
    327345                                            &builtin_registry_values[i]);
    328                         regdb_store_values_internal(db,
     346                        status = regdb_store_values_internal(db,
    329347                                        builtin_registry_values[i].path,
    330348                                        values);
     349                        if (!NT_STATUS_IS_OK(status)) {
     350                                goto done;
     351                        }
    331352                }
    332353                TALLOC_FREE(values);
     
    388409         */
    389410
    390         werr = ntstatus_to_werror(dbwrap_trans_do(regdb,
    391                                                   init_registry_data_action,
    392                                                   NULL));
     411        werr = regdb_trans_do(regdb,
     412                              init_registry_data_action,
     413                              NULL);
    393414
    394415done:
     
    403424        const char *keyname;
    404425        NTSTATUS status;
    405 
    406         if (rec->key.dptr == NULL || rec->key.dsize == 0) {
     426        TDB_DATA key;
     427        TDB_DATA value;
     428        struct db_context *db = (struct db_context *)private_data;
     429
     430        key = dbwrap_record_get_key(rec);
     431        if (key.dptr == NULL || key.dsize == 0) {
    407432                return 0;
    408433        }
    409434
    410         keyname = strchr((const char *) rec->key.dptr, '/');
     435        value = dbwrap_record_get_value(rec);
     436
     437        if (db == NULL) {
     438                DEBUG(0, ("regdb_normalize_keynames_fn: ERROR: "
     439                          "NULL db context handed in via private_data\n"));
     440                return 1;
     441        }
     442
     443        if (strncmp((const char *)key.dptr, REGDB_VERSION_KEYNAME,
     444            strlen(REGDB_VERSION_KEYNAME)) == 0)
     445        {
     446                return 0;
     447        }
     448
     449        keyname = strchr((const char *)key.dptr, '/');
    411450        if (keyname) {
    412                 struct db_record new_rec;
    413 
    414451                keyname = talloc_string_sub(mem_ctx,
    415                                             (const char *) rec->key.dptr,
     452                                            (const char *)key.dptr,
    416453                                            "/",
    417454                                            "\\");
    418455
    419456                DEBUG(2, ("regdb_normalize_keynames_fn: Convert %s to %s\n",
    420                           (const char *) rec->key.dptr,
     457                          (const char *)key.dptr,
    421458                          keyname));
    422459
    423                 new_rec.value = rec->value;
    424                 new_rec.key = string_term_tdb_data(keyname);
    425                 new_rec.private_data = rec->private_data;
    426 
    427460                /* Delete the original record and store the normalized key */
    428                 status = rec->delete_rec(rec);
     461                status = dbwrap_record_delete(rec);
    429462                if (!NT_STATUS_IS_OK(status)) {
    430463                        DEBUG(0,("regdb_normalize_keynames_fn: "
    431464                                 "tdb_delete for [%s] failed!\n",
    432                                  rec->key.dptr));
     465                                 (const char *)key.dptr));
    433466                        return 1;
    434467                }
    435468
    436                 status = rec->store(&new_rec, new_rec.value, TDB_REPLACE);
     469                status = dbwrap_store_bystring(db, keyname, value, TDB_REPLACE);
    437470                if (!NT_STATUS_IS_OK(status)) {
    438471                        DEBUG(0,("regdb_normalize_keynames_fn: "
     
    446479}
    447480
    448 static WERROR regdb_store_regdb_version(uint32_t version)
     481static WERROR regdb_store_regdb_version(struct db_context *db, uint32_t version)
    449482{
    450483        NTSTATUS status;
    451         const char *version_keyname = "INFO/version";
    452 
    453         if (!regdb) {
     484        if (db == NULL) {
    454485                return WERR_CAN_NOT_COMPLETE;
    455486        }
    456487
    457         status = dbwrap_trans_store_int32(regdb, version_keyname, version);
     488        status = dbwrap_trans_store_int32_bystring(db, REGDB_VERSION_KEYNAME,
     489                                                   version);
    458490        if (!NT_STATUS_IS_OK(status)) {
    459491                DEBUG(1, ("regdb_store_regdb_version: error storing %s = %d: %s\n",
    460                           version_keyname, version, nt_errstr(status)));
     492                          REGDB_VERSION_KEYNAME, version, nt_errstr(status)));
    461493                return ntstatus_to_werror(status);
    462494        } else {
    463495                DEBUG(10, ("regdb_store_regdb_version: stored %s = %d\n",
    464                           version_keyname, version));
     496                          REGDB_VERSION_KEYNAME, version));
    465497                return WERR_OK;
    466498        }
    467499}
    468500
    469 static WERROR regdb_upgrade_v1_to_v2(void)
     501static WERROR regdb_upgrade_v1_to_v2(struct db_context *db)
    470502{
    471503        TALLOC_CTX *mem_ctx;
    472         int rc;
     504        NTSTATUS status;
    473505        WERROR werr;
    474506
    475507        mem_ctx = talloc_stackframe();
    476         if (mem_ctx == NULL) {
    477                 return WERR_NOMEM;
    478         }
    479 
    480         rc = regdb->traverse(regdb, regdb_normalize_keynames_fn, mem_ctx);
    481 
    482         talloc_destroy(mem_ctx);
    483 
    484         if (rc == -1) {
    485                 return WERR_REG_IO_FAILURE;
    486         }
    487 
    488         werr = regdb_store_regdb_version(REGVER_V2);
     508
     509        status = dbwrap_traverse(db, regdb_normalize_keynames_fn, db, NULL);
     510        if (!NT_STATUS_IS_OK(status)) {
     511                werr = WERR_REG_IO_FAILURE;
     512                goto done;
     513        }
     514
     515        werr = regdb_store_regdb_version(db, REGDB_VERSION_V2);
     516
     517done:
     518        talloc_free(mem_ctx);
     519        return werr;
     520}
     521
     522static bool tdb_data_read_uint32(TDB_DATA *buf, uint32_t *result)
     523{
     524        const size_t len = sizeof(uint32_t);
     525        if (buf->dsize >= len) {
     526                *result = IVAL(buf->dptr, 0);
     527                buf->dptr += len;
     528                buf->dsize -= len;
     529                return true;
     530        }
     531        return false;
     532}
     533
     534static bool tdb_data_read_cstr(TDB_DATA *buf, char **result)
     535{
     536        const size_t len = strnlen((char*)buf->dptr, buf->dsize) + 1;
     537        if (buf->dsize >= len) {
     538                *result = (char*)buf->dptr;
     539                buf->dptr += len;
     540                buf->dsize -= len;
     541                return true;
     542        }
     543        return false;
     544}
     545
     546static bool tdb_data_is_cstr(TDB_DATA d) {
     547        if (tdb_data_is_empty(d) || (d.dptr[d.dsize-1] != '\0')) {
     548                return false;
     549        }
     550        return strlen((char *)d.dptr) == (d.dsize-1);
     551}
     552
     553static bool upgrade_v2_to_v3_check_subkeylist(struct db_context *db,
     554                                              const char *key,
     555                                              const char *subkey)
     556{
     557        static uint32_t zero = 0;
     558        static TDB_DATA empty_subkey_list = {
     559                .dptr = (unsigned char*)&zero,
     560                .dsize = sizeof(uint32_t),
     561        };
     562        bool success = false;
     563        char *path = talloc_asprintf(talloc_tos(), "%s\\%s", key, subkey);
     564        if (!strupper_m(path)) {
     565                goto done;
     566        }
     567
     568        if (!dbwrap_exists(db, string_term_tdb_data(path))) {
     569                NTSTATUS status;
     570
     571                DEBUG(10, ("regdb_upgrade_v2_to_v3: writing subkey list [%s]\n",
     572                           path));
     573
     574                status = dbwrap_store_bystring(db, path, empty_subkey_list,
     575                                               TDB_INSERT);
     576                if (!NT_STATUS_IS_OK(status)) {
     577                        DEBUG(0, ("regdb_upgrade_v2_to_v3: writing subkey list "
     578                                  "[%s] failed\n", path));
     579                        goto done;
     580                }
     581        }
     582        success = true;
     583done:
     584        talloc_free(path);
     585        return success;
     586}
     587
     588static bool upgrade_v2_to_v3_check_parent(struct db_context *db,
     589                                          const char *key)
     590{
     591        const char *sep = strrchr_m(key, '\\');
     592        if (sep != NULL) {
     593                char *pkey = talloc_strndup(talloc_tos(), key, sep-key);
     594                if (!dbwrap_exists(db, string_term_tdb_data(pkey))) {
     595                        DEBUG(0, ("regdb_upgrade_v2_to_v3: missing subkey list "
     596                                  "[%s]\nrun \"net registry check\"\n", pkey));
     597                }
     598                talloc_free(pkey);
     599        }
     600        return true;
     601}
     602
     603
     604#define IS_EQUAL(d,s) (((d).dsize == strlen(s)+1) &&    \
     605                       (strcmp((char*)(d).dptr, (s)) == 0))
     606#define STARTS_WITH(d,s) (((d).dsize > strlen(s)) &&                    \
     607                          (strncmp((char*)(d).dptr, (s), strlen(s)) == 0))
     608#define SSTR(d) (int)(d).dsize , (char*)(d).dptr
     609
     610
     611static int regdb_upgrade_v2_to_v3_fn(struct db_record *rec, void *private_data)
     612{
     613        struct db_context *db = (struct db_context *)private_data;
     614        TDB_DATA key = dbwrap_record_get_key(rec);
     615        TDB_DATA val = dbwrap_record_get_value(rec);
     616
     617        if (tdb_data_is_empty(key)) {
     618                return 0;
     619        }
     620
     621        if (db == NULL) {
     622                DEBUG(0, ("regdb_upgrade_v2_to_v3_fn: ERROR: "
     623                          "NULL db context handed in via private_data\n"));
     624                return 1;
     625        }
     626
     627        if (IS_EQUAL(key, REGDB_VERSION_KEYNAME) ||
     628            STARTS_WITH(key, REG_VALUE_PREFIX) ||
     629            STARTS_WITH(key, REG_SECDESC_PREFIX))
     630        {
     631                DEBUG(10, ("regdb_upgrade_v2_to_v3: skipping [%.*s]\n",
     632                           SSTR(key)));
     633                return 0;
     634        }
     635
     636        if (STARTS_WITH(key, REG_SORTED_SUBKEYS_PREFIX)) {
     637                NTSTATUS status;
     638                /* Delete the deprecated sorted subkeys cache. */
     639
     640                DEBUG(10, ("regdb_upgrade_v2_to_v3: deleting [%.*s]\n",
     641                           SSTR(key)));
     642
     643                status = dbwrap_record_delete(rec);
     644                if (!NT_STATUS_IS_OK(status)) {
     645                        DEBUG(0, ("regdb_upgrade_v2_to_v3: deleting [%.*s] "
     646                                  "failed!\n", SSTR(key)));
     647                        return 1;
     648                }
     649
     650                return 0;
     651        }
     652
     653        if ( tdb_data_is_cstr(key) &&
     654             hive_info((char*)key.dptr) != NULL )
     655        {
     656                /*
     657                 * Found a regular subkey list record.
     658                 * Walk the list and create the list record for those
     659                 * subkeys that don't already have one.
     660                 */
     661                TDB_DATA pos = val;
     662                char *subkey, *path = (char*)key.dptr;
     663                uint32_t num_items, found_items = 0;
     664
     665
     666                DEBUG(10, ("regdb_upgrade_v2_to_v3: scanning subkeylist of "
     667                           "[%s]\n", path));
     668
     669                if (!tdb_data_read_uint32(&pos, &num_items)) {
     670                        /* invalid or empty - skip */
     671                        return 0;
     672                }
     673
     674                while (tdb_data_read_cstr(&pos, &subkey)) {
     675                        found_items++;
     676
     677                        if (!upgrade_v2_to_v3_check_subkeylist(db, path, subkey))
     678                        {
     679                                return 1;
     680                        }
     681
     682                        if (!upgrade_v2_to_v3_check_parent(db, path)) {
     683                                return 1;
     684                        }
     685                }
     686                if (found_items != num_items) {
     687                        DEBUG(0, ("regdb_upgrade_v2_to_v3: inconsistent subkey "
     688                                  "list [%s]\nrun \"net registry check\"\n",
     689                                  path));
     690                }
     691        } else {
     692                DEBUG(10, ("regdb_upgrade_v2_to_v3: skipping invalid [%.*s]\n"
     693                           "run \"net registry check\"\n", SSTR(key)));
     694        }
     695
     696        return 0;
     697}
     698
     699static WERROR regdb_upgrade_v2_to_v3(struct db_context *db)
     700{
     701        NTSTATUS status;
     702        WERROR werr;
     703
     704        status = dbwrap_traverse(db, regdb_upgrade_v2_to_v3_fn, db, NULL);
     705        if (!NT_STATUS_IS_OK(status)) {
     706                werr = WERR_REG_IO_FAILURE;
     707                goto done;
     708        }
     709
     710        werr = regdb_store_regdb_version(db, REGDB_VERSION_V3);
     711
     712done:
    489713        return werr;
    490714}
     
    496720WERROR regdb_init(void)
    497721{
    498         const char *vstring = "INFO/version";
    499         uint32 vers_id, expected_version;
     722        int32_t vers_id;
    500723        WERROR werr;
     724        NTSTATUS status;
     725        char *db_path;
    501726
    502727        if (regdb) {
     
    507732        }
    508733
    509         regdb = db_open(NULL, state_path("registry.tdb"), 0,
    510                               REG_TDB_FLAGS, O_RDWR, 0600);
     734        db_path = state_path("registry.tdb");
     735        if (db_path == NULL) {
     736                return WERR_NOMEM;
     737        }
     738
     739        regdb = db_open(NULL, db_path, 0,
     740                        REG_TDB_FLAGS, O_RDWR, 0600,
     741                        DBWRAP_LOCK_ORDER_1, REG_DBWRAP_FLAGS);
    511742        if (!regdb) {
    512                 regdb = db_open(NULL, state_path("registry.tdb"), 0,
    513                                       REG_TDB_FLAGS, O_RDWR|O_CREAT, 0600);
     743                regdb = db_open(NULL, db_path, 0,
     744                                REG_TDB_FLAGS, O_RDWR|O_CREAT, 0600,
     745                                DBWRAP_LOCK_ORDER_1, REG_DBWRAP_FLAGS);
    514746                if (!regdb) {
    515747                        werr = ntstatus_to_werror(map_nt_error_from_unix(errno));
    516748                        DEBUG(1,("regdb_init: Failed to open registry %s (%s)\n",
    517                                 state_path("registry.tdb"), strerror(errno) ));
     749                                db_path, strerror(errno) ));
     750                        TALLOC_FREE(db_path);
    518751                        return werr;
    519752                }
    520753
     754                werr = regdb_store_regdb_version(regdb, REGDB_CODE_VERSION);
     755                if (!W_ERROR_IS_OK(werr)) {
     756                        DEBUG(1, ("regdb_init: Failed to store version: %s\n",
     757                                  win_errstr(werr)));
     758                        TALLOC_FREE(db_path);
     759                        return werr;
     760                }
     761
    521762                DEBUG(10,("regdb_init: Successfully created registry tdb\n"));
    522763        }
     764        TALLOC_FREE(db_path);
    523765
    524766        regdb_refcount = 1;
     
    526768                   regdb_refcount));
    527769
    528         expected_version = REGVER_V2;
    529 
    530         vers_id = dbwrap_fetch_int32(regdb, vstring);
    531         if (vers_id == -1) {
     770        status = dbwrap_fetch_int32_bystring(regdb, REGDB_VERSION_KEYNAME,
     771                                             &vers_id);
     772        if (!NT_STATUS_IS_OK(status)) {
    532773                DEBUG(10, ("regdb_init: registry version uninitialized "
    533774                           "(got %d), initializing to version %d\n",
    534                            vers_id, expected_version));
    535 
    536                 werr = regdb_store_regdb_version(expected_version);
    537                 return werr;
    538         }
    539 
    540         if (vers_id > expected_version || vers_id == 0) {
    541                 DEBUG(1, ("regdb_init: unknown registry version %d "
     775                           vers_id, REGDB_VERSION_V1));
     776
     777                /*
     778                 * There was a regdb format version prior to version 1
     779                 * which did not store a INFO/version key. The format
     780                 * of this version was identical to version 1 except for
     781                 * the lack of the sorted subkey cache records.
     782                 * Since these are disposable, we can safely assume version
     783                 * 1 if no INFO/version key is found and run the db through
     784                 * the whole chain of upgrade. If the database was not
     785                 * initialized, this does not harm. If it was the unversioned
     786                 * version ("0"), then it do the right thing with the records.
     787                 */
     788                werr = regdb_store_regdb_version(regdb, REGDB_VERSION_V1);
     789                if (!W_ERROR_IS_OK(werr)) {
     790                        return werr;
     791                }
     792                vers_id = REGDB_VERSION_V1;
     793        }
     794
     795        if (vers_id == REGDB_CODE_VERSION) {
     796                return WERR_OK;
     797        }
     798
     799        if (vers_id > REGDB_CODE_VERSION || vers_id == 0) {
     800                DEBUG(0, ("regdb_init: unknown registry version %d "
    542801                          "(code version = %d), refusing initialization\n",
    543                           vers_id, expected_version));
     802                          vers_id, REGDB_CODE_VERSION));
    544803                return WERR_CAN_NOT_COMPLETE;
    545804        }
    546805
    547         if (vers_id == REGVER_V1) {
    548                 DEBUG(10, ("regdb_init: got registry db version %d, upgrading "
    549                            "to version %d\n", REGVER_V1, REGVER_V2));
    550 
    551                 if (regdb->transaction_start(regdb) != 0) {
    552                         return WERR_REG_IO_FAILURE;
    553                 }
    554 
    555                 werr = regdb_upgrade_v1_to_v2();
     806        if (dbwrap_transaction_start(regdb) != 0) {
     807                return WERR_REG_IO_FAILURE;
     808        }
     809
     810        if (vers_id == REGDB_VERSION_V1) {
     811                DEBUG(10, ("regdb_init: upgrading registry from version %d "
     812                           "to %d\n", REGDB_VERSION_V1, REGDB_VERSION_V2));
     813
     814                werr = regdb_upgrade_v1_to_v2(regdb);
    556815                if (!W_ERROR_IS_OK(werr)) {
    557                         regdb->transaction_cancel(regdb);
     816                        dbwrap_transaction_cancel(regdb);
    558817                        return werr;
    559818                }
    560819
    561                 if (regdb->transaction_commit(regdb) != 0) {
    562                         return WERR_REG_IO_FAILURE;
    563                 }
    564 
    565                 vers_id = REGVER_V2;
     820                vers_id = REGDB_VERSION_V2;
     821        }
     822
     823        if (vers_id == REGDB_VERSION_V2) {
     824                DEBUG(10, ("regdb_init: upgrading registry from version %d "
     825                           "to %d\n", REGDB_VERSION_V2, REGDB_VERSION_V3));
     826
     827                werr = regdb_upgrade_v2_to_v3(regdb);
     828                if (!W_ERROR_IS_OK(werr)) {
     829                        dbwrap_transaction_cancel(regdb);
     830                        return werr;
     831                }
     832
     833                vers_id = REGDB_VERSION_V3;
    566834        }
    567835
    568836        /* future upgrade code should go here */
     837
     838        if (dbwrap_transaction_commit(regdb) != 0) {
     839                return WERR_REG_IO_FAILURE;
     840        }
    569841
    570842        return WERR_OK;
     
    578850{
    579851        WERROR result = WERR_OK;
     852        char *db_path;
     853        int saved_errno;
    580854
    581855        if ( regdb ) {
     
    586860        }
    587861
     862        db_path = state_path("registry.tdb");
     863        if (db_path == NULL) {
     864                return WERR_NOMEM;
     865        }
     866
    588867        become_root();
    589868
    590         regdb = db_open(NULL, state_path("registry.tdb"), 0,
    591                               REG_TDB_FLAGS, O_RDWR, 0600);
     869        regdb = db_open(NULL, db_path, 0,
     870                        REG_TDB_FLAGS, O_RDWR, 0600,
     871                        DBWRAP_LOCK_ORDER_1, REG_DBWRAP_FLAGS);
     872        saved_errno = errno;
     873        unbecome_root();
    592874        if ( !regdb ) {
    593                 result = ntstatus_to_werror( map_nt_error_from_unix( errno ) );
     875                result = ntstatus_to_werror(map_nt_error_from_unix(saved_errno));
    594876                DEBUG(0,("regdb_open: Failed to open %s! (%s)\n",
    595                         state_path("registry.tdb"), strerror(errno) ));
    596         }
    597 
    598         unbecome_root();
     877                         db_path, strerror(saved_errno)));
     878                TALLOC_FREE(db_path);
     879                return result;
     880        }
     881        TALLOC_FREE(db_path);
    599882
    600883        regdb_refcount = 1;
     
    602885                   regdb_refcount));
    603886
    604         return result;
     887        return WERR_OK;
    605888}
    606889
     
    630913WERROR regdb_transaction_start(void)
    631914{
    632         return (regdb->transaction_start(regdb) == 0) ?
     915        return (dbwrap_transaction_start(regdb) == 0) ?
    633916                WERR_OK : WERR_REG_IO_FAILURE;
    634917}
     
    636919WERROR regdb_transaction_commit(void)
    637920{
    638         return (regdb->transaction_commit(regdb) == 0) ?
     921        return (dbwrap_transaction_commit(regdb) == 0) ?
    639922                WERR_OK : WERR_REG_IO_FAILURE;
    640923}
     
    642925WERROR regdb_transaction_cancel(void)
    643926{
    644         return (regdb->transaction_cancel(regdb) == 0) ?
     927        return (dbwrap_transaction_cancel(regdb) == 0) ?
    645928                WERR_OK : WERR_REG_IO_FAILURE;
    646929}
     
    653936int regdb_get_seqnum(void)
    654937{
    655         return regdb->get_seqnum(regdb);
     938        return dbwrap_get_seqnum(regdb);
    656939}
    657940
     
    684967        }
    685968
    686         werr = ntstatus_to_werror(dbwrap_delete_bystring(db, path));
    687 
    688         /* treat "not" found" as ok */
    689         if (W_ERROR_EQUAL(werr, WERR_NOT_FOUND)) {
    690                 werr = WERR_OK;
    691         }
     969        werr = ntstatus_to_werror(dbwrap_purge_bystring(db, path));
    692970
    693971done:
     
    711989        return regdb_delete_key_with_prefix(db, keyname, NULL);
    712990}
     991
    713992
    714993static WERROR regdb_delete_key_lists(struct db_context *db, const char *keyname)
     
    7521031{
    7531032        TDB_DATA dbuf;
    754         uint8 *buffer = NULL;
     1033        uint8_t *buffer = NULL;
    7551034        int i = 0;
    756         uint32 len, buflen;
    757         uint32 num_subkeys = regsubkey_ctr_numkeys(ctr);
     1035        uint32_t len, buflen;
     1036        uint32_t num_subkeys = regsubkey_ctr_numkeys(ctr);
    7581037        char *keyname = NULL;
    7591038        TALLOC_CTX *ctx = talloc_stackframe();
     
    7791058        /* allocate some initial memory */
    7801059
    781         buffer = (uint8 *)SMB_MALLOC(1024);
     1060        buffer = (uint8_t *)SMB_MALLOC(1024);
    7821061        if (buffer == NULL) {
    7831062                werr = WERR_NOMEM;
     
    8321111        werr = ntstatus_to_werror(dbwrap_store_bystring(db, keyname, dbuf,
    8331112                                                        TDB_REPLACE));
    834         W_ERROR_NOT_OK_GOTO_DONE(werr);
    835 
    836         /*
    837          * recreate the sorted subkey cache for regdb_key_exists()
    838          */
    839         werr = ntstatus_to_werror(create_sorted_subkeys(keyname));
    8401113
    8411114done:
    8421115        TALLOC_FREE(ctx);
    8431116        SAFE_FREE(buffer);
     1117        return werr;
     1118}
     1119
     1120/**
     1121 * Utility function to store a new empty list of
     1122 * subkeys of given key specified as parent and subkey name
     1123 * (thereby creating the key).
     1124 * If the parent keyname is NULL, then the "subkey" is
     1125 * interpreted as a base key.
     1126 * If the subkey list does already exist, it is not modified.
     1127 *
     1128 * Must be called from within a transaction.
     1129 */
     1130static WERROR regdb_store_subkey_list(struct db_context *db, const char *parent,
     1131                                      const char *key)
     1132{
     1133        WERROR werr;
     1134        char *path = NULL;
     1135        struct regsubkey_ctr *subkeys = NULL;
     1136        TALLOC_CTX *frame = talloc_stackframe();
     1137
     1138        if (parent == NULL) {
     1139                path = talloc_strdup(frame, key);
     1140        } else {
     1141                path = talloc_asprintf(frame, "%s\\%s", parent, key);
     1142        }
     1143        if (!path) {
     1144                werr = WERR_NOMEM;
     1145                goto done;
     1146        }
     1147
     1148        werr = regsubkey_ctr_init(frame, &subkeys);
     1149        W_ERROR_NOT_OK_GOTO_DONE(werr);
     1150
     1151        werr = regdb_fetch_keys_internal(db, path, subkeys);
     1152        if (W_ERROR_IS_OK(werr)) {
     1153                /* subkey list exists already - don't modify */
     1154                goto done;
     1155        }
     1156
     1157        werr = regsubkey_ctr_reinit(subkeys);
     1158        W_ERROR_NOT_OK_GOTO_DONE(werr);
     1159
     1160        /* create a record with 0 subkeys */
     1161        werr = regdb_store_keys_internal2(db, path, subkeys);
     1162        if (!W_ERROR_IS_OK(werr)) {
     1163                DEBUG(0, ("regdb_store_keys: Failed to store new record for "
     1164                          "key [%s]: %s\n", path, win_errstr(werr)));
     1165                goto done;
     1166        }
     1167
     1168done:
     1169        talloc_free(frame);
    8441170        return werr;
    8451171}
     
    8621188        int num_subkeys, i;
    8631189        char *path = NULL;
    864         struct regsubkey_ctr *subkeys = NULL, *old_subkeys = NULL;
     1190        struct regsubkey_ctr *old_subkeys = NULL;
    8651191        char *oldkeyname = NULL;
    8661192        TALLOC_CTX *mem_ctx = talloc_stackframe();
     
    9451271        num_subkeys = regsubkey_ctr_numkeys(store_ctx->ctr);
    9461272
    947         if (num_subkeys == 0) {
    948                 werr = regsubkey_ctr_init(mem_ctx, &subkeys);
     1273        for (i=0; i<num_subkeys; i++) {
     1274                const char *subkey;
     1275
     1276                subkey = regsubkey_ctr_specific_key(store_ctx->ctr, i);
     1277
     1278                werr = regdb_store_subkey_list(db, store_ctx->key, subkey);
    9491279                W_ERROR_NOT_OK_GOTO_DONE(werr);
    950 
    951                 werr = regdb_store_keys_internal2(db, store_ctx->key, subkeys);
    952                 if (!W_ERROR_IS_OK(werr)) {
    953                         DEBUG(0,("regdb_store_keys: Failed to store "
    954                                  "new record for key [%s]: %s\n",
    955                                  store_ctx->key, win_errstr(werr)));
    956                         goto done;
    957                 }
    958                 TALLOC_FREE(subkeys);
    959         }
    960 
    961         for (i=0; i<num_subkeys; i++) {
    962                 path = talloc_asprintf(mem_ctx, "%s\\%s", store_ctx->key,
    963                                 regsubkey_ctr_specific_key(store_ctx->ctr, i));
    964                 if (!path) {
    965                         werr = WERR_NOMEM;
    966                         goto done;
    967                 }
    968                 werr = regsubkey_ctr_init(mem_ctx, &subkeys);
    969                 W_ERROR_NOT_OK_GOTO_DONE(werr);
    970 
    971                 werr = regdb_fetch_keys_internal(db, path, subkeys);
    972                 if (!W_ERROR_IS_OK(werr)) {
    973                         /* create a record with 0 subkeys */
    974                         werr = regdb_store_keys_internal2(db, path, subkeys);
    975                         if (!W_ERROR_IS_OK(werr)) {
    976                                 DEBUG(0,("regdb_store_keys: Failed to store "
    977                                          "new record for key [%s]: %s\n", path,
    978                                          win_errstr(werr)));
    979                                 goto done;
    980                         }
    981                 }
    982 
    983                 TALLOC_FREE(subkeys);
    984                 TALLOC_FREE(path);
    9851280        }
    9861281
     
    9891284         * prevent next read from going to disk
    9901285         */
    991         werr = regsubkey_ctr_set_seqnum(store_ctx->ctr, db->get_seqnum(db));
     1286        werr = regsubkey_ctr_set_seqnum(store_ctx->ctr, dbwrap_get_seqnum(db));
    9921287
    9931288done:
     
    10061301        struct regdb_store_keys_context store_ctx;
    10071302
    1008         if (!regdb_key_is_base_key(key) && !regdb_key_exists(db, key)) {
     1303        if (!regdb_key_exists(db, key)) {
    10091304                goto done;
    10101305        }
     
    10571352        store_ctx.ctr = ctr;
    10581353
    1059         werr = ntstatus_to_werror(dbwrap_trans_do(db,
    1060                                                   regdb_store_keys_action,
    1061                                                   &store_ctx));
     1354        werr = regdb_trans_do(db,
     1355                              regdb_store_keys_action,
     1356                              &store_ctx);
    10621357
    10631358        ret = W_ERROR_IS_OK(werr);
     
    10691364}
    10701365
    1071 bool regdb_store_keys(const char *key, struct regsubkey_ctr *ctr)
     1366static bool regdb_store_keys(const char *key, struct regsubkey_ctr *ctr)
    10721367{
    10731368        return regdb_store_keys_internal(regdb, key, ctr);
     
    11091404        }
    11101405
     1406        werr = regdb_store_subkey_list(db, create_ctx->key, create_ctx->subkey);
     1407
    11111408done:
    11121409        talloc_free(mem_ctx);
     
    11141411}
    11151412
    1116 static WERROR regdb_create_subkey(const char *key, const char *subkey)
     1413static WERROR regdb_create_subkey_internal(struct db_context *db,
     1414                                           const char *key,
     1415                                           const char *subkey)
    11171416{
    11181417        WERROR werr;
     
    11211420        struct regdb_create_subkey_context create_ctx;
    11221421
    1123         if (!regdb_key_is_base_key(key) && !regdb_key_exists(regdb, key)) {
     1422        if (!regdb_key_exists(db, key)) {
    11241423                werr = WERR_NOT_FOUND;
    11251424                goto done;
     
    11291428        W_ERROR_NOT_OK_GOTO_DONE(werr);
    11301429
    1131         werr = regdb_fetch_keys_internal(regdb, key, subkeys);
     1430        werr = regdb_fetch_keys_internal(db, key, subkeys);
    11321431        W_ERROR_NOT_OK_GOTO_DONE(werr);
    11331432
    11341433        if (regsubkey_ctr_key_exists(subkeys, subkey)) {
    1135                 werr = WERR_OK;
    1136                 goto done;
     1434                char *newkey;
     1435
     1436                newkey = talloc_asprintf(mem_ctx, "%s\\%s", key, subkey);
     1437                if (newkey == NULL) {
     1438                        werr = WERR_NOMEM;
     1439                        goto done;
     1440                }
     1441
     1442                if (regdb_key_exists(db, newkey)) {
     1443                        werr = WERR_OK;
     1444                        goto done;
     1445                }
    11371446        }
    11381447
     
    11421451        create_ctx.subkey = subkey;
    11431452
    1144         werr = ntstatus_to_werror(dbwrap_trans_do(regdb,
    1145                                                   regdb_create_subkey_action,
    1146                                                   &create_ctx));
     1453        werr = regdb_trans_do(db,
     1454                              regdb_create_subkey_action,
     1455                              &create_ctx);
    11471456
    11481457done:
    11491458        talloc_free(mem_ctx);
     1459        return werr;
     1460}
     1461
     1462static WERROR regdb_create_subkey(const char *key, const char *subkey)
     1463{
     1464        return regdb_create_subkey_internal(regdb, key, subkey);
     1465}
     1466
     1467/**
     1468 * create a base key
     1469 */
     1470
     1471struct regdb_create_basekey_context {
     1472        const char *key;
     1473};
     1474
     1475static NTSTATUS regdb_create_basekey_action(struct db_context *db,
     1476                                            void *private_data)
     1477{
     1478        WERROR werr;
     1479        struct regdb_create_basekey_context *create_ctx;
     1480
     1481        create_ctx = (struct regdb_create_basekey_context *)private_data;
     1482
     1483        werr = regdb_store_subkey_list(db, NULL, create_ctx->key);
     1484
     1485        return werror_to_ntstatus(werr);
     1486}
     1487
     1488static WERROR regdb_create_basekey(struct db_context *db, const char *key)
     1489{
     1490        WERROR werr;
     1491        struct regdb_create_subkey_context create_ctx;
     1492
     1493        create_ctx.key = key;
     1494
     1495        werr = regdb_trans_do(db,
     1496                              regdb_create_basekey_action,
     1497                              &create_ctx);
     1498
    11501499        return werr;
    11511500}
     
    11591508        const char *subkey;
    11601509        const char *path;
     1510        bool lazy;
    11611511};
    11621512
     
    11731523        werr = regdb_delete_key_lists(db, delete_ctx->path);
    11741524        W_ERROR_NOT_OK_GOTO_DONE(werr);
     1525
     1526        if (delete_ctx->lazy) {
     1527                goto done;
     1528        }
    11751529
    11761530        werr = regsubkey_ctr_init(mem_ctx, &subkeys);
     
    11951549}
    11961550
    1197 static WERROR regdb_delete_subkey(const char *key, const char *subkey)
     1551static WERROR regdb_delete_subkey(const char *key, const char *subkey, bool lazy)
    11981552{
    11991553        WERROR werr;
     
    12021556        TALLOC_CTX *mem_ctx = talloc_stackframe();
    12031557
    1204         if (!regdb_key_is_base_key(key) && !regdb_key_exists(regdb, key)) {
     1558        if (!regdb_key_exists(regdb, key)) {
    12051559                werr = WERR_NOT_FOUND;
    12061560                goto done;
     
    12211575        delete_ctx.subkey = subkey;
    12221576        delete_ctx.path = path;
    1223 
    1224         werr = ntstatus_to_werror(dbwrap_trans_do(regdb,
    1225                                                   regdb_delete_subkey_action,
    1226                                                   &delete_ctx));
     1577        delete_ctx.lazy = lazy;
     1578
     1579        werr = regdb_trans_do(regdb,
     1580                              regdb_delete_subkey_action,
     1581                              &delete_ctx);
    12271582
    12281583done:
     
    12361591        char *path = NULL;
    12371592        TDB_DATA data;
     1593        NTSTATUS status;
    12381594
    12391595        path = normalize_reg_path(mem_ctx, key);
     
    12421598        }
    12431599
    1244         data = dbwrap_fetch_bystring(db, mem_ctx, path);
     1600        status = dbwrap_fetch_bystring(db, mem_ctx, path, &data);
     1601        if (!NT_STATUS_IS_OK(status)) {
     1602                data = tdb_null;
     1603        }
    12451604
    12461605        TALLOC_FREE(path);
     
    12501609
    12511610/**
    1252  * check whether a given key name represents a base key,
    1253  * i.e one without a subkey separator ('\').
     1611 * Check for the existence of a key.
     1612 *
     1613 * Existence of a key is authoritatively defined by
     1614 * the existence of the record that contains the list
     1615 * of its subkeys.
     1616 *
     1617 * Return false, if the record does not match the correct
     1618 * structure of an initial 4-byte counter and then a
     1619 * list of the corresponding number of zero-terminated
     1620 * strings.
    12541621 */
    1255 static bool regdb_key_is_base_key(const char *key)
     1622static bool regdb_key_exists(struct db_context *db, const char *key)
    12561623{
    12571624        TALLOC_CTX *mem_ctx = talloc_stackframe();
     1625        TDB_DATA value;
    12581626        bool ret = false;
    12591627        char *path;
     1628        uint32_t buflen;
     1629        const char *buf;
     1630        uint32_t num_items, i;
     1631        int32_t len;
    12601632
    12611633        if (key == NULL) {
     
    12731645        }
    12741646
    1275         ret = (strrchr(path, '\\') == NULL);
    1276 
    1277 done:
    1278         TALLOC_FREE(mem_ctx);
    1279         return ret;
    1280 }
    1281 
    1282 /*
    1283  * regdb_key_exists() is a very frequent operation. It can be quite
    1284  * time-consuming to fully fetch the parent's subkey list, talloc_strdup all
    1285  * subkeys and then compare the keyname linearly to all the parent's subkeys.
    1286  *
    1287  * The following code tries to make this operation as efficient as possible:
    1288  * Per registry key we create a list of subkeys that is very efficient to
    1289  * search for existence of a subkey. Its format is:
    1290  *
    1291  * 4 bytes num_subkeys
    1292  * 4*num_subkey bytes offset into the string array
    1293  * then follows a sorted list of subkeys in uppercase
    1294  *
    1295  * This record is created by create_sorted_subkeys() on demand if it does not
    1296  * exist. scan_parent_subkeys() uses regdb->parse_record to search the sorted
    1297  * list, the parsing code and the binary search can be found in
    1298  * parent_subkey_scanner. The code uses parse_record() to avoid a memcpy of
    1299  * the potentially large subkey record.
    1300  *
    1301  * The sorted subkey record is deleted in regdb_store_keys_internal2 and
    1302  * recreated on demand.
    1303  */
    1304 
    1305 static int cmp_keynames(char **p1, char **p2)
    1306 {
    1307         return StrCaseCmp(*p1, *p2);
    1308 }
    1309 
    1310 struct create_sorted_subkeys_context {
    1311         const char *key;
    1312         const char *sorted_keyname;
    1313 };
    1314 
    1315 static NTSTATUS create_sorted_subkeys_action(struct db_context *db,
    1316                                              void *private_data)
    1317 {
    1318         char **sorted_subkeys;
    1319         struct regsubkey_ctr *ctr;
    1320         NTSTATUS status;
    1321         char *buf;
    1322         char *p;
    1323         int i;
    1324         size_t len;
    1325         int num_subkeys;
    1326         struct create_sorted_subkeys_context *sorted_ctx;
    1327 
    1328         sorted_ctx = (struct create_sorted_subkeys_context *)private_data;
     1647        value = regdb_fetch_key_internal(db, mem_ctx, path);
     1648        if (value.dptr == NULL) {
     1649                goto done;
     1650        }
     1651
     1652        if (value.dsize == 0) {
     1653                DEBUG(10, ("regdb_key_exists: subkeylist-record for key "
     1654                          "[%s] is empty: Could be a deleted record in a "
     1655                          "clustered (ctdb) environment?\n",
     1656                          path));
     1657                goto done;
     1658        }
     1659
     1660        len = tdb_unpack(value.dptr, value.dsize, "d", &num_items);
     1661        if (len == (int32_t)-1) {
     1662                DEBUG(1, ("regdb_key_exists: ERROR: subkeylist-record for key "
     1663                          "[%s] is invalid: Could not parse initial 4-byte "
     1664                          "counter. record data length is %u.\n",
     1665                          path, (unsigned int)value.dsize));
     1666                goto done;
     1667        }
    13291668
    13301669        /*
    1331          * In this function, we only treat failing of the actual write to
    1332          * the db as a real error. All preliminary errors, at a stage when
    1333          * nothing has been written to the DB yet are treated as success
    1334          * to be committed (as an empty transaction).
    1335          *
    1336          * The reason is that this (disposable) call might be nested in other
    1337          * transactions. Doing a cancel here would destroy the possibility of
    1338          * a transaction_commit for transactions that we might be wrapped in.
     1670         * Note: the tdb_unpack check above implies that len <= value.dsize
    13391671         */
    1340 
    1341         status = werror_to_ntstatus(regsubkey_ctr_init(talloc_tos(), &ctr));
    1342         if (!NT_STATUS_IS_OK(status)) {
    1343                 /* don't treat this as an error */
    1344                 status = NT_STATUS_OK;
    1345                 goto done;
    1346         }
    1347 
    1348         status = werror_to_ntstatus(regdb_fetch_keys_internal(db,
    1349                                                               sorted_ctx->key,
    1350                                                               ctr));
    1351         if (!NT_STATUS_IS_OK(status)) {
    1352                 /* don't treat this as an error */
    1353                 status = NT_STATUS_OK;
    1354                 goto done;
    1355         }
    1356 
    1357         num_subkeys = regsubkey_ctr_numkeys(ctr);
    1358         sorted_subkeys = talloc_array(ctr, char *, num_subkeys);
    1359         if (sorted_subkeys == NULL) {
    1360                 /* don't treat this as an error */
    1361                 goto done;
    1362         }
    1363 
    1364         len = 4 + 4*num_subkeys;
    1365 
    1366         for (i = 0; i < num_subkeys; i++) {
    1367                 sorted_subkeys[i] = talloc_strdup_upper(sorted_subkeys,
    1368                                         regsubkey_ctr_specific_key(ctr, i));
    1369                 if (sorted_subkeys[i] == NULL) {
    1370                         /* don't treat this as an error */
     1672        buflen = value.dsize - len;
     1673        buf = (const char *)value.dptr + len;
     1674
     1675        len = 0;
     1676
     1677        for (i = 0; i < num_items; i++) {
     1678                if (buflen == 0) {
     1679                        break;
     1680                }
     1681                len = strnlen(buf, buflen) + 1;
     1682                if (buflen < len) {
     1683                        DEBUG(1, ("regdb_key_exists: ERROR: subkeylist-record "
     1684                                  "for key [%s] is corrupt: %u items expected, "
     1685                                  "item number %u is not zero terminated.\n",
     1686                                  path, num_items, i+1));
    13711687                        goto done;
    13721688                }
    1373                 len += strlen(sorted_subkeys[i])+1;
    1374         }
    1375 
    1376         TYPESAFE_QSORT(sorted_subkeys, num_subkeys, cmp_keynames);
    1377 
    1378         buf = talloc_array(ctr, char, len);
    1379         if (buf == NULL) {
    1380                 /* don't treat this as an error */
    1381                 goto done;
    1382         }
    1383         p = buf + 4 + 4*num_subkeys;
    1384 
    1385         SIVAL(buf, 0, num_subkeys);
    1386 
    1387         for (i=0; i < num_subkeys; i++) {
    1388                 ptrdiff_t offset = p - buf;
    1389                 SIVAL(buf, 4 + 4*i, offset);
    1390                 strlcpy(p, sorted_subkeys[i], len-offset);
    1391                 p += strlen(sorted_subkeys[i]) + 1;
    1392         }
    1393 
    1394         status = dbwrap_store_bystring(
    1395                 db, sorted_ctx->sorted_keyname, make_tdb_data((uint8_t *)buf,
    1396                 len),
    1397                 TDB_REPLACE);
    1398 
    1399 done:
    1400         talloc_free(ctr);
    1401         return status;
    1402 }
    1403 
    1404 static NTSTATUS create_sorted_subkeys_internal(const char *key,
    1405                                                const char *sorted_keyname)
    1406 {
    1407         NTSTATUS status;
    1408         struct create_sorted_subkeys_context sorted_ctx;
    1409 
    1410         sorted_ctx.key = key;
    1411         sorted_ctx.sorted_keyname = sorted_keyname;
    1412 
    1413         status = dbwrap_trans_do(regdb,
    1414                                  create_sorted_subkeys_action,
    1415                                  &sorted_ctx);
    1416 
    1417         return status;
    1418 }
    1419 
    1420 static NTSTATUS create_sorted_subkeys(const char *key)
    1421 {
    1422         char *sorted_subkeys_keyname;
    1423         NTSTATUS status;
    1424 
    1425         sorted_subkeys_keyname = talloc_asprintf(talloc_tos(), "%s\\%s",
    1426                                                  REG_SORTED_SUBKEYS_PREFIX,
    1427                                                  key);
    1428         if (sorted_subkeys_keyname == NULL) {
    1429                 status = NT_STATUS_NO_MEMORY;
    1430                 goto done;
    1431         }
    1432 
    1433         status = create_sorted_subkeys_internal(key, sorted_subkeys_keyname);
    1434 
    1435 done:
    1436         return status;
    1437 }
    1438 
    1439 struct scan_subkey_state {
    1440         char *name;
    1441         bool scanned;
    1442         bool found;
    1443 };
    1444 
    1445 static int parent_subkey_scanner(TDB_DATA key, TDB_DATA data,
    1446                                  void *private_data)
    1447 {
    1448         struct scan_subkey_state *state =
    1449                 (struct scan_subkey_state *)private_data;
    1450         uint32_t num_subkeys;
    1451         uint32_t l, u;
    1452 
    1453         if (data.dsize < sizeof(uint32_t)) {
    1454                 return -1;
    1455         }
    1456 
    1457         state->scanned = true;
    1458         state->found = false;
    1459 
    1460         tdb_unpack(data.dptr, data.dsize, "d", &num_subkeys);
    1461 
    1462         l = 0;
    1463         u = num_subkeys;
    1464 
    1465         while (l < u) {
    1466                 uint32_t idx = (l+u)/2;
    1467                 char *s = (char *)data.dptr + IVAL(data.dptr, 4 + 4*idx);
    1468                 int comparison = strcmp(state->name, s);
    1469 
    1470                 if (comparison < 0) {
    1471                         u = idx;
    1472                 } else if (comparison > 0) {
    1473                         l = idx + 1;
    1474                 } else {
    1475                         state->found = true;
    1476                         return 0;
    1477                 }
    1478         }
    1479         return 0;
    1480 }
    1481 
    1482 static bool scan_parent_subkeys(struct db_context *db, const char *parent,
    1483                                 const char *name)
    1484 {
    1485         char *path = NULL;
    1486         char *key = NULL;
    1487         struct scan_subkey_state state = { 0, };
    1488         bool result = false;
    1489         int res;
    1490 
    1491         state.name = NULL;
    1492 
    1493         path = normalize_reg_path(talloc_tos(), parent);
    1494         if (path == NULL) {
    1495                 goto fail;
    1496         }
    1497 
    1498         key = talloc_asprintf(talloc_tos(), "%s\\%s",
    1499                               REG_SORTED_SUBKEYS_PREFIX, path);
    1500         if (key == NULL) {
    1501                 goto fail;
    1502         }
    1503 
    1504         state.name = talloc_strdup_upper(talloc_tos(), name);
    1505         if (state.name == NULL) {
    1506                 goto fail;
    1507         }
    1508         state.scanned = false;
    1509 
    1510         res = db->parse_record(db, string_term_tdb_data(key),
    1511                                parent_subkey_scanner, &state);
    1512 
    1513         if (state.scanned) {
    1514                 result = state.found;
    1515         } else {
    1516                 NTSTATUS status;
    1517 
    1518                 res = db->transaction_start(db);
    1519                 if (res != 0) {
    1520                         DEBUG(0, ("error starting transaction\n"));
    1521                         goto fail;
    1522                 }
    1523 
    1524                 DEBUG(2, (__location__ " WARNING: recreating the sorted "
    1525                           "subkeys cache for key '%s' from scan_parent_subkeys "
    1526                           "this should not happen (too frequently)...\n",
    1527                           path));
    1528 
    1529                 status = create_sorted_subkeys_internal(path, key);
    1530                 if (!NT_STATUS_IS_OK(status)) {
    1531                         res = db->transaction_cancel(db);
    1532                         if (res != 0) {
    1533                                 smb_panic("Failed to cancel transaction.");
    1534                         }
    1535                         goto fail;
    1536                 }
    1537 
    1538                 res = db->parse_record(db, string_term_tdb_data(key),
    1539                                        parent_subkey_scanner, &state);
    1540                 if ((res == 0) && (state.scanned)) {
    1541                         result = state.found;
    1542                 }
    1543 
    1544                 res = db->transaction_commit(db);
    1545                 if (res != 0) {
    1546                         DEBUG(0, ("error committing transaction\n"));
    1547                         result = false;
    1548                 }
    1549         }
    1550 
    1551  fail:
    1552         TALLOC_FREE(path);
    1553         TALLOC_FREE(state.name);
    1554         return result;
    1555 }
    1556 
    1557 /**
    1558  * Check for the existence of a key.
    1559  *
    1560  * Existence of a key is authoritatively defined by its
    1561  * existence in the list of subkeys of its parent key.
    1562  * The exeption of this are keys without a parent key,
    1563  * i.e. the "base" keys (HKLM, HKCU, ...).
    1564  */
    1565 static bool regdb_key_exists(struct db_context *db, const char *key)
    1566 {
    1567         TALLOC_CTX *mem_ctx = talloc_stackframe();
    1568         TDB_DATA value;
    1569         bool ret = false;
    1570         char *path, *p;
    1571 
    1572         if (key == NULL) {
    1573                 goto done;
    1574         }
    1575 
    1576         path = normalize_reg_path(mem_ctx, key);
    1577         if (path == NULL) {
    1578                 DEBUG(0, ("out of memory! (talloc failed)\n"));
    1579                 goto done;
    1580         }
    1581 
    1582         if (*path == '\0') {
    1583                 goto done;
    1584         }
    1585 
    1586         p = strrchr(path, '\\');
    1587         if (p == NULL) {
    1588                 /* this is a base key */
    1589                 value = regdb_fetch_key_internal(db, mem_ctx, path);
    1590                 ret = (value.dptr != NULL);
    1591         } else {
    1592                 *p = '\0';
    1593                 ret = scan_parent_subkeys(db, path, p+1);
    1594         }
     1689
     1690                buf += len;
     1691                buflen -= len;
     1692        }
     1693
     1694        if (buflen > 0) {
     1695                DEBUG(1, ("regdb_key_exists: ERROR: subkeylist-record for key "
     1696                          "[%s] is corrupt: %u items expected and found, but "
     1697                          "the record contains additional %u bytes\n",
     1698                          path, num_items, buflen));
     1699                goto done;
     1700        }
     1701
     1702        if (i < num_items) {
     1703                DEBUG(1, ("regdb_key_exists: ERROR: subkeylist-record for key "
     1704                          "[%s] is corrupt: %u items expected, but only %u "
     1705                          "items found.\n",
     1706                          path, num_items, i+1));
     1707                goto done;
     1708        }
     1709
     1710        ret = true;
    15951711
    15961712done:
     
    16101726        WERROR werr;
    16111727        uint32_t num_items;
    1612         uint8 *buf;
    1613         uint32 buflen, len;
     1728        uint8_t *buf;
     1729        uint32_t buflen, len;
    16141730        int i;
    16151731        fstring subkeyname;
     
    16311747        count = 0;
    16321748        ZERO_STRUCT(value);
    1633         seqnum[0] = db->get_seqnum(db);
     1749        seqnum[0] = dbwrap_get_seqnum(db);
    16341750
    16351751        do {
     
    16371753                TALLOC_FREE(value.dptr);
    16381754                value = regdb_fetch_key_internal(db, frame, key);
    1639                 seqnum[count % 2] = db->get_seqnum(db);
     1755                seqnum[count % 2] = dbwrap_get_seqnum(db);
    16401756
    16411757        } while (seqnum[0] != seqnum[1]);
     
    16841800}
    16851801
    1686 int regdb_fetch_keys(const char *key, struct regsubkey_ctr *ctr)
     1802static int regdb_fetch_keys(const char *key, struct regsubkey_ctr *ctr)
    16871803{
    16881804        WERROR werr;
     
    17001816 ***************************************************************************/
    17011817
    1702 static int regdb_unpack_values(struct regval_ctr *values, uint8 *buf, int buflen)
     1818static int regdb_unpack_values(struct regval_ctr *values, uint8_t *buf, int buflen)
    17031819{
    17041820        int             len = 0;
    1705         uint32          type;
     1821        uint32_t        type;
    17061822        fstring valuename;
    1707         uint32          size;
    1708         uint8           *data_p;
    1709         uint32          num_values = 0;
     1823        uint32_t        size;
     1824        uint8_t         *data_p;
     1825        uint32_t        num_values = 0;
    17101826        int             i;
    17111827
     
    17421858 ***************************************************************************/
    17431859
    1744 static int regdb_pack_values(struct regval_ctr *values, uint8 *buf, int buflen)
     1860static int regdb_pack_values(struct regval_ctr *values, uint8_t *buf, int buflen)
    17451861{
    17461862        int             len = 0;
     
    18031919        ZERO_STRUCT(value);
    18041920        count = 0;
    1805         seqnum[0] = db->get_seqnum(db);
     1921        seqnum[0] = dbwrap_get_seqnum(db);
    18061922
    18071923        do {
     
    18091925                TALLOC_FREE(value.dptr);
    18101926                value = regdb_fetch_key_internal(db, ctx, keystr);
    1811                 seqnum[count % 2] = db->get_seqnum(db);
     1927                seqnum[count % 2] = dbwrap_get_seqnum(db);
    18121928        } while (seqnum[0] != seqnum[1]);
    18131929
     
    18361952}
    18371953
    1838 int regdb_fetch_values(const char* key, struct regval_ctr *values)
     1954static int regdb_fetch_values(const char* key, struct regval_ctr *values)
    18391955{
    18401956        return regdb_fetch_values_internal(regdb, key, values);
    18411957}
    18421958
    1843 static bool regdb_store_values_internal(struct db_context *db, const char *key,
    1844                                         struct regval_ctr *values)
     1959static NTSTATUS regdb_store_values_internal(struct db_context *db,
     1960                                            const char *key,
     1961                                            struct regval_ctr *values)
    18451962{
    18461963        TDB_DATA old_data, data;
     
    18491966        int len;
    18501967        NTSTATUS status;
    1851         bool result = false;
    18521968        WERROR werr;
    18531969
     
    18551971
    18561972        if (!regdb_key_exists(db, key)) {
     1973                status = NT_STATUS_NOT_FOUND;
     1974                goto done;
     1975        }
     1976
     1977        if (regval_ctr_numvals(values) == 0) {
     1978                werr = regdb_delete_values(db, key);
     1979                if (!W_ERROR_IS_OK(werr)) {
     1980                        status = werror_to_ntstatus(werr);
     1981                        goto done;
     1982                }
     1983
     1984                /*
     1985                 * update the seqnum in the cache to prevent the next read
     1986                 * from going to disk
     1987                 */
     1988                werr = regval_ctr_set_seqnum(values, dbwrap_get_seqnum(db));
     1989                status = werror_to_ntstatus(werr);
    18571990                goto done;
    18581991        }
     
    18631996        if (len <= 0) {
    18641997                DEBUG(0,("regdb_store_values: unable to pack values. len <= 0\n"));
    1865                 goto done;
    1866         }
    1867 
    1868         data.dptr = TALLOC_ARRAY(ctx, uint8, len);
     1998                status = NT_STATUS_UNSUCCESSFUL;
     1999                goto done;
     2000        }
     2001
     2002        data.dptr = talloc_array(ctx, uint8_t, len);
    18692003        data.dsize = len;
    18702004
     
    18752009        keystr = talloc_asprintf(ctx, "%s\\%s", REG_VALUE_PREFIX, key );
    18762010        if (!keystr) {
     2011                status = NT_STATUS_NO_MEMORY;
    18772012                goto done;
    18782013        }
    18792014        keystr = normalize_reg_path(ctx, keystr);
    18802015        if (!keystr) {
    1881                 goto done;
    1882         }
    1883 
    1884         old_data = dbwrap_fetch_bystring(db, ctx, keystr);
    1885 
    1886         if ((old_data.dptr != NULL)
     2016                status = NT_STATUS_NO_MEMORY;
     2017                goto done;
     2018        }
     2019
     2020        status = dbwrap_fetch_bystring(db, ctx, keystr, &old_data);
     2021
     2022        if (NT_STATUS_IS_OK(status)
     2023            && (old_data.dptr != NULL)
    18872024            && (old_data.dsize == data.dsize)
    18882025            && (memcmp(old_data.dptr, data.dptr, data.dsize) == 0))
    18892026        {
    1890                 result = true;
     2027                status = NT_STATUS_OK;
    18912028                goto done;
    18922029        }
     
    19022039         * from going to disk
    19032040         */
    1904         werr = regval_ctr_set_seqnum(values, db->get_seqnum(db));
    1905         result = W_ERROR_IS_OK(status);
     2041        werr = regval_ctr_set_seqnum(values, dbwrap_get_seqnum(db));
     2042        status = werror_to_ntstatus(werr);
    19062043
    19072044done:
    19082045        TALLOC_FREE(ctx);
    1909         return result;
    1910 }
    1911 
    1912 bool regdb_store_values(const char *key, struct regval_ctr *values)
    1913 {
    1914         return regdb_store_values_internal(regdb, key, values);
     2046        return status;
     2047}
     2048
     2049struct regdb_store_values_ctx {
     2050        const char *key;
     2051        struct regval_ctr *values;
     2052};
     2053
     2054static NTSTATUS regdb_store_values_action(struct db_context *db,
     2055                                          void *private_data)
     2056{
     2057        NTSTATUS status;
     2058        struct regdb_store_values_ctx *ctx =
     2059                (struct regdb_store_values_ctx *)private_data;
     2060
     2061        status = regdb_store_values_internal(db, ctx->key, ctx->values);
     2062
     2063        return status;
     2064}
     2065
     2066static bool regdb_store_values(const char *key, struct regval_ctr *values)
     2067{
     2068        WERROR werr;
     2069        struct regdb_store_values_ctx ctx;
     2070
     2071        ctx.key = key;
     2072        ctx.values = values;
     2073
     2074        werr = regdb_trans_do(regdb, regdb_store_values_action, &ctx);
     2075
     2076        return W_ERROR_IS_OK(werr);
    19152077}
    19162078
     
    19432105        }
    19442106
    1945         data = dbwrap_fetch_bystring(regdb, tmp_ctx, tdbkey);
    1946         if (data.dptr == NULL) {
     2107        status = dbwrap_fetch_bystring(regdb, tmp_ctx, tdbkey, &data);
     2108        if (!NT_STATUS_IS_OK(status)) {
    19472109                err = WERR_BADFILE;
    19482110                goto done;
    19492111        }
    19502112
    1951         status = unmarshall_sec_desc(mem_ctx, (uint8 *)data.dptr, data.dsize,
     2113        status = unmarshall_sec_desc(mem_ctx, (uint8_t *)data.dptr, data.dsize,
    19522114                                     psecdesc);
    19532115
     
    19632125}
    19642126
     2127struct regdb_set_secdesc_ctx {
     2128        const char *key;
     2129        struct security_descriptor *secdesc;
     2130};
     2131
     2132static NTSTATUS regdb_set_secdesc_action(struct db_context *db,
     2133                                         void *private_data)
     2134{
     2135        char *tdbkey;
     2136        NTSTATUS status;
     2137        TDB_DATA tdbdata;
     2138        struct regdb_set_secdesc_ctx *ctx =
     2139                (struct regdb_set_secdesc_ctx *)private_data;
     2140        TALLOC_CTX *frame = talloc_stackframe();
     2141
     2142        tdbkey = talloc_asprintf(frame, "%s\\%s", REG_SECDESC_PREFIX, ctx->key);
     2143        if (tdbkey == NULL) {
     2144                status = NT_STATUS_NO_MEMORY;
     2145                goto done;
     2146        }
     2147
     2148        tdbkey = normalize_reg_path(frame, tdbkey);
     2149        if (tdbkey == NULL) {
     2150                status = NT_STATUS_NO_MEMORY;
     2151                goto done;
     2152        }
     2153
     2154        if (ctx->secdesc == NULL) {
     2155                /* assuming a delete */
     2156                status = dbwrap_delete_bystring(db, tdbkey);
     2157                goto done;
     2158        }
     2159
     2160        status = marshall_sec_desc(frame, ctx->secdesc, &tdbdata.dptr,
     2161                                   &tdbdata.dsize);
     2162        if (!NT_STATUS_IS_OK(status)) {
     2163                goto done;
     2164        }
     2165
     2166        status = dbwrap_store_bystring(db, tdbkey, tdbdata, 0);
     2167
     2168done:
     2169        TALLOC_FREE(frame);
     2170        return status;
     2171}
     2172
    19652173static WERROR regdb_set_secdesc(const char *key,
    19662174                                struct security_descriptor *secdesc)
    19672175{
    1968         TALLOC_CTX *mem_ctx = talloc_stackframe();
    1969         char *tdbkey;
    1970         WERROR err = WERR_NOMEM;
    1971         TDB_DATA tdbdata;
     2176        WERROR err;
     2177        struct regdb_set_secdesc_ctx ctx;
    19722178
    19732179        if (!regdb_key_exists(regdb, key)) {
     
    19762182        }
    19772183
    1978         tdbkey = talloc_asprintf(mem_ctx, "%s\\%s", REG_SECDESC_PREFIX, key);
    1979         if (tdbkey == NULL) {
    1980                 goto done;
    1981         }
    1982 
    1983         tdbkey = normalize_reg_path(mem_ctx, tdbkey);
    1984         if (tdbkey == NULL) {
    1985                 err = WERR_NOMEM;
    1986                 goto done;
    1987         }
    1988 
    1989         if (secdesc == NULL) {
    1990                 /* assuming a delete */
    1991                 err = ntstatus_to_werror(dbwrap_trans_delete_bystring(regdb,
    1992                                                                       tdbkey));
    1993                 goto done;
    1994         }
    1995 
    1996         err = ntstatus_to_werror(marshall_sec_desc(mem_ctx, secdesc,
    1997                                                    &tdbdata.dptr,
    1998                                                    &tdbdata.dsize));
    1999         W_ERROR_NOT_OK_GOTO_DONE(err);
    2000 
    2001         err = ntstatus_to_werror(dbwrap_trans_store_bystring(regdb, tdbkey,
    2002                                                              tdbdata, 0));
    2003 
    2004  done:
    2005         TALLOC_FREE(mem_ctx);
     2184        ctx.key = key;
     2185        ctx.secdesc = secdesc;
     2186
     2187        err = regdb_trans_do(regdb, regdb_set_secdesc_action, &ctx);
     2188
     2189done:
    20062190        return err;
    20072191}
    20082192
    2009 bool regdb_subkeys_need_update(struct regsubkey_ctr *subkeys)
     2193static bool regdb_subkeys_need_update(struct regsubkey_ctr *subkeys)
    20102194{
    20112195        return (regdb_get_seqnum() != regsubkey_ctr_get_seqnum(subkeys));
    20122196}
    20132197
    2014 bool regdb_values_need_update(struct regval_ctr *values)
     2198static bool regdb_values_need_update(struct regval_ctr *values)
    20152199{
    20162200        return (regdb_get_seqnum() != regval_ctr_get_seqnum(values));
  • vendor/current/source3/registry/reg_backend_db.h

    r740 r988  
    3333WERROR regdb_transaction_cancel(void);
    3434int regdb_get_seqnum(void);
    35 bool regdb_store_keys(const char *key, struct regsubkey_ctr *ctr);
    36 int regdb_fetch_keys(const char *key, struct regsubkey_ctr *ctr);
    37 int regdb_fetch_values(const char* key, struct regval_ctr *values);
    38 bool regdb_store_values(const char *key, struct regval_ctr *values);
    39 bool regdb_subkeys_need_update(struct regsubkey_ctr *subkeys);
    40 bool regdb_values_need_update(struct regval_ctr *values);
    4135
    4236#endif /* _REG_BACKEND_DB_H */
  • vendor/current/source3/registry/reg_backend_hkpt_params.c

    r740 r988  
    3737static int hkpt_params_fetch_values(const char *key, struct regval_ctr *regvals)
    3838{
    39         uint32 base_index;
    40         uint32 buffer_size;
     39        uint32_t base_index;
     40        uint32_t buffer_size;
    4141        char *buffer = NULL;
    4242
     
    4646        base_index = reg_perfcount_get_base_index();
    4747        buffer_size = reg_perfcount_get_counter_names(base_index, &buffer);
    48         regval_ctr_addvalue(regvals, "Counters", REG_MULTI_SZ, (uint8 *)buffer,
     48        regval_ctr_addvalue(regvals, "Counters", REG_MULTI_SZ, (uint8_t *)buffer,
    4949                            buffer_size);
    5050
     
    5454
    5555        buffer_size = reg_perfcount_get_counter_help(base_index, &buffer);
    56         regval_ctr_addvalue(regvals, "Help", REG_MULTI_SZ, (uint8 *)buffer, buffer_size);
     56        regval_ctr_addvalue(regvals, "Help", REG_MULTI_SZ, (uint8_t *)buffer, buffer_size);
    5757        if(buffer_size > 0) {
    5858                SAFE_FREE(buffer);
  • vendor/current/source3/registry/reg_backend_netlogon_params.c

    r740 r988  
    3737static int netlogon_params_fetch_values(const char *key, struct regval_ctr *regvals)
    3838{
    39         uint32 dwValue;
     39        uint32_t dwValue;
    4040
    4141        if (!pdb_get_account_policy(PDB_POLICY_REFUSE_MACHINE_PW_CHANGE, &dwValue)) {
  • vendor/current/source3/registry/reg_backend_printing.c

    r740 r988  
    2424#include "registry.h"
    2525#include "reg_util_internal.h"
    26 #include "reg_backend_db.h"
    2726
    2827#undef DBGC_CLASS
    2928#define DBGC_CLASS DBGC_REGISTRY
     29
     30extern struct registry_ops regdb_ops;
    3031
    3132/* registry paths used in the print_registry[] */
     
    8990        if (printers_key == NULL) {
    9091                /* normalize on the 'HKLM\SOFTWARE\....\Print\Printers' key */
    91                 return regdb_fetch_keys(KEY_WINNT_PRINTERS, subkeys);
    92         }
    93 
    94         return regdb_fetch_keys(printers_key, subkeys);
     92                return regdb_ops.fetch_subkeys(KEY_WINNT_PRINTERS, subkeys);
     93        }
     94
     95        return regdb_ops.fetch_subkeys(printers_key, subkeys);
    9596}
    9697
     
    106107        if (printers_key == NULL) {
    107108                /* normalize on the 'HKLM\SOFTWARE\....\Print\Printers' key */
    108                 return regdb_store_keys(KEY_WINNT_PRINTERS, subkeys);
    109         }
    110 
    111         return regdb_store_keys(printers_key, subkeys);
     109                return regdb_ops.store_subkeys(KEY_WINNT_PRINTERS, subkeys);
     110        }
     111
     112        return regdb_ops.store_subkeys(printers_key, subkeys);
    112113}
    113114
     
    123124        if (printers_key == NULL) {
    124125                /* normalize on the 'HKLM\SOFTWARE\....\Print\Printers' key */
    125                 return regdb_fetch_values(KEY_WINNT_PRINTERS, values);
    126         }
    127 
    128         return regdb_fetch_values(printers_key, values);
     126                return regdb_ops.fetch_values(KEY_WINNT_PRINTERS, values);
     127        }
     128
     129        return regdb_ops.fetch_values(printers_key, values);
    129130}
    130131
     
    140141        if (printers_key == NULL) {
    141142                /* normalize on the 'HKLM\SOFTWARE\....\Print\Printers' key */
    142                 return regdb_store_values(KEY_WINNT_PRINTERS, values);
    143         }
    144 
    145         return regdb_store_values(printers_key, values);
     143                return regdb_ops.store_values(KEY_WINNT_PRINTERS, values);
     144        }
     145
     146        return regdb_ops.store_values(printers_key, values);
    146147}
    147148
  • vendor/current/source3/registry/reg_backend_shares.c

    r740 r988  
    3939{
    4040        const char *p;
    41         uint16 key_len = strlen(KEY_SHARES);
     41        uint16_t key_len = strlen(KEY_SHARES);
    4242
    4343        /*
  • vendor/current/source3/registry/reg_backend_smbconf.c

    r746 r988  
    4343}
    4444
    45 static WERROR smbconf_delete_subkey(const char *key, const char *subkey)
     45static WERROR smbconf_delete_subkey(const char *key, const char *subkey, bool lazy)
    4646{
    47         return regdb_ops.delete_subkey(key, subkey);
     47        return regdb_ops.delete_subkey(key, subkey, lazy);
    4848}
    4949
     
    5858}
    5959
    60 static bool smbconf_reg_access_check(const char *keyname, uint32 requested,
    61                                      uint32 *granted,
     60static bool smbconf_reg_access_check(const char *keyname, uint32_t requested,
     61                                     uint32_t *granted,
    6262                                     const struct security_token *token)
    6363{
  • vendor/current/source3/registry/reg_cachehook.c

    r740 r988  
    9494                   (void *)ops, key));
    9595
    96         werr = pathtree_add(cache_tree, key, ops);
     96        if (!pathtree_add(cache_tree, key, ops))
     97                werr = WERR_NOMEM;
     98        else
     99                werr = WERR_OK;
    97100
    98101done:
  • vendor/current/source3/registry/reg_db.h

    r740 r988  
    2222
    2323#define REG_TDB_FLAGS   TDB_SEQNUM
     24#define REG_DBWRAP_FLAGS DBWRAP_FLAG_NONE
    2425
    25 #define REGVER_V1       1       /* first db version with write support */
    26 #define REGVER_V2       2       /* version 2 with normalized keys */
     26#define REGDB_VERSION_V1    1  /* first db version with write support */
     27#define REGDB_VERSION_V2    2  /* version 2 with normalized keys */
     28#define REGDB_VERSION_V3    3  /* different definition of key existence, */
     29                               /* sorted subkeys cache removed. */
     30
     31#define REGDB_CODE_VERSION REGDB_VERSION_V3
    2732
    2833#define REG_VALUE_PREFIX    "SAMBA_REGVAL"
  • vendor/current/source3/registry/reg_dispatcher.c

    r740 r988  
    2525
    2626#include "includes.h"
     27#include "system/passwd.h" /* uid_wrapper */
    2728#include "registry.h"
    2829#include "reg_dispatcher.h"
     
    114115}
    115116
    116 WERROR delete_reg_subkey(struct registry_key_handle *key, const char *subkey)
     117WERROR delete_reg_subkey(struct registry_key_handle *key, const char *subkey, bool lazy)
    117118{
    118119        if (key->ops && key->ops->delete_subkey) {
    119                 return key->ops->delete_subkey(key->name, subkey);
     120                return key->ops->delete_subkey(key->name, subkey, lazy);
    120121        }
    121122
     
    161162 ***********************************************************************/
    162163
    163 bool regkey_access_check(struct registry_key_handle *key, uint32 requested,
    164                          uint32 *granted,
     164bool regkey_access_check(struct registry_key_handle *key, uint32_t requested,
     165                         uint32_t *granted,
    165166                         const struct security_token *token )
    166167{
     
    170171
    171172        /* root free-pass, like we have on all other pipes like samr, lsa, etc. */
    172         if (geteuid() == sec_initial_uid()) {
     173        if (root_mode()) {
    173174                *granted = REG_KEY_ALL;
    174175                return true;
     
    244245        }
    245246
    246         return false;
     247        return true;
    247248}
    248249
     
    259260        }
    260261
    261         return false;
    262 }
    263 
     262        return true;
     263}
     264
  • vendor/current/source3/registry/reg_dispatcher.h

    r740 r988  
    2626bool store_reg_values(struct registry_key_handle *key, struct regval_ctr *val);
    2727WERROR create_reg_subkey(struct registry_key_handle *key, const char *subkey);
    28 WERROR delete_reg_subkey(struct registry_key_handle *key, const char *subkey);
     28WERROR delete_reg_subkey(struct registry_key_handle *key, const char *subkey, bool lazy);
    2929int fetch_reg_keys(struct registry_key_handle *key,
    3030                   struct regsubkey_ctr *subkey_ctr);
    3131int fetch_reg_values(struct registry_key_handle *key, struct regval_ctr *val);
    32 bool regkey_access_check(struct registry_key_handle *key, uint32 requested,
    33                          uint32 *granted,
     32bool regkey_access_check(struct registry_key_handle *key, uint32_t requested,
     33                         uint32_t *granted,
    3434                         const struct security_token *token);
    3535WERROR regkey_get_secdesc(TALLOC_CTX *mem_ctx, struct registry_key_handle *key,
  • vendor/current/source3/registry/reg_format.c

    r746 r988  
    9494{
    9595        if (fmt->hive_fmt != FMT_HIVE_PRESERVE) {
    96                 const struct hive_info* hinfo = hive_info(hive, len);
     96                const struct hive_info* hinfo = hive_info(hive);
    9797                if (hinfo == NULL) {
    9898                        DEBUG(0, ("Unknown hive %*s", len, hive));
     
    568568                            bool del)
    569569{
    570         return reg_format_key(f, (const char**)&key->key->name, 1, del);
     570        const char *knames[1];
     571        knames[0] = key->key->name;
     572        return reg_format_key(f, knames, 1, del);
    571573}
    572574
  • vendor/current/source3/registry/reg_import.c

    r740 r988  
    2929static const int TL = 2;
    3030
    31 struct reg_import
    32 {
     31struct reg_import {
    3332        struct reg_parse_callback reg_parse_callback;
    3433        struct reg_import_callback call;
    35         void* open_key;
     34        void *open_key;
    3635};
    3736
    38 static int
    39 reg_parse_callback_key(struct reg_import* cb_private,
    40                        const char* key[], size_t n,
    41                        bool del);
    42 
    43 static int
    44 reg_parse_callback_val(struct reg_import* cb_private,
    45                        const char* name, uint32_t type,
    46                        const uint8_t* data, uint32_t len);
    47 
    48 static int
    49 reg_parse_callback_val_registry_value(struct reg_import* cb_private,
    50                                       const char* name, uint32_t type,
    51                                       const uint8_t* data, uint32_t len);
    52 
    53 static int
    54 reg_parse_callback_val_regval_blob(struct reg_import* cb_private,
    55                                    const char* name, uint32_t type,
    56                                    const uint8_t* data, uint32_t len);
    57 
    58 static int
    59 reg_parse_callback_val_del(struct reg_import* cb_private,
    60                            const char* name);
    61 
    62 static int
    63 reg_parse_callback_comment(struct reg_import* cb_private,
    64                            const char* txt);
     37static int reg_parse_callback_key(struct reg_import *cb_private,
     38                                  const char *key[], size_t n, bool del);
     39
     40static int reg_parse_callback_val(struct reg_import *cb_private,
     41                                  const char *name, uint32_t type,
     42                                  const uint8_t *data, uint32_t len);
     43
     44static int reg_parse_callback_val_registry_value(struct reg_import *cb_private,
     45                                                 const char *name,
     46                                                 uint32_t type,
     47                                                 const uint8_t *data,
     48                                                 uint32_t len);
     49
     50static int reg_parse_callback_val_regval_blob(struct reg_import *cb_private,
     51                                              const char *name, uint32_t type,
     52                                              const uint8_t *data,
     53                                              uint32_t len);
     54
     55static int reg_parse_callback_val_del(struct reg_import *cb_private,
     56                                      const char *name);
     57
     58static int reg_parse_callback_comment(struct reg_import *cb_private,
     59                                      const char *txt);
    6560
    6661
    6762/*******************************************************************************/
    6863
    69 int reg_parse_callback_key(struct reg_import* p,
    70                            const char* key[], size_t n, bool del)
     64int reg_parse_callback_key(struct reg_import *p,
     65                           const char *key[], size_t n, bool del)
    7166{
    7267        WERROR werr = WERR_OK;
     
    7469        DEBUG(TL, ("%s: %s\n", __FUNCTION__, key[0]));
    7570
    76         if (p->open_key != NULL ) {
     71        if (p->open_key != NULL) {
    7772                werr = p->call.closekey(p->call.data, p->open_key);
     73                p->open_key = NULL;
    7874                if (!W_ERROR_IS_OK(werr)) {
    7975                        DEBUG(0, ("closekey failed: %s\n", win_errstr(werr)));
     
    9187                                  key[0], win_errstr(werr)));
    9288                }
    93         }
    94         else {
     89        } else {
    9590                bool existing;
    9691                werr = p->call.createkey(p->call.data, NULL, key[0],
     
    122117
    123118/*----------------------------------------------------------------------------*/
    124 int reg_parse_callback_val(struct reg_import* p,
    125                            const char* name, uint32_t type,
    126                            const uint8_t* data, uint32_t len)
     119int reg_parse_callback_val(struct reg_import *p,
     120                           const char *name, uint32_t type,
     121                           const uint8_t *data, uint32_t len)
    127122{
    128123        WERROR werr = WERR_OK;
     
    142137
    143138/*----------------------------------------------------------------------------*/
    144 int reg_parse_callback_val_registry_value(struct reg_import* p,
    145                                           const char* name, uint32_t type,
    146                                           const uint8_t* data, uint32_t len)
     139int reg_parse_callback_val_registry_value(struct reg_import *p,
     140                                          const char *name, uint32_t type,
     141                                          const uint8_t *data, uint32_t len)
    147142{
    148143        WERROR werr = WERR_OK;
     
    167162
    168163/*----------------------------------------------------------------------------*/
    169 int reg_parse_callback_val_regval_blob(struct reg_import* p,
    170                                        const char* name, uint32_t type,
    171                                        const uint8_t* data, uint32_t len)
     164int reg_parse_callback_val_regval_blob(struct reg_import *p,
     165                                       const char *name, uint32_t type,
     166                                       const uint8_t *data, uint32_t len)
    172167{
    173168        WERROR werr = WERR_OK;
    174169        void* mem_ctx = talloc_new(p);
    175         struct regval_blob* v = NULL;
     170        struct regval_blob *v = NULL;
    176171
    177172        DEBUG(TL, ("%s(%x): >%s< = [%x]\n", __FUNCTION__, type, name, len));
     
    200195/*----------------------------------------------------------------------------*/
    201196
    202 int reg_parse_callback_val_del(struct reg_import* p,
    203                                const char* name)
     197int reg_parse_callback_val_del(struct reg_import *p,
     198                               const char *name)
    204199{
    205200        WERROR werr = WERR_OK;
     
    217212
    218213
    219 int reg_parse_callback_comment(struct reg_import* cb_private,
    220                                const char* txt)
     214int reg_parse_callback_comment(struct reg_import *cb_private,
     215                               const char *txt)
    221216{
    222217        DEBUG(TL, ("%s: %s\n", __FUNCTION__, txt));
     
    225220
    226221/******************************************************************************/
    227 static int nop(void* data)
     222static int nop(void *data)
    228223{
    229224        return 0;
     
    231226
    232227
    233 struct reg_parse_callback* reg_import_adapter(const void* talloc_ctx,
     228struct reg_parse_callback *reg_import_adapter(TALLOC_CTX *talloc_ctx,
    234229                                              struct reg_import_callback cb)
    235230{
    236         struct reg_parse_callback* ret;
    237         struct reg_import* p = talloc_zero(talloc_ctx, struct reg_import);
     231        struct reg_parse_callback *ret;
     232        struct reg_import *p = talloc_zero(talloc_ctx, struct reg_import);
    238233        if (p == NULL) {
    239234                goto fail;
    240235        }
    241         if (cb.openkey == NULL ) {
     236        if (cb.openkey == NULL) {
    242237                cb.openkey = (reg_import_callback_openkey_t)&nop;
    243238        }
    244         if (cb.closekey == NULL ) {
     239        if (cb.closekey == NULL) {
    245240                cb.closekey = (reg_import_callback_closekey_t)&nop;
    246241        }
    247         if (cb.createkey == NULL ) {
     242        if (cb.createkey == NULL) {
    248243                cb.createkey = (reg_import_callback_createkey_t)&nop;
    249244        }
    250         if (cb.deletekey == NULL ) {
     245        if (cb.deletekey == NULL) {
    251246                cb.deletekey = (reg_import_callback_deletekey_t)&nop;
    252247        }
    253         if (cb.deleteval == NULL ) {
     248        if (cb.deleteval == NULL) {
    254249                cb.deleteval = (reg_import_callback_deleteval_t)&nop;
    255250        }
     
    283278        }
    284279
    285         assert((struct reg_parse_callback*)p == ret);
     280        assert((struct reg_parse_callback *)p == ret);
    286281        return ret;
    287282fail:
  • vendor/current/source3/registry/reg_import.h

    r740 r988  
    195195 * @return a talloc'ed reg_import object, NULL on error
    196196 */
    197 struct reg_parse_callback* reg_import_adapter(const void* talloc_ctx,
     197struct reg_parse_callback* reg_import_adapter(TALLOC_CTX *talloc_ctx,
    198198                                              struct reg_import_callback cb);
    199199#endif
  • vendor/current/source3/registry/reg_init_full.c

    r740 r988  
    7070/***********************************************************************
    7171 Open the registry database and initialize the registry_hook cache
    72  with all available backens.
     72 with all available backends.
    7373 ***********************************************************************/
    7474
  • vendor/current/source3/registry/reg_objects.c

    r746 r988  
    2525#include "reg_objects.h"
    2626#include "util_tdb.h"
    27 #include "dbwrap.h"
     27#include "dbwrap/dbwrap.h"
     28#include "dbwrap/dbwrap_rbt.h"
    2829#include "../libcli/registry/util_reg.h"
    2930
     
    6364
    6465 There is no longer a regval_ctr_intit() and regval_ctr_destroy()
    65  pair of functions.  Simply TALLOC_ZERO_P() and TALLOC_FREE() the
     66 pair of functions.  Simply talloc_zero() and TALLOC_FREE() the
    6667 object.
    6768
     
    170171{
    171172        TDB_DATA data;
     173        NTSTATUS status;
    172174
    173175        if ((ctr == NULL) || (keyname == NULL)) {
     
    175177        }
    176178
    177         data = dbwrap_fetch_bystring_upper(ctr->subkeys_hash, ctr, keyname);
    178         if (data.dptr == NULL) {
     179        status = dbwrap_fetch_bystring_upper(ctr->subkeys_hash, ctr, keyname,
     180                                             &data);
     181        if (!NT_STATUS_IS_OK(status)) {
    179182                return WERR_NOT_FOUND;
    180183        }
     
    186189
    187190        if (idx != NULL) {
    188                 *idx = *(uint32_t *)data.dptr;
     191                memcpy(idx, data.dptr, sizeof(*idx));
    189192        }
    190193
     
    212215        }
    213216
    214         if (!(newkeys = TALLOC_REALLOC_ARRAY(ctr, ctr->subkeys, char *,
     217        if (!(newkeys = talloc_realloc(ctr, ctr->subkeys, char *,
    215218                                             ctr->num_subkeys+1))) {
    216219                return WERR_NOMEM;
     
    302305
    303306/***********************************************************************
    304  Retreive a specific key string
     307 Retrieve a specific key string
    305308 **********************************************************************/
    306309
     
    343346}
    344347
    345 /***********************************************************************
    346  allocate memory for and duplicate a struct regval_blob.
    347  This is malloc'd memory so the caller should free it when done
    348  **********************************************************************/
    349 
    350 struct regval_blob* dup_registry_value(struct regval_blob *val)
    351 {
    352         struct regval_blob *copy = NULL;
    353 
    354         if ( !val )
    355                 return NULL;
    356 
    357         if ( !(copy = SMB_MALLOC_P( struct regval_blob)) ) {
    358                 DEBUG(0,("dup_registry_value: malloc() failed!\n"));
    359                 return NULL;
    360         }
    361 
    362         /* copy all the non-pointer initial data */
    363 
    364         memcpy( copy, val, sizeof(struct regval_blob) );
    365 
    366         copy->size = 0;
    367         copy->data_p = NULL;
    368 
    369         if ( val->data_p && val->size )
    370         {
    371                 if ( !(copy->data_p = (uint8_t *)memdup( val->data_p,
    372                                                        val->size )) ) {
    373                         DEBUG(0,("dup_registry_value: memdup() failed for [%d] "
    374                                  "bytes!\n", val->size));
    375                         SAFE_FREE( copy );
    376                         return NULL;
    377                 }
    378                 copy->size = val->size;
    379         }
    380 
    381         return copy;
    382 }
    383 
    384 /**********************************************************************
    385  free the memory allocated to a struct regval_blob
    386  *********************************************************************/
    387 
    388 void free_registry_value(struct regval_blob *val)
    389 {
    390         if ( !val )
    391                 return;
    392 
    393         SAFE_FREE( val->data_p );
    394         SAFE_FREE( val );
    395 
    396         return;
    397 }
    398 
    399348/**********************************************************************
    400349 *********************************************************************/
     
    430379
    431380/***********************************************************************
    432  Retreive a pointer to a specific value.  Caller shoud dup the structure
     381 Retrieve a pointer to a specific value.  Caller shoud dup the structure
    433382 since this memory will go away when the ctr is free()'d
    434383 **********************************************************************/
     
    467416        int i;
    468417
    469         for (i=0; i<ctr->num_values; i++) {
    470                 if (strequal(ctr->values[i]->valuename,value)) {
     418        for (i = 0; i < ctr->num_values; i++) {
     419                if (strequal(ctr->values[i]->valuename, value)) {
    471420                        return ctr->values[i];
    472421                }
     
    485434                                   const uint8_t *data_p, size_t size)
    486435{
    487         struct regval_blob *regval = TALLOC_P(ctx, struct regval_blob);
     436        struct regval_blob *regval = talloc(ctx, struct regval_blob);
    488437
    489438        if (regval == NULL) {
     
    494443        regval->type = type;
    495444        if (size) {
    496                 regval->data_p = (uint8_t *)TALLOC_MEMDUP(regval, data_p, size);
     445                regval->data_p = (uint8_t *)talloc_memdup(regval, data_p, size);
    497446                if (!regval->data_p) {
    498447                        TALLOC_FREE(regval);
     
    524473
    525474        if (  ctr->num_values == 0 ) {
    526                 ctr->values = TALLOC_P( ctr, struct regval_blob *);
     475                ctr->values = talloc( ctr, struct regval_blob *);
    527476        } else {
    528                 ctr->values = TALLOC_REALLOC_ARRAY(ctr, ctr->values,
     477                ctr->values = talloc_realloc(ctr, ctr->values,
    529478                                                   struct regval_blob *,
    530479                                                   ctr->num_values+1);
     
    664613        return WERR_OK;
    665614}
    666 
    667 /***********************************************************************
    668  return the data_p as a uint32_t
    669  **********************************************************************/
    670 
    671 uint32_t regval_dword(struct regval_blob *val)
    672 {
    673         uint32_t data;
    674 
    675         data = IVAL( regval_data_p(val), 0 );
    676 
    677         return data;
    678 }
    679 
    680 /***********************************************************************
    681  return the data_p as a character string
    682  **********************************************************************/
    683 
    684 const char *regval_sz(struct regval_blob *val)
    685 {
    686         const char *data = NULL;
    687         DATA_BLOB blob = data_blob_const(regval_data_p(val), regval_size(val));
    688 
    689         pull_reg_sz(talloc_tos(), &blob, &data);
    690 
    691         return data;
    692 }
  • vendor/current/source3/registry/reg_objects.h

    r746 r988  
    4848WERROR regval_ctr_init(TALLOC_CTX *mem_ctx, struct regval_ctr **ctr);
    4949int regval_ctr_numvals(struct regval_ctr *ctr);
    50 struct regval_blob* dup_registry_value(struct regval_blob *val);
    51 void free_registry_value(struct regval_blob *val);
    5250uint8_t* regval_data_p(struct regval_blob *val);
    5351uint32_t regval_size(struct regval_blob *val);
     
    7270int regval_ctr_get_seqnum(struct regval_ctr *ctr);
    7371WERROR regval_ctr_set_seqnum(struct regval_ctr *ctr, int seqnum);
    74 uint32_t regval_dword(struct regval_blob *val);
    75 const char *regval_sz(struct regval_blob *val);
    7672
    7773
  • vendor/current/source3/registry/reg_parse.c

    r746 r988  
    3535
    3636#include <stdio.h>
    37 #include <unistd.h>
    38 #include <wchar.h>
    3937#include <talloc.h>
    4038#include <stdbool.h>
    4139#include <string.h>
    42 #include <sys/types.h>
    4340#include <regex.h>
    4441#include <assert.h>
     
    164161                if (convert_string_talloc(p->valblob, CH_UNIX, CH_UTF16LE,
    165162                                          src, strlen(src)+1,
    166                                           &dst, &dlen, true))
     163                                          &dst, &dlen))
    167164                {
    168165                        cbuf_swapptr(p->valblob, &dst, dlen);
     
    623620
    624621        size_t l = MIN(len/2, 64);
    625         uint16_t* u = (uint16_t*)line;
     622        const uint16_t* u = (const uint16_t*)line;
    626623        int i;
    627624
     
    937934        fd = open(fname, O_RDONLY);
    938935        if (fd < 0) {
    939                 DEBUG(0, ("reg_parse_file: open failed: %s\n", strerror(errno)));
     936                DEBUG(0, ("reg_parse_file: open %s failed: %s\n", fname,
     937                          strerror(errno)));
    940938                return -1;
    941939        }
  • vendor/current/source3/registry/reg_parse_internal.c

    r740 r988  
    115115#endif
    116116
    117 #define HIVE_INFO_ENTRY(SHORT,LONG)                     \
    118 static const struct hive_info HIVE_INFO_##SHORT = {     \
    119         .handle = LONG,                                 \
    120         .short_name = #SHORT,                           \
    121         .short_name_len = sizeof(#SHORT)-1,             \
    122         .long_name = #LONG,                             \
    123         .long_name_len = sizeof(#LONG)-1,               \
     117#define HIVE_INFO_ENTRY(SHORT,LONG)             \
     118const struct hive_info HIVE_INFO_##SHORT = {    \
     119        .handle = LONG,                         \
     120        .short_name = #SHORT,                   \
     121        .short_name_len = sizeof(#SHORT)-1,     \
     122        .long_name = #LONG,                     \
     123        .long_name_len = sizeof(#LONG)-1,       \
    124124}
    125125
     
    135135#undef HIVE_INFO_ENTRY
    136136
    137 static const struct hive_info* HIVE_INFO[] = {
     137const struct hive_info* HIVE_INFO[] = {
    138138        &HIVE_INFO_HKLM, &HIVE_INFO_HKCU, &HIVE_INFO_HKCR, &HIVE_INFO_HKU,
    139139        &HIVE_INFO_HKCC, &HIVE_INFO_HKDD, &HIVE_INFO_HKPD, &HIVE_INFO_HKPT,
     
    141141};
    142142
    143 const struct hive_info* hive_info(const char* name, int nlen)
    144 {
    145         const struct hive_info** info;
    146         char buf[32];
    147         int s;
    148 
    149         if (nlen >= sizeof(buf)) {
    150                 return NULL;
    151         }
    152         for (s=0; s<nlen; s++) {
    153                 buf[s] = toupper(name[s]);
    154         }
    155         buf[s] = '\0';
    156 
    157         if ((s < 3) || (strncmp(buf, "HK", 2) != 0)) {
    158                 return NULL;
    159         }
    160 
    161         if (s <= 4) {
    162                 for(info = HIVE_INFO; *info; info++) {
    163                         if (strcmp(buf+2, (*info)->short_name+2) == 0) {
    164                                 return *info;
     143#define TOINT(A,B) ((int)(A) << 8) + (int)(B)
     144
     145bool srprs_hive(const char** ptr, const struct hive_info** result)
     146{
     147        const char* str = *ptr;
     148        const struct hive_info* info = NULL;
     149        bool long_hive = false;
     150
     151        if ((toupper(str[0]) != 'H') || (toupper(str[1]) != 'K')
     152            || (str[2] == '\0') )
     153        {
     154                return false;
     155        }
     156
     157        switch ( TOINT(toupper(str[2]), toupper(str[3])) ) {
     158        case TOINT('E', 'Y'):
     159                if (str[4] == '_') {
     160                        int i;
     161                        for (i=0; (info = HIVE_INFO[i]); i++) {
     162                                if (strncmp(&str[5], &info->long_name[5],
     163                                            info->long_name_len-5) == 0)
     164                                {
     165                                        long_hive = true;
     166                                        break;
     167                                }
    165168                        }
    166169                }
    167                 return NULL;
    168         }
    169 
    170         if ((s < 10) || (strncmp(buf, "HKEY_", 5)) != 0) {
    171                 return NULL;
    172         }
    173 
    174         for(info = HIVE_INFO; *info; info++) {
    175                 if (strcmp(buf+5, (*info)->long_name+5) == 0) {
    176                         return *info;
    177                 }
    178         }
    179         return NULL;
     170                break;
     171        case TOINT('L', 'M'):
     172                info = &HIVE_INFO_HKLM;
     173                break;
     174        case TOINT('C', 'U'):
     175                info = &HIVE_INFO_HKCU;
     176                break;
     177        case TOINT('C', 'R'):
     178                info = &HIVE_INFO_HKCR;
     179                break;
     180        case TOINT('C', 'C'):
     181                info = &HIVE_INFO_HKCC;
     182                break;
     183        case TOINT('D', 'D'):
     184                info = &HIVE_INFO_HKDD;
     185                break;
     186        case TOINT('P', 'D'):
     187                info = &HIVE_INFO_HKPD;
     188                break;
     189        case TOINT('P', 'T'):
     190                info = &HIVE_INFO_HKPT;
     191                break;
     192        case TOINT('P', 'N'):
     193                info = &HIVE_INFO_HKPN;
     194                break;
     195        default:
     196                if (toupper(str[2]) == 'U') {
     197                        info = &HIVE_INFO_HKU;
     198                }
     199                break;
     200        }
     201        if (info != NULL) {
     202                if (result != NULL) {
     203                        *result = info;
     204                }
     205                *ptr += long_hive ? info->long_name_len : info->short_name_len;
     206                return true;
     207        }
     208        return false;
     209}
     210
     211const struct hive_info* hive_info(const char* name)
     212{
     213        const struct hive_info* info = NULL;
     214        srprs_hive(&name, &info);
     215        return info;
    180216}
    181217
     
    265301        charset_t ctype;
    266302        int  len;
    267         char seq[4];
     303        uint8_t seq[4];
    268304} BOM[] = {
    269305        {"UTF-8",    CH_UTF8,    3, {0xEF, 0xBB, 0xBF}},
     
    314350        } else {
    315351                for (i=0; BOM[i].name; i++) {
    316                         if (StrCaseCmp(BOM[i].name, charset) == 0) {
     352                        if (strcasecmp_m(BOM[i].name, charset) == 0) {
    317353                                return fwrite(BOM[i].seq, 1, BOM[i].len, file);
    318354                        }
  • vendor/current/source3/registry/reg_parse_internal.h

    r740 r988  
    3939#  define smb_iconv_t     iconv_t
    4040#  define smb_iconv(CD, IPTR, ILEN, OPTR, OLEN) \
    41         iconv(CD, (char**)(IPTR), ILEN, OPTR, OLEN)
     41        iconv(CD, discard_const_p(char*, (IPTR)), ILEN, OPTR, OLEN)
    4242#  define smb_iconv_open  iconv_open
    4343#  define smb_iconv_close iconv_close
     
    5757};
    5858
    59 const struct hive_info* hive_info(const char* name, int nlen);
     59extern const struct hive_info HIVE_INFO_HKLM;
     60extern const struct hive_info HIVE_INFO_HKCU;
     61extern const struct hive_info HIVE_INFO_HKCR;
     62extern const struct hive_info HIVE_INFO_HKU;
     63extern const struct hive_info HIVE_INFO_HKCC;
     64extern const struct hive_info HIVE_INFO_HKDD;
     65extern const struct hive_info HIVE_INFO_HKPD;
     66extern const struct hive_info HIVE_INFO_HKPT;
     67extern const struct hive_info HIVE_INFO_HKPN;
     68
     69extern const struct hive_info* HIVE_INFO[];
     70
     71const struct hive_info* hive_info(const char* name);
     72bool srprs_hive(const char** ptr, const struct hive_info** result);
     73
     74
    6075
    6176const char* get_charset(const char* c);
  • vendor/current/source3/registry/reg_parse_prs.c

    r740 r988  
    4949 **/
    5050
    51 bool prs_init(prs_struct *ps, uint32 size, TALLOC_CTX *ctx, bool io)
     51bool prs_init(prs_struct *ps, uint32_t size, TALLOC_CTX *ctx, bool io)
    5252{
    5353        ZERO_STRUCTP(ps);
     
    132132 ********************************************************************/
    133133
    134 bool prs_grow(prs_struct *ps, uint32 extra_space)
    135 {
    136         uint32 new_size;
     134bool prs_grow(prs_struct *ps, uint32_t extra_space)
     135{
     136        uint32_t new_size;
    137137
    138138        ps->grow_size = MAX(ps->grow_size, ps->data_offset + extra_space);
     
    210210 ********************************************************************/
    211211
    212 uint32 prs_data_size(prs_struct *ps)
     212uint32_t prs_data_size(prs_struct *ps)
    213213{
    214214        return ps->buffer_size;
     
    219219 ********************************************************************/
    220220
    221 uint32 prs_offset(prs_struct *ps)
     221uint32_t prs_offset(prs_struct *ps)
    222222{
    223223        return ps->data_offset;
     
    228228 ********************************************************************/
    229229
    230 bool prs_set_offset(prs_struct *ps, uint32 offset)
     230bool prs_set_offset(prs_struct *ps, uint32_t offset)
    231231{
    232232        if ((offset > ps->data_offset)
     
    243243 ********************************************************************/
    244244
    245 bool prs_copy_data_in(prs_struct *dst, const char *src, uint32 len)
     245bool prs_copy_data_in(prs_struct *dst, const char *src, uint32_t len)
    246246{
    247247        if (len == 0)
     
    264264bool prs_align(prs_struct *ps)
    265265{
    266         uint32 mod = ps->data_offset & (ps->align-1);
     266        uint32_t mod = ps->data_offset & (ps->align-1);
    267267
    268268        if (ps->align != 0 && mod != 0) {
    269                 uint32 extra_space = (ps->align - mod);
     269                uint32_t extra_space = (ps->align - mod);
    270270                if(!prs_grow(ps, extra_space))
    271271                        return False;
     
    284284{
    285285        bool ret;
    286         uint8 old_align = ps->align;
     286        uint8_t old_align = ps->align;
    287287
    288288        ps->align = 8;
     
    297297 ********************************************************************/
    298298
    299 char *prs_mem_get(prs_struct *ps, uint32 extra_size)
     299char *prs_mem_get(prs_struct *ps, uint32_t extra_size)
    300300{
    301301        if(UNMARSHALLING(ps)) {
     
    331331
    332332/*******************************************************************
    333  Stream a uint8.
    334  ********************************************************************/
    335 
    336 bool prs_uint8(const char *name, prs_struct *ps, int depth, uint8 *data8)
    337 {
    338         char *q = prs_mem_get(ps, 1);
    339         if (q == NULL)
    340                 return False;
    341 
    342         if (UNMARSHALLING(ps))
    343                 *data8 = CVAL(q,0);
    344         else
    345                 SCVAL(q,0,*data8);
    346 
    347         DEBUGADD(5,("%s%04x %s: %02x\n", tab_depth(5,depth), ps->data_offset, name, *data8));
    348 
    349         ps->data_offset += 1;
    350 
    351         return True;
    352 }
    353 
    354 /*******************************************************************
    355333 Stream a uint16.
    356334 ********************************************************************/
    357335
    358 bool prs_uint16(const char *name, prs_struct *ps, int depth, uint16 *data16)
    359 {
    360         char *q = prs_mem_get(ps, sizeof(uint16));
     336bool prs_uint16(const char *name, prs_struct *ps, int depth, uint16_t *data16)
     337{
     338        char *q = prs_mem_get(ps, sizeof(uint16_t));
    361339        if (q == NULL)
    362340                return False;
     
    376354        DEBUGADD(5,("%s%04x %s: %04x\n", tab_depth(5,depth), ps->data_offset, name, *data16));
    377355
    378         ps->data_offset += sizeof(uint16);
     356        ps->data_offset += sizeof(uint16_t);
    379357
    380358        return True;
     
    385363 ********************************************************************/
    386364
    387 bool prs_uint32(const char *name, prs_struct *ps, int depth, uint32 *data32)
    388 {
    389         char *q = prs_mem_get(ps, sizeof(uint32));
     365bool prs_uint32(const char *name, prs_struct *ps, int depth, uint32_t *data32)
     366{
     367        char *q = prs_mem_get(ps, sizeof(uint32_t));
    390368        if (q == NULL)
    391369                return False;
     
    405383        DEBUGADD(5,("%s%04x %s: %08x\n", tab_depth(5,depth), ps->data_offset, name, *data32));
    406384
    407         ps->data_offset += sizeof(uint32);
     385        ps->data_offset += sizeof(uint32_t);
    408386
    409387        return True;
     
    413391 Stream a uint64_struct
    414392 ********************************************************************/
    415 bool prs_uint64(const char *name, prs_struct *ps, int depth, uint64 *data64)
     393bool prs_uint64(const char *name, prs_struct *ps, int depth, uint64_t *data64)
    416394{
    417395        if (UNMARSHALLING(ps)) {
    418                 uint32 high, low;
     396                uint32_t high, low;
    419397
    420398                if (!prs_uint32(name, ps, depth+1, &low))
     
    428406                return True;
    429407        } else {
    430                 uint32 high = (*data64) >> 32, low = (*data64) & 0xFFFFFFFF;
     408                uint32_t high = (*data64) >> 32, low = (*data64) & 0xFFFFFFFF;
    431409                return prs_uint32(name, ps, depth+1, &low) &&
    432410                           prs_uint32(name, ps, depth+1, &high);
     
    438416 ********************************************************************/
    439417
    440 bool prs_uint8s(bool charmode, const char *name, prs_struct *ps, int depth, uint8 *data8s, int len)
     418bool prs_uint8s(bool charmode, const char *name, prs_struct *ps, int depth, uint8_t *data8s, int len)
    441419{
    442420        int i;
  • vendor/current/source3/registry/reg_parse_prs.h

    r740 r988  
    3434         */
    3535        bool bigendian_data;
    36         uint8 align; /* data alignment */
     36        uint8_t align; /* data alignment */
    3737        bool is_dynamic; /* Do we own this memory or not ? */
    38         uint32 data_offset; /* Current working offset into data. */
    39         uint32 buffer_size; /* Current allocated size of the buffer. */
    40         uint32 grow_size; /* size requested via prs_grow() calls */
     38        uint32_t data_offset; /* Current working offset into data. */
     39        uint32_t buffer_size; /* Current allocated size of the buffer. */
     40        uint32_t grow_size; /* size requested via prs_grow() calls */
    4141        /* The buffer itself. If "is_dynamic" is true this
    4242         * MUST BE TALLOC'ed off mem_ctx. */
     
    5858
    5959void prs_debug(prs_struct *ps, int depth, const char *desc, const char *fn_name);
    60 bool prs_init(prs_struct *ps, uint32 size, TALLOC_CTX *ctx, bool io);
     60bool prs_init(prs_struct *ps, uint32_t size, TALLOC_CTX *ctx, bool io);
    6161void prs_mem_free(prs_struct *ps);
    6262char *prs_alloc_mem_(prs_struct *ps, size_t size, unsigned int count);
    6363char *prs_alloc_mem(prs_struct *ps, size_t size, unsigned int count);
    6464TALLOC_CTX *prs_get_mem_context(prs_struct *ps);
    65 bool prs_grow(prs_struct *ps, uint32 extra_space);
     65bool prs_grow(prs_struct *ps, uint32_t extra_space);
    6666char *prs_data_p(prs_struct *ps);
    67 uint32 prs_data_size(prs_struct *ps);
    68 uint32 prs_offset(prs_struct *ps);
    69 bool prs_set_offset(prs_struct *ps, uint32 offset);
    70 bool prs_copy_data_in(prs_struct *dst, const char *src, uint32 len);
     67uint32_t prs_data_size(prs_struct *ps);
     68uint32_t prs_offset(prs_struct *ps);
     69bool prs_set_offset(prs_struct *ps, uint32_t offset);
     70bool prs_copy_data_in(prs_struct *dst, const char *src, uint32_t len);
    7171bool prs_align(prs_struct *ps);
    7272bool prs_align_uint64(prs_struct *ps);
    73 char *prs_mem_get(prs_struct *ps, uint32 extra_size);
     73char *prs_mem_get(prs_struct *ps, uint32_t extra_size);
    7474void prs_switch_type(prs_struct *ps, bool io);
    75 bool prs_uint8(const char *name, prs_struct *ps, int depth, uint8 *data8);
    76 bool prs_uint16(const char *name, prs_struct *ps, int depth, uint16 *data16);
    77 bool prs_uint32(const char *name, prs_struct *ps, int depth, uint32 *data32);
    78 bool prs_uint64(const char *name, prs_struct *ps, int depth, uint64 *data64);
    79 bool prs_uint8s(bool charmode, const char *name, prs_struct *ps, int depth, uint8 *data8s, int len);
     75bool prs_uint16(const char *name, prs_struct *ps, int depth, uint16_t *data16);
     76bool prs_uint32(const char *name, prs_struct *ps, int depth, uint32_t *data32);
     77bool prs_uint64(const char *name, prs_struct *ps, int depth, uint64_t *data64);
     78bool prs_uint8s(bool charmode, const char *name, prs_struct *ps, int depth, uint8_t *data8s, int len);
    8079
    8180#endif
  • vendor/current/source3/registry/reg_perfcount.c

    r740 r988  
    4242*********************************************************************/
    4343
     44/* returns perfcount path for dbname allocated on talloc_tos */
    4445static char *counters_directory(const char *dbname)
    4546{
    46         char *path = NULL;
     47        char *dir_path = NULL;
     48        char *db_subpath = NULL;
    4749        char *ret = NULL;
    48         TALLOC_CTX *ctx = talloc_tos();
    49 
    50         path = state_path(PERFCOUNTDIR);
    51         if (!directory_exist(path)) {
    52                 mkdir(path, 0755);
    53         }
    54 
    55         path = talloc_asprintf(ctx, "%s/%s", PERFCOUNTDIR, dbname);
    56         if (!path) {
     50
     51        dir_path = state_path(PERFCOUNTDIR);
     52        if (dir_path == NULL) {
    5753                return NULL;
    5854        }
    5955
    60         ret = talloc_strdup(ctx, state_path(path));
    61         TALLOC_FREE(path);
     56        if (!directory_create_or_exist(dir_path, 0755)) {
     57                TALLOC_FREE(dir_path);
     58                return NULL;
     59        }
     60
     61        db_subpath = talloc_asprintf(dir_path, "%s/%s", PERFCOUNTDIR, dbname);
     62        if (db_subpath == NULL) {
     63                TALLOC_FREE(dir_path);
     64                return NULL;
     65        }
     66
     67        ret = state_path(db_subpath);
     68        TALLOC_FREE(dir_path);
    6269        return ret;
    6370}
     
    6673*********************************************************************/
    6774
    68 uint32 reg_perfcount_get_base_index(void)
    69 {
    70         const char *fname = counters_directory( NAMES_DB );
     75uint32_t reg_perfcount_get_base_index(void)
     76{
     77        char *fname;
    7178        TDB_CONTEXT *names;
    7279        TDB_DATA kbuf, dbuf;
    7380        char key[] = "1";
    74         uint32 retval = 0;
     81        uint32_t retval = 0;
    7582        char buf[PERFCOUNT_MAX_LEN];
    7683
     84        fname = counters_directory(NAMES_DB);
     85        if (fname == NULL) {
     86                return 0;
     87        }
     88
    7789        names = tdb_open_log(fname, 0, TDB_DEFAULT, O_RDONLY, 0444);
    7890
    7991        if ( !names ) {
    80                 DEBUG(1, ("reg_perfcount_get_base_index: unable to open [%s].\n", fname));
     92                DEBUG(2, ("reg_perfcount_get_base_index: unable to open [%s].\n", fname));
     93                TALLOC_FREE(fname);
    8194                return 0;
    82         }   
     95        }
    8396        /* needs to read the value of key "1" from the counter_names.tdb file, as that is
    8497           where the total number of counters is stored. We're assuming no holes in the
     
    101114                DEBUG(1, ("reg_perfcount_get_base_index: failed to find key \'1\' in [%s].\n", fname));
    102115                tdb_close(names);
     116                TALLOC_FREE(fname);
    103117                return 0;
    104118        }
    105         else
    106         {
    107                 tdb_close(names);
    108                 memset(buf, 0, PERFCOUNT_MAX_LEN);
    109                 memcpy(buf, dbuf.dptr, dbuf.dsize);
    110                 retval = (uint32)atoi(buf);
    111                 SAFE_FREE(dbuf.dptr);
    112                 return retval;
    113         }
    114         return 0;
    115 }
    116 
    117 /*********************************************************************
    118 *********************************************************************/
    119 
    120 uint32 reg_perfcount_get_last_counter(uint32 base_index)
    121 {
    122         uint32 retval;
     119
     120        tdb_close(names);
     121        TALLOC_FREE(fname);
     122        memset(buf, 0, PERFCOUNT_MAX_LEN);
     123        memcpy(buf, dbuf.dptr, dbuf.dsize);
     124        retval = (uint32_t)atoi(buf);
     125        SAFE_FREE(dbuf.dptr);
     126        return retval;
     127}
     128
     129/*********************************************************************
     130*********************************************************************/
     131
     132uint32_t reg_perfcount_get_last_counter(uint32_t base_index)
     133{
     134        uint32_t retval;
    123135
    124136        if(base_index == 0)
     
    133145*********************************************************************/
    134146
    135 uint32 reg_perfcount_get_last_help(uint32 last_counter)
    136 {
    137         uint32 retval;
     147uint32_t reg_perfcount_get_last_help(uint32_t last_counter)
     148{
     149        uint32_t retval;
    138150
    139151        if(last_counter == 0)
     
    149161*********************************************************************/
    150162
    151 static uint32 _reg_perfcount_multi_sz_from_tdb(TDB_CONTEXT *tdb,
     163static uint32_t _reg_perfcount_multi_sz_from_tdb(TDB_CONTEXT *tdb,
    152164                                               int keyval,
    153165                                               char **retbuf,
    154                                                uint32 buffer_size)
     166                                               uint32_t buffer_size)
    155167{
    156168        TDB_DATA kbuf, dbuf;
    157169        char temp[256];
    158170        char *buf1 = *retbuf;
    159         uint32 working_size = 0;
     171        uint32_t working_size = 0;
    160172        DATA_BLOB name_index, name;
     173        bool ok;
    161174
    162175        memset(temp, 0, sizeof(temp));
     
    173186        }
    174187        /* First encode the name_index */
    175         working_size = (kbuf.dsize + 1)*sizeof(uint16);
     188        working_size = (kbuf.dsize + 1)*sizeof(uint16_t);
    176189        buf1 = (char *)SMB_REALLOC(buf1, buffer_size + working_size);
    177190        if(!buf1) {
     
    179192                return buffer_size;
    180193        }
    181         push_reg_sz(talloc_tos(), &name_index, (const char *)kbuf.dptr);
     194        ok = push_reg_sz(talloc_tos(), &name_index, (const char *)kbuf.dptr);
     195        if (!ok) {
     196                buffer_size = 0;
     197                return buffer_size;
     198        }
    182199        memcpy(buf1+buffer_size, (char *)name_index.data, working_size);
    183200        buffer_size += working_size;
    184201        /* Now encode the actual name */
    185         working_size = (dbuf.dsize + 1)*sizeof(uint16);
     202        working_size = (dbuf.dsize + 1)*sizeof(uint16_t);
    186203        buf1 = (char *)SMB_REALLOC(buf1, buffer_size + working_size);
    187204        if(!buf1) {
     
    192209        memcpy(temp, dbuf.dptr, dbuf.dsize);
    193210        SAFE_FREE(dbuf.dptr);
    194         push_reg_sz(talloc_tos(), &name, temp);
     211        ok = push_reg_sz(talloc_tos(), &name, temp);
     212        if (!ok) {
     213                buffer_size = 0;
     214                return buffer_size;
     215        }
    195216        memcpy(buf1+buffer_size, (char *)name.data, working_size);
    196217        buffer_size += working_size;
     
    204225*********************************************************************/
    205226
    206 uint32 reg_perfcount_get_counter_help(uint32 base_index, char **retbuf)
     227uint32_t reg_perfcount_get_counter_help(uint32_t base_index, char **retbuf)
    207228{
    208229        char *buf1 = NULL;
    209         uint32 buffer_size = 0;
     230        uint32_t buffer_size = 0;
    210231        TDB_CONTEXT *names;
    211         const char *fname = counters_directory( NAMES_DB );
     232        char *fname;
    212233        int i;
    213234
    214         if(base_index == 0)
     235        if (base_index == 0) {
    215236                return 0;
     237        }
     238
     239        fname = counters_directory(NAMES_DB);
     240        if (fname == NULL) {
     241                return 0;
     242        }
    216243
    217244        names = tdb_open_log(fname, 0, TDB_DEFAULT, O_RDONLY, 0444);
    218245
    219         if(names == NULL)
    220         {
     246        if (names == NULL) {
    221247                DEBUG(1, ("reg_perfcount_get_counter_help: unable to open [%s].\n", fname));
     248                TALLOC_FREE(fname);
    222249                return 0;
    223         }   
     250        }
     251        TALLOC_FREE(fname);
    224252
    225253        for(i = 1; i <= base_index; i++)
     
    247275*********************************************************************/
    248276
    249 uint32 reg_perfcount_get_counter_names(uint32 base_index, char **retbuf)
     277uint32_t reg_perfcount_get_counter_names(uint32_t base_index, char **retbuf)
    250278{
    251279        char *buf1 = NULL;
    252         uint32 buffer_size = 0;
     280        uint32_t buffer_size = 0;
    253281        TDB_CONTEXT *names;
    254         const char *fname = counters_directory( NAMES_DB );
     282        char *fname;
    255283        int i;
    256284
    257         if(base_index == 0)
     285        if (base_index == 0) {
    258286                return 0;
     287        }
     288
     289        fname = counters_directory(NAMES_DB);
     290        if (fname == NULL) {
     291                return 0;
     292        }
    259293
    260294        names = tdb_open_log(fname, 0, TDB_DEFAULT, O_RDONLY, 0444);
    261295
    262         if(names == NULL)
    263         {
     296        if (names == NULL) {
    264297                DEBUG(1, ("reg_perfcount_get_counter_names: unable to open [%s].\n", fname));
     298                TALLOC_FREE(fname);
    265299                return 0;
    266         }   
     300        }
     301        TALLOC_FREE(fname);
    267302
    268303        buffer_size = _reg_perfcount_multi_sz_from_tdb(names, 1, retbuf, buffer_size);
     
    342377*********************************************************************/
    343378
    344 static uint32 _reg_perfcount_get_numinst(int objInd, TDB_CONTEXT *names)
     379static uint32_t _reg_perfcount_get_numinst(int objInd, TDB_CONTEXT *names)
    345380{
    346381        TDB_DATA key, data;
     
    351386
    352387        if(data.dptr == NULL)
    353                 return (uint32)PERF_NO_INSTANCES;
     388                return (uint32_t)PERF_NO_INSTANCES;
    354389
    355390        memset(buf, 0, PERFCOUNT_MAX_LEN);
    356391        memcpy(buf, data.dptr, data.dsize);
    357392        SAFE_FREE(data.dptr);
    358         return (uint32)atoi(buf);
     393        return (uint32_t)atoi(buf);
    359394}
    360395
     
    377412        struct PERF_OBJECT_TYPE *obj;
    378413
    379         block->objects = (struct PERF_OBJECT_TYPE *)TALLOC_REALLOC_ARRAY(mem_ctx,
     414        block->objects = (struct PERF_OBJECT_TYPE *)talloc_realloc(mem_ctx,
    380415                                                                  block->objects,
    381416                                                                  struct PERF_OBJECT_TYPE,
     
    394429        block->objects[block->NumObjectTypes].counters = NULL;
    395430        block->objects[block->NumObjectTypes].instances = NULL;
    396         block->objects[block->NumObjectTypes].counter_data.ByteLength = sizeof(uint32);
     431        block->objects[block->NumObjectTypes].counter_data.ByteLength = sizeof(uint32_t);
    397432        block->objects[block->NumObjectTypes].counter_data.data = NULL;
    398433        block->objects[block->NumObjectTypes].DetailLevel = PERF_DETAIL_NOVICE;
     
    412447{
    413448        TDB_CONTEXT *counters;
    414         const char *fname = counters_directory( DATA_DB );
     449        char *fname;
     450
     451        fname = counters_directory(DATA_DB);
     452        if (fname == NULL) {
     453                return false;
     454        }
    415455
    416456        counters = tdb_open_log(fname, 0, TDB_DEFAULT, O_RDONLY, 0444);
    417457
    418         if(counters == NULL)
    419         {
     458        if (counters == NULL) {
    420459                DEBUG(1, ("reg_perfcount_get_counter_data: unable to open [%s].\n", fname));
    421                 return False;
    422         }   
     460                TALLOC_FREE(fname);
     461                return False;
     462        }
     463        TALLOC_FREE(fname);
    423464
    424465        *data = tdb_fetch(counters, key);
     
    432473*********************************************************************/
    433474
    434 static uint32 _reg_perfcount_get_size_field(uint32 CounterType)
    435 {
    436         uint32 retval;
     475static uint32_t _reg_perfcount_get_size_field(uint32_t CounterType)
     476{
     477        uint32_t retval;
    437478
    438479        retval = CounterType;
     
    449490*********************************************************************/
    450491
    451 static uint32 _reg_perfcount_compute_scale(int64_t data)
     492static uint32_t _reg_perfcount_compute_scale(int64_t data)
    452493{
    453494        int scale = 0;
     
    465506        }
    466507
    467         return (uint32)scale;
     508        return (uint32_t)scale;
    468509}
    469510
     
    482523        long int data32, dbuf[2];
    483524        int64_t data64;
    484         uint32 counter_size;
     525        uint32_t counter_size;
    485526
    486527        obj->counters[obj->NumCounters].DefaultScale = 0;
     
    548589
    549590        obj->counter_data.ByteLength += dsize + padding;
    550         obj->counter_data.data = TALLOC_REALLOC_ARRAY(mem_ctx,
     591        obj->counter_data.data = talloc_realloc(mem_ctx,
    551592                                                      obj->counter_data.data,
    552                                                       uint8,
    553                                                       obj->counter_data.ByteLength - sizeof(uint32));
     593                                                      uint8_t,
     594                                                      obj->counter_data.ByteLength - sizeof(uint32_t));
    554595        if(obj->counter_data.data == NULL)
    555596                return False;
     
    557598        {
    558599                memcpy((void *)(obj->counter_data.data +
    559                                 (obj->counter_data.ByteLength - (sizeof(uint32) + dsize))),
     600                                (obj->counter_data.ByteLength - (sizeof(uint32_t) + dsize))),
    560601                       (const void *)dbuf, dsize);
    561602        }
     
    564605                /* Handling PERF_SIZE_VARIABLE_LEN */
    565606                memcpy((void *)(obj->counter_data.data +
    566                                 (obj->counter_data.ByteLength - (sizeof(uint32) + dsize))),
     607                                (obj->counter_data.ByteLength - (sizeof(uint32_t) + dsize))),
    567608                       (const void *)buf, dsize);
    568609        }
     
    636677                        return False;
    637678                }
    638                 obj->counters = (struct PERF_COUNTER_DEFINITION *)TALLOC_REALLOC_ARRAY(mem_ctx,
     679                obj->counters = (struct PERF_COUNTER_DEFINITION *)talloc_realloc(mem_ctx,
    639680                                                                                obj->counters,
    640681                                                                                struct PERF_COUNTER_DEFINITION,
     
    688729        }
    689730        inst->counter_data.ByteLength = data.dsize + sizeof(inst->counter_data.ByteLength);
    690         inst->counter_data.data = TALLOC_REALLOC_ARRAY(mem_ctx,
     731        inst->counter_data.data = talloc_realloc(mem_ctx,
    691732                                                       inst->counter_data.data,
    692                                                        uint8,
     733                                                       uint8_t,
    693734                                                       data.dsize);
    694735        if(inst->counter_data.data == NULL)
     
    720761                        return False;
    721762                }
    722                 inst->data = TALLOC_REALLOC_ARRAY(mem_ctx,
     763                inst->data = talloc_realloc(mem_ctx,
    723764                                                  inst->data,
    724                                                   uint8,
     765                                                  uint8_t,
    725766                                                  inst->NameLength);
    726767                if (inst->data == NULL) {
     
    735776        inst->ParentObjectTitlePointer = 0;
    736777        inst->UniqueID = PERF_NO_UNIQUE_ID;
    737         inst->NameOffset = 6 * sizeof(uint32);
     778        inst->NameOffset = 6 * sizeof(uint32_t);
    738779
    739780        inst->ByteLength = inst->NameOffset + inst->NameLength;
     
    742783        {
    743784                pad = 8 - pad;
    744                 inst->data = TALLOC_REALLOC_ARRAY(mem_ctx,
     785                inst->data = talloc_realloc(mem_ctx,
    745786                                                  inst->data,
    746                                                   uint8,
     787                                                  uint8_t,
    747788                                                  inst->NameLength + pad);
    748789                memset(inst->data + inst->NameLength, 0, pad);
     
    764805
    765806        if(obj->instances == NULL) {
    766                 obj->instances = TALLOC_REALLOC_ARRAY(mem_ctx,
     807                obj->instances = talloc_realloc(mem_ctx,
    767808                                                      obj->instances,
    768809                                                      struct PERF_INSTANCE_DEFINITION,
     
    857898        TDB_CONTEXT *counters;
    858899        bool status = False;
    859         const char *fname = counters_directory( DATA_DB );
     900        char *fname;
     901
     902        fname = counters_directory(DATA_DB);
     903        if (fname == NULL) {
     904                return false;
     905        }
    860906
    861907        counters = tdb_open_log(fname, 0, TDB_DEFAULT, O_RDONLY, 0444);
    862908
    863         if(counters == NULL)
    864         {
     909        if (counters == NULL) {
    865910                DEBUG(1, ("reg_perfcount_init_data_block_perf: unable to open [%s].\n", fname));
    866                 return False;
    867         }   
     911                TALLOC_FREE(fname);
     912                return False;
     913        }
     914        TALLOC_FREE(fname);
    868915
    869916        status = _reg_perfcount_get_64(&PerfFreq, names, 0, "PerfFreq");
     
    920967{
    921968        smb_ucs2_t *temp = NULL;
     969        TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
    922970        time_t tm;
    923 
    924         if (rpcstr_push_talloc(mem_ctx, &temp, "PERF")==(size_t)-1) {
    925                 return false;
    926         }
    927         if (!temp) {
    928                 return false;
     971        size_t sz;
     972
     973        sz = rpcstr_push_talloc(tmp_ctx, &temp, "PERF");
     974        if ((sz == -1) || (temp == NULL)) {
     975                goto err_out;
    929976        }
    930977        memcpy(block->Signature, temp, strlen_w(temp) *2);
     
    943990        make_systemtime(&(block->SystemTime), gmtime(&tm));
    944991        _reg_perfcount_init_data_block_perf(block, names);
    945         memset(temp, 0, sizeof(temp));
    946         rpcstr_push((void *)temp, global_myname(), sizeof(temp), STR_TERMINATE);
     992
     993        sz = rpcstr_push_talloc(tmp_ctx, &temp, lp_netbios_name());
     994        if ((sz == -1) || (temp == NULL)) {
     995                goto err_out;
     996        }
    947997        block->SystemNameLength = (strlen_w(temp) * 2) + 2;
    948         block->data = TALLOC_ZERO_ARRAY(mem_ctx, uint8, block->SystemNameLength + (8 - (block->SystemNameLength % 8)));
     998        block->data = talloc_zero_array(mem_ctx, uint8_t, block->SystemNameLength + (8 - (block->SystemNameLength % 8)));
    949999        if (block->data == NULL) {
    950                 return False;
     1000                goto err_out;
    9511001        }
    9521002        memcpy(block->data, temp, block->SystemNameLength);
     
    9561006           so that the PERF_OBJECT_TYPE struct comes out 64-bit aligned */
    9571007        block->HeaderLength += 8 - (block->HeaderLength % 8);
    958 
    959         return True;
    960 }
    961 
    962 /*********************************************************************
    963 *********************************************************************/
    964 
    965 static uint32 _reg_perfcount_perf_data_block_fixup(struct PERF_DATA_BLOCK *block, TALLOC_CTX *mem_ctx)
     1008        talloc_free(tmp_ctx);
     1009
     1010        return true;
     1011
     1012err_out:
     1013        talloc_free(tmp_ctx);
     1014        return false;
     1015}
     1016
     1017/*********************************************************************
     1018*********************************************************************/
     1019
     1020static uint32_t _reg_perfcount_perf_data_block_fixup(struct PERF_DATA_BLOCK *block, TALLOC_CTX *mem_ctx)
    9661021{
    9671022        int obj, cnt, inst, pad, i;
     
    9941049                                counter = &(object[obj].counters[object[obj].NumCounters - 1]);
    9951050                                counter_data->ByteLength = counter->CounterOffset + counter->CounterSize + sizeof(counter_data->ByteLength);
    996                                 temp = TALLOC_REALLOC_ARRAY(mem_ctx,
     1051                                temp = talloc_realloc(mem_ctx,
    9971052                                                            temp,
    9981053                                                            char,
     
    10151070                                        pad = 8 - pad;
    10161071                                }
    1017                                 counter_data->data = TALLOC_REALLOC_ARRAY(mem_ctx,
     1072                                counter_data->data = talloc_realloc(mem_ctx,
    10181073                                                                         counter_data->data,
    1019                                                                          uint8,
     1074                                                                         uint8_t,
    10201075                                                                         counter_data->ByteLength - sizeof(counter_data->ByteLength) + pad);
    10211076                                if (counter_data->data == NULL) {
     
    10351090                        {
    10361091                                pad = 8 - pad;
    1037                                 object[obj].counter_data.data = TALLOC_REALLOC_ARRAY(mem_ctx,
     1092                                object[obj].counter_data.data = talloc_realloc(mem_ctx,
    10381093                                                                                     object[obj].counter_data.data,
    1039                                                                                      uint8,
     1094                                                                                     uint8_t,
    10401095                                                                                     object[obj].counter_data.ByteLength + pad);
    10411096                                memset((void *)(object[obj].counter_data.data + object[obj].counter_data.ByteLength), 0, pad);
     
    10571112*********************************************************************/
    10581113
    1059 static uint32 reg_perfcount_get_perf_data_block(uint32 base_index,
     1114static uint32_t reg_perfcount_get_perf_data_block(uint32_t base_index,
    10601115                                                TALLOC_CTX *mem_ctx,
    10611116                                                struct PERF_DATA_BLOCK *block,
     
    10631118                                                bool bigendian_data)
    10641119{
    1065         uint32 buffer_size = 0;
    1066         const char *fname = counters_directory( NAMES_DB );
     1120        uint32_t buffer_size = 0;
     1121        char *fname;
    10671122        TDB_CONTEXT *names;
    10681123        int retval = 0;
    10691124
     1125        fname = counters_directory(NAMES_DB);
     1126        if (fname == NULL) {
     1127                return 0;
     1128        }
     1129
    10701130        names = tdb_open_log(fname, 0, TDB_DEFAULT, O_RDONLY, 0444);
    10711131
     
    10731133        {
    10741134                DEBUG(1, ("reg_perfcount_get_perf_data_block: unable to open [%s].\n", fname));
     1135                TALLOC_FREE(fname);
    10751136                return 0;
    10761137        }
     1138        TALLOC_FREE(fname);
    10771139
    10781140        if (!_reg_perfcount_init_data_block(block, mem_ctx, names, bigendian_data)) {
     
    10821144        }
    10831145
    1084         reg_perfcount_get_last_counter(base_index);
    1085 
    1086         if(object_ids == NULL)
    1087         {
    1088                 /* we're getting a request for "Global" here */
    1089                 retval = _reg_perfcount_assemble_global(block, mem_ctx, base_index, names);
    1090         }
    1091         else
    1092         {
    1093                 /* we're getting a request for a specific set of PERF_OBJECT_TYPES */
    1094                 retval = _reg_perfcount_assemble_global(block, mem_ctx, base_index, names);
    1095         }
     1146        retval = _reg_perfcount_assemble_global(block, mem_ctx, base_index, names);
     1147
    10961148        buffer_size = _reg_perfcount_perf_data_block_fixup(block, mem_ctx);
    10971149
     
    12431295        if(!prs_uint32("ByteLength", ps, depth, &counter_data.ByteLength))
    12441296                return False;
    1245         if(!prs_uint8s(False, "CounterData", ps, depth, counter_data.data, counter_data.ByteLength - sizeof(uint32)))
     1297        if(!prs_uint8s(False, "CounterData", ps, depth, counter_data.data, counter_data.ByteLength - sizeof(uint32_t)))
    12461298                return False;
    12471299        if(!prs_align_uint64(ps))
     
    13651417*********************************************************************/
    13661418
    1367 WERROR reg_perfcount_get_hkpd(prs_struct *ps, uint32 max_buf_size, uint32 *outbuf_len, const char *object_ids)
     1419WERROR reg_perfcount_get_hkpd(prs_struct *ps, uint32_t max_buf_size, uint32_t *outbuf_len, const char *object_ids)
    13681420{
    13691421        /*
     
    13761428         */
    13771429        struct PERF_DATA_BLOCK block;
    1378         uint32 buffer_size, base_index;
     1430        uint32_t buffer_size, base_index;
    13791431
    13801432        buffer_size = 0;
  • vendor/current/source3/registry/reg_perfcount.h

    r740 r988  
    2525#include "reg_parse_prs.h"
    2626
    27 uint32 reg_perfcount_get_base_index(void);
    28 uint32 reg_perfcount_get_last_counter(uint32 base_index);
    29 uint32 reg_perfcount_get_last_help(uint32 last_counter);
    30 uint32 reg_perfcount_get_counter_help(uint32 base_index, char **retbuf);
    31 uint32 reg_perfcount_get_counter_names(uint32 base_index, char **retbuf);
    32 WERROR reg_perfcount_get_hkpd(prs_struct *ps, uint32 max_buf_size, uint32 *outbuf_len, const char *object_ids);
     27uint32_t reg_perfcount_get_base_index(void);
     28uint32_t reg_perfcount_get_last_counter(uint32_t base_index);
     29uint32_t reg_perfcount_get_last_help(uint32_t last_counter);
     30uint32_t reg_perfcount_get_counter_help(uint32_t base_index, char **retbuf);
     31uint32_t reg_perfcount_get_counter_names(uint32_t base_index, char **retbuf);
     32WERROR reg_perfcount_get_hkpd(prs_struct *ps, uint32_t max_buf_size, uint32_t *outbuf_len, const char *object_ids);
    3333
    3434#endif /* _REG_PERFCOUNT_H */
  • vendor/current/source3/registry/reg_util_internal.c

    r740 r988  
    9898
    9999        /* skip leading '\' chars */
    100         p = (char *)keyname;
    101         while (*p == '\\') {
    102                 p++;
     100        while (*keyname == '\\') {
     101                keyname++;
    103102        }
    104103
    105         nkeyname = talloc_strdup(ctx, p);
     104        nkeyname = talloc_strdup(ctx, keyname);
    106105        if (nkeyname == NULL) {
    107106                return NULL;
     
    115114        }
    116115
    117         strupper_m(nkeyname);
     116        if (!strupper_m(nkeyname)) {
     117                TALLOC_FREE(nkeyname);
     118                return NULL;
     119        }
    118120
    119121        return nkeyname;
  • vendor/current/source3/registry/reg_util_token.c

    r740 r988  
    3939        }
    4040
    41         token = TALLOC_ZERO_P(mem_ctx, struct security_token);
     41        token = talloc_zero(mem_ctx, struct security_token);
    4242        if (token == NULL) {
    4343                DEBUG(1, ("talloc failed\n"));
  • vendor/current/source3/registry/regfio.c

    r746 r988  
    2323#include "../librpc/gen_ndr/ndr_security.h"
    2424#include "../libcli/security/security_descriptor.h"
     25#include "../libcli/security/secdesc.h"
    2526
    2627#undef DBGC_CLASS
     
    4546static bool smb_io_time(const char *desc, NTTIME *nttime, prs_struct *ps, int depth)
    4647{
    47         uint32 low, high;
     48        uint32_t low, high;
    4849        if (nttime == NULL)
    4950                return False;
     
    7576*******************************************************************/
    7677
    77 static int write_block( REGF_FILE *file, prs_struct *ps, uint32 offset )
     78static int write_block( REGF_FILE *file, prs_struct *ps, uint32_t offset )
    7879{
    7980        int bytes_written, returned;
    8081        char *buffer = prs_data_p( ps );
    81         uint32 buffer_size = prs_data_size( ps );
     82        uint32_t buffer_size = prs_data_size( ps );
    8283        SMB_STRUCT_STAT sbuf;
    8384
     
    113114*******************************************************************/
    114115
    115 static int read_block( REGF_FILE *file, prs_struct *ps, uint32 file_offset, uint32 block_size )
     116static int read_block( REGF_FILE *file, prs_struct *ps, uint32_t file_offset, uint32_t block_size )
    116117{
    117118        int bytes_read, returned;
     
    199200
    200201        if ( hbin->free_off != REGF_OFFSET_NONE ) {
    201                 uint32 header = 0xffffffff;
    202 
    203                 if ( !prs_set_offset( &hbin->ps, hbin->free_off-sizeof(uint32) ) )
     202                uint32_t header = 0xffffffff;
     203
     204                if ( !prs_set_offset( &hbin->ps, hbin->free_off-sizeof(uint32_t) ) )
    204205                        return False;
    205206                if ( !prs_uint32( "free_size", &hbin->ps, 0, &hbin->free_size ) )
     
    224225
    225226        for ( p=file->block_list; p && p!=hbin; p=p->next )
    226                 ;;
     227                ;
    227228
    228229        if ( p == hbin ) {
     
    246247        depth++;
    247248       
    248         if ( !prs_uint8s( True, "header", ps, depth, (uint8*)file->header, sizeof( file->header )) )
     249        if ( !prs_uint8s( True, "header", ps, depth, (uint8_t *)file->header, sizeof( file->header )) )
    249250                return False;
    250251       
     
    303304static bool prs_hbin_block( const char *desc, prs_struct *ps, int depth, REGF_HBIN *hbin )
    304305{
    305         uint32 block_size2;
     306        uint32_t block_size2;
    306307
    307308        prs_debug(ps, depth, desc, "prs_regf_block");
    308309        depth++;
    309310       
    310         if ( !prs_uint8s( True, "header", ps, depth, (uint8*)hbin->header, sizeof( hbin->header )) )
     311        if ( !prs_uint8s( True, "header", ps, depth, (uint8_t*)hbin->header, sizeof( hbin->header )) )
    311312                return False;
    312313
     
    338339static bool prs_nk_rec( const char *desc, prs_struct *ps, int depth, REGF_NK_REC *nk )
    339340{
    340         uint16 class_length, name_length;
    341         uint32 start;
    342         uint32 data_size, start_off, end_off;
    343         uint32 unknown_off = REGF_OFFSET_NONE;
     341        uint16_t class_length, name_length;
     342        uint32_t start;
     343        uint32_t data_size, start_off, end_off;
     344        uint32_t unknown_off = REGF_OFFSET_NONE;
    344345
    345346        nk->hbin_off = prs_offset( ps );
     
    351352        /* back up and get the data_size */
    352353       
    353         if ( !prs_set_offset( ps, prs_offset(ps)-sizeof(uint32)) )
     354        if ( !prs_set_offset( ps, prs_offset(ps)-sizeof(uint32_t)) )
    354355                return False;
    355356        start_off = prs_offset( ps );
     
    357358                return False;
    358359       
    359         if ( !prs_uint8s( True, "header", ps, depth, (uint8*)nk->header, sizeof( nk->header )) )
     360        if ( !prs_uint8s( True, "header", ps, depth, (uint8_t *)nk->header, sizeof( nk->header )) )
    360361                return False;
    361362               
     
    418419                }
    419420
    420                 if ( !prs_uint8s( True, "name", ps, depth, (uint8*)nk->keyname, name_length) )
     421                if ( !prs_uint8s( True, "name", ps, depth, (uint8_t *)nk->keyname, name_length) )
    421422                        return False;
    422423
     
    442443*******************************************************************/
    443444
    444 static uint32 regf_block_checksum( prs_struct *ps )
     445static uint32_t regf_block_checksum( prs_struct *ps )
    445446{
    446447        char *buffer = prs_data_p( ps );
    447         uint32 checksum, x;
     448        uint32_t checksum, x;
    448449        int i;
    449450
     
    466467{
    467468        prs_struct ps;
    468         uint32 checksum;
     469        uint32_t checksum;
    469470       
    470471        /* grab the first block from the file */
     
    496497{
    497498        REGF_HBIN *hbin;
    498         uint32 record_size, curr_off, block_size, header;
    499        
    500         if ( !(hbin = TALLOC_ZERO_P(file->mem_ctx, REGF_HBIN)) )
     499        uint32_t record_size, curr_off, block_size, header;
     500       
     501        if ( !(hbin = talloc_zero(file->mem_ctx, REGF_HBIN)) )
    501502                return NULL;
    502503        hbin->file_off = offset;
     
    521522        /* remember that the record_size is in the 4 bytes preceeding the record itself */
    522523
    523         if ( !prs_set_offset( &hbin->ps, file->data_offset+HBIN_HDR_SIZE-sizeof(uint32) ) )
    524                 return False;
     524        if ( !prs_set_offset( &hbin->ps, file->data_offset+HBIN_HDR_SIZE-sizeof(uint32_t) ) )
     525                return NULL;
    525526
    526527        record_size = 0;
     
    545546
    546547                if ( !prs_set_offset( &hbin->ps, curr_off) )
    547                         return False;
     548                        return NULL;
    548549
    549550                if ( !prs_uint32( "rec_size", &hbin->ps, 0, &record_size ) )
    550                         return False;
     551                        return NULL;
    551552                if ( !prs_uint32( "header", &hbin->ps, 0, &header ) )
    552                         return False;
     553                        return NULL;
    553554               
    554555                SMB_ASSERT( record_size != 0 );
     
    567568                   record header */
    568569
    569                 hbin->free_off = curr_off + sizeof(uint32);
     570                hbin->free_off = curr_off + sizeof(uint32_t);
    570571                hbin->free_size = record_size;
    571572        }
     
    574575
    575576        if ( !prs_set_offset( &hbin->ps, file->data_offset+HBIN_HDR_SIZE )  )
    576                 return False;
     577                return NULL;
    577578       
    578579        return hbin;
     
    584585*******************************************************************/
    585586
    586 static bool hbin_contains_offset( REGF_HBIN *hbin, uint32 offset )
     587static bool hbin_contains_offset( REGF_HBIN *hbin, uint32_t offset )
    587588{
    588589        if ( !hbin )
     
    600601*******************************************************************/
    601602
    602 static REGF_HBIN* lookup_hbin_block( REGF_FILE *file, uint32 offset )
     603static REGF_HBIN* lookup_hbin_block( REGF_FILE *file, uint32_t offset )
    603604{
    604605        REGF_HBIN *hbin = NULL;
    605         uint32 block_off;
     606        uint32_t block_off;
    606607
    607608        /* start with the open list */
     
    659660        int i;
    660661        REGF_LF_REC *lf = &nk->subkeys;
    661         uint32 data_size, start_off, end_off;
     662        uint32_t data_size, start_off, end_off;
    662663
    663664        prs_debug(&hbin->ps, depth, desc, "prs_lf_records");
     
    676677        /* backup and get the data_size */
    677678       
    678         if ( !prs_set_offset( &hbin->ps, prs_offset(&hbin->ps)-sizeof(uint32)) )
     679        if ( !prs_set_offset( &hbin->ps, prs_offset(&hbin->ps)-sizeof(uint32_t)) )
    679680                return False;
    680681        start_off = prs_offset( &hbin->ps );
     
    682683                return False;
    683684
    684         if ( !prs_uint8s( True, "header", &hbin->ps, depth, (uint8*)lf->header, sizeof( lf->header )) )
     685        if ( !prs_uint8s( True, "header", &hbin->ps, depth, (uint8_t *)lf->header, sizeof( lf->header )) )
    685686                return False;
    686687               
     
    722723{
    723724        prs_struct *ps = &hbin->ps;
    724         uint16 tag = 0xFFFF;
    725         uint32 data_size, start_off, end_off;
     725        uint16_t tag = 0xFFFF;
     726        uint32_t data_size, start_off, end_off;
    726727
    727728
     
    734735        /* backup and get the data_size */
    735736       
    736         if ( !prs_set_offset( &hbin->ps, prs_offset(&hbin->ps)-sizeof(uint32)) )
     737        if ( !prs_set_offset( &hbin->ps, prs_offset(&hbin->ps)-sizeof(uint32_t)) )
    737738                return False;
    738739        start_off = prs_offset( &hbin->ps );
     
    740741                return False;
    741742
    742         if ( !prs_uint8s( True, "header", ps, depth, (uint8*)sk->header, sizeof( sk->header )) )
     743        if ( !prs_uint8s( True, "header", ps, depth, (uint8_t *)sk->header, sizeof( sk->header )) )
    743744                return False;
    744745        if ( !prs_uint16( "tag", ps, depth, &tag))
     
    768769                                return False;
    769770                } else {
    770                         blob = data_blob_const(prs_data_p(&hbin->ps),
    771                                                prs_data_size(&hbin->ps));
     771                        blob = data_blob_const(
     772                                prs_data_p(&hbin->ps) + prs_offset(&hbin->ps),
     773                                prs_data_size(&hbin->ps) - prs_offset(&hbin->ps)
     774                               );
    772775                        status = unmarshall_sec_desc(mem_ctx,
    773776                                                     blob.data, blob.length,
     
    798801static bool hbin_prs_vk_rec( const char *desc, REGF_HBIN *hbin, int depth, REGF_VK_REC *vk, REGF_FILE *file )
    799802{
    800         uint32 offset;
    801         uint16 name_length;
     803        uint32_t offset;
     804        uint16_t name_length;
    802805        prs_struct *ps = &hbin->ps;
    803         uint32 data_size, start_off, end_off;
     806        uint32_t data_size, start_off, end_off;
    804807
    805808        prs_debug(ps, depth, desc, "prs_vk_rec");
     
    808811        /* backup and get the data_size */
    809812       
    810         if ( !prs_set_offset( &hbin->ps, prs_offset(&hbin->ps)-sizeof(uint32)) )
     813        if ( !prs_set_offset( &hbin->ps, prs_offset(&hbin->ps)-sizeof(uint32_t)) )
    811814                return False;
    812815        start_off = prs_offset( &hbin->ps );
     
    814817                return False;
    815818
    816         if ( !prs_uint8s( True, "header", ps, depth, (uint8*)vk->header, sizeof( vk->header )) )
     819        if ( !prs_uint8s( True, "header", ps, depth, (uint8_t *)vk->header, sizeof( vk->header )) )
    817820                return False;
    818821
     
    843846                                return False;
    844847                }
    845                 if ( !prs_uint8s( True, "name", ps, depth, (uint8*)vk->valuename, name_length ) )
     848                if ( !prs_uint8s( True, "name", ps, depth, (uint8_t *)vk->valuename, name_length ) )
    846849                        return False;
    847850        }
     
    861864                if ( !(vk->data_size & VK_DATA_IN_OFFSET) ) {
    862865                        REGF_HBIN *hblock = hbin;
    863                         uint32 data_rec_size;
     866                        uint32_t data_rec_size;
    864867
    865868                        if ( UNMARSHALLING(&hbin->ps) ) {
    866                                 if ( !(vk->data = PRS_ALLOC_MEM( ps, uint8, vk->data_size) ) )
     869                                if ( !(vk->data = PRS_ALLOC_MEM( ps, uint8_t, vk->data_size) ) )
    867870                                        return False;
    868871                        }
     
    873876                                        return False;
    874877                        }
    875                         if ( !(prs_set_offset( &hblock->ps, (vk->data_off+HBIN_HDR_SIZE-hblock->first_hbin_off)-sizeof(uint32) )) )
     878                        if ( !(prs_set_offset( &hblock->ps, (vk->data_off+HBIN_HDR_SIZE-hblock->first_hbin_off)-sizeof(uint32_t) )) )
    876879                                return False;
    877880
    878881                        if ( MARSHALLING(&hblock->ps) ) {
    879                                 data_rec_size = ( (vk->data_size+sizeof(uint32)) & 0xfffffff8 ) + 8;
     882                                data_rec_size = ( (vk->data_size+sizeof(uint32_t)) & 0xfffffff8 ) + 8;
    880883                                data_rec_size = ( data_rec_size - 1 ) ^ 0xFFFFFFFF;
    881884                        }
     
    889892                }
    890893                else {
    891                         if ( !(vk->data = PRS_ALLOC_MEM( ps, uint8, 4 ) ) )
     894                        if ( !(vk->data = PRS_ALLOC_MEM( ps, uint8_t, 4 ) ) )
    892895                                return False;
    893896                        SIVAL( vk->data, 0, vk->data_off );
     
    916919{
    917920        int i;
    918         uint32 record_size;
     921        uint32_t record_size;
    919922
    920923        prs_debug(&hbin->ps, depth, desc, "prs_vk_records");
     
    933936        /* convert the offset to something relative to this HBIN block */
    934937       
    935         if ( !prs_set_offset( &hbin->ps, nk->values_off+HBIN_HDR_SIZE-hbin->first_hbin_off-sizeof(uint32)) )
     938        if ( !prs_set_offset( &hbin->ps, nk->values_off+HBIN_HDR_SIZE-hbin->first_hbin_off-sizeof(uint32_t)) )
    936939                return False;
    937940
    938941        if ( MARSHALLING( &hbin->ps) ) {
    939                 record_size = ( ( nk->num_values * sizeof(uint32) ) & 0xfffffff8 ) + 8;
     942                record_size = ( ( nk->num_values * sizeof(uint32_t) ) & 0xfffffff8 ) + 8;
    940943                record_size = (record_size - 1) ^ 0xFFFFFFFF;
    941944        }
     
    951954        for ( i=0; i<nk->num_values; i++ ) {
    952955                REGF_HBIN *sub_hbin = hbin;
    953                 uint32 new_offset;
     956                uint32_t new_offset;
    954957       
    955958                if ( !hbin_contains_offset( hbin, nk->values[i].rec_off ) ) {
     
    980983*******************************************************************/
    981984
    982 static REGF_SK_REC* find_sk_record_by_offset( REGF_FILE *file, uint32 offset )
     985static REGF_SK_REC* find_sk_record_by_offset( REGF_FILE *file, uint32_t offset )
    983986{
    984987        REGF_SK_REC *p_sk;
     
    10671070                        sub_hbin = lookup_hbin_block( file, nk->sk_off );
    10681071                        if ( !sub_hbin ) {
    1069                                 DEBUG(0,("hbin_prs_key: Failed to find HBIN block containing sk_offset [0x%x]\n",
    1070                                         nk->subkeys_off));
     1072                                DEBUG(0,("hbin_prs_key: Failed to find HBIN block containing sk_off [0x%x]\n",
     1073                                        nk->sk_off));
    10711074                                return False;
    10721075                        }
    10731076                }
    10741077               
    1075                 if ( !(nk->sec_desc = TALLOC_ZERO_P( file->mem_ctx, REGF_SK_REC )) )
     1078                if ( !(nk->sec_desc = talloc_zero( file->mem_ctx, REGF_SK_REC )) )
    10761079                        return False;
    10771080                nk->sec_desc->sk_off = nk->sk_off;
     
    10931096static bool next_record( REGF_HBIN *hbin, const char *hdr, bool *eob )
    10941097{
    1095         uint8 header[REC_HDR_SIZE];
    1096         uint32 record_size;
    1097         uint32 curr_off, block_size;
     1098        uint8_t header[REC_HDR_SIZE];
     1099        uint32_t record_size;
     1100        uint32_t curr_off, block_size;
    10981101        bool found = False;
    10991102        prs_struct *ps = &hbin->ps;
     
    11061109           and we need to backup to read the record size */
    11071110
    1108         curr_off -= sizeof(uint32);
     1111        curr_off -= sizeof(uint32_t);
    11091112
    11101113        block_size = prs_data_size( ps );
    11111114        record_size = 0;
    1112         memset( header, 0x0, sizeof(uint8)*REC_HDR_SIZE );
     1115        memset( header, 0x0, sizeof(uint8_t)*REC_HDR_SIZE );
    11131116        while ( !found ) {
    11141117
     
    11321135                if ( memcmp( header, hdr, REC_HDR_SIZE ) == 0 ) {
    11331136                        found = True;
    1134                         curr_off += sizeof(uint32);
     1137                        curr_off += sizeof(uint32_t);
    11351138                }
    11361139        }
     
    13721375        REGF_NK_REC *nk;
    13731376        REGF_HBIN   *hbin;
    1374         uint32      offset = REGF_BLOCKSIZE;
     1377        uint32_t      offset = REGF_BLOCKSIZE;
    13751378        bool        found = False;
    13761379        bool        eob;
     
    13791382                return NULL;
    13801383               
    1381         if ( !(nk = TALLOC_ZERO_P( file->mem_ctx, REGF_NK_REC )) ) {
     1384        if ( !(nk = talloc_zero( file->mem_ctx, REGF_NK_REC )) ) {
    13821385                DEBUG(0,("regfio_rootkey: talloc() failed!\n"));
    13831386                return NULL;
     
    14271430        REGF_NK_REC *subkey;
    14281431        REGF_HBIN   *hbin;
    1429         uint32      nk_offset;
     1432        uint32_t      nk_offset;
    14301433
    14311434        /* see if there is anything left to report */
     
    14471450               
    14481451        nk->subkey_index++;
    1449         if ( !(subkey = TALLOC_ZERO_P( file->mem_ctx, REGF_NK_REC )) )
     1452        if ( !(subkey = talloc_zero( file->mem_ctx, REGF_NK_REC )) )
    14501453                return NULL;
    14511454               
     
    14601463*******************************************************************/
    14611464
    1462 static REGF_HBIN* regf_hbin_allocate( REGF_FILE *file, uint32 block_size )
     1465static REGF_HBIN* regf_hbin_allocate( REGF_FILE *file, uint32_t block_size )
    14631466{
    14641467        REGF_HBIN *hbin;
    14651468        SMB_STRUCT_STAT sbuf;
    14661469
    1467         if ( !(hbin = TALLOC_ZERO_P( file->mem_ctx, REGF_HBIN )) )
     1470        if ( !(hbin = talloc_zero( file->mem_ctx, REGF_HBIN )) )
    14681471                return NULL;
    14691472
     
    14791482
    14801483        hbin->free_off       = HBIN_HEADER_REC_SIZE;
    1481         hbin->free_size      = block_size - hbin->free_off + sizeof(uint32);
     1484        hbin->free_size      = block_size - hbin->free_off + sizeof(uint32_t);
    14821485
    14831486        hbin->block_size     = block_size;
     
    15011504*******************************************************************/
    15021505
    1503 static void update_free_space( REGF_HBIN *hbin, uint32 size_used )
     1506static void update_free_space( REGF_HBIN *hbin, uint32_t size_used )
    15041507{
    15051508        hbin->free_off  += size_used;
     
    15161519*******************************************************************/
    15171520
    1518 static REGF_HBIN* find_free_space( REGF_FILE *file, uint32 size )
     1521static REGF_HBIN* find_free_space( REGF_FILE *file, uint32_t size )
    15191522{
    15201523        REGF_HBIN *hbin, *p_hbin;
    1521         uint32 block_off;
     1524        uint32_t block_off;
    15221525        bool cached;
    15231526
     
    15751578
    15761579        if ( !hbin ) {
    1577                 uint32 alloc_size;
     1580                uint32_t alloc_size;
    15781581
    15791582                /* allocate in multiples of REGF_ALLOC_BLOCK; make sure (size + hbin_header) fits */
     
    15911594        /* set the offset to be ready to write */
    15921595
    1593         if ( !prs_set_offset( &hbin->ps, hbin->free_off-sizeof(uint32) ) )
     1596        if ( !prs_set_offset( &hbin->ps, hbin->free_off-sizeof(uint32_t) ) )
    15941597                return NULL;
    15951598
     
    15991602
    16001603        if ( !prs_uint32("allocated_size", &hbin->ps, 0, &size) )
    1601                 return False;
     1604                return NULL;
    16021605
    16031606        update_free_space( hbin, size );
     
    16091612*******************************************************************/
    16101613
    1611 static uint32 sk_record_data_size( struct security_descriptor * sd )
    1612 {
    1613         uint32 size, size_mod8;
     1614static uint32_t sk_record_data_size( struct security_descriptor * sd )
     1615{
     1616        uint32_t size, size_mod8;
    16141617
    16151618        size_mod8 = 0;
     
    16171620        /* the record size is sizeof(hdr) + name + static members + data_size_field */
    16181621
    1619         size = sizeof(uint32)*5 + ndr_size_security_descriptor(sd, 0) + sizeof(uint32);
     1622        size = sizeof(uint32_t)*5 + ndr_size_security_descriptor(sd, 0) + sizeof(uint32_t);
    16201623
    16211624        /* multiple of 8 */
     
    16301633*******************************************************************/
    16311634
    1632 static uint32 vk_record_data_size( REGF_VK_REC *vk )
    1633 {
    1634         uint32 size, size_mod8;
     1635static uint32_t vk_record_data_size( REGF_VK_REC *vk )
     1636{
     1637        uint32_t size, size_mod8;
    16351638
    16361639        size_mod8 = 0;
     
    16381641        /* the record size is sizeof(hdr) + name + static members + data_size_field */
    16391642
    1640         size = REC_HDR_SIZE + (sizeof(uint16)*3) + (sizeof(uint32)*3) + sizeof(uint32);
     1643        size = REC_HDR_SIZE + (sizeof(uint16_t)*3) + (sizeof(uint32_t)*3) + sizeof(uint32_t);
    16411644
    16421645        if ( vk->valuename )
     
    16541657*******************************************************************/
    16551658
    1656 static uint32 lf_record_data_size( uint32 num_keys )
    1657 {
    1658         uint32 size, size_mod8;
     1659static uint32_t lf_record_data_size( uint32_t num_keys )
     1660{
     1661        uint32_t size, size_mod8;
    16591662
    16601663        size_mod8 = 0;
    16611664
    1662         /* the record size is sizeof(hdr) + num_keys + sizeof of hash_array + data_size_uint32 */
    1663 
    1664         size = REC_HDR_SIZE + sizeof(uint16) + (sizeof(REGF_HASH_REC) * num_keys) + sizeof(uint32);
     1665        /* the record size is sizeof(hdr) + num_keys + sizeof of hash_array + data_size_uint32_t */
     1666
     1667        size = REC_HDR_SIZE + sizeof(uint16_t) + (sizeof(REGF_HASH_REC) * num_keys) + sizeof(uint32_t);
    16651668
    16661669        /* multiple of 8 */
     
    16751678*******************************************************************/
    16761679
    1677 static uint32 nk_record_data_size( REGF_NK_REC *nk )
    1678 {
    1679         uint32 size, size_mod8;
     1680static uint32_t nk_record_data_size( REGF_NK_REC *nk )
     1681{
     1682        uint32_t size, size_mod8;
    16801683
    16811684        size_mod8 = 0;
    16821685
    1683         /* the record size is static + length_of_keyname + length_of_classname + data_size_uint32 */
    1684 
    1685         size = 0x4c + strlen(nk->keyname) + sizeof(uint32);
     1686        /* the record size is static + length_of_keyname + length_of_classname + data_size_uint32_t */
     1687
     1688        size = 0x4c + strlen(nk->keyname) + sizeof(uint32_t);
    16861689
    16871690        if ( nk->classname )
     
    17171720        vk->type      = regval_type( value );
    17181721
    1719         if ( vk->data_size > sizeof(uint32) ) {
    1720                 uint32 data_size = ( (vk->data_size+sizeof(uint32)) & 0xfffffff8 ) + 8;
    1721 
    1722                 vk->data = (uint8 *)TALLOC_MEMDUP( file->mem_ctx,
     1722        if ( vk->data_size > sizeof(uint32_t) ) {
     1723                uint32_t data_size = ( (vk->data_size+sizeof(uint32_t)) & 0xfffffff8 ) + 8;
     1724
     1725                vk->data = (uint8_t *)talloc_memdup( file->mem_ctx,
    17231726                                                   regval_data_p(value),
    17241727                                                   vk->data_size );
     
    17391742
    17401743                if ( vk->data_size != 0 )
    1741                         memcpy( &vk->data_off, regval_data_p(value), sizeof(uint32) );
     1744                        memcpy( &vk->data_off, regval_data_p(value), vk->data_size);
    17421745                vk->data_size |= VK_DATA_IN_OFFSET;             
    17431746        }
     
    17511754static int hashrec_cmp( REGF_HASH_REC *h1, REGF_HASH_REC *h2 )
    17521755{
    1753         return StrCaseCmp( h1->fullname, h2->fullname );
     1756        return strcasecmp_m( h1->fullname, h2->fullname );
    17541757}
    17551758
     
    17631766        REGF_NK_REC *nk;
    17641767        REGF_HBIN *vlist_hbin = NULL;
    1765         uint32 size;
    1766 
    1767         if ( !(nk = TALLOC_ZERO_P( file->mem_ctx, REGF_NK_REC )) )
     1768        uint32_t size;
     1769
     1770        if ( !(nk = talloc_zero( file->mem_ctx, REGF_NK_REC )) )
    17681771                return NULL;
    17691772
     
    18041807
    18051808                hash->nk_off = prs_offset( &nk->hbin->ps ) + nk->hbin->first_hbin_off - HBIN_HDR_SIZE;
    1806                 memcpy( hash->keycheck, name, sizeof(uint32) );
     1809                memcpy(hash->keycheck, name, MIN(strlen(name),sizeof(uint32_t)));
    18071810                hash->fullname = talloc_strdup( file->mem_ctx, name );
    18081811                parent->subkey_index++;
     
    18121815
    18131816                if ( !hbin_prs_lf_records( "lf_rec", parent->subkeys.hbin, 0, parent ) )
    1814                         return False;
     1817                        return NULL;
    18151818        }
    18161819
     
    18191822        nk->sk_off = REGF_OFFSET_NONE;
    18201823        if ( sec_desc ) {
    1821                 uint32 sk_size = sk_record_data_size( sec_desc );
     1824                uint32_t sk_size = sk_record_data_size( sec_desc );
    18221825                REGF_HBIN *sk_hbin;
    18231826
     
    18311834                        }
    18321835
    1833                         if ( !(nk->sec_desc = TALLOC_ZERO_P( file->mem_ctx, REGF_SK_REC )) )
     1836                        if ( !(nk->sec_desc = talloc_zero( file->mem_ctx, REGF_SK_REC )) )
    18341837                                return NULL;
    18351838       
     
    18481851                        /* size value must be self-inclusive */
    18491852                        nk->sec_desc->size      = ndr_size_security_descriptor(sec_desc, 0)
    1850                                 + sizeof(uint32);
    1851 
    1852                         DLIST_ADD_END( file->sec_desc_list, nk->sec_desc, REGF_SK_REC *);
     1853                                + sizeof(uint32_t);
     1854
     1855                        DLIST_ADD_END( file->sec_desc_list, nk->sec_desc);
    18531856
    18541857                        /* update the offsets for us and the previous sd in the list.
     
    18831886        nk->subkeys_off = REGF_OFFSET_NONE;
    18841887        if ( (nk->num_subkeys = regsubkey_ctr_numkeys( subkeys )) != 0 ) {
    1885                 uint32 lf_size = lf_record_data_size( nk->num_subkeys );
    1886                 uint32 namelen;
     1888                uint32_t lf_size = lf_record_data_size( nk->num_subkeys );
     1889                uint32_t namelen;
    18871890                int i;
    18881891               
     
    18981901                nk->subkeys.num_keys = nk->num_subkeys;
    18991902                if (nk->subkeys.num_keys) {
    1900                         if ( !(nk->subkeys.hashes = TALLOC_ZERO_ARRAY( file->mem_ctx, REGF_HASH_REC, nk->subkeys.num_keys )) )
     1903                        if ( !(nk->subkeys.hashes = talloc_zero_array( file->mem_ctx, REGF_HASH_REC, nk->subkeys.num_keys )) )
    19011904                                return NULL;
    19021905                } else {
     
    19171920        nk->values_off = REGF_OFFSET_NONE;
    19181921        if ( (nk->num_values = regval_ctr_numvals( values )) != 0 ) {
    1919                 uint32 vlist_size = ( ( nk->num_values * sizeof(uint32) ) & 0xfffffff8 ) + 8;
     1922                uint32_t vlist_size = ( ( nk->num_values * sizeof(uint32_t) ) & 0xfffffff8 ) + 8;
    19201923                int i;
    19211924               
     
    19261929       
    19271930                if (nk->num_values) {
    1928                         if ( !(nk->values = TALLOC_ARRAY( file->mem_ctx, REGF_VK_REC, nk->num_values )) )
     1931                        if ( !(nk->values = talloc_array( file->mem_ctx, REGF_VK_REC, nk->num_values )) )
    19291932                                return NULL;
    19301933                } else {
     
    19351938
    19361939                for ( i=0; i<nk->num_values; i++ ) {
    1937                         uint32 vk_size, namelen, datalen;
     1940                        uint32_t vk_size, namelen, datalen;
    19381941                        struct regval_blob *r;
    19391942
     
    19641967        prs_set_offset( &nk->hbin->ps, nk->hbin_off );
    19651968        if ( !prs_nk_rec( "nk_rec", &nk->hbin->ps, 0, nk ) )
    1966                 return False;
     1969                return NULL;
    19671970
    19681971        if ( nk->num_values ) {
    19691972                if ( !hbin_prs_vk_records( "vk_records", vlist_hbin, 0, nk, file ) )
    1970                         return False;
     1973                        return NULL;
    19711974        }
    19721975
  • vendor/current/source3/registry/regfio.h

    r740 r988  
    6565typedef struct regf_hbin {
    6666        struct regf_hbin *prev, *next;
    67         uint32 file_off;                /* my offset in the registry file */
    68         uint32 free_off;                /* offset to free space within the hbin record */
    69         uint32 free_size;               /* amount of data left in the block */
     67        uint32_t file_off;              /* my offset in the registry file */
     68        uint32_t free_off;              /* offset to free space within the hbin record */
     69        uint32_t free_size;             /* amount of data left in the block */
    7070        int ref_count;                  /* how many active records are pointing to this block (not used currently) */
    7171       
    7272        char   header[HBIN_HDR_SIZE];   /* "hbin" */
    73         uint32 first_hbin_off;          /* offset from first hbin block */
    74         uint32 block_size;              /* block size of this blockually a multiple of 4096Kb) */
     73        uint32_t first_hbin_off;                /* offset from first hbin block */
     74        uint32_t block_size;            /* block size of this blockually a multiple of 4096Kb) */
    7575
    7676        prs_struct ps;                  /* data */
     
    8282
    8383typedef struct {
    84         uint32 nk_off;
    85         uint8 keycheck[sizeof(uint32)];
     84        uint32_t nk_off;
     85        uint8_t keycheck[sizeof(uint32_t)];
    8686        char *fullname;
    8787} REGF_HASH_REC;
     
    8989typedef struct {
    9090        REGF_HBIN *hbin;        /* pointer to HBIN record (in memory) containing this nk record */
    91         uint32 hbin_off;        /* offset from beginning of this hbin block */
    92         uint32 rec_size;        /* ((start_offset - end_offset) & 0xfffffff8) */
    93 
    94         char header[REC_HDR_SIZE];
    95         uint16 num_keys;
     91        uint32_t hbin_off;      /* offset from beginning of this hbin block */
     92        uint32_t rec_size;      /* ((start_offset - end_offset) & 0xfffffff8) */
     93
     94        char header[REC_HDR_SIZE];
     95        uint16_t num_keys;
    9696        REGF_HASH_REC *hashes;
    9797} REGF_LF_REC;
     
    101101typedef struct {
    102102        REGF_HBIN *hbin;        /* pointer to HBIN record (in memory) containing this nk record */
    103         uint32 hbin_off;        /* offset from beginning of this hbin block */
    104         uint32 rec_size;        /* ((start_offset - end_offset) & 0xfffffff8) */
    105         uint32 rec_off;         /* offset stored in the value list */
     103        uint32_t hbin_off;      /* offset from beginning of this hbin block */
     104        uint32_t rec_size;      /* ((start_offset - end_offset) & 0xfffffff8) */
     105        uint32_t rec_off;               /* offset stored in the value list */
    106106       
    107107        char header[REC_HDR_SIZE];
    108108        char *valuename;
    109         uint32 data_size;
    110         uint32 data_off;
    111         uint8  *data;
    112         uint32 type;
    113         uint16 flag;
     109        uint32_t data_size;
     110        uint32_t data_off;
     111        uint8_t  *data;
     112        uint32_t type;
     113        uint16_t flag;
    114114} REGF_VK_REC;
    115115
     
    121121        struct _regf_sk_rec *next, *prev;
    122122        REGF_HBIN *hbin;        /* pointer to HBIN record (in memory) containing this nk record */
    123         uint32 hbin_off;        /* offset from beginning of this hbin block */
    124         uint32 rec_size;        /* ((start_offset - end_offset) & 0xfffffff8) */
    125 
    126         uint32 sk_off;          /* offset parsed from NK record used as a key
     123        uint32_t hbin_off;      /* offset from beginning of this hbin block */
     124        uint32_t rec_size;      /* ((start_offset - end_offset) & 0xfffffff8) */
     125
     126        uint32_t sk_off;                /* offset parsed from NK record used as a key
    127127                                   to lookup reference to this SK record */
    128128
    129129        char header[REC_HDR_SIZE];
    130         uint32 prev_sk_off;
    131         uint32 next_sk_off;
    132         uint32 ref_count;
    133         uint32 size;
     130        uint32_t prev_sk_off;
     131        uint32_t next_sk_off;
     132        uint32_t ref_count;
     133        uint32_t size;
    134134        struct security_descriptor *sec_desc;
    135135} REGF_SK_REC;
     
    139139typedef struct {
    140140        REGF_HBIN *hbin;        /* pointer to HBIN record (in memory) containing this nk record */
    141         uint32 hbin_off;        /* offset from beginning of this hbin block */
    142         uint32 subkey_index;    /* index to next subkey record to return */
    143         uint32 rec_size;        /* ((start_offset - end_offset) & 0xfffffff8) */
     141        uint32_t hbin_off;      /* offset from beginning of this hbin block */
     142        uint32_t subkey_index;  /* index to next subkey record to return */
     143        uint32_t rec_size;      /* ((start_offset - end_offset) & 0xfffffff8) */
    144144       
    145145        /* header information */
    146146       
    147147        char header[REC_HDR_SIZE];
    148         uint16 key_type;
     148        uint16_t key_type;
    149149        NTTIME mtime;
    150         uint32 parent_off;      /* back pointer in registry hive */
    151         uint32 classname_off;   
     150        uint32_t parent_off;    /* back pointer in registry hive */
     151        uint32_t classname_off;
    152152        char *classname;
    153153        char *keyname;
     
    155155        /* max lengths */
    156156
    157         uint32 max_bytes_subkeyname;            /* max subkey name * 2 */
    158         uint32 max_bytes_subkeyclassname;       /* max subkey classname length (as if) */
    159         uint32 max_bytes_valuename;             /* max valuename * 2 */
    160         uint32 max_bytes_value;                 /* max value data size */
     157        uint32_t max_bytes_subkeyname;          /* max subkey name * 2 */
     158        uint32_t max_bytes_subkeyclassname;     /* max subkey classname length (as if) */
     159        uint32_t max_bytes_valuename;           /* max valuename * 2 */
     160        uint32_t max_bytes_value;                       /* max value data size */
    161161
    162162        /* unknowns */
    163163
    164         uint32 unk_index;                       /* nigel says run time index ? */
     164        uint32_t unk_index;                     /* nigel says run time index ? */
    165165       
    166166        /* children */
    167167       
    168         uint32 num_subkeys;
    169         uint32 subkeys_off;     /* hash records that point to NK records */     
    170         uint32 num_values;
    171         uint32 values_off;      /* value lists which point to VK records */
    172         uint32 sk_off;          /* offset to SK record */
     168        uint32_t num_subkeys;
     169        uint32_t subkeys_off;   /* hash records that point to NK records */
     170        uint32_t num_values;
     171        uint32_t values_off;    /* value lists which point to VK records */
     172        uint32_t sk_off;                /* offset to SK record */
    173173       
    174174        /* link in the other records here */
     
    193193
    194194        char   header[REGF_HDR_SIZE];   /* "regf" */
    195         uint32 data_offset;             /* offset to record in the first (or any?) hbin block */
    196         uint32 last_block;              /* offset to last hbin block in file */
    197         uint32 checksum;                /* XOR of bytes 0x0000 - 0x01FB */
     195        uint32_t data_offset;           /* offset to record in the first (or any?) hbin block */
     196        uint32_t last_block;            /* offset to last hbin block in file */
     197        uint32_t checksum;              /* XOR of bytes 0x0000 - 0x01FB */
    198198        NTTIME mtime;
    199199       
     
    202202        /* unknowns used to simply writing */
    203203       
    204         uint32 unknown1;
    205         uint32 unknown2;
    206         uint32 unknown3;
    207         uint32 unknown4;
    208         uint32 unknown5;
    209         uint32 unknown6;
     204        uint32_t unknown1;
     205        uint32_t unknown2;
     206        uint32_t unknown3;
     207        uint32_t unknown4;
     208        uint32_t unknown5;
     209        uint32_t unknown6;
    210210       
    211211} REGF_FILE;
Note: See TracChangeset for help on using the changeset viewer.