ReinerNippes / nextcloud

Ansible playbook to install nextcloud, php, nginx or apache, mariadb or postgres, redis-server, onlyoffice or collabora office
MIT License
412 stars 142 forks source link

phpsessionclean fails on removing session files #77

Open 0xphk opened 4 years ago

0xphk commented 4 years ago

Hi, unsure if this is a problem with the installation, but on Ubuntu 18.04 and Debian 10 the systemd-timer controlled phpsessionclean.service fails with similar errors on both systems, syslog:

sessionclean[24005]: find: cannot delete '/usr/local/tmp/sessions/sess_a5a9uj18v2qgsavdk2oq1carn7': Read-only file system

I can not find any clue, the permissions of the session files are 600 www-data:www-data which should be ok, but the session folder itself is 777 www-data:root with tempfs sticky bit.

I thought the 'root' group ownership of the sessions directory could be the problem but chown www-data:www-data does not fix this. I guess phpsessionclean is also run under www-data context.

Any help on this is appreciated, thank you

0xphk commented 4 years ago

Looks like this is a systemd related error, probably some user context issue.

As manually running session-clean works, the problem can be fixed by switching back to cron: systemctl disable --now phpsessionclean.timer

then modify /etc/cron.d/php and remove the systemd test condition from 09,39 * * * * root [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi to 09,39 * * * * root [ -x /usr/lib/php/sessionclean ] && /usr/lib/php/sessionclean

Now this uses cron again to run this in root context, so cleaning up old sessions works again. Maybe this helps another ppl.