Browse code

--report sometimes failed

git-svn: trunk@2324

Nigel Horne authored on 2006/09/28 01:38:40
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Wed Sep 27 17:37:42 BST 2006 (njh)
2
+----------------------------------
3
+  * clamav-milter:	--report sometimes failed
4
+
1 5
 Wed Sep 27 17:29:24 BST 2006 (njh)
2 6
 ----------------------------------
3 7
   * libclamav/mbox.c:	 CL_EXPERIMENTAL now compiles under VS2005
... ...
@@ -23,9 +23,9 @@
23 23
  *
24 24
  * For installation instructions see the file INSTALL that came with this file
25 25
  */
26
-static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.287 2006/09/21 07:46:17 njh Exp $";
26
+static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.288 2006/09/27 16:38:39 njh Exp $";
27 27
 
28
-#define	CM_VERSION	"devel-100906"
28
+#define	CM_VERSION	"devel-270906"
29 29
 
30 30
 #if HAVE_CONFIG_H
31 31
 #include "clamav-config.h"
... ...
@@ -1858,11 +1858,11 @@ createSession(unsigned int s)
1858 1858
 	server.sin_addr.s_addr = serverIPs[serverNumber];
1859 1859
 
1860 1860
 	session->sock = -1;
1861
-	proto = getprotoentbyname("tcp");
1861
+	proto = getprotobyname("tcp");
1862 1862
 	if(proto == NULL) {
1863 1863
 		fputs("Unknown prototol tcp, check /etc/protocols\n", stderr);
1864 1864
 		ret = -1;
1865
-	} else if((fd = socket(AF_INET, SOCK_STREAM, p->p_proto)) < 0) {
1865
+	} else if((fd = socket(AF_INET, SOCK_STREAM, proto->p_proto)) < 0) {
1866 1866
 		perror("socket");
1867 1867
 		ret = -1;
1868 1868
 	} else if(connect(fd, (struct sockaddr *)&server, sizeof(struct sockaddr_in)) < 0) {
... ...
@@ -2643,7 +2643,7 @@ clamfi_envfrom(SMFICTX *ctx, char **argv)
2643 2643
 					rc = pthread_cond_timedwait(&n_children_cond, &n_children_mutex, &timeout);
2644 2644
 				}
2645 2645
 			} while((n_children >= max_children) && (rc != ETIMEDOUT));
2646
-			logg(_("Finished waiting, n_children = %d"), n_children);
2646
+			logg(_("Finished waiting, n_children = %d\n"), n_children);
2647 2647
 		}
2648 2648
 		n_children++;
2649 2649
 
... ...
@@ -3513,13 +3513,16 @@ clamfi_eom(SMFICTX *ctx)
3513 3513
 			if(smfi_addrcpt(ctx, report) == MI_FAILURE) {
3514 3514
 				/* It's a remote site */
3515 3515
 				if(privdata->filename) {
3516
-					char cmd[128];
3516
+					char cmd[1024];
3517 3517
 
3518
-					snprintf(cmd, sizeof(cmd), "mail -s %s %s < %s",
3518
+					snprintf(cmd, sizeof(cmd) - 1,
3519
+						"mail -s \"%s\" %s < %s",
3519 3520
 						virusname, report,
3520 3521
 						privdata->filename);
3521 3522
 					if(system(cmd) == 0)
3522 3523
 						logg(_("#Reported phishing to %s"), report);
3524
+					else
3525
+						logg(_("^Couldn't report to %s\n"), report);
3523 3526
 				} else {
3524 3527
 					logg(_("^Can't set anti-phish header\n"));
3525 3528
 					rc = (privdata->discard) ? SMFIS_DISCARD : SMFIS_REJECT;
... ...
@@ -4654,8 +4657,7 @@ qfile(struct privdata *privdata, const char *sendmailId, const char *virusname)
4654 4654
 	if((mkdir(newname, 0700) < 0) && (errno != EEXIST)) {
4655 4655
 #endif
4656 4656
 		perror(newname);
4657
-		if(use_syslog)
4658
-			syslog(LOG_ERR, _("mkdir %s failed"), newname);
4657
+		logg(_("!mkdir %s failed\n"), newname);
4659 4658
 		return -1;
4660 4659
 	}
4661 4660
 	sprintf(newname, "%s/%02d%02d%02d/%s.%s",
... ...
@@ -4670,7 +4672,7 @@ qfile(struct privdata *privdata, const char *sendmailId, const char *virusname)
4670 4670
 #ifdef	C_DARWIN
4671 4671
 		*ptr &= '\177';
4672 4672
 #endif
4673
-#if	defined(MSDOS) || defined(C_CYGWIN) || defined(WIN32) || defined(C_OS2)
4673
+#if	defined(MSDOS) || defined(C_CYGWIN) || defined(C_WINDOWS) || defined(C_OS2)
4674 4674
 		if(strchr("/*?<>|\\\"+=,;:\t ", *ptr))
4675 4675
 #else
4676 4676
 		if(*ptr == '/')
... ...
@@ -4680,17 +4682,15 @@ qfile(struct privdata *privdata, const char *sendmailId, const char *virusname)
4680 4680
 	cli_dbgmsg("qfile move '%s' to '%s'\n", privdata->filename, newname);
4681 4681
 
4682 4682
 	if(move(privdata->filename, newname) < 0) {
4683
-		if(use_syslog)
4684
-			syslog(LOG_WARNING, _("Can't rename %1$s to %2$s"),
4685
-				privdata->filename, newname);
4683
+		logg(_("^Can't rename %1$s to %2$s\n"),
4684
+			privdata->filename, newname);
4686 4685
 		free(newname);
4687 4686
 		return -1;
4688 4687
 	}
4689 4688
 	free(privdata->filename);
4690 4689
 	privdata->filename = newname;
4691 4690
 
4692
-	if(use_syslog)
4693
-		syslog(LOG_INFO, _("Email quarantined as %s"), newname);
4691
+	logg(_("Email quarantined as %s\n"), newname);
4694 4692
 
4695 4693
 	return 0;
4696 4694
 }