Changeset 68 for trunk/src/sh_hash.c
- Timestamp:
- Oct 30, 2006, 12:03:44 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_hash.c
r40 r68 285 285 char * fullpath; 286 286 char * linkpath; 287 char * attr_string; 287 288 int visited; 288 289 int reported; … … 337 338 #endif 338 339 340 #define REC_FLAGS_ATTR (1<<8) 341 #define REC_FLAGS_MASK 0xFF00 339 342 340 343 /************************************************************** … … 389 392 theFile->hardlinks = p->theFile.hardlinks; 390 393 394 if (p->attr_string) 395 theFile->attr_string = sh_util_strdup(p->attr_string); 396 else 397 theFile->attr_string = NULL; 398 391 399 SL_RETURN((theFile), _("sh_hash_create_ft")); 392 400 } … … 440 448 SH_FREE(tmp); 441 449 SH_FREE(str); 450 if (theFile->attr_string) 451 SH_FREE(theFile->attr_string); 442 452 SH_FREE(theFile); 443 453 return 0; … … 517 527 MSG_FI_MISS2, tmp, str); 518 528 SH_FREE(str); 529 if (theFile->attr_string) 530 SH_FREE(theFile->attr_string); 519 531 SH_FREE(theFile); 520 532 … … 532 544 theFile = sh_hash_create_ft (p, fileHash); 533 545 sh_hash_pushdata (theFile, fileHash); 546 if (theFile->attr_string) 547 SH_FREE(theFile->attr_string); 534 548 SH_FREE(theFile); 535 549 } … … 554 568 p->linkpath = NULL; 555 569 } 570 if (p->attr_string) 571 { 572 SH_FREE(p->attr_string); 573 p->attr_string = NULL; 574 } 556 575 SH_FREE(p); 557 576 p = NULL; … … 576 595 MSG_FI_MISS2, tmp, str); 577 596 SH_FREE(str); 597 if (theFile->attr_string) 598 SH_FREE(theFile->attr_string); 578 599 SH_FREE(theFile); 579 600 … … 635 656 SH_FREE(p->linkpath); 636 657 p->linkpath = NULL; 658 } 659 if (p->attr_string) 660 { 661 SH_FREE(p->attr_string); 662 p->attr_string = NULL; 637 663 } 638 664 SH_FREE(p); … … 696 722 if(p->linkpath) 697 723 SH_FREE(p->linkpath); 724 if(p->attr_string) 725 SH_FREE(p->attr_string); 698 726 memcpy(p, s, sizeof(sh_file_t)); 699 727 p->next = q; … … 868 896 char * fullpath; 869 897 char * linkpath; 898 char * attr_string = NULL; 870 899 char * tmp; 871 900 … … 908 937 #endif 909 938 910 if ( ft.mark!= REC_MAGIC)939 if ((ft.mark & ~REC_FLAGS_MASK) != REC_MAGIC) 911 940 { 912 941 SH_FREE(p); … … 967 996 linkpath[len-2] = '\0'; 968 997 998 /* Read next record -- Part Four -- attr_string 999 */ 1000 if ((ft.mark & REC_FLAGS_ATTR) != 0) 1001 { 1002 i = sh_hash_getline (sh_fin_fd, line, size); 1003 if (i < 0 ) 1004 { 1005 SH_FREE(line); 1006 SH_FREE(fullpath); 1007 SH_FREE(linkpath); 1008 SH_FREE(p); 1009 dlog(1, FIL__, __LINE__, 1010 _("There is a corrupt record in the file signature database: %s\nThe attribute string is missing.\n"), 1011 (NULL == file_path('D', 'R'))? _("(null)"):file_path('D', 'R')); 1012 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_P_NODATA, 1013 ( (NULL == file_path('D', 'R')) ? _("(null)") : 1014 file_path('D', 'R')) 1015 ); 1016 aud_exit (FIL__, __LINE__,EXIT_FAILURE); 1017 } 1018 1019 tmp = unquote_string (line); 1020 1021 len = sl_strlen(tmp)+1; 1022 attr_string = SH_ALLOC(len); 1023 (void) sl_strlcpy (attr_string, tmp, len); 1024 if (tmp) 1025 SH_FREE(tmp); 1026 if (attr_string[len-2] == '\n') 1027 attr_string[len-2] = '\0'; 1028 } 1029 969 1030 /* Read next record -- Part Four -- Decode 970 1031 */ … … 986 1047 sh_do_decode(linkpath, sl_strlen(linkpath)); 987 1048 } 1049 if ((ft.mark & REC_FLAGS_ATTR) != 0) 1050 { 1051 sh_do_decode(attr_string, sl_strlen(attr_string)); 1052 } 988 1053 #endif 989 1054 … … 995 1060 p->fullpath = fullpath; 996 1061 p->linkpath = linkpath; 1062 1063 p->attr_string = attr_string; 997 1064 998 1065 /* set to an invalid value … … 1313 1380 char * fullpath = NULL; 1314 1381 char * linkpath = NULL; 1382 char * attr_string = NULL; 1315 1383 1316 1384 char * line = NULL; … … 1518 1586 } 1519 1587 1588 if (buf != NULL && buf->attr_string != NULL) 1589 { 1590 old_len = sl_strlen(buf->attr_string); 1591 #if defined(SH_STEALTH) 1592 sh_do_encode(buf->attr_string, old_len); 1593 #endif 1594 tmp = quote_string(buf->attr_string); 1595 if (tmp) 1596 { 1597 attr_string = tmp; 1598 tmp = NULL; 1599 } 1600 #if defined(SH_STEALTH) 1601 sh_do_decode(buf->attr_string, old_len); 1602 #endif 1603 } 1604 1605 1520 1606 if (buf != NULL) { 1521 1607 p.mark = REC_MAGIC; 1608 if (attr_string) 1609 p.mark |= REC_FLAGS_ATTR; 1522 1610 sl_strlcpy(p.c_mode, buf->c_mode, 11); 1523 1611 sl_strlcpy(p.c_group, buf->c_group, GROUP_MAX+1); … … 1640 1728 sl_write_line (pushdata_fd, fullpath, sl_strlen(fullpath)); 1641 1729 sl_write_line (pushdata_fd, linkpath, sl_strlen(linkpath)); 1730 if (attr_string) 1731 sl_write_line (pushdata_fd, attr_string, sl_strlen(attr_string)); 1642 1732 } else { 1643 1733 fwrite (&p, sizeof(sh_filestore_t), 1, stdout); 1644 1734 printf ("%s\n", fullpath); 1645 1735 printf ("%s\n", linkpath); 1736 if (attr_string) 1737 printf ("%s\n", attr_string); 1646 1738 } 1647 1739 … … 1656 1748 SH_FREE(fullpath); 1657 1749 SH_FREE(linkpath); 1750 if (attr_string) 1751 SH_FREE(attr_string); 1658 1752 1659 1753 SL_RET0(_("sh_hash_pushdata")); … … 1689 1783 f = sh_hash_create_ft (p, fileHash); 1690 1784 sh_hash_pushdata (f, fileHash); 1785 if (f->attr_string) 1786 SH_FREE(f->attr_string); 1691 1787 SH_FREE(f); 1692 1788 } … … 1757 1853 tmpFile->mtime = p->theFile.mtime; 1758 1854 tmpFile->ctime = p->theFile.ctime; 1855 1856 tmpFile->attr_string = NULL; 1759 1857 return 0; 1760 1858 } … … 1857 1955 int i = 0; 1858 1956 char * p; 1957 1958 tmpFile.attr_string = NULL; 1859 1959 1860 1960 sl_strlcpy(tmpFile.fullpath, key, PATH_MAX); … … 1979 2079 char * fullpath; 1980 2080 char * linkpath; 2081 char * attr_string = NULL; 1981 2082 1982 2083 SL_ENTER(_("sh_hash_push_int")); … … 1985 2086 1986 2087 p.mark = REC_MAGIC; 2088 if (buf->attr_string) 2089 p.mark |= REC_FLAGS_ATTR; 1987 2090 sl_strlcpy(p.c_mode, buf->c_mode, 11); 1988 2091 sl_strlcpy(p.c_group, buf->c_group, GROUP_MAX+1); … … 2015 2118 fp->modi_mask = 0L; 2016 2119 2120 if (buf->attr_string) 2121 attr_string = sh_util_strdup(buf->attr_string); 2122 fp->attr_string = attr_string; 2123 2017 2124 len = sl_strlen(buf->fullpath); 2018 2125 if (len <= MAX_PATH_STORE) … … 2235 2342 } 2236 2343 } 2344 2345 if (theFile->attr_string) 2346 { 2347 tmp_lnk = sh_util_safe_name(theFile->attr_string); 2348 if (tmp_lnk) 2349 { 2350 if (is_new) 2351 sl_snprintf(tmp, SH_BUFSIZE, _("acl_new=\"%s\" "), tmp_lnk); 2352 else 2353 sl_snprintf(tmp, SH_BUFSIZE, _("acl_old=\"%s\" "), tmp_lnk); 2354 SH_FREE(tmp_lnk); 2355 sl_strlcat(msg, tmp, SH_BUFSIZE); 2356 } 2357 } 2358 2237 2359 2238 2360 SH_FREE(tmp); … … 2387 2509 } 2388 2510 2511 if (theFile->attr_string) 2512 { 2513 tmp_lnk = sh_util_safe_name(theFile->attr_string); 2514 if (tmp_lnk) 2515 { 2516 if (is_new) 2517 sl_snprintf(tmp, SH_BUFSIZE, _(", acl_new=<%s> "), tmp_lnk); 2518 else 2519 sl_snprintf(tmp, SH_BUFSIZE, _(", acl_old=<%s> "), tmp_lnk); 2520 SH_FREE(tmp_lnk); 2521 sl_strlcat(msg, tmp, SH_BUFSIZE); 2522 } 2523 } 2524 2389 2525 SH_FREE(tmp); 2390 2526 return (msg); … … 2605 2741 2606 2742 if ( ( (theFile->mode != p->theFile.mode) 2743 #if defined(USE_ACL) || defined(USE_XATTR) 2744 || ( (sh_unix_check_selinux|sh_unix_check_acl) && 2745 ( 2746 (theFile->attr_string == NULL && p->attr_string != NULL) || 2747 (theFile->attr_string != NULL && p->attr_string == NULL) || 2748 (theFile->attr_string != NULL && 0 != strcmp(theFile->attr_string, p->attr_string)) 2749 ) 2750 ) 2751 #endif 2607 2752 #if defined(__linux__) || defined(HAVE_STAT_FLAGS) 2608 2753 || (theFile->attributes != p->theFile.attributes) 2609 2754 #endif 2610 2755 ) 2611 2756 && (theFile->check_mask & MODI_MOD) != 0) 2612 2757 { … … 2652 2797 } 2653 2798 2654 if ( theFile->atime != (time_t) p->theFile.atime&&2655 (theFile->check_mask & MODI_ATM) != 0)2799 if ( (theFile->check_mask & MODI_ATM) != 0 && 2800 theFile->atime != (time_t) p->theFile.atime) 2656 2801 { 2657 2802 modi_mask |= MODI_ATM; … … 2705 2850 if ( ((modi_mask & MODI_MOD) != 0) 2706 2851 #if defined(HAVE_LIBPRELUDE) && defined(HAVE_LIBPRELUDE_9) 2707 || ((modi_mask & MODI_USR) != 0)2708 || ((modi_mask & MODI_GRP) != 0)2852 || ((modi_mask & MODI_USR) != 0) 2853 || ((modi_mask & MODI_GRP) != 0) 2709 2854 #endif 2710 2855 ) … … 2729 2874 sl_snprintf(tmp, SH_BUFSIZE, 2730 2875 _("mode_old=\"%s\" mode_new=\"%s\" imode_old=\"%ld\" imode_new=\"%ld\" "), 2731 #else 2732 sl_snprintf(tmp, SH_BUFSIZE, _("mode_old=<%s>, mode_new=<%s>, "), 2733 #endif 2734 p->theFile.c_mode, theFile->c_mode 2876 p->theFile.c_mode, theFile->c_mode, 2877 (long) p->theFile.mode, (long) theFile->mode); 2878 #else 2879 sl_snprintf(tmp, SH_BUFSIZE, _("mode_old=<%s>, mode_new=<%s>, "), 2880 p->theFile.c_mode, theFile->c_mode); 2881 #endif 2882 #endif 2883 sl_strlcat(msg, tmp, SH_BUFSIZE); 2884 2885 #if defined(USE_ACL) || defined(USE_XATTR) 2886 if (theFile->attr_string != NULL || p->attr_string != NULL) 2887 { 2888 sl_snprintf(tmp, SH_BUFSIZE, 2735 2889 #ifdef SH_USE_XML 2736 , (long) p->theFile.mode, (long) theFile->mode 2737 #endif 2738 ); 2739 #endif 2740 sl_strlcat(msg, tmp, SH_BUFSIZE); 2890 _("acl_old=\"%s\" acl_new=\"%s\" "), 2891 #else 2892 _("acl_old=<%s>, acl_new=<%s>, "), 2893 #endif 2894 (p->attr_string) ? p->attr_string : _("none"), 2895 (theFile->attr_string) ? theFile->attr_string : _("none")); 2896 2897 sl_strlcat(msg, tmp, SH_BUFSIZE); 2898 } 2899 #endif 2900 2741 2901 #ifdef REPLACE_OLD 2742 2902 if ((modi_mask & MODI_MOD) != 0) … … 2754 2914 p->theFile.attributes = theFile->attributes; 2755 2915 #endif 2916 #if defined(USE_ACL) || defined(USE_XATTR) 2917 if (p->attr_string == NULL && theFile->attr_string != NULL) 2918 { p->attr_string = sh_util_strdup (theFile->attr_string); } 2919 else if (p->attr_string != NULL && theFile->attr_string == NULL) 2920 { SH_FREE(p->attr_string); p->attr_string = NULL; } 2921 else if (theFile->attr_string != NULL && p->attr_string != NULL) 2922 { 2923 if (0 != strcmp(theFile->attr_string, p->attr_string)) 2924 { 2925 SH_FREE(p->attr_string); 2926 p->attr_string = sh_util_strdup (theFile->attr_string); 2927 } 2928 } 2929 #endif 2756 2930 } 2757 2931 } … … 3039 3213 sl_strlcpy(theFile->c_attributes, p->theFile.c_attributes, 16); 3040 3214 theFile->attributes = p->theFile.attributes; 3215 #endif 3216 #if defined(USE_ACL) || defined(USE_XATTR) 3217 if (theFile->attr_string == NULL && p->attr_string != NULL) 3218 { theFile->attr_string = sh_util_strdup (p->attr_string); } 3219 else if (theFile->attr_string != NULL && p->attr_string == NULL) 3220 { SH_FREE(theFile->attr_string); theFile->attr_string = NULL; } 3221 else if (theFile->attr_string != NULL && p->attr_string != NULL) 3222 { 3223 if (0 != strcmp(theFile->attr_string, p->attr_string)) 3224 { 3225 SH_FREE(theFile->attr_string); 3226 theFile->attr_string = sh_util_strdup (p->attr_string); 3227 } 3228 } 3041 3229 #endif 3042 3230 … … 3084 3272 p->theFile.attributes = theFile->attributes; 3085 3273 #endif 3274 #if defined(USE_ACL) || defined(USE_XATTR) 3275 if (p->attr_string == NULL && theFile->attr_string != NULL) 3276 { p->attr_string = sh_util_strdup (theFile->attr_string); } 3277 else if (p->attr_string != NULL && theFile->attr_string == NULL) 3278 { SH_FREE(p->attr_string); p->attr_string = NULL; } 3279 else if (theFile->attr_string != NULL && p->attr_string != NULL) 3280 { 3281 if (0 != strcmp(theFile->attr_string, p->attr_string)) 3282 { 3283 SH_FREE(p->attr_string); 3284 p->attr_string = sh_util_strdup (theFile->attr_string); 3285 } 3286 } 3287 #endif 3086 3288 3087 3289 if (theFile->c_mode[0] == 'l') … … 3216 3418 char * tmp; 3217 3419 char str[81]; 3420 size_t i; 3218 3421 3219 3422 if (ListWithDelimiter == S_TRUE) … … 3270 3473 tmp = sh_util_safe_name(p->linkpath); 3271 3474 if (ListWithDelimiter == S_TRUE) 3272 printf(_(" %s \n"), tmp);3475 printf(_(" %s"), tmp); 3273 3476 else 3274 printf(_(" -> %s \n"), tmp);3477 printf(_(" -> %s"), tmp); 3275 3478 SH_FREE(tmp); 3276 3479 } 3277 else 3278 printf("\n"); 3480 if (ListWithDelimiter == S_TRUE) 3481 putchar(','); 3482 3483 if (p->attr_string) 3484 { 3485 tmp = sh_util_safe_name(p->attr_string); 3486 if (ListWithDelimiter == S_TRUE) { 3487 for (i = 0; i < strlen(tmp); ++i) 3488 if (tmp[i] == ',') tmp[i] = ';'; 3489 } 3490 printf(_(" %s"), tmp); 3491 SH_FREE(tmp); 3492 } 3493 else 3494 { 3495 if (ListWithDelimiter == S_TRUE) 3496 printf(_(" no_attr")); 3497 } 3498 putchar('\n'); 3279 3499 3280 3500 return;
Note:
See TracChangeset
for help on using the changeset viewer.