Browse code

Handle --from, print error message if write to quarantine fails

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@570 77e5149b-7576-45b1-b177-96237e5ba77b

Nigel Horne authored on 2004/05/21 18:17:37
Showing 3 changed files
... ...
@@ -1,3 +1,9 @@
1
+Fri May 21 10:16:27 BST 2004 (njh)
2
+----------------------------------
3
+  * clamav-milter:	--from wasn't always recognised
4
+  			write failures to quarantine area were not correctly
5
+	reported
6
+
1 7
 Thu May 20 11:23:23 BST 2004 (trog)
2 8
 -----------------------------------
3 9
   * libclamav ole2_extract.c,vba_extract.c: more malloc checks
... ...
@@ -391,6 +391,10 @@ Changes
391 391
 			a child dies we continue when max children is hit
392 392
 		Report an error if inet_ntop fails in tcp_wrappers
393 393
 0.71	16/5/04	Up issue
394
+0.71a	21/5/04	--from wasn't always a recognised option
395
+		Write failure to quarantine file now logs the name of the file
396
+		Commented out TKs advice about using quarantine when using
397
+			localSocket, sys admins were confused by it
394 398
 
395 399
 BUG REPORTS
396 400
 
... ...
@@ -395,9 +395,18 @@
395 395
  *				children is hit
396 396
  *			Report an error if inet_ntop fails in tcp_wrappers
397 397
  *	0.71	16/5/04	Up issue
398
+ *	0.71a	21/5/04	--from wasn't always a recognised option
399
+ *			Write failure to quarantine file now logs the name
400
+ *				of the file
401
+ *			Commented out TKs advice about using quarantine
402
+ *				when using localSocket, sys admins were
403
+ *				confused by it
398 404
  *
399 405
  * Change History:
400 406
  * $Log: clamav-milter.c,v $
407
+ * Revision 1.89  2004/05/21 09:14:57  nigelhorne
408
+ * Handle --from, print error message if write to quarantine fails
409
+ *
401 410
  * Revision 1.88  2004/05/16 08:25:09  nigelhorne
402 411
  * Up issue
403 412
  *
... ...
@@ -647,7 +656,7 @@
647 647
  * Revision 1.6  2003/09/28 16:37:23  nigelhorne
648 648
  * Added -f flag use MaxThreads if --max-children not set
649 649
  */
650
-static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.88 2004/05/16 08:25:09 nigelhorne Exp $";
650
+static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.89 2004/05/21 09:14:57 nigelhorne Exp $";
651 651
 
652 652
 #define	CM_VERSION	"0.71"
653 653
 
... ...
@@ -886,7 +895,7 @@ static	const	char	*postmaster = "postmaster";
886 886
 static	const	char	*from = "MAILER-DAEMON";
887 887
 
888 888
 /*
889
- * NULL terminated whitelist of source e-mail addresses that we do NOT scan
889
+ * NULL terminated whitelist of target ("to") addresses that we do NOT scan
890 890
  * TODO: read in from a file
891 891
  * TODO: add white list of target e-mail addresses that we do NOT scan
892 892
  * TODO: items in the list should be regular expressions
... ...
@@ -974,9 +983,9 @@ main(int argc, char **argv)
974 974
 	for(;;) {
975 975
 		int opt_index = 0;
976 976
 #ifdef	CL_DEBUG
977
-		const char *args = "bc:CDfF:lm:nNop:PqQ:dhHs:St:U:Vx:";
977
+		const char *args = "abc:CDfF:lm:nNop:PqQ:dhHs:St:U:Vx:";
978 978
 #else
979
-		const char *args = "bc:CDfF:lm:nNop:PqQ:dhHs:St:U:V";
979
+		const char *args = "abc:CDfF:lm:nNop:PqQ:dhHs:St:U:V";
980 980
 #endif
981 981
 
982 982
 		static struct option long_options[] = {
... ...
@@ -1297,8 +1306,8 @@ main(int argc, char **argv)
1297 1297
 				cfgfile);
1298 1298
 			return EX_CONFIG;
1299 1299
 		}
1300
-		if(quarantine_dir == NULL)
1301
-			fprintf(stderr, "When using Localsocket in %s\nyou may improve performance if you use the --quarantine_dir option\n", cfgfile);
1300
+		/*if(quarantine_dir == NULL)
1301
+			fprintf(stderr, "When using Localsocket in %s\nyou may improve performance if you use the --quarantine-dir option\n", cfgfile);*/
1302 1302
 
1303 1303
 		umask(077);
1304 1304
 
... ...
@@ -2715,21 +2724,38 @@ clamfi_send(struct privdata *privdata, size_t len, const char *format, ...)
2715 2715
 		assert(privdata->dataSocket >= 0);
2716 2716
 
2717 2717
 		if(nbytes == -1) {
2718
-			if(errno == EINTR)
2719
-				continue;
2720
-			perror("send");
2721
-			if(use_syslog) {
2718
+			if(quarantine_dir) {
2719
+				perror(privdata->filename);
2720
+				if(use_syslog) {
2722 2721
 #ifdef HAVE_STRERROR_R
2723
-				char buf[32];
2724
-				strerror_r(errno, buf, sizeof(buf));
2725
-				syslog(LOG_ERR,
2726
-					"write failure (%u bytes) to clamd: %s",
2727
-					len, buf);
2722
+					char buf[32];
2723
+					strerror_r(errno, buf, sizeof(buf));
2724
+					syslog(LOG_ERR,
2725
+						"write failure (%u bytes) to %s: %s",
2726
+						len, privdata->filename, buf);
2728 2727
 #else
2729
-				syslog(LOG_ERR, "write failure (%u bytes) to clamd: %s", len, strerror(errno));
2728
+					syslog(LOG_ERR, "write failure (%u bytes) to %s: %s",
2729
+						len, privdata->filename,
2730
+						strerror(errno));
2730 2731
 #endif
2732
+				}
2733
+			} else {
2734
+				if(errno == EINTR)
2735
+					continue;
2736
+				perror("send");
2737
+				if(use_syslog) {
2738
+#ifdef HAVE_STRERROR_R
2739
+					char buf[32];
2740
+					strerror_r(errno, buf, sizeof(buf));
2741
+					syslog(LOG_ERR,
2742
+						"write failure (%u bytes) to clamd: %s",
2743
+						len, buf);
2744
+#else
2745
+					syslog(LOG_ERR, "write failure (%u bytes) to clamd: %s", len, strerror(errno));
2746
+#endif
2747
+				}
2748
+				checkClamd();
2731 2749
 			}
2732
-			checkClamd();
2733 2750
 
2734 2751
 			return -1;
2735 2752
 		}