Changeset 740 for vendor/current/source4/lib/registry/local.c
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified vendor/current/source4/lib/registry/local.c ¶
r414 r740 58 58 59 59 local_key = talloc(ctx, struct local_key); 60 local_key->hive_key = talloc_steal(local_key, hive); 61 local_key->global.context = talloc_reference(local_key, ctx); 62 local_key->path = parent_path; 60 if (local_key != NULL) { 61 local_key->hive_key = talloc_reference(local_key, hive); 62 local_key->global.context = talloc_reference(local_key, ctx); 63 local_key->path = parent_path; 64 } 63 65 64 66 return (struct registry_key *)local_key; … … 71 73 struct registry_key **result) 72 74 { 73 char *orig = talloc_strdup(mem_ctx, path), 74 *curbegin = orig, 75 *curend = strchr(orig, '\\'); 75 char *orig, *curbegin, *curend; 76 76 struct local_key *local_parent = talloc_get_type(parent, 77 77 struct local_key); … … 81 81 int el; 82 82 83 if (path == NULL) { 84 return WERR_INVALID_PARAM; 85 } 86 87 orig = talloc_strdup(mem_ctx, path); 88 W_ERROR_HAVE_NO_MEMORY(orig); 89 curbegin = orig; 90 curend = strchr(orig, '\\'); 91 83 92 if (local_parent->path.elements != NULL) { 84 93 elements = talloc_array(mem_ctx, const char *, 85 94 str_list_length(local_parent->path.elements) + 1); 95 W_ERROR_HAVE_NO_MEMORY(elements); 86 96 for (el = 0; local_parent->path.elements[el] != NULL; el++) { 87 97 elements[el] = talloc_reference(elements, … … 98 108 *curend = '\0'; 99 109 elements = talloc_realloc(mem_ctx, elements, const char *, el+2); 110 W_ERROR_HAVE_NO_MEMORY(elements); 100 111 elements[el] = talloc_strdup(elements, curbegin); 112 W_ERROR_HAVE_NO_MEMORY(elements[el]); 101 113 el++; 102 114 elements[el] = NULL; … … 159 171 160 172 static WERROR local_create_key(TALLOC_CTX *mem_ctx, 161 struct registry_key *parent _key,162 const char * name,173 struct registry_key *parent, 174 const char *path, 163 175 const char *key_class, 164 176 struct security_descriptor *security, 165 struct registry_key **key) 166 { 167 struct local_key *local_parent; 168 struct hive_key *hivekey; 169 const char **elements; 170 int i; 171 const char *last_part; 172 173 last_part = strrchr(name, '\\'); 174 if (last_part == NULL) { 175 last_part = name; 176 local_parent = (struct local_key *)parent_key; 177 struct registry_key **result) 178 { 179 char *orig, *curbegin, *curend; 180 struct local_key *local_parent = talloc_get_type(parent, 181 struct local_key); 182 struct hive_key *curkey = local_parent->hive_key; 183 WERROR error; 184 const char **elements = NULL; 185 int el; 186 187 if (path == NULL) { 188 return WERR_INVALID_PARAM; 189 } 190 191 orig = talloc_strdup(mem_ctx, path); 192 W_ERROR_HAVE_NO_MEMORY(orig); 193 curbegin = orig; 194 curend = strchr(orig, '\\'); 195 196 if (local_parent->path.elements != NULL) { 197 elements = talloc_array(mem_ctx, const char *, 198 str_list_length(local_parent->path.elements) + 1); 199 W_ERROR_HAVE_NO_MEMORY(elements); 200 for (el = 0; local_parent->path.elements[el] != NULL; el++) { 201 elements[el] = talloc_reference(elements, 202 local_parent->path.elements[el]); 203 } 204 elements[el] = NULL; 177 205 } else { 178 W_ERROR_NOT_OK_RETURN(reg_open_key(mem_ctx, parent_key, 179 talloc_strndup(mem_ctx, name, last_part-name), 180 (struct registry_key **)&local_parent)); 181 last_part++; 182 } 183 184 W_ERROR_NOT_OK_RETURN(hive_key_add_name(mem_ctx, local_parent->hive_key, 185 last_part, key_class, security, 186 &hivekey)); 187 188 if (local_parent->path.elements != NULL) { 189 elements = talloc_array(hivekey, const char *, 190 str_list_length(local_parent->path.elements)+2); 191 for (i = 0; local_parent->path.elements[i] != NULL; i++) { 192 elements[i] = talloc_reference(elements, 193 local_parent->path.elements[i]); 194 } 195 } else { 196 elements = talloc_array(hivekey, const char *, 2); 197 i = 0; 198 } 199 200 elements[i] = talloc_strdup(elements, name); 201 elements[i+1] = NULL; 202 203 *key = reg_import_hive_key(local_parent->global.context, hivekey, 204 local_parent->path.predefined_key, 205 elements); 206 elements = NULL; 207 el = 0; 208 } 209 210 while (curbegin != NULL && *curbegin) { 211 if (curend != NULL) 212 *curend = '\0'; 213 elements = talloc_realloc(mem_ctx, elements, const char *, el+2); 214 W_ERROR_HAVE_NO_MEMORY(elements); 215 elements[el] = talloc_strdup(elements, curbegin); 216 W_ERROR_HAVE_NO_MEMORY(elements[el]); 217 el++; 218 elements[el] = NULL; 219 error = hive_get_key_by_name(mem_ctx, curkey, 220 curbegin, &curkey); 221 if (W_ERROR_EQUAL(error, WERR_BADFILE)) { 222 error = hive_key_add_name(mem_ctx, curkey, curbegin, 223 key_class, security, 224 &curkey); 225 } 226 if (!W_ERROR_IS_OK(error)) { 227 DEBUG(2, ("Open/Creation of key %s failed: %s\n", 228 curbegin, win_errstr(error))); 229 talloc_free(orig); 230 return error; 231 } 232 if (curend == NULL) 233 break; 234 curbegin = curend + 1; 235 curend = strchr(curbegin, '\\'); 236 } 237 talloc_free(orig); 238 239 *result = reg_import_hive_key(local_parent->global.context, curkey, 240 local_parent->path.predefined_key, 241 talloc_steal(curkey, elements)); 206 242 207 243 return WERR_OK; … … 212 248 { 213 249 struct local_key *local = (struct local_key *)key; 250 251 if (name == NULL) { 252 return WERR_INVALID_PARAM; 253 } 214 254 215 255 return hive_key_set_value(local->hive_key, name, type, data); … … 221 261 { 222 262 const struct local_key *local = (const struct local_key *)key; 263 264 if (name == NULL) { 265 return WERR_INVALID_PARAM; 266 } 223 267 224 268 return hive_get_value(mem_ctx, local->hive_key, name, type, data); … … 237 281 } 238 282 239 static WERROR local_delete_key(struct registry_key *key, const char *name) 240 { 241 const struct local_key *local = (const struct local_key *)key; 242 243 return hive_key_del(local->hive_key, name); 244 } 245 246 static WERROR local_delete_value(struct registry_key *key, const char *name) 247 { 248 const struct local_key *local = (const struct local_key *)key; 249 250 return hive_key_del_value(local->hive_key, name); 283 static WERROR local_delete_key(TALLOC_CTX *mem_ctx, struct registry_key *key, 284 const char *name) 285 { 286 const struct local_key *local = (const struct local_key *)key; 287 288 if (name == NULL) { 289 return WERR_INVALID_PARAM; 290 } 291 292 return hive_key_del(mem_ctx, local->hive_key, name); 293 } 294 295 static WERROR local_delete_value(TALLOC_CTX *mem_ctx, struct registry_key *key, 296 const char *name) 297 { 298 const struct local_key *local = (const struct local_key *)key; 299 300 if (name == NULL) { 301 return WERR_INVALID_PARAM; 302 } 303 304 return hive_key_del_value(mem_ctx, local->hive_key, name); 251 305 } 252 306 … … 328 382 struct registry_local *reg_local = talloc_get_type(rctx, 329 383 struct registry_local); 330 struct mountpoint *mp = talloc(rctx, struct mountpoint); 331 int i = 0; 332 384 struct mountpoint *mp; 385 unsigned int i = 0; 386 387 mp = talloc(rctx, struct mountpoint); 388 W_ERROR_HAVE_NO_MEMORY(mp); 333 389 mp->path.predefined_key = key_id; 334 390 mp->prev = mp->next = NULL; … … 337 393 mp->path.elements = talloc_array(mp, const char *, 338 394 str_list_length(elements)); 395 W_ERROR_HAVE_NO_MEMORY(mp->path.elements); 339 396 for (i = 0; elements[i] != NULL; i++) { 340 397 mp->path.elements[i] = talloc_reference(mp->path.elements,
Note:
See TracChangeset
for help on using the changeset viewer.