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: <root@blackbox.linux> 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: <20031101154141.81C7210CC0E@blackbox.linux> 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="$HOSTNAME Power has returned" # ( echo "Subject: $MSG" echo " " echo "$MSG" echo " " /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 "Subject" line. To correct, change to this: echo "Subject: $MSG" echo echo "$MSG" Echo alone will output the required blank line. Also, I suggest adding the following line just before or after the subject: echo "To: $SYSADMIN" This will prevent postfix/sendmail from adding "To: Undisclosed recipients" 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'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't used when using Postfix. Or we could have the Postfix team just ignore that switch! :) Reproducible: Always Steps to Reproduce:
Created attachment 20062 [details, diff] Patch for my suggestions Note: this is the first time I create a patch, so I'd like somebody to check if it's done ok first. I made a directory called "old" with the original files and a "new" directory with my modified files, the called "diff -u old new > apcupsd.patch". I tried applying patches with "patch -p1 < apcupsd.patch" while in the /etc/apcupsd directory, and it seems to work. This patch removes the changes 'echo " "' to 'echo', adds a "To" line and removes the -s switch to the sendmail command because Postfix doesn't like it.
qmail will not even send any email when the -s "$MSG" is in the command line. Isn't that redundant anyway since the message itself contains the "Subject:" header? I'm all in favor of adding more complete headers too. Please! strip the -s "$MSG" from the scripts, and while you'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.
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.
Thanks! It peacefully coexists with qmail now. After several simulated power outages, I actually got one onbattery alert (the first one I've ever seen here) but it never missed the powerout alerts. This closes #30716 as well. Here'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
I'm happy with that! Case closed as far as I'm concerned! Thanks!
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.