- Timestamp:
- Jan 27, 2010, 10:52:20 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile.in
r269 r272 906 906 echo "Package $$DEBFILE built."; \ 907 907 cp $$DEBFILE ./$(PACKAGE)-$(VERSION)-$(BUILD_NUM).deb; \ 908 ln -s ./$(PACKAGE)-$(VERSION)-$(BUILD_NUM).deb ./$(PACKAGE)-$(VERSION).deb; \ 908 909 fi; \ 909 910 echo -
trunk/configure.ac
r269 r272 12 12 dnl start 13 13 dnl 14 AM_INIT_AUTOMAKE(samhain, 2.6. 1b)14 AM_INIT_AUTOMAKE(samhain, 2.6.2) 15 15 AC_DEFINE([SAMHAIN], 1, [Application is samhain]) 16 16 AC_CANONICAL_HOST -
trunk/docs/Changelog
r271 r272 1 1 2.6.2: 2 * Makefile.in: fix problem in deploy system caused 3 by adding build number for debs in 2.5.9 (reported 4 by roman) 5 * add option for per-rule email alias in log monitoring 6 module 7 * sh_readconf.c: make keywords case-independent 8 * sh_mail.c: on error, report full reply of mail server 9 * sh_mail.c: report smtp transcript at debug level 10 * make sure mail aliases are not emailed twice, and 11 recipients cannot be defined after aliasing them 2 12 * handle named pipes in log monitoring module 3 13 (open in nonblocking mode, ignore read error if empty) -
trunk/include/sh_error_min.h
r265 r272 25 25 long errnum, unsigned long msg_index, ...); 26 26 27 /* this function should be called to (only) send mail 28 */ 29 void sh_error_mail (const char * alias, int sev, 30 const char * file, long line, 31 long status, unsigned long msg_id, ...); 32 27 33 /* convert a string to a numeric priority 28 34 */ -
trunk/include/sh_fifo.h
r214 r272 68 68 sh_string * tag_list (SH_FIFO * fifo, char * tag, 69 69 int(*check)(int, const char*, const char*, const void*), 70 const void * info );70 const void * info, int okNull); 71 71 void rollback_list (SH_FIFO * fifo); 72 72 void mark_list (SH_FIFO * fifo); -
trunk/include/sh_log_evalrule.h
r265 r272 49 49 enum policies policy; 50 50 int severity; 51 sh_string * alias; 51 52 time_t interval; /* if EVAL_SUM, interval */ 52 53 struct sh_qeval * next; … … 56 57 57 58 int sh_log_lookup_severity(const char * str); 59 sh_string * sh_log_lookup_alias(const char * str); 58 60 59 61 #endif -
trunk/include/sh_mail_int.h
r232 r272 25 25 dnsrep * mx_list; 26 26 int severity; 27 int send_mail; 27 short send_mail; 28 short isAlias; 28 29 sh_filter_type * mail_filter; 29 30 struct alias * next; -
trunk/include/slib.h
r252 r272 220 220 221 221 /* 222 * robust strn cmp replacement222 * robust strn[case]cmp replacement 223 223 */ 224 224 int sl_strncmp(const char * a, const char * b, size_t n); 225 226 int sl_strncasecmp(const char * a, const char * b, size_t n); 225 227 226 228 /* -
trunk/src/sh_error.c
r214 r272 1332 1332 /*@i@*/} 1333 1333 1334 #if defined(SH_WITH_MAIL) 1335 void sh_error_mail (const char * alias, int sev, 1336 const char * file, long line, 1337 long status, unsigned long msg_id, ...) 1338 { 1339 va_list vl; /* argument list */ 1340 struct _log_t * lmsg; 1341 1342 int severity; 1343 unsigned int class; 1344 char * fmt; 1345 int retval; 1346 1347 SL_ENTER(_("sh_error_mail")); 1348 1349 /* Returns pointer to (constant|thread-specific) static memory 1350 */ 1351 fmt = /*@i@*/get_format (msg_id, &severity, &class); 1352 1353 if (!fmt) 1354 { 1355 SL_RET0(_("sh_error_mail")); 1356 } 1357 1358 /* --- Override the catalogue severity. --- 1359 */ 1360 if (sev != (-1)) 1361 severity = sev; 1362 1363 /* --- Build the message. --- 1364 */ 1365 lmsg = (struct _log_t *) SH_ALLOC(sizeof(struct _log_t)); 1366 MLOCK( (char *) lmsg, sizeof(struct _log_t)); 1367 /*@i@*/lmsg->msg = NULL; 1368 1369 /*@i@*/(void) sl_strlcpy(lmsg->format, fmt, SH_PATHBUF); 1370 (void) sl_strlcpy(lmsg->file, file, SH_PATHBUF); 1371 lmsg->severity = severity; 1372 lmsg->class = (int) class; 1373 lmsg->line = line; 1374 lmsg->status = status; 1375 1376 /* Format the log message with timestamp etc. 1377 * Allocate lmsg->msg 1378 */ 1379 va_start (vl, msg_id); 1380 (void) sh_error_string (lmsg, vl); 1381 va_end (vl); 1382 1383 if ( (severity & SH_ERR_FATAL) == 0) 1384 retval = sh_nmail_pushstack (severity, lmsg->msg, alias); 1385 else 1386 retval = sh_nmail_msg (severity, lmsg->msg, alias); 1387 1388 if (retval == -2) 1389 { 1390 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_QUEUE_FULL, 1391 _("email")); 1392 } 1393 SL_RET0(_("sh_error_mail")); 1394 } 1395 #else 1396 void sh_error_mail (const char * alias, int sev, 1397 const char * file, long line, 1398 long status, unsigned long msg_id, ...) 1399 { 1400 (void) alias; 1401 (void) sev; 1402 (void) file; 1403 (void) line; 1404 (void) status; 1405 (void) msg_id; 1406 1407 return; 1408 } 1409 /* defined(SH_WITH_MAIL) */ 1410 #endif 1334 1411 1335 1412 /* ------------------------- -
trunk/src/sh_fifo.c
r214 r272 44 44 #define SH_FIFO_MARKED 4 45 45 46 /* Prepare an email message and return it. 46 /* Prepare an email message and return it. Iterate over list on stack and 47 * check for each if it is valid for recipient 'tag'. If yes, add to the 48 * returned string. 49 * okNull == False means that item->s_xtra must be defined 47 50 */ 48 51 sh_string * tag_list (SH_FIFO * fifo, char * tag, 49 52 int(*valid)(int, const char*, const char*, const void*), 50 const void * info )53 const void * info, int okNull) 51 54 { 52 55 struct dlist * item; … … 59 62 while (item) 60 63 { 64 /* Same recipient, or no recipient ( := all ) 65 */ 61 66 if ( (tag && item->s_xtra && 0 == strcmp(item->s_xtra, tag)) || 62 !(item->s_xtra) )67 ((okNull == S_TRUE) && !(item->s_xtra)) ) 63 68 { 64 69 if (valid == NULL) … … 68 73 else 69 74 { 75 /* level, message, recipient, list */ 70 76 if (!valid(item->i_xtra, item->data, tag, info)) 71 77 goto skipped; -
trunk/src/sh_getopt.c
r210 r272 454 454 fputs (_(" using time server"), stdout); ++num; 455 455 #endif 456 #if defined(HAVE_REGEX_H) 457 if (num > 0) fputc ('\n', stdout); 458 fputs (_(" posix regex support"), stdout); ++num; 459 #endif 460 456 461 457 462 #if defined(SH_WITH_CLIENT) || defined(SH_STANDALONE) -
trunk/src/sh_log_check.c
r271 r272 1179 1179 1180 1180 /* Define a reporting queue. 1181 * Format: Label : [Interval] : TYPE : Severity 1181 * Format: Label : [Interval] : TYPE : Severity[:alias] 1182 1182 * TYPE must be 'report' or 'sum' 1183 1183 * Interval is ignored for TYPE='report' -
trunk/src/sh_log_correlate.c
r265 r272 282 282 if (val >= 0) 283 283 { 284 sh_string * alias; 284 285 SH_MUTEX_LOCK(mutex_thread_nolog); 285 286 sh_error_handle (mkeep->queue->severity, FIL__, __LINE__, 0, 286 287 MSG_LOGMON_COR, sh_string_str(mkeep->label), 287 288 val); 289 290 alias = mkeep->queue->alias; 291 if (alias) 292 { 293 sh_error_mail (sh_string_str(alias), 294 mkeep->queue->severity, FIL__, __LINE__, 0, 295 MSG_LOGMON_COR, sh_string_str(mkeep->label), 296 val); 297 } 298 288 299 SH_MUTEX_UNLOCK(mutex_thread_nolog); 289 300 } -
trunk/src/sh_log_evalrule.c
r265 r272 151 151 char ** splits = split_array(new, &nfields, ':', lengths); 152 152 153 /* group is label:regex 154 */ 155 153 156 if (group_open) 154 157 group_open = NULL; … … 313 316 struct sh_qeval * nq; 314 317 int severity; 315 unsigned int nfields = 4; /* label:interval:(report|sum):severity*/316 size_t lengths[ 4];318 unsigned int nfields = 5; /* label:interval:(report|sum):severity[:alias] */ 319 size_t lengths[5]; 317 320 char * new = sh_util_strdup(str); 318 321 char ** splits = split_array(new, &nfields, ':', lengths); 319 322 320 if (nfields !=4)323 if (nfields < 4) 321 324 { 322 325 SH_FREE(splits); … … 356 359 nq = SH_ALLOC(sizeof(struct sh_qeval)); 357 360 nq->label = sh_string_new_from_lchar(splits[0], lengths[0]); 361 nq->alias = NULL; 358 362 359 363 DEBUG("debug: splits[2] = %s, policy = %d\n",splits[2],nq->policy); … … 368 372 369 373 nq->severity = severity; 374 375 if (nfields == 5) 376 { 377 nq->alias = sh_string_new_from_lchar(splits[4], lengths[4]); 378 } 379 370 380 nq->next = queuelist; 371 381 queuelist = nq; … … 408 418 return SH_ERR_SEVERE; 409 419 } 420 421 sh_string * sh_log_lookup_alias(const char * str) 422 { 423 struct sh_qeval * queue; 424 425 if (str) 426 { 427 if (0 != strcmp(str, _("trash"))) 428 { 429 queue = sh_log_find_queue(str); 430 431 if (queue) 432 return queue->alias; 433 } 434 } 435 return NULL; 436 } 437 410 438 411 439 static char * get_label_and_time(const char * inprefix, char * str, … … 993 1021 } 994 1022 995 static void msg_report(int severity, struct sh_geval * rule, struct sh_logrecord * record) 1023 static void msg_report(int severity, const sh_string * alias, 1024 struct sh_geval * rule, struct sh_logrecord * record) 996 1025 { 997 1026 char * tmp; … … 1017 1046 sh_string_str(record->host), 1018 1047 tmp); 1048 if (alias) 1049 { 1050 sh_error_mail (sh_string_str(alias), 1051 severity, FIL__, __LINE__, 0, MSG_LOGMON_REP, 1052 msg, 1053 ttt, 1054 sh_string_str(record->host), 1055 tmp); 1056 } 1019 1057 SH_FREE(ttt); 1020 1058 SH_FREE(msg); … … 1025 1063 } 1026 1064 1027 static void sum_report(int severity, sh_string * host, sh_string * message, sh_string * path) 1065 static void sum_report(int severity, const sh_string * alias, 1066 sh_string * host, sh_string * message, sh_string * path) 1028 1067 { 1029 1068 char * tmp; … … 1037 1076 sh_string_str(host), 1038 1077 tmp); 1078 if (alias) 1079 { 1080 sh_error_mail (sh_string_str(alias), 1081 severity, FIL__, __LINE__, 0, MSG_LOGMON_SUM, 1082 msg, 1083 sh_string_str(host), 1084 tmp); 1085 } 1039 1086 SH_FREE(msg); 1040 1087 SH_FREE(tmp); … … 1108 1155 { 1109 1156 DEBUG("debug: report count\n"); 1110 sum_report(rule->queue->severity, counter->hostname,1111 counter-> counted_str, counter->filename);1157 sum_report(rule->queue->severity, rule->queue->alias, 1158 counter->hostname, counter->counted_str, counter->filename); 1112 1159 counter->start = time(NULL); 1113 1160 counter->count = 0; … … 1131 1178 sh_string_str(record->host), 1132 1179 sh_string_str(record->message)); 1133 msg_report(queue->severity, rule, record);1180 msg_report(queue->severity, queue->alias, rule, record); 1134 1181 retval = 0; 1135 1182 } … … 1177 1224 { 1178 1225 DEBUG("debug: (%lu) no rule found\n", i); ++i; 1179 msg_report(DEFAULT_SEVERITY, NULL, record);1226 msg_report(DEFAULT_SEVERITY, NULL, NULL, record); 1180 1227 } 1181 1228 -
trunk/src/sh_log_mark.c
r265 r272 221 221 { 222 222 int severity; 223 sh_string * alias; 223 224 SH_MUTEX_LOCK(mutex_thread_nolog); 224 225 … … 233 234 sh_string_str(event->label), 234 235 (unsigned long) delay); 236 alias = sh_log_lookup_alias(sh_string_str(event->queue_id)); 237 if (alias) 238 { 239 sh_error_mail (sh_string_str(alias), severity, 240 FIL__, __LINE__, 0, MSG_LOGMON_MARK, 241 sh_string_str(event->label), 242 (unsigned long) delay); 243 } 244 235 245 SH_MUTEX_UNLOCK(mutex_thread_nolog); 236 246 } -
trunk/src/sh_log_repeat.c
r265 r272 521 521 char * tmpmsg; 522 522 char * tmphost; 523 sh_string * alias; 523 524 524 525 /* issue report */ … … 530 531 FIL__, __LINE__, 0, MSG_LOGMON_BURST, 531 532 repeat, tmpmsg, tmphost); 533 alias = sh_log_lookup_alias(sh_repeat_queue); 534 if (alias) 535 { 536 sh_error_mail (sh_string_str(alias), 537 sh_log_lookup_severity(sh_repeat_queue), 538 FIL__, __LINE__, 0, MSG_LOGMON_BURST, 539 repeat, tmpmsg, tmphost); 540 } 532 541 SH_FREE(tmpmsg); 533 542 SH_FREE(tmphost); -
trunk/src/sh_mail.c
r252 r272 947 947 948 948 static time_t time_wait = 300; 949 static void report_smtp (char * reply); 949 950 950 951 static FILE * sh_mail_start_conn (struct alias * ma_address, … … 1113 1114 if (0 != is_numeric(sh.host.name)) 1114 1115 { 1115 TPT(( 0, FIL__, __LINE__, _("msg=<HELO [%s]>%c%c"),1116 sh.host.name, 13, 10));1116 sl_snprintf(error_msg, sizeof(error_msg), "HELO [%s]", 1117 sh.host.name); 1117 1118 } 1118 1119 else 1119 1120 { 1120 TPT(( 0, FIL__, __LINE__, _("msg=<HELO %s>%c%c"), 1121 sh.host.name, 13, 10)); 1122 } 1121 sl_snprintf(error_msg, sizeof(error_msg), "HELO %s", 1122 sh.host.name); 1123 } 1124 report_smtp(error_msg); 1125 1123 1126 if (0 != is_numeric(sh.host.name)) 1124 1127 fprintf(connFile, _("HELO [%s]%c%c"), sh.host.name, 13, 10); … … 1152 1155 } 1153 1156 1154 TPT(( 0, FIL__, __LINE__, _("msg=<MAIL FROM:<%s>>%c%c"), 1155 this_address, 13, 10)); 1157 sl_snprintf(error_msg, sizeof(error_msg), "MAIL FROM:<%s>", 1158 this_address); 1159 report_smtp(error_msg); 1156 1160 1157 1161 (void) fflush(connFile); … … 1175 1179 if (aFlag == 0) 1176 1180 { 1177 TPT(( 0, FIL__, __LINE__, _("msg=<RCPT TO:<%s>>%c%c"), 1178 address, 13, 10)); 1181 sl_snprintf(error_msg, sizeof(error_msg), "RCPT TO:<%s>", 1182 address); 1183 report_smtp(error_msg); 1179 1184 1180 1185 (void) fflush(connFile); … … 1210 1215 ++address_num; 1211 1216 1212 TPT(( 0, FIL__, __LINE__, _("msg=<RCPT TO:<%s>>%c%c"), 1213 sh_string_str(ma_address->recipient), 13, 10)); 1217 sl_snprintf(error_msg, sizeof(error_msg), "RCPT TO:<%s>", 1218 sh_string_str(ma_address->recipient)); 1219 report_smtp(error_msg); 1214 1220 1215 1221 (void) fflush(connFile); … … 1241 1247 /* Send the message 1242 1248 */ 1243 TPT(( 0, FIL__, __LINE__, _("msg=<DATA>%c%c"), 13, 10));1249 report_smtp(_("DATA")); 1244 1250 1245 1251 (void) fflush(connFile); … … 1273 1279 TPT(( 0, FIL__, __LINE__, _("msg=<From: <%s>%c%cTo: <%s>%c%cDate: %s>%c%c"), 1274 1280 this_address, 13, 10, address, 13, 10, my_tbuf, 13, 10)); 1281 1282 report_smtp(_("sending data..")); 1275 1283 1276 1284 (void) fflush(connFile); … … 1299 1307 time_wait = 300; 1300 1308 1309 report_smtp(_(".")); 1310 1301 1311 (void) fflush(connFile); 1302 1312 fprintf(connFile, _("%c%c.%c%c"), 13, 10, 13, 10); 1303 1313 (void) fflush(connFile); 1304 1305 TPT(( 0, FIL__, __LINE__, _("msg=<message end written>\n")));1306 1314 1307 1315 if (0 != sh_mail_wait(250, fd)) … … 1332 1340 * 1333 1341 */ 1342 extern int flag_err_debug; 1343 1344 static void report_smtp (char * reply) 1345 { 1346 char * tmp; 1347 1348 if (flag_err_debug == SL_TRUE) 1349 { 1350 tmp = sh_util_safe_name_keepspace(reply); 1351 1352 sh_error_handle (SH_ERR_ALL, FIL__, __LINE__, 0, MSG_E_SUBGEN, 1353 tmp, 1354 _("report_smtp") ); 1355 SH_FREE(tmp); 1356 } 1357 return; 1358 } 1359 1334 1360 1335 1361 static int sh_mail_wait(int code, int ma_socket) … … 1339 1365 char c; 1340 1366 1341 char errmsg[128]; 1367 char errmsg[194]; 1368 char reply[128]; 1369 unsigned int ireply = 0; 1342 1370 1343 1371 enum { … … 1357 1385 */ 1358 1386 1359 rcode = 0; 1360 state = WAIT_CODE_START; 1387 rcode = 0; 1388 state = WAIT_CODE_START; 1389 reply[0] = '\0'; 1361 1390 1362 1391 while (sl_read_timeout_fd (ma_socket, &c, 1, time_wait, SL_FALSE) > 0) { 1392 1393 if (ireply < (sizeof(reply) - 1)) 1394 { 1395 if (c != '\n' && c != '\r') 1396 { 1397 reply[ireply] = c; 1398 ++ireply; 1399 reply[ireply] = '\0'; 1400 } 1401 } 1363 1402 1364 1403 g = (int) c; … … 1379 1418 if (0 != isspace(g)) 1380 1419 break; /* Skip white space */ 1381 if (0 == isdigit(g)) 1382 return 0; /* No leading number */ 1420 if (0 == isdigit(g)) 1421 { 1422 report_smtp(reply); 1423 SL_RETURN( 0, _("mail_wait")); /* No leading number */ 1424 } 1383 1425 rcode = g-(int)'0'; /* convert to number */ 1384 1426 state = WAIT_CODE; … … 1411 1453 if (g != 1) 1412 1454 { 1455 char * tmp = sh_util_safe_name_keepspace(reply); 1413 1456 sl_snprintf(errmsg, sizeof(errmsg), 1414 _("Bad response (%d), expected %d"), rcode, code); 1457 _("Bad response (%s), expected %d"), tmp, code); 1458 SH_FREE(tmp); 1415 1459 1416 1460 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_NET, 1417 1461 errmsg, _("sh_mail_wait"), 1418 1462 _("mail"), _("SMTP server")); 1463 } 1464 else 1465 { 1466 report_smtp(reply); 1419 1467 } 1420 1468 waited_time = time(NULL) - waited_time; … … 1438 1486 1439 1487 TPT((0, FIL__, __LINE__, _("msg=<mail_wait: bad>\n"))); 1488 report_smtp(reply); 1440 1489 SL_RETURN( 0, _("mail_wait")); 1441 1490 … … 1446 1495 1447 1496 /* Failed, EOF or error on socket */ 1497 report_smtp(reply); 1448 1498 SL_RETURN( 0, _("mail_wait")); 1449 1499 } -
trunk/src/sh_nmail.c
r240 r272 65 65 struct alias * all_recipients = NULL; 66 66 67 int check_double (const char * str, struct alias * list) 67 /* Check if addr is in list. If list is all_recipients, 68 * must iterate over ->all_next instead of ->next 69 */ 70 static int check_double (const char * str, struct alias * list, int isAll) 68 71 { 69 72 if (str && list) … … 73 76 while (item) 74 77 { 78 fprintf(stderr, "FIXME check %s %s\n", str, sh_string_str(item->recipient)); 79 75 80 if (0 == strcmp(sh_string_str(item->recipient), str)) 76 81 return -1; 77 item = item->next; 82 if (isAll) 83 item = item->all_next; 84 else 85 item = item->next; 78 86 } 79 87 } … … 81 89 } 82 90 91 /* Add recipient to 'list' AND to all_recipients. If 92 * it already is in all_recipients, mark it as an alias 93 * (isAlias = 1). 94 */ 83 95 struct alias * add_recipient_intern(const char * str, 84 96 struct alias * list) … … 93 105 new->severity = (-1); 94 106 new->send_mail = 0; 107 new->isAlias = 0; 95 108 new->recipient = sh_string_new_from_lchar(str, strlen(str)); 96 109 list = new; 97 110 98 111 SH_MUTEX_LOCK_UNSAFE(mutex_listall); 112 fprintf(stderr, "FIXME intern %s\n", str); 113 if (0 == check_double(str, all_recipients, S_TRUE)) 114 { 115 new->isAlias = 1; 116 } 99 117 new->all_next = all_recipients; 100 118 all_recipients = new; 119 fprintf(stderr, "FIXME intern end\n"); 101 120 SH_MUTEX_UNLOCK_UNSAFE(mutex_listall); 102 121 } … … 116 135 } 117 136 118 /* Add a single recipient 137 /* Add a single recipient. Must not be in in 138 * recipient_list already, and not in all_recipients. 119 139 */ 120 140 int sh_nmail_add_recipient(const char * str) 121 141 { 122 if (0 == check_double(str, recipient_list)) 142 /* return error if duplicate, or 143 * already defined within an alias list. 144 */ 145 if (0 == check_double(str, recipient_list, S_FALSE) && 146 0 == check_double(str, all_recipients, S_TRUE)) 123 147 { 124 148 recipient_list = add_recipient_intern(str, recipient_list); … … 133 157 int sh_nmail_add_compiled_recipient(const char * str) 134 158 { 135 if (0 == check_double(str, compiled_recipient_list ))159 if (0 == check_double(str, compiled_recipient_list, S_FALSE)) 136 160 { 137 161 compiled_recipient_list = … … 164 188 if (strlen(new) > 0) 165 189 { 190 /* strip trailing space 191 */ 166 192 --q; while ((q != new) && *q == ' ') { *q = '\0'; --q; } 167 193 } … … 171 197 } 172 198 173 if (0 == check_double(new, alias_list)) 174 { 199 if (0 == check_double(new, alias_list, S_FALSE)) 200 { 201 202 fprintf(stderr, "FIXME LIST %s\n", p); 175 203 176 204 array = split_array_list(p, &nfields, lengths); 177 205 206 fprintf(stderr, "FIXME LIST %d\n", nfields); 207 178 208 if (array && nfields > 0) 179 209 { 180 struct alias * newalias = SH_ALLOC(sizeof(struct alias)); 181 newalias->recipient_list = NULL; 182 newalias->mail_filter = NULL; 183 newalias->mx_list = NULL; 184 newalias->severity = (-1); 185 /* This is the alias */ 186 newalias->recipient = sh_string_new_from_lchar(new, strlen(new)); 187 188 for (i = 0; i < nfields; ++i) 210 struct alias * newalias = NULL; 211 212 /* Enforce that all list members are defined already 213 */ 214 int nflag = 0; 215 216 for (i = 0; i < nfields; ++i) { 217 if (0 == check_double(array[i], all_recipients, S_TRUE)) 218 nflag = 1; 219 } 220 221 if (nflag == 0) 189 222 { 190 if (lengths[i] > 0 && 191 0 == check_double(array[i], newalias->recipient_list)) 223 newalias = SH_ALLOC(sizeof(struct alias)); 224 newalias->recipient_list = NULL; 225 newalias->mail_filter = NULL; 226 newalias->mx_list = NULL; 227 newalias->severity = (-1); 228 229 /* This is the alias */ 230 newalias->recipient = sh_string_new_from_lchar(new, strlen(new)); 231 232 for (i = 0; i < nfields; ++i) 192 233 { 193 newalias->recipient_list = 194 add_recipient_intern(array[i],newalias->recipient_list); 234 fprintf(stderr, "FIXME LIST(%d) %s\n", lengths[i], array[i]); 235 236 if (lengths[i] > 0 && 237 0 == check_double(array[i], newalias->recipient_list, S_FALSE)) 238 { 239 fprintf(stderr, "FIXME add %s\n", array[i]); 240 241 newalias->recipient_list = 242 add_recipient_intern(array[i], newalias->recipient_list); 243 } 195 244 } 196 245 } … … 198 247 SH_FREE(array); 199 248 200 if (newalias ->recipient_list == NULL)249 if (newalias && newalias->recipient_list == NULL) 201 250 { 202 251 SH_FREE(newalias); … … 304 353 } 305 354 355 if (alias) 356 { 357 fprintf(stderr, "FIXME %s, %s, %s\n", alias, 358 (rcv->mail_filter) ? "filtered" : "NULL", message); 359 } 360 306 361 return 1; 307 362 } … … 365 420 /* Mark the entry 366 421 */ 367 if (flagit)368 list->send_mail = 1;369 422 if (flag) 370 list = list->all_next; 423 { 424 /* Don't mark aliases 425 */ 426 if (flagit && list->isAlias == 0) 427 list->send_mail = 1; 428 list = list->all_next; 429 } 371 430 else 372 list = list->next; 431 { 432 if (flagit) 433 list->send_mail = 1; 434 list = list->next; 435 } 373 436 ++retval; 374 437 } … … 551 614 reset_list(fifo_mail); 552 615 553 /* Compiled recipients 616 fprintf(stderr, "FIXME Compiled\n"); 617 618 /* Compiled recipients. These share threshold and filter, 619 * hence only the first recipient needs to be tested. 554 620 */ 555 621 list = compiled_recipient_list; … … 558 624 { 559 625 msg = tag_list(fifo_mail, sh_string_str(list->recipient), 560 sh_nmail_valid_message_for_alias, list );626 sh_nmail_valid_message_for_alias, list, S_TRUE); 561 627 } 562 628 … … 585 651 } 586 652 653 fprintf(stderr, "FIXME Aliases\n"); 654 587 655 /* Aliases 588 656 */ 589 590 657 list = alias_list; 591 658 … … 601 668 { 602 669 msg = tag_list(fifo_mail, sh_string_str(list->recipient), 603 sh_nmail_valid_message_for_alias, list );670 sh_nmail_valid_message_for_alias, list, S_FALSE); 604 671 605 672 if (msg) … … 624 691 while (lnew) 625 692 { 693 fprintf(stderr, "FIXME %s\n", sh_string_str(lnew->recipient)); 626 694 lnew->send_mail = 1; 627 695 lnew= lnew->next; … … 659 727 660 728 729 fprintf(stderr, "FIXME Single\n"); 730 661 731 /* Single recipients 662 732 */ … … 673 743 { 674 744 msg = tag_list(fifo_mail, sh_string_str(list->recipient), 675 sh_nmail_valid_message_for_alias, list);745 sh_nmail_valid_message_for_alias, list, S_TRUE); 676 746 677 747 if (msg) -
trunk/src/sh_readconf.c
r265 r272 182 182 ++p; while (isspace((int)*p)) ++p; 183 183 184 if (0 != strnc mp(p, _("if "), 3)) {184 if (0 != strncasecmp(p, _("if "), 3)) { 185 185 cond_type = SH_RC_HOST; /* [!]$host */ 186 186 } … … 190 190 p += 3; while (isspace((int)*p)) ++p; /* skip the 'if\s+' */ 191 191 192 if (0 == strnc mp(p, _("not "), 4))192 if (0 == strncasecmp(p, _("not "), 4)) 193 193 { 194 194 p += 4; while (isspace((int)*p)) ++p; … … 201 201 } 202 202 203 if (0 == strnc mp(p, _("file_exists "), 12))203 if (0 == strncasecmp(p, _("file_exists "), 12)) 204 204 { 205 205 p += 12; cond_type = SH_RC_FILE; 206 206 } 207 else if (0 == strnc mp(p, _("interface_exists "), 17))207 else if (0 == strncasecmp(p, _("interface_exists "), 17)) 208 208 { 209 209 p += 17; cond_type = SH_RC_IFACE; 210 210 } 211 else if (0 == strnc mp(p, _("hostname_matches "), 17))211 else if (0 == strncasecmp(p, _("hostname_matches "), 17)) 212 212 { 213 213 p += 17; cond_type = SH_RC_HOST; 214 214 } 215 else if (0 == strnc mp(p, _("system_matches "), 15))215 else if (0 == strncasecmp(p, _("system_matches "), 15)) 216 216 { 217 217 p += 15; cond_type = SH_RC_SYSTEM; 218 218 } 219 else if (0 == strnc mp(p, _("command_succeeds "), 17))219 else if (0 == strncasecmp(p, _("command_succeeds "), 17)) 220 220 { 221 221 p += 17; cond_type = SH_RC_CMD; … … 289 289 ++p; while (isspace((int)*p)) ++p; 290 290 if ( 291 (0 == strnc mp (p, _("end"), 3) && (p[3] == '\0' || isspace((int)p[3]))) ||292 (0 == strnc mp (p, _("fi"), 2) && (p[2] == '\0' || isspace((int)p[2])))291 (0 == strncasecmp (p, _("end"), 3) && (p[3] == '\0' || isspace((int)p[3]))) || 292 (0 == strncasecmp (p, _("fi"), 2) && (p[2] == '\0' || isspace((int)p[2]))) 293 293 ) 294 294 { … … 307 307 char * p = str; 308 308 ++p; while (isspace((int)*p)) ++p; 309 if ( 0 == strnc mp (p, _("else"), 4) && (p[4] == '\0' || isspace((int)p[4])) )309 if ( 0 == strncasecmp (p, _("else"), 4) && (p[4] == '\0' || isspace((int)p[4])) ) 310 310 { 311 311 return 1; … … 586 586 read_mode = SH_SECTION_NONE; 587 587 588 if (0 == sl_strnc mp (line, _("[EOF]"), 5)) {588 if (0 == sl_strncasecmp (line, _("[EOF]"), 5)) { 589 589 goto nopel; 590 590 } … … 594 594 while (tab_ListSections[i].name != 0) 595 595 { 596 if (sl_strnc mp (line, _(tab_ListSections[i].name),597 596 if (sl_strncasecmp (line, _(tab_ListSections[i].name), 597 sl_strlen(tab_ListSections[i].name)) == 0) 598 598 { 599 599 read_mode = tab_ListSections[i].type; … … 608 608 for (modnum = 0; modList[modnum].name != NULL; ++modnum) 609 609 { 610 if (0 == sl_strnc mp (line,_(modList[modnum].conf_section),611 610 if (0 == sl_strncasecmp (line, _(modList[modnum].conf_section), 611 sl_strlen(modList[modnum].conf_section)) ) 612 612 read_mode = SH_SECTION_OTHER; 613 613 } … … 626 626 { 627 627 #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE) 628 if (line[0] == '!' && 0 == sl_strc mp(&(line[2]), _("SCHEDULE_TWO")))628 if (line[0] == '!' && 0 == sl_strcasecmp(&(line[2]), _("SCHEDULE_TWO"))) 629 629 set_dirList(1); 630 else if (0 == sl_strc mp(&(line[1]), _("SCHEDULE_TWO")))630 else if (0 == sl_strcasecmp(&(line[1]), _("SCHEDULE_TWO"))) 631 631 set_dirList(2); 632 632 #else -
trunk/src/sh_socket.c
r270 r272 209 209 static void sh_socket_add2list (struct socket_cmd * in); 210 210 211 void sh_socket_probe4reload (void)211 static void sh_socket_probe4reload (void) 212 212 { 213 213 struct reload_cmd * new; -
trunk/src/slib.c
r252 r272 1080 1080 if (a != NULL && b != NULL) 1081 1081 return (strncmp(a, b, n)); 1082 else if (a == NULL && b != NULL) 1083 return (-1); 1084 else if (a != NULL && b == NULL) 1085 return (1); 1086 else 1087 return (-7); /* default to not equal */ 1088 } 1089 1090 int sl_strncasecmp(const char * a, const char * b, size_t n) 1091 { 1092 #ifdef SL_FAIL_ON_ERROR 1093 SL_REQUIRE (a != NULL, _("a != NULL")); 1094 SL_REQUIRE (b != NULL, _("b != NULL")); 1095 SL_REQUIRE (n > 0, _("n > 0")); 1096 #endif 1097 1098 if (a != NULL && b != NULL) 1099 return (strncasecmp(a, b, n)); 1082 1100 else if (a == NULL && b != NULL) 1083 1101 return (-1);
Note:
See TracChangeset
for help on using the changeset viewer.