forked from EnderUNIX/spamGuard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
129 lines (111 loc) · 3.82 KB
/
main.c
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
/*
*
* EnderUNIX Software Development Team @ Turkey
* (c) 200 Istanbul, Turkiye
*
* See COPYING for copyright and copying restrictions
*
*/
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <errno.h>
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "wildmat.h"
#include "parser.h"
#include "loadconfig.h"
#include "functions.h"
#include "hash.h"
#include "qsheff_parser.h"
#include "config.h"
extern char logtype[VALSIZE];
extern char logfile[VALSIZE];
extern char ignorefile[VALSIZE];
extern char badmailfile[VALSIZE];
int w = 0;
int b = 0;
int p = 0;
int
main(int argc, char **argv)
{
int c = 0, f = 0, error = 0;
extern char *optarg;
extern int optind;
char spamguardconf[VALSIZE];
while (!error && (c = getopt(argc, argv, "f:hv")) != -1) {
switch (c) {
case 'v':
printf("EnderUNIX spamGuard Version %s\n", VERSION);
exit(0);
break;
case 'h':
printf("Usage: %s [-f spamguard.conf]\n", argv[0]);
exit(0);
break;
case 'f':
strncpy(spamguardconf, optarg, VALSIZE - 1);
f = 1;
break;
default:
error = 1;
puts("Usage: spamGuard [-f spamguard.conf]");
exit(-1);
break;
}
}
if (f == 0)
readconfig(CONFIGFILE);
else
readconfig(spamguardconf);
iaddrlist = NULL;
if (strcmp(logtype, "qmail") == 0) {
read_logfile(logfile);
load_ignore_list(ignorefile, SRC_IGNOREFILE);
load_ignore_list(ignorefile, SRC_HIGHFILE);
load_ignore_list(badmailfile, SRC_BADMAILFROM);
printf("Spammers:\n");
if (qmail_finalize() > 0)
printf("Spammer is detected\n");
else
printf("No spammer found yet\n");
}
if ((strcmp(logtype, "sendmail") == 0) || (strcmp(logtype, "postfix") == 0)) {
read_logfile(logfile);
load_ignore_list(ignorefile, SRC_IGNOREFILE);
load_ignore_list(ignorefile, SRC_HIGHFILE);
load_ignore_sendmail(badmailfile, SRC_BADMAILFROM);
printf("Spammers:\n");
if (sendmail_finalize() > 0)
printf("Spammer is detected\n");
else
printf("No spammer found yet\n");
}
if (strcmp(logtype, "qsheff") == 0) {
parse_qsheff_log(logfile);
load_ignored_IP(ignorefile, SRC_IGNOREFILE);
load_ignored_IP(ignorefile, SRC_HIGHFILE);
load_ignored_IP(badmailfile, SRC_BADMAILFROM);
printf("Spammers:\n");
if (qsheff_finalize() > 0)
printf("Spammer is detected\n");
else
printf("No spammer found yet\n");
}
if ((strcmp(logtype, "exim") == 0)) {
read_logfile(logfile);
load_ignore_list(ignorefile, SRC_IGNOREFILE);
load_ignore_list(ignorefile, SRC_HIGHFILE);
load_ignore_list(badmailfile, SRC_BADMAILFROM);
printf("Spammers:\n");
if (exim_finalize() > 0)
printf("Spammer is detected\n");
else
printf("No spammer found yet\n");
}
return 0;
}