Bug 50971 - logrotate should create new logfiles with permissions of "old" logfile
logrotate should create new logfiles with permissions of "old" logfile
Status: RESOLVED WORKSFORME
Product: UCS
Classification: Unclassified
Component: logrotate
UCS 4.4
Other Linux
: P5 normal (vote)
: ---
Assigned To: UCS maintainers
UCS maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2020-03-17 13:07 CET by Julia Bremer
Modified: 2020-03-17 15:24 CET (History)
1 user (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): Usability
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Julia Bremer univentionstaff 2020-03-17 13:07:14 CET
The permissions of files created by logrotations are controlled by the UCR Variable 
logrotate/create
which is evaluated by /base/univention-lib/python/ucrLogrotate.py.

This means that we are not able to set the permissions per logfile, we can only set the permissions for all logfiles to the same value. 

We noticed this when enabling logrotation for radius_ntlm_auth.log in Bug #50545. 
The logfile is created with the permissions 

-rw-r--r-- 1 root freerad 291 Jan 11 00:59 radius_ntlm_auth.log

After logrotation the permissions are set like this:
-rw-r----- 1 root adm       0 Jan 11 01:00 radius_ntlm_auth.log
-rw-r--r-- 1 root freerad 291 Jan 11 00:59 radius_ntlm_auth.log.1

since logrotate/create is set to "640 root adm" as default.

We should add the possibility to set the file permissions at logrotate creation per logfile.
Comment 1 Philipp Hahn univentionstaff 2020-03-17 15:24:02 CET
WORKS-4-ME:
> logrotate/create: 640 root adm
>  Configures mode, owner and group of a log file after rotation, e.g. '640 root adm'.
also works for individual sections like the other 'logrotate/$SECTION/....' variables.

# ls -ld /var/log/syslog 
-rw-r----- 1 root adm 33068180 Mär 17 15:18 /var/log/syslog

# ucr set logrotate/syslog/create='644 root staff'

# grep -A4 /var/log/syslog /etc/logrotate.d/rsyslog
/var/log/syslog
{
        daily
        rotate 84
        create 644 root staff

# logrotate --force /etc/logrotate.conf
# ls -ld /var/log/syslog 
-rw-r--r-- 1 root staff 3513 Mär 17 15:20 /var/log/syslog