X-Git-Url: http://ftp.carnet.hr/pub/carnet-debian/scm?a=blobdiff_plain;f=src%2Fos_maild%2Fsendcustomemail.c;h=9026d0227c0b8d331da38a351774a8be99252b8d;hb=e81e4e82e5115bf99b6fbd9ebd486de325d67ed6;hp=ea2b203cbf70b736725ed07638957e3bd3da39eb;hpb=301048b51990573e58a30dc4a5bb4ec285cad554;p=ossec-hids.git diff --git a/src/os_maild/sendcustomemail.c b/src/os_maild/sendcustomemail.c index ea2b203..9026d02 100755 --- a/src/os_maild/sendcustomemail.c +++ b/src/os_maild/sendcustomemail.c @@ -1,11 +1,12 @@ -/* @(#) $Id$ */ +/* @(#) $Id: ./src/os_maild/sendcustomemail.c, 2011/09/08 dcid Exp $ + */ /* Copyright (C) 2009 Trend Micro Inc. * All rights reserved. * * This program is a free software; you can redistribute it * and/or modify it under the terms of the GNU General Public - * License (version 2) as published by the FSF - Free Software + * License (version 2) as published by the FSF - Free Software * Foundation */ @@ -34,8 +35,10 @@ #define TO "To: <%s>\r\n" #define CC "Cc: <%s>\r\n" #define SUBJECT "Subject: %s\r\n" +#define ENDHEADER "\r\n" #define ENDDATA "\r\n.\r\n" #define QUITMSG "QUIT\r\n" +#define XHEADER "X-IDS-OSSEC: %s\r\n" /* Error messages - Can be translated */ @@ -55,7 +58,7 @@ /* OS_SendCustomEmail */ -int OS_SendCustomEmail(char **to, char *subject, char *smtpserver, char *from, FILE *fp, struct tm *p) +int OS_SendCustomEmail(char **to, char *subject, char *smtpserver, char *from, char *idsname, FILE *fp, struct tm *p) { int socket,i = 0; char *msg; @@ -67,7 +70,7 @@ int OS_SendCustomEmail(char **to, char *subject, char *smtpserver, char *from, F /* Connecting to the smtp server */ - socket = OS_ConnectTCP(SMTP_DEFAULT_PORT, smtpserver); + socket = OS_ConnectTCP(SMTP_DEFAULT_PORT, smtpserver, 0); if(socket < 0) { return(socket); @@ -112,7 +115,7 @@ int OS_SendCustomEmail(char **to, char *subject, char *smtpserver, char *from, F if(msg) free(msg); close(socket); - return(OS_INVALID); + return(OS_INVALID); } } else @@ -209,7 +212,7 @@ int OS_SendCustomEmail(char **to, char *subject, char *smtpserver, char *from, F { break; } - + memset(snd_msg,'\0',128); snprintf(snd_msg,127, TO, to[i]); OS_SendTCP(socket,snd_msg); @@ -229,9 +232,16 @@ int OS_SendCustomEmail(char **to, char *subject, char *smtpserver, char *from, F #else strftime(snd_msg, 127, "Date: %a, %d %b %Y %T %z\r\n",p); #endif - + OS_SendTCP(socket,snd_msg); + if (idsname) + { + /* Sending server name header */ + memset(snd_msg,'\0',128); + snprintf(snd_msg,127, XHEADER, idsname); + OS_SendTCP(socket, snd_msg); + } /* Sending subject */ memset(snd_msg, '\0', 128); @@ -239,6 +249,7 @@ int OS_SendCustomEmail(char **to, char *subject, char *smtpserver, char *from, F OS_SendTCP(socket, snd_msg); + OS_SendTCP(socket,ENDHEADER); /* Sending body */ @@ -246,7 +257,7 @@ int OS_SendCustomEmail(char **to, char *subject, char *smtpserver, char *from, F while(fgets(buffer, 2048, fp) != NULL) { OS_SendTCP(socket,buffer); - } + } /* Sending end of data \r\n.\r\n */