Bug 1317122

Summary: Report mail has wrong content type application/octet-stream instead of text/plain; charset=us-ascii
Product: [Fedora] Fedora Reporter: Peter Bieringer <pb>
Component: amandaAssignee: Josef Ridky <jridky>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 31CC: fedora, j, phracek
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-24 19:54:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Peter Bieringer 2016-03-12 06:05:27 UTC
Description of problem:
Perhaps since last update (to fix #1262571) the report got wrong content type

Version-Release number of selected component (if applicable):
amanda-3.3.8-1.fc23.x86_64


How reproducible:
Configure sending report by e-mail

Actual results:
...
User-Agent: Heirloom mailx 12.5 7/5/10
MIME-Version: 1.0
Content-Type: application/octet-stream
Content-Transfer-Encoding: 8bit
...

Expected results:

(from Amanda 3.3.3 on EL7)
...
User-Agent: Heirloom mailx 12.5 7/5/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
...

Additional info:
content application/octet stream e-mails are not displayed but can be downloaded as attachment only

contents can be only viewed displaying raw e-mail contents

Comment 1 Peter Bieringer 2016-03-24 21:02:01 UTC
Further analysis shows that this issue is caused by LANG which is not en_US and as result the displayed date is not displayed in 7bit ascii.

$ echo $LANG
de_DE.UTF-8

$ amreport backuphost 
Hostname: amandahost
Org     : backuphost
Config  : backuphost
Date    : M�rz 21, 2016 <-!!!


Proper output with LANG=C

$ LC_TIME=C amreport backuphost
Hostname: amandahost
Org     : backuphost
Config  : backuphost
Date    : March 21, 2016

=> in case sent by e-mail then contents is displayed proper

As Amanda/Report/human.pm only supports English LC_TIME should be proper set somewhere before entering

    my $date  = POSIX::strftime('%B %e, %Y', 0, 0, 0, $day, $month - 1, $year - 1900);

%B is the problematic placeholder

Following patch would fix the bug:
--- vendor_perl/Amanda/Report/human.pm.orig	2016-02-09 10:44:43.000000000 +0100
+++ vendor_perl/Amanda/Report/human.pm	2016-03-24 22:01:08.671869798 +0100
@@ -24,7 +24,7 @@
 use warnings;
 use Carp;
 
-use POSIX;
+use POSIX qw(locale_h strftime);
 use Data::Dumper;
 
 use Amanda::Config qw(:getconf config_dir_relative);
@@ -377,6 +377,7 @@
     # TODO: this should be a shared method somewhere
     my $timestamp = $report->get_timestamp();
     my ($year, $month, $day) = ($timestamp =~ m/^(\d\d\d\d)(\d\d)(\d\d)/);
+    setlocale(LC_TIME, "C");
     my $date  = POSIX::strftime('%B %e, %Y', 0, 0, 0, $day, $month - 1, $year - 1900);
     $date =~ s/  / /g; # get rid of intervening space

Comment 2 Fedora Admin XMLRPC Client 2016-07-11 10:13:25 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 3 Josef Ridky 2016-08-11 10:15:44 UTC
This problem was reported to upstream. 

Their previous suggestion for this issue is change LOCAL variable settings in system. I have posted them patch from #c1. 

We should wait for their response.

Comment 4 Fedora End Of Life 2016-11-24 16:02:30 UTC
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 5 Fedora Update System 2017-03-01 15:03:59 UTC
amanda-3.4.2-4.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2017-0ac18bda03

Comment 6 Fedora Update System 2017-03-01 15:04:16 UTC
amanda-3.4.2-4.fc25 has been submitted as an update to Fedora 25. https://bodhi.fedoraproject.org/updates/FEDORA-2017-41e61e4f94

Comment 7 Peter Bieringer 2017-03-05 11:31:12 UTC
amanda-3.4.2-4 has not a fix for this problem included

/usr/lib64/perl5/vendor_perl/Amanda/Report/human.pm

is unchanged :-(

Comment 8 Fedora End Of Life 2017-11-16 19:16:53 UTC
This message is a reminder that Fedora 25 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 25. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '25'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 25 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 9 Peter Bieringer 2017-11-19 11:09:56 UTC
still not fixed in amanda-3.4.5-5.fc27.x86_64

Comment 10 Peter Bieringer 2018-03-01 19:15:50 UTC
Any new status from upstream? What about an intermediate patch until they finally fix this?

Patch is still the same, only line numbers are slighly different from #c1

--- /usr/lib64/perl5/vendor_perl/Amanda/Report/human.pm.orig	2017-08-02 19:52:23.000000000 +0200
+++ /usr/lib64/perl5/vendor_perl/Amanda/Report/human.pm	2018-03-01 20:15:06.206915377 +0100
@@ -25,7 +25,7 @@
 use warnings;
 use Carp;
 
-use POSIX;
+use POSIX qw(locale_h strftime);
 use Data::Dumper;
 
 use Amanda::Config qw(:getconf config_dir_relative);
@@ -399,6 +399,7 @@
     # TODO: this should be a shared method somewhere
     my $timestamp = $report->get_timestamp();
     my ($year, $month, $day) = ($timestamp =~ m/^(\d\d\d\d)(\d\d)(\d\d)/);
+    setlocale(LC_TIME, "C");
     my $date  = POSIX::strftime('%B %e, %Y', 0, 0, 0, $day, $month - 1, $year - 1900);
     $date =~ s/  / /g; # get rid of intervening space

Comment 11 Jason Tibbitts 2018-03-01 21:41:03 UTC
This ticket was filed before I started helping with Amanda maintenance so I never really looked at it.  Also, upstream doesn't have any kind of public bug tracker so I can't easily check to see if this is has been reported.

I don't think anything has changed in version 3.5.1 which would help this, so I'm sending a message upstream just in case they haven't been given a heads up about this before.  And perhaps they will agree with forcing the locale, because the rest of the report isn't going to be translated so showing just the date in the current locale seems odd.  But the issue with that is that Amanda isn't really doing anything wrong; the issue is in mailx.

Try running the following, substituting your address:

LANG=de_DE.UTF-8 perl -MPOSIX -e 'print POSIX::strftime( "%A, %B %d, %Y", 0, 0, 0, 19, 1, 95, 2 ), "\n";' | mailx -s foo your@address
LANG=de_DE.UTF-8 perl -MPOSIX -e 'print POSIX::strftime( "%A, %B %d, %Y", 0, 0, 0, 19, 2, 95, 2 ), "\n";' | mailx -s foo your@address

(have to have glibc-langpack-de installed for this to work).  For me, one message is fine and the other shows up with content-type: application/octet-stream.  I don't know if mailx has any option which could be set to make things better; adding -S encoding=quoted-printable makes no difference.

Comment 12 Jason Tibbitts 2018-03-01 23:50:53 UTC
Now I'm thinking this isn't a mailx problem, either.  Run this on el7 and Fedora:

LANG=de_DE.utf8 perl -MPOSIX -e 'print POSIX::strftime( "%A, %B %d, %Y", 0, 0, 0, 19, 2, 95, 2 ), "\n";

EL7: Dienstag, März 19, 1995
F27: Sonntag, M�rz 19, 1995

So, I mean, I just don't know what to say.  Obviously the way Perl handles strftime has changed at some point.  I was just using the example from the perldoc POSIX page.

In any case, I think that somehow newer Perl versions sometimes need to be told that stdout can handle utf8.  Can you try just adding 

binmode(STDOUT, ":utf8");

near the top of the amreport script (and undoing your change to force the locale)?  For me this fixes the problem on F27, but breaks the output (because of course it does) on EL7.

Comment 13 Peter Bieringer 2018-03-02 05:57:23 UTC
I can confirm that there is no related issue on EL7, but here it's displaying the date regulary in "C":

Hostname: ***
Org     : ***
Config  : ***
Date    : March 2, 2018


No specific settings on that EL7 system

# set |egrep '(LANG|LC_TIME)'
LANG=de_DE.utf8
# env |egrep '(LANG|LC_TIME)'
LANG=de_DE.utf8

perl -MPOSIX -e 'print POSIX::strftime( "%A, %B %d, %Y", 0, 0, 0, 19, 2, 95, 2 ), "\n";
Dienstag, März 19, 1995

/usr/lib64/perl5/vendor_perl/Amanda/Report/human.pm is not adjusted there



As it also can be discussed whether it should make sense to display the date in local format while all of the rest of the report is in English I still prefer to enforce the LC_TIME=C before strftime.

Comment 14 Jason Tibbitts 2018-03-02 17:34:56 UTC
On EL7 the Amanda code is significantly older and honestly I haven't looked at what it does.  I was specifically investigating the Perl behavior on different platforms, and testing in your environment with the binmode fix would be useful information to pass to upstream.

I did raise both options (binmode and forcing the locale before calling strftime() in my message to upstream but have not yet received a response.  I would provide a link to the thread but sourceforge is offline so amanda.org does not currently respond.  If you want to search it should be the most recent message sent to amanda-hackers.

Comment 15 Jason Tibbitts 2018-03-02 17:35:37 UTC
Better searching turns up https://marc.info/?l=amanda-hackers&m=151994863417010&w=2

Comment 16 Ben Cotton 2018-11-27 16:49:22 UTC
This message is a reminder that Fedora 27 is nearing its end of life.
On 2018-Nov-30  Fedora will stop maintaining and issuing updates for
Fedora 27. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora  'version' of '27'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 27 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 17 Ben Cotton 2018-11-30 20:09:32 UTC
Fedora 27 changed to end-of-life (EOL) status on 2018-11-30. Fedora 27 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 18 Peter Bieringer 2019-03-08 05:50:54 UTC
Still not fixed in amanda-3.5.1-16.fc29.x86_64

Comment 19 Jason Tibbitts 2019-03-08 17:22:36 UTC
Unfortunately you never tested my proposed fix using binmode (from comment #12), so... I don't know what to tell you.  If you had tested that (and it had worked) then this would have been fixed long ago.

Comment 20 Peter Bieringer 2019-03-08 19:08:22 UTC
Sorry, looks like I have forgotten to test your proposed fix mentioned in https://bugzilla.redhat.com/show_bug.cgi?id=1317122#c12

tried it now:

--- /usr/sbin/amreport-3.5.1-16.fc29	2019-02-07 06:12:22.000000000 +0100
+++ /usr/sbin/amreport	2019-03-08 19:59:48.198981310 +0100
@@ -23,6 +23,8 @@
 use strict;
 use warnings;
 
+binmode(STDOUT, ":utf8");
+
 use Getopt::Long;
 use IPC::Open3;
 use Cwd qw( abs_path );


Result:

Content-Transfer-Encoding: 8bit
Message-Id: <***>
From: Amanda user <amandabackup@***>

Hostname: ***
Org     : ***
Config  : ***
Date    : März 8, 2019


but as mentioned in https://bugzilla.redhat.com/show_bug.cgi?id=1317122#c13, the whole contents of the report is in English, so why should then be the date in local language?

I still vote for applying patch from https://bugzilla.redhat.com/show_bug.cgi?id=1317122#c10

Comment 21 Ben Cotton 2019-10-31 19:50:08 UTC
This message is a reminder that Fedora 29 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 29 on 2019-11-26.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '29'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 29 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 22 Ben Cotton 2019-11-27 21:24:29 UTC
Fedora 29 changed to end-of-life (EOL) status on 2019-11-26. Fedora 29 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 23 Peter Bieringer 2020-03-08 10:49:58 UTC
still happen in Fedora 31

rpm -qf /usr/sbin/amreport
amanda-server-3.5.1-20.fc31.x86_64

and as mentioned above, the "inmode" fix is imho not well enough because it displays the month in local language, but all the other contents is in English only.

Here latest patch:

--- /usr/lib64/perl5/vendor_perl/Amanda/Report/human.pm-3.5.1-20.fc31	2020-03-08 11:47:02.459583088 +0100
+++ /usr/lib64/perl5/vendor_perl/Amanda/Report/human.pm	2020-03-08 11:47:50.277036336 +0100
@@ -25,7 +25,7 @@
 use warnings;
 use Carp;
 
-use POSIX;
+use POSIX qw(locale_h strftime);
 use Data::Dumper;
 
 use Amanda::Config qw(:getconf config_dir_relative);
@@ -399,6 +399,7 @@
     # TODO: this should be a shared method somewhere
     my $timestamp = $report->get_timestamp();
     my ($year, $month, $day) = ($timestamp =~ m/^(\d\d\d\d)(\d\d)(\d\d)/);
+    setlocale(LC_TIME, "C");
     my $date  = POSIX::strftime('%B %e, %Y', 0, 0, 0, $day, $month - 1, $year - 1900);
     $date =~ s/  / /g; # get rid of intervening space

Comment 24 Ben Cotton 2020-11-03 17:29:39 UTC
This message is a reminder that Fedora 31 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 31 on 2020-11-24.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '31'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 31 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 25 Ben Cotton 2020-11-24 19:54:16 UTC
Fedora 31 changed to end-of-life (EOL) status on 2020-11-24. Fedora 31 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.