From da43f143eba8bdd986c013afc1640d69a3848d4d Mon Sep 17 00:00:00 2001
From: Tom Cort
Date: Tue, 27 Nov 2007 19:03:08 -0500
Subject: [PATCH] libesmtp -> jwSMTP
---
CMakeLists.txt | 36 ++++++++++++++++----------------
smtp.c | 61 ------------------------------------------------------
smtp.h => smtp.cxx | 20 ++++++++++++++----
smtp.h => smtp.hxx | 6 +++---
www/index.html | 2 +-
5 files changed, 38 insertions(+), 87 deletions(-)
delete mode 100644 smtp.c
copy smtp.h => smtp.cxx (62%)
rename smtp.h => smtp.hxx (93%)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7575494..51840dd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,11 +18,11 @@
# Contributor(s):
# Tom Cort
-PROJECT (inoclam C)
+PROJECT (inoclam)
SET (libdirs /usr/lib /usr/pkg/lib /usr/local/lib /usr/lib64 /usr/local/lib64 /usr/lib32 /usr/local/lib32)
SET (bindirs /usr/bin /usr/pkg/bin /usr/local/bin)
-SET (incdirs /usr/include /usr/local/include /usr/pkg/include)
+SET (incdirs /usr/include /usr/local/include /usr/pkg/include /usr/include/jwsmtp-1.32 /usr/local/include/jwsmtp-1.32 /usr/pkg/include/jwsmtp-1.32)
#############################################
# libclamav checks
@@ -85,24 +85,24 @@ ELSE (LIBINOTIFYTOOLS_INCLUDE_DIR)
ENDIF (LIBINOTIFYTOOLS_INCLUDE_DIR)
#############################################
-# libesmtp checks
+# jwsmtp checks
#############################################
-FIND_LIBRARY(LIBESMTP esmtp ${libdirs})
+FIND_LIBRARY(JWSMTP jwsmtp ${libdirs})
-IF (LIBESMTP)
- MESSAGE(STATUS "Found libesmtp: ${LIBESMTP}")
-ELSE (LIBESMTP)
- MESSAGE (FATAL_ERROR "libesmtp not found.")
-ENDIF (LIBESMTP)
+IF (JWSMTP)
+ MESSAGE(STATUS "Found jwsmtp: ${JWSMTP}")
+ELSE (JWSMTP)
+ MESSAGE (FATAL_ERROR "jwsmtp not found.")
+ENDIF (JWSMTP)
-FIND_PATH(LIBESMTP_INCLUDE_DIR libesmtp.h ${incdirs})
+FIND_PATH(JWSMTP_INCLUDE_DIR jwsmtp/jwsmtp.h ${incdirs})
-IF (LIBESMTP_INCLUDE_DIR)
- MESSAGE(STATUS "Found libesmtp.h in ${LIBESMTP_INCLUDE_DIR}")
-ELSE (LIBESMTP_INCLUDE_DIR)
- MESSAGE (FATAL_ERROR "libesmtp.h not found.")
-ENDIF (LIBESMTP_INCLUDE_DIR)
+IF (JWSMTP_INCLUDE_DIR)
+ MESSAGE(STATUS "Found jwsmtp/jwsmtp.h in ${JWSMTP_INCLUDE_DIR}")
+ELSE (JWSMTP_INCLUDE_DIR)
+ MESSAGE (FATAL_ERROR "jwsmtp/jwsmtp.h not found.")
+ENDIF (JWSMTP_INCLUDE_DIR)
#############################################
# inotify checks
@@ -120,16 +120,16 @@ ENDIF (INOTIFY_INCLUDE_DIR)
# include dirs
#############################################
-INCLUDE_DIRECTORIES(${incdirs} ${LIBCLAMAV_INCLUDE_DIR} ${LIBDAEMON_INCLUDE_DIR} ${LIBINOTIFYTOOLS_INCLUDE_DIR} ${INOTIFY_INCLUDE_DIR} ${LIBESMTP_INCLUDE_DIR})
+INCLUDE_DIRECTORIES(${incdirs} ${LIBCLAMAV_INCLUDE_DIR} ${LIBDAEMON_INCLUDE_DIR} ${LIBINOTIFYTOOLS_INCLUDE_DIR} ${INOTIFY_INCLUDE_DIR} ${JWSMTP_INCLUDE_DIR})
#############################################
# compile
#############################################
-ADD_EXECUTABLE(inoclam clam.c inoclam.c inotify.c monitor.c sig.c smtp.c)
+ADD_EXECUTABLE(inoclam clam.c inoclam.c inotify.c monitor.c sig.c smtp.cxx)
#############################################
# link
#############################################
-TARGET_LINK_LIBRARIES(inoclam ${LIBCLAMAV} ${LIBDAEMON} ${LIBINOTIFYTOOLS} ${LIBESMTP})
+TARGET_LINK_LIBRARIES(inoclam ${LIBCLAMAV} ${LIBDAEMON} ${LIBINOTIFYTOOLS} ${JWSMTP})
diff --git a/smtp.c b/smtp.c
deleted file mode 100644
index 6599866..0000000
--- a/smtp.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * inoclam - Inotify+ClamAV virus scanner
- * Copyright (C) 2007 Vermont Department of Taxes
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Contributor(s):
- * Tom Cort
- */
-
-#define _XOPEN_SOURCE 500
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-int smtp_send(char *hostport, char *to, char *from, char *subject) {
- smtp_session_t session;
- smtp_message_t message;
- smtp_recipient_t recipient;
- const smtp_status_t *status;
-
- session = smtp_create_session();
- message = smtp_add_message(session);
-
- /* TODO error checking */
-
- /* TODO make this configurable */
- smtp_set_server(session, hostport);
- smtp_set_reverse_path (message, from);
- smtp_set_header(message, "To", NULL, NULL);
- smtp_set_header(message, "Subject", subject);
- smtp_set_header_option(message, "Subject", Hdr_OVERRIDE, 1);
-
- /* TODO use our own callback */
- smtp_set_message_fp(message, stdin);
- recipient = smtp_add_recipient(message, to);
- smtp_start_session(session);
- smtp_destroy_session(session);
-}
diff --git a/smtp.h b/smtp.cxx
similarity index 62%
copy from smtp.h
copy to smtp.cxx
index e6708a2..91d31a5 100644
--- a/smtp.h
+++ b/smtp.cxx
@@ -20,9 +20,21 @@
* Tom Cort
*/
-#ifndef __SMTP_H
-#define __SMTP_H
+#include
-int smtp_send();
+#include "smtp.hxx"
-#endif
+/*
+ * TODO: Replace these defaults with something more configurable ;)
+ */
+#define SMTP_TO "tom.cort@state.vt.us"
+#define SMTP_FROM "tom.cort@state.vt.us"
+#define SMTP_SUBJECT "[inoscan] Virus Detected"
+#define SMTP_BODY "Virus Found. Check the Logs."
+#define SMTP_HOSTNAME "localhost"
+#define SMTP_PORT (25)
+
+int smtp_send(char *body) {
+ jwsmtp::mailer mail(SMTP_TO, SMTP_FROM, SMTP_SUBJECT, SMTP_BODY, SMTP_HOSTNAME, SMTP_PORT, false);
+ mail.send();
+}
diff --git a/smtp.h b/smtp.hxx
similarity index 93%
rename from smtp.h
rename to smtp.hxx
index e6708a2..1797d06 100644
--- a/smtp.h
+++ b/smtp.hxx
@@ -20,9 +20,9 @@
* Tom Cort
*/
-#ifndef __SMTP_H
-#define __SMTP_H
+#ifndef __SMTP_HXX
+#define __SMTP_HXX
-int smtp_send();
+int smtp_send(char *body);
#endif
diff --git a/www/index.html b/www/index.html
index 7442d77..67e9479 100644
--- a/www/index.html
+++ b/www/index.html
@@ -68,7 +68,7 @@
ClamAV 0.91 or later
inotify-tools 3.12 or later
libdaemon 0.12 or later
- LibESMTP 1.0.3 or later
+ jwSMTP 1.32 or later
--
2.11.4.GIT