Icinga2: Acknowledgement comments with newlines break emails using default notify scripts.

Created on 18 Sep 2019  路  6Comments  路  Source: Icinga/icinga2

Describe the bug

Acknowledging a service or host problem with a comment containing a newline causes the notification email to be blank with an unnamed attachment.

If the comment contains a newline, the email seems to be encoded as base64 which breaks rendering in thunderbird, evolution and also iPhone. On the desktop it's possible to download the attachment and view in a text editor, however on iphone I'm not able to view the attachment so is impossible to read the ACK message.

To Reproduce

Provide a link to a live example, or an unambiguous set of steps to reproduce this issue. Include configuration, logs, etc. to reproduce, if relevant.

  1. Acknowledge a host or service problem with a comment and select send notification
  2. If the message does not contain newlines then it is displayed in email clients as text.
  3. If the message does contain a newline then the email client shows a blank message with an attachment.
    Evolution calls the attachment "attachment.dat", thunderbird shows it as an unnamed file. iPhone shows it as "mime-attachment".

Expected behaviour

Contents of the message to be part of the email body text (as it does when there's no newlines).

Screenshots

If applicable, add screenshots to help explain your problem.

Your Environment

Include as many relevant details about the environment you experienced the problem in

  • Icinga Web 2 version and modules (System - About):
    Icinga Web 2 Version: 2.7.1
    Git commit
    b0bf9c4b0637f6113adb788e78c2bcf619225dd8
    PHP Version
    7.1.8```
  • Web browser used: Firefox 69
  • Icinga 2 version used (icinga2 --version): r2.10.5-1
  • Server operating system and version:
    Centos 7 64bit (latest).
    user-agent: Heirloom mailx 12.5 7/5/10

Additional context

debug logs

No newline:

[2019-09-18 14:59:37 +0100] notice/Process: Running command '/etc/icinga2/scripts/mail-host-notification.sh' '-4' '192.168.17.198' '-6' '' '-b' 'icingauser' '-c' 'host problem - no newline.' '-d' '2019-09-18 14:59:37 +0100' '-f' 'Icinga <[email protected]>' '-l' 'df-testhost' '-n' 'df-testhost' '-o' 'CRITICAL - Plugin timed out' '-r' '[email protected]' '-s' 'DOWN' '-t' 'ACKNOWLEDGEMENT' '-v' 'false': PID 13656

With newline:

[2019-09-18 14:50:44 +0100] notice/Process: Running command '/etc/icinga2/scripts/mail-host-notification.sh' '-4' '192.168.17.198' '-6' '' '-b' 'icingauser' '-c' 'host problem\r\nwith newline' '-d' '2019-09-18 14:50:44 +0100' '-f' 'Icinga <[email protected]>' '-l' 'df-testhost' '-n' 'df-testhost' '-o' 'CRITICAL - Plugin timed out' '-r' '[email protected]' '-s' 'DOWN' '-t' 'ACKNOWLEDGEMENT' '-v' 'false': PID 29353

Email source

No newline:

```From: Icinga icinga@mydomain.com
To: [email protected]
Subject: [ACKNOWLEDGEMENT] Current Load on df-testhost is
CRITICAL!
User-Agent: Heirloom mailx 12.5 7/5/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable

Service Monitoring on icinga.mydomain.com

Current Load on df-testhost is CRITICAL!

Info: connect to address 192.168.17.198 port 5666: Connection refuse=
d
connect to host 192.168.xx.xx port 5666: Connection refused

When: 2019-09-18 14:05:00 +0100
Service: Current Load
Host: df-testhost
IPv4: 192.168.xx.x

Comment by icingauser:
this is also an ack!=

#### with newline:
```From: Icinga <[email protected]>
To: [email protected]
Subject: [ACKNOWLEDGEMENT] ntp on df-testhost is CRITICAL!
User-Agent: Heirloom mailx 12.5 7/5/10
MIME-Version: 1.0
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64

KioqKiogU2VydmljZSBNb25pdG9yaW5nIG9uIGljaW5nYS5teWRvbWFpbi5jb20gKioqKioKCm50
cCBvbiBkZi10ZXN0aG9zdCBpcyBDUklUSUNBTCEKCkluZm86ICAgIGNvbm5lY3QgdG8gYWRkcmVz
cyAxOTIuMTY4Lnh4Lnh4IHBvcnQgNTY2NjogQ29ubmVjdGlvbiByZWZ1c2VkCmNvbm5lY3QgdG8g
aG9zdCAxOTIuMTY4Lnh4Lnh4IHBvcnQgNTY2NjogQ29ubmVjdGlvbiByZWZ1c2VkCgpXaGVuOiAg
ICAyMDE5LTA5LTE4IDE0OjA1OjEyICswMTAwClNlcnZpY2U6IG50cApIb3N0OiAgICBkZi10ZXN0
aG9zdApJUHY0OiAgICAxOTIuMTY4Lnh4Lnh4CgpDb21tZW50IGJ5IGljaW5nYXVzZXI6CiAgYW5k
IHRoaXMsIG9uY2UgYWdhaW4sIGlzIGFuIGFjay4KdGhpcyB0aW1lIHdpdGggYSBuZXdsaW5l

Hopefully my attempts to redact the information haven't caused any confusion

arenotifications aresetup

Most helpful comment

From what I understand the reporter uses Icinga 2.10.5, while 2.11.0 got my fix #7184, which should address the reported issue. Further on the reporter refers to the body while #6369 refers to the headers. My suggestion would be to test my fix from #7184 on 2.10.5 as it's supposed to address it.

All 6 comments

Thanks, we'll look into this after 2.11 has been released.

We had similar problems with non-us-ascii characters and there are solutions tested in https://github.com/Icinga/icinga2/pull/6369. Can you @BuildTheRobots have a look into this and test if this also solves your problem? If so it would be a good reason to move this approach forward.

I've tested with the new mail-host-noficiation.sh script as linked in #6369 and it seems to make the situation significantly worse.

The standard host down notifications now include half the headers inside the email body (though all in ascii) and the multi-line ack now has ascii headers and a base64 encoded blob.

This is still on centos-7. The only change made is swapping out the host notify script.

Screenshots are from thunderbird, same display issues in Evolution and on iPhone.

icinga-hostdown

icinga-notification

From what I understand the reporter uses Icinga 2.10.5, while 2.11.0 got my fix #7184, which should address the reported issue. Further on the reporter refers to the body while #6369 refers to the headers. My suggestion would be to test my fix from #7184 on 2.10.5 as it's supposed to address it.

I'll be back in the office middle of next week and will test the fix in #7184 then. Thank you :)

Can confirm that the updated scripts in #7184 (which also seem to have mainlined into centos) seem to have fixed the newline issue.
Greatest of thanks :)

Was this page helpful?
0 / 5 - 0 ratings