On 30/10/2013 10:14, jdoeconsulting wrote:
[color=blue]
I’ve set an extended file acl, through setfacl, granting a user read
rights
to /var/log/messages This works like a charm.
However every time the file is rotated through logrotate the extended
file
acl gets lost.
In /etc/logrotate.d/syslog the following is defined;
/var/log/warn /var/log/messages /var/log/allmessages
/var/log/localmessages /var/log/firewall /var/log/acpid
/var/log/NetworkManager {
compress
dateext
maxage 365
rotate 99
missingok
notifempty
size +4096k
create 640 root root
sharedscripts
postrotate
/etc/init.d/syslog reload > /dev/null
endscript
}
This tells logrotate to create a new file with permissions 640 with
owner root:root
I’m guessing this is what causes the extended acl to be dropped. As far
I know logrotate
should keep the existing permissions of the file when creating the new
one, or am I wrong?
What needs to be done to keep the existing config for how
/var/log/messages is rotated while
keep the extended acl permission as well?[/color]
Whilst you can use the logrotate “create” directive to set the mode,
owner, and/or group of the new log file (see below) this doesn’t (re)set
the ACLs.
–begin–
create mode owner group
Immediately after rotation (before the postrotate script is run)
the log file is created (with the same name as the log file just
rotated). mode specifies the mode for the log file in octal
(the same as chmod(2)), owner specifies the user name who will
own the log file, and group specifies the group the log file
will belong to. Any of the log file attributes may be omitted,
in which case those attributes for the new file will use the
same values as the original log file for the omitted attributes.
This option can be disabled using the nocreate option.
—end—
What you can do instead (or as well) is use the “postrotate” directive
to (re)set the ACLs
–begin–
postrotate/endscript
The lines between postrotate and endscript (both of which must
appear on lines by themselves) are executed (using /bin/sh)
after the log file is rotated. These directives may only appear
inside a log file definition. Normally, the absolute path to the
log file is passed as first argument to the script. If shared-
scripts is specified, whole pattern is passed to the script.
See also prerotate. See sharedscripts and nosharedscripts for
error handling.
—end—
So for the example you gave, add your setfacl command(s) above the
“endscript” directive which will give you something like
–begin–
/var/log/warn /var/log/messages /var/log/allmessages
/var/log/localmessages /var/log/firewall /var/log/acpid
/var/log/NetworkManager {
compress
dateext
maxage 365
rotate 99
missingok
notifempty
size +4096k
create 640 root root
sharedscripts
postrotate
/etc/init.d/syslog reload > /dev/null
/path/to/setfacl …
endscript
}
—end—
HTH.
Simon
SUSE Knowledge Partner
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below. Thanks.