- Timestamp:
- 01/23/09 17:58:43 (16 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/common.c
r136 r137 38 38 } 39 39 40 void printMsgs(REGFI_ITERATOR* iter) 41 { 42 char* msgs = regfi_get_messages(iter->f); 43 if(msgs != NULL) 44 { 45 fprintf(stderr, "%s", msgs); 46 free(msgs); 47 } 48 } 49 40 50 41 51 /* Returns a newly malloc()ed string which contains original buffer, … … 205 215 * is the responsibility of the caller to free both a non-NULL return 206 216 * value, and a non-NULL (*error_msg). 217 */ 218 /* XXX: Part of this function's logic should be pushed into the regfi API. 219 * The structures should be parsed and stored with VK records and only 220 * escaped/encoded later in reglookup and reglookup-recover. 207 221 */ 208 222 static char* data_to_ascii(unsigned char* datap, uint32 len, uint32 type, -
trunk/src/reglookup.c
r136 r137 67 67 if(size > REGFI_VK_MAX_DATA_LENGTH) 68 68 { 69 fprintf(stderr, "WARN ING: value data size %d larger than "69 fprintf(stderr, "WARN: value data size %d larger than " 70 70 "%d, truncating...\n", size, REGFI_VK_MAX_DATA_LENGTH); 71 71 size = REGFI_VK_MAX_DATA_LENGTH; … … 90 90 { 91 91 if(conv_error == NULL) 92 fprintf(stderr, "WARN ING: Could not quote value for '%s/%s'. "92 fprintf(stderr, "WARN: Could not quote value for '%s/%s'. " 93 93 "Memory allocation failure likely.\n", prefix, quoted_name); 94 94 else if(print_verbose) 95 fprintf(stderr, "WARN ING: Could not quote value for '%s/%s'. "95 fprintf(stderr, "WARN: Could not quote value for '%s/%s'. " 96 96 "Returned error: %s\n", prefix, quoted_name, conv_error); 97 97 } … … 129 129 130 130 131 132 /* XXX: Each chunk must be unquoted after it is split out.133 * Quoting syntax may need to be standardized and pushed into the API134 * to deal with this issue and others.135 */136 131 char** splitPath(const char* s) 137 132 { … … 200 195 201 196 /* Returns a quoted path from an iterator's stack */ 202 /* XXX: Some way should be found to integrate this into regfi's API203 * The problem is that the escaping is sorta reglookup-specific.204 */205 197 char* iter2Path(REGFI_ITERATOR* i) 206 198 { … … 273 265 274 266 275 void printValueList(REGFI_ITERATOR* i , char* prefix)267 void printValueList(REGFI_ITERATOR* iter, char* prefix) 276 268 { 277 269 const REGFI_VK_REC* value; 278 270 279 value = regfi_iterator_first_value(i );271 value = regfi_iterator_first_value(iter); 280 272 while(value != NULL) 281 273 { 282 274 if(!type_filter_enabled || (value->type == type_filter)) 283 275 printValue(value, prefix); 284 value = regfi_iterator_next_value(i); 285 } 286 } 287 288 289 void printKey(REGFI_ITERATOR* i, char* full_path) 276 value = regfi_iterator_next_value(iter); 277 printMsgs(iter); 278 } 279 } 280 281 282 void printKey(REGFI_ITERATOR* iter, char* full_path) 290 283 { 291 284 static char empty_str[1] = ""; … … 300 293 struct tm* tmp_time_s = NULL; 301 294 const REGFI_SK_REC* sk; 302 const REGFI_NK_REC* k = regfi_iterator_cur_key(i );295 const REGFI_NK_REC* k = regfi_iterator_cur_key(iter); 303 296 304 297 *tmp_time = nt_time_to_unix(&k->mtime); … … 306 299 strftime(mtime, sizeof(mtime), "%Y-%m-%d %H:%M:%S", tmp_time_s); 307 300 308 if(print_security && (sk=regfi_iterator_cur_sk(i )))301 if(print_security && (sk=regfi_iterator_cur_sk(iter))) 309 302 { 310 303 owner = regfi_get_owner(sk->sec_desc); … … 340 333 { 341 334 if(print_verbose) 342 fprintf(stderr, "WARN ING: While converting classname"335 fprintf(stderr, "WARN: While converting classname" 343 336 " for key '%s': %s.\n", full_path, error_msg); 344 337 free(error_msg); … … 348 341 quoted_classname = empty_str; 349 342 343 printMsgs(iter); 350 344 printf("%s,KEY,,%s,%s,%s,%s,%s,%s\n", full_path, mtime, 351 345 owner, group, sacl, dacl, quoted_classname); … … 373 367 const REGFI_NK_REC* sub = NULL; 374 368 char* path = NULL; 375 char* msgs = NULL;376 369 int key_type = regfi_type_str2val("KEY"); 377 370 bool print_this = true; … … 379 372 root = cur = regfi_iterator_cur_key(iter); 380 373 sub = regfi_iterator_first_subkey(iter); 381 msgs = regfi_get_messages(iter->f); 382 if(msgs != NULL) 383 fprintf(stderr, "%s", msgs); 374 printMsgs(iter); 375 384 376 if(root == NULL) 385 377 bailOut(EX_DATAERR, "ERROR: root cannot be NULL.\n"); … … 392 384 if(path == NULL) 393 385 bailOut(EX_OSERR, "ERROR: Could not construct iterator's path.\n"); 394 386 395 387 if(!type_filter_enabled || (key_type == type_filter)) 396 388 printKey(iter, path); … … 407 399 /* We're done with this sub-tree, going up and hitting other branches. */ 408 400 if(!regfi_iterator_up(iter)) 401 { 402 printMsgs(iter); 409 403 bailOut(EX_DATAERR, "ERROR: could not traverse iterator upward.\n"); 410 404 } 405 411 406 cur = regfi_iterator_cur_key(iter); 412 407 if(cur == NULL) 408 { 409 printMsgs(iter); 413 410 bailOut(EX_DATAERR, "ERROR: unexpected NULL for key.\n"); 414 411 } 412 415 413 sub = regfi_iterator_next_subkey(iter); 416 414 } … … 422 420 */ 423 421 if(!regfi_iterator_down(iter)) 422 { 423 printMsgs(iter); 424 424 bailOut(EX_DATAERR, "ERROR: could not traverse iterator downward.\n"); 425 } 425 426 426 427 cur = sub; … … 428 429 print_this = true; 429 430 } 431 printMsgs(iter); 430 432 } while(!((cur == root) && (sub == NULL))); 431 433 … … 479 481 if(!regfi_iterator_walk_path(iter, tmp_path)) 480 482 { 483 printMsgs(iter); 481 484 free(tmp_path); 482 485 return 0; … … 489 492 490 493 value = regfi_iterator_cur_value(iter); 494 printMsgs(iter); 491 495 tmp_path_joined = iter2Path(iter); 492 496 … … 503 507 else if(regfi_iterator_find_subkey(iter, path[i])) 504 508 { 509 printMsgs(iter); 505 510 if(print_verbose) 506 511 fprintf(stderr, "VERBOSE: Found final path element as key.\n"); 507 512 508 513 if(!regfi_iterator_down(iter)) 514 { 515 printMsgs(iter); 509 516 bailOut(EX_DATAERR, "ERROR: Unexpected error on traversing path filter key.\n"); 517 } 510 518 511 519 return 2; 512 520 } 521 printMsgs(iter); 513 522 514 523 if(print_verbose) … … 625 634 { 626 635 retr_path_ret = retrievePath(iter, path); 636 printMsgs(iter); 627 637 freePath(path); 628 638 629 639 if(retr_path_ret == 0) 630 fprintf(stderr, "WARN ING: specified path not found.\n");640 fprintf(stderr, "WARN: specified path not found.\n"); 631 641 else if (retr_path_ret == 2) 632 642 printKeyTree(iter);
Note: See TracChangeset
for help on using the changeset viewer.