pkg-nagios-plugins-contrib icon indicating copy to clipboard operation
pkg-nagios-plugins-contrib copied to clipboard

Incorrect date format in check_email_delivery/check_smtp_send

Open dverite opened this issue 7 years ago • 0 comments

When LC_TIME is non english, the default_date_header in check_smtp_send will output, for example:

Date: mar., 7 août 2018 10:55:41 +0200 (CEST)

This does not conform to RFC822 for several reasons:

  • the day and months must be in english
  • the trailing time zone name is not allowed.
  • the hour is expressed in GMT but the +0200 time displacement claims that's it local, i.e. in the above example, it should be 12:55:41 +0200, or 10:55:41 +0000 if GMT is prefered for some reason.

Date and time spec in RFC822: https://tools.ietf.org/html/rfc2822#page-14

Proposed fix:

use POSIX qw(strftime locale_h);
...
sub default_date_header {
 my $old_locale = setlocale(LC_TIME, "C");
 my $date_rfc822 = strftime("%a, %d %b %Y %H:%M:%S %z", localtime);
 setlocale(LC_TIME, $old_locale);
 return "Date: $date_rfc822";
}

dverite avatar Aug 07 '18 11:08 dverite