Bug 847338

Summary: logrotate ignores create mode
Product: Red Hat Enterprise Linux 6 Reporter: Daniel Crisman <fixing-stuff-d-f-crisman-redhat-bugzilla>
Component: logrotateAssignee: Jan Kaluža <jkaluza>
Status: CLOSED ERRATA QA Contact: Tomas Dolezal <todoleza>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.3CC: azelinka, jorton, mooney, SCHAKRAB
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: logrotate-3.7.8-17.el6 Doc Type: Bug Fix
Doc Text:
Cause: Setting the ACL on rotated log overwrote the previously set mode of the log file. Consequence: "create" directive was ignored. Fix: When "create" directive is used, ACL are not copied from old log file and mode defined using "create" directive is used instead. Result: "create" mode works like before and is not ignored.
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-07-18 09:35:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Daniel Crisman 2012-08-10 15:25:33 UTC
Description of problem:
The mode in the directive 'create mode owner group' is ignored when
built with WITH_ACL.

Version-Release number of selected component (if applicable):
logrotate-3.7.8-15.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
echo -e 'weekly\nrotate 4\ncreate\ndateext\n\n"./a.log" {\n    create 0600\n}' > conf
echo -e 'logrotate state -- version 2\n"./a.log" 2000-8-9n' > state
rm -f a.log*
touch a.log
chmod 644 a.log
logrotate -v -s state conf
ls -l a.log*
  
Actual results:
# on RHEL Server 6.3
new a.log is mode 0644

Expected results:
# as it worked on RHEL Server 6.2 and before
new a.log is mode 0600

Additional info:
Caused by the ACL change from bug 683622

acl_set_fd on line 1266 overwrites the mode set in createOutputFile() on line 1259.

acl_set_fd really should be an alternate to fchmod on line 251 inside createOutputFile():
    #ifdef WITH_ACL
        # do acl_set_fd stuff
    #else
        # do fchmod
    #endif
but that probably break other uses of createOutputFile().

Alternate solution to ACL issue would be to allow the mode in the create directive to be a mode (octal number) or acl text (see SHORT TEXT FORM in acl(5) to process with acl_from_text()).

Comment 2 Jan Kaluža 2012-08-13 12:06:32 UTC
Thanks for the report. I think patch I've just committed into logrotate repository should fix this issue. I have also added two tests to test the fix.

https://fedorahosted.org/logrotate/changeset/382

Comment 3 RHEL Program Management 2012-09-07 05:12:06 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unable to address this
request at this time.

Red Hat invites you to ask your support representative to
propose this request, if appropriate, in the next release of
Red Hat Enterprise Linux.

Comment 4 Tim Mooney 2012-09-20 15:51:17 UTC
We are being impacted by this issue too and would like to see the fix included in a logrotate release before RHEL 6.4.

Comment 12 errata-xmlrpc 2013-07-18 09:35:05 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-1095.html