Changeset 355
- Timestamp:
- Sep 5, 2011, 6:21:54 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/docs/Changelog
r354 r355 1 1 2.8.6: 2 * Option to use a textfile with a list of files for update 2 3 * Fix --enable-db-reload option (reported by David L.) 3 4 * Fix samhain_kmem compilation, need to compile under chosen -
trunk/include/sh_utils.h
r305 r355 96 96 int sh_util_ask_update(const char * path); 97 97 int sh_util_set_interactive(const char * str); 98 int sh_util_update_file (const char * str); 98 99 99 100 /* don't log output files -
trunk/src/sh_getopt.c
r347 r355 80 80 HAS_ARG_NO, 81 81 sh_util_set_interactive }, 82 { N_("listfile"), 83 '-', 84 N_("Run update with listfile"), 85 HAS_ARG_YES, 86 sh_util_update_file }, 82 87 #endif 83 88 #if defined(SH_WITH_SERVER) || defined(SH_WITH_CLIENT) -
trunk/src/sh_utils.c
r305 r355 107 107 108 108 sh_ask_update = S_TRUE; 109 110 109 sh_unix_setnodeamon(NULL); 111 110 112 111 return 0; 113 112 } 113 114 static char * sh_update_file = NULL; 115 116 int sh_util_update_file (const char * str) 117 { 118 if (str) 119 { 120 if (0 == access(str, R_OK)) /* flawfinder: ignore */ 121 { 122 if (NULL != sh_update_file) 123 SH_FREE(sh_update_file); 124 sh_update_file = sh_util_strdup(str); 125 sh_ask_update = S_TRUE; 126 sh_unix_setnodeamon(NULL); 127 return 0; 128 } 129 else 130 { 131 char ebuf[SH_ERRBUF_SIZE]; 132 int errnum = errno; 133 134 sh_error_message(errnum, ebuf, sizeof(ebuf)); 135 sh_error_handle (SH_ERR_ERR, FIL__, __LINE__, errnum, MSG_E_SUBGEN, 136 ebuf, _("sh_util_update_file") ); 137 138 return -1; 139 } 140 } 141 142 return -1; 143 } 144 114 145 115 146 #if !defined(STDIN_FILENO) … … 120 151 #endif 121 152 153 /* Returns S_FALSE if no update desired 154 */ 155 int sh_util_update_checkfile(const char * path) 156 { 157 FILE * fd = fopen(sh_update_file, "r"); 158 char * line; 159 160 if (!fd) 161 { 162 uid_t euid; 163 int errnum = errno; 164 sl_get_euid(&euid); 165 sh_error_handle (SH_ERR_ERR, FIL__, __LINE__, errnum, MSG_NOACCESS, 166 (long) euid, sh_update_file); 167 aud_exit (FIL__, __LINE__, EXIT_FAILURE); 168 return S_FALSE; 169 } 170 171 line = SH_ALLOC(8192); 172 173 while (NULL != fgets(line, 8192, fd)) 174 { 175 char * nl = strrchr(line, '\n'); 176 177 if (nl) 178 { 179 *nl = '\0'; 180 181 /* Check for MS Windows line terminator 182 */ 183 if (nl > line) --nl; 184 if (*nl == '\r') 185 *nl = '\0'; 186 } 187 188 if (0 == sl_strcmp(line, path)) 189 { 190 SH_FREE(line); 191 fclose(fd); 192 return S_TRUE; 193 } 194 } 195 SH_FREE(line); 196 fclose(fd); 197 return S_FALSE; 198 } 199 200 /* Returns S_FALSE if no update desired 201 */ 122 202 int sh_util_ask_update(const char * path) 123 203 { … … 130 210 if (sh_ask_update != S_TRUE) 131 211 { 212 SL_RETURN(i, _("sh_util_ask_update")); 213 } 214 215 if (sh_update_file) 216 { 217 i = sh_util_update_checkfile(path); 132 218 SL_RETURN(i, _("sh_util_ask_update")); 133 219 }
Note:
See TracChangeset
for help on using the changeset viewer.