-- rewrite. We drop messages with viruses detected, however we do not yet send any notification in either direction of an infected mail.
This commit is contained in:
@@ -3,9 +3,7 @@ sbin_PROGRAMS += bongoavirus
|
||||
|
||||
bongoavirus_SOURCES = \
|
||||
src/agents/avirus/avirus.c \
|
||||
src/agents/avirus/avirus.h \
|
||||
src/agents/avirus/mime.c \
|
||||
src/agents/avirus/stream.c
|
||||
src/agents/avirus/avirus.h
|
||||
|
||||
bongoavirus_LDADD = \
|
||||
libbongonmap.la \
|
||||
|
||||
+143
-1196
File diff suppressed because it is too large
Load Diff
+50
-136
@@ -20,168 +20,87 @@
|
||||
* (C) 2007 Patrick Felt
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _AVIRUS_H
|
||||
#define _AVIRUS_H
|
||||
#ifndef _ANTIVIRUS_H
|
||||
#define _ANTIVIRUS_H
|
||||
|
||||
|
||||
#ifdef LOGGERNAME
|
||||
#undef LOGGERNAME
|
||||
#endif
|
||||
|
||||
#define AGENT_NAME "antivirus"
|
||||
#define LOGGERNAME "antivirus"
|
||||
#include <logger.h>
|
||||
|
||||
#include <connio.h>
|
||||
#include <msgapi.h>
|
||||
#include <nmap.h>
|
||||
#include <nmlib.h>
|
||||
|
||||
#define PRODUCT_SHORT_NAME "avirus.nlm"
|
||||
|
||||
#define ANTIVIRUS_EXT "av"
|
||||
|
||||
#define NO_VIRUS 1
|
||||
#define PRODUCT_SHORT_NAME "bongoavirus.nlm"
|
||||
|
||||
#define CONNECTION_TIMEOUT (15 * 60)
|
||||
|
||||
#define MIME_REALLOC_SIZE 20
|
||||
|
||||
#define CLAMAV_DEFAULT_ADDRESS "127.0.0.1"
|
||||
#define CLAMAV_DEFAULT_PORT 3310
|
||||
|
||||
typedef enum _AVirusStates {
|
||||
AV_STATE_STARTING = 0,
|
||||
AV_STATE_INITIALIZING,
|
||||
AV_STATE_LOADING,
|
||||
AV_STATE_RUNNING,
|
||||
AV_STATE_RELOADING,
|
||||
AV_STATE_UNLOADING,
|
||||
AV_STATE_STOPPING,
|
||||
AV_STATE_DONE,
|
||||
AVIRUS_STATE_STARTING = 0,
|
||||
AVIRUS_STATE_INITIALIZING,
|
||||
AVIRUS_STATE_LOADING,
|
||||
AVIRUS_STATE_RUNNING,
|
||||
AVIRUS_STATE_RELOADING,
|
||||
AVIRUS_STATE_UNLOADING,
|
||||
AVIRUS_STATE_STOPPING,
|
||||
AVIRUS_STATE_DONE,
|
||||
|
||||
AV_STATE_MAX_STATES
|
||||
AVIRUS_STATE_MAX_STATES
|
||||
} AVirusStates;
|
||||
|
||||
typedef enum _AVirusFlags {
|
||||
AV_FLAG_USE_CA = (1 << 0),
|
||||
AV_FLAG_USE_MCAFEE = (1 << 1),
|
||||
AV_FLAG_USE_SYMANTEC = (1 << 2),
|
||||
AV_FLAG_NOTIFY_USER = (1 << 3),
|
||||
AV_FLAG_NOTIFY_SENDER = (1 << 4),
|
||||
AV_FLAG_SCAN_INCOMING = (1 << 5),
|
||||
AV_FLAG_USE_COMMANDAV = (1 << 6),
|
||||
AV_FLAG_USE_CLAMAV = (1 << 7),
|
||||
|
||||
AV_FLAG_SCAN = (1 << 29),
|
||||
AV_FLAG_INFECTED = (1 << 30),
|
||||
AV_FLAG_CURED = (1 << 31)
|
||||
AVIRUS_FLAG_RETURN_TO_SENDER = (1 << 0),
|
||||
AVIRUS_FLAG_NOTIFY_POSTMASTER = (1 << 1),
|
||||
} AVirusFlags;
|
||||
|
||||
typedef enum _AVirusClientFlags {
|
||||
AV_CLIENT_FLAG_NEW = (1 << 0),
|
||||
AV_CLIENT_FLAG_WAITING = (1 << 1),
|
||||
AV_CLIENT_FLAG_EXITING = (1 << 2)
|
||||
AVIRUS_CLIENT_FLAG_NEW = (1 << 0),
|
||||
AVIRUS_CLIENT_FLAG_WAITING = (1 << 1),
|
||||
AVIRUS_CLIENT_FLAG_EXITING = (1 << 2)
|
||||
} AVirusClientFlags;
|
||||
|
||||
typedef struct _AVMIME {
|
||||
AVirusFlags flags;
|
||||
|
||||
struct {
|
||||
unsigned long start;
|
||||
unsigned long size;
|
||||
} part;
|
||||
|
||||
unsigned char *type;
|
||||
unsigned char *encoding;
|
||||
unsigned char *fileName;
|
||||
unsigned char *virusName;
|
||||
} AVMIME;
|
||||
|
||||
typedef struct _AVRecipient {
|
||||
unsigned char *name;
|
||||
unsigned char *address;
|
||||
unsigned char *next;
|
||||
} AVRecipient;
|
||||
|
||||
typedef struct {
|
||||
AVirusClientFlags flags;
|
||||
|
||||
Connection *conn;
|
||||
void *handle;
|
||||
|
||||
unsigned int envelopeLength;
|
||||
unsigned int messageLength;
|
||||
unsigned int envelopeLines;
|
||||
|
||||
char qID[16]; /* holds the queueID */
|
||||
unsigned char *envelope;
|
||||
unsigned char work[XPL_MAX_PATH + 1];
|
||||
unsigned char line[CONN_BUFSIZE + 1];
|
||||
unsigned char command[CONN_BUFSIZE + 1];
|
||||
unsigned char dn[101];
|
||||
} AVirusClient;
|
||||
|
||||
struct {
|
||||
unsigned long used;
|
||||
unsigned long allocated;
|
||||
unsigned long current;
|
||||
|
||||
AVMIME *cache;
|
||||
} mime;
|
||||
|
||||
struct {
|
||||
unsigned long used;
|
||||
unsigned long allocated;
|
||||
|
||||
char **names;
|
||||
} foundViruses;
|
||||
} AVClient;
|
||||
|
||||
typedef struct _AVirusGlobals {
|
||||
AVirusStates state;
|
||||
AVirusFlags flags;
|
||||
|
||||
struct {
|
||||
XplSemaphore semaphore;
|
||||
|
||||
struct {
|
||||
XplSemaphore todo;
|
||||
|
||||
XplAtomic maximum;
|
||||
XplAtomic active;
|
||||
XplAtomic idle;
|
||||
|
||||
Connection *head;
|
||||
Connection *tail;
|
||||
} worker;
|
||||
|
||||
struct {
|
||||
BOOL enable;
|
||||
|
||||
ConnSSLConfiguration config;
|
||||
|
||||
bongo_ssl_context *context;
|
||||
|
||||
Connection *conn;
|
||||
} ssl;
|
||||
|
||||
Connection *conn;
|
||||
|
||||
void *pool;
|
||||
|
||||
time_t sleepTime;
|
||||
|
||||
unsigned long queue;
|
||||
|
||||
unsigned char address[80];
|
||||
unsigned char hash[NMAP_HASH_SIZE];
|
||||
} nmap;
|
||||
|
||||
struct {
|
||||
XplThreadID main; /* Tid */
|
||||
XplThreadID group; /* TGid */
|
||||
|
||||
XplSemaphore semaphore;
|
||||
|
||||
unsigned long next;
|
||||
XplThreadID main;
|
||||
XplThreadID group;
|
||||
} id;
|
||||
|
||||
struct {
|
||||
XplRWLock config; /* */
|
||||
XplRWLock pattern;
|
||||
} lock;
|
||||
|
||||
struct {
|
||||
unsigned char work[XPL_MAX_PATH + 1];
|
||||
unsigned char *patterns;
|
||||
} path;
|
||||
|
||||
struct {
|
||||
XplSemaphore main;
|
||||
XplSemaphore shutdown;
|
||||
@@ -192,33 +111,28 @@ typedef struct _AVirusGlobals {
|
||||
} server;
|
||||
|
||||
struct {
|
||||
struct {
|
||||
XplAtomic scanned; /* Scanned */
|
||||
} messages;
|
||||
|
||||
struct {
|
||||
XplAtomic scanned; /* Scanned */
|
||||
XplAtomic blocked; /* Blocked */
|
||||
} attachments;
|
||||
|
||||
XplAtomic viruses; /* Viruses */
|
||||
XplAtomic called;
|
||||
} stats;
|
||||
|
||||
struct {
|
||||
BongoArray *hostlist;
|
||||
AddressPool hosts;
|
||||
int timeout;
|
||||
} clam;
|
||||
BongoArray *hostlist;
|
||||
BOOL enabled;
|
||||
unsigned long connectionTimeout;
|
||||
} clamd;
|
||||
|
||||
BongoAgent agent;
|
||||
void *QueueMemPool;
|
||||
BongoThreadPool *QueueThreadPool;
|
||||
Connection *QueueConnection;
|
||||
} AVirusGlobals;
|
||||
|
||||
extern AVirusGlobals AVirus;
|
||||
|
||||
/* mime.c */
|
||||
void ClearMIMECache(AVClient *client);
|
||||
int LoadMIMECache(AVClient *client);
|
||||
/* spamd.c */
|
||||
BOOL VirusCheck(AVirusClient *client, const char *queueID, BOOL hasFlags, unsigned long msgFlags, unsigned long senderIp, char *senderUserName);
|
||||
void VirusShutdown();
|
||||
void VirusStartup();
|
||||
BOOL VirusReadConfiguration(BongoJsonNode *node);
|
||||
|
||||
/* stream.c */
|
||||
BOOL MWHandleNamedTemplate(void *ignored1, unsigned char *ignored2, void *ignored3);
|
||||
int StreamAttachmentToFile(AVClient *client, unsigned char *queueID, AVMIME *mime);
|
||||
|
||||
#endif /* _AVIRUS_H */
|
||||
#endif /* _ANTIVIRUS_H */
|
||||
|
||||
Reference in New Issue
Block a user