Logrotate frustration

Dominick Grift domg472 at gmail.com
Sun Dec 6 11:59:11 UTC 2009


On Sun, Dec 06, 2009 at 09:38:32AM +0000, Arthur Dent wrote:
> Hello all,
> 
> Its seems that almost every week logrotate is throwing up a new AVC. I
> have an almost vanilla F11 install with most packages installed via yum
> and yet I keep getting these. Each time I audit2allow and build a new
> policy. My "mylogr.te" is now at version 7. Am I missing a bool or is
> there something else I'm lacking?
> 
> Here is the latest version of my policy:
> 
> 
> ===============8<==================================================
> 
> module mylogr 11.1.7;
> 
> require {
> 	type mail_spool_t;
> 	type logrotate_t;
> 	type fail2ban_var_run_t;
> 	type initrc_t;
> 	type squid_log_t;
> 	class dir {read open write remove_name};
> 	class file { getattr read write open};
> 	class file setattr;
> 	class sock_file write;
>         class unix_stream_socket connectto;
> 	class lnk_file rename;
> }
> 
> #============= logrotate_t ==============
> allow logrotate_t mail_spool_t:file { getattr read write open };
> allow logrotate_t mail_spool_t:dir { read open write remove_name};
> allow logrotate_t mail_spool_t:file setattr;
> allow logrotate_t fail2ban_var_run_t:sock_file write;
> allow logrotate_t initrc_t:unix_stream_socket connectto;
> allow logrotate_t squid_log_t:lnk_file rename;
> 
> ===============8<==================================================
> 
> 
> This was today's AVC that necessitated the inclusion of the squid stuff:
> 
> ===============8<==================================================
> Raw Audit Messages :
> 
> node=mydomain.org.uk type=AVC msg=audit(1260069452.494:45041): avc: denied { rename } for pid=12302 comm="logrotate" name="squidGuard.log" dev=sda5 ino=387195 scontext=system_u:system_r:logrotate_t:s0-s0:c0.c1023 tcontext=system_u:object_r:squid_log_t:s0 tclass=lnk_file 
> node=mydomain.org.uk type=SYSCALL msg=audit(1260069452.494:45041): arch=40000003 syscall=38 success=no exit=-13 a0=890b130 a1=8908760 a2=890b060 a3=0 items=0 ppid=12300 pid=12302 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=2275 comm="logrotate" exe="/usr/sbin/logrotate" subj=system_u:system_r:logrotate_t:s0-s0:c0.c1023 key=(null)
> ===============8<==================================================


The  rule with the initrc_t type is due to missing policy. It is encouraged to implement policy for all init daemons.

With regard to the other rules you can, i guess, basically allow the access required,

But always go through the checklist:

1. are the parties in an interaction labeled correctly? (matchpatchcon/restorecon/semanage/chcon)
2. are there any booleans or types that facilitate a certain interaction? (audit2allow)
3. is there a misconfiguration in some application? (see if a program should be able to do what it wants)
3. is there a bug in some application? (is the denial due to a bug in an application?)
4. is there a bug in the selinux policy? (missing policy to allow a certain interaction?)
5. is it a break in attempt (is the application compromised.

taking these 5 golden rules into concideration. i have some questions:

allow logrotate_t fail2ban_var_run_t:sock_file write
- why would logrotate have to write to a fail2ban sock file? (this may be a bug in fail2ban, maybe leaked file descriptor. does this denial cause any loss in functionality? if not consider silently denying it)

allow logrotate_t squid_log_t:lnk_file rename;
- why does squidgaurd, or whatever managed squid_log_t lnk_file, create a lnk_file in /var/log/... This is obviously not common behaviour afaik. That may be the reason why is denied.

withregard to the rules with mail_spool_t type i would like to know if and why logrotate wants to rotate spool files. is this expeected behaviour of logrotate or are the mail_spool_t object mislabeled?

so in conclusion the only denial that i am somewhat comfortable with is the squid link file denial. This may be some uncommon behaviour of squid/squidgaurd that selinux policy currently does not support (when confirmed that squidgaurd indeed creates a lnk file in /var/log for some reason , then implement policy to allow logrotate to rename the link (and what else it may need to do with the lnk_file.)

See what runs initrc_t (ps auxZ) and consider writing policy for this init daemon. By implementing policy for init daemon you prtect the system plus you achive that confined domain do not have to interact with the unconfined initrc_t domain.


> --
> fedora-selinux-list mailing list
> fedora-selinux-list at redhat.com
> https://www.redhat.com/mailman/listinfo/fedora-selinux-list

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-selinux-list/attachments/20091206/5b222b5c/attachment.sig>


More information about the fedora-selinux-list mailing list