summaryrefslogtreecommitdiff
path: root/mail/p3scan/files/patch-p3scan.c
diff options
context:
space:
mode:
Diffstat (limited to 'mail/p3scan/files/patch-p3scan.c')
-rw-r--r--mail/p3scan/files/patch-p3scan.c109
1 files changed, 58 insertions, 51 deletions
diff --git a/mail/p3scan/files/patch-p3scan.c b/mail/p3scan/files/patch-p3scan.c
index 08cd4fdc9db0..fae28f2ce0c9 100644
--- a/mail/p3scan/files/patch-p3scan.c
+++ b/mail/p3scan/files/patch-p3scan.c
@@ -1,9 +1,9 @@
---- p3scan.c.orig Wed Jan 21 01:26:48 2004
-+++ p3scan.c Wed Feb 18 13:32:33 2004
-@@ -30,34 +30,39 @@
- *
- */
-
+--- p3scan.c.orig Thu Jan 6 04:53:04 2005
++++ p3scan.c Fri Jul 29 10:10:15 2005
+@@ -36,36 +36,38 @@
+ TODO: Wanted: white-list support
+ TODO: Wanted: no iptables support
+ */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
@@ -18,6 +18,7 @@
+#include <sys/param.h>
+#include <sys/signal.h>
#include <sys/stat.h>
++#include <sys/statvfs.h>
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
@@ -43,17 +44,16 @@
#include <libgen.h>
#include <errno.h>
#include <dirent.h>
-+#ifdef __FreeBSD__
+-#include <sys/statvfs.h>
+ #include <assert.h>
+ #include <sys/select.h>
+#include <sys/ucred.h>
+#include <sys/mount.h>
-+#else
-+#include <linux/netfilter_ipv4.h>
- #include <sys/statvfs.h>
-+#endif
++
#include "p3scan.h"
#include "getline.h"
-@@ -81,8 +86,8 @@
+@@ -94,13 +96,13 @@
#define VIRUS_SCANNER_VIRUSCODE 1
#define PID_FILE "/var/run/p3scan/p3scan.pid"
#define SYSLOG_NAME "p3scan"
@@ -63,18 +63,22 @@
+#define VIRUS_TEMPLATE "/usr/local/etc/p3scan/p3scan.mail"
#define DEBUG 0
#define QUIET 0
- #define OVERWRITE 0
-@@ -340,11 +345,24 @@
- #define MOVEIT "/bin/mv"
+ #define OVERWRITE NULL
+ #define CHECKSPAM 0
+-#define SPAMCHECK "/usr/bin/spamc"
++#define SPAMCHECK "/usr/local/bin/spamc"
+ #define MINSPACE 0
+ #define DELIT 0
+ #define NEWLINE '\n'
+@@ -507,10 +509,21 @@
FILE * scanner;
static char line[4096*16];
+ //static char line[4096];
- struct statvfs fs;
- int kbfree;
- struct linebuf *filebuf;
- int res, htmlfd, html, toggle;
+ unsigned long kbfree;
+ int htmlfd;
-+#ifdef __FreeBSD__
-+ struct statfs fs;
++ struct statfs fs;
+ if ((ret=statfs(config->virusdir,&fs))!=0) {
+ do_log(LOG_EMERG, "Unable to get available space!");
+ return SCANNER_RET_CRIT; // Should never reach here, but keep it clean. :)
@@ -84,32 +88,34 @@
+ do_log(LOG_CRIT, "Not enough space! Available space: %d", kbfree);
+ return SCANNER_RET_CRIT;
+ }
-+#else
-+ struct statvfs fs;
+
- /* See if we have enough room to process the message based upon
- what the user determines is enough room in p3scan.conf */
- if ( statvfs( config->virusdir, &fs ) == SCANNER_RET_ERR){
-@@ -356,6 +374,7 @@
- do_log(LOG_CRIT, "Not enough space! Available space: %d", kbfree);
- return SCANNER_RET_CRIT;
++
+ ret=checktimeout(p);
+ if (ret < 0) return SCANNER_RET_CRIT;
+ /* See if we have enough room to process the message based upon
+@@ -521,7 +534,7 @@
+ do_log(LOG_EMERG, "Unable to get available space!");
+ return SCANNER_RET_CRIT; // Should never reach here, but keep it clean. :)
}
-+#endif
-
- /* This is where we should scan for spam - before demime to
- give SpamAssassin the virgin message */
-@@ -820,8 +839,8 @@
- do_log(LOG_NOTICE, "Connection from %s:%i", inet_ntoa(p->client_addr.sin_addr), ntohs(p->client_addr.sin_port));
+- kbfree=(fs.f_bavail * fs.f_frsize / 1024);
++ kbfree=(fs.f_bavail * fs.f_bsize / 1024);
+ if ( config->freespace != 0 && kbfree < config->freespace ){
+ p->errmsg=1;
+ do_log(LOG_CRIT, "Not enough space! Available space: %d", kbfree);
+@@ -1179,8 +1192,10 @@
p->server_addr.sin_family = AF_INET;
-- if (getsockopt(p->client_fd, SOL_IP, SO_ORIGINAL_DST, &p->server_addr, &p->socksize)){
-- do_log(LOG_CRIT, "No IP-Conntrack-data (getsockopt failed)");
+ if (htonl(INADDR_ANY) == config->targetaddr.sin_addr.s_addr) {
+- if (getsockopt(p->client_fd, SOL_IP, SO_ORIGINAL_DST, &p->server_addr, &p->socksize)){
+- do_log(LOG_CRIT, "No IP-Conntrack-data (getsockopt failed)");
++// if (getsockopt(p->client_fd, SOL_IP, SO_ORIGINAL_DST, &p->server_addr, &p->socksize)){
++// do_log(LOG_CRIT, "No IP-Conntrack-data (getsockopt failed)");
+ if (getsockname(p->client_fd, (struct sockaddr*)&p->server_addr, &p->socksize)){
+ do_log(LOG_CRIT, "No IP-Conntrack-data (getsockname failed)");
- return 1;
- }
- do_log(LOG_NOTICE, "Real-server adress is %s:%i", inet_ntoa(p->server_addr.sin_addr), ntohs(p->server_addr.sin_port));
-@@ -1534,7 +1553,7 @@
+ return 1;
+ }
+ /* try to avoid loop */
+@@ -2041,7 +2056,7 @@
char * responsemsg;
int virusdirlen;
char chownit[100];
@@ -118,14 +124,15 @@
int len;
int ret;
FILE * chowncmd;
-@@ -1574,8 +1593,8 @@
- };
- // chown /var/run/p3scan/p3scan.pid mail.mail
- len=strlen(CHOWNCMD)+1+strlen(config->runasuser)+1+strlen(config->runasuser)+1+strlen(config->pidfile)+1;
-- do_log(LOG_DEBUG, "%s %s.%s %s=%i",CHOWNCMD, config->runasuser, config->runasuser, config->pidfile, len);
-- snprintf(chownit, len, "%s %s.%s %s", CHOWNCMD, config->runasuser, config->runasuser, config->pidfile);
-+ do_log(LOG_DEBUG, "%s %s:%s %s=%i",CHOWNCMD, config->runasuser, config->runasuser, config->pidfile, len);
-+ snprintf(chownit, len, "%s %s:%s %s", CHOWNCMD, config->runasuser, config->runasuser, config->pidfile);
- if ((chowncmd=popen(chownit, "r"))==NULL){
- do_log(LOG_ALERT, "Can't '%s' !!!", chowncmd);
- return SCANNER_RET_ERR;
+@@ -2080,7 +2095,10 @@
+ if (!config->debug){
+ len=strlen(CHOWNCMD)+1+strlen(config->runasuser)+1+strlen(config->runasuser)+1+strlen(config->pidfile)+1;
+ //do_log(LOG_DEBUG, "%s %s.%s %s=%i",CHOWNCMD, config->runasuser, config->runasuser, config->pidfile, len);
+- snprintf(chownit, len, "%s %s.%s %s", CHOWNCMD, config->runasuser, config->runasuser, config->pidfile);
++// snprintf(chownit, len, "%s %s.%s %s", CHOWNCMD, config->runasuser, config->runasuser, config->pidfile);
++ do_log(LOG_DEBUG, "%s %s:%s %s=%i",CHOWNCMD, config->runasuser, config->runasuser, config->pidfile, len);
++ snprintf(chownit, len, "%s %s:%s %s", CHOWNCMD, config->runasuser, config->runasuser, config->pidfile);
++
+ if ((chowncmd=popen(chownit, "r"))==NULL){
+ do_log(LOG_ALERT, "Can't '%s' !!!", chowncmd);
+ return SCANNER_RET_ERR;