Changeset 215 for trunk/src/sh_extern.c
- Timestamp:
- Feb 18, 2009, 7:11:26 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_extern.c
r214 r215 92 92 #include "sh_extern.h" 93 93 #include "sh_calls.h" 94 #include "sh_filter.h" 94 95 #define SH_NEED_PWD_GRP 1 95 96 #include "sh_static.h" … … 867 868 char type[4]; 868 869 869 int for_c; 870 char * for_v[32]; 871 int fand_c; 872 char * fand_v[32]; 873 int fnot_c; 874 char * fnot_v[32]; 870 sh_filter_type * filter; 871 875 872 time_t deadtime; 876 873 time_t last_run; … … 900 897 sh_com_t * command_init(void) 901 898 { 902 int i;903 899 uid_t ff_euid; 904 900 sh_com_t * ext_com = NULL; … … 924 920 925 921 set3(ext_com->type, 'l', 'o', 'g'); 926 ext_com->for_c = 0; 927 ext_com->fand_c = 0; 928 ext_com->fnot_c = 0; 922 ext_com->filter = NULL; 929 923 ext_com->deadtime = 0; 930 924 ext_com->last_run = 0; 931 925 932 for (i = 0; i < 32; ++i)933 {934 ext_com->for_v[i] = NULL;935 ext_com->fand_v[i] = NULL;936 ext_com->fnot_v[i] = NULL;937 }938 926 ext_com->next = NULL; 939 927 … … 1128 1116 int sh_ext_cleanup(void) 1129 1117 { 1130 int i;1131 1118 sh_com_t * retval; 1132 1119 … … 1140 1127 sh_ext_tas_free (&(retval->tas)); 1141 1128 1142 for (i = 0; i < 32; ++i) 1143 { 1144 if (NULL != retval->for_v[i]) SH_FREE(retval->for_v[i]); 1145 if (NULL != retval->fand_v[i]) SH_FREE(retval->fand_v[i]); 1146 if (NULL != retval->fnot_v[i]) SH_FREE(retval->fnot_v[i]); 1147 } 1129 if (retval->filter) 1130 sh_filter_free (retval->filter); 1148 1131 1149 1132 SH_FREE(retval); … … 1173 1156 if (ext_coms == NULL || ext_failed == (-1)) 1174 1157 return (-1); 1175 return (sh_ext_add (str, &(ext_coms->for_c), ext_coms->for_v)); 1158 if (ext_coms->filter == NULL) 1159 ext_coms->filter = sh_filter_alloc(); 1160 return (sh_filter_add(str, ext_coms->filter, SH_FILT_OR)); 1176 1161 } 1177 1162 … … 1183 1168 if (ext_coms == NULL || ext_failed == (-1)) 1184 1169 return (-1); 1185 return (sh_ext_add (str, &(ext_coms->fand_c), ext_coms->fand_v)); 1170 if (ext_coms->filter == NULL) 1171 ext_coms->filter = sh_filter_alloc(); 1172 return (sh_filter_add(str, ext_coms->filter, SH_FILT_AND)); 1186 1173 } 1187 1174 … … 1193 1180 if (ext_coms == NULL || ext_failed == (-1)) 1194 1181 return (-1); 1195 return (sh_ext_add (str, &(ext_coms->fnot_c), ext_coms->fnot_v)); 1182 if (ext_coms->filter == NULL) 1183 ext_coms->filter = sh_filter_alloc(); 1184 return (sh_filter_add(str, ext_coms->filter, SH_FILT_NOT)); 1196 1185 } 1197 1186 … … 1354 1343 static int sh_ext_filter (char * message, sh_com_t * task) 1355 1344 { 1356 int i;1357 int j = 0;1358 1345 time_t now_time; 1359 1346 1360 1347 SL_ENTER(_("sh_ext_filter")); 1361 1348 1362 /* Presence of any of these keywords prevents execution. 1363 */ 1364 if (task->fnot_c > 0) 1365 { 1366 for (i = 0; i < task->fnot_c; ++i) 1349 if (task->filter) 1350 { 1351 if (0 != sh_filter_filter (message, task->filter)) 1367 1352 { 1368 if (NULL != sl_strstr(message, task->fnot_v[i])) 1369 { 1370 SL_RETURN ((-1), _("sh_ext_filter")); 1371 } 1353 SL_RETURN ((-1), _("sh_ext_filter")); 1372 1354 } 1373 1355 } 1374 1356 1375 /* Presence of all of these keywords is required for execution. 1376 */ 1377 if (task->fand_c > 0) 1378 { 1379 j = 0; 1380 1381 for (i = 0; i < task->fand_c; ++i) 1382 { 1383 if (NULL == sl_strstr(message, task->fand_v[i])) 1384 { 1385 SL_RETURN ((-1), _("sh_ext_filter")); 1386 } 1387 } 1388 1389 } 1390 1391 /* Presence of at least one of these keywords is required for execution. 1392 */ 1393 if (task->for_c > 0) 1394 { 1395 for (i = 0; i < task->for_c; ++i) 1396 { 1397 if (NULL != sl_strstr(message, task->for_v[i])) 1398 { 1399 goto checkdeadtime; 1400 } 1401 } 1402 SL_RETURN ((-1), _("sh_ext_filter")); 1403 } 1404 1405 checkdeadtime: 1406 if (task->deadtime != (time_t) 0) /* deadtime */ 1357 /* Filter passed, check deadtime */ 1358 1359 if (task->deadtime != (time_t) 0) 1407 1360 { 1408 1361 now_time = time (NULL);
Note:
See TracChangeset
for help on using the changeset viewer.