Changeset 36 for trunk/src/sh_prelude.c
- Timestamp:
- May 19, 2006, 11:35:40 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_prelude.c
r26 r36 27 27 * include libprelude 0.9 code from Yoann Vandoorselaere 28 28 */ 29 29 30 31 /* 32 * for strptime() 33 */ 34 #define _GNU_SOURCE 1 35 30 36 #include "config_xor.h" 31 32 #define _XOPEN_SOURCE 500 /* glibc2 needs this */33 37 34 38 #include <stdio.h> 35 39 #include <string.h> 36 40 #include <sys/types.h> 41 #include <sys/stat.h> 37 42 38 43 #if TIME_WITH_SYS_TIME … … 49 54 # endif 50 55 56 #endif 57 58 #ifdef MAJOR_IN_MKDEV 59 # include <sys/mkdev.h> 60 #else 61 # ifdef MAJOR_IN_SYSMACROS 62 # include <sys/sysmacros.h> 63 # endif 51 64 #endif 52 65 … … 390 403 */ 391 404 ret = idmef_file_new_path(file, &str); 392 if ( ret < 0 ) 405 if ( ret < 0 ) { 406 free(ptr); 393 407 return; 408 } 394 409 prelude_string_set_nodup(str, ptr); 395 410 … … 413 428 if ( ptr ) { 414 429 ret = idmef_time_from_samhain(&time, ptr); 415 if ( ret < 0 ) 430 if ( ret < 0 ) { 431 free(ptr); 416 432 return; 433 } 417 434 418 435 idmef_file_set_modify_time(file, time); … … 423 440 if ( ptr ) { 424 441 ret = idmef_time_from_samhain(&time, ptr); 425 if ( ret < 0 ) 442 if ( ret < 0 ) { 443 free(ptr); 426 444 return; 427 445 } 446 428 447 idmef_file_set_create_time(file, time); 429 448 free(ptr); … … 432 451 ptr = get_value(msg, _("inode"), suffix); 433 452 if ( ptr ) { 453 struct stat st; 454 455 ret = stat(prelude_string_get_string(idmef_file_get_path(file)), &st); 456 if ( ret < 0 ) { 457 free(ptr); 458 return; 459 } 460 434 461 ret = idmef_file_new_inode(file, &inode); 435 if ( ret < 0 ) 462 if ( ret < 0 ) { 463 free(ptr); 436 464 return; 437 465 } 466 467 idmef_inode_set_major_device(inode, major(st.st_dev)); 468 idmef_inode_set_minor_device(inode, minor(st.st_dev)); 438 469 idmef_inode_set_number(inode, strtoul(ptr, NULL, 10)); 439 470 free(ptr); … … 443 474 if ( ptr ) { 444 475 ret = idmef_file_new_checksum(file, &checksum, IDMEF_LIST_APPEND); 445 if ( ret < 0 ) 476 if ( ret < 0 ) { 477 free(ptr); 446 478 return; 479 } 447 480 448 481 hashtype = sh_tiger_get_hashtype(); … … 462 495 463 496 ret = idmef_checksum_new_value(checksum, &str); 464 if ( ret < 0 ) 497 if ( ret < 0 ) { 498 free(ptr); 465 499 return; 500 } 466 501 467 502 /* will be freed on destroy() … … 475 510 ret = idmef_file_new_file_access(file, &access, IDMEF_LIST_APPEND); 476 511 if ( ret < 0 ) 477 return;512 goto mode_free; 478 513 479 514 /* flawfinder: ignore *//* is part of name, not access() */ 480 515 ret = idmef_file_access_new_user_id(access, &userid); 481 516 if ( ret < 0 ) 482 return;517 goto mode_free; 483 518 idmef_user_id_set_type(userid, IDMEF_USER_ID_TYPE_OTHER_PRIVS); 484 519 … … 493 528 /* flawfinder: ignore *//* is part of name, not access() */ 494 529 ret = idmef_file_new_file_access(file, &access, IDMEF_LIST_APPEND); 495 if ( ret < 0 ) 496 return; 530 if ( ret < 0 ) { 531 free(ptr); 532 goto mode_free; 533 } 497 534 498 535 /* flawfinder: ignore *//* is part of name, not access() */ 499 536 ret = idmef_file_access_new_user_id(access, &userid); 500 if ( ret < 0 ) 501 return; 537 if ( ret < 0 ) { 538 free(ptr); 539 goto mode_free; 540 } 502 541 idmef_user_id_set_type(userid, IDMEF_USER_ID_TYPE_USER_PRIVS); 503 542 504 543 ret = idmef_user_id_new_name(userid, &str); 505 if ( ret < 0 ) 506 return; 507 544 if ( ret < 0 ) { 545 free(ptr); 546 goto mode_free; 547 } 508 548 prelude_string_set_nodup(str, ptr); 509 549 510 550 pw = getpwnam(ptr); 511 551 if ( ! pw ) 512 return;552 goto mode_free; 513 553 514 554 idmef_user_id_set_number(userid, pw->pw_uid); … … 526 566 /* flawfinder: ignore *//* is part of name, not access() */ 527 567 ret = idmef_file_new_file_access(file, &access, IDMEF_LIST_APPEND); 528 if ( ret < 0 ) 529 return; 530 531 /* flawfinder: ignore *//* is part of name, not access() */ 532 ret = idmef_file_access_new_user_id(access, &userid); 533 if ( ret < 0 ) 534 return; 568 if ( ret < 0 ) { 569 free(ptr); 570 goto mode_free; 571 } 572 573 ret = idmef_file_access_new_user_id(access, &userid);/* flawfinder: ignore *//* is part of name, not access() */ 574 if ( ret < 0 ) { 575 free(ptr); 576 goto mode_free; 577 } 578 535 579 idmef_user_id_set_type(userid, IDMEF_USER_ID_TYPE_GROUP_PRIVS); 536 580 537 581 ret = idmef_user_id_new_name(userid, &str); 538 if ( ret < 0 ) 539 return; 582 if ( ret < 0 ) { 583 free(ptr); 584 goto mode_free; 585 } 540 586 541 587 prelude_string_set_nodup(str, ptr); … … 543 589 gr = getgrnam(ptr); 544 590 if ( ! gr ) 545 return;591 goto mode_free; 546 592 547 593 idmef_user_id_set_number(userid, gr->gr_gid); … … 551 597 } 552 598 } 599 600 mode_free: 553 601 554 602 if ( mode ) { 555 603 free ( mode ); 556 604 } 605 606 return; 557 607 } 558 608
Note:
See TracChangeset
for help on using the changeset viewer.