<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>32471</bug_id>
          
          <creation_ts>2003-11-01 08:36 0000</creation_ts>
          <short_desc>apcupsd sends mail with an error in the headers</short_desc>
          <delta_ts>2009-04-02 13:06:09 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Core system</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>demerss@gmail.com</reporter>
          <assigned_to>tantive@gentoo.org</assigned_to>
          <cc>swtaylor@gentoo.org</cc>

      

      
          <long_desc isprivate="0">
            <who>demerss@gmail.com</who>
            <bug_when>2003-11-01 08:36:39 0000</bug_when>
            <thetext>apcupsd 3.10.5 (up to and including -r3) and 3.10.6 
 
When a power event occurs, scripts in the /etc/apcupsd directory are executed. 
Those scripts send mail, but they add an extra CRLF after the subject line of 
the headers, so we end up with something like this: 
 
  Return-Path: &lt;root@blackbox.linux&gt; 
  X-Original-To: black 
  Delivered-To: black@blackbox.linux 
  Received: by blackbox.linux (Postfix, from userid 0) 
  	id 81C7210CC0E; Sat,  1 Nov 2003 10:41:41 -0500 (EST) 
  Subject: blackbox.linux Power has returned 
    
  Message-Id: &lt;20031101154141.81C7210CC0E@blackbox.linux&gt; 
  Date: Sat,  1 Nov 2003 10:41:41 -0500 (EST) 
  From: root@blackbox.linux (root) 
  To: undisclosed-recipients:; 
 
The extra line makes the following part of the message rather than part of the 
headers, so Date, From and To are, in effect, missing. 
 
The problem comes from the scripts in /etc/apcupsd. For example, mainsback 
contains this: 
  HOSTNAME=`hostname` 
  MSG=&quot;$HOSTNAME Power has returned&quot; 
  # 
  ( 
     echo &quot;Subject: $MSG&quot; 
     echo &quot; &quot; 
     echo &quot;$MSG&quot; 
     echo &quot; &quot; 
     /usr/sbin/apcaccess status 
  ) | $APCUPSD_MAIL $SYSADMIN 
 
(Note: the last line is $APCUPSD_MAIL -s $MSG $SYSDAMIN in 3.10.6, see below 
as it causes problems with Postfix on my system) 
 
The problem here is that the headers should be separated from the message body 
with a blank line, but the above script sends a line with a single space after 
the &quot;Subject&quot; line.  To correct, change to this: 
   echo &quot;Subject: $MSG&quot; 
   echo 
   echo &quot;$MSG&quot; 
 
Echo alone will output the required blank line. 
 
Also, I suggest adding the following line just before or after the subject: 
   echo &quot;To: $SYSADMIN&quot; 
 
This will prevent postfix/sendmail from adding &quot;To: Undisclosed recipients&quot; 
which in turn triggers a SpamAssassin rule. 
 
Finally, with 3.10.6, the sendmail command is called with the -s parameter to 
set the subject. Postfix doesn&apos;t seem to like this and thus fails to send the 
mail. Is this required for SendMail? If so, maybe we could add a parameter 
somewhere so that this switch isn&apos;t used when using Postfix. Or we could have 
the Postfix team just ignore that switch! :) 
 

Reproducible: Always
Steps to Reproduce:</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>demerss@gmail.com</who>
            <bug_when>2003-11-01 08:44:54 0000</bug_when>
            <thetext>Created an attachment (id=20062)
Patch for my suggestions

Note: this is the first time I create a patch, so I&apos;d like somebody to check
if
it&apos;s done ok first.

I made a directory called &quot;old&quot; with the original files and a &quot;new&quot; directory
with my modified files, the called &quot;diff -u old new &gt; apcupsd.patch&quot;.

I tried applying patches with &quot;patch -p1 &lt; apcupsd.patch&quot; while in the
/etc/apcupsd directory, and it seems to work.

This patch removes the changes &apos;echo &quot; &quot;&apos; to &apos;echo&apos;, adds a &quot;To&quot; line and
removes the -s switch to the sendmail command because Postfix doesn&apos;t like
it.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>swtaylor@gentoo.org</who>
            <bug_when>2003-11-01 11:02:01 0000</bug_when>
            <thetext>qmail will not even send any email when the -s &quot;$MSG&quot; is in the command line.
Isn&apos;t that redundant anyway since the message itself contains the &quot;Subject:&quot;
header? I&apos;m all in favor of adding more complete headers too.

Please! strip the -s &quot;$MSG&quot; from the scripts, and while you&apos;re at it, copy
or symlink the /etc/apcupsd/onbattery to also run as /etc/apcupsd/powerout
- apparently different models send different signals for a power failure.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>tantive@gentoo.org</who>
            <bug_when>2003-11-01 12:04:30 0000</bug_when>
            <thetext>I checked in an corrected ebuild (the 3.10.6.ebuild one) with
-the patch and with
-ln -s onbattery powerout.

Please check if everything is fine.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>swtaylor@gentoo.org</who>
            <bug_when>2003-11-01 13:06:45 0000</bug_when>
            <thetext>Thanks! It peacefully coexists with qmail now. After several simulated power
outages, I actually got one onbattery alert (the first one I&apos;ve ever seen
here) but it never missed the powerout alerts. This closes #30716 as well.

Here&apos;s the scripts that actually got called. Getting an occasional extra
email updating the status from powerout to onbattery is far better in my
book than getting a mystery email that power has returned without having
a power failure to match it up with...
/etc/apcupsd/powerout BERTHOUD 1 0
/etc/apcupsd/mainsback BERTHOUD 1 0
/etc/apcupsd/powerout BERTHOUD 1 0
/etc/apcupsd/mainsback BERTHOUD 1 0
/etc/apcupsd/powerout BERTHOUD 1 0
/etc/apcupsd/onbattery BERTHOUD 1 0
/etc/apcupsd/mainsback BERTHOUD 1 0

</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>demerss@gmail.com</who>
            <bug_when>2003-11-01 15:30:24 0000</bug_when>
            <thetext>I&apos;m happy with that! Case closed as far as I&apos;m concerned!

Thanks!
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>tantive@gentoo.org</who>
            <bug_when>2003-11-02 02:30:14 0000</bug_when>
            <thetext>Good news for me :)

I closes #30716 and will close this one now.
Thanks for your testing. Feel free to report any other bugs you find within
apcupsd.</thetext>
          </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>20062</attachid>
            <date>2003-11-01 08:44 0000</date>
            <desc>Patch for my suggestions</desc>
            <filename>apcupsd.patch</filename>
            <type>text/plain</type>
            <data encoding="base64">ZGlmZiAtdSBvbGQvY2hhbmdlbWUgbmV3L2NoYW5nZW1lCi0tLSBvbGQvY2hhbmdlbWUJMjAwMy0x
MS0wMSAxMTozMToxMC4wMDAwMDAwMDAgLTA1MDAKKysrIG5ldy9jaGFuZ2VtZQkyMDAzLTExLTAx
IDExOjI3OjA5LjAwMDAwMDAwMCAtMDUwMApAQCAtMTMsOSArMTMsMTAgQEAKICMKICgKICAgIGVj
aG8gIlN1YmplY3Q6ICRNU0ciCi0gICBlY2hvICIgIgorICAgZWNobyAiVG86ICRTWVNBRE1JTiIK
KyAgIGVjaG8KICAgIGVjaG8gIiRNU0ciCiAgICBlY2hvICIgIgogICAgL3Vzci9zYmluL2FwY2Fj
Y2VzcyBzdGF0dXMKLSkgfCAkQVBDVVBTRF9NQUlMIC1zICIkTVNHIiAkU1lTQURNSU4KKykgfCAk
QVBDVVBTRF9NQUlMICRTWVNBRE1JTgogZXhpdCAwCmRpZmYgLXUgb2xkL2NvbW1mYWlsdXJlIG5l
dy9jb21tZmFpbHVyZQotLS0gb2xkL2NvbW1mYWlsdXJlCTIwMDMtMTEtMDEgMTE6MzE6MjYuMDAw
MDAwMDAwIC0wNTAwCisrKyBuZXcvY29tbWZhaWx1cmUJMjAwMy0xMS0wMSAxMToyNzoxMy4wMDAw
MDAwMDAgLTA1MDAKQEAgLTEzLDkgKzEzLDEwIEBACiAjCiAoCiAgICBlY2hvICJTdWJqZWN0OiAk
TVNHIgotICAgZWNobyAiICIKKyAgIGVjaG8gIlRvOiAkU1lTQURNSU4iCisgICBlY2hvCiAgICBl
Y2h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