I use msmtp as mta, to send emails from cron scripts. This works and I receive the emails as expected. I have selinux activated and I noticed an audit denial for a write to /etc/pki/ca-trust/source which I find surprising.
Anybody has any idea what could be the reason? Or what else I could do to investigate?
See below for some info, /etc is mounted on dev/sda4.
If a process calls access() or faccessat() and SELinux denies their request there will be a check for a dontaudit rule on the audit_access permission. If there is a dontaudit rule on audit_access an AVC event will not be written. If there is no dontaudit rule an AVC event will be written for the permissions requested (read, write, or exec).
So in fact SELinux reports that the process tried to check if it can write, to which the answer was “no” (EACCESS) but this gets in the AVC (which is the cache of permissions granted/denied) as a “denied write”
Ok, so I was curious who (and potentially why) would check the access. So I fired up gdb and breakpoint on access and run msmtp and got the following:
#0 0x00007ffff78fd6d0 in access () from /lib64/libc.so.6 #1 0x00007ffff68b1c6d in check_directory.lto_priv () from /usr/lib64/pkcs11/p11-kit-trust.so #2 0x00007ffff68a54b1 in sys_C_GetTokenInfo () from /usr/lib64/pkcs11/p11-kit-trust.so #3 0x00007ffff7ca9a42 in _pkcs11_traverse_tokens () from /lib64/libgnutls.so.30 #4 0x00007ffff7cacc25 in gnutls_pkcs11_obj_list_import_url4 () from /lib64/libgnutls.so.30 #5 0x00007ffff7cacd7a in gnutls_pkcs11_obj_list_import_url3 () from /lib64/libgnutls.so.30 #6 0x00007ffff7d0c9ba in gnutls_x509_trust_list_add_trust_file () from /lib64/libgnutls.so.30 #7 0x00007ffff7c7b971 in gnutls_x509_trust_list_add_system_trust () from /lib64/libgnutls.so.30 #8 0x000055555556b29c in mtls_init () #9 0x0000555555564a96 in msmtp_sendmail () #10 0x0000555555559e18 in main ()
As a conclusion, nothing related specifically to Rocky/msmtp/selinux (but not obvious when you don’t know), I would have been great if SELinux would have been more clear even for non experts, I mean “write” and “check is writable” are quite different thing to put under the same message.
There are several reasons why it might not be reported more often: a) there is no error, as in fact it does not want to write, hence it will not fail. b) msmtp (not standard) is not used in a SELinux environment (not used by everybody either). c) people notice the fact that this is only checking the access and do not report it (if I would have notice that I would have not posted either).