Changeset 740 for vendor/current/source3/libgpo
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- Location:
- vendor/current/source3/libgpo
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/libgpo/gpext/registry.c
r414 r740 2 2 * Unix SMB/CIFS implementation. 3 3 * Group Policy Support 4 * Copyright (C) Guenther Deschner 2007-2008 4 * Copyright (C) Guenther Deschner 2007-2008,2010 5 5 * 6 6 * This program is free software; you can redistribute it and/or modify … … 20 20 #include "includes.h" 21 21 #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" 22 26 23 27 #define GP_EXT_NAME "registry" … … 33 37 static TALLOC_CTX *ctx = NULL; 34 38 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 188 39 /**************************************************************** 189 40 ****************************************************************/ 190 41 191 42 static bool reg_parse_value(TALLOC_CTX *mem_ctx, 192 c har **value,43 const char **value, 193 44 enum gp_reg_action *action) 194 45 { … … 252 103 253 104 static bool gp_reg_entry_from_file_entry(TALLOC_CTX *mem_ctx, 254 struct gp_registry_file_entry *file_entry,105 struct preg_entry *r, 255 106 struct gp_registry_entry **reg_entry) 256 107 { 257 108 struct registry_value *data = NULL; 258 109 struct gp_registry_entry *entry = NULL; 259 char *key = NULL;260 char *value = NULL;261 110 enum gp_reg_action action = GP_REG_ACTION_NONE; 262 size_t converted_size;263 111 264 112 ZERO_STRUCTP(*reg_entry); … … 268 116 return false; 269 117 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); 325 120 326 121 entry = TALLOC_ZERO_P(mem_ctx, struct gp_registry_entry); … … 328 123 return false; 329 124 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); 332 130 entry->data = data; 333 131 entry->action = action; 334 132 335 133 *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 }381 134 382 135 return true; … … 389 142 uint32_t flags, 390 143 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; 399 150 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; 403 155 404 156 status = gp_find_file(mem_ctx, … … 408 160 &real_filename); 409 161 if (!NT_STATUS_IS_OK(status)) { 410 TALLOC_FREE(reg_file);411 162 return status; 412 163 } 413 164 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) { 417 167 return NT_STATUS_CANNOT_LOAD_REGISTRY_FILE; 418 168 } 419 169 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); 422 174 goto out; 423 175 } 424 176 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", ®_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")) { 438 178 status = NT_STATUS_INVALID_PARAMETER; 439 179 goto out; 440 180 } 441 181 442 if (r eg_file->header.version != GP_REGPOL_FILE_VERSION) {182 if (r.header.version != GP_REGPOL_FILE_VERSION) { 443 183 status = NT_STATUS_INVALID_PARAMETER; 444 184 goto out; 445 185 } 446 186 447 if (!reg_parse_entries(mem_ctx, "entries", ®_file->entries, 448 ®_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; 455 209 456 210 status = NT_STATUS_OK; 457 211 458 212 out: 459 TALLOC_FREE(buf); 460 prs_mem_free(&ps); 461 213 data_blob_free(&blob); 462 214 return status; 463 215 } … … 467 219 468 220 static WERROR reg_apply_registry(TALLOC_CTX *mem_ctx, 469 const struct nt_user_token *token,221 const struct security_token *token, 470 222 struct registry_key *root_key, 471 223 uint32_t flags, … … 522 274 uint32_t flags, 523 275 struct registry_key *root_key, 524 const struct nt_user_token *token,276 const struct security_token *token, 525 277 struct GROUP_POLICY_OBJECT *gpo, 526 278 const char *extension_guid, -
vendor/current/source3/libgpo/gpext/scripts.c
r414 r740 19 19 20 20 #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" 22 27 23 28 #define GP_EXT_NAME "scripts" … … 94 99 switch (data->type) { 95 100 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); 97 103 break; 98 104 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 } 101 108 break; 102 109 default: … … 256 263 257 264 static WERROR scripts_apply(TALLOC_CTX *mem_ctx, 258 const struct nt_user_token *token,265 const struct security_token *token, 259 266 struct registry_key *root_key, 260 267 uint32_t flags, … … 276 283 #if 0 277 284 if (flags & GPO_INFO_FLAG_MACHINE) { 278 struct nt_user_token *tmp_token;285 struct security_token *tmp_token; 279 286 280 287 tmp_token = registry_create_system_token(mem_ctx); … … 296 303 W_ERROR_HAVE_NO_MEMORY(keystr); 297 304 298 reg_deletekey_recursive( mem_ctx,root_key, keystr);305 reg_deletekey_recursive(root_key, keystr); 299 306 300 307 werr = gp_store_reg_subkey(mem_ctx, keystr, … … 333 340 uint32_t flags, 334 341 struct registry_key *root_key, 335 const struct nt_user_token *token,342 const struct security_token *token, 336 343 struct GROUP_POLICY_OBJECT *gpo, 337 344 const char *extension_guid, -
vendor/current/source3/libgpo/gpext/security.c
r414 r740 19 19 20 20 #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" 22 24 23 25 #define GP_EXT_NAME "security" … … 143 145 uint32_t flags, 144 146 struct registry_key *root_key, 145 const struct nt_user_token *token,147 const struct security_token *token, 146 148 struct GROUP_POLICY_OBJECT *gpo, 147 149 const char *extension_guid, -
vendor/current/source3/libgpo/gpo_filesync.c
r414 r740 19 19 20 20 #include "includes.h" 21 #include "system/filesys.h" 22 #include "libsmb/libsmb.h" 23 #include "../libgpo/gpo.h" 24 #include "libgpo/gpo_proto.h" 21 25 22 26 struct sync_context { … … 29 33 }; 30 34 31 static voidgpo_sync_func(const char *mnt,32 file_info *info,35 static NTSTATUS gpo_sync_func(const char *mnt, 36 struct file_info *info, 33 37 const char *mask, 34 38 void *state); … … 97 101 { 98 102 if ((mkdir(unix_path, 0644)) < 0 && errno != EEXIST) { 99 return NT_STATUS_ACCESS_DENIED;103 return map_nt_error_from_unix(errno); 100 104 } 101 105 … … 107 111 ****************************************************************/ 108 112 109 static bool gpo_sync_files(struct sync_context *ctx) 110 { 113 static NTSTATUS gpo_sync_files(struct sync_context *ctx) 114 { 115 NTSTATUS status; 116 111 117 DEBUG(3,("calling cli_list with mask: %s\n", ctx->mask)); 112 118 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; 124 128 } 125 129 … … 128 132 ****************************************************************/ 129 133 130 static voidgpo_sync_func(const char *mnt,131 file_info *info,134 static NTSTATUS gpo_sync_func(const char *mnt, 135 struct file_info *info, 132 136 const char *mask, 133 137 void *state) … … 142 146 143 147 if (strequal(info->name, ".") || strequal(info->name, "..")) { 144 return ;148 return NT_STATUS_OK; 145 149 } 146 150 … … 148 152 mask, info->name)); 149 153 150 if (info->mode & aDIR) {154 if (info->mode & FILE_ATTRIBUTE_DIRECTORY) { 151 155 152 156 DEBUG(3,("got dir: [%s]\n", info->name)); … … 164 168 DEBUG(1,("failed to copy dir: %s\n", 165 169 nt_errstr(result))); 170 return result; 166 171 } 167 172 … … 177 182 if (!ctx->local_path || !ctx->mask || !ctx->remote_path) { 178 183 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)) { 182 188 DEBUG(0,("could not sync files\n")); 189 return result; 183 190 } 184 191 185 192 ctx->remote_path = old_nt_dir; 186 193 ctx->local_path = old_unix_dir; 187 return ;194 return NT_STATUS_OK; 188 195 } 189 196 … … 204 211 nt_errstr(result))); 205 212 } 213 return result; 206 214 } 207 215 … … 222 230 ctx.remote_path = CONST_DISCARD(char *, nt_path); 223 231 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); 225 233 226 234 ctx.mask = talloc_asprintf(mem_ctx, … … 231 239 } 232 240 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 19 19 20 20 #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 35 struct 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); 31 40 if (!token) { 32 41 DEBUG(1,("talloc failed\n")); … … 34 43 } 35 44 36 token->privilege s = se_priv_all;45 token->privilege_mask = SE_ALL_PRIVS; 37 46 38 47 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))) { 40 49 DEBUG(1,("Error adding nt-authority system sid to token\n")); 41 50 return NULL; … … 51 60 const char *initial_path, 52 61 uint32_t desired_access, 53 const struct nt_user_token *token,62 const struct security_token *token, 54 63 struct gp_registry_context **reg_ctx) 55 64 { … … 162 171 { 163 172 struct registry_value reg_val; 164 ZERO_STRUCT(reg_val);165 166 /* FIXME: hack */167 val = val ? val : " ";168 173 169 174 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, ®_val.data, val)) { 176 return WERR_NOMEM; 177 } 173 178 174 179 return reg_setvalue(key, val_name, ®_val); … … 184 189 { 185 190 struct registry_value reg_val; 186 ZERO_STRUCT(reg_val);187 191 188 192 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); 190 195 191 196 return reg_setvalue(key, val_name, ®_val); … … 210 215 } 211 216 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, ®_val->data, val)) { 218 return WERR_NOMEM; 219 } 214 220 215 221 return WERR_OK; … … 234 240 } 235 241 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); 237 246 238 247 return WERR_OK; … … 295 304 296 305 static const char *gp_reg_groupmembership_path(TALLOC_CTX *mem_ctx, 297 const DOM_SID*sid,306 const struct dom_sid *sid, 298 307 uint32_t flags) 299 308 { … … 311 320 static WERROR gp_reg_del_groupmembership(TALLOC_CTX *mem_ctx, 312 321 struct registry_key *key, 313 const struct nt_user_token *token,322 const struct security_token *token, 314 323 uint32_t flags) 315 324 { 316 325 const char *path = NULL; 317 326 318 path = gp_reg_groupmembership_path(mem_ctx, &token-> user_sids[0],327 path = gp_reg_groupmembership_path(mem_ctx, &token->sids[0], 319 328 flags); 320 329 W_ERROR_HAVE_NO_MEMORY(path); 321 330 322 return reg_deletekey_recursive( mem_ctx,key, path);331 return reg_deletekey_recursive(key, path); 323 332 324 333 } … … 329 338 static WERROR gp_reg_store_groupmembership(TALLOC_CTX *mem_ctx, 330 339 struct gp_registry_context *reg_ctx, 331 const struct nt_user_token *token,340 const struct security_token *token, 332 341 uint32_t flags) 333 342 { … … 340 349 int count = 0; 341 350 342 path = gp_reg_groupmembership_path(mem_ctx, &token-> user_sids[0],351 path = gp_reg_groupmembership_path(mem_ctx, &token->sids[0], 343 352 flags); 344 353 W_ERROR_HAVE_NO_MEMORY(path); … … 355 364 W_ERROR_HAVE_NO_MEMORY(valname); 356 365 357 val = sid_string_talloc(mem_ctx, &token-> user_sids[i]);366 val = sid_string_talloc(mem_ctx, &token->sids[i]); 358 367 W_ERROR_HAVE_NO_MEMORY(val); 359 368 werr = gp_store_reg_val_sz(mem_ctx, key, valname, val); … … 373 382 static WERROR gp_reg_read_groupmembership(TALLOC_CTX *mem_ctx, 374 383 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, 377 386 uint32_t flags) 378 387 { … … 385 394 uint32_t count = 0; 386 395 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); 390 399 W_ERROR_HAVE_NO_MEMORY(tmp_token); 391 400 … … 407 416 W_ERROR_NOT_OK_RETURN(werr); 408 417 409 if (!string_to_sid(&tmp_token-> user_sids[num_token_sids++],418 if (!string_to_sid(&tmp_token->sids[num_token_sids++], 410 419 val)) { 411 420 return WERR_INSUFFICIENT_BUFFER; … … 424 433 425 434 static const char *gp_req_state_path(TALLOC_CTX *mem_ctx, 426 const DOM_SID*sid,435 const struct dom_sid *sid, 427 436 uint32_t flags) 428 437 { … … 441 450 const char *path) 442 451 { 443 return reg_deletesubkeys_recursive( mem_ctx,key, path);452 return reg_deletesubkeys_recursive(key, path); 444 453 } 445 454 … … 450 459 uint32_t flags, 451 460 const char *dn, 452 const struct nt_user_token *token,461 const struct security_token *token, 453 462 struct GROUP_POLICY_OBJECT *gpo_list) 454 463 { … … 465 474 466 475 werr = gp_secure_key(mem_ctx, flags, reg_ctx->curr_key, 467 &token-> user_sids[0]);476 &token->sids[0]); 468 477 if (!W_ERROR_IS_OK(werr)) { 469 478 DEBUG(0,("failed to secure key: %s\n", win_errstr(werr))); … … 477 486 } 478 487 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); 480 489 if (!subkeyname) { 481 490 werr = WERR_NOMEM; … … 610 619 WERROR gp_reg_state_read(TALLOC_CTX *mem_ctx, 611 620 uint32_t flags, 612 const DOM_SID*sid,621 const struct dom_sid *sid, 613 622 struct GROUP_POLICY_OBJECT **gpo_list) 614 623 { … … 685 694 686 695 static WERROR gp_reg_generate_sd(TALLOC_CTX *mem_ctx, 687 const DOM_SID*sid,696 const struct dom_sid *sid, 688 697 struct security_descriptor **sd, 689 698 size_t *sd_size) 690 699 { 691 SEC_ACEace[6];700 struct security_ace ace[6]; 692 701 uint32_t mask; 693 702 694 SEC_ACL*theacl = NULL;703 struct security_acl *theacl = NULL; 695 704 696 705 uint8_t inherit_flags; … … 739 748 W_ERROR_HAVE_NO_MEMORY(theacl); 740 749 741 *sd = make_sec_desc(mem_ctx, S EC_DESC_REVISION,750 *sd = make_sec_desc(mem_ctx, SD_REVISION, 742 751 SEC_DESC_SELF_RELATIVE | 743 752 SEC_DESC_DACL_AUTO_INHERITED | /* really ? */ … … 756 765 uint32_t flags, 757 766 struct registry_key *key, 758 const DOM_SID*sid)767 const struct dom_sid *sid) 759 768 { 760 769 struct security_descriptor *sd = NULL; 761 770 size_t sd_size = 0; 762 const DOM_SID*sd_sid = NULL;771 const struct dom_sid *sd_sid = NULL; 763 772 WERROR werr; 764 773 … … 788 797 } 789 798 790 type_str = reg_type_lookup(val->type);799 type_str = str_regtype(val->type); 791 800 792 801 DEBUG(lvl,("\tdump_reg_val:\t%s '%s'\n\t\t\t'%s' %s: ", … … 794 803 795 804 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); 797 811 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); 801 821 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 } 806 831 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; 816 839 } 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 } 818 849 case REG_NONE: 819 850 DEBUG(lvl,("\n")); 820 851 break; 821 852 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); 824 855 break; 825 856 default: … … 925 956 struct gp_registry_context *reg_ctx, 926 957 struct gp_registry_entry *entry, 927 const struct nt_user_token *token,958 const struct security_token *token, 928 959 uint32_t flags) 929 960 { … … 934 965 printf("about to store key: [%s]\n", entry->key); 935 966 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)); 937 968 printf(" action: [%s]\n", gp_reg_action_str(entry->action)); 938 969 } … … 954 985 werr = gp_secure_key(mem_ctx, flags, 955 986 key, 956 &token-> user_sids[0]);987 &token->sids[0]); 957 988 if (!W_ERROR_IS_OK(werr)) { 958 989 DEBUG(0,("reg_apply_registry_entry: "
Note:
See TracChangeset
for help on using the changeset viewer.