Added more information to headers flag

git-svn: trunk@377
remotes/push_mirror/metadata
Nigel Horne 22 years ago
parent e8da4921b7
commit 5b6bb93bd8
  1. 5
      clamav-devel/ChangeLog
  2. 5
      clamav-devel/clamav-milter/INSTALL
  3. 88
      clamav-devel/clamav-milter/clamav-milter.c

@ -1,3 +1,8 @@
Sun Mar 7 15:19:51 GMT 2004 (njh)
----------------------------------
* libclamav/message.c: Fixed minor typo in bounce message
clamav-milter: Added extra information to --headers
Sun Mar 7 12:40:05 GMT 2004 (njh) Sun Mar 7 12:40:05 GMT 2004 (njh)
---------------------------------- ----------------------------------
* libclamav/message.c: Added new bounce delimeter (thanks to Dirk * libclamav/message.c: Added new bounce delimeter (thanks to Dirk

@ -277,6 +277,11 @@ Changes
and put sockets into subdirectory for security and put sockets into subdirectory for security
clamfi_close debug, change assert to debug message clamfi_close debug, change assert to debug message
Better way to force TCPwrappers only with TCP/IP Better way to force TCPwrappers only with TCP/IP
0.67k 7/3/04 Ensure cli_dbgmsg's end with \n
Fixed some warning messages with icc
Use cli_[cm]alloc
Included extra information if --headers is given (based on an
idea from "Leonid Zeitlin" <lz@europe.com>
BUG REPORTS BUG REPORTS

@ -276,9 +276,17 @@
* and put sockets into subdirectory for security * and put sockets into subdirectory for security
* clamfi_close debug, change assert to debug message * clamfi_close debug, change assert to debug message
* Better way to force TCPwrappers only with TCP/IP * Better way to force TCPwrappers only with TCP/IP
* * 0.67k 7/3/04 Ensure cli_dbgmsg's end with \n
* Fixed some warning messages with icc
* Use cli_[cm]alloc
* Included extra information if --headers is given (based
* on an idea from "Leonid Zeitlin" <lz@europe.com>
*
* Change History: * Change History:
* $Log: clamav-milter.c,v $ * $Log: clamav-milter.c,v $
* Revision 1.59 2004/03/07 15:11:15 nigelhorne
* Added more information to headers flag
*
* Revision 1.58 2004/03/03 09:14:55 nigelhorne * Revision 1.58 2004/03/03 09:14:55 nigelhorne
* Change way check for TCPwrappers on TCP/IP * Change way check for TCPwrappers on TCP/IP
* *
@ -438,9 +446,9 @@
* Revision 1.6 2003/09/28 16:37:23 nigelhorne * Revision 1.6 2003/09/28 16:37:23 nigelhorne
* Added -f flag use MaxThreads if --max-children not set * Added -f flag use MaxThreads if --max-children not set
*/ */
static char const rcsid[] = "$Id: clamav-milter.c,v 1.58 2004/03/03 09:14:55 nigelhorne Exp $"; static char const rcsid[] = "$Id: clamav-milter.c,v 1.59 2004/03/07 15:11:15 nigelhorne Exp $";
#define CM_VERSION "0.67j" #define CM_VERSION "0.67k"
/*#define CONFDIR "/usr/local/etc"*/ /*#define CONFDIR "/usr/local/etc"*/
@ -461,9 +469,6 @@ static char const rcsid[] = "$Id: clamav-milter.c,v 1.58 2004/03/03 09:14:55 nig
#include <stdio.h> #include <stdio.h>
#include <sysexits.h> #include <sysexits.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <syslog.h> #include <syslog.h>
@ -773,7 +778,7 @@ main(int argc, char **argv)
"force-scan", 0, NULL, 'f' "force-scan", 0, NULL, 'f'
}, },
{ {
"headers", 0, NULL, 'H' "headers", 0, NULL, 'H'
}, },
{ {
"help", 0, NULL, 'h' "help", 0, NULL, 'h'
@ -1051,7 +1056,7 @@ main(int argc, char **argv)
return EX_CONFIG; return EX_CONFIG;
} }
tcpSocket = cpt->numarg; tcpSocket = (in_port_t)cpt->numarg;
/* /*
* cli_strtok's fieldno counts from 0 * cli_strtok's fieldno counts from 0
@ -1230,8 +1235,8 @@ pingServer(int serverNumber)
memset((char *)&server, 0, sizeof(struct sockaddr_in)); memset((char *)&server, 0, sizeof(struct sockaddr_in));
server.sin_family = AF_INET; server.sin_family = AF_INET;
server.sin_port = htons(tcpSocket); server.sin_port = (in_port_t)htons(tcpSocket);
assert(serverIPs != NULL); assert(serverIPs != NULL);
assert(serverIPs[0] != -1L); assert(serverIPs[0] != -1L);
@ -1328,7 +1333,7 @@ findServer(void)
int sock; int sock;
server->sin_family = AF_INET; server->sin_family = AF_INET;
server->sin_port = htons(tcpSocket); server->sin_port = (in_port_t)htons(tcpSocket);
server->sin_addr.s_addr = serverIPs[i]; server->sin_addr.s_addr = serverIPs[i];
sock = socks[i] = socket(AF_INET, SOCK_STREAM, 0); sock = socks[i] = socket(AF_INET, SOCK_STREAM, 0);
@ -1363,7 +1368,7 @@ findServer(void)
tv.tv_sec = threadtimeout; tv.tv_sec = threadtimeout;
tv.tv_usec = 0; tv.tv_usec = 0;
retval = select(maxsock, &rfds, NULL, NULL, &tv); retval = select(maxsock, &rfds, NULL, NULL, &tv);
if(retval < 0) if(retval < 0)
perror("select"); perror("select");
@ -1388,7 +1393,7 @@ findServer(void)
for(i = 0; i < numServers; i++) for(i = 0; i < numServers; i++)
if(FD_ISSET(socks[i], &rfds)) { if(FD_ISSET(socks[i], &rfds)) {
free(socks); free(socks);
cli_dbgmsg("findServer: using server %d", i); cli_dbgmsg("findServer: using server %d\n", i);
return i; return i;
} }
@ -1440,7 +1445,7 @@ clamfi_connect(SMFICTX *ctx, char *hostname, _SOCK_ADDR *hostaddr)
const char *hostmail; const char *hostmail;
const struct hostent *hp = NULL; const struct hostent *hp = NULL;
/* /*
* Using TCP/IP for the sendmail->clamav-milter connection * Using TCP/IP for the sendmail->clamav-milter connection
*/ */
if((hostmail = smfi_getsymval(ctx, "{if_name}")) == NULL) { if((hostmail = smfi_getsymval(ctx, "{if_name}")) == NULL) {
@ -1480,7 +1485,7 @@ clamfi_connect(SMFICTX *ctx, char *hostname, _SOCK_ADDR *hostaddr)
#ifdef CL_DEBUG #ifdef CL_DEBUG
if(use_syslog) if(use_syslog)
syslog(LOG_DEBUG, "clamfi_connect: not scanning outgoing messages"); syslog(LOG_DEBUG, "clamfi_connect: not scanning outgoing messages");
cli_dbgmsg("clamfi_connect: not scanning outgoing messages"); cli_dbgmsg("clamfi_connect: not scanning outgoing messages\n");
#endif #endif
return SMFIS_ACCEPT; return SMFIS_ACCEPT;
} }
@ -1518,7 +1523,7 @@ clamfi_connect(SMFICTX *ctx, char *hostname, _SOCK_ADDR *hostaddr)
#ifdef CL_DEBUG #ifdef CL_DEBUG
if(use_syslog) if(use_syslog)
syslog(LOG_DEBUG, "clamfi_connect: not scanning local messages"); syslog(LOG_DEBUG, "clamfi_connect: not scanning local messages");
cli_dbgmsg("clamfi_connect: not scanning outgoing messages"); cli_dbgmsg("clamfi_connect: not scanning outgoing messages\n");
#endif #endif
return SMFIS_ACCEPT; return SMFIS_ACCEPT;
} }
@ -1593,7 +1598,7 @@ clamfi_envfrom(SMFICTX *ctx, char **argv)
if(use_syslog) if(use_syslog)
syslog(LOG_NOTICE, "Timeout waiting for a child to die"); syslog(LOG_NOTICE, "Timeout waiting for a child to die");
#endif #endif
cli_dbgmsg("Timeout waiting for a child to die"); cli_dbgmsg("Timeout waiting for a child to die\n");
} }
} }
@ -1659,7 +1664,7 @@ clamfi_envfrom(SMFICTX *ctx, char **argv)
memset((char *)&server, 0, sizeof(struct sockaddr_in)); memset((char *)&server, 0, sizeof(struct sockaddr_in));
server.sin_family = AF_INET; server.sin_family = AF_INET;
server.sin_port = htons(tcpSocket); server.sin_port = (in_port_t)htons(tcpSocket);
assert(serverIPs != NULL); assert(serverIPs != NULL);
@ -1732,7 +1737,7 @@ clamfi_envfrom(SMFICTX *ctx, char **argv)
memset((char *)&reply, 0, sizeof(struct sockaddr_in)); memset((char *)&reply, 0, sizeof(struct sockaddr_in));
reply.sin_family = AF_INET; reply.sin_family = AF_INET;
reply.sin_port = htons(port); reply.sin_port = (in_port_t)htons(port);
assert(serverIPs != NULL); assert(serverIPs != NULL);
@ -1770,7 +1775,7 @@ clamfi_envfrom(SMFICTX *ctx, char **argv)
privdata->to = NULL; privdata->to = NULL;
if (hflag) if (hflag)
privdata->headers = header_list_new(); privdata->headers = header_list_new();
else else
privdata->headers = NULL; privdata->headers = NULL;
@ -1797,7 +1802,7 @@ clamfi_envrcpt(SMFICTX *ctx, char **argv)
clamfi_send(privdata, 0, "To: %s\n", argv[0]); clamfi_send(privdata, 0, "To: %s\n", argv[0]);
if(privdata->to == NULL) { if(privdata->to == NULL) {
privdata->to = malloc(sizeof(char *) * 2); privdata->to = cli_malloc(sizeof(char *) * 2);
assert(privdata->numTo == 0); assert(privdata->numTo == 0);
} else } else
@ -1820,7 +1825,7 @@ clamfi_header(SMFICTX *ctx, char *headerf, char *headerv)
if(debug_level >= 9) if(debug_level >= 9)
printf("clamfi_header: %s: %s\n", headerf, headerv); printf("clamfi_header: %s: %s\n", headerf, headerv);
else else
cli_dbgmsg("clamfi_header"); cli_dbgmsg("clamfi_header\n");
#endif #endif
if(clamfi_send(privdata, 0, "%s: %s\n", headerf, headerv) < 0) { if(clamfi_send(privdata, 0, "%s: %s\n", headerf, headerv) < 0) {
@ -1829,7 +1834,7 @@ clamfi_header(SMFICTX *ctx, char *headerf, char *headerv)
} }
if(hflag) if(hflag)
header_list_add(privdata->headers, headerf, headerv); header_list_add(privdata->headers, headerf, headerv);
return SMFIS_CONTINUE; return SMFIS_CONTINUE;
} }
@ -1843,7 +1848,7 @@ clamfi_eoh(SMFICTX *ctx)
if(logVerbose) if(logVerbose)
syslog(LOG_DEBUG, "clamfi_eoh"); syslog(LOG_DEBUG, "clamfi_eoh");
#ifdef CL_DEBUG #ifdef CL_DEBUG
cli_dbgmsg("clamfi_eoh"); cli_dbgmsg("clamfi_eoh\n");
#endif #endif
if(clamfi_send(privdata, 1, "\n") < 0) { if(clamfi_send(privdata, 1, "\n") < 0) {
@ -1888,7 +1893,7 @@ clamfi_eoh(SMFICTX *ctx)
if(use_syslog) if(use_syslog)
syslog(LOG_NOTICE, "clamfi_connect: ignoring whitelisted message"); syslog(LOG_NOTICE, "clamfi_connect: ignoring whitelisted message");
#ifdef CL_DEBUG #ifdef CL_DEBUG
cli_dbgmsg("clamfi_connect: not scanning outgoing messages"); cli_dbgmsg("clamfi_connect: not scanning outgoing messages\n");
#endif #endif
clamfi_cleanup(ctx); clamfi_cleanup(ctx);
@ -1918,7 +1923,7 @@ clamfi_body(SMFICTX *ctx, u_char *bodyp, size_t len)
privdata->bodyLen += len; privdata->bodyLen += len;
} else { } else {
assert(privdata->bodyLen == 0); assert(privdata->bodyLen == 0);
privdata->body = malloc(len); privdata->body = cli_malloc(len);
memcpy(privdata->body, bodyp, len); memcpy(privdata->body, bodyp, len);
privdata->bodyLen = len; privdata->bodyLen = len;
} }
@ -1937,7 +1942,7 @@ clamfi_eom(SMFICTX *ctx)
if(logVerbose) if(logVerbose)
syslog(LOG_DEBUG, "clamfi_eom"); syslog(LOG_DEBUG, "clamfi_eom");
#ifdef CL_DEBUG #ifdef CL_DEBUG
cli_dbgmsg("clamfi_eom"); cli_dbgmsg("clamfi_eom\n");
assert(privdata != NULL); assert(privdata != NULL);
assert((privdata->cmdSocket >= 0) || (privdata->filename != NULL)); assert((privdata->cmdSocket >= 0) || (privdata->filename != NULL));
assert(!((privdata->cmdSocket >= 0) && (privdata->filename != NULL))); assert(!((privdata->cmdSocket >= 0) && (privdata->filename != NULL)));
@ -2000,7 +2005,7 @@ clamfi_eom(SMFICTX *ctx)
clamfi_cleanup(ctx); clamfi_cleanup(ctx);
syslog(LOG_NOTICE, "clamfi_eom: read nothing from clamd"); syslog(LOG_NOTICE, "clamfi_eom: read nothing from clamd");
#ifdef CL_DEBUG #ifdef CL_DEBUG
cli_dbgmsg("clamfi_eom: read nothing from clamd"); cli_dbgmsg("clamfi_eom: read nothing from clamd\n");
#endif #endif
return cl_error; return cl_error;
} }
@ -2054,7 +2059,7 @@ clamfi_eom(SMFICTX *ctx)
/* /*
* Setup err as a list of recipients * Setup err as a list of recipients
*/ */
err = (char *)malloc(1024); err = (char *)cli_malloc(1024);
/* /*
* Use snprintf rather than printf since we don't know the * Use snprintf rather than printf since we don't know the
@ -2087,7 +2092,7 @@ clamfi_eom(SMFICTX *ctx)
smfi_getsymval(ctx, "i"), smfi_getsymval(ctx, "i"),
err); err);
#ifdef CL_DEBUG #ifdef CL_DEBUG
cli_dbgmsg(err); cli_dbgmsg("%s\n", err);
#endif #endif
free(err); free(err);
@ -2152,9 +2157,10 @@ clamfi_eom(SMFICTX *ctx)
if(privdata->filename != NULL) if(privdata->filename != NULL)
fprintf(sendmail, "\nThe message in question has been quarantined as %s\n", privdata->filename); fprintf(sendmail, "\nThe message in question has been quarantined as %s\n", privdata->filename);
if (hflag) { if(hflag) {
fprintf(sendmail, "\nThe message was received by %s from %s\n\n", fprintf(sendmail, "\nThe message was received by %s from %s via %s\n\n",
smfi_getsymval(ctx, "j"), from); smfi_getsymval(ctx, "j"), from,
smfi_getsymval(ctx, "_"));
fputs("For your information, the original message headers were:\n\n", sendmail); fputs("For your information, the original message headers were:\n\n", sendmail);
header_list_print(privdata->headers, sendmail); header_list_print(privdata->headers, sendmail);
} }
@ -2211,7 +2217,7 @@ clamfi_abort(SMFICTX *ctx)
#ifdef CL_DEBUG #ifdef CL_DEBUG
if(use_syslog) if(use_syslog)
syslog(LOG_DEBUG, "clamfi_abort"); syslog(LOG_DEBUG, "clamfi_abort");
cli_dbgmsg("clamfi_abort"); cli_dbgmsg("clamfi_abort\n");
#endif #endif
/* /*
@ -2233,7 +2239,7 @@ clamfi_close(SMFICTX *ctx)
#ifdef CL_DEBUG #ifdef CL_DEBUG
struct privdata *privdata = (struct privdata *)smfi_getpriv(ctx); struct privdata *privdata = (struct privdata *)smfi_getpriv(ctx);
cli_dbgmsg("clamfi_close"); cli_dbgmsg("clamfi_close\n");
if(privdata != NULL) { if(privdata != NULL) {
if(use_syslog) if(use_syslog)
syslog(LOG_DEBUG, "clamfi_close, privdata != NULL"); syslog(LOG_DEBUG, "clamfi_close, privdata != NULL");
@ -2281,7 +2287,7 @@ clamfi_free(struct privdata *privdata)
if(privdata->from) { if(privdata->from) {
#ifdef CL_DEBUG #ifdef CL_DEBUG
if(debug_level >= 9) if(debug_level >= 9)
cli_dbgmsg("Free privdata->from"); cli_dbgmsg("Free privdata->from\n");
#endif #endif
free(privdata->from); free(privdata->from);
privdata->from = NULL; privdata->from = NULL;
@ -2293,13 +2299,13 @@ clamfi_free(struct privdata *privdata)
for(to = privdata->to; *to; to++) { for(to = privdata->to; *to; to++) {
#ifdef CL_DEBUG #ifdef CL_DEBUG
if(debug_level >= 9) if(debug_level >= 9)
cli_dbgmsg("Free *privdata->to"); cli_dbgmsg("Free *privdata->to\n");
#endif #endif
free(*to); free(*to);
} }
#ifdef CL_DEBUG #ifdef CL_DEBUG
if(debug_level >= 9) if(debug_level >= 9)
cli_dbgmsg("Free privdata->to"); cli_dbgmsg("Free privdata->to\n");
#endif #endif
free(privdata->to); free(privdata->to);
privdata->to = NULL; privdata->to = NULL;
@ -2321,7 +2327,7 @@ clamfi_free(struct privdata *privdata)
#ifdef CL_DEBUG #ifdef CL_DEBUG
if(debug_level >= 9) if(debug_level >= 9)
cli_dbgmsg("Free privdata"); cli_dbgmsg("Free privdata\n");
#endif #endif
free(privdata); free(privdata);
} }
@ -2334,7 +2340,7 @@ clamfi_free(struct privdata *privdata)
if(n_children > 0) if(n_children > 0)
--n_children; --n_children;
#ifdef CL_DEBUG #ifdef CL_DEBUG
cli_dbgmsg("pthread_cond_broadcast"); cli_dbgmsg("pthread_cond_broadcast\n");
#endif #endif
pthread_cond_broadcast(&n_children_cond); pthread_cond_broadcast(&n_children_cond);
#ifdef CL_DEBUG #ifdef CL_DEBUG
@ -2518,7 +2524,7 @@ header_list_add(header_list_t list, const char *headerf, const char *headerv)
header = (char *)cli_malloc(len); header = (char *)cli_malloc(len);
snprintf(header, len, "%s: %s", headerf, headerv); snprintf(header, len, "%s: %s", headerf, headerv);
new_node = (struct header_node_t *) malloc(sizeof(struct header_node_t)); new_node = (struct header_node_t *)cli_malloc(sizeof(struct header_node_t));
new_node->header = header; new_node->header = header;
new_node->next = NULL; new_node->next = NULL;
if(!list->first) if(!list->first)

Loading…
Cancel
Save