Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

Location:
vendor/current/source3/libgpo
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/libgpo/gpext/registry.c

    r414 r740  
    22 *  Unix SMB/CIFS implementation.
    33 *  Group Policy Support
    4  *  Copyright (C) Guenther Deschner 2007-2008
     4 *  Copyright (C) Guenther Deschner 2007-2008,2010
    55 *
    66 *  This program is free software; you can redistribute it and/or modify
     
    2020#include "includes.h"
    2121#include "../libgpo/gpo_ini.h"
     22#include "../libgpo/gpo.h"
     23#include "libgpo/gpo_proto.h"
     24#include "registry.h"
     25#include "../librpc/gen_ndr/ndr_preg.h"
    2226
    2327#define GP_EXT_NAME "registry"
     
    3337static TALLOC_CTX *ctx = NULL;
    3438
    35 struct gp_registry_file_header {
    36         uint32_t signature;
    37         uint32_t version;
    38 };
    39 
    40 struct gp_registry_file_entry {
    41         UNISTR key;
    42         UNISTR value;
    43         enum winreg_Type type;
    44         size_t size;
    45         uint8_t *data;
    46 };
    47 
    48 struct gp_registry_file {
    49         struct gp_registry_file_header header;
    50         size_t num_entries;
    51         struct gp_registry_entry *entries;
    52 };
    53 
    54 /****************************************************************
    55 ****************************************************************/
    56 
    57 static bool reg_parse_header(const char *desc,
    58                              struct gp_registry_file_header *header,
    59                              prs_struct *ps,
    60                              int depth)
    61 {
    62         if (!header)
    63                 return false;
    64 
    65         prs_debug(ps, depth, desc, "reg_parse_header");
    66         depth++;
    67 
    68         if (!prs_uint32("signature", ps, depth, &header->signature))
    69                 return false;
    70 
    71         if (!prs_uint32("version", ps, depth, &header->version))
    72                 return false;
    73 
    74         return true;
    75 }
    76 
    77 /****************************************************************
    78 ****************************************************************/
    79 
    80 static bool reg_parse_and_verify_ucs2_char(const char *desc,
    81                                            char character,
    82                                            prs_struct *ps,
    83                                            int depth)
    84 {
    85         uint16_t tmp;
    86 
    87         if (!prs_uint16(desc, ps, depth, &tmp))
    88                 return false;
    89 
    90         if (tmp != UCS2_CHAR(character))
    91                 return false;
    92 
    93         return true;
    94 }
    95 
    96 /****************************************************************
    97 ****************************************************************/
    98 
    99 static bool reg_parse_init(prs_struct *ps, int depth)
    100 {
    101         return reg_parse_and_verify_ucs2_char("initiator '['", '[',
    102                                               ps, depth);
    103 }
    104 
    105 /****************************************************************
    106 ****************************************************************/
    107 
    108 static bool reg_parse_sep(prs_struct *ps, int depth)
    109 {
    110         return reg_parse_and_verify_ucs2_char("separator ';'", ';',
    111                                               ps, depth);
    112 }
    113 
    114 /****************************************************************
    115 ****************************************************************/
    116 
    117 static bool reg_parse_term(prs_struct *ps, int depth)
    118 {
    119         return reg_parse_and_verify_ucs2_char("terminator ']'", ']',
    120                                               ps, depth);
    121 }
    122 
    123 
    124 /****************************************************************
    125 * [key;value;type;size;data]
    126 ****************************************************************/
    127 
    128 static bool reg_parse_entry(TALLOC_CTX *mem_ctx,
    129                             const char *desc,
    130                             struct gp_registry_file_entry *entry,
    131                             prs_struct *ps,
    132                             int depth)
    133 {
    134         uint32_t size = 0;
    135 
    136         if (!entry)
    137                 return false;
    138 
    139         prs_debug(ps, depth, desc, "reg_parse_entry");
    140         depth++;
    141 
    142         ZERO_STRUCTP(entry);
    143 
    144         if (!reg_parse_init(ps, depth))
    145                 return false;
    146 
    147         if (!prs_unistr("key", ps, depth, &entry->key))
    148                 return false;
    149 
    150         if (!reg_parse_sep(ps, depth))
    151                 return false;
    152 
    153         if (!prs_unistr("value", ps, depth, &entry->value))
    154                 return false;
    155 
    156         if (!reg_parse_sep(ps, depth))
    157                 return false;
    158 
    159         if (!prs_uint32("type", ps, depth, &entry->type))
    160                 return false;
    161 
    162         if (!reg_parse_sep(ps, depth))
    163                 return false;
    164 
    165         if (!prs_uint32("size", ps, depth, &size))
    166                 return false;
    167 
    168         entry->size = size;
    169 
    170         if (!reg_parse_sep(ps, depth))
    171                 return false;
    172 
    173         if (entry->size) {
    174                 entry->data = TALLOC_ZERO_ARRAY(mem_ctx, uint8, entry->size);
    175                 if (!entry->data)
    176                         return false;
    177         }
    178 
    179         if (!prs_uint8s(false, "data", ps, depth, entry->data, entry->size))
    180                 return false;
    181 
    182         if (!reg_parse_term(ps, depth))
    183                 return false;
    184 
    185         return true;
    186 }
    187 
    18839/****************************************************************
    18940****************************************************************/
    19041
    19142static bool reg_parse_value(TALLOC_CTX *mem_ctx,
    192                             char **value,
     43                            const char **value,
    19344                            enum gp_reg_action *action)
    19445{
     
    252103
    253104static bool gp_reg_entry_from_file_entry(TALLOC_CTX *mem_ctx,
    254                                          struct gp_registry_file_entry *file_entry,
     105                                         struct preg_entry *r,
    255106                                         struct gp_registry_entry **reg_entry)
    256107{
    257108        struct registry_value *data = NULL;
    258109        struct gp_registry_entry *entry = NULL;
    259         char *key = NULL;
    260         char *value = NULL;
    261110        enum gp_reg_action action = GP_REG_ACTION_NONE;
    262         size_t converted_size;
    263111
    264112        ZERO_STRUCTP(*reg_entry);
     
    268116                return false;
    269117
    270         if (strlen_w((const smb_ucs2_t *)file_entry->key.buffer) <= 0)
    271                 return false;
    272 
    273         if (!pull_ucs2_talloc(mem_ctx, &key, file_entry->key.buffer,
    274                               &converted_size))
    275         {
    276                 return false;
    277         }
    278 
    279         if (strlen_w((const smb_ucs2_t *)file_entry->value.buffer) > 0 &&
    280             !pull_ucs2_talloc(mem_ctx, &value, file_entry->value.buffer,
    281                               &converted_size))
    282         {
    283                         return false;
    284         }
    285 
    286         if (!reg_parse_value(mem_ctx, &value, &action))
    287                 return false;
    288 
    289         data->type = file_entry->type;
    290 
    291         switch (data->type) {
    292                 case REG_DWORD:
    293                         data->v.dword = atoi((char *)file_entry->data);
    294                         break;
    295                 case REG_BINARY:
    296                         data->v.binary = data_blob_talloc(mem_ctx,
    297                                                           file_entry->data,
    298                                                           file_entry->size);
    299                         break;
    300                 case REG_NONE:
    301                         break;
    302                 case REG_SZ:
    303                         if (!pull_ucs2_talloc(mem_ctx, &data->v.sz.str,
    304                                               (const smb_ucs2_t *)
    305                                               file_entry->data,
    306                                               &data->v.sz.len)) {
    307                                 data->v.sz.len = -1;
    308                         }
    309 
    310                         break;
    311                 case REG_DWORD_BIG_ENDIAN:
    312                 case REG_EXPAND_SZ:
    313                 case REG_LINK:
    314                 case REG_MULTI_SZ:
    315                 case REG_QWORD:
    316 /*              case REG_DWORD_LITTLE_ENDIAN: */
    317 /*              case REG_QWORD_LITTLE_ENDIAN: */
    318                         printf("not yet implemented: %d\n", data->type);
    319                         return false;
    320                 default:
    321                         printf("invalid reg type defined: %d\n", data->type);
    322                         return false;
    323 
    324         }
     118        data->type = r->type;
     119        data->data = data_blob_talloc(data, r->data, r->size);
    325120
    326121        entry = TALLOC_ZERO_P(mem_ctx, struct gp_registry_entry);
     
    328123                return false;
    329124
    330         entry->key = key;
    331         entry->value = value;
     125        if (!reg_parse_value(mem_ctx, &r->valuename, &action))
     126                return false;
     127
     128        entry->key = talloc_strdup(entry, r->keyname);
     129        entry->value = talloc_strdup(entry, r->valuename);
    332130        entry->data = data;
    333131        entry->action = action;
    334132
    335133        *reg_entry = entry;
    336 
    337         return true;
    338 }
    339 
    340 /****************************************************************
    341 * [key;value;type;size;data][key;value;type;size;data]...
    342 ****************************************************************/
    343 
    344 static bool reg_parse_entries(TALLOC_CTX *mem_ctx,
    345                               const char *desc,
    346                               struct gp_registry_entry **entries,
    347                               size_t *num_entries,
    348                               prs_struct *ps,
    349                               int depth)
    350 {
    351 
    352         if (!entries || !num_entries)
    353                 return false;
    354 
    355         prs_debug(ps, depth, desc, "reg_parse_entries");
    356         depth++;
    357 
    358         *entries = NULL;
    359         *num_entries = 0;
    360 
    361         while (ps->buffer_size > ps->data_offset) {
    362 
    363                 struct gp_registry_file_entry f_entry;
    364                 struct gp_registry_entry *r_entry = NULL;
    365 
    366                 if (!reg_parse_entry(mem_ctx, desc, &f_entry,
    367                                      ps, depth))
    368                         return false;
    369 
    370                 if (!gp_reg_entry_from_file_entry(mem_ctx,
    371                                                   &f_entry,
    372                                                   &r_entry))
    373                         return false;
    374 
    375                 if (!add_gp_registry_entry_to_array(mem_ctx,
    376                                                     r_entry,
    377                                                     entries,
    378                                                     num_entries))
    379                         return false;
    380         }
    381134
    382135        return true;
     
    389142                                   uint32_t flags,
    390143                                   const char *filename,
    391                                    struct gp_registry_entry **entries,
    392                                    size_t *num_entries)
    393 {
    394         uint16_t *buf = NULL;
    395         size_t n = 0;
    396         NTSTATUS status;
    397         prs_struct ps;
    398         struct gp_registry_file *reg_file;
     144                                   struct gp_registry_entry **entries_p,
     145                                   size_t *num_entries_p)
     146{
     147        DATA_BLOB blob;
     148        NTSTATUS status;
     149        enum ndr_err_code ndr_err;
    399150        const char *real_filename = NULL;
    400 
    401         reg_file = TALLOC_ZERO_P(mem_ctx, struct gp_registry_file);
    402         NT_STATUS_HAVE_NO_MEMORY(reg_file);
     151        struct preg_file r;
     152        struct gp_registry_entry *entries = NULL;
     153        size_t num_entries = 0;
     154        int i;
    403155
    404156        status = gp_find_file(mem_ctx,
     
    408160                              &real_filename);
    409161        if (!NT_STATUS_IS_OK(status)) {
    410                 TALLOC_FREE(reg_file);
    411162                return status;
    412163        }
    413164
    414         buf = (uint16 *)file_load(real_filename, &n, 0, NULL);
    415         if (!buf) {
    416                 TALLOC_FREE(reg_file);
     165        blob.data = (uint8_t *)file_load(real_filename, &blob.length, 0, NULL);
     166        if (!blob.data) {
    417167                return NT_STATUS_CANNOT_LOAD_REGISTRY_FILE;
    418168        }
    419169
    420         if (!prs_init(&ps, n, mem_ctx, UNMARSHALL)) {
    421                 status = NT_STATUS_NO_MEMORY;
     170        ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, &r,
     171                        (ndr_pull_flags_fn_t)ndr_pull_preg_file);
     172        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     173                status = ndr_map_error2ntstatus(ndr_err);
    422174                goto out;
    423175        }
    424176
    425         if (!prs_copy_data_in(&ps, (char *)buf, n)) {
    426                 status = NT_STATUS_NO_MEMORY;
    427                 goto out;
    428         }
    429 
    430         prs_set_offset(&ps, 0);
    431 
    432         if (!reg_parse_header("header", &reg_file->header, &ps, 0)) {
    433                 status = NT_STATUS_REGISTRY_IO_FAILED;
    434                 goto out;
    435         }
    436 
    437         if (reg_file->header.signature != GP_REGPOL_FILE_SIGNATURE) {
     177        if (!strequal(r.header.signature, "PReg")) {
    438178                status = NT_STATUS_INVALID_PARAMETER;
    439179                goto out;
    440180        }
    441181
    442         if (reg_file->header.version != GP_REGPOL_FILE_VERSION) {
     182        if (r.header.version != GP_REGPOL_FILE_VERSION) {
    443183                status = NT_STATUS_INVALID_PARAMETER;
    444184                goto out;
    445185        }
    446186
    447         if (!reg_parse_entries(mem_ctx, "entries", &reg_file->entries,
    448                                &reg_file->num_entries, &ps, 0)) {
    449                 status = NT_STATUS_REGISTRY_IO_FAILED;
    450                 goto out;
    451         }
    452 
    453         *entries = reg_file->entries;
    454         *num_entries = reg_file->num_entries;
     187        for (i=0; i < r.num_entries; i++) {
     188
     189                struct gp_registry_entry *r_entry = NULL;
     190
     191                if (!gp_reg_entry_from_file_entry(mem_ctx,
     192                                                  &r.entries[i],
     193                                                  &r_entry)) {
     194                        status = NT_STATUS_NO_MEMORY;
     195                        goto out;
     196                }
     197
     198                if (!add_gp_registry_entry_to_array(mem_ctx,
     199                                                    r_entry,
     200                                                    &entries,
     201                                                    &num_entries)) {
     202                        status = NT_STATUS_NO_MEMORY;
     203                        goto out;
     204                }
     205        }
     206
     207        *entries_p = entries;
     208        *num_entries_p = num_entries;
    455209
    456210        status = NT_STATUS_OK;
    457211
    458212 out:
    459         TALLOC_FREE(buf);
    460         prs_mem_free(&ps);
    461 
     213        data_blob_free(&blob);
    462214        return status;
    463215}
     
    467219
    468220static WERROR reg_apply_registry(TALLOC_CTX *mem_ctx,
    469                                  const struct nt_user_token *token,
     221                                 const struct security_token *token,
    470222                                 struct registry_key *root_key,
    471223                                 uint32_t flags,
     
    522274                                              uint32_t flags,
    523275                                              struct registry_key *root_key,
    524                                               const struct nt_user_token *token,
     276                                              const struct security_token *token,
    525277                                              struct GROUP_POLICY_OBJECT *gpo,
    526278                                              const char *extension_guid,
  • vendor/current/source3/libgpo/gpext/scripts.c

    r414 r740  
    1919
    2020#include "includes.h"
    21 #include "libgpo/gpo_ini.h"
     21#include "../libgpo/gpo_ini.h"
     22#include "../libgpo/gpo.h"
     23#include "libgpo/gpo_proto.h"
     24#include "registry.h"
     25#include "registry/reg_api.h"
     26#include "../libcli/registry/util_reg.h"
    2227
    2328#define GP_EXT_NAME "scripts"
     
    9499        switch (data->type) {
    95100                case REG_QWORD:
    96                         data->v.qword = *(uint64_t *)data_p;
     101                        data->data = data_blob_talloc(mem_ctx, NULL, 8);
     102                        SBVAL(data->data.data, 0, *(uint64_t *)data_p);
    97103                        break;
    98104                case REG_SZ:
    99                         data->v.sz.str = talloc_strdup(mem_ctx, (char *)data_p);
    100                         data->v.sz.len = strlen(data->v.sz.str);
     105                        if (!push_reg_sz(mem_ctx, &data->data, (char *)data_p)) {
     106                                return NT_STATUS_NO_MEMORY;
     107                        }
    101108                        break;
    102109                default:
     
    256263
    257264static WERROR scripts_apply(TALLOC_CTX *mem_ctx,
    258                             const struct nt_user_token *token,
     265                            const struct security_token *token,
    259266                            struct registry_key *root_key,
    260267                            uint32_t flags,
     
    276283#if 0
    277284        if (flags & GPO_INFO_FLAG_MACHINE) {
    278                 struct nt_user_token *tmp_token;
     285                struct security_token *tmp_token;
    279286
    280287                tmp_token = registry_create_system_token(mem_ctx);
     
    296303        W_ERROR_HAVE_NO_MEMORY(keystr);
    297304
    298         reg_deletekey_recursive(mem_ctx, root_key, keystr);
     305        reg_deletekey_recursive(root_key, keystr);
    299306
    300307        werr = gp_store_reg_subkey(mem_ctx, keystr,
     
    333340                                             uint32_t flags,
    334341                                             struct registry_key *root_key,
    335                                              const struct nt_user_token *token,
     342                                             const struct security_token *token,
    336343                                             struct GROUP_POLICY_OBJECT *gpo,
    337344                                             const char *extension_guid,
  • vendor/current/source3/libgpo/gpext/security.c

    r414 r740  
    1919
    2020#include "includes.h"
    21 #include "libgpo/gpo_ini.h"
     21#include "../libgpo/gpo_ini.h"
     22#include "../libgpo/gpo.h"
     23#include "libgpo/gpo_proto.h"
    2224
    2325#define GP_EXT_NAME "security"
     
    143145                                              uint32_t flags,
    144146                                              struct registry_key *root_key,
    145                                               const struct nt_user_token *token,
     147                                              const struct security_token *token,
    146148                                              struct GROUP_POLICY_OBJECT *gpo,
    147149                                              const char *extension_guid,
  • vendor/current/source3/libgpo/gpo_filesync.c

    r414 r740  
    1919
    2020#include "includes.h"
     21#include "system/filesys.h"
     22#include "libsmb/libsmb.h"
     23#include "../libgpo/gpo.h"
     24#include "libgpo/gpo_proto.h"
    2125
    2226struct sync_context {
     
    2933};
    3034
    31 static void gpo_sync_func(const char *mnt,
    32                           file_info *info,
     35static NTSTATUS gpo_sync_func(const char *mnt,
     36                          struct file_info *info,
    3337                          const char *mask,
    3438                          void *state);
     
    97101{
    98102        if ((mkdir(unix_path, 0644)) < 0 && errno != EEXIST) {
    99                 return NT_STATUS_ACCESS_DENIED;
     103                return map_nt_error_from_unix(errno);
    100104        }
    101105
     
    107111****************************************************************/
    108112
    109 static bool gpo_sync_files(struct sync_context *ctx)
    110 {
     113static NTSTATUS gpo_sync_files(struct sync_context *ctx)
     114{
     115        NTSTATUS status;
     116
    111117        DEBUG(3,("calling cli_list with mask: %s\n", ctx->mask));
    112118
    113         if (cli_list(ctx->cli,
    114                      ctx->mask,
    115                      ctx->attribute,
    116                      gpo_sync_func,
    117                      ctx) == -1) {
    118                 DEBUG(1,("listing [%s] failed with error: %s\n",
    119                         ctx->mask, cli_errstr(ctx->cli)));
    120                 return false;
    121         }
    122 
    123         return true;
     119        status = cli_list(ctx->cli, ctx->mask, ctx->attribute, gpo_sync_func,
     120                          ctx);
     121        if (!NT_STATUS_IS_OK(status)) {
     122                DEBUG(1, ("listing [%s] failed with error: %s\n",
     123                          ctx->mask, nt_errstr(status)));
     124                return status;
     125        }
     126
     127        return status;
    124128}
    125129
     
    128132****************************************************************/
    129133
    130 static void gpo_sync_func(const char *mnt,
    131                           file_info *info,
     134static NTSTATUS gpo_sync_func(const char *mnt,
     135                          struct file_info *info,
    132136                          const char *mask,
    133137                          void *state)
     
    142146
    143147        if (strequal(info->name, ".") || strequal(info->name, "..")) {
    144                 return;
     148                return NT_STATUS_OK;
    145149        }
    146150
     
    148152                mask, info->name));
    149153
    150         if (info->mode & aDIR) {
     154        if (info->mode & FILE_ATTRIBUTE_DIRECTORY) {
    151155
    152156                DEBUG(3,("got dir: [%s]\n", info->name));
     
    164168                        DEBUG(1,("failed to copy dir: %s\n",
    165169                                nt_errstr(result)));
     170                        return result;
    166171                }
    167172
     
    177182                if (!ctx->local_path || !ctx->mask || !ctx->remote_path) {
    178183                        DEBUG(0,("gpo_sync_func: ENOMEM\n"));
    179                         return;
    180                 }
    181                 if (!gpo_sync_files(ctx)) {
     184                        return NT_STATUS_NO_MEMORY;
     185                }
     186                result = gpo_sync_files(ctx);
     187                if (!NT_STATUS_IS_OK(result)) {
    182188                        DEBUG(0,("could not sync files\n"));
     189                        return result;
    183190                }
    184191
    185192                ctx->remote_path = old_nt_dir;
    186193                ctx->local_path = old_unix_dir;
    187                 return;
     194                return NT_STATUS_OK;
    188195        }
    189196
     
    204211                        nt_errstr(result)));
    205212        }
     213        return result;
    206214}
    207215
     
    222230        ctx.remote_path = CONST_DISCARD(char *, nt_path);
    223231        ctx.local_path  = CONST_DISCARD(char *, local_path);
    224         ctx.attribute   = (aSYSTEM | aHIDDEN | aDIR);
     232        ctx.attribute   = (FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY);
    225233
    226234        ctx.mask = talloc_asprintf(mem_ctx,
     
    231239        }
    232240
    233         if (!gpo_sync_files(&ctx)) {
    234                 return NT_STATUS_NO_SUCH_FILE;
    235         }
    236 
    237         return NT_STATUS_OK;
    238 }
     241        return gpo_sync_files(&ctx);
     242}
  • vendor/current/source3/libgpo/gpo_reg.c

    r414 r740  
    1919
    2020#include "includes.h"
    21 
    22 
    23 /****************************************************************
    24 ****************************************************************/
    25 
    26 struct nt_user_token *registry_create_system_token(TALLOC_CTX *mem_ctx)
    27 {
    28         struct nt_user_token *token = NULL;
    29 
    30         token = TALLOC_ZERO_P(mem_ctx, struct nt_user_token);
     21#include "../libgpo/gpo.h"
     22#include "libgpo/gpo_proto.h"
     23#include "registry.h"
     24#include "registry/reg_api.h"
     25#include "registry/reg_backend_db.h"
     26#include "registry/reg_api_util.h"
     27#include "registry/reg_init_basic.h"
     28#include "../libcli/security/security.h"
     29#include "../libcli/registry/util_reg.h"
     30
     31
     32/****************************************************************
     33****************************************************************/
     34
     35struct security_token *registry_create_system_token(TALLOC_CTX *mem_ctx)
     36{
     37        struct security_token *token = NULL;
     38
     39        token = TALLOC_ZERO_P(mem_ctx, struct security_token);
    3140        if (!token) {
    3241                DEBUG(1,("talloc failed\n"));
     
    3443        }
    3544
    36         token->privileges = se_priv_all;
     45        token->privilege_mask = SE_ALL_PRIVS;
    3746
    3847        if (!NT_STATUS_IS_OK(add_sid_to_array(token, &global_sid_System,
    39                          &token->user_sids, &token->num_sids))) {
     48                         &token->sids, &token->num_sids))) {
    4049                DEBUG(1,("Error adding nt-authority system sid to token\n"));
    4150                return NULL;
     
    5160                       const char *initial_path,
    5261                       uint32_t desired_access,
    53                        const struct nt_user_token *token,
     62                       const struct security_token *token,
    5463                       struct gp_registry_context **reg_ctx)
    5564{
     
    162171{
    163172        struct registry_value reg_val;
    164         ZERO_STRUCT(reg_val);
    165 
    166         /* FIXME: hack */
    167         val = val ? val : " ";
    168173
    169174        reg_val.type = REG_SZ;
    170         reg_val.v.sz.len = strlen(val);
    171         reg_val.v.sz.str = talloc_strdup(mem_ctx, val);
    172         W_ERROR_HAVE_NO_MEMORY(reg_val.v.sz.str);
     175        if (!push_reg_sz(mem_ctx, &reg_val.data, val)) {
     176                return WERR_NOMEM;
     177        }
    173178
    174179        return reg_setvalue(key, val_name, &reg_val);
     
    184189{
    185190        struct registry_value reg_val;
    186         ZERO_STRUCT(reg_val);
    187191
    188192        reg_val.type = REG_DWORD;
    189         reg_val.v.dword = val;
     193        reg_val.data = data_blob_talloc(mem_ctx, NULL, 4);
     194        SIVAL(reg_val.data.data, 0, val);
    190195
    191196        return reg_setvalue(key, val_name, &reg_val);
     
    210215        }
    211216
    212         *val = talloc_strdup(mem_ctx, reg_val->v.sz.str);
    213         W_ERROR_HAVE_NO_MEMORY(*val);
     217        if (!pull_reg_sz(mem_ctx, &reg_val->data, val)) {
     218                return WERR_NOMEM;
     219        }
    214220
    215221        return WERR_OK;
     
    234240        }
    235241
    236         *val = reg_val->v.dword;
     242        if (reg_val->data.length < 4) {
     243                return WERR_INSUFFICIENT_BUFFER;
     244        }
     245        *val = IVAL(reg_val->data.data, 0);
    237246
    238247        return WERR_OK;
     
    295304
    296305static const char *gp_reg_groupmembership_path(TALLOC_CTX *mem_ctx,
    297                                                const DOM_SID *sid,
     306                                               const struct dom_sid *sid,
    298307                                               uint32_t flags)
    299308{
     
    311320static WERROR gp_reg_del_groupmembership(TALLOC_CTX *mem_ctx,
    312321                                         struct registry_key *key,
    313                                          const struct nt_user_token *token,
     322                                         const struct security_token *token,
    314323                                         uint32_t flags)
    315324{
    316325        const char *path = NULL;
    317326
    318         path = gp_reg_groupmembership_path(mem_ctx, &token->user_sids[0],
     327        path = gp_reg_groupmembership_path(mem_ctx, &token->sids[0],
    319328                                           flags);
    320329        W_ERROR_HAVE_NO_MEMORY(path);
    321330
    322         return reg_deletekey_recursive(mem_ctx, key, path);
     331        return reg_deletekey_recursive(key, path);
    323332
    324333}
     
    329338static WERROR gp_reg_store_groupmembership(TALLOC_CTX *mem_ctx,
    330339                                           struct gp_registry_context *reg_ctx,
    331                                            const struct nt_user_token *token,
     340                                           const struct security_token *token,
    332341                                           uint32_t flags)
    333342{
     
    340349        int count = 0;
    341350
    342         path = gp_reg_groupmembership_path(mem_ctx, &token->user_sids[0],
     351        path = gp_reg_groupmembership_path(mem_ctx, &token->sids[0],
    343352                                           flags);
    344353        W_ERROR_HAVE_NO_MEMORY(path);
     
    355364                W_ERROR_HAVE_NO_MEMORY(valname);
    356365
    357                 val = sid_string_talloc(mem_ctx, &token->user_sids[i]);
     366                val = sid_string_talloc(mem_ctx, &token->sids[i]);
    358367                W_ERROR_HAVE_NO_MEMORY(val);
    359368                werr = gp_store_reg_val_sz(mem_ctx, key, valname, val);
     
    373382static WERROR gp_reg_read_groupmembership(TALLOC_CTX *mem_ctx,
    374383                                          struct gp_registry_context *reg_ctx,
    375                                           const DOM_SID *object_sid,
    376                                           struct nt_user_token **token,
     384                                          const struct dom_sid *object_sid,
     385                                          struct security_token **token,
    377386                                          uint32_t flags)
    378387{
     
    385394        uint32_t count = 0;
    386395        int num_token_sids = 0;
    387         struct nt_user_token *tmp_token = NULL;
    388 
    389         tmp_token = TALLOC_ZERO_P(mem_ctx, struct nt_user_token);
     396        struct security_token *tmp_token = NULL;
     397
     398        tmp_token = TALLOC_ZERO_P(mem_ctx, struct security_token);
    390399        W_ERROR_HAVE_NO_MEMORY(tmp_token);
    391400
     
    407416                W_ERROR_NOT_OK_RETURN(werr);
    408417
    409                 if (!string_to_sid(&tmp_token->user_sids[num_token_sids++],
     418                if (!string_to_sid(&tmp_token->sids[num_token_sids++],
    410419                                   val)) {
    411420                        return WERR_INSUFFICIENT_BUFFER;
     
    424433
    425434static const char *gp_req_state_path(TALLOC_CTX *mem_ctx,
    426                                      const DOM_SID *sid,
     435                                     const struct dom_sid *sid,
    427436                                     uint32_t flags)
    428437{
     
    441450                               const char *path)
    442451{
    443         return reg_deletesubkeys_recursive(mem_ctx, key, path);
     452        return reg_deletesubkeys_recursive(key, path);
    444453}
    445454
     
    450459                          uint32_t flags,
    451460                          const char *dn,
    452                           const struct nt_user_token *token,
     461                          const struct security_token *token,
    453462                          struct GROUP_POLICY_OBJECT *gpo_list)
    454463{
     
    465474
    466475        werr = gp_secure_key(mem_ctx, flags, reg_ctx->curr_key,
    467                              &token->user_sids[0]);
     476                             &token->sids[0]);
    468477        if (!W_ERROR_IS_OK(werr)) {
    469478                DEBUG(0,("failed to secure key: %s\n", win_errstr(werr)));
     
    477486        }
    478487
    479         subkeyname = gp_req_state_path(mem_ctx, &token->user_sids[0], flags);
     488        subkeyname = gp_req_state_path(mem_ctx, &token->sids[0], flags);
    480489        if (!subkeyname) {
    481490                werr = WERR_NOMEM;
     
    610619WERROR gp_reg_state_read(TALLOC_CTX *mem_ctx,
    611620                         uint32_t flags,
    612                          const DOM_SID *sid,
     621                         const struct dom_sid *sid,
    613622                         struct GROUP_POLICY_OBJECT **gpo_list)
    614623{
     
    685694
    686695static WERROR gp_reg_generate_sd(TALLOC_CTX *mem_ctx,
    687                                  const DOM_SID *sid,
     696                                 const struct dom_sid *sid,
    688697                                 struct security_descriptor **sd,
    689698                                 size_t *sd_size)
    690699{
    691         SEC_ACE ace[6];
     700        struct security_ace ace[6];
    692701        uint32_t mask;
    693702
    694         SEC_ACL *theacl = NULL;
     703        struct security_acl *theacl = NULL;
    695704
    696705        uint8_t inherit_flags;
     
    739748        W_ERROR_HAVE_NO_MEMORY(theacl);
    740749
    741         *sd = make_sec_desc(mem_ctx, SEC_DESC_REVISION,
     750        *sd = make_sec_desc(mem_ctx, SD_REVISION,
    742751                            SEC_DESC_SELF_RELATIVE |
    743752                            SEC_DESC_DACL_AUTO_INHERITED | /* really ? */
     
    756765                     uint32_t flags,
    757766                     struct registry_key *key,
    758                      const DOM_SID *sid)
     767                     const struct dom_sid *sid)
    759768{
    760769        struct security_descriptor *sd = NULL;
    761770        size_t sd_size = 0;
    762         const DOM_SID *sd_sid = NULL;
     771        const struct dom_sid *sd_sid = NULL;
    763772        WERROR werr;
    764773
     
    788797        }
    789798
    790         type_str = reg_type_lookup(val->type);
     799        type_str = str_regtype(val->type);
    791800
    792801        DEBUG(lvl,("\tdump_reg_val:\t%s '%s'\n\t\t\t'%s' %s: ",
     
    794803
    795804        switch (val->type) {
    796                 case REG_DWORD:
     805                case REG_DWORD: {
     806                        uint32_t v;
     807                        if (val->data.length < 4) {
     808                                break;
     809                        }
     810                        v = IVAL(val->data.data, 0);
    797811                        DEBUG(lvl,("%d (0x%08x)\n",
    798                                 (int)val->v.dword, val->v.dword));
    799                         break;
    800                 case REG_QWORD:
     812                                (int)v, v));
     813                        break;
     814                }
     815                case REG_QWORD: {
     816                        uint64_t v;
     817                        if (val->data.length < 8) {
     818                                break;
     819                        }
     820                        v = BVAL(val->data.data, 0);
    801821                        DEBUG(lvl,("%d (0x%016llx)\n",
    802                                 (int)val->v.qword,
    803                                 (unsigned long long)val->v.qword));
    804                         break;
    805                 case REG_SZ:
     822                                (int)v,
     823                                (unsigned long long)v));
     824                        break;
     825                }
     826                case REG_SZ: {
     827                        const char *s;
     828                        if (!pull_reg_sz(talloc_tos(), &val->data, &s)) {
     829                                break;
     830                        }
    806831                        DEBUG(lvl,("%s (length: %d)\n",
    807                                    val->v.sz.str,
    808                                    (int)val->v.sz.len));
    809                         break;
    810                 case REG_MULTI_SZ:
    811                         DEBUG(lvl,("(num_strings: %d)\n",
    812                                    val->v.multi_sz.num_strings));
    813                         for (i=0; i < val->v.multi_sz.num_strings; i++) {
    814                                 DEBUGADD(lvl,("\t%s\n",
    815                                         val->v.multi_sz.strings[i]));
     832                                   s, (int)strlen_m(s)));
     833                        break;
     834                }
     835                case REG_MULTI_SZ: {
     836                        const char **a;
     837                        if (!pull_reg_multi_sz(talloc_tos(), &val->data, &a)) {
     838                                break;
    816839                        }
    817                         break;
     840                        for (i=0; a[i] != NULL; i++) {
     841                                ;;
     842                        }
     843                        DEBUG(lvl,("(num_strings: %d)\n", i));
     844                        for (i=0; a[i] != NULL; i++) {
     845                                DEBUGADD(lvl,("\t%s\n", a[i]));
     846                        }
     847                        break;
     848                }
    818849                case REG_NONE:
    819850                        DEBUG(lvl,("\n"));
    820851                        break;
    821852                case REG_BINARY:
    822                         dump_data(lvl, val->v.binary.data,
    823                                   val->v.binary.length);
     853                        dump_data(lvl, val->data.data,
     854                                  val->data.length);
    824855                        break;
    825856                default:
     
    925956                                struct gp_registry_context *reg_ctx,
    926957                                struct gp_registry_entry *entry,
    927                                 const struct nt_user_token *token,
     958                                const struct security_token *token,
    928959                                uint32_t flags)
    929960{
     
    934965                printf("about to store key:    [%s]\n", entry->key);
    935966                printf("               value:  [%s]\n", entry->value);
    936                 printf("               data:   [%s]\n", reg_type_lookup(entry->data->type));
     967                printf("               data:   [%s]\n", str_regtype(entry->data->type));
    937968                printf("               action: [%s]\n", gp_reg_action_str(entry->action));
    938969        }
     
    954985                        werr = gp_secure_key(mem_ctx, flags,
    955986                                             key,
    956                                              &token->user_sids[0]);
     987                                             &token->sids[0]);
    957988                        if (!W_ERROR_IS_OK(werr)) {
    958989                                DEBUG(0,("reg_apply_registry_entry: "
Note: See TracChangeset for help on using the changeset viewer.