Changeset 283 for trunk/src/sh_prelude.c
- Timestamp:
- May 4, 2010, 10:28:11 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_prelude.c
r227 r283 219 219 { 220 220 char *ret = NULL; 221 221 #if defined(SH_WITH_SERVER) 222 int delim_start_count = 0; 223 int found = 0; 224 #endif 225 222 226 ptr = strchr(ptr, delim_start); 223 227 if ( ! ptr ) … … 225 229 226 230 ret = ++ptr; 227 231 #if defined(SH_WITH_SERVER) 232 while ((*ptr != '\0') && (!found)){ 233 if (*ptr == delim_end) { 234 if (delim_start_count == 0) 235 found = 1; 236 delim_start_count--; 237 } 238 else if (*ptr == delim_start) 239 delim_start_count++; 240 ptr++; 241 } 242 ptr = (found) ? ptr-1 : NULL ; 243 #else 228 244 ptr = strchr(ptr, delim_end); 245 #endif 229 246 if ( ! ptr ) 230 247 return NULL; … … 555 572 556 573 free(uid); 574 /* Don't free(ptr) because of prelude_string_set_nodup(str, ptr) */ 557 575 } 558 576 … … 597 615 598 616 free(gid); 617 /* Don't free(ptr) because of prelude_string_set_nodup(str, ptr) */ 599 618 } 600 619 … … 683 702 return -1; 684 703 } 685 704 705 #if defined(SH_WITH_SERVER) 706 /* when using yule, theres a msg=<... msg=<...> >*/ 707 do { 708 msg = ptr; 709 ptr = get_value(msg, _("msg"), NULL); 710 if ( ! ptr ) { 711 ptr = msg; 712 break; 713 } else { 714 free(msg); 715 } 716 } while (1); 717 #endif 718 686 719 ret = prelude_string_cat(out, ptr); 687 720 free(ptr); … … 1115 1148 1116 1149 1150 static int node_set_address(idmef_node_t *node, const char *addr) 1151 { 1152 int ret; 1153 prelude_string_t *prelude_str; 1154 idmef_address_t *idmef_addr; 1155 1156 ret = prelude_string_new(&prelude_str); 1157 if ( ret < 0 ) 1158 goto err; 1159 1160 ret = prelude_string_set_ref(prelude_str, addr); 1161 if ( ret < 0 ) 1162 goto err; 1163 1164 ret = idmef_address_new(&idmef_addr); 1165 if ( ret < 0 ) 1166 goto err; 1167 1168 idmef_address_set_category(idmef_addr, IDMEF_ADDRESS_CATEGORY_IPV4_ADDR); 1169 idmef_address_set_address(idmef_addr, prelude_str); 1170 idmef_node_set_address(node, idmef_addr, 0); 1171 1172 return 0; 1173 err: 1174 return -1; 1175 } 1176 1177 1178 1117 1179 static int samhain_alert_prelude(int priority, int sh_class, 1118 char *message, unsigned long msgid )1180 char *message, unsigned long msgid, char * inet_peer_ip) 1119 1181 { 1120 1182 int ret; … … 1129 1191 idmef_confidence_t *confidence; 1130 1192 prelude_string_t *str; 1193 #if defined(SH_WITH_SERVER) 1194 idmef_node_t *node; 1195 #endif 1131 1196 1132 1197 if ( !client || sh_class == STAMP) … … 1162 1227 1163 1228 idmef_target_set_decoy(target, IDMEF_TARGET_DECOY_NO); 1164 1229 1230 #if defined(SH_WITH_SERVER) 1231 if ( inet_peer_ip != NULL){ 1232 ret = idmef_target_new_node(target, &node); 1233 1234 ret = node_set_address(node, inet_peer_ip); 1235 if ( ret < 0 ) 1236 goto err; 1237 1238 idmef_target_set_node(target, idmef_node_ref(node)); 1239 } 1240 else 1165 1241 if ( idmef_analyzer_get_node(prelude_client_get_analyzer(client)) ) { 1166 1242 idmef_node_ref(idmef_analyzer_get_node(prelude_client_get_analyzer(client))); 1167 1243 idmef_target_set_node(target, idmef_analyzer_get_node(prelude_client_get_analyzer(client))); 1168 1244 } 1169 1245 #else 1246 if ( idmef_analyzer_get_node(prelude_client_get_analyzer(client)) ) { 1247 idmef_node_ref(idmef_analyzer_get_node(prelude_client_get_analyzer(client))); 1248 idmef_target_set_node(target, idmef_analyzer_get_node(prelude_client_get_analyzer(client))); 1249 } 1250 #endif 1170 1251 if ( strstr(message, _("path=")) ) { 1171 1252 #if defined(SH_WITH_CLIENT) || defined(SH_STANDALONE) … … 1248 1329 1249 1330 1250 int sh_prelude_alert(int priority, int sh_class, char *message, long msgflags, unsigned long msgid )1331 int sh_prelude_alert(int priority, int sh_class, char *message, long msgflags, unsigned long msgid, char *inet_peer_ip) 1251 1332 { 1252 1333 int ret; … … 1257 1338 return -1; 1258 1339 1259 ret = samhain_alert_prelude(priority, sh_class, message, msgid );1340 ret = samhain_alert_prelude(priority, sh_class, message, msgid, inet_peer_ip); 1260 1341 if ( ret < 0 ) { 1261 1342 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN,
Note:
See TracChangeset
for help on using the changeset viewer.