[Logcheck-commits] Hannes von Haugwitz: Use mime-construct to send mail (closes: #542781, #564693)

Gerfried Fuchs alfie at alioth.debian.org
Mon Feb 8 17:44:35 UTC 2010


Module: logcheck
Branch: lenny-backports
Commit: c6dad099e03d938b5733ef81b3080e4c41c4e8ce
URL:    http://git.debian.org/?p=logcheck/logcheck.git;a=commit;h=c6dad099e03d938b5733ef81b3080e4c41c4e8ce

Author: Hannes von Haugwitz <hannes at vonhaugwitz.com>
Date:   Mon Jan 25 15:16:40 2010 +0100

Use mime-construct to send mail (closes: #542781, #564693)

---

 debian/changelog |    1 +
 debian/control   |    2 +-
 src/logcheck     |   23 +++++++++--------------
 3 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 1564268..28204a5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
 logcheck (1.3.6) UNRELEASED; urgency=low
 
   [ Hannes von Haugwitz ]
+  * Use mime-construct to send mail (closes: #542781, #564693)
   * etc/logcheck.conf:
     - added hint for suggested package
   * Removed obsolete files in violations.ignore.d/ (closes: #566107)
diff --git a/debian/control b/debian/control
index 9dcc294..c8a7970 100644
--- a/debian/control
+++ b/debian/control
@@ -12,7 +12,7 @@ Homepage: http://www.logcheck.org/
 
 Package: logcheck
 Architecture: all
-Depends: adduser, exim4 | mail-transport-agent, cron, rsyslog | system-log-daemon, bsd-mailx | mailx, logtail (>= 1.2.59), lockfile-progs, ${misc:Depends}
+Depends: adduser, exim4 | mail-transport-agent, cron, rsyslog | system-log-daemon, mime-construct, logtail (>= 1.2.59), lockfile-progs, ${misc:Depends}
 Recommends: logcheck-database (>= ${source:Version})
 Suggests: syslog-summary
 Description: mails anomalies in the system logfiles to the administrator
diff --git a/src/logcheck b/src/logcheck
index 0a64119..436bee9 100755
--- a/src/logcheck
+++ b/src/logcheck
@@ -1,6 +1,6 @@
 #!/bin/bash
 #
-# Copyright (C) 2004-2007 Debian Logcheck Team
+# Copyright (C) 2004-2010 Debian Logcheck Team
 #                         <logcheck-devel at alioth.lists.debian.org>
 # Copyright (C) 2002,2003 Jonathan Middleton <jjm at ixtab.org.uk>
 # Copyright (C) 1999-2002 Rene Mayrhofer <rmayr at debian.org>
@@ -51,7 +51,7 @@ GETOPTS="c:dhH:l:L:m:opr:RsS:tTuvw"
 
 # Get the details for the email message
 DATE="$(date +'%Y-%m-%d %H:%M')"
-VERSION="1.2.61"
+VERSION="1.3.6"
 
 # Set the default report level
 REPORTLEVEL="server"
@@ -60,7 +60,7 @@ REPORTLEVEL="server"
 SENDMAILTO="root"
 
 # by default, append a header
-MAILARGS="-a 'Auto-Submitted: auto-generated'"
+MIMECONSTRUCTARGS="--header 'Auto-Submitted: auto-generated'"
 
 # Set the default subject lines
 ATTACKSUBJECT="Security Alerts"
@@ -174,9 +174,9 @@ Also verify that the logcheck user can read all files referenced in
 
 $(export)
 EOF
-	} | eval mail $MAILARGS \
-	    -s "'Logcheck: $HOSTNAME $DATE exiting due to errors'" \
-	    "$SENDMAILTO"
+	} | eval mime-construct $MIMECONSTRUCTARGS \
+	    --subject "'Logcheck: $HOSTNAME $DATE exiting due to errors'" --file - \
+	    --to "$SENDMAILTO"
 
     elif [ "$MAILOUT" -eq 1 ]; then
           {
@@ -302,15 +302,10 @@ sendreport() {
 	debug "Sending report: '$subject' to $SENDMAILTO"
         if [ "$MAILASATTACH" -eq 1 ]; then
           debug "Sending report as attachment"
-          if command -v nail >/dev/null; then
-            echo "Report attached" | nail -s "$subject" -a "$TMPDIR/report" "$SENDMAILTO"
-            return $?
-          else
-            echo >> "$TMPDIR/report"
-            echo Could not send report as attachment, nail not installed >> "$TMPDIR/report"
-          fi
+          eval mime-construct $MIMECONSTRUCTARGS --subject "'$subject'" --string "'Report attached'" --to "$SENDMAILTO" --attachment "logcheck_report" --encoding "base64" --file "$TMPDIR/report"
+          return $?
         fi
-        cat "$TMPDIR/report" | eval mail $MAILARGS -s "'$subject'" "$SENDMAILTO"
+        eval mime-construct $MIMECONSTRUCTARGS --subject "'$subject'" --to "$SENDMAILTO" --file "$TMPDIR/report"
     fi
 }
 




More information about the Logcheck-commits mailing list