PHP session garbage collection measured in minutes instead of seconds

Bug #908154 reported by Bill Ruddock
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
php5 (Ubuntu)
Invalid
High
Unassigned

Bug Description

1) $ lsb_release -rd
Description: Ubuntu 11.04
Release: 11.04

2) php5-common:
  Installed: 5.3.5-1ubuntu7.4
  Candidate: 5.3.5-1ubuntu7.4

3) With session.gc_maxlifetime = 1440 Expected session files to be cleaned up that are over 1440 seconds old (=24 minutes)

4) What happens: only files older than 1440 minutes are deleted.

In the file /etc/cron.d/php5 is the following
09,39 * * * * root [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete

This takes the output from /usr/lib/php5/maxlifetime which is in seconds and treats it as though it was in minutes.

Should be
-cmin +$(($(/usr/lib/php5/maxlifetime) / 60)

Tags: patch
Revision history for this message
Bill Ruddock (bill-ruddock) wrote :
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "/etc/cron.d/php5" of this bug report has been identified as being a patch. The ubuntu-reviewers team has been subscribed to the bug report so that they can review the patch. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-reviewers team please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]

tags: added: patch
Dave Walker (davewalker)
Changed in php5 (Ubuntu):
importance: Undecided → High
Revision history for this message
Ondřej Surý (ondrej) wrote :

It's not really a bug in PHP5, but a feature in psmisc package before 22.15 (see related Debian bug).

You can pick new psmisc[*] from my PPA: https://launchpad.net/~ondrej/+archive/php5 and report back here. (Be aware to not install 5.3.10-1 unless you really want to.)

* - It was uploaded just now, so it will take some time to build properly.

(Hint: You might want to backport fuser changes to old Ubuntu releases if confirmed this helps instead of hacking php5 cron job.)

Revision history for this message
Steve Beattie (sbeattie) wrote :

BIll,

The /usr/lib/php5/maxlifetime script is already dividing the result by 60; if you run it with the default settings, you will see that it returns 24 (the expected number of minutes). So your patch should not be necessary. Is that not the behavior you see? What does it output if you run it directly?

Ondřej,

Hrm, the issue you're raising, ensuring that a session file that was started more than 24 minutes ago but is still in use doesn't get purged by using fuser, is a separate issue from what Bill is reporting. Can you open a separate bug for that?

Thanks!

Changed in php5 (Ubuntu):
status: New → Incomplete
Revision history for this message
Bill Ruddock (bill-ruddock) wrote :

Steve,

You're right, /usr/lib/php5/maxlifetime is dividing by 60 to give it in minutes. I can't think why I believed otherwise when I reported this.

Thanks, this is not a bug after all.

Steve Beattie (sbeattie)
Changed in php5 (Ubuntu):
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.