forked from poppyred/1.6.x
/
exec.maillog.php
executable file
·4218 lines (3541 loc) · 170 KB
/
exec.maillog.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
$GLOBALS["DEBUG_MEM"]=true;
$GLOBALS["DEBUG_MEM_FILE"]="{$GLOBALS["ARTICALOGDIR"]}/postfix-logger.debug";
if(!isset($GLOBALS["ARTICALOGDIR"])){$GLOBALS["ARTICALOGDIR"]=@file_get_contents("/etc/artica-postfix/settings/Daemons/ArticaLogDir"); if($GLOBALS["ARTICALOGDIR"]==null){ $GLOBALS["ARTICALOGDIR"]="/var/log/artica-postfix"; } }
events("Memory: START AT ".round(((memory_get_usage()/1024)/1000),2) ." line:".__LINE__);
include_once(dirname(__FILE__).'/ressources/class.ini.inc');
events("Memory: ".round(((memory_get_usage()/1024)/1000),2) ." after includes class.ini.inc line:".__LINE__);
include_once(dirname(__FILE__).'/ressources/class.os.system.inc');
events("Memory: ".round(((memory_get_usage()/1024)/1000),2) ." after includes class.os.system.inc line:".__LINE__);
include_once(dirname(__FILE__).'/framework/frame.class.inc');
events("Memory: ".round(((memory_get_usage()/1024)/1000),2) ." after includes frame.class.inc line: ".__LINE__);
include_once(dirname(__FILE__).'/framework/class.unix.inc');
events("Memory: ".round(((memory_get_usage()/1024)/1000),2) ." after includes class.unix.inc line: ".__LINE__);
include_once(dirname(__FILE__).'/framework/class.settings.inc');
events("Memory: ".round(((memory_get_usage()/1024)/1000),2) ." after includes class.settings.inc line: ".__LINE__);
include_once(dirname(__FILE__).'/ressources/class.sockets.inc');
events("Memory: ".round(((memory_get_usage()/1024)/1000),2) ." after includes class.sockets.inc line: ".__LINE__);
include_once(dirname(__FILE__).'/ressources/class.postfix.maillog.inc');
events("Memory: ".round(((memory_get_usage()/1024)/1000),2) ." after includes class.postfix.maillog.inc line: ".__LINE__);
include_once(dirname(__FILE__).'/ressources/class.amavis.maillog.inc');
events("Memory: ".round(((memory_get_usage()/1024)/1000),2) ." after includes class.amavis.maillog.inc line: ".__LINE__);
include_once(dirname(__FILE__).'/ressources/class.mysql.inc');
include_once(dirname(__FILE__).'/ressources/class.mysql.postfix.builder.inc');
events("Memory: ".round(((memory_get_usage()/1024)/1000),2) ." after includes class.amavis.maillog.inc line: ".__LINE__);
//Jun 29 14:53:54 ns214639 postfix-outbond-167-33.ultranavy.info/smtpd[23815]: warning: SASL authentication failure: cannot connect to saslauthd server: No such file or directory
@mkdir("{$GLOBALS["ARTICALOGDIR"]}/MGREYSTATS");
$set=new settings_inc();
$GLOBALS["CLASS_SETTINGS"]=$set;
events("Memory: FINISH ".round(((memory_get_usage()/1024)/1000),2) ." after includes line: ".__LINE__);
if(posix_getuid()<>0){die("Cannot be used in web server mode\n\n");}
$GLOBALS["COMMANDLINE"]=implode(" ",$argv);
if(strpos($GLOBALS["COMMANDLINE"],"--verbose")>0){$GLOBALS["VERBOSE"]=true;$GLOBALS["debug"]=true;$GLOBALS["DEBUG"]=true;ini_set('html_errors',0);ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);}
if($argv[1]=='--amavis-port'){postfix_is_amavis_port($argv[2]);die();}
$unix=new unix();
$pidfile="/etc/artica-postfix/".basename(__FILE__).".pid";
$pid=@file_get_contents($pidfile);
if($unix->process_exists($pid)){writelogs("Already running pid $pid, Aborting");die();}
$pid=getmypid();
events("running $pid ");
file_put_contents($pidfile,$pid);
events("Memory: ".round(((memory_get_usage()/1024)/1000),2) ." after unix() declaration line: ".__LINE__);
$sock=new sockets();
$GLOBALS["CLASS_SOCKETS"]=$sock;
$GlobalIptablesEnabled=$sock->GET_INFO("GlobalIptablesEnabled");
if(!is_numeric($GlobalIptablesEnabled)){$GlobalIptablesEnabled=1;}
events("Memory: ".round(((memory_get_usage()/1024)/1000),2) ." after sockets() declaration line: ".__LINE__);
$users=new settings_inc();
events("Memory: ".round(((memory_get_usage()/1024)/1000),2) ." after usersMenus() declaration line: ".__LINE__);
$_GET["server"]=$users->hostname;
$GLOBALS["MYHOSTNAME"]=$users->hostname;
$_GET["IMAP_HACK"]=array();
$GLOBALS["ZARAFA_INSTALLED"]=$users->ZARAFA_INSTALLED;
$GLOBALS["AMAVIS_INSTALLED"]=$users->AMAVIS_INSTALLED;
$GLOBALS["CLASS_POSTFIX_SQL"]=new mysql_postfix_builder();
$GLOBALS["POP_HACK"]=array();
$GLOBALS["SMTP_HACK"]=array();
$GLOBALS["PHP5_BIN"]=LOCATE_PHP5_BIN2();
$GLOBALS["LN_BIN"]=$unix->find_program("ln");
$GLOBALS["POSTFIX_BIN"]=$unix->find_program("postfix");
$GLOBALS["iptables"]=$unix->find_program("iptables");
$GLOBALS["EnablePostfixAutoBlock"]=trim($sock->GET_INFO("EnablePostfixAutoBlock"));
if(!is_numeric($GLOBALS["EnablePostfixAutoBlock"])){$GLOBALS["EnablePostfixAutoBlock"]=1;}
$GLOBALS["PostfixNotifyMessagesRestrictions"]=$sock->GET_INFO("PostfixNotifyMessagesRestrictions");
$GLOBALS["GlobalIptablesEnabled"]=$GlobalIptablesEnabled;
$GLOBALS["PopHackEnabled"]=$sock->GET_INFO("PopHackEnabled");
$GLOBALS["PopHackCount"]=$sock->GET_INFO("PopHackCount");
$GLOBALS["DisableMailBoxesHack"]=$sock->GET_INFO("DisableMailBoxesHack");
$GLOBALS["EnableArticaSMTPStatistics"]=$sock->GET_INFO("EnableArticaSMTPStatistics");
$GLOBALS["ActAsASyslogSMTPClient"]=$sock->GET_INFO("ActAsASyslogSMTPClient");
$GLOBALS["EnableStopPostfix"]=$sock->GET_INFO("EnableStopPostfix");
$GLOBALS["EnableAmavisDaemon"]=$sock->GET_INFO("EnableAmavisDaemon");
if(!is_numeric($GLOBALS["EnableStopPostfix"])){$GLOBALS["EnableStopPostfix"]=0;}
if(!is_numeric($GLOBALS["EnableArticaSMTPStatistics"])){$GLOBALS["EnableArticaSMTPStatistics"]=1;}
if(!is_numeric($GLOBALS["ActAsASyslogSMTPClient"])){$GLOBALS["ActAsASyslogSMTPClient"]=0;}
if(!is_numeric($GLOBALS["EnableAmavisDaemon"])){$GLOBALS["EnableAmavisDaemon"]=0;}
if(!is_numeric($GLOBALS["DisableMailBoxesHack"])){$GLOBALS["DisableMailBoxesHack"]=0;}
if($GLOBALS["PopHackEnabled"]==null){$GLOBALS["PopHackEnabled"]=1;}
if($GLOBALS["PopHackCount"]==null){$GLOBALS["PopHackCount"]=10;}
$GLOBALS["MYPATH"]=dirname(__FILE__);
$GLOBALS["SIEVEC_PATH"]=$unix->LOCATE_SIEVEC();
$GLOBALS["SMTP_HACK_CONFIG_RATE"]["NAME_SERVICE_NOT_KNOWN"]=10;
$GLOBALS["SMTP_HACK_CONFIG_RATE"]["SASL_LOGIN"]=15;
$GLOBALS["SMTP_HACK_CONFIG_RATE"]["RBL"]=5;
$GLOBALS["SMTP_HACK_CONFIG_RATE"]["USER_UNKNOWN"]=10;
$GLOBALS["SMTP_HACK_CONFIG_RATE"]["BLOCKED_SPAM"]=5;
$GLOBALS["SMTP_HACK_CONFIG_RATE"]["SMTPHACK_TIMEOUT"]=10;
$GLOBALS["SMTP_HACK_CONFIG_RATE"]["SMTPHACK_RESOLUTION_FAILURE"]=2;
$GLOBALS["SMTP_HACK_CONFIG_RATE"]["SMTPHACK_TOO_MANY_ERRORS"]=10;
smtp_hack_reconfigure();
$GLOBALS["CLASS_UNIX"]=$unix;
$GLOBALS["postfix_bin_path"]=$unix->find_program("postfix");
$GLOBALS["postconf_bin_path"]=$unix->find_program("postconf");
$GLOBALS["CHOWN"]=$unix->find_program("chown");
$GLOBALS["GROUPADD"]=$unix->find_program("groupadd");
$GLOBALS["CHMOD"]=$unix->find_program("chmod");
$GLOBALS["fuser"]=$unix->find_program("fuser");
$GLOBALS["kill"]=$unix->find_program("kill");
$GLOBALS["NOHUP_PATH"]=$unix->find_program("nohup");
$GLOBALS["NETSTAT_PATH"]=$unix->find_program("netstat");
$GLOBALS["TOUCH_PATH"]=$unix->find_program("touch");
$GLOBALS["POSTMAP_PATH"]=$unix->find_program("postmap");
$GLOBALS["maillog_tools"]=new maillog_tools();
@mkdir("{$GLOBALS["ARTICALOGDIR"]}/smtp-connections",0755,true);
@mkdir("/etc/artica-postfix/cron.1",0755,true);
@mkdir("/etc/artica-postfix/cron.2",0755,true);
$users=null;
$sock=null;
$unix=null;
events("Memory: ".round(((memory_get_usage()/1024)/1000),2) ." after all declarations ".__LINE__);
$pipe = fopen("php://stdin", "r");
while(!feof($pipe)){
$buffer=fgets($pipe, 4096);
Parseline($buffer);
$buffer=null;
}
fclose($pipe);
events("Shutdown...");
die();
function Parseline($buffer){
if(is_file("/etc/artica-postfix/DO_NOT_DETECT_POSTFIX")){return;}
$buffer=trim($buffer);
if($buffer==null){return null;}
if(is_file("{$GLOBALS["ARTICALOGDIR"]}/smtp-hack-reconfigure")){smtp_hack_reconfigure();}
if(strpos($buffer,"]: fatal: Usage:postmulti")>0){return;}
if(strpos($buffer,"Do you need to run 'sa-update'?")>0){amavis_sa_update($buffer);return;}
if(strpos($buffer,"Passed CLEAN {AcceptedOpenRelay}")>0){return;}
if(strpos($buffer,"Passed BAD-HEADER-1 {RelayedInternal}")>0){return;}
if(strpos($buffer,"Valid PID file (")>0){return;}
if(strpos($buffer,"]: SA dbg:")>0){return;}
if(strpos($buffer,") SA dbg:")>0){return;}
if(strpos($buffer,"enabling PIX workarounds: disable_esmtp delay_dotcrlf")>0){return;}
if(strpos($buffer,"]: child: exiting: idle for")>0){return;}
if(strpos($buffer,"]: master: child")>0){return;}
if(strpos($buffer,") 2822.From: <")>0){return;}
if(strpos($buffer,") Connecting to LDAP server")>0){return;}
if(strpos($buffer,") connect_to_ldap: connected")>0){return;}
if(strpos($buffer,") connect_to_ldap: bind")>0){return;}
if(strpos($buffer,") Passed CLEAN, AM.PDP-SOCK [")>0){return;}
if(strpos($buffer,"mode select: signing")>0){return;}
if(strpos($buffer,"Starting worker process for POP3 request")>0){return;}
if(strpos($buffer,": Accepted connection from")>0){return;}
if(strpos($buffer,"]: Not authorized for command:")>0){return;}
if(strpos($buffer,"milter-greylist: GeoIP failed to lookup ip")>0){return;}
if(strpos($buffer,": Number of messages in the queue")>0){return;}
if(strpos($buffer,") inspect_dsn: is a DSN")>0){return;}
if(strpos($buffer,": decided action=DUNNO NULL")>0){return;}
if(strpos($buffer,"Mail::SpamAssassin::Plugin::Check")>0){return;}
if(strpos($buffer,"vnStat daemon")>0){return;}
if(strpos($buffer,"aliases.db: duplicate entry")>0){return;}
if(strpos($buffer,"DKIM-Signature\" header added")>0){return;}
if(strpos($buffer,": decided action=PREPEND X-policyd-weight: using cached result;")>0){return;}
if(strpos($buffer," mode select: verifying")>0){return;}
//if(strpos($buffer,") SPAM-TAG, <")>0){return;}
if(strpos($buffer,") mail checking ended: version_server=")>0){return;}
if(strpos($buffer,") check_header:")>0){return;}
if(strpos($buffer,") dkim: FAILED Author")>0){return;}
if(strpos($buffer,") dkim: VALID Sender signature")>0){return;}
if(strpos($buffer,") collect banned table")>0){return;}
if(strpos($buffer,") p.path")>0){return;}
if(strpos($buffer,") ask_av Using (ClamAV-clamd): CONTSCAN")>0){return;}
if(strpos($buffer,") ClamAV-clamd: Connecting to socket")>0){return;}
if(strpos($buffer,") ClamAV-clamd: Sending CONTSCAN")>0){return;}
if(strpos($buffer,") inspect_dsn:")>0){return;}
if(strpos($buffer,"IO::Socket::INET")>0){return;}
if(strpos($buffer,") smtp resp to greeting:")>0){return;}
if(strpos($buffer,") smtp cmd> EHLO")>0){return;}
if(strpos($buffer,") smtp resp to EHLO:")>0){return;}
if(strpos($buffer,") smtp resp to RCPT (")>0){return;}
if(strpos($buffer,"greylist: mi_stop=1")>0){return;}
if(strpos($buffer,"smfi_main() returned 0")>0){return;}
if(strpos($buffer,"Final database dump")>0){return;}
if(strpos($buffer,"refreshing the Postfix")>0){return;}
if(strpos($buffer,"class.auth.tail.inc")>0){return;}
if(strpos($buffer,"authenticated, bypassing greylisting")>0){return;}
if(strpos($buffer,"NEW message_id")>0){return;}
if(strpos($buffer,"Passed CLEAN {")>0){return;}
if(strpos($buffer,") Blocked SPAM {")>0){return;}
if(strpos($buffer,") Blocked SPAMMY {")>0){return;}
if(strpos($buffer,"does not resolve to address")>0){return;}
// ************************ DKIM DUTSBIN
if(strpos($buffer,"no signing domain match for")>0){return;}
if(strpos($buffer,"no signing subdomain match for")>0){return;}
if(strpos($buffer,"no signing keylist match for")>0){return;}
if(strpos($buffer,": no signature data")>0){return;}
if(strpos($buffer," not internal")>0){return;}
if(strpos($buffer," not authenticated")>0){return;}
// ************************ ZARAFA DUTSBIN
if(strpos($buffer,"]: Still waiting for 1 threads to exit")>0){return;}
if(preg_match("#zarafa-dagent\[.*?Delivered message to#",$buffer)){return;}
if(strpos($buffer,": Disconnecting client.")>0){return;}
if(strpos($buffer,"thread exiting")>0){return;}
if(strpos($buffer,"Started to create store")>0){return;}
//if(strpos($buffer,") p00")>0){return;}
//if(strpos($buffer,") TIMING [total")>0){return;}
//if(strpos($buffer,") TIMING-SA total")>0){return;}
if(strpos($buffer,"mailarchiver[")>0){return;}
if(strpos($buffer,") policy protocol:")>0){return;}
if(strpos($buffer,"]: policy protocol:")>0){return;}
if(strpos($buffer,") run_av (ClamAV-clamd)")>0){return;}
if(strpos($buffer,"Net::Server: Process Backgrounded")>0){return;}
if(strpos($buffer,"Net::Server:")>0){return;}
if(strpos($buffer,": No ext program for")>0){return;}
if(strpos($buffer,": SA info: zoom: able to use")>0){return;}
if(strpos($buffer,": warm restart on HUP [")>0){return;}
if(strpos($buffer,": starting. (warm)")>0){return;}
if(strpos($buffer,"user=postfix, EUID:")>0){return;}
if(strpos($buffer,"No \$altermime,")>0){return;}
if(strpos($buffer,"starting. /usr/local/sbin/amavisd")>0){return;}
if(strpos($buffer,"initializing Mail::SpamAssassin")>0){return;}
if(strpos($buffer,"Net::Server: Binding to UNIX socket file")>0){return;}
if(strpos($buffer,"SpamControl: init_pre_chroot on SpamAssassin done")>0){return;}
if(strpos($buffer,"Starting worker for LMTP request")>0){return;}
if(strpos($buffer,"LMTP thread exiting")>0){return;}
if(strpos($buffer,") truncating a message passed to SA at")>0){return;}
if(strpos($buffer,"loaded policy bank")>0){return;}
if(strpos($buffer,"process_request: fileno sock")>0){return;}
if(strpos($buffer,"AM.PDP /var/amavis/")>0){return;}
if(strpos($buffer,"KASWARNING [NOLOGID]: mfhelo: HELO already set")>0){return;}
if(strpos($buffer,"Passed CLEAN {AcceptedInbound}")>0){return;}
if(strpos($buffer,"Blocked MTA-BLOCKED {TempFailedOutbound}")>0){return;}
if(strpos($buffer,") body hash: ")>0){return;}
//if(strpos($buffer,") spam_scan: score=")>0){return;}
if(strpos($buffer,") Cached virus check expired")>0){return;}
if(strpos($buffer,") blocking contents category is")>0){return;}
if(strpos($buffer,") do_notify_and_quar: ccat=")>0){return;}
if(strpos($buffer,") inspect_dsn: not a bounce")>0){return;}
if(strpos($buffer,") local delivery:")>0){return;}
if(strpos($buffer,") DSN: NOTIFICATION: ")>0){return;}
if(strpos($buffer,") SEND via PIPE:")>0){return;}
if(strpos($buffer,") Checking for banned types and")>0){return;}
if(strpos($buffer,"skipping mailbox user")>0){return;}
if(strpos($buffer,"artica-plugin:")>0){return;}
if(strpos($buffer,"success delivered trough 192.168.1.228:33559")>0){return;}
if(strpos($buffer,"skiplist: checkpointed /var/lib/cyrus/user")>0){return;}
if(strpos($buffer,"starttls: TLSv1 with cipher AES256-SHA (256/256 bits new)")>0){return;}
if(strpos($buffer,"lost connection after CONNECT from unknown")>0){return null;}
if(strpos($buffer,"lost connection after DATA from unknown")>0){return null;}
if(strpos($buffer,"lost connection after RCPT")>0){return null;}
if(strpos($buffer,"created decompress buffer of")>0){return null;}
if(strpos($buffer,"created compress buffer of")>0){return null;}
if(strpos($buffer,"SQUAT returned")>0){return null;}
if(strpos($buffer,": lmtp connection preauth")>0){return null;}
if(strpos($buffer,"indexing mailbox user")>0){return null;}
if(strpos($buffer,"mystore: starting txn")>0){return null;}
if(strpos($buffer,"duplicate_mark:")>0){return null;}
if(strpos($buffer,"mystore: committing txn")>0){return null;}
if(strpos($buffer,"cyrus/tls_prune")>0){return null;}
if(strpos($buffer,"milter-greylist: reloading config file")>0){return null;}
if(strpos($buffer,"milter-greylist: reloaded config file")>0){return null;}
if(strpos($buffer,"skiplist: recovered")>0){return null;}
if(strpos($buffer,"milter-reject NOQUEUE < 451 4.7.1 Greylisting in action, please come back in")>0){return null;}
if(strpos($buffer,"extra modules loaded after daemonizing/chrooting")>0){return null;}
if(strpos($buffer,"exec: /usr/bin/php5")>0){return;}
if(strpos($buffer,"rec_get: type N")>0){return;}
if(strpos($buffer,"Found decoder for ")>0){return;}
if(strpos($buffer,"Internal decoder for ")>0){return;}
if(strpos($buffer,"indexing mailboxes")>0){return;}
if(strpos($buffer,"decided action=DUNNO multirecipient-mail - already accepted by previous query")>0){return;}
if(strpos($buffer,"decided action=PREPEND X-policyd-weight: passed - too many local DNS-errors")>0){return;}
if(strpos($buffer,"DSN: FILTER 554 Spam, spam level")>0){return;}
if(strpos($buffer,"emailrelay: info: no more messages to send")>0){return;}
if(strpos($buffer,"spamd: connection from ip6-localhost")>0){return;}
if(strpos($buffer,"spamd: processing message")>0){return;}
if(strpos($buffer,"spamd: clean message")>0){return;}
if(strpos($buffer,"spamd: result:")>0){return;}
if(strpos($buffer,"prefork: child states: I")>0){return;}
if(strpos($buffer,"autowhitelisted for another")>0){return;}
//if(strpos($buffer,"spamd: identified spam")>0){return;}
if(strpos($buffer,"spamd: handled cleanup of child pid")>0){return;}
if(strpos($buffer,"open_on_specific_fd")>0){return;}
if(strpos($buffer,"rundown_child on")>0){return;}
if(strpos($buffer,"switch_to_my_time")>0){return;}
if(strpos($buffer,"%, total idle")>0){return;}
if(strpos($buffer,"exec.mailarchive.php[")>0){return;}
if(strpos($buffer,"do_notify_and_quarantine: spam level exceeds")>0){return;}
if(strpos($buffer,", DEAR_SOMETHING=")>0){return;}
if(strpos($buffer,", DIGEST_MULTIPLE=")>0){return;}
if(strpos($buffer,", BAD_ENC_HEADER=")>0){return;}
if(strpos($buffer,"dkim: VALID")>0){return;}
if(strpos($buffer,"SA info: pyzor:")>0){return;}
if(strpos($buffer,"DSN: sender is credible")>0){return;}
if(strpos($buffer,"mail_via_pipe")>0){return;}
if(strpos($buffer,") ...continue")>0){return;}
if(strpos($buffer,"Cached spam check expired")>0){return;}
if(strpos($buffer,") cached")>0){return;}
if(strpos($buffer,"extra modules loaded:")>0){return;}
if(strpos($buffer,"Use of uninitialized value")>0){return;}
if(strpos($buffer,"DecodeShortURLs")>0){return;}
if(strpos($buffer,"FWD via SMTP: <")>0){return;}
if(strpos($buffer,"DKIM-Signature header added")>0){return;}
if(strpos($buffer,"Passed CLEAN, MYNETS LOCAL")>0){return;}
if(strpos($buffer,") Passed CLEAN, [")>0){return;}
if(strpos($buffer,") Passed BAD-HEADER, [")>0){return;}
if(strpos($buffer,") Checking: ")>0){return;}
if(strpos($buffer,") WARN: MIME::Parser error: unexpected end of header")>0){return;}
if(strpos($buffer,") Open relay? Nonlocal recips but not originating")>0){return;}
if(strpos($buffer,": not authenticated")>0){return;}
if(strpos($buffer,": dk_eom() returned status")>0){return;}
if(strpos($buffer,"ASN1_D2I_READ_BIO:not enough data")>0){return;}
if(strpos($buffer,"SpamControl: init_pre_fork on SpamAssassin done")>0){return;}
if(strpos($buffer,": Selected group:")>0){return;}
if(strpos($buffer,"Message entity scanning: message CLEAN")>0){return;}
if(strpos($buffer,"New connection on thread")>0){return;}
//if(strpos($buffer,"AM.PDP-SOCK/MYNETS")>0){return;}
if(strpos($buffer,": disconnect from")>0){return;}
if(strpos($buffer,"sfupdates: KASINFO")>0){return;}
if(strpos($buffer,": lost connection after CONNECT")>0){return;}
if(strpos($buffer,"enabling PIX workarounds: disable_esmtp delay_dotcrlf")>0){return;}
if(strpos($buffer,"Message Aborted!")>0){return;}
if(strpos($buffer,"WHITELISTED [")>0){return;}
if(strpos($buffer,"COMMAND PIPELINING from")>0){return;}
if(strpos($buffer,"COMMAND COUNT LIMIT from [")>0){return;}
if(strpos($buffer,"]: warning: psc_cache_update:")>0){return;}
if(strpos($buffer,"]: PREGREET")>0){return;}
if(strpos($buffer,": PASS OLD [")>0){return;}
if(strpos($buffer,"]: DNSBL rank")>0){return;}
if(strpos($buffer,"]: HANGUP after")>0){return;}
if(strpos($buffer,": DISCONNECT [")>0){return;}
if(strpos($buffer,"KASNOTICE")>0){return;}
if(strpos($buffer,"KASINFO")>0){return;}
if(strpos($buffer,"]: PASS NEW [")>0){return;}
if(strpos($buffer,"]: COMMAND TIME LIMIT from")>0){return;}
if(strpos($buffer,"Client host triggers FILTER")>0){return;}
if(strpos($buffer,"Starting worker process for IMAP request")>0){return;}
if(strpos($buffer,"IMAP thread exiting")>0){return;}
if(strpos($buffer,"]: seen_db: user ")>0){return;}
if(strpos($buffer,"Client disconnected")>0){return;}
if(strpos($buffer,"starting the Postfix mail system")>0){return;}
if(strpos($buffer,"Postfix mail system is already running")>0){return;}
if(strpos($buffer,": Perl version")>0){return;}
if(strpos($buffer,": No decoder for")>0){return;}
if(strpos($buffer,"Using primary internal av scanner")>0){return;}
if(strpos($buffer,"starting. /usr/local/sbin/amavisd")>0){return;}
if(strpos($buffer,") smtp resp to data-dot (")>0){return;}
if(strpos($buffer,") TIMING-SA total")>0){return;}
if(strpos($buffer,") sending SMTP response:")>0){return;}
if(strpos($buffer,") TIMING [total")>0){return;}
if(strpos($buffer,") Amavis::")>0){return;}
if(strpos($buffer,"] run_as_subprocess: child done")>0){return;}
if(strpos($buffer,"]: vstream_buf_get_ready:")>0){return;}
if(strpos($buffer,"]: > 127.0.0.1[")>0){return;}
if(strpos($buffer,"]: Using secondary internal")>0){return;}
if(strpos($buffer,"]: rec_get:")>0){return;}
if(strpos($buffer,") p004 1")>0){return;}
if(strpos($buffer,") p001 1")>0){return;}
if(strpos($buffer,") p002 1")>0){return;}
if(strpos($buffer,") p003 1")>0){return;}
if(strpos($buffer,") SPAM-TAG,")>0){return;}
if(strpos($buffer,"]: send attr")>0){return;}
if(strpos($buffer,") (!)FWD from <")>0){return;}
if(strpos($buffer,") bounce rescued by:")>0){return;}
if(strpos($buffer,") smtp session: setting")>0){return;}
if(strpos($buffer,") smtp cmd> MAIL FROM:")>0){return;}
if(strpos($buffer,") smtp cmd> RCPT TO:")>0){return;}
if(strpos($buffer,") smtp connection cache")>0){return;}
if(strpos($buffer,") spam_scan: score=")>0){return;}
if(strpos($buffer,") smtp session reuse,")>0){return;}
if(strpos($buffer,") smtp cmd> NOOP")>0){return;}
if(strpos($buffer,") smtp resp to NOOP")>0){return;}
if(strpos($buffer,") smtp cmd> DATA")>0){return;}
if(strpos($buffer,") smtp resp to MAIL")>0){return;}
if(strpos($buffer,") smtp resp to DATA:")>0){return;}
if(strpos($buffer,") smtp cmd> QUIT")>0){return;}
if(strpos($buffer,") smtp session most")>0){return;}
if(strpos($buffer,") smtp resp to RCPT")>0){return;}
if(strpos($buffer,") inspect_dsn:")>0){return;}
if(strpos($buffer,"IO::Socket::INET")>0){return;}
if(strpos($buffer,") smtp resp to greeting")>0){return;}
if(strpos($buffer,") smtp cmd> EHLO")>0){return;}
if(strpos($buffer,") smtp resp to EHLO:")>0){return;}
if(strpos($buffer,") smtp resp to RCPT (")>0){return;}
if(strpos($buffer,"exiting on SIGTERM/SIGINT")>0){return;}
if(strpos($buffer,": ready for work")>0){return;}
if(strpos($buffer,": process started")>0){return;}
if(strpos($buffer,"]: entered child_init_hook")>0){return;}
if(strpos($buffer,"]: SpamControl: init_child on SpamAssassin done")>0){return;}
if(preg_match("#kavmilter\[.+?\[tid.+?New message from:#",$buffer,$re)){return null;}
if(preg_match("#assp\[.+?LDAP Results#",$buffer,$re)){return null;}
if(preg_match("#smtpd\[.+?\]: disconnect from#",$buffer,$re)){return null;}
if(preg_match("#smtpd\[.+?\]: timeout after END-OF-MESSAGE#",$buffer,$re)){return null;}
if(preg_match("#smtpd\[.+?\]:.+?enabling PIX workarounds#",$buffer,$re)){return null;}
if(preg_match("#milter-greylist:.+?skipping greylist#",$buffer,$re)){return null;}
if(preg_match("#milter-greylist:\s+\(.+?greylisted entry timed out#",$buffer,$re)){return null;}
if(preg_match("#postfix\/qmgr\[.+?\]:\s+.+?: removed#",$buffer,$re)){return null;}
if(preg_match("#postfix\/smtpd\[.+?\]:\s+lost connection after#",$buffer,$re)){return null;}
if(preg_match("#assp.+?\[MessageOK\]#",$buffer,$re)){return null;}
if(preg_match("#assp.+?\[NoProcessing\]#",$buffer,$re)){return null;}
if(preg_match("#passed trough amavis and event is saved#",$buffer,$re)){return null;}
if(preg_match("#assp.+?AdminUpdate#",$buffer,$re)){return null;}
if(preg_match("#last message repeated.+?times#",$buffer,$re)){return null;}
if(preg_match("#cyrus\/master.+?about to exec#",$buffer,$re)){return null;}
if(preg_match("#cyrus\/.+?open: user#",$buffer,$re)){return null;}
if(preg_match("#cyrus\/lmtpunix.+?accepted connection#",$buffer,$re)){return null;}
if(preg_match("#cyrus\/lmtpunix.+?Delivered:#",$buffer,$re)){return null;}
if(preg_match("#cyrus\/master.+?process.+?exited#",$buffer,$re)){return null;}
if(preg_match("#lmtpunix.+?mystore: starting txn#",$buffer,$re)){return null;}
if(preg_match("#lmtpunix.+?duplicate_mark#",$buffer,$re)){return null;}
if(preg_match("#lmtpunix.+?mystore: committing txn#",$buffer,$re)){return null;}
if(preg_match("#ctl_cyrusdb.+?archiving#",$buffer,$re)){return null;}
if(preg_match("#assp.+?LDAP - found.+?in LDAPlist;#",$buffer,$re)){return null;}
if(preg_match("#anvil.+?statistics: max#",$buffer,$re)){return null;}
if(preg_match("#smfi_getsymval failed for#",$buffer)){return null;}
if(preg_match("#cyrus\/imap\[.+?Expunged\s+[0-9]+\s+message.+?from#",$buffer)){return null;}
if(preg_match("#cyrus\/imap\[.+?seen_db:\s+#",$buffer)){return null;}
if(preg_match("#cyrus\/[pop3|imap]\[.+?SSL_accept\(#",$buffer)){return null;}
if(preg_match("#cyrus\/[pop3|imap]\[.+?starttls:#",$buffer)){return null;}
if(preg_match("#cyrus\/[pop3|imap]\[.+?:\s+inflate#",$buffer)){return null;}
if(preg_match("#cyrus\/imap.*?fetching\s+user_.+? entry for '#",$buffer)){return null;}
if(preg_match("#cyrus\/.+?\[.+?:\s+accepted connection$#",$buffer)){return null;}
if(preg_match("#cyrus\/.+?\[.+?:\s+deflate\(#",$buffer)){return null;}
if(preg_match("#cyrus\/.+?\[.+?:\s+\=>\s+compressed to#",$buffer)){return null;}
if(preg_match("#filter-module\[.+?:\s+KASINFO#",$buffer)){return null;}
if(preg_match("#exec\.mailbackup\.php#",$buffer)){return null;}
if(preg_match("#kavmilter\[.+?\]:\s+Loading#",$buffer)){return null;}
if(preg_match("#DBERROR: init.+?on berkeley#",$buffer)){return null;}
if(preg_match("#FATAL: lmtpd: unable to init duplicate delivery database#",$buffer)){return null;}
if(preg_match("#skiplist: checkpointed.+?annotations\.db#",$buffer)){return null;}
if(preg_match("#duplicate_prune#",$buffer)){return null;}
if(preg_match("#cyrus\/cyr_expire\[[0-9]+#",$buffer)){return null;}
if(preg_match("#cyrus\/imap.+?SSL_accept#",$buffer)){return null;}
if(preg_match("#cyrus\/pop3.+?SSL_accept#",$buffer)){return null;}
if(preg_match("#cyrus\/imap.+?:\s+executed#",$buffer)){return null;}
if(preg_match("#cyrus\/ctl_cyrusdb.+?recovering cyrus databases#",$buffer)){return null;}
if(preg_match("#cyrus.+?executed#",$buffer)){return null;}
if(preg_match("#postfix\/.+?refreshing the Postfix mail system#",$buffer)){return null;}
if(preg_match("#master.+?reload -- version#",$buffer)){return null;}
if(preg_match("#SQUAT failed#",$buffer)){return null;}
if(preg_match("#lmtpunix.+?sieve\s+runtime\s+error\s+for#",$buffer)){return null;}
if(preg_match("#imapd:Loading hard-coded DH parameters#",$buffer)){return null;}
if(preg_match("#ctl_cyrusdb.+?checkpointing cyrus databases#",$buffer)){return null;}
if(preg_match("#idle for too long, closing connection#",$buffer)){return null;}
if(preg_match("#amavis\[.+?Found#",$buffer)){return null;}
if(preg_match("#amavis\[.+?Module\s+#",$buffer)){return null;}
if(preg_match("#amavis\[.+?\s+loaded$#",trim($buffer))){return null;}
if(preg_match("#amavis\[.+?\s+Internal decoder#",trim($buffer))){return null;}
if(preg_match("#amavis\[.+?\s+Creating db#",trim($buffer))){return null;}
if(preg_match("#smtpd\[.+? warning:.+?address not listed for hostname#",$buffer)){return null;}
if(preg_match("#zarafa-dagent\[.+?Delivered message to#",$buffer)){return null;}
if(preg_match("#postfix\/policyd-weight\[.+?SPAM#",$buffer)){return null;}
if(preg_match("#postfix\/policyd-weight\[.+?decided action=550#",$buffer)){return null;}
if(preg_match("#qmgr\[.+?: removed#",$buffer)){return null;}
if(preg_match("#cyrus\/lmtp\[.+?Delivered#",$buffer)){return null;}
if(preg_match("#ESMTP::.+?\/var\/amavis\/tmp\/amavis#",$buffer)){return null;}
if(preg_match("#zarafa-dagent.+?Client disconnected#",$buffer)){return null;}
if(preg_match("#zarafa-dagent.+?Failed to resolve recipient#",$buffer)){return null;}
if(strpos($buffer, "MGREYSTATS")>0){$md5=md5($buffer);@file_put_contents("{$GLOBALS["ARTICALOGDIR"]}/MGREYSTATS/$md5", $buffer);return;}
if(stripos($buffer,"opendkim")>0){
include_once(dirname(__FILE__).'/ressources/class.opendkim.maillog.inc');
if(parse_opendkim($buffer)){return;}
}
// ---------------------------------------------------------------------------------------------------------------
if(preg_match("#unknown group name:\s+postdrop#i", $buffer,$re)){
shell_exec("{$GLOBALS["GROUPADD"]} postdrop >/dev/null 2>&1");
return;
}
// ---------------------------------------------------------------------------------------------------------------
if(preg_match("#warning: SASL authentication problem: unable to open Berkeley db \/etc\/sasldb2: Permission denied#", $buffer,$re)){
$file="/etc/artica-postfix/pids/SASL.authentication.problem.".__LINE__.".time";
$timefile=file_time_min($file);
if($timefile>3){
@file_put_contents("/etc/artica-postfix/settings/Daemons/smtpd_sasl_path", "smtpd");
shell_exec("{$GLOBALS["postconf_bin_path"]} -e \"smtpd_sasl_path=smtpd\"");
shell_exec("{$GLOBALS["NOHUP_PATH"]} /etc/init.d/postfix reload >/dev/null 2>&1 &");
@unlink($file);
@file_put_contents($file, time());
return;
}
}
if(preg_match("#smtpd.*?warning: No server certs available. TLS won't be enabled#", $buffer,$re)){
$file="/etc/artica-postfix/pids/postfix.No.server.certs.available.".__LINE__.".time";
$timefile=file_time_min($file);
if($timefile>3){
}
}
// ---------------------------------------------------------------------------------------------------------------
if(preg_match("#fatal: scan_dir_push: open directory .*?: Permission denied#", $buffer,$re)){
shell_exec("{$GLOBALS["POSTFIX_BIN"]} set-permissions");
shell_exec("{$GLOBALS["NOHUP_PATH"]} /etc/init.d/postfix restart >/dev/null 2>&1 &");
return;
}
// ---------------------------------------------------------------------------------------------------------------
if(preg_match("#warning: SASL authentication problem: unable to open Berkeley db\s+(.+?):\s+Permission denied#", $buffer,$re)){
$GLOBALS["CLASS_UNIX"]->chown_func("postfix","postfix", "{$re[1]}");
return;
}
// ---------------------------------------------------------------------------------------------------------------
if(preg_match("#hash.*? open database\s+(.*?)\.db: No such file or directory#", $buffer,$re)){
if(!is_file($GLOBALS["postconf_bin_path"])){return;}
events("Missing hash database {$re[1]} -> build it");
@file_put_contents($re[1], "\n");
shell_exec("{$GLOBALS["NOHUP_PATH"]} {$GLOBALS["postconf_bin_path"]} hash:{$re[1]} >/dev/null 2>&1 &");
return;
}
// ---------------------------------------------------------------------------------------------------------------
if(preg_match("#cyrus.*?DBERROR: opening (.*?)\.seen: cyrusdb error#", $buffer,$re)){
events("cyrus, corrupted seen file {$re[1]}.seen");
@unlink("{$re[1]}.seen");
return;
}
// ---------------------------------------------------------------------------------------------------------------
if(preg_match("#connect to.*?\[(.*?)lmtp\]:\s+Permission denied#", $buffer)){
events("{$re[1]}/lmtp, permission denied, apply postfix:postfix");
$GLOBALS["CLASS_UNIX"]->chown_func("postfix","postfix", "{$re[1]}/lmtp");
return;
}
// ---------------------------------------------------------------------------------------------------------------
if(preg_match("#warning: connect \#[0-9]+\s+to subsystem private\/cyrus: No such file or directory#", $buffer)){
events("Cyrus unconfigured, reconfigure it...");
$file="/etc/artica-postfix/pids/cyrus-subsystem.".__LINE__.".time";
$timefile=file_time_min($file);
if($timefile>3){shell_exec_maillog("{$GLOBALS["NOHUP_PATH"]} {$GLOBALS["PHP5_BIN"]} /usr/share/artica-postfix/exec.postfix.maincf.php --imap-sockets >/dev/null 2>&1 &");}
@unlink($file);
@file_put_contents($file, time());
return;
}
// ---------------------------------------------------------------------------------------------------------------
if(preg_match("#postfix-script\[.+?: the Postfix mail system is not running#", $buffer)){
if($GLOBALS["EnableStopPostfix"]==0){
$file="/etc/artica-postfix/pids/postfix-script.start.time";
$timefile=file_time_min($file);
if($timefile>1){
shell_exec_maillog("{$GLOBALS["NOHUP_PATH"]} {$GLOBALS["postfix_bin_path"]} start >/dev/null 2>&1 &");}
@unlink($file);
@file_put_contents($file, time());
}
return;
}
// ---------------------------------------------------------------------------------------------------------------
if(preg_match("#master.*?fatal: bind (.+?)\s+port\s+([0-9]+):\s+Address already in use#", $buffer,$re)){
$port=$re[2];
events("Port conflict on $port");
exec("{$GLOBALS["fuser"]} $port/tcp 2>&1",$results);
while (list ($num, $ligne) = each ($results) ){
if(preg_match("#:\s+([0-9]+)#", $ligne,$re)){
$tokill=$re[1];
events("Killing PID $tokill");
shell_exec_maillog("{$GLOBALS["kill"]} -9 $tokill");
}
}
if($GLOBALS["EnableStopPostfix"]==0){
$file="/etc/artica-postfix/pids/postfix-script.start.".__LINE__.".time";
$timefile=file_time_min($file);
if($timefile>1){
shell_exec_maillog("{$GLOBALS["NOHUP_PATH"]} {$GLOBALS["postfix_bin_path"]} start >/dev/null 2>&1 &");}
@unlink($file);
@file_put_contents($file, time());
}
return;
}
// ---------------------------------------------------------------------------------------------------------------
if(strpos($buffer,"fatal: mail system startup failed")>0){
$sock=new sockets();
if($GLOBALS["EnableStopPostfix"]==0){
$file="/etc/artica-postfix/pids/postfix-script.start.".__LINE__.".time";
$timefile=file_time_min($file);
if($timefile>1){shell_exec_maillog("{$GLOBALS["NOHUP_PATH"]} {$GLOBALS["postfix_bin_path"]} start >/dev/null 2>&1 &");}
@unlink($file);
@file_put_contents($file, time());
}
return;
}
// ---------------------------------------------------------------------------------------------------------------
if(strpos($buffer," amavis[")>0){
$p=new amavis_maillog_buffer($buffer);
if($p->parse()){$p=null;return;}
}
$p=new postfix_maillog_buffer($buffer);if($p->parse()){$p=null;return;}
if(strpos($buffer," zarafa-")>0){
if(!class_exists("zarafa_maillog_buffer")){include_once(dirname(__FILE__)."/ressources/class.zarafa.maillog.inc");}
$p=new zarafa_maillog_buffer($buffer);
if($p->parse()){$p=null;return;}
}
if($GLOBALS["CLASS_SETTINGS"]->cyrus_imapd_installed){
if(!class_exists("cyrus_maillog")){include_once(dirname(__FILE__)."/ressources/class.cyrus.maillog.inc");}
$p=new cyrus_maillog($buffer);if($p->ParseBuffer()){$p=null;return;}
}
if(preg_match("#createuser\[.+?User store\s+'(.+?)'\s+createdi#",$buffer,$re)){
$this->email_events("Zarafa server new store created for {$re[1]}",$buffer,"mailbox");
return;
}
if(preg_match("#milter-greylist:.+?bind failed: Address already in use#",$buffer,$re)){
$file="/etc/artica-postfix/croned.1/milter-greylist.".md5("cannot start MX sync, bind failed: Address already in use");
$timefile=file_time_min($file);
if($timefile>5){
email_events("milter-greylist: double service issue",
"milter-greylist\n$buffer\nArtica will restart milter-greylist service","smtp");
@file_put_contents($file,"#");
$cmd="{$GLOBALS["NOHUP_PATH"]} /etc/init.d/milter-greylist restart >/dev/null 2>&1 &";
events("$cmd");
shell_exec_maillog($cmd);
}
return;
}
if(strpos($buffer,"inet_interfaces: no local interface found")>0){
$file="/etc/artica-postfix/croned.1/postfix.error.inet_interfaces";
events("inet_interfaces issues $buffer");
$timefile=file_time_min($file);
if($timefile>10){
email_events("{$re[1]}: misconfiguration on inet_interfaces",
"Postfix claim \n$buffer\n\nIf this event is resended\nplease Check Artica Technology support service.","postfix");
@file_put_contents($file,"#");
$cmd=trim("{$GLOBALS["NOHUP_PATH"]} {$GLOBALS["PHP5_BIN"]} /usr/share/artica-postfix/exec.postfix.maincf.php --interfaces >/dev/null 2>&1 &");
events("$cmd");
shell_exec_maillog($cmd);
}
return;
}
if(preg_match("#mail_queue_enter.*?create file maildrop\/.*?Permission denied#", $buffer,$re)){
chgrp("/var/spool/postfix/public", "postdrop");
chgrp("/var/spool/postfix/maildrop", "maildrop");
shell_exec("{$GLOBALS["CHMOD"]} 1730 /var/spool/postfix/maildrop");
shell_exec("{$GLOBALS["postfix_bin_path"]} stop && {$GLOBALS["postfix_bin_path"]} start");
return;
}
if(preg_match("#(.+?)\/smtpd\[.+?fatal:\s+config variable inet_interfaces#", $buffer)){
$file="/etc/artica-postfix/croned.1/postfix.error.inet_interfaces";
events("inet_interfaces issues' '{$re[1]}'");
$timefile=file_time_min($file);
if($timefile>10){
email_events("{$re[1]}: misconfiguration on inet_interfaces",
"Postfix claim \n$buffer\n\nIf this event is resended\nplease Check Artica Technology support service.","postfix");
@file_put_contents($file,"#");
if($re[1]=="postfix"){
$cmd=trim("{$GLOBALS["NOHUP_PATH"]} {$GLOBALS["PHP5_BIN"]} /usr/share/artica-postfix/exec.postfix.maincf.php --interfaces >/dev/null 2>&1 &");
events("$cmd");
shell_exec_maillog($cmd);
}else{
$cmd=trim("{$GLOBALS["NOHUP_PATH"]} {$GLOBALS["PHP5_BIN"]} /usr/share/artica-postfix/exec.postfix-multi.php >/dev/null 2>&1 &");
events("$cmd");
shell_exec_maillog($cmd);
}
}
return;
}
if(preg_match("#\]:\s+bayes: cannot open bayes databases\s+(.+?)\/bayes_.+?R\/.+?: tie failed.+?Permission denied#", $buffer,$re)){
events("cannot open bayes databases , Permission denied' '{$re[1]}/bayes_*'");
shell_exec_maillog("/bin/chown postfix:postfix {$re[1]}/bayes*");
return;
}
if(preg_match("#\]:\s+bayes: cannot open bayes databases\s+(.+?)\/bayes_.+?R\/O: tie failed#", $buffer,$re)){
events("cannot open bayes databases , unlink '{$re[1]}/bayes_seen' '{$re[1]}/bayes_toks'");
if(is_file("{$re[1]}/bayes_seen")){@unlink("{$re[1]}/bayes_seen");}
if(is_file("{$re[1]}/bayes_toks")){@unlink("{$re[1]}/bayes_toks");}
return;
}
if(preg_match("#problem talking to server\s+127\.0\.0\.1:10040: Connection refused#",$buffer,$re)){
events("Postfix: Postfwd2 issue... -> Connection refused");
$file="/etc/artica-postfix/croned.1/postfix.postfwd2.Connection.refused";
$timefile=file_time_min($file);
if($timefile>5){
email_events("Postfix: postfwd2 plugin is not available",
"Postfix claim \n$buffer\nArtica will try to start postfwd2.","postfix");
shell_exec_maillog(trim("{$GLOBALS["NOHUP_PATH"]} {$GLOBALS["PHP5_BIN"]} /usr/share/artica-postfix/exec.postfwd2.php --start >/dev/null 2>&1"));
@file_put_contents($file,"#");
}else{events("Postfix: Postfwd2 issue... -> Connection refused: {$timefile}Mn/5Mn");}
return;
}
if(preg_match("#postfix-(.+?)\/smtpd\[[0-9]+\]:\s+warning:\s+connect to Milter service unix:(.+?):\s+Connection refused#", $buffer,$re)){
events("Postfix: {$re[2]} socket issue Connection refused... (line ".__LINE__.")");
$file="/etc/artica-postfix/croned.1/postfix.{$re[1]}.". md5($re[2]).".sock.No.such.file.or.directory";
$timefile=file_time_min($file);
if($timefile>5){
$cmd=trim("{$GLOBALS["NOHUP_PATH"]} /bin/chown postfix:postfix {$re[2]} >/dev/null 2>&1 &");
events("Postfix:{$re[1]}: $cmd");
shell_exec_maillog($cmd);
}
return;
}
if(preg_match("#smtpd\[.+?warning:\s+connect to Milter service unix:\/var\/spool\/postfix\/var\/run\/amavisd-milter\/amavisd-milter\.sock: No such file or directory#", $buffer,$re)){
$file="/etc/artica-postfix/croned.1/postfix.amavisd-milter.sock.No.such.file.or.directory";
$timefile=file_time_min($file);
events("Postfix: Amavisd socket issue... (line ".__LINE__.")");
if($timefile>5){
if(!is_file("/usr/local/sbin/amavisd-milter")){
email_events("Postfix: amavisd-milter is not installed !, change the postfix method",
"postfix claim \n$buffer\nit seems that amavisd-milter is not installed\nArtica will re-install amavisd-milter or just\nChange amavis hooking to after-queue in order to use amavis main daemon.","postfix");
@file_put_contents($file,"#");
$cmd=trim("{$GLOBALS["NOHUP_PATH"]} /usr/share/artica-postfix/bin/artica-make APP_AMAVISD_MILTER >/dev/null 2>&1 &");
shell_exec_maillog($cmd);
return;
}
$cmd=trim("{$GLOBALS["NOHUP_PATH"]} /etc/init.d/amavis start >/dev/null 2>&1 &");
shell_exec_maillog($cmd);
return;
}
return;
}
if(preg_match("#\[.+?:\s+connect to 127\.0\.0\.1\[127\.0\.0\.1\]:2003:\s+Connection refused#", $buffer,$re)){
$file="/etc/artica-postfix/croned.1/postfix.port.2003.Connection.refused";
$timefile=file_time_min($file);
if($timefile>5){
email_events("Postfix: Connect to zarafa LMTP port Connection refused zarafa-lmtp will be restarted",
"postfix claim \n$buffer\nArtica will try to restart zarafa-lmtp daemon.","postfix");
shell_exec_maillog(trim("{$GLOBALS["NOHUP_PATH"]} /etc/init.d/artica-postfix restart zarafa-lmtp >/dev/null 2>&1 &"));
@file_put_contents($file,"#");
}else{events("Postfix: Connect to zarafa LMTP port Connection refused: {$timefile}Mn/5Mn");}
return;
}
if(preg_match("#smtp\[.+?:\s+connect to 127\.0\.0\.1\[127\.0\.0\.1\]:([0-9]+):\s+Connection refused#", $buffer,$re)){
if(postfix_is_amavis_port($re[1])){
$file="/etc/artica-postfix/croned.1/postfix.port.{$re[1]}.Connection.refused";
$timefile=file_time_min($file);
if($timefile>5){
email_events("Postfix: Connect to amavis port {$re[1]} Connection refused Amavis will be restarted",
"postfix claim \n$buffer\nArtica will try to restart amavis daemon.","postfix");
shell_exec_maillog(trim("{$GLOBALS["NOHUP_PATH"]} /etc/init.d/amavis restart --by-exec-maillog >/dev/null 2>&1 &"));
@file_put_contents($file,"#");
}else{events("Postfix: Connect to amavis port {$re[1]} Connection refused: {$timefile}Mn/5Mn");}
return;
}
}
if(preg_match("#cyrus\/.+?\[[0-9]+]#",$buffer)){
include_once(dirname(__FILE__)."/ressources/class.cyrus.maillog.inc");
$cyrus=new cyrus_maillog();
if($cyrus->ParseBuffer($buffer)){return;}
}
if(preg_match("#master\[.+?fatal: bind 127.0.0.1 port 33559: Address already in use#", $buffer,$re)){
events("Postfix: bind 127.0.0.1 port 33559: Address already in use -> startit");
shell_exec_maillog(trim("{$GLOBALS["NOHUP_PATH"]} {$GLOBALS["postfix_bin_path"]} start >/dev/null 2>&1 &"));
return;
}
if(preg_match("#postqueue.+?warning: Mail system is down#", $buffer,$re)){
$sock=new sockets();
$EnableStopPostfix=$sock->GET_INFO("EnableStopPostfix");
if(!is_numeric($EnableStopPostfix)){$EnableStopPostfix=0;}
if($EnableStopPostfix==0){
events("Postfix: Mail system is down: -> startit");
shell_exec_maillog(trim("{$GLOBALS["NOHUP_PATH"]} {$GLOBALS["postfix_bin_path"]} start >/dev/null 2>&1 &"));
}
return;
}
if(preg_match("#postscreen.+?warning: database\s+(.+?):\s+could not delete entry for#", $buffer,$re)){
events("Postscreen: Cache database failed");
if(is_file($re[1])){
@unlink($re[1]);
email_events("Postfix: postscreen_cache_map problem",
"postfix claim \n$buffer\nArtica have deleted {$re[1]} file to fix this issue.","postfix");
}
}
if(preg_match("#fatal: dict_open: unsupported dictionary type: pcre: Is the postfix-pcre package installed#i",$buffer,$re)){
events("Postfix: pcre missing");
$file="/etc/artica-postfix/croned.1/postfix.pcre.missing";
$timefile=file_time_min($file);
if($timefile>20){
email_events("Postfix: pcre missing",
"postfix claim \n$buffer\nArtica will try to upgrade postfix.","postfix");
shell_exec_maillog(trim("{$GLOBALS["NOHUP_PATH"]} /usr/share/artica-postfix/bin/artica-make APP_POSTFIX >/dev/null 2>&1 &"));
@file_put_contents($file,"#");
}else{events("Postfix: pcre missing: {$timefile}Mn/20Mn");}
return;
}
if(preg_match("#zarafa-server.+?The recommended upgrade procedure is to use the zarafa7-upgrade commandline tool#",$buffer,$re)){
$cmd=trim("{$GLOBALS["NOHUP_PATH"]} {$GLOBALS["PHP5_BIN"]} /usr/share/artica-postfix/exec.zarafa-migrate.php --upgrade-7 >/dev/null 2>&1 &");
events("zarafa-server, need to upgrade... -> $cmd");
shell_exec_maillog($cmd);
}
if(preg_match("#zarafa-gateway.+?POP3, POP3S, IMAP and IMAPS are all four disabled#",$buffer,$re)){
events("Zarafa-gateway No services enabled...???");
$file="/etc/artica-postfix/croned.1/zarafa-gateway.no.services";
$timefile=file_time_min($file);
if($timefile>10){
email_events("Zarafa mail server: No mailbox protocol ?",
"Zarafa claim \n$buffer\nYou have disabled all mailboxes protocols.\nMeans that zarafa-gateway is not necessary ???\nAre you sure ??","mailbox");
@file_put_contents($file,"#");
}else{events("Postfix: Zarafa-gateway No services enabled...: {$timefile}Mn/10Mn");}
return;
}
if(preg_match("#kavmilter\[.+?Cannot read template file:\s+(.+?)$#",$buffer,$re)){
events("kavmilter: {$re[1]} missing");
$md=md5($re[1]);
$file="/etc/artica-postfix/croned.1/kavmilter.template.$md";
$timefile=file_time_min($file);
if($timefile>5){
email_events("Kaspersky Milter: error template ".basename($re[1]),
"kavmilter claim \n$buffer\nArtica will try to repair.","postfix");
shell_exec_maillog("/bin/touch {$re[1]}");
shell_exec_maillog(trim("{$GLOBALS["NOHUP_PATH"]} {$GLOBALS["PHP5_BIN"]} /usr/share/artica-postfix/exec.kavmilter.php --templates >/dev/null 2>&1 &"));
@file_put_contents($file,"#");
}else{events("kavmilter: {$re[1]} missing: {$timefile}Mn/5Mn");}
return;
}
if(preg_match("#kavmilter\[.+?Can't load keys: No active key. Only skip actions allowed#",$buffer,$re)){
events("kavmilter: key missing");
$md=md5($re[1]);
$file="/etc/artica-postfix/croned.1/kavmilter.no-active-key.error";
$timefile=file_time_min($file);
if($timefile>10){
email_events("Kaspersky Milter: no license !!",
"kavmilter claim \n$buffer\nPlease disable kavmilter plugin or perform a license key activation","postfix");
@file_put_contents($file,"#");
}else{events("kavmilter: kavmilter: key missing: {$timefile}Mn/5Mn");}
return;
}
if(preg_match("#warning:.+?then you may have to chmod a\+r\s+(.+?)$#",$buffer,$re)){
events("chmod a+r {$re[1]}");
shell_exec_maillog("/bin/chmod a+r {$re[1]}");
return;
}
if(preg_match("#imaps\[.+?Fatal error: tls_start_servertls.+?failed#",$buffer,$re)){
events("Cyrus-imap : IMAP SSL FAILED");
$file="/etc/artica-postfix/croned.1/imaps.error.tls_start_servertls";
$timefile=file_time_min($file);
if($timefile>5){
shell_exec_maillog(trim("{$GLOBALS["NOHUP_PATH"]} {$GLOBALS["PHP5_BIN"]} /usr/share/artica-postfix/exec.cyrus.php --imaps-failed >/dev/null 2>&1 &"));
@unlink($file);
@file_put_contents($file,"#");
}else{events("Cyrus-imap wait:{$timefile}Mn/5Mn");}
return;
}
if(preg_match("#fatal: file.+?main\.cf: parameter setgid_group: unknown group name:\s+(.+)#",$buffer,$re)){
events("Postfix : group name {$re[1]} problem");
$file="/etc/artica-postfix/croned.1/postfix.group.{$re[1]}.error";
$timefile=file_time_min($file);
if($timefile>5){
email_events("Postfix: group {$re[1]} is not available",
"Postfix claim \n$buffer\nArtica will try create this group.","postfix");
$unix=new unix();
$groupadd=$unix->find_program("groupadd");
shell_exec_maillog("$groupadd {$re[1]}&");
@file_put_contents($file,"#");
}else{events("Postfix: Postfix: group {$re[1]} is not available: {$timefile}Mn/5Mn");}
return;
}
if(preg_match("#fatal: parameter inet_interfaces: no local interface found for ([0-9\.]+)#i",$buffer,$re)){
events("Postfix : NIC {$re[1]} problem");
$file="/etc/artica-postfix/croned.1/postfix.interface.{$re[1]}.error";
$timefile=file_time_min($file);
if($timefile>5){
email_events("Postfix: Interface {$re[1]} is not available",
"Postfix claim \n$buffer\nArtica will try to restore TCP/IP interfaces.","postfix");
@unlink("/etc/artica-postfix/MEM_INTERFACES");
shell_exec_maillog(trim("{$GLOBALS["NOHUP_PATH"]} {$GLOBALS["PHP5_BIN"]} /usr/share/artica-postfix/exec.virtuals-ip.php >/dev/null 2>&1 &"));
@unlink($file);
@file_put_contents($file,"#");
}else{events("Postfix: Interface {$re[1]} is not available: {$timefile}Mn/5Mn");}
return;
}
if(preg_match("#qmgr\[.+?fatal: incorrect version of Berkeley DB: compiled against.+?run-time linked against#i",$buffer,$re)){
events("Postfix : incorrect version of Berkeley DB");
$file="/etc/artica-postfix/croned.1/qmgr.error.Berkeley";
$timefile=file_time_min($file);
if($timefile>5){
email_events("Postfix: incorrect version of Berkeley DB",
"Postfix claim \n$buffer\nArtica will upgrade/re-install your postfix version.","postfix");
@unlink($file);
shell_exec_maillog(trim("{$GLOBALS["NOHUP_PATH"]} /usr/share/artica-postfix/bin/artica-make APP_POSTFIX 2>&1 &"));
@file_put_contents($file,"#");
}else{events("Postfix : incorrect version of Berkeley DB wait:{$timefile}Mn/5Mn");}
return;
}
if(preg_match('#smtpd\[.+? warning: unknown smtpd restriction: "(.+?)"#',$buffer,$re)){
events("Postfix : incorrect parameters on smtpd restriction");
$file="/etc/artica-postfix/croned.1/smtpd.error.restriction." .md5($re[1]);
$timefile=file_time_min($file);
if($timefile>5){
email_events("Postfix: incorrect parameters on smtpd restriction",
"Postfix claim \n$buffer\nArtica will try to fix the problem.\nif this error is sended again, please contact Artica Support team.","postfix");
@unlink($file);
shell_exec_maillog(trim("{$GLOBALS["PHP5_BIN"]} /usr/share/artica-postfix/exec.postfix.maincf.php --smtp-sender-restrictions &"));
@file_put_contents($file,"#");
}else{events("Postfix : incorrect parameters on smtpd restriction wait:{$timefile}Mn/5Mn");}
return;
}
if(preg_match('#spamc\[.+?connect to spamd on (.+?)\s+failed,.+?Connection refused#',$buffer,$re)){
events("Spamassassin : {$re[1]} Connection refused");
$file="/etc/artica-postfix/croned.1/spamc.error.cnx.refused." .md5($re[1]);
$timefile=file_time_min($file);
if($timefile>5){
email_events("Spamassassin: Connection refused on {$re[1]}",
"Spamassassin claim \n$buffer\nYou should have less issues and better performances using Amavisd-new instead Spamassassin only","postfix");
@unlink($file);
@file_put_contents($file,"#");
}else{events("Spamassassin : {$re[1]} Connection refused wait:{$timefile}Mn/5Mn");}
return;
}
if(preg_match("#smtpd\[.+?warning: connect to 127.0.0.1:54423: Connection refused#",$buffer,$re)){
events("restart Artica-policy");
shell_exec_maillog("/etc/init.d/artica-postfix restart artica-policy &");
return;
}
if(preg_match("#nss_wins\[.+?connect from (.+?)\[(.+?)\]#",$buffer,$re)){
Postfix_Addconnection($re[1],$re[2]);
return;
}
if(preg_match("#nss_wins\[.+?warning: (.+?):\s+address not listed for hostname\s+(.+?)$#",$buffer,$re)){
$GLOBALS["maillog_tools"]->Postfix_Addconnection_error($re[2],$re[1],"ADDR_NOT_LISTED1");
return;
}
if(preg_match("#postscreen\[.+?CONNECT from \[(.+?)\]#i",$buffer,$re)){
Postfix_Addconnection(null,$re[1]);
return;
}