Lines 1-6
Link Here
|
1 |
--- p3scan.c.origThu Jan 6 04:53:04 2005 |
1 |
--- p3scan.c.origMon Dec 12 18:00:00 2005 |
2 |
+++ p3scan.cFri Jul 29 10:10:15 2005 |
2 |
+++ p3scan.cMon May 1 00:45:41 2006 |
3 |
@@ -36,36 +36,38 @@ |
3 |
@@ -41,36 +41,37 @@ |
4 |
TODO: Wanted: white-list support |
4 |
TODO: Wanted: white-list support |
5 |
TODO: Wanted: no iptables support |
5 |
TODO: Wanted: no iptables support |
6 |
*/ |
6 |
*/ |
Lines 49-138
Link Here
|
49 |
#include <sys/select.h> |
49 |
#include <sys/select.h> |
50 |
+#include <sys/ucred.h> |
50 |
+#include <sys/ucred.h> |
51 |
+#include <sys/mount.h> |
51 |
+#include <sys/mount.h> |
52 |
+ |
|
|
53 |
|
52 |
|
54 |
#include "p3scan.h" |
53 |
#include "p3scan.h" |
55 |
#include "getline.h" |
54 |
#include "getline_ssl.h" |
56 |
@@ -94,13 +96,13 @@ |
55 |
@@ -1640,8 +1641,9 @@ |
57 |
#define VIRUS_SCANNER_VIRUSCODE 1 |
|
|
58 |
#define PID_FILE "/var/run/p3scan/p3scan.pid" |
59 |
#define SYSLOG_NAME "p3scan" |
60 |
-#define CONFIGFILE "/etc/p3scan/p3scan.conf" |
61 |
-#define VIRUS_TEMPLATE "/etc/p3scan/p3scan.mail" |
62 |
+#define CONFIGFILE "/usr/local/etc/p3scan/p3scan.conf" |
63 |
+#define VIRUS_TEMPLATE "/usr/local/etc/p3scan/p3scan.mail" |
64 |
#define DEBUG 0 |
65 |
#define QUIET 0 |
66 |
#define OVERWRITE NULL |
67 |
#define CHECKSPAM 0 |
68 |
-#define SPAMCHECK "/usr/bin/spamc" |
69 |
+#define SPAMCHECK "/usr/local/bin/spamc" |
70 |
#define MINSPACE 0 |
71 |
#define DELIT 0 |
72 |
#define NEWLINE '\n' |
73 |
@@ -507,10 +509,21 @@ |
74 |
FILE * scanner; |
75 |
static char line[4096*16]; |
76 |
//static char line[4096]; |
77 |
- struct statvfs fs; |
78 |
unsigned long kbfree; |
79 |
int htmlfd; |
80 |
|
81 |
+ struct statfs fs; |
82 |
+ if ((ret=statfs(config->virusdir,&fs))!=0) { |
83 |
+ do_log(LOG_EMERG, "Unable to get available space!"); |
84 |
+ return SCANNER_RET_CRIT; // Should never reach here, but keep it clean. :) |
85 |
+ } |
86 |
+ kbfree=fs.f_bavail*fs.f_bsize/1024; |
87 |
+ if ( config->freespace != 0 && kbfree < config->freespace ){ |
88 |
+ do_log(LOG_CRIT, "Not enough space! Available space: %d", kbfree); |
89 |
+ return SCANNER_RET_CRIT; |
90 |
+ } |
91 |
+ |
92 |
+ |
93 |
ret=checktimeout(p); |
94 |
if (ret < 0) return SCANNER_RET_CRIT; |
95 |
/* See if we have enough room to process the message based upon |
96 |
@@ -521,7 +534,7 @@ |
97 |
do_log(LOG_EMERG, "Unable to get available space!"); |
98 |
return SCANNER_RET_CRIT; // Should never reach here, but keep it clean. :) |
99 |
} |
100 |
- kbfree=(fs.f_bavail * fs.f_frsize / 1024); |
101 |
+ kbfree=(fs.f_bavail * fs.f_bsize / 1024); |
102 |
if ( config->freespace != 0 && kbfree < config->freespace ){ |
103 |
p->errmsg=1; |
104 |
do_log(LOG_CRIT, "Not enough space! Available space: %d", kbfree); |
105 |
@@ -1179,8 +1192,10 @@ |
106 |
|
107 |
p->server_addr.sin_family = AF_INET; |
108 |
if (htonl(INADDR_ANY) == config->targetaddr.sin_addr.s_addr) { |
109 |
- if (getsockopt(p->client_fd, SOL_IP, SO_ORIGINAL_DST, &p->server_addr, &p->socksize)){ |
110 |
- do_log(LOG_CRIT, "No IP-Conntrack-data (getsockopt failed)"); |
111 |
+// if (getsockopt(p->client_fd, SOL_IP, SO_ORIGINAL_DST, &p->server_addr, &p->socksize)){ |
112 |
+// do_log(LOG_CRIT, "No IP-Conntrack-data (getsockopt failed)"); |
113 |
+ if (getsockname(p->client_fd, (struct sockaddr*)&p->server_addr, &p->socksize)){ |
114 |
+ do_log(LOG_CRIT, "No IP-Conntrack-data (getsockname failed)"); |
115 |
return 1; |
116 |
} |
56 |
} |
117 |
/* try to avoid loop */ |
57 |
} else { |
118 |
@@ -2041,7 +2056,7 @@ |
58 |
if (htonl(INADDR_ANY) == config->targetaddr.sin_addr.s_addr) { |
|
|
59 |
- if (getsockopt(p->client_fd, SOL_IP, SO_ORIGINAL_DST, &p->server_addr, &p->socksize)){ |
60 |
- do_log(LOG_CRIT, "ERR: No IP-Conntrack-data (getsockopt failed)"); |
61 |
+ // if (getsockopt(p->client_fd, SOL_IP, SO_ORIGINAL_DST, &p->server_addr, &p->socksize)){ |
62 |
+ // do_log(LOG_CRIT, "ERR: No IP-Conntrack-data (getsockopt failed)"); |
63 |
+ if (getsockname(p->client_fd, (struct sockaddr*)&p->server_addr, &p->socksize)){ |
64 |
return 1; |
65 |
} |
66 |
/* try to avoid loop */ |
67 |
@@ -2882,7 +2884,7 @@ |
119 |
char * responsemsg; |
68 |
char * responsemsg; |
120 |
int virusdirlen; |
69 |
int virusdirlen=0; |
121 |
char chownit[100]; |
70 |
char chownit[100]; |
122 |
-#define CHOWNCMD "/bin/chown" |
71 |
-#define CHOWNCMD "/bin/chown" |
123 |
+#define CHOWNCMD "/usr/sbin/chown" |
72 |
+#define CHOWNCMD "/usr/sbin/chown" |
124 |
int len; |
73 |
int len=0; |
125 |
int ret; |
74 |
int ret=0; |
126 |
FILE * chowncmd; |
75 |
FILE * chowncmd; |
127 |
@@ -2080,7 +2095,10 @@ |
76 |
@@ -2920,7 +2922,8 @@ |
128 |
if (!config->debug){ |
77 |
fclose(fp); |
129 |
len=strlen(CHOWNCMD)+1+strlen(config->runasuser)+1+strlen(config->runasuser)+1+strlen(config->pidfile)+1; |
78 |
}else do_log(LOG_CRIT, "ERR: Can't write PID to %s", PID_FILE); |
130 |
//do_log(LOG_DEBUG, "%s %s.%s %s=%i",CHOWNCMD, config->runasuser, config->runasuser, config->pidfile, len); |
79 |
len=strlen(CHOWNCMD)+1+strlen(config->runasuser)+1+strlen(config->runasuser)+1+strlen(config->pidfile)+1; |
131 |
- snprintf(chownit, len, "%s %s.%s %s", CHOWNCMD, config->runasuser, config->runasuser, config->pidfile); |
80 |
- snprintf(chownit, len, "%s %s:%s %s", CHOWNCMD, config->runasuser, config->runasuser, config->pidfile); |
132 |
+// snprintf(chownit, len, "%s %s.%s %s", CHOWNCMD, config->runasuser, config->runasuser, config->pidfile); |
|
|
133 |
+ do_log(LOG_DEBUG, "%s %s:%s %s=%i",CHOWNCMD, config->runasuser, config->runasuser, config->pidfile, len); |
81 |
+ do_log(LOG_DEBUG, "%s %s:%s %s=%i",CHOWNCMD, config->runasuser, config->runasuser, config->pidfile, len); |
134 |
+ snprintf(chownit, len, "%s %s:%s %s", CHOWNCMD, config->runasuser, config->runasuser, config->pidfile); |
82 |
+ snprintf(chownit, len, "%s %s:%s %s", CHOWNCMD, config->runasuser, config->runasuser, config->pidfile); |
135 |
+ |
83 |
if ((chowncmd=popen(chownit, "r"))==NULL){ |
136 |
if ((chowncmd=popen(chownit, "r"))==NULL){ |
84 |
do_log(LOG_ALERT, "ERR: Can't '%s' !!!", chowncmd); |
137 |
do_log(LOG_ALERT, "Can't '%s' !!!", chowncmd); |
85 |
return SCANNER_RET_ERR; |
138 |
return SCANNER_RET_ERR; |
|
|