Quantcast
Viewing latest article 2
Browse Latest Browse All 2

How to allow cron to send an email attachment?

SELinux is preventing cron from attaching a log file in the email with the following error:

notice kernel [ 7148.923034] type=1400 audit(1359466501.857:5): avc: denied { read } for pid=3182 comm="mailx" name="attachment" dev="dm-1" ino=4140 scontext=system_u:system_r:system_mail_t:s0-s0:c0.c1023 tcontext=system_u:object_r:var_log_t:s0 tclass=file

A bash script is run by cron every hour to email a log file if it is not empty. The script contains the following line:

echo "" | mailx -s "Critical Message" -a /var/log/attachment test@email.com

I think the problem has to do with the file security context. I read somewhere that setting the context to public content might help, but not sure if it is a good idea or if there is a better approach.


Viewing latest article 2
Browse Latest Browse All 2

Trending Articles