34 |
*/ |
*/ |
35 |
|
|
36 |
#include <config.h> |
#include <config.h> |
|
|
|
37 |
#include <stdio.h> |
#include <stdio.h> |
38 |
#include <stdlib.h> |
#include <stdlib.h> |
39 |
#include <errno.h> |
#include <errno.h> |
40 |
|
#include <ctype.h> |
41 |
|
|
42 |
#ifdef HAVE_SYS_TYPES_H |
#ifdef HAVE_SYS_TYPES_H |
43 |
#include <sys/types.h> |
#include <sys/types.h> |
96 |
int ssl; |
int ssl; |
97 |
char *request; |
char *request; |
98 |
char *pathname; |
char *pathname; |
99 |
|
char *certmd5; |
100 |
Protocol_T protocol; |
Protocol_T protocol; |
101 |
}; |
}; |
102 |
|
|
126 |
static struct MailFilter mtf= { NULL, NULL, NULL, FALSE, FALSE, FALSE, |
static struct MailFilter mtf= { NULL, NULL, NULL, FALSE, FALSE, FALSE, |
127 |
FALSE, FALSE }; |
FALSE, FALSE }; |
128 |
static struct PortSet portset= { -1, NULL, 0, SOCK_STREAM, AF_INET, FALSE, |
static struct PortSet portset= { -1, NULL, 0, SOCK_STREAM, AF_INET, FALSE, |
129 |
NULL, NULL, NULL }; |
NULL, NULL, NULL, NULL }; |
130 |
static struct ResourceSet resourceset= { 0, 0, RESOURCE_OPERATOR_GREATER, |
static struct ResourceSet resourceset= { 0, 0, RESOURCE_OPERATOR_GREATER, |
131 |
1, RESOURCE_ACTION_ALERT }; |
1, RESOURCE_ACTION_ALERT }; |
132 |
|
|
156 |
static void check_hostname (char *); |
static void check_hostname (char *); |
157 |
static void createprocinfo(); |
static void createprocinfo(); |
158 |
static char *append_hostname(char *); |
static char *append_hostname(char *); |
159 |
|
static void cleanup_md5_string(char *); |
160 |
%} |
%} |
161 |
|
|
162 |
%union { |
%union { |
171 |
%token HOST PORT TYPE UDP TCP TCPSSL PROTOCOL |
%token HOST PORT TYPE UDP TCP TCPSSL PROTOCOL |
172 |
%token ALERT MAILFORMAT UNIXSOCKET |
%token ALERT MAILFORMAT UNIXSOCKET |
173 |
%token TIMEOUT RESTART CHECKSUM EXPECT EVERY |
%token TIMEOUT RESTART CHECKSUM EXPECT EVERY |
174 |
%token DEFAULT HTTP FTP SMTP POP IMAP NNTP |
%token DEFAULT HTTP FTP SMTP POP IMAP NNTP CERTMD5 |
175 |
%token <string> STRING PATH MAILADDR MAILFROM MAILSUBJECT |
%token <string> STRING PATH MAILADDR MAILFROM MAILSUBJECT |
176 |
%token <string> MAILBODY |
%token <string> MAILBODY |
177 |
%token <number> NUMBER |
%token <number> NUMBER |
379 |
|
|
380 |
type : /* EMPTY */ { portset.type= SOCK_STREAM; } |
type : /* EMPTY */ { portset.type= SOCK_STREAM; } |
381 |
| TYPE TCP { portset.type= SOCK_STREAM; } |
| TYPE TCP { portset.type= SOCK_STREAM; } |
382 |
| TYPE TCPSSL { portset.type= SOCK_STREAM; |
| TYPE TCPSSL certmd5 { portset.type= SOCK_STREAM; |
383 |
portset.ssl= TRUE; } |
portset.ssl= TRUE; } |
384 |
| TYPE UDP { portset.type= SOCK_DGRAM; } |
| TYPE UDP { portset.type= SOCK_DGRAM; } |
385 |
; |
; |
386 |
|
|
387 |
|
certmd5 : /* EMPTY */ { portset.certmd5= NULL; } |
388 |
|
| CERTMD5 STRING { portset.certmd5= $2; } |
389 |
|
| EXPECT CERTMD5 STRING { portset.certmd5= $3; } |
390 |
|
; |
391 |
|
|
392 |
protocol : /* EMPTY */ { portset.protocol= addprotocol(P_DEFAULT); } |
protocol : /* EMPTY */ { portset.protocol= addprotocol(P_DEFAULT); } |
393 |
| PROTOCOL DEFAULT { portset.protocol= addprotocol(P_DEFAULT); } |
| PROTOCOL DEFAULT { portset.protocol= addprotocol(P_DEFAULT); } |
394 |
| PROTOCOL HTTP request {portset.protocol= addprotocol(P_HTTP);} |
| PROTOCOL HTTP request {portset.protocol= addprotocol(P_HTTP);} |
699 |
if ( sum ) { |
if ( sum ) { |
700 |
|
|
701 |
c->md5= sum; |
c->md5= sum; |
702 |
|
|
703 |
|
|
704 |
} else if ( ! set_md5sum(&c->md5, filename) ) { |
} else if ( ! set_md5sum(&c->md5, filename) ) { |
705 |
|
|
709 |
|
|
710 |
} |
} |
711 |
|
|
712 |
|
|
713 |
|
if (c->md5 != NULL) { |
714 |
|
|
715 |
|
cleanup_md5_string(c->md5); |
716 |
|
|
717 |
|
} |
718 |
|
|
719 |
c->next= current->checksumlist; |
c->next= current->checksumlist; |
720 |
current->checksumlist= c; |
current->checksumlist= c; |
721 |
|
|
779 |
p->request= pp->request; |
p->request= pp->request; |
780 |
p->protocol= pp->protocol; |
p->protocol= pp->protocol; |
781 |
p->pathname= pp->pathname; |
p->pathname= pp->pathname; |
782 |
|
p->certmd5= pp->certmd5; |
783 |
|
|
784 |
|
if (p->certmd5 != NULL) { |
785 |
|
|
786 |
|
cleanup_md5_string(p->certmd5); |
787 |
|
|
788 |
|
} |
789 |
|
|
790 |
if ( pp->family == AF_INET ) { |
if ( pp->family == AF_INET ) { |
791 |
snprintf(address, STRLEN, "INET[%s:%d]", pp->hostname, pp->port); |
snprintf(address, STRLEN, "INET[%s:%d]", pp->hostname, pp->port); |
1187 |
|
|
1188 |
} |
} |
1189 |
|
|
1190 |
|
/* |
1191 |
|
* Cleans up an md5 string, tolower and remove byte sperators |
1192 |
|
*/ |
1193 |
|
|
1194 |
|
static void cleanup_md5_string(char *md5string) { |
1195 |
|
|
1196 |
|
int i= 0, j= 0; |
1197 |
|
|
1198 |
|
if (md5string == NULL) { |
1199 |
|
|
1200 |
|
return; |
1201 |
|
|
1202 |
|
} |
1203 |
|
|
1204 |
|
|
1205 |
|
while (md5string[i] != '\0') { |
1206 |
|
|
1207 |
|
if (isxdigit((int) md5string[i])) { |
1208 |
|
|
1209 |
|
md5string[j]=tolower(md5string[i]); |
1210 |
|
j++; |
1211 |
|
|
1212 |
|
} |
1213 |
|
|
1214 |
|
i++; |
1215 |
|
|
1216 |
|
} |
1217 |
|
|
1218 |
|
md5string[j]='\0'; |
1219 |
|
|
1220 |
|
return; |
1221 |
|
|
1222 |
|
} |