Bug#846060: patch

2016-11-28 Thread Ola Lundqvist
Hi Bob and Bas

Thank you very much for this. I have changed the code according to
that and uploaded a new release.

// Ola

On 28 November 2016 at 20:21, Bob Proulx  wrote:
> Bas Zoetekouw wrote:
>> -eval mail $XHEADERS -s \"$SUBJECT\" \"$MAILTO\" < "$MAIL"
>> +( printf "$hdr\n"; echo; cat $MAIL ) | sendmail -t
>
> If using sendmail and reading from stdin then the -oi option should
> also be used.  The sendmail man page says:
>
>   -oi  When reading a message from standard input, don't treat a line
>   with only a . character as the end of input.
>
> Therefore:
>
>   ... | sendmail -t -oi
>
> Bob



-- 
 --- Inguza Technology AB --- MSc in Information Technology 
/  o...@inguza.comFolkebogatan 26\
|  o...@debian.org   654 68 KARLSTAD|
|  http://inguza.com/Mobile: +46 (0)70-332 1551 |
\  gpg/f.p.: 7090 A92B 18FE 7994 0C36 4FE4 18A1 B1CF 0FE5 3DD9  /
 ---



Bug#846060: patch

2016-11-28 Thread Bob Proulx
Bas Zoetekouw wrote:
> -eval mail $XHEADERS -s \"$SUBJECT\" \"$MAILTO\" < "$MAIL"
> +( printf "$hdr\n"; echo; cat $MAIL ) | sendmail -t

If using sendmail and reading from stdin then the -oi option should
also be used.  The sendmail man page says:

  -oi  When reading a message from standard input, don't treat a line
  with only a . character as the end of input.

Therefore:

  ... | sendmail -t -oi

Bob


signature.asc
Description: PGP signature


Bug#846060: patch

2016-11-28 Thread Ola Lundqvist
Hi Bas

Thank you. I'll have a look at this.
At a quick look it looks good.

// Ola

On 28 November 2016 at 11:32, Bas Zoetekouw  wrote:
> Tags: patch
>
> Hi,
>
> Here's a patch to use sendmail directly, instead of relying on mailx.
> sendmail -t should work with any decent MTA.
>
> Greetings,
> Bas.



-- 
 --- Inguza Technology AB --- MSc in Information Technology 
/  o...@inguza.comFolkebogatan 26\
|  o...@debian.org   654 68 KARLSTAD|
|  http://inguza.com/Mobile: +46 (0)70-332 1551 |
\  gpg/f.p.: 7090 A92B 18FE 7994 0C36 4FE4 18A1 B1CF 0FE5 3DD9  /
 ---



Bug#846060: patch

2016-11-28 Thread Bas Zoetekouw
Tags: patch

Hi,

Here's a patch to use sendmail directly, instead of relying on mailx.
sendmail -t should work with any decent MTA.

Greetings,
Bas.
diff --git a/debian/changelog b/debian/changelog
index 3a8cc38..71b18fa 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+cron-apt (0.9.6.bas) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * test sendmail  
+
+ -- Bas Zoetekouw   Mon, 28 Nov 2016 11:03:16 +0100
+
 cron-apt (0.9.6) unstable; urgency=medium
 
   * Correction to make it work with space in XHEADERS. Closes: #813609.
diff --git a/debian/control b/debian/control
index f12fb70..4438d01 100644
--- a/debian/control
+++ b/debian/control
@@ -9,7 +9,7 @@ Standards-Version: 3.9.6
 Package: cron-apt
 Architecture: all
 Depends: apt, ${misc:Depends}
-Recommends: liblockfile1, mailx, cron | cron-daemon
+Recommends: liblockfile1, cron | cron-daemon, mail-transport-agent
 Description: automatic update of packages using apt-get
  Contains a tool that is run by a cron job at regular intervals. By default it
  just updates the package list and downloads new packages without installing.
diff --git a/src/functions b/src/functions
index 8ff2d74..4e3dcf0 100644
--- a/src/functions
+++ b/src/functions
@@ -94,27 +94,29 @@ onexit() {
rm -f "$RUNMAIL"
 fi
 if [ -f "$MAIL" ] && [ "$MAILON" != "never" ] && [ -n "$MAILON" ] ; then
-   if command -v mail >/dev/null; then
+   if command -v sendmail >/dev/null; then
+   hdr="To: $MAILTO"
if [ -z "$HOSTNAME" ]; then
HOSTNAME="$(uname -n)"
fi
-   SUBJECT="CRON-APT completed on $HOSTNAME [$CONFIG]"
if [ -f "$ERROR" ] ; then
-   SUBJECT="CRON-APT error on $HOSTNAME [$CONFIG]"
+   hdr=$(printf "$hdr\nSubject: CRON-APT error on $HOSTNAME 
[$CONFIG]")
+   else
+   hdr=$(printf "$hdr\nSubject: CRON-APT completed on $HOSTNAME 
[$CONFIG]")
fi
# Support for XHEADERS
 i=1
eval "VAL=\${XHEADER$i}"
while [ ! -z "$VAL" ] ; do
-   XHEADERS="$XHEADERS -a \"$VAL\""
+   hdr=$(printf "$hdr\n$VAL")
i=$(( $i + 1 ))
eval "VAL=\${XHEADER$i}"
done
#
-eval mail $XHEADERS -s \"$SUBJECT\" \"$MAILTO\" < "$MAIL"
+( printf "$hdr\n"; echo; cat $MAIL ) | sendmail -t
else
-   echo >&2 "cron-apt was configured to send e-mail, but no mail 
binary found in path."
-   echo >&2 "Either set MAILON=never in configuration or install the 
mailx package."
+   echo >&2 "cron-apt was configured to send e-mail, but no sendmail 
binary was found in path."
+   echo >&2 "Either set MAILON=never in configuration or install an 
MTA package."
fi
rm -f "$MAIL"
 fi


signature.asc
Description: OpenPGP digital signature