- Timestamp:
- Aug 21, 2007, 10:22:59 PM (17 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_hash.c
r114 r115 1054 1054 memcpy( &(*p).theFile, &ft, sizeof(sh_filestore_t) ); 1055 1055 1056 p->fflags = 0; 1057 1056 /* init fflags, such that suid files in 1057 * database are recognized as such 1058 */ 1059 { 1060 mode_t mode = (mode_t) ft.mode; 1061 1062 if (S_ISREG(mode) && 1063 (0 !=(S_ISUID & mode) || 1064 #if defined(HOST_IS_LINUX) 1065 (0 !=(S_ISGID & mode) && 1066 0 !=(S_IXGRP & mode)) 1067 #else 1068 0 !=(S_ISGID & mode) 1069 #endif 1070 ) 1071 ) 1072 p->fflags = SH_FFLAG_SUIDCHK; 1073 1074 else 1075 p->fflags = 0; 1076 } 1077 1058 1078 p->modi_mask = 0L; 1059 1079 p->fullpath = fullpath; … … 1812 1832 sh_file_t * p; 1813 1833 1814 SL_ENTER(_("sh_hash_have_it "));1834 SL_ENTER(_("sh_hash_have_it_int")); 1815 1835 1816 1836 if (newname == NULL) 1817 SL_RETURN( (NULL), _("sh_hash_have_it "));1837 SL_RETURN( (NULL), _("sh_hash_have_it_int")); 1818 1838 1819 1839 if (IsInit != 1) … … 1824 1844 p = hashsearch ( sh_tiger_hash(newname, TIGER_DATA, sl_strlen(newname)) ); 1825 1845 if (p == NULL) 1826 SL_RETURN( (NULL), _("sh_hash_have_it "));1846 SL_RETURN( (NULL), _("sh_hash_have_it_int")); 1827 1847 /* 1828 1848 if (p->allignore == S_FALSE && … … 1831 1851 SL_RETURN( (1), _("sh_hash_have_it")); 1832 1852 */ 1833 SL_RETURN( (p), _("sh_hash_have_it "));1853 SL_RETURN( (p), _("sh_hash_have_it_int")); 1834 1854 } 1835 1855 … … 1860 1880 return 0; 1861 1881 } 1862 1882 1883 int sh_hash_getflags (char * filename) 1884 { 1885 sh_file_t * p = sh_hash_have_it_int (filename); 1886 if (!p) 1887 return (-1); 1888 return (p->fflags); 1889 } 1890 1891 int sh_hash_setflags (char * filename, int flags) 1892 { 1893 sh_file_t * p = sh_hash_have_it_int (filename); 1894 if (!p) 1895 return (-1); 1896 p->fflags = flags; 1897 return 0; 1898 } 1899 1900 /* needs lock to be threadsafe 1901 */ 1902 void sh_hash_addflag (char * filename, int flag_to_set) 1903 { 1904 int fflags = sh_hash_getflags(filename); 1905 1906 if (fflags >= 0) 1907 { 1908 fflags |= flag_to_set; 1909 sh_hash_setflags(filename, fflags); 1910 } 1911 return; 1912 } 1863 1913 1864 1914 /***************************************************************** … … 2106 2156 2107 2157 memcpy( &(*fp).theFile, &p, sizeof(sh_filestore_t) ); 2108 fp->fflags = 0; 2158 fp->fflags = 0; /* init fflags */ 2109 2159 fp->modi_mask = 0L; 2110 2160 -
trunk/src/sh_suidchk.c
r114 r115 831 831 struct stat buf; 832 832 int status; 833 int fflags; 833 834 char * fs; 834 835 long sl_status = SL_ENONE; … … 910 911 ++FileLimTotal; 911 912 913 /* Rate limit (Fps == Files per second) 914 */ 912 915 if ((ShSuidchkFps > 0 && FileLimNum > ShSuidchkFps && FileLimTotal > 0)&& 913 916 (ShSuidchkYield == S_FALSE)) … … 995 998 else 996 999 { 997 if (sh.flag.update == S_TRUE && 1000 1001 if ( sh.flag.update == S_TRUE && 998 1002 (sh.flag.checkSum == SH_CHECK_INIT || 999 1003 sh.flag.checkSum == SH_CHECK_CHECK)) 1000 1004 { 1005 /* Updating database. Report new files that 1006 * are not in database already. Then compare 1007 * to database and report changes. 1008 */ 1001 1009 if (-1 == sh_hash_have_it (tmpcat)) 1002 1010 { … … 1017 1025 sh_hash_pushdata_memory (&theFile, fileHash); 1018 1026 } 1027 1028 sh_hash_addflag(tmpcat, SH_FFLAG_SUIDCHK); 1029 1019 1030 } 1031 1020 1032 else if (sh.flag.checkSum == SH_CHECK_INIT && 1021 1033 sh.flag.update == S_FALSE ) 1022 1034 { 1035 /* Running init. Report on files detected. 1036 */ 1023 1037 sh_hash_pushdata (&theFile, fileHash); 1024 1038 sh_error_handle ((-1), FIL__, __LINE__, 1025 1039 0, MSG_SUID_FOUND, tmp ); 1026 1040 } 1041 1027 1042 else if (sh.flag.checkSum == SH_CHECK_CHECK ) 1028 1043 { 1044 /* Running file check. Report on new files 1045 * detected, and quarantine them. 1046 */ 1029 1047 sh_error_handle (SH_ERR_ALL, FIL__, __LINE__, 1030 1048 0, MSG_SUID_FOUND, tmp ); 1031 if (-1 == sh_hash_have_it (tmpcat)) 1049 1050 fflags = sh_hash_getflags(tmpcat); 1051 1052 if ( (-1 == fflags) || (!SH_FFLAG_SUIDCHK_SET(fflags))) 1032 1053 { 1033 report_file(tmpcat, &theFile, timestrc, timestra, timestrm); 1054 if (-1 == fflags) 1055 report_file(tmpcat, &theFile, timestrc, timestra, timestrm); 1034 1056 1035 1057 /* Quarantine file according to configured method … … 1063 1085 _("[SuidCheck]"), 1064 1086 ShSuidchkSeverity); 1087 1088 sh_hash_addflag(tmpcat, SH_FFLAG_SUIDCHK); 1089 1065 1090 } 1066 1091 } 1067 1092 else 1068 1093 { 1094 /* File exists. Check for modifications. 1095 */ 1069 1096 (void) sh_hash_compdata (SH_LEVEL_READONLY, 1070 1097 &theFile, fileHash, 1071 1098 _("[SuidCheck]"), 1072 1099 ShSuidchkSeverity); 1100 1101 sh_hash_addflag(tmpcat, SH_FFLAG_SUIDCHK); 1102 1073 1103 } 1074 1104 }
Note:
See TracChangeset
for help on using the changeset viewer.