Hi, I updated the patch once again. The new version doesn't use signing of the message anymore and will not complain if gnupg ist not installed (it will ignore that fact and work as usual). Additionally a check was added that will determine if a public key for the intended receiver of the apticron-mail is available. If not, apticron will work as usual. All that being accomplished with fewer lines of code than before.
Best regards, Matthias
diff --git a/apticron b/apticron index f55071c..ed4d700 100755 --- a/apticron +++ b/apticron @@ -4,27 +4,34 @@ # 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 gpg --list-public-keys "$EMAIL" > /dev/null 2>&1; then + msg=$(echo "$msg" | gpg --trust-model always --batch --armor --encrypt --recipient "$EMAIL") + 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" \ "$@"
signature.asc
Description: OpenPGP digital signature