Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that "mail from" works on RHEL/CentOS #5299

Closed
dnsmichi opened this issue May 29, 2017 · 2 comments · Fixed by #5357
Closed

Ensure that "mail from" works on RHEL/CentOS #5299

dnsmichi opened this issue May 29, 2017 · 2 comments · Fixed by #5357
Assignees
Labels
area/notifications Notification events
Milestone

Comments

@dnsmichi
Copy link
Contributor

Change from #5170 (comment) doesn't seem to work reliably.

#5170 (comment) tell that tests happened, but I doubt they were successful.

Before releasing 2.7 we should ensure to have this working properly.

@dnsmichi
Copy link
Contributor Author

Discussed it offline. Unfortunately tests did not target the "mail from" functionality. So we need to fix that accordingly.

dnsmichi pushed a commit that referenced this issue Jun 16, 2017
dnsmichi pushed a commit that referenced this issue Jun 16, 2017
@dnsmichi
Copy link
Contributor Author

Analysis

mail on Linux/Unix is a PITA.

Now for my findings:

  • Debian's default supports -a (from mailutils)

  • RHEL uses -a for attachments, but insists on -r (which is the default for "mailx")

  • Unix might have or not have it

  • -a expects From: Firstname Lastname <mail@foo.com>

  • -r expects a single string with an email address, or "Firstname Lastname mail@foo.com".

The only thing I see here, to make it at least work on the base distributions we support:

  • check for /etc/debian-version and use mailutils
  • use mailx otherwise (on rhel it is called bsd-mailx, so I would believe that *BSD has it too)
  • add the right param and format
  • add documentation for the user with the encouragement to modify the script for their own mail binary with different parameters.

If anyone comes up with a proper bash script or patch, feel free. But not for v2.7 anymore.

Misc

The script wasn't properly tested on Ubuntu/Debian. There must have been a warning at least for /bin/sh not being bash but dash. Needs to be changed too.

./mail-service-notification.sh: 135: [: unexpected operator

Tests

CentOS 7

[root@icinga2 ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

[root@icinga2 ~]# ./mail-service-notification.sh -4 1.2.3.4 -d 1234 -e bumsti -l foohost -n schnurzi -u puh -o "i hate different mail binaries and different behaviours" -r "michael.friedrich@netways.de" -s 2 -t PROBLEM -f "Michael Friedrich <michael.friedrich@icinga.com>"
From: Michael Friedrich <michael.friedrich@icinga.com>
Subject: [PROBLEM] puh on schnurzi is 2!
Date: 16. June 2017 at 20:40:40 GMT+2
To: michael.friedrich@netways.de


***** Icinga 2 Service Monitoring on foohost *****

==> puh on schnurzi is 2! <==

Info:    i hate different mail binaries and different behaviours

When:    1234
Service: bumsti (Display Name: "puh")
Host:    foohost (Display Name: "schnurzi")
IPv4:    1.2.3.4

Ubuntu 16.04 LTS

root@vagrant:~# cat /etc/os-release
NAME="Ubuntu"
VERSION="16.04.2 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.2 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial

root@vagrant:~# ./mail-service-notification.sh -4 1.2.3.4 -d 1234 -e bumsti -l foohost -n schnurzi -u puh -o "i hate different mail binaries and different behaviours" -r "michael.friedrich@netways.de" -s 2 -t PROBLEM -f "Michael Friedrich <michael.friedrich@icinga.com>"
From: Michael Friedrich <michael.friedrich@icinga.com>
Subject: [PROBLEM] puh on schnurzi is 2!
Date: 16. June 2017 at 20:35:33 GMT+2
To: <michael.friedrich@netways.de>


***** Icinga 2 Service Monitoring on foohost *****

==> puh on schnurzi is 2! <==

Info:    i hate different mail binaries and different behaviours

When:    1234
Service: bumsti (Display Name: "puh")
Host:    foohost (Display Name: "schnurzi")
IPv4:    1.2.3.4

@dnsmichi dnsmichi self-assigned this Jun 16, 2017
dnsmichi pushed a commit that referenced this issue Jun 16, 2017
dnsmichi pushed a commit that referenced this issue Jun 16, 2017
Notification Scripts: Ensure that mail from address works on Debian/RHEL/SUSE (mailutils vs mailx)

fixes #5299
Crunsher pushed a commit that referenced this issue Jul 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/notifications Notification events
Projects
None yet
2 participants
@dnsmichi and others