Hi,

in order to come closer to a fix for this issue, I propose the following
two patches:


0001-Add-outputencoding-parameter.patch

This patch allows to configure the value for the charset in the
Content-Type line in mail output. This should address Klaus Ethgen's
original concern. Since most people use UTF-8, I left the default at UTF-8.

0002-Use-pager-on-stdout-output-to-terminal.patch

Use pager less if output is on terminal. This should address the issues
associated with escape sequences in logs that may mess with your
terminal. Less seems to be good at filtering these escape sequences.


Let me know what you think about these patches.

Willi

Am 2017-01-01 um 23:01 schrieb Mike Tremaine:
> 
>>
>> The fail-safe default before was ISO-8859-1. So I suggest to use it
>> again.
>>
> 
> 
> If stream converted output it s require please consider making it a 
> configurable module in the code base that can be turned on and off and 
> modified (the module) as needed. Leave the default as is, that way DESTRO’s 
> and users can configure to their liking. But it will work as intended all the 
> way back to the stone-age tools that we started this project with. (I’m 
> looking at you Solaris 7/8)
> 
> 
> -Mike
> 

>From 162f8b2e7fae134e65761dc64e0a8d29c9c172d4 Mon Sep 17 00:00:00 2001
From: Willi Mann <wi...@wm1.at>
Date: Sat, 14 Jan 2017 15:32:39 +0100
Subject: [PATCH 1/2] Add outputencoding parameter

---
 conf/logwatch.conf  | 8 ++++++++
 scripts/logwatch.pl | 8 +++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/conf/logwatch.conf b/conf/logwatch.conf
index 2b61ec6..0d0e31b 100644
--- a/conf/logwatch.conf
+++ b/conf/logwatch.conf
@@ -126,4 +126,12 @@ mailer = "/usr/sbin/sendmail -t"
 #
 #HostLimit = myhost
 
+#
+# With this option, the output encoding for mail headers can be set. It
+# defaults to utf-8. Be aware that the default value may change to autodetect
+# (take the system's encoding). Note that the configured value will be
+# upper-cased.
+#
+# OutputEncoding = utf-8
+
 # vi: shiftwidth=3 tabstop=3 et
diff --git a/scripts/logwatch.pl b/scripts/logwatch.pl
index 0167755..0cff511 100755
--- a/scripts/logwatch.pl
+++ b/scripts/logwatch.pl
@@ -90,6 +90,7 @@ $Config{'pathtobzcat'} = "bzcat";
 $Config{'output'} = "stdout"; #8.0
 $Config{'format'} = "text"; #8.0
 $Config{'encode'} = "none"; #8.0
+$Config{'outputencoding'} = "utf-8";
 $Config{'hostformat'} = "none"; #8.0
 $Config{'html_wrap'} = 80;
 $Config{'supress_ignores'} = 0;
@@ -1160,11 +1161,12 @@ sub initprint {
          } else {
             $out_mime .= "Content-Transfer-Encoding: 7bit\n";
          }
-         #Config{output} html
+         #Config{output} html, Config{outputenconding}
+         my $encoding = uc($Config{outputencoding});
          if ( $Config{'format'} eq "html" ) {
-            $out_mime .= "Content-Type: text/html; charset=\"UTF-8\"\n\n";
+            $out_mime .= "Content-Type: text/html; charset=\"$encoding\"\n\n";
          } else {
-            $out_mime .= "Content-Type: text/plain; charset=\"UTF-8\"\n\n";
+            $out_mime .= "Content-Type: text/plain; charset=\"$encoding\"\n\n";
          }
 
          if ($Config{'hostformat'} eq "split") { #8.0 check hostlimit also? or ne none?
-- 
2.1.4

>From 4e2579f41f1b94db97d265a72f67309cbf1737fa Mon Sep 17 00:00:00 2001
From: Willi Mann <wi...@wm1.at>
Date: Sat, 14 Jan 2017 16:25:30 +0100
Subject: [PATCH 2/2] Use pager on stdout output to terminal

---
 conf/logwatch.conf  | 4 ++++
 scripts/logwatch.pl | 7 ++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/conf/logwatch.conf b/conf/logwatch.conf
index 0d0e31b..e15ed3b 100644
--- a/conf/logwatch.conf
+++ b/conf/logwatch.conf
@@ -134,4 +134,8 @@ mailer = "/usr/sbin/sendmail -t"
 #
 # OutputEncoding = utf-8
 
+#
+# For output type stdout, use pager if the stdout is a terminal.
+#Pager = /usr/bin/less
+
 # vi: shiftwidth=3 tabstop=3 et
diff --git a/scripts/logwatch.pl b/scripts/logwatch.pl
index 0cff511..f053cb3 100755
--- a/scripts/logwatch.pl
+++ b/scripts/logwatch.pl
@@ -88,6 +88,7 @@ $Config{'pathtocat'} = "cat";
 $Config{'pathtozcat'} = "zcat";
 $Config{'pathtobzcat'} = "bzcat";
 $Config{'output'} = "stdout"; #8.0
+$Config{'pager'} = "/usr/bin/less"; #8.0
 $Config{'format'} = "text"; #8.0
 $Config{'encode'} = "none"; #8.0
 $Config{'outputencoding'} = "utf-8";
@@ -1127,7 +1128,11 @@ sub initprint {
    $OStitle = "Solaris" if ($OSname eq "SunOS" && $release >= 2);
 
    if ($Config{'output'} eq "stdout") { #8.0 start with others?
-      *OUTFILE = *STDOUT;
+      if($Config{'pager'} and -t STDOUT) {
+         open(OUTFILE,"|$Config{'pager'}") or die "could not open pager: $Config{'pager'} $!";
+      } else {
+         *OUTFILE = *STDOUT;
+      }
    } elsif ($Config{'output'} eq "file") {
       open(OUTFILE,">>" . $Config{'filename'}) or die "Can't open output file: $Config{'filename'} $!\n";
    } else {
-- 
2.1.4

Reply via email to