[CentOS] CentOS9 vs. s-nail

Fri Jan 20 13:00:23 UTC 2023
Bill Gee <bgee at campercaver.net>

Hello everyone - I did some more poking at this last night, and I think 
I have devised a work-around.  The basic process is to have logwatch 
output a file and then call s-nail from a script to send the file.

Step 1 - Add these lines to /etc/logwatch/conf/logwatch.conf:

Filename = /temp/logwatchreport.txt
Output = file


Step 2 - Create a shell script named /usr/local/bin/sendlogwatchreport. 
It simply a call to s-nail:

/usr/bin/mailx -m /temp/logwatchreport.txt \
    -s "Logwatch report for centos7.billgee.local" \
    -r logwatch at centos7.billgee.local \
    --batch-mode \
    bgee at campercaver.net

The "-m" parameter takes the named file and makes it the body of the 
email message.  Note that the default logwatch call to a mailer uses the 
"-t" parameter which expects the input to be a template.  The template 
includes lines at the top which are turned into the email headers for 
subject, to and from fields.

Step 3 - Modify /etc/s-nail.rc.  This line is changed:

	set asksend
changes to
	unset asksend

Without this s-nail gets stuck waiting for user input that will never come.

Step 4 - Add the shell script to the cron.daily list of tasks.  I did 
this by creating a hard link.

ln /usr/local/bin/sendlogwatchreport /etc/cron.daily/sendlogwatchreport

More testing is required for this.  I think there are some permission 
problems.  I tried to use the /tmp directory, but files that logwatch 
puts there disappear before the script can use them.  Creating /temp 
with 777 permissions is an attempt to work around this.

When run from a root prompt, logwatch and sendlogwatchreport result in a 
nicely readable email message.  I am not sure what will happen when 
anacron runs the process.  It will take an overnight cycle to find out.


===============
Bill Gee

On 1/19/23 15:00, Robert Heller wrote:
> It is called "Quoted Printable".  There should be something in the E-Mail
> header that indicates this (Content-Transfer-Encoding header).  Maybe either
> Logwatch or s-nail is leaving out this header.
> 
> https://en.wikipedia.org/wiki/Quoted-printable
> 
> At Thu, 19 Jan 2023 15:50:37 -0500 CentOS mailing list <centos at centos.org> wrote:
> 
>>
>> =20 is an ASCII space character, and =3D is an ascii "=" (equal) sign.
>>
>> I've seen various emailed documents that mangle them as you see, but if I
>> ever knew the cause, my tired old brain no longer remembers.
>>
>> Fred
>>
>> On Thu, Jan 19, 2023 at 2:42 PM Bill Gee <bgee at campercaver.net> wrote:
>>
>>> Now that I have a test CentOS9 system set up, I am trying to get it to
>>> send me logwatch reports via email.  S-nail is proving very frustrating.
>>>    It almost works ...  But not quite!
>>>
>>> The main problem is bogus characters in the logwatch report.  Here is a
>>> section of the report I get through email:
>>>
>>>
>>> ==================
>>> =20
>>>    ################### Logwatch 7.5.5 (01/22/21) ####################=20
>>>           Processing Initiated: Thu Jan 19 13:31:57 2023
>>>           Date Range Processed: yesterday
>>>                                 ( 2023-Jan-18 )
>>>                                 Period is day.
>>>           Detail Level of Output: 5
>>>           Type of Output/Format: email / text
>>>           Logfiles for Host: centos7.billgee.local
>>>    ##################################################################=20
>>> =20
>>>    --------------------- Kernel Audit Begin ------------------------=20
>>>
>>>     Number of audit daemon starts: 1=20
>>> =20
>>>    **Unmatched Entries**
>>>       audit: type=3D1403 audit(1674073255.247:3): auid=3D4294967295
>>> ses=3D429=
>>> 4967295 lsm=3Dselinux res=3D1: 1 Time(s)
>>>       auditd[517]: audit dispatcher initialized with q_depth=3D1200 and 1
>>> act=
>>> ive plugins: 1 Time(s)
>>> =20
>>>    ---------------------- Kernel Audit End -------------------------=20
>>>
>>> =20
>>>    --------------------- Chrony report Begin ------------------------=20
>>>
>>>    MS Name/IP address         Stratum Poll Reach LastRx Last sample
>>>      =
>>>       =20
>>>    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
>>>
>>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
>>>
>>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
>>> =3D=3D=3D=3D=3D
>>>    ^* server3.17.168.192.IN-AD>     4   6   377    42    -16us[  -23us] ± 9=
>>> 716us
>>>    Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset
>>> Std=
>>>    Dev
>>> ================================
>>>
>>> What are all those =20 and =30 strings for?  How do I make them go away?
>>>
>>> I have been experimenting with a line in /etc/s-nail.rc.
>>>
>>>          set ttycharset=utf-8
>>>
>>> That is the only value for this that produces anything useful.  If I set
>>> it to charset-7bit or charset-8bit, then s-nail complains about invalid
>>> syntax on the "set mta=" line.  What????
>>>
>>> I just don't get it.  Can someone shed some light on this?
>>>
>>> For what it is worth, a test CentOS8 system using mailx (the REAL
>>> mailx!) works perfectly.  So do all of my CentOS7 and Fedora systems.
>>>
>>> --
>>> ===============
>>> Bill Gee
>>> _______________________________________________
>>> CentOS mailing list
>>> CentOS at centos.org
>>> https://lists.centos.org/mailman/listinfo/centos
>>>
>> _______________________________________________
>> CentOS mailing list
>> CentOS at centos.org
>> https://lists.centos.org/mailman/listinfo/centos
>>
>>
> 
> 
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> https://lists.centos.org/mailman/listinfo/centos