logrotate failing to work with RBAC enabled.

Discuss usability issues, general maintenance, and general support issues for a grsecurity-enabled system.

logrotate failing to work with RBAC enabled.

Postby tjh » Wed Nov 02, 2011 5:53 pm

Debian 6.0.3 system.

I have a problem when I have my RBAC policy enabled that logrotate doesn't work properly.

Firstly, there's no denies in the log to help me with this, thus my frustration.

What it'll do it move /var/log/syslog to /var/log/syslog.1 as it's supposed to, it also creates a new /var/log/syslog. But this file stays empty and it keeps writing to the /var/log/syslog.1 file, until I restart it.

If I don't have the RBAC system enabled - it works fine.

Does anyone have any clues/pointers as to how I could track this down? The lack of any grsec deny messages is what's really bugging me.
tjh
 
Posts: 102
Joined: Sat Oct 16, 2004 8:19 pm

Re: logrotate failing to work with RBAC enabled.

Postby spender » Fri Nov 04, 2011 1:22 am

Can you paste the logrotate subject?

-Brad
spender
 
Posts: 2185
Joined: Wed Feb 20, 2002 8:00 pm

Re: logrotate failing to work with RBAC enabled.

Postby tjh » Fri Nov 04, 2011 2:46 am

Code: Select all

subject /usr/sbin/logrotate o {
        /                               r
        /bin                            h
        /bin/dash                       x
        /bin/gzip                       x
        /boot                           h
        /dev/grsec                      h
        /dev/kmem                       h
        /dev/log                        h
        /dev/mem                        h
        /dev/port                       h
        /etc                            r
        /etc/grsec                      h
        /etc/gshadow                    h
        /etc/gshadow-                   h
        /etc/ppp                        h
        /etc/samba/smbpasswd            h
        /etc/shadow                     h
        /etc/shadow-                    h
        /etc/ssh                        h
        /lib                            rx
        /lib/modules                    h
        /lib64/modules                  h
        /proc                           h
        /proc/filesystems               r
        /selinux
        /sys                            h
        /usr                            h
        /usr/lib/gconv/gconv-modules.cache      r
        /usr/lib/locale/locale-archive  r
        /usr/sbin/logrotate             rx
        /var                            h
        /var/lib                        h
        /var/lib/logrotate/status       rw
        /var/log                        rwcd
        +CAP_ALL
        bind    disabled
        connect disabled
        sock_allow_family all
}


I haven't allowed hardlinking for /var/log, because this is what was learnt and I'm not seeing errors.
tjh
 
Posts: 102
Joined: Sat Oct 16, 2004 8:19 pm

Re: logrotate failing to work with RBAC enabled.

Postby spender » Fri Nov 04, 2011 10:54 am

I think the problem is not necessarily with logrotate, but that rsyslog (is that the syslog you're using?) wasn't reloaded successfully. On my system, logrotate will issue a reload of rsyslog which will happen via a kill(pid, SIGHUP). rsyslog will then reopen /var/log/syslog. The fact that syslog is still logging to the .1 file, which is a rename()'d version of the old /var/log/syslog shows this. Does the problem still happen if you change the system date (date -s "Jan 1 2012") while in admin mode and run strace -f logrotate /etc/logrotate.conf ? If not, could you add a subject for strace:

subject /usr/bin/strace tr


It'll need some tweaking, but what I really need to see is the results of an strace while RBAC is enabled.

-Brad
spender
 
Posts: 2185
Joined: Wed Feb 20, 2002 8:00 pm

Re: logrotate failing to work with RBAC enabled.

Postby tjh » Sat Nov 05, 2011 2:28 am

I am using rsyslog, yea.

This is my subject:

Code: Select all
# role: root
subject /usr/sbin/rsyslogd dhop {
        /                               h
        /dev                            h
        /dev/log                        wd
        /dev/xconsole                   rw
        /etc                            h
        /etc/ld.so.cache                r
        /lib                            h
        /lib/libgcc_s.so.1              rx
        /var                            h
        /var/log                        a
        /var/run/rsyslogd.pid           wd
        /var/spool/postfix/dev/log      wd
        -CAP_ALL
        bind    disabled
        connect disabled
}


I'm wondering if the /var/log a might be the problem? That's what was learnt, but wouldn't I also need maybe a "w" or a "c" there?
tjh
 
Posts: 102
Joined: Sat Oct 16, 2004 8:19 pm

Re: logrotate failing to work with RBAC enabled.

Postby spender » Sat Nov 05, 2011 10:26 am

Logrotate creates the new /var/log/syslog prior to restarting rsyslog, not rsyslog itself.

-Brad
spender
 
Posts: 2185
Joined: Wed Feb 20, 2002 8:00 pm

Re: logrotate failing to work with RBAC enabled.

Postby tjh » Sun Nov 06, 2011 8:30 pm

Hmmm Ok.

I'm loath to do the time thing on this server as it'll mess up all the logs. I will try adding the "k" mode to logrotate though, so it can properly send signals to rsyslog (which is protected)

Hopefully this'll fix it, I'll report back.
tjh
 
Posts: 102
Joined: Sat Oct 16, 2004 8:19 pm

Re: logrotate failing to work with RBAC enabled.

Postby spender » Sun Nov 06, 2011 9:39 pm

If it was due to rsyslog being a protected task, the denied signal would have been logged (and you said there were no logs).

-Brad
spender
 
Posts: 2185
Joined: Wed Feb 20, 2002 8:00 pm

Re: logrotate failing to work with RBAC enabled.

Postby tjh » Sun Nov 06, 2011 9:42 pm

Good point.
Ok, I'll keep looking, try some of your suggestions and get back to you.

Thanks for the assistance.

Tim
tjh
 
Posts: 102
Joined: Sat Oct 16, 2004 8:19 pm

Re: logrotate failing to work with RBAC enabled.

Postby spender » Sun Nov 06, 2011 11:33 pm

I noticed you also have 'h' in the subject mode. IIRC the restart script will access /proc/pid/status based on the pidfile for rsyslog. 'h' would prevent this and not be logged. You should just remove the 'h' really from rsyslog, otherwise you'll have to add 'v' to logrotate and also add inheritance object modes to objects in the logrotate subject so that all the shell scripts it executes can view rsyslog. Problem solved I think ;)

-Brad
spender
 
Posts: 2185
Joined: Wed Feb 20, 2002 8:00 pm

Re: logrotate failing to work with RBAC enabled.

Postby tjh » Sun Nov 06, 2011 11:39 pm

Ahh. Yes, that would make sense.

Thanks! I'll report back.
tjh
 
Posts: 102
Joined: Sat Oct 16, 2004 8:19 pm

Re: logrotate failing to work with RBAC enabled.

Postby tjh » Mon Nov 07, 2011 1:28 pm

Working like a charm now.

Thanks.
tjh
 
Posts: 102
Joined: Sat Oct 16, 2004 8:19 pm

Re: logrotate failing to work with RBAC enabled.

Postby tjh » Thu Jan 15, 2015 1:49 pm

Well, this is embarrassing.
I just searched for this problem and look who's had it previously and had it answered.

I'm such a muppet.
tjh
 
Posts: 102
Joined: Sat Oct 16, 2004 8:19 pm


Return to grsecurity support