Logrotate fails when cwd is not accessible

Logrotate is run with sudo as the syslog user by cron.hourly
The current working directory is `/root` which is inaccessible to the syslog
user so the logrotate command fails. Currently the following stderr is being
thrown away by the cron script:
```
error: cannot open current directory: Permission denied
```

Fixes #15468

Signed-off-by: Christopher Jenkins <christj@gmail.com>
This commit is contained in:
Christopher Jenkins 2021-09-01 15:28:30 -07:00
parent ff617950b7
commit 0585b148c7
1 changed files with 2 additions and 1 deletions

View File

@ -2,5 +2,6 @@
# run the logrotate with user 10000, the state file "/var/lib/logrotate/logrotate.status"
# is specified to avoid the permission error
cd /
sudo -u \#10000 -E /usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status /etc/logrotate.conf
exit 0
exit 0