diff -u --recursive ../../dbmail.orig/dbmail/Makefile.mysql ./Makefile.mysql --- ../../dbmail.orig/dbmail/Makefile.mysql Sat Jun 1 16:29:47 2002 +++ ./Makefile.mysql Fri Aug 30 15:22:41 2002 @@ -12,7 +12,7 @@ DBOBJECT = $(DBASETYPE)/db$(DBASETYPE).o SMTP_OBJECTS = list.o debug.o pipe.o mime.o $(DBOBJECT) dbmd5.o md5.o bounce.o forward.o memblock.o \ -$(AUTHOBJECT) +$(AUTHOBJECT) outofoffice.o INJECTOR_OBJECTS = list.o debug.o $(DBOBJECT) dbmd5.o md5.o $(AUTHOBJECT) mime.o UNIONE_OBJECTS = list.o debug.o $(DBOBJECT) dbmd5.o md5.o $(AUTHOBJECT) mime.o MINI_OBJECTS = debug.o $(DBOBJECT) list.o dbmd5.o md5.o $(AUTHOBJECT) mime.o @@ -25,12 +25,12 @@ CONFIG_OBJECTS = $(DBOBJECT) list.o md5.o debug.o dbmd5.o mime.o memblock.o $(AUTHOBJECT) USER_OBJECTS = debug.o list.o dbmd5.o md5.o $(DBOBJECT) mime.o memblock.o $(AUTHOBJECT) VUTCONV_OBJECTS = debug.o list.o dbmd5.o md5.o mime.o $(DBOBJECT) $(AUTHOBJECT) -CC = cc +CC = cc -I/www/mysql/include -MYSQLLIBDIR=/usr/local/lib/mysql +MYSQLLIBDIR=/www/mysql/lib -LIBS = -L$(MYSQLLIBDIR) -LIB = -lmysqlclient -lcrypt +LIBS = -L$(MYSQLLIBDIR) +LIB = -lmysqlclient -lcrypt -lz # Added the -D_BSD_SOURCE option to suppress warnings # from compiler about vsyslog function diff -u --recursive ../../dbmail.orig/dbmail/db.h ./db.h --- ../../dbmail.orig/dbmail/db.h Tue Jun 11 18:43:43 2002 +++ ./db.h Sat Aug 31 00:02:34 2002 @@ -200,4 +200,9 @@ int db_mailbox_msg_match(u64_t mailboxuid, u64_t msguid); + +int send_out_of_office_reply(char *header, unsigned long headersize, char *destination_address); +int check_out_of_office(u64_t userid, char **message); +int mark_out_of_office_sent(u64_t userid, char *to_address); + #endif Only in .: dbmail-adduser Only in .: dbmail-config Only in .: dbmail-imapd Only in .: dbmail-maintenance Only in .: dbmail-mini-injector Only in .: dbmail-pop3d Only in .: dbmail-readvut Only in .: dbmail-smtp Only in .: dbmail-smtp-injector Only in .: mbox2dbmail diff -u --recursive ../../dbmail.orig/dbmail/mysql/dbauthmysql.c ./mysql/dbauthmysql.c --- ../../dbmail.orig/dbmail/mysql/dbauthmysql.c Tue Jun 4 19:04:53 2002 +++ ./mysql/dbauthmysql.c Fri Aug 30 00:09:04 2002 @@ -6,7 +6,7 @@ */ #include "../auth.h" -#include "/usr/include/mysql/mysql.h" +#include "mysql.h" #include "../list.h" #include "../debug.h" #include diff -u --recursive ../../dbmail.orig/dbmail/mysql/dbmsgbufmysql.c ./mysql/dbmsgbufmysql.c --- ../../dbmail.orig/dbmail/mysql/dbmsgbufmysql.c Mon Mar 25 18:17:21 2002 +++ ./mysql/dbmsgbufmysql.c Fri Aug 30 00:11:47 2002 @@ -7,7 +7,7 @@ #include "../dbmsgbuf.h" #include "../db.h" -#include "/usr/include/mysql/mysql.h" +#include "mysql.h" #include #include #include diff -u --recursive ../../dbmail.orig/dbmail/mysql/dbmysql.c ./mysql/dbmysql.c --- ../../dbmail.orig/dbmail/mysql/dbmysql.c Tue Jul 16 13:13:22 2002 +++ ./mysql/dbmysql.c Sat Aug 31 01:33:34 2002 @@ -5,7 +5,7 @@ * Functions for connecting and talking to the Mysql database */ #include "../db.h" -#include "/usr/include/mysql/mysql.h" +#include "mysql.h" #include "../config.h" #include "../pop3.h" #include "../list.h" @@ -4014,3 +4014,128 @@ return val; } +/* + THIS IS WHAT I ADDED + + Function for checking if user has out-of-office turned on. + + Input params: userid, char ** pointer for message + + Return value: out-of-office on/off + + TODO: Change function so it returns also dates to message. + +*/ + +int check_out_of_office(u64_t userid, char **message) +{ + + + char timestr[30]; + time_t td; + struct tm tm; + + time(&td); /* get time */ + tm = *localtime(&td); /* get components */ + strftime(timestr, sizeof(timestr), "%G-%m-%d %H:%M:%S", &tm); + + + snprintf(query, DEF_QUERYSIZE, "SELECT msg FROM filter WHERE filter.userid = '%llu' and filter.type ='ooo' and sdate <= '%s' and edate >= '%s'", userid, timestr, timestr); + + + if(db_query(query) == -1) + { + + trace(TRACE_ERROR, "check_out_of_office(): could not check filters (out-of-office)\n"); + return -1; + } + + if((res = mysql_store_result(&conn)) == NULL) + { + trace(TRACE_ERROR, "check_out_of_office(): mysql_store_result failed %s", mysql_error(&conn)); + return -1; + } + + + if(mysql_num_rows(res) == 1) + { + + row = mysql_fetch_row(res); + + *message = (char *) malloc(strlen(row[0] + 1)); + + strcpy(*message,row[0]); + + return 1; + } + + return 0; + +} + +/* + THIS IS WHAT I ADDED + + Function for checking is notice allready sent and + if it's not then send it + + Input params: userid, address where that notice should be sent + + Return value: Is notice allready sent or not for toaddress + +*/ + +int mark_out_of_office_sent(u64_t userid, char *to_address) +{ + + snprintf(query, DEF_QUERYSIZE, "SELECT * FROM filter_log WHERE filter_log.userid = '%llu' and filter_log.type ='ooo' and filter_log.log_data = '%s'", userid, to_address); + + + if(db_query(query) == -1) + { + + trace(TRACE_ERROR, "check_out_of_office(): could not check filters (out-of-office)\n"); + return -1; + } + + if((res = mysql_store_result(&conn)) == NULL) + { + trace(TRACE_ERROR, "check_out_of_office(): mysql_store_result failed %s", mysql_error(&conn)); + return -1; + } + + if(mysql_num_rows(res) == 1) // This means that notice message is allready been sent + { + return 0; + } + else if(mysql_num_rows(res) == 0) + { + + snprintf(query, DEF_QUERYSIZE, "INSERT into filter_log (userid, type,log_data) values(%llu, 'ooo', '%s')", userid, to_address); + + if(db_query(query) == -1) + { + trace(TRACE_ERROR, "mark_out_of_office_sent(): could not check filter_log (out-of-office)\n"); + return -1; + } + + if(mysql_affected_rows(&conn) == 1) + { + return 1; + } + else + { + trace(TRACE_ERROR, "mark_out_of_office_sent(): filter_log data insert failed\n"); + return -1; + } + + } + else // this should never be the case + { + trace(TRACE_ERROR,"mark_out_of_office_send(): Too many log record for same address!!!"); + return 0; + } + + return 0; + +} diff -u --recursive ../../dbmail.orig/dbmail/mysql/dbsearchmysql.c ./mysql/dbsearchmysql.c --- ../../dbmail.orig/dbmail/mysql/dbsearchmysql.c Mon Mar 25 18:17:21 2002 +++ ./mysql/dbsearchmysql.c Fri Aug 30 00:44:56 2002 @@ -6,7 +6,7 @@ #include "../dbsearch.h" #include "../db.h" -#include "/usr/include/mysql/mysql.h" +#include "mysql.h" #include "../rfcmsg.h" #include #include Only in .: outofoffice.c diff -u --recursive ../../dbmail.orig/dbmail/pipe.c ./pipe.c --- ../../dbmail.orig/dbmail/pipe.c Tue Jul 16 13:13:22 2002 +++ ./pipe.c Sat Aug 31 00:42:55 2002 @@ -221,6 +221,7 @@ else { /* fetch the userid as a numeric string from the dbase */ + userid = auth_user_exists((char*)tmp->data); if (userid == -1) { @@ -241,6 +242,19 @@ } } + + + /* + THIS IS WHAT I ADDED + + Out-of-office reply + We check if user is out of office and send notice back to sender. + + */ + + send_out_of_office_reply(header,headersize,tmp->data); + + /* get the next taget in list */ tmp=tmp->nextnode; } @@ -301,6 +315,7 @@ /* adding this messageid to the message id list */ list_nodeadd(&messageids,&temp_message_record_id,sizeof(temp_message_record_id)); + } /* get next item */ Only in .: raw-convertor Only in .: uni-one-convertor