Pi-hole logrotate parent directory has insecure permissions

My Pi-hole was producing this error every day:

Cron test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.daily )

/etc/cron.daily/logrotate: error: skipping “/var/log/lighttpd/access.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.
error: skipping “/var/log/lighttpd/error.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.
run-parts: /etc/cron.daily/logrotate exited with return code 1

The solution to this was pretty easy:

  • sudo vi /etc/logrotate.d/lighttpd
  • Under /var/log/lighttpd/*.log { add the following line:

su www-data www-data

That’s it! You may want to do sudo systemctl restart cron to make it reload, and now the error should not reoccur.