git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@927 77e5149b-7576-45b1-b177-96237e5ba77b
Nigel Horne authored on 2004/09/26 00:49:45... | ... |
@@ -1,3 +1,10 @@ |
1 |
+Sat Sep 25 16:48:18 BST 2004 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * clamav-milter: Didn't compile with some older Linuxes |
|
4 |
+ Honour LogFacility |
|
5 |
+ When sanitising the quarantine's filename, don't |
|
6 |
+ sanitise the directory name as well |
|
7 |
+ |
|
1 | 8 |
Fri Sep 24 09:14:44 BST 2004 (trog) |
2 | 9 |
----------------------------------- |
3 | 10 |
* libclamav/filetypes.c: Add more HTML markers |
... | ... |
@@ -117,9 +117,9 @@ I suggest putting SpamAssassin first since you're more likely to get spam |
117 | 117 |
than a virus/worm sent to you. |
118 | 118 |
|
119 | 119 |
Add to /etc/sysconfig/clamav-milter |
120 |
- CLAMAV_FLAGS="--max-children=2 local:/var/run/clamav/clmilter.sock" |
|
120 |
+ CLAMAV_FLAGS="local:/var/run/clamav/clmilter.sock" |
|
121 | 121 |
or if clamd is on a different machine |
122 |
- CLAMAV_FLAGS="--max-children=2 --server=192.168.1.9 local:/var/run/clamav/clmilter.sock" |
|
122 |
+ CLAMAV_FLAGS="--server=192.168.1.9 local:/var/run/clamav/clmilter.sock" |
|
123 | 123 |
|
124 | 124 |
If you want clamav-milter to listen on TCP for communication with sendmail, |
125 | 125 |
for example if they are on different machines use inet:<port>. |
... | ... |
@@ -497,6 +497,10 @@ Changes |
497 | 497 |
0.75s 20/9/04 StreamSaveToDisk is longer used |
498 | 498 |
Update references to clamav.conf, should now be clamd.conf |
499 | 499 |
0.80 20/9/04 Up-issued |
500 |
+0.80a 25/9/04 Some Linux's need locale.h as well as libintl.h |
|
501 |
+ Honour LogFacility |
|
502 |
+ When sanitising the quarantine's filename, don't sanitise |
|
503 |
+ the directory name as well |
|
500 | 504 |
|
501 | 505 |
INTERNATIONALISATION |
502 | 506 |
|
... | ... |
@@ -26,6 +26,9 @@ |
26 | 26 |
* |
27 | 27 |
* Change History: |
28 | 28 |
* $Log: clamav-milter.c,v $ |
29 |
+ * Revision 1.132 2004/09/25 15:47:19 nigelhorne |
|
30 |
+ * Honour LogFacility |
|
31 |
+ * |
|
29 | 32 |
* Revision 1.131 2004/09/20 12:46:05 nigelhorne |
30 | 33 |
* Up issued |
31 | 34 |
* |
... | ... |
@@ -404,9 +407,9 @@ |
404 | 404 |
* Revision 1.6 2003/09/28 16:37:23 nigelhorne |
405 | 405 |
* Added -f flag use MaxThreads if --max-children not set |
406 | 406 |
*/ |
407 |
-static char const rcsid[] = "$Id: clamav-milter.c,v 1.131 2004/09/20 12:46:05 nigelhorne Exp $"; |
|
407 |
+static char const rcsid[] = "$Id: clamav-milter.c,v 1.132 2004/09/25 15:47:19 nigelhorne Exp $"; |
|
408 | 408 |
|
409 |
-#define CM_VERSION "0.80" |
|
409 |
+#define CM_VERSION "0.80a" |
|
410 | 410 |
|
411 | 411 |
/*#define CONFDIR "/usr/local/etc"*/ |
412 | 412 |
|
... | ... |
@@ -436,9 +439,9 @@ static char const rcsid[] = "$Id: clamav-milter.c,v 1.131 2004/09/20 12:46:05 ni |
436 | 436 |
#include <string.h> |
437 | 437 |
#include <sys/wait.h> |
438 | 438 |
#include <assert.h> |
439 |
+#include <sys/socket.h> |
|
439 | 440 |
#include <netinet/in.h> |
440 | 441 |
#include <arpa/inet.h> |
441 |
-#include <sys/socket.h> |
|
442 | 442 |
#include <sys/un.h> |
443 | 443 |
#include <stdarg.h> |
444 | 444 |
#include <errno.h> |
... | ... |
@@ -454,6 +457,7 @@ static char const rcsid[] = "$Id: clamav-milter.c,v 1.131 2004/09/20 12:46:05 ni |
454 | 454 |
|
455 | 455 |
#ifdef C_LINUX |
456 | 456 |
#include <libintl.h> |
457 |
+#include <locale.h> |
|
457 | 458 |
|
458 | 459 |
#define gettext_noop(s) s |
459 | 460 |
#define _(s) gettext(s) |
... | ... |
@@ -491,7 +495,8 @@ typedef unsigned short in_port_t; |
491 | 491 |
|
492 | 492 |
/* |
493 | 493 |
* Do not define SESSION in a production environment - it has been known to put |
494 |
- * clamd/ into a loop and sending STREAM often returns EPIPE |
|
494 |
+ * clamd into a loop when clamav-milter is restarted and sending STREAM often |
|
495 |
+ * returns EPIPE |
|
495 | 496 |
* |
496 | 497 |
* It is however OK for testing: code is now in place to reopen as session |
497 | 498 |
* that has gone bad, and it would be useful to find out the set of |
... | ... |
@@ -616,6 +621,7 @@ static void clamdIsDown(void); |
616 | 616 |
#ifdef SESSION |
617 | 617 |
static void *watchdog(void *a); |
618 | 618 |
#endif |
619 |
+static int logg_facility(const char *name); |
|
619 | 620 |
|
620 | 621 |
static char clamav_version[128]; |
621 | 622 |
static int fflag = 0; /* force a scan, whatever */ |
... | ... |
@@ -1374,11 +1380,20 @@ main(int argc, char **argv) |
1374 | 1374 |
pidFile = cpt->strarg; |
1375 | 1375 |
|
1376 | 1376 |
if(cfgopt(copt, "LogSyslog")) { |
1377 |
+ int fac = LOG_LOCAL6; |
|
1378 |
+ |
|
1377 | 1379 |
if(cfgopt(copt, "LogVerbose")) |
1378 | 1380 |
logVerbose = 1; |
1379 | 1381 |
use_syslog = 1; |
1380 | 1382 |
|
1381 |
- openlog("clamav-milter", LOG_CONS|LOG_PID, LOG_MAIL); |
|
1383 |
+ if((cpt = cfgopt(copt, "LogFacility")) != NULL) |
|
1384 |
+ if((fac = logg_facility(cpt->strarg)) == -1) { |
|
1385 |
+ fprintf(stderr, "%s: LogFacility: %s: No such facility\n", |
|
1386 |
+ argv[0], cpt->strarg); |
|
1387 |
+ return EX_CONFIG; |
|
1388 |
+ } |
|
1389 |
+ |
|
1390 |
+ openlog("clamav-milter", LOG_CONS|LOG_PID, fac); |
|
1382 | 1391 |
if(logVerbose) |
1383 | 1392 |
syslog(LOG_INFO, _("Starting: %s"), clamav_version); |
1384 | 1393 |
else |
... | ... |
@@ -2780,6 +2795,7 @@ clamfi_free(struct privdata *privdata) |
2780 | 2780 |
#ifdef SESSION |
2781 | 2781 |
pthread_mutex_lock(&sstatus_mutex); |
2782 | 2782 |
if(cmdSocketsStatus[privdata->serverNumber] == CMDSOCKET_INUSE) { |
2783 |
+#if 0 |
|
2783 | 2784 |
pthread_mutex_unlock(&sstatus_mutex); |
2784 | 2785 |
if(readTimeout) { |
2785 | 2786 |
char buf[64]; |
... | ... |
@@ -2797,6 +2813,7 @@ clamfi_free(struct privdata *privdata) |
2797 | 2797 |
; |
2798 | 2798 |
} |
2799 | 2799 |
pthread_mutex_lock(&sstatus_mutex); |
2800 |
+#endif |
|
2800 | 2801 |
cmdSocketsStatus[privdata->serverNumber] = CMDSOCKET_FREE; |
2801 | 2802 |
} |
2802 | 2803 |
pthread_mutex_unlock(&sstatus_mutex); |
... | ... |
@@ -3540,13 +3557,16 @@ static int |
3540 | 3540 |
qfile(struct privdata *privdata, const char *virusname) |
3541 | 3541 |
{ |
3542 | 3542 |
char *newname, *ptr; |
3543 |
+ size_t len; |
|
3543 | 3544 |
|
3544 | 3545 |
assert(privdata != NULL); |
3545 | 3546 |
|
3546 | 3547 |
if((privdata->filename == NULL) || (virusname == NULL)) |
3547 | 3548 |
return -1; |
3548 | 3549 |
|
3549 |
- newname = cli_malloc(strlen(privdata->filename) + strlen(virusname) + 2); |
|
3550 |
+ len = strlen(privdata->filename); |
|
3551 |
+ |
|
3552 |
+ newname = cli_malloc(len + strlen(virusname) + 2); |
|
3550 | 3553 |
|
3551 | 3554 |
if(newname == NULL) |
3552 | 3555 |
return -1; |
... | ... |
@@ -3558,7 +3578,7 @@ qfile(struct privdata *privdata, const char *virusname) |
3558 | 3558 |
* that would cause the quarantine to fail to save since the name |
3559 | 3559 |
* of the virus is included in the filename |
3560 | 3560 |
*/ |
3561 |
- for(ptr = newname; *ptr; ptr++) { |
|
3561 |
+ for(ptr = &newname[len]; *ptr; ptr++) { |
|
3562 | 3562 |
#ifdef C_DARWIN |
3563 | 3563 |
*ptr &= '\177'; |
3564 | 3564 |
#endif |
... | ... |
@@ -3656,8 +3676,8 @@ clamfi_gethostbyname(const char *hostname, struct hostent *hp, char *buf, size_t |
3656 | 3656 |
* Check whether addr is on network by applying netmasks. |
3657 | 3657 |
* addr must be a 32-bit integer-packed IPv4 address in network order. |
3658 | 3658 |
* For example: |
3659 |
- * struct in_addr IPAddress; |
|
3660 |
- * isLocal = isLocalAddr(IPAddress.s_addr); |
|
3659 |
+ * struct in_addr IPAddress; |
|
3660 |
+ * isLocal = isLocalAddr(IPAddress.s_addr); |
|
3661 | 3661 |
*/ |
3662 | 3662 |
static int |
3663 | 3663 |
isLocalAddr(in_addr_t addr) |
... | ... |
@@ -3834,3 +3854,85 @@ watchdog(void *a) |
3834 | 3834 |
return NULL; |
3835 | 3835 |
} |
3836 | 3836 |
#endif |
3837 |
+ |
|
3838 |
+static const struct { |
|
3839 |
+ const char *name; |
|
3840 |
+ int code; |
|
3841 |
+} facilitymap[] = { |
|
3842 |
+#ifdef LOG_AUTH |
|
3843 |
+ { "LOG_AUTH", LOG_AUTH }, |
|
3844 |
+#endif |
|
3845 |
+#ifdef LOG_AUTHPRIV |
|
3846 |
+ { "LOG_AUTHPRIV", LOG_AUTHPRIV }, |
|
3847 |
+#endif |
|
3848 |
+#ifdef LOG_CRON |
|
3849 |
+ { "LOG_CRON", LOG_CRON }, |
|
3850 |
+#endif |
|
3851 |
+#ifdef LOG_DAEMON |
|
3852 |
+ { "LOG_DAEMON", LOG_DAEMON }, |
|
3853 |
+#endif |
|
3854 |
+#ifdef LOG_FTP |
|
3855 |
+ { "LOG_FTP", LOG_FTP }, |
|
3856 |
+#endif |
|
3857 |
+#ifdef LOG_KERN |
|
3858 |
+ { "LOG_KERN", LOG_KERN }, |
|
3859 |
+#endif |
|
3860 |
+#ifdef LOG_LPR |
|
3861 |
+ { "LOG_LPR", LOG_LPR }, |
|
3862 |
+#endif |
|
3863 |
+#ifdef LOG_MAIL |
|
3864 |
+ { "LOG_MAIL", LOG_MAIL }, |
|
3865 |
+#endif |
|
3866 |
+#ifdef LOG_NEWS |
|
3867 |
+ { "LOG_NEWS", LOG_NEWS }, |
|
3868 |
+#endif |
|
3869 |
+#ifdef LOG_AUTH |
|
3870 |
+ { "LOG_AUTH", LOG_AUTH }, |
|
3871 |
+#endif |
|
3872 |
+#ifdef LOG_SYSLOG |
|
3873 |
+ { "LOG_SYSLOG", LOG_SYSLOG }, |
|
3874 |
+#endif |
|
3875 |
+#ifdef LOG_USER |
|
3876 |
+ { "LOG_USER", LOG_USER }, |
|
3877 |
+#endif |
|
3878 |
+#ifdef LOG_UUCP |
|
3879 |
+ { "LOG_UUCP", LOG_UUCP }, |
|
3880 |
+#endif |
|
3881 |
+#ifdef LOG_LOCAL0 |
|
3882 |
+ { "LOG_LOCAL0", LOG_LOCAL0 }, |
|
3883 |
+#endif |
|
3884 |
+#ifdef LOG_LOCAL1 |
|
3885 |
+ { "LOG_LOCAL1", LOG_LOCAL1 }, |
|
3886 |
+#endif |
|
3887 |
+#ifdef LOG_LOCAL2 |
|
3888 |
+ { "LOG_LOCAL2", LOG_LOCAL2 }, |
|
3889 |
+#endif |
|
3890 |
+#ifdef LOG_LOCAL3 |
|
3891 |
+ { "LOG_LOCAL3", LOG_LOCAL3 }, |
|
3892 |
+#endif |
|
3893 |
+#ifdef LOG_LOCAL4 |
|
3894 |
+ { "LOG_LOCAL4", LOG_LOCAL4 }, |
|
3895 |
+#endif |
|
3896 |
+#ifdef LOG_LOCAL5 |
|
3897 |
+ { "LOG_LOCAL5", LOG_LOCAL5 }, |
|
3898 |
+#endif |
|
3899 |
+#ifdef LOG_LOCAL6 |
|
3900 |
+ { "LOG_LOCAL6", LOG_LOCAL6 }, |
|
3901 |
+#endif |
|
3902 |
+#ifdef LOG_LOCAL7 |
|
3903 |
+ { "LOG_LOCAL7", LOG_LOCAL7 }, |
|
3904 |
+#endif |
|
3905 |
+ { NULL, -1 } |
|
3906 |
+}; |
|
3907 |
+ |
|
3908 |
+static int |
|
3909 |
+logg_facility(const char *name) |
|
3910 |
+{ |
|
3911 |
+ int i; |
|
3912 |
+ |
|
3913 |
+ for(i = 0; facilitymap[i].name; i++) |
|
3914 |
+ if(strcasecmp(facilitymap[i].name, name) == 0) |
|
3915 |
+ return facilitymap[i].code; |
|
3916 |
+ |
|
3917 |
+ return -1; |
|
3918 |
+} |