Hi Tiago,

I updated the patch file (can now be applied on top of commit
e457576ebbf742245ca03458b4902478d214a8c8).

Best whishes,

Matthias



diff --git a/apticron b/apticron
index f55071c..7c9cc56 100755
--- a/apticron
+++ b/apticron
@@ -4,27 +4,41 @@
 # implementations in Debian. Make sure we send proper headers, and a
 # text/plain content type.
 Mailx() {
+    # The statement msg="$(xargs --null echo)" will fail if the generated message
+    # is very long with xargs: argument line too long.
+    msg="$(xargs --null echo)"
+    if which gpg > /dev/null ; then
+        msg=$(echo "$msg" | gpg --trust-model always --batch --armor --encrypt --recipient $EMAIL --sign --passphrase $GPG_PASS_PHRASE)
+        if [ -z "$msg" ]; then
+            echo "GnuPG error. Could not encrypt message for $EMAIL. Exiting here."
+            exit 1
+        fi
+    else
+        echo "GnuPG not installed. Exiting here."
+        exit 1
+    fi
+
     local MAILER="`readlink -e /usr/bin/mailx`"
     if [ x$MAILER = "x/usr/bin/heirloom-mailx" -o x$MAILER = "x/usr/bin/s-nail" ]
 	then
 		# heirloom-mailx creates correct headers, but needs help
 		# if the terminal charset (LC_CTYPE) is no UTF-8 locale
 		if [ -n "$CUSTOM_FROM" ] ; then
-			/usr/bin/mailx -S ttycharset=utf-8 -r "$CUSTOM_FROM" "$@"
+			echo "$msg" | /usr/bin/mailx -S ttycharset=utf-8 -r "$CUSTOM_FROM" "$@"
 		else
-			/usr/bin/mailx -S ttycharset=utf-8 "$@"
+			echo "$msg" | /usr/bin/mailx -S ttycharset=utf-8 "$@"
 		fi
 	else
 		# bsd-mailx/mailutils' mailx don't do character set
 		# conversion, but do not support MIME either.
 		if [ -n "$CUSTOM_FROM" ] ; then
-			/usr/bin/mailx -a "MIME-Version: 1.0" \
+			echo "$msg" | /usr/bin/mailx -a "MIME-Version: 1.0" \
 				-a "Content-type: text/plain; charset=UTF-8" \
 				-a "Content-transfer-encoding: 8bit" \
 				-a "From: $CUSTOM_FROM" \
 				"$@"
 		else
-			/usr/bin/mailx -a "MIME-Version: 1.0" \
+			echo "$msg" | /usr/bin/mailx -a "MIME-Version: 1.0" \
 				-a "Content-type: text/plain; charset=UTF-8" \
 				-a "Content-transfer-encoding: 8bit" \
 				"$@"

Reply via email to