Changes in trunk/src/sh_files.c [20:27]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_files.c
r20 r27 72 72 #define FIL__ _("sh_files.c") 73 73 74 extern int safe_logger (int signal, int method, pid_t thepid);75 76 74 extern int flag_err_debug; 77 75 extern int flag_err_info; 78 76 79 int sh_files_reportonce(c har * c)77 int sh_files_reportonce(const char * c) 80 78 { 81 79 int i; … … 86 84 } 87 85 88 int sh_files_fulldetail(c har * c)86 int sh_files_fulldetail(const char * c) 89 87 { 90 88 int i; … … 156 154 static int sh_files_fullpath (char * testdir, char * d_name, 157 155 char * statpath); 158 static int sh_files_pushdir (int class, c har * str_s);159 static int sh_files_pushfile (int class, c har * str_s);156 static int sh_files_pushdir (int class, const char * str_s); 157 static int sh_files_pushfile (int class, const char * str_s); 160 158 static int sh_files_checkdir (int class, int rdepth, char * dirName, 161 159 char * relativeName); … … 446 444 447 445 448 int sh_files_pushfile_prelink (c har * str_s)446 int sh_files_pushfile_prelink (const char * str_s) 449 447 { 450 448 return (sh_files_pushfile (SH_LEVEL_PRELINK, str_s)); 451 449 } 452 450 453 int sh_files_pushfile_user0 (c har * str_s)451 int sh_files_pushfile_user0 (const char * str_s) 454 452 { 455 453 return (sh_files_pushfile (SH_LEVEL_USER0, str_s)); 456 454 } 457 455 458 459 int sh_files_pushfile_user1 (char * str_s) 456 int sh_files_pushfile_user1 (const char * str_s) 460 457 { 461 458 return (sh_files_pushfile (SH_LEVEL_USER1, str_s)); 462 459 } 463 460 464 465 int sh_files_pushfile_ro (char * str_s) 461 int sh_files_pushfile_user2 (const char * str_s) 462 { 463 return (sh_files_pushfile (SH_LEVEL_USER2, str_s)); 464 } 465 466 int sh_files_pushfile_user3 (const char * str_s) 467 { 468 return (sh_files_pushfile (SH_LEVEL_USER3, str_s)); 469 } 470 471 int sh_files_pushfile_user4 (const char * str_s) 472 { 473 return (sh_files_pushfile (SH_LEVEL_USER4, str_s)); 474 } 475 476 477 int sh_files_pushfile_ro (const char * str_s) 466 478 { 467 479 return (sh_files_pushfile (SH_LEVEL_READONLY, str_s)); 468 480 } 469 481 470 int sh_files_pushfile_attr (c har * str_s)482 int sh_files_pushfile_attr (const char * str_s) 471 483 { 472 484 return (sh_files_pushfile (SH_LEVEL_ATTRIBUTES, str_s)); 473 485 } 474 486 475 int sh_files_pushfile_log (c har * str_s)487 int sh_files_pushfile_log (const char * str_s) 476 488 { 477 489 return (sh_files_pushfile (SH_LEVEL_LOGFILES, str_s)); 478 490 } 479 491 480 int sh_files_pushfile_glog (c har * str_s)492 int sh_files_pushfile_glog (const char * str_s) 481 493 { 482 494 return (sh_files_pushfile (SH_LEVEL_LOGGROW, str_s)); 483 495 } 484 496 485 int sh_files_pushfile_noig (c har * str_s)497 int sh_files_pushfile_noig (const char * str_s) 486 498 { 487 499 return (sh_files_pushfile (SH_LEVEL_NOIGNORE, str_s)); 488 500 } 489 501 490 int sh_files_pushfile_allig (c har * str_s)502 int sh_files_pushfile_allig (const char * str_s) 491 503 { 492 504 return (sh_files_pushfile (SH_LEVEL_ALLIGNORE, str_s)); … … 511 523 /* set mask(class) 512 524 */ 513 static int sh_files_parse_mask (unsigned long * mask, c har * str)525 static int sh_files_parse_mask (unsigned long * mask, const char * str) 514 526 { 515 527 int l, i = 0, act = 0, k = 0; … … 602 614 } 603 615 604 int sh_files_redef_prelink(c har * str)616 int sh_files_redef_prelink(const char * str) 605 617 { 606 618 return (sh_files_parse_mask(&mask_PRELINK, str)); 607 619 } 608 int sh_files_redef_user0(c har * str)620 int sh_files_redef_user0(const char * str) 609 621 { 610 622 return (sh_files_parse_mask(&mask_USER0, str)); 611 623 } 612 int sh_files_redef_user1(c har * str)624 int sh_files_redef_user1(const char * str) 613 625 { 614 626 return (sh_files_parse_mask(&mask_USER1, str)); 615 627 } 616 int sh_files_redef_readonly(char * str) 628 int sh_files_redef_user2(const char * str) 629 { 630 return (sh_files_parse_mask(&mask_USER2, str)); 631 } 632 int sh_files_redef_user3(const char * str) 633 { 634 return (sh_files_parse_mask(&mask_USER3, str)); 635 } 636 int sh_files_redef_user4(const char * str) 637 { 638 return (sh_files_parse_mask(&mask_USER4, str)); 639 } 640 int sh_files_redef_readonly(const char * str) 617 641 { 618 642 return (sh_files_parse_mask(&mask_READONLY, str)); 619 643 } 620 int sh_files_redef_loggrow(c har * str)644 int sh_files_redef_loggrow(const char * str) 621 645 { 622 646 return (sh_files_parse_mask(&mask_LOGGROW, str)); 623 647 } 624 int sh_files_redef_logfiles(c har * str)648 int sh_files_redef_logfiles(const char * str) 625 649 { 626 650 return (sh_files_parse_mask(&mask_LOGFILES, str)); 627 651 } 628 int sh_files_redef_attributes(c har * str)652 int sh_files_redef_attributes(const char * str) 629 653 { 630 654 return (sh_files_parse_mask(&mask_ATTRIBUTES, str)); 631 655 } 632 int sh_files_redef_noignore(c har * str)656 int sh_files_redef_noignore(const char * str) 633 657 { 634 658 return (sh_files_parse_mask(&mask_NOIGNORE, str)); 635 659 } 636 int sh_files_redef_allignore(c har * str)660 int sh_files_redef_allignore(const char * str) 637 661 { 638 662 return (sh_files_parse_mask(&mask_ALLIGNORE, str)); … … 659 683 case SH_LEVEL_USER1: 660 684 return (unsigned long) mask_USER1; 685 case SH_LEVEL_USER2: 686 return (unsigned long) mask_USER2; 687 case SH_LEVEL_USER3: 688 return (unsigned long) mask_USER3; 689 case SH_LEVEL_USER4: 690 return (unsigned long) mask_USER4; 661 691 case SH_LEVEL_PRELINK: 662 692 return (unsigned long) mask_PRELINK; … … 725 755 if (zfileList == NULL) 726 756 { 727 (void) safe_logger (0, 0, getpid());757 (void) safe_logger (0, 0, NULL); 728 758 aud__exit(FIL__, __LINE__, EXIT_FAILURE); 729 759 } … … 734 764 if (-1 == ret) 735 765 { 736 (void) safe_logger (0, 0, getpid());766 (void) safe_logger (0, 0, NULL); 737 767 aud__exit(FIL__, __LINE__, EXIT_FAILURE); 738 768 } … … 745 775 746 776 747 static int sh_files_pushfile (int class, char * str_s) 748 { 777 static int sh_files_pushfile (int class, const char * str_s) 778 { 779 int len; 749 780 char * tmp; 750 int len;781 char * p; 751 782 #ifdef HAVE_GLOB_H 752 glob_t pglob;753 783 int globstatus = -1; 754 784 unsigned int gloop; 785 glob_t pglob; 755 786 #endif 756 787 … … 808 839 * special case of the root directory. 809 840 */ 810 if (str_s[len-1] == '/' && len > 1) 841 p = sh_util_strdup (str_s); 842 if (p[len-1] == '/' && len > 1) 811 843 { 812 str_s[len-1] = '\0';844 p[len-1] = '\0'; 813 845 --len; 814 846 } … … 817 849 818 850 #ifdef HAVE_GLOB_H 819 if (0 == sh_files_has_metachar( str_s))820 { 821 sh_files_push_file_int (class, str_s, len);851 if (0 == sh_files_has_metachar(p)) 852 { 853 sh_files_push_file_int (class, p, len); 822 854 } 823 855 else 824 856 { 825 857 pglob.gl_offs = 0; 826 globstatus = glob ( str_s, 0, sh_files_globerr, &pglob);858 globstatus = glob (p, 0, sh_files_globerr, &pglob); 827 859 828 860 if (globstatus == 0 && pglob.gl_pathc > 0) … … 834 866 else 835 867 { 836 tmp = sh_util_safe_name ( str_s);868 tmp = sh_util_safe_name (p); 837 869 838 870 if (pglob.gl_pathc == 0 … … 869 901 870 902 #else 871 sh_files_push_file_int (class, str_s, len); 872 #endif 873 903 sh_files_push_file_int (class, p, len); 904 #endif 905 906 SH_FREE(p); 874 907 SL_RETURN((0),_("sh_files_pushfile")); 875 908 } … … 1028 1061 } 1029 1062 1030 int sh_files_pushdir_prelink (c har * str_s)1063 int sh_files_pushdir_prelink (const char * str_s) 1031 1064 { 1032 1065 return (sh_files_pushdir (SH_LEVEL_PRELINK, str_s)); 1033 1066 } 1034 1067 1035 int sh_files_pushdir_user0 (c har * str_s)1068 int sh_files_pushdir_user0 (const char * str_s) 1036 1069 { 1037 1070 return (sh_files_pushdir (SH_LEVEL_USER0, str_s)); 1038 1071 } 1039 1072 1040 int sh_files_pushdir_user1 (c har * str_s)1073 int sh_files_pushdir_user1 (const char * str_s) 1041 1074 { 1042 1075 return (sh_files_pushdir (SH_LEVEL_USER1, str_s)); 1043 1076 } 1044 1077 1045 int sh_files_pushdir_attr (char * str_s) 1078 int sh_files_pushdir_user2 (const char * str_s) 1079 { 1080 return (sh_files_pushdir (SH_LEVEL_USER2, str_s)); 1081 } 1082 1083 int sh_files_pushdir_user3 (const char * str_s) 1084 { 1085 return (sh_files_pushdir (SH_LEVEL_USER3, str_s)); 1086 } 1087 1088 int sh_files_pushdir_user4 (const char * str_s) 1089 { 1090 return (sh_files_pushdir (SH_LEVEL_USER4, str_s)); 1091 } 1092 1093 int sh_files_pushdir_attr (const char * str_s) 1046 1094 { 1047 1095 return (sh_files_pushdir (SH_LEVEL_ATTRIBUTES, str_s)); 1048 1096 } 1049 1097 1050 int sh_files_pushdir_ro (c har * str_s)1098 int sh_files_pushdir_ro (const char * str_s) 1051 1099 { 1052 1100 return (sh_files_pushdir (SH_LEVEL_READONLY, str_s)); 1053 1101 } 1054 1102 1055 int sh_files_pushdir_log (c har * str_s)1103 int sh_files_pushdir_log (const char * str_s) 1056 1104 { 1057 1105 return (sh_files_pushdir (SH_LEVEL_LOGFILES, str_s)); 1058 1106 } 1059 1107 1060 int sh_files_pushdir_glog (c har * str_s)1108 int sh_files_pushdir_glog (const char * str_s) 1061 1109 { 1062 1110 return (sh_files_pushdir (SH_LEVEL_LOGGROW, str_s)); 1063 1111 } 1064 1112 1065 int sh_files_pushdir_noig (c har * str_s)1113 int sh_files_pushdir_noig (const char * str_s) 1066 1114 { 1067 1115 return (sh_files_pushdir (SH_LEVEL_NOIGNORE, str_s)); 1068 1116 } 1069 1117 1070 int sh_files_pushdir_allig (c har * str_s)1118 int sh_files_pushdir_allig (const char * str_s) 1071 1119 { 1072 1120 return (sh_files_pushdir (SH_LEVEL_ALLIGNORE, str_s)); … … 1120 1168 if (tree == NULL) 1121 1169 { 1122 (void) safe_logger (0, 0, getpid());1170 (void) safe_logger (0, 0, NULL); 1123 1171 aud__exit(FIL__, __LINE__, EXIT_FAILURE); 1124 1172 } … … 1133 1181 if (-1 == ret) 1134 1182 { 1135 (void) safe_logger (0, 0, getpid());1183 (void) safe_logger (0, 0, NULL); 1136 1184 aud__exit(FIL__, __LINE__, EXIT_FAILURE); 1137 1185 } … … 1143 1191 } 1144 1192 1145 static int sh_files_pushdir (int class, c har * str_s)1193 static int sh_files_pushdir (int class, const char * str_s) 1146 1194 { 1147 1195 char * tmp; … … 1149 1197 int rdepth = 0; 1150 1198 char * tail = NULL; 1199 char * p; 1151 1200 1152 1201 #ifdef HAVE_GLOB_H … … 1166 1215 SL_RETURN((-1), _("sh_files_pushdir")); 1167 1216 1168 1169 if (str_s[0] != '/') 1170 { 1171 rdepth = strtol(str_s, &tail, 10); 1172 if (tail == str_s) 1173 SL_RETURN((-1), _("sh_files_pushdir")); 1217 p = sh_util_strdup (str_s); 1218 1219 if (p[0] != '/') 1220 { 1221 rdepth = strtol(p, &tail, 10); 1222 if (tail == p) 1223 { 1224 SH_FREE(p); 1225 SL_RETURN((-1), _("sh_files_pushdir")); 1226 } 1174 1227 } 1175 1228 else 1176 tail = str_s;1229 tail = p; 1177 1230 1178 1231 1179 if (rdepth < (-1) || tail == str_s|| rdepth > 99)1232 if (rdepth < (-1) || tail == p || rdepth > 99) 1180 1233 rdepth = (-2); 1181 1234 … … 1188 1241 tmp); 1189 1242 SH_FREE(tmp); 1243 SH_FREE(p); 1190 1244 SL_RETURN((-1), _("sh_files_pushdir")); 1191 1245 } 1192 1246 else if (len < 1) 1193 1247 { 1248 SH_FREE(p); 1194 1249 SL_RETURN((-1), _("sh_files_pushdir")); 1195 1250 } … … 1200 1255 tmp); 1201 1256 SH_FREE(tmp); 1257 SH_FREE(p); 1202 1258 SL_RETURN((-1), _("sh_files_pushdir")); 1203 1259 } … … 1268 1324 #endif 1269 1325 1326 SH_FREE(p); 1270 1327 SL_RETURN((0), _("sh_files_pushdir")); 1271 1328 } … … 1322 1379 /* Simply sets our boolean as to whether this check is active 1323 1380 */ 1324 int sh_files_check_hardlinks (c har * opt)1381 int sh_files_check_hardlinks (const char * opt) 1325 1382 { 1326 1383 int i; … … 1338 1395 static struct sh_hle_struct * sh_hl_exc = NULL; 1339 1396 1340 int sh_files_hle_reg (c har * str)1397 int sh_files_hle_reg (const char * str) 1341 1398 { 1342 1399 long offset;
Note:
See TracChangeset
for help on using the changeset viewer.