File: p3scan.h

package info (click to toggle)
p3scan 2%3A2.1-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,568 kB
  • ctags: 2,371
  • sloc: ansic: 12,072; makefile: 253; sh: 234
file content (177 lines) | stat: -rw-r--r-- 5,523 bytes parent folder | download | duplicates (2)
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
/*
 * P3Scan v2.1
 *
 * (C) 2003-2005 by Jack S. Lai <laitcg@cox.net>
 *
 * It's intent is to provide a follow on program to POP3-Virusscan-Proxy 0.4
 * by Folke Ashberg <folke@ashberg.de>.
 *
 * It is based upon his program but provides numerous changes to include
 * scanning pop3 mail for spam, hardening the program, addaption to todays
 * email environment, and many other changes.
 *
 * The initial release of p3scan includes patches made and submitted to the
 * original project but were never incorporated. Please see the README for
 * further information.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef _P3SCAN_H
#define _P3SCAN_H

#include <syslog.h>           /* do_log */
#include <arpa/inet.h>        /* config */

#define PROGNAME              "P3Scan"
#define VERSION               "2.1"
#define MAX_PSEUDO_ARGV       50
#define MESSAGE_NOVIRINFO     "<no virusinfo could be examined>"
#define FILEDEL               "The infected message has been deleted."
#define SVRCMD                "NOOP"
#define PERIOD                "."
#define BOGUSX                "X-P3Scan: Due to an extremely large attachment you see this message line."

#define CONFIG_STATE_CMDPRE   1
#define CONFIG_STATE_FILE     2
#define CONFIG_STATE_CMD      3

#define SCANNER_INIT_NO       0
#define SCANNER_INIT_OK       1
#define SCANNER_INIT_NULL     2 /* scanner needs no init */
#define SCANNER_INIT_ERR      -1

#define SCANNER_RET_OK        0
#define SCANNER_RET_ERR       -1
#define SCANNER_RET_VIRUS     2
#define SCANNER_RET_CRIT      3

#define MAX_VIRUS_CODES       16

#if defined(__USE_FILE_OFFSET64) || defined(__USE_LARGEFILE64)
#define FSTAT(a, b) fstat64(a,b)
#define LSTAT(a, b) lstat64(a,b)
#define STAT(a, b) stat64(a,b)
#define stat_t stat64
#else
#define FSTAT(a, b) fstat(a,b)
#define LSTAT(a, b) lstat(a,b)
#define STAT(a, b) stat(a,b)
#define stat_t stat
#endif

#define SETIFNULL(a,b) if (!a) a=b  /* wow, that's magic */
#define NONULL(x) ( x==NULL ? "" : x) /* this is nice, found in the mutt code */

#define TRIM(a) \
{ \
   int len=0; \
   while ((a)[len] && isspace((a)[len])) len++; \
   memmove((a),&(a)[len], strlen(&(a)[len])+1); \
   while ((len=strlen(a))>0 && isspace((a)[len-1])) (a)[len-1]='\0'; \
}

typedef struct proxycontext {
   struct  linebuf   *serverbuf;
   struct  linebuf   *clientbuf;
   struct  linebuf   *hdrbuf;
   struct  sockaddr_in   client_addr;
   struct  sockaddr_in   server_addr;
   size_t        socksize;
   off_t         hdroffset;
   time_t        now;
   int           client_fd;
   int           server_fd;
   int           header_fd;
   int           ismail;
   unsigned int  msgnum;
   int           header_exists;
   int           fakehdrdone;
   int           notified;
   int           noop;
   int           errmsg;
   struct paramlist *params;
   int           mailcount;
   unsigned long bytecount;
   int           gobogus;
   int           boguspos;
   int           hdrdate;
   int           hdrfrom;
   int           hdrto;
   char          mailfile[4096];
   char          maildir[4096]; /* mailfile.content */
   char          p3shdrfile[4096];
   char          cbuff[1];
   char          * filename;
   char          * scanthis; /* depending on demime linked to mailfile / maildir */
   char          * virinfo; /* has to be filled from the scanner */
   char          * filestatus; /* infected mail kept or deleted */
   int           scannerinit; /* see SCANNER_INIT_* */
} proxycontext;

typedef struct scanner_t {
   char    *name;
   char    *descr;
   int     (*init1)(void);
   int     (*init2)(struct proxycontext *);
   int     (*scan)(struct proxycontext *, char ** virname);
   void    (*uninit2)(struct proxycontext *);
   void    (*uninit1)(void);
   int     dirscan;
} scanner_t;


typedef struct configuration_t {
   int         maxchilds;
   char *      renattach;
   char *      runasuser;
   char *      virusdirbase;
   char *      virusdir;
   char *      notifydir;
   char *      virustemplate;
   char *      virusscanner;
   int         viruscode[MAX_VIRUS_CODES + 1];
   int         gvcode[MAX_VIRUS_CODES + 1];
   char *      virusregexp;
   int         virusregexpsub;
   int         demime;
   char *      pidfile;
   char *      syslogname;
   char *      configfile;
   int         debug;
   char *      overwrite;
   struct      sockaddr_in addr;
   struct      sockaddr_in targetaddr;
   scanner_t * scanner;
   int         scannerenabled;
   int         quiet;
   int         checkspam;
   char *      spamcheck;
   unsigned long freespace;
   int         delit;
   char *      dspamuser;
   int         ispam;
   int         broken;
   char *      subject;
   char *      notify;
   char *      ispspam;
} configuration_t;

extern void do_log(int level, const char *fmt,...);

void context_uninit(struct proxycontext * p);

#endif