Lines 1-9
Link Here
|
1 |
--- p3scan.c.orig Wed Jan 21 01:26:48 2004 |
1 |
--- p3scan.c.orig Tue Jul 26 15:39:29 2005 |
2 |
+++ p3scan.c Wed Feb 18 13:32:33 2004 |
2 |
+++ p3scan.c Tue Jul 26 15:38:58 2005 |
3 |
@@ -30,34 +30,39 @@ |
3 |
@@ -36,36 +36,37 @@ |
4 |
* |
4 |
TODO: Wanted: white-list support |
5 |
*/ |
5 |
TODO: Wanted: no iptables support |
6 |
|
6 |
*/ |
7 |
-#include <stdio.h> |
7 |
-#include <stdio.h> |
8 |
-#include <stdlib.h> |
8 |
-#include <stdlib.h> |
9 |
-#include <string.h> |
9 |
-#include <string.h> |
Lines 43-59
Link Here
|
43 |
#include <libgen.h> |
43 |
#include <libgen.h> |
44 |
#include <errno.h> |
44 |
#include <errno.h> |
45 |
#include <dirent.h> |
45 |
#include <dirent.h> |
46 |
+#ifdef __FreeBSD__ |
46 |
-#include <sys/statvfs.h> |
|
|
47 |
#include <assert.h> |
48 |
#include <sys/select.h> |
47 |
+#include <sys/ucred.h> |
49 |
+#include <sys/ucred.h> |
48 |
+#include <sys/mount.h> |
50 |
+#include <sys/mount.h> |
49 |
+#else |
51 |
+ |
50 |
+#include <linux/netfilter_ipv4.h> |
|
|
51 |
#include <sys/statvfs.h> |
52 |
+#endif |
53 |
|
52 |
|
54 |
#include "p3scan.h" |
53 |
#include "p3scan.h" |
55 |
#include "getline.h" |
54 |
#include "getline.h" |
56 |
@@ -81,8 +86,8 @@ |
55 |
@@ -94,13 +95,13 @@ |
57 |
#define VIRUS_SCANNER_VIRUSCODE 1 |
56 |
#define VIRUS_SCANNER_VIRUSCODE 1 |
58 |
#define PID_FILE "/var/run/p3scan/p3scan.pid" |
57 |
#define PID_FILE "/var/run/p3scan/p3scan.pid" |
59 |
#define SYSLOG_NAME "p3scan" |
58 |
#define SYSLOG_NAME "p3scan" |
Lines 63-80
Link Here
|
63 |
+#define VIRUS_TEMPLATE "/usr/local/etc/p3scan/p3scan.mail" |
62 |
+#define VIRUS_TEMPLATE "/usr/local/etc/p3scan/p3scan.mail" |
64 |
#define DEBUG 0 |
63 |
#define DEBUG 0 |
65 |
#define QUIET 0 |
64 |
#define QUIET 0 |
66 |
#define OVERWRITE 0 |
65 |
#define OVERWRITE NULL |
67 |
@@ -340,11 +345,24 @@ |
66 |
#define CHECKSPAM 0 |
68 |
#define MOVEIT "/bin/mv" |
67 |
-#define SPAMCHECK "/usr/bin/spamc" |
|
|
68 |
+#define SPAMCHECK "/usr/local/bin/spamc" |
69 |
#define MINSPACE 0 |
70 |
#define DELIT 0 |
71 |
#define NEWLINE '\n' |
72 |
@@ -507,10 +508,21 @@ |
69 |
FILE * scanner; |
73 |
FILE * scanner; |
70 |
static char line[4096*16]; |
74 |
static char line[4096*16]; |
|
|
75 |
//static char line[4096]; |
71 |
- struct statvfs fs; |
76 |
- struct statvfs fs; |
72 |
int kbfree; |
77 |
unsigned long kbfree; |
73 |
struct linebuf *filebuf; |
78 |
int htmlfd; |
74 |
int res, htmlfd, html, toggle; |
|
|
75 |
|
79 |
|
76 |
+#ifdef __FreeBSD__ |
80 |
+ struct statfs fs; |
77 |
+ struct statfs fs; |
|
|
78 |
+ if ((ret=statfs(config->virusdir,&fs))!=0) { |
81 |
+ if ((ret=statfs(config->virusdir,&fs))!=0) { |
79 |
+ do_log(LOG_EMERG, "Unable to get available space!"); |
82 |
+ do_log(LOG_EMERG, "Unable to get available space!"); |
80 |
+ return SCANNER_RET_CRIT; // Should never reach here, but keep it clean. :) |
83 |
+ return SCANNER_RET_CRIT; // Should never reach here, but keep it clean. :) |
Lines 84-115
Link Here
|
84 |
+ do_log(LOG_CRIT, "Not enough space! Available space: %d", kbfree); |
87 |
+ do_log(LOG_CRIT, "Not enough space! Available space: %d", kbfree); |
85 |
+ return SCANNER_RET_CRIT; |
88 |
+ return SCANNER_RET_CRIT; |
86 |
+ } |
89 |
+ } |
87 |
+#else |
|
|
88 |
+ struct statvfs fs; |
89 |
+ |
90 |
+ |
90 |
/* See if we have enough room to process the message based upon |
91 |
+ |
91 |
what the user determines is enough room in p3scan.conf */ |
92 |
ret=checktimeout(p); |
92 |
if ( statvfs( config->virusdir, &fs ) == SCANNER_RET_ERR){ |
93 |
if (ret < 0) return SCANNER_RET_CRIT; |
93 |
@@ -356,6 +374,7 @@ |
94 |
/* See if we have enough room to process the message based upon |
94 |
do_log(LOG_CRIT, "Not enough space! Available space: %d", kbfree); |
95 |
@@ -521,7 +533,7 @@ |
95 |
return SCANNER_RET_CRIT; |
96 |
do_log(LOG_EMERG, "Unable to get available space!"); |
|
|
97 |
return SCANNER_RET_CRIT; // Should never reach here, but keep it clean. :) |
96 |
} |
98 |
} |
97 |
+#endif |
99 |
- kbfree=(fs.f_bavail * fs.f_frsize / 1024); |
98 |
|
100 |
+ kbfree=(fs.f_bavail * fs.f_bsize / 1024); |
99 |
/* This is where we should scan for spam - before demime to |
101 |
if ( config->freespace != 0 && kbfree < config->freespace ){ |
100 |
give SpamAssassin the virgin message */ |
102 |
p->errmsg=1; |
101 |
@@ -820,8 +839,8 @@ |
103 |
do_log(LOG_CRIT, "Not enough space! Available space: %d", kbfree); |
102 |
do_log(LOG_NOTICE, "Connection from %s:%i", inet_ntoa(p->client_addr.sin_addr), ntohs(p->client_addr.sin_port)); |
104 |
@@ -1179,8 +1191,10 @@ |
103 |
|
105 |
|
104 |
p->server_addr.sin_family = AF_INET; |
106 |
p->server_addr.sin_family = AF_INET; |
105 |
- if (getsockopt(p->client_fd, SOL_IP, SO_ORIGINAL_DST, &p->server_addr, &p->socksize)){ |
107 |
if (htonl(INADDR_ANY) == config->targetaddr.sin_addr.s_addr) { |
106 |
- do_log(LOG_CRIT, "No IP-Conntrack-data (getsockopt failed)"); |
108 |
- if (getsockopt(p->client_fd, SOL_IP, SO_ORIGINAL_DST, &p->server_addr, &p->socksize)){ |
|
|
109 |
- do_log(LOG_CRIT, "No IP-Conntrack-data (getsockopt failed)"); |
110 |
+// if (getsockopt(p->client_fd, SOL_IP, SO_ORIGINAL_DST, &p->server_addr, &p->socksize)){ |
111 |
+// do_log(LOG_CRIT, "No IP-Conntrack-data (getsockopt failed)"); |
107 |
+ if (getsockname(p->client_fd, (struct sockaddr*)&p->server_addr, &p->socksize)){ |
112 |
+ if (getsockname(p->client_fd, (struct sockaddr*)&p->server_addr, &p->socksize)){ |
108 |
+ do_log(LOG_CRIT, "No IP-Conntrack-data (getsockname failed)"); |
113 |
+ do_log(LOG_CRIT, "No IP-Conntrack-data (getsockname failed)"); |
109 |
return 1; |
114 |
return 1; |
110 |
} |
115 |
} |
111 |
do_log(LOG_NOTICE, "Real-server adress is %s:%i", inet_ntoa(p->server_addr.sin_addr), ntohs(p->server_addr.sin_port)); |
116 |
/* try to avoid loop */ |
112 |
@@ -1534,7 +1553,7 @@ |
117 |
@@ -2041,7 +2055,7 @@ |
113 |
char * responsemsg; |
118 |
char * responsemsg; |
114 |
int virusdirlen; |
119 |
int virusdirlen; |
115 |
char chownit[100]; |
120 |
char chownit[100]; |
Lines 118-131
Link Here
|
118 |
int len; |
123 |
int len; |
119 |
int ret; |
124 |
int ret; |
120 |
FILE * chowncmd; |
125 |
FILE * chowncmd; |
121 |
@@ -1574,8 +1593,8 @@ |
126 |
@@ -2080,7 +2094,10 @@ |
122 |
}; |
127 |
if (!config->debug){ |
123 |
// chown /var/run/p3scan/p3scan.pid mail.mail |
128 |
len=strlen(CHOWNCMD)+1+strlen(config->runasuser)+1+strlen(config->runasuser)+1+strlen(config->pidfile)+1; |
124 |
len=strlen(CHOWNCMD)+1+strlen(config->runasuser)+1+strlen(config->runasuser)+1+strlen(config->pidfile)+1; |
129 |
//do_log(LOG_DEBUG, "%s %s.%s %s=%i",CHOWNCMD, config->runasuser, config->runasuser, config->pidfile, len); |
125 |
- do_log(LOG_DEBUG, "%s %s.%s %s=%i",CHOWNCMD, config->runasuser, config->runasuser, config->pidfile, len); |
130 |
- snprintf(chownit, len, "%s %s.%s %s", CHOWNCMD, config->runasuser, config->runasuser, config->pidfile); |
126 |
- snprintf(chownit, len, "%s %s.%s %s", CHOWNCMD, config->runasuser, config->runasuser, config->pidfile); |
131 |
+// snprintf(chownit, len, "%s %s.%s %s", CHOWNCMD, config->runasuser, config->runasuser, config->pidfile); |
127 |
+ do_log(LOG_DEBUG, "%s %s:%s %s=%i",CHOWNCMD, config->runasuser, config->runasuser, config->pidfile, len); |
132 |
+ do_log(LOG_DEBUG, "%s %s:%s %s=%i",CHOWNCMD, config->runasuser, config->runasuser, config->pidfile, len); |
128 |
+ snprintf(chownit, len, "%s %s:%s %s", CHOWNCMD, config->runasuser, config->runasuser, config->pidfile); |
133 |
+ snprintf(chownit, len, "%s %s:%s %s", CHOWNCMD, config->runasuser, config->runasuser, config->pidfile); |
129 |
if ((chowncmd=popen(chownit, "r"))==NULL){ |
134 |
+ |
130 |
do_log(LOG_ALERT, "Can't '%s' !!!", chowncmd); |
135 |
if ((chowncmd=popen(chownit, "r"))==NULL){ |
131 |
return SCANNER_RET_ERR; |
136 |
do_log(LOG_ALERT, "Can't '%s' !!!", chowncmd); |
|
|
137 |
return SCANNER_RET_ERR; |