Changeset 745 for trunk/server/source4/lib/registry/patchfile.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source4/lib/registry/patchfile.c
r414 r745 5 5 Copyright (C) Jelmer Vernooij 2004-2007 6 6 Copyright (C) Wilco Baan Hofman 2006 7 Copyright (C) Matthias Dieter Wallnöfer 2008 7 Copyright (C) Matthias Dieter Wallnöfer 2008-2010 8 8 9 9 This program is free software; you can redistribute it and/or modify … … 27 27 28 28 _PUBLIC_ WERROR reg_preg_diff_load(int fd, 29 struct smb_iconv_convenience *iconv_convenience,30 29 const struct reg_diff_callbacks *callbacks, 31 30 void *callback_data); 32 31 33 32 _PUBLIC_ WERROR reg_dotreg_diff_load(int fd, 34 struct smb_iconv_convenience *iconv_convenience,35 33 const struct reg_diff_callbacks *callbacks, 36 34 void *callback_data); … … 45 43 void *callback_data) 46 44 { 47 int i;45 unsigned int i; 48 46 struct registry_key *t1 = NULL, *t2 = NULL; 49 47 char *tmppath; … … 87 85 88 86 if (!W_ERROR_IS_OK(error2) && !W_ERROR_EQUAL(error2, WERR_BADFILE)) { 89 DEBUG(0, ("Error occur ed while getting subkey by name: %s\n",87 DEBUG(0, ("Error occurred while getting subkey by name: %s\n", 90 88 win_errstr(error2))); 91 89 talloc_free(mem_ctx); … … 96 94 /* didn't have such a subkey and therefore add a del diff */ 97 95 tmppath = talloc_asprintf(mem_ctx, "%s\\%s", path, keyname1); 96 if (tmppath == NULL) { 97 DEBUG(0, ("Out of memory\n")); 98 talloc_free(mem_ctx); 99 return WERR_NOMEM; 100 } 98 101 if (!W_ERROR_IS_OK(error2)) 99 102 callbacks->del_key(callback_data, tmppath); … … 102 105 error1 = reg_open_key(mem_ctx, oldkey, keyname1, &t1); 103 106 if (!W_ERROR_IS_OK(error1)) { 104 DEBUG(0, ("Error occur ed while getting subkey by name: %s\n",107 DEBUG(0, ("Error occurred while getting subkey by name: %s\n", 105 108 win_errstr(error1))); 106 109 talloc_free(mem_ctx); … … 155 158 } 156 159 157 /* oldkey didn't have such a subkey, add a dd diff */160 /* oldkey didn't have such a subkey, add a add diff */ 158 161 tmppath = talloc_asprintf(mem_ctx, "%s\\%s", path, keyname1); 162 if (tmppath == NULL) { 163 DEBUG(0, ("Out of memory\n")); 164 talloc_free(mem_ctx); 165 return WERR_NOMEM; 166 } 159 167 callbacks->add_key(callback_data, tmppath); 160 168 … … 162 170 error1 = reg_open_key(mem_ctx, newkey, keyname1, &t2); 163 171 if (!W_ERROR_IS_OK(error1)) { 164 DEBUG(0, ("Error occur ed while getting subkey by name: %s\n",172 DEBUG(0, ("Error occurred while getting subkey by name: %s\n", 165 173 win_errstr(error1))); 166 174 talloc_free(mem_ctx); … … 176 184 const char *name; 177 185 uint32_t type1, type2; 178 DATA_BLOB contents1 , contents2;186 DATA_BLOB contents1 = { NULL, 0 }, contents2 = { NULL, 0 }; 179 187 180 188 error1 = reg_key_get_value_by_index(mem_ctx, newkey, i, … … 203 211 204 212 if (W_ERROR_IS_OK(error2) 205 && (data_blob_cmp(&contents1, &contents2) == 0) 206 && (type1 == type2)) 213 && (data_blob_cmp(&contents1, &contents2) == 0) 214 && (type1 == type2)) { 215 talloc_free(discard_const_p(char, name)); 216 talloc_free(contents1.data); 217 talloc_free(contents2.data); 207 218 continue; 219 } 208 220 209 221 callbacks->set_value(callback_data, path, name, 210 222 type1, contents1); 223 224 talloc_free(discard_const_p(char, name)); 225 talloc_free(contents1.data); 226 talloc_free(contents2.data); 211 227 } 212 228 … … 215 231 const char *name; 216 232 uint32_t type; 217 DATA_BLOB contents ;233 DATA_BLOB contents = { NULL, 0 }; 218 234 219 235 error1 = reg_key_get_value_by_index(mem_ctx, oldkey, i, &name, … … 232 248 error2 = WERR_BADFILE; 233 249 234 if (W_ERROR_IS_OK(error2)) 250 if (W_ERROR_IS_OK(error2)) { 251 talloc_free(discard_const_p(char, name)); 252 talloc_free(contents.data); 235 253 continue; 254 } 236 255 237 256 if (!W_ERROR_EQUAL(error2, WERR_BADFILE)) { … … 243 262 244 263 callbacks->del_value(callback_data, path, name); 264 265 talloc_free(discard_const_p(char, name)); 266 talloc_free(contents.data); 245 267 } 246 268 … … 257 279 void *callback_data) 258 280 { 259 int i;281 unsigned int i; 260 282 WERROR error; 261 283 … … 281 303 } 282 304 305 /* if "r1" is NULL (old hive) and "r2" isn't (new hive) then 306 * the hive doesn't exist yet and we have to generate an add 307 * diff */ 308 if ((r1 == NULL) && (r2 != NULL)) { 309 callbacks->add_key(callback_data, 310 reg_predefined_keys[i].name); 311 } 312 /* if "r1" isn't NULL (old hive) and "r2" is (new hive) then 313 * the hive shouldn't exist anymore and we have to generate a 314 * del diff */ 315 if ((r1 != NULL) && (r2 == NULL)) { 316 callbacks->del_key(callback_data, 317 reg_predefined_keys[i].name); 318 } 319 283 320 error = reg_generate_diff_key(r1, r2, 284 321 reg_predefined_keys[i].name, callbacks, … … 300 337 */ 301 338 _PUBLIC_ WERROR reg_diff_load(const char *filename, 302 struct smb_iconv_convenience *iconv_convenience,303 339 const struct reg_diff_callbacks *callbacks, 304 340 void *callback_data) … … 334 370 if (strncmp(hdr, "PReg", 4) == 0) { 335 371 /* Must be a GPO Registry.pol file */ 336 return reg_preg_diff_load(fd, iconv_convenience,callbacks, callback_data);372 return reg_preg_diff_load(fd, callbacks, callback_data); 337 373 } else { 338 374 /* Must be a normal .REG file */ 339 return reg_dotreg_diff_load(fd, iconv_convenience,callbacks, callback_data);375 return reg_dotreg_diff_load(fd, callbacks, callback_data); 340 376 } 341 377 } … … 353 389 /* Recursively create the path */ 354 390 buf = talloc_strdup(ctx, key_name); 391 W_ERROR_HAVE_NO_MEMORY(buf); 355 392 buf_ptr = buf; 356 393 … … 367 404 } 368 405 *buf_ptr++ = '\\'; 369 } 370 } 406 talloc_free(tmp); 407 } 408 } 409 410 talloc_free(buf); 371 411 372 412 /* Add the key */ … … 379 419 return error; 380 420 } 421 talloc_free(tmp); 422 381 423 return WERR_OK; 382 424 } … … 388 430 /* We can't proof here for success, because a common superkey could */ 389 431 /* have been deleted before the subkey's (diff order). This removed */ 390 /* therefore all child srecursively and the "WERR_BADFILE" result is */432 /* therefore all children recursively and the "WERR_BADFILE" result is */ 391 433 /* expected. */ 392 434 … … 420 462 } 421 463 464 talloc_free(tmp); 465 422 466 return WERR_OK; 423 467 } … … 438 482 } 439 483 440 error = reg_del_value( tmp, value_name);484 error = reg_del_value(ctx, tmp, value_name); 441 485 if (!W_ERROR_IS_OK(error)) { 442 486 DEBUG(0, ("Error deleting value '%s'\n", value_name)); … … 444 488 } 445 489 490 talloc_free(tmp); 446 491 447 492 return WERR_OK; … … 453 498 struct registry_key *key; 454 499 WERROR error; 455 const char *value_name;500 const char *value_name; 456 501 457 502 error = reg_open_key_abs(ctx, ctx, key_name, &key); … … 467 512 while (W_ERROR_IS_OK(reg_key_get_value_by_index( 468 513 ctx, key, 0, &value_name, NULL, NULL))) { 469 error = reg_del_value( key, value_name);514 error = reg_del_value(ctx, key, value_name); 470 515 if (!W_ERROR_IS_OK(error)) { 471 516 DEBUG(0, ("Error deleting value '%s'\n", value_name)); 472 517 return error; 473 518 } 474 } 519 talloc_free(discard_const_p(char, value_name)); 520 } 521 522 talloc_free(key); 475 523 476 524 return WERR_OK; … … 481 529 */ 482 530 _PUBLIC_ WERROR reg_diff_apply(struct registry_context *ctx, 483 struct smb_iconv_convenience *iconv_convenience,484 531 const char *filename) 485 532 { … … 493 540 callbacks.done = NULL; 494 541 495 return reg_diff_load(filename, iconv_convenience, 496 &callbacks, ctx); 497 } 542 return reg_diff_load(filename, &callbacks, ctx); 543 }
Note:
See TracChangeset
for help on using the changeset viewer.