91 |
#include <netinet/ip_icmp.h> |
#include <netinet/ip_icmp.h> |
92 |
#endif |
#endif |
93 |
|
|
94 |
|
#ifdef HAVE_REGEX_H |
95 |
|
#include <regex.h> |
96 |
|
#endif |
97 |
|
|
98 |
#include "net.h" |
#include "net.h" |
99 |
#include "monitor.h" |
#include "monitor.h" |
100 |
#include "protocol.h" |
#include "protocol.h" |
122 |
int ssl; |
int ssl; |
123 |
int sslversion; |
int sslversion; |
124 |
char *request; |
char *request; |
125 |
|
Generic_T generic; |
126 |
char *pathname; |
char *pathname; |
127 |
char *certmd5; |
char *certmd5; |
128 |
Protocol_T protocol; |
Protocol_T protocol; |
206 |
static Service_T depend_list= NULL; |
static Service_T depend_list= NULL; |
207 |
static struct IHavePrecedence ihp= {FALSE, FALSE, FALSE}; |
static struct IHavePrecedence ihp= {FALSE, FALSE, FALSE}; |
208 |
static struct PortSet portset= {-1, NULL, 0, SOCK_STREAM, AF_INET, FALSE, |
static struct PortSet portset= {-1, NULL, 0, SOCK_STREAM, AF_INET, FALSE, |
209 |
SSL_VERSION_AUTO, NULL, NULL, NULL, NULL, ACTION_ALERT, NET_TIMEOUT}; |
SSL_VERSION_AUTO, NULL, NULL, NULL, NULL, NULL, ACTION_ALERT, NET_TIMEOUT}; |
210 |
static struct ResourceSet resourceset= {0, 0, OPERATOR_EQUAL, 1, |
static struct ResourceSet resourceset= {0, 0, OPERATOR_EQUAL, 1, |
211 |
ACTION_ALERT}; |
ACTION_ALERT}; |
212 |
static struct TimestampSet timestampset= {OPERATOR_EQUAL, 0, 0, ACTION_ALERT}; |
static struct TimestampSet timestampset= {OPERATOR_EQUAL, 0, 0, ACTION_ALERT}; |
232 |
static void adddevice(struct DeviceSet *); |
static void adddevice(struct DeviceSet *); |
233 |
static void addicmp(struct IcmpSet *); |
static void addicmp(struct IcmpSet *); |
234 |
static void *addprotocol(int); |
static void *addprotocol(int); |
235 |
|
static void addgeneric(struct PortSet *, char*, char*); |
236 |
static void addcommand(int); |
static void addcommand(int); |
237 |
static void addargument(char *); |
static void addargument(char *); |
238 |
static uid_t get_uid(char *, uid_t); |
static uid_t get_uid(char *, uid_t); |
284 |
%token IF THEN ELSE FAILED CYCLE |
%token IF THEN ELSE FAILED CYCLE |
285 |
%token SET LOGFILE FACILITY DAEMON SYSLOG MAILSERVER HTTPD ALLOW ADDRESS INIT |
%token SET LOGFILE FACILITY DAEMON SYSLOG MAILSERVER HTTPD ALLOW ADDRESS INIT |
286 |
%token PEMFILE ENABLE DISABLE HTTPDSSL CLIENTPEMFILE ALLOWSELFCERTIFICATION |
%token PEMFILE ENABLE DISABLE HTTPDSSL CLIENTPEMFILE ALLOWSELFCERTIFICATION |
287 |
%token STATEFILE |
%token STATEFILE SEND EXPECT |
288 |
%token CHECK PIDFILE START STOP PATHTOK |
%token CHECK PIDFILE START STOP PATHTOK |
289 |
%token HOST PORT TYPE UDP TCP TCPSSL PROTOCOL CONNECTION |
%token HOST PORT TYPE UDP TCP TCPSSL PROTOCOL CONNECTION |
290 |
%token ALERT MAILFORMAT UNIXSOCKET |
%token ALERT MAILFORMAT UNIXSOCKET |
308 |
|
|
309 |
%left GREATER LESS EQUAL NOTEQUAL |
%left GREATER LESS EQUAL NOTEQUAL |
310 |
|
|
311 |
|
|
312 |
%% |
%% |
313 |
cfgfile : /* EMPTY */ |
cfgfile : /* EMPTY */ |
314 |
| statement_list |
| statement_list |
691 |
| SSLAUTO { portset.sslversion= SSL_VERSION_AUTO; } |
| SSLAUTO { portset.sslversion= SSL_VERSION_AUTO; } |
692 |
; |
; |
693 |
|
|
694 |
protocol : /* EMPTY */ { portset.protocol= addprotocol(P_DEFAULT); } |
protocol : /* EMPTY */ { portset.protocol= addprotocol(P_DEFAULT);} |
695 |
| PROTOCOL DEFAULT { portset.protocol= addprotocol(P_DEFAULT); } |
| PROTOCOL DEFAULT { portset.protocol= addprotocol(P_DEFAULT); } |
696 |
| PROTOCOL HTTP request {portset.protocol= addprotocol(P_HTTP);} |
| PROTOCOL HTTP request {portset.protocol= addprotocol(P_HTTP);} |
697 |
| PROTOCOL FTP { portset.protocol= addprotocol(P_FTP); } |
| PROTOCOL FTP { portset.protocol= addprotocol(P_FTP); } |
705 |
| PROTOCOL LDAP3 { portset.protocol= addprotocol(P_LDAP3); } |
| PROTOCOL LDAP3 { portset.protocol= addprotocol(P_LDAP3); } |
706 |
| PROTOCOL RDATE { portset.protocol= addprotocol(P_RDATE); } |
| PROTOCOL RDATE { portset.protocol= addprotocol(P_RDATE); } |
707 |
| PROTOCOL RSYNC { portset.protocol= addprotocol(P_RSYNC); } |
| PROTOCOL RSYNC { portset.protocol= addprotocol(P_RSYNC); } |
708 |
|
| sendexpectlist { portset.protocol= addprotocol(P_GENERIC); } |
709 |
; |
; |
710 |
|
|
711 |
|
sendexpectlist : sendexpect |
712 |
|
| sendexpectlist sendexpect |
713 |
|
; |
714 |
|
|
715 |
|
sendexpect : SEND STRING { addgeneric(&portset, $2, NULL);} |
716 |
|
| EXPECT STRING { addgeneric(&portset, NULL, $2); } |
717 |
|
; |
718 |
|
|
719 |
request : /* EMPTY */ |
request : /* EMPTY */ |
720 |
| REQUEST PATH { portset.request= url_encode($2); free($2); } |
| REQUEST PATH { portset.request= url_encode($2); free($2); } |
721 |
; |
; |
1310 |
p->action= pp->action; |
p->action= pp->action; |
1311 |
p->timeout= pp->timeout; |
p->timeout= pp->timeout; |
1312 |
p->request= pp->request; |
p->request= pp->request; |
1313 |
|
p->generic= pp->generic; |
1314 |
p->protocol= pp->protocol; |
p->protocol= pp->protocol; |
1315 |
p->pathname= pp->pathname; |
p->pathname= pp->pathname; |
1316 |
p->hostname= pp->hostname; |
p->hostname= pp->hostname; |
1682 |
static void *addprotocol(int protocol) { |
static void *addprotocol(int protocol) { |
1683 |
|
|
1684 |
switch (protocol) { |
switch (protocol) { |
1685 |
case P_HTTP: return create_http(); |
case P_HTTP: return create_http(); |
1686 |
case P_FTP: return create_ftp(); |
case P_FTP: return create_ftp(); |
1687 |
case P_SMTP: return create_smtp(); |
case P_SMTP: return create_smtp(); |
1688 |
case P_POP: return create_pop(); |
case P_POP: return create_pop(); |
1689 |
case P_IMAP: return create_imap(); |
case P_IMAP: return create_imap(); |
1690 |
case P_NNTP: return create_nntp(); |
case P_NNTP: return create_nntp(); |
1691 |
case P_SSH: return create_ssh(); |
case P_SSH: return create_ssh(); |
1692 |
case P_DWP: return create_dwp(); |
case P_DWP: return create_dwp(); |
1693 |
case P_LDAP2: return create_ldap2(); |
case P_LDAP2: return create_ldap2(); |
1694 |
case P_LDAP3: return create_ldap3(); |
case P_LDAP3: return create_ldap3(); |
1695 |
case P_RDATE: return create_rdate(); |
case P_RDATE: return create_rdate(); |
1696 |
case P_RSYNC: return create_rsync(); |
case P_RSYNC: return create_rsync(); |
1697 |
|
case P_GENERIC: return create_generic(); |
1698 |
} |
} |
1699 |
|
|
1700 |
return create_default(); |
return create_default(); |
1701 |
|
|
1702 |
} |
} |
1703 |
|
|
1704 |
|
/* |
1705 |
|
* Add a generic protocol handler to |
1706 |
|
*/ |
1707 |
|
static void addgeneric(struct PortSet *pp, char *send, char *expect) { |
1708 |
|
|
1709 |
|
Generic_T g=pp->generic; |
1710 |
|
|
1711 |
|
if ( g == NULL ) { |
1712 |
|
|
1713 |
|
NEW(g); |
1714 |
|
pp->generic=g; |
1715 |
|
|
1716 |
|
} else { |
1717 |
|
|
1718 |
|
while (g->next != NULL) { |
1719 |
|
|
1720 |
|
g=g->next; |
1721 |
|
|
1722 |
|
} |
1723 |
|
|
1724 |
|
NEW(g->next); |
1725 |
|
g=g->next; |
1726 |
|
} |
1727 |
|
|
1728 |
|
if ( send != NULL ) { |
1729 |
|
|
1730 |
|
g->send=xstrdup(send); |
1731 |
|
g->expect=NULL; |
1732 |
|
|
1733 |
|
} else if ( expect != NULL ) { |
1734 |
|
|
1735 |
|
#ifdef HAVE_REGEX_H |
1736 |
|
int reg_return; |
1737 |
|
int error_offset; |
1738 |
|
|
1739 |
|
NEW(g->expect); |
1740 |
|
|
1741 |
|
reg_return= regcomp(g->expect, expect, REG_NOSUB|REG_EXTENDED); |
1742 |
|
|
1743 |
|
if (reg_return!=0) { |
1744 |
|
|
1745 |
|
char errbuf[STRLEN]; |
1746 |
|
|
1747 |
|
regerror(reg_return, g->expect, errbuf, STRLEN); |
1748 |
|
log("%s: regex error: %s '%s' at line %d\n", |
1749 |
|
prog, errbuf, expect, lineno-1); |
1750 |
|
cfg_errflag++; |
1751 |
|
|
1752 |
|
} |
1753 |
|
|
1754 |
|
#else |
1755 |
|
|
1756 |
|
g->expect=xstrdup(expect); |
1757 |
|
|
1758 |
|
#endif |
1759 |
|
|
1760 |
|
g->send=NULL; |
1761 |
|
|
1762 |
|
} |
1763 |
|
|
1764 |
|
} |
1765 |
|
|
1766 |
|
|
1767 |
/* |
/* |
1768 |
* Add the current command object to the current service object's |
* Add the current command object to the current service object's |
2102 |
portset.ssl= FALSE; |
portset.ssl= FALSE; |
2103 |
portset.sslversion= SSL_VERSION_AUTO; |
portset.sslversion= SSL_VERSION_AUTO; |
2104 |
portset.request= NULL; |
portset.request= NULL; |
2105 |
|
portset.generic= NULL; |
2106 |
portset.protocol= NULL; |
portset.protocol= NULL; |
2107 |
portset.pathname= NULL; |
portset.pathname= NULL; |
2108 |
portset.action= ACTION_ALERT; |
portset.action= ACTION_ALERT; |