Package: php5-common
Version: 5.6.13+dfsg-0+deb8u1
Severity: normal
Tags: patch
Dear Maintainer,
I've observed that sessions have a short living no matter what the
session.gc_maxlifetime setting is.
I've debugged the sessionclean script and found that it never touches
the session files so they will be removed even when they're still in use
for the specified time.
The variable proc_names is set inside the while loop that is in a
pipelined command, thus the variable isn't updated outside the loop.
I've modified the script so everything up to the touch loop runs inside
the same subshell. Patch provided.
Best regards,
Bernat Arlandis
-- Package-specific info:
==== Additional PHP 5 information ====
++++ PHP 5 SAPI (php5query -S): ++++
cli
apache2
++++ PHP 5 Extensions (php5query -M -v): ++++
xcache (Enabled for cli by maintainer script)
xcache (Enabled for apache2 by maintainer script)
mysql (Enabled for cli by maintainer script)
mysql (Enabled for apache2 by maintainer script)
curl (Enabled for cli by maintainer script)
curl (Enabled for apache2 by maintainer script)
opcache (Enabled for cli by maintainer script)
opcache (Enabled for apache2 by maintainer script)
readline (Enabled for cli by maintainer script)
readline (Enabled for apache2 by maintainer script)
pdo_sqlite (Enabled for cli by maintainer script)
pdo_sqlite (Enabled for apache2 by maintainer script)
mysqli (Enabled for cli by maintainer script)
mysqli (Enabled for apache2 by maintainer script)
intl (Enabled for cli by maintainer script)
intl (Enabled for apache2 by maintainer script)
gd (Enabled for cli by maintainer script)
gd (Enabled for apache2 by maintainer script)
json (Enabled for cli by maintainer script)
json (Enabled for apache2 by maintainer script)
pdo (Enabled for cli by maintainer script)
pdo (Enabled for apache2 by maintainer script)
pdo_mysql (Enabled for cli by maintainer script)
pdo_mysql (Enabled for apache2 by maintainer script)
mcrypt (Enabled for cli by maintainer script)
mcrypt (Enabled for apache2 by maintainer script)
sqlite3 (Enabled for cli by maintainer script)
sqlite3 (Enabled for apache2 by maintainer script)
xdebug (Enabled for cli by maintainer script)
xdebug (Enabled for apache2 by maintainer script)
++++ Configuration files: ++++
**** /etc/php5/mods-available/pdo.ini ****
extension=pdo.so
**** /etc/php5/mods-available/opcache.ini ****
zend_extension=opcache.so
-- System Information:
Debian Release: 8.2
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 3.16.0-4-amd64 (SMP w/8 CPU cores)
Locale: LANG=es_ES.UTF-8, LC_CTYPE=es_ES.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages php5-common depends on:
ii libc6 2.19-18+deb8u1
ii lsof 4.86+dfsg-1
ii psmisc 22.21-2
ii sed 4.2.2-4+b1
ii ucf 3.0030
php5-common recommends no packages.
Versions of packages php5-common suggests:
ii php5-xcache [php5-user-cache] 3.2.0-1
Versions of packages php5-cli depends on:
ii libbz2-1.0 1.0.6-7+b3
ii libc6 2.19-18+deb8u1
ii libcomerr2 1.42.12-1.1
ii libdb5.3 5.3.28-9
ii libedit2 3.1-20140620-2
ii libgssapi-krb5-2 1.12.1+dfsg-19
ii libk5crypto3 1.12.1+dfsg-19
ii libkrb5-3 1.12.1+dfsg-19
ii libmagic1 1:5.22+15-2
ii libonig2 5.9.5-3.2
ii libpcre3 2:8.35-3.3
ii libqdbm14 1.8.78-5+b1
ii libssl1.0.0 1.0.1k-3+deb8u1
ii libxml2 2.9.1+dfsg1-5
ii mime-support 3.58
ii php5-json 1.3.6-1
ii tzdata 2015f-0+deb8u1
ii ucf 3.0030
ii zlib1g 1:1.2.8.dfsg-2+b1
Versions of packages php5-cli recommends:
ii php5-readline 5.6.13+dfsg-0+deb8u1
Versions of packages php5-cli suggests:
ii php-pear 5.6.13+dfsg-0+deb8u1
Versions of packages libapache2-mod-php5 depends on:
ii apache2 2.4.10-10+deb8u3
ii apache2-bin [apache2-api-20120211] 2.4.10-10+deb8u3
ii libbz2-1.0 1.0.6-7+b3
ii libc6 2.19-18+deb8u1
ii libcomerr2 1.42.12-1.1
ii libdb5.3 5.3.28-9
ii libgssapi-krb5-2 1.12.1+dfsg-19
ii libk5crypto3 1.12.1+dfsg-19
ii libkrb5-3 1.12.1+dfsg-19
ii libmagic1 1:5.22+15-2
ii libonig2 5.9.5-3.2
ii libpcre3 2:8.35-3.3
ii libqdbm14 1.8.78-5+b1
ii libssl1.0.0 1.0.1k-3+deb8u1
ii libstdc++6 4.9.2-10
ii libxml2 2.9.1+dfsg1-5
ii mime-support 3.58
ii php5-cli 5.6.13+dfsg-0+deb8u1
ii php5-json 1.3.6-1
ii tzdata 2015f-0+deb8u1
ii ucf 3.0030
ii zlib1g 1:1.2.8.dfsg-2+b1
Versions of packages libapache2-mod-php5 suggests:
ii php-pear 5.6.13+dfsg-0+deb8u1
-- no debconf information
--- a/sessionclean 2015-09-16 12:52:00.502262185 +0200
+++ b/sessionclean 2015-09-16 12:53:25.895040658 +0200
@@ -4,26 +4,28 @@
# Iterate through all web SAPIs
(
-proc_names=""
printf "$SAPIS" | \
-while IFS=: read -r conf_dir proc_name; do
- if [ -e /etc/php5/${conf_dir}/php.ini ]; then
- # Get all session variables once so we don't need to start PHP to get each config option
- session_config=$(php5 -c /etc/php5/${conf_dir}/php.ini -d "error_reporting='~E_ALL'" -r 'foreach(ini_get_all("session") as $k => $v) echo "$k=".$v["local_value"]."\n";')
- save_handler=$(echo "$session_config" | sed -ne 's/^session\.save_handler=\(.*\)$/\1/p')
- save_path=$(echo "$session_config" | sed -ne 's/^session\.save_path=\(.*\)$/\1/p')
- gc_maxlifetime=$(($(echo "$session_config" | sed -ne 's/^session\.gc_maxlifetime=\(.*\)$/\1/p')/60))
+ {
+ proc_names=""
+ while IFS=: read -r conf_dir proc_name; do
+ if [ -e /etc/php5/${conf_dir}/php.ini ]; then
+ # Get all session variables once so we don't need to start PHP to get each config option
+ session_config=$(php5 -c /etc/php5/${conf_dir}/php.ini -d "error_reporting='~E_ALL'" -r 'foreach(ini_get_all("session") as $k => $v) echo "$k=".$v["local_value"]."\n";')
+ save_handler=$(echo "$session_config" | sed -ne 's/^session\.save_handler=\(.*\)$/\1/p')
+ save_path=$(echo "$session_config" | sed -ne 's/^session\.save_path=\(.*\)$/\1/p')
+ gc_maxlifetime=$(($(echo "$session_config" | sed -ne 's/^session\.gc_maxlifetime=\(.*\)$/\1/p')/60))
- if [ "$save_handler" = "files" -a -d "$save_path" ]; then
- proc_names="$proc_names $proc_name";
- printf "%s:%s\n" "$save_path" "$gc_maxlifetime"
- fi
- fi
-done
-# first find all open session files and touch them (hope it's not massive amount of files)
-for pid in $(pidof $proc_names); do
- find "/proc/$pid/fd" -ignore_readdir_race -lname "$save_path/sess_\*" -exec touch -c {} \;
-done
+ if [ "$save_handler" = "files" -a -d "$save_path" ]; then
+ proc_names="$proc_names $proc_name";
+ printf "%s:%s\n" "$save_path" "$gc_maxlifetime"
+ fi
+ fi
+ done
+ # first find all open session files and touch them (hope it's not massive amount of files)
+ for pid in $(pidof $proc_names); do
+ find "/proc/$pid/fd" -ignore_readdir_race -lname "$save_path/sess_\*" -exec touch -c {} \;
+ done
+ }
) | sort -rn -t: -k2,2 | sort -u -t: -k 1,1 | while IFS=: read -r save_path gc_maxlifetime; do
# find all files older then maxlifetime and delete them
find -O3 "$save_path" -depth -mindepth 1 -name 'sess_*' -ignore_readdir_race -type f -cmin "+$gc_maxlifetime" -delete