Skip to content

Commit 969622c

Browse files
committed
Merge branch 'PHP-7.1'
* PHP-7.1: Fixed bug #69582 session not readable by root in CLI
2 parents 7c94b3b + 811dfaa commit 969622c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ PHP NEWS
8686
. Fixed bug #73461 (Prohibit session save handler recursion). (Yasuo)
8787
. PR #2233 Removed register_globals related code and "!" can be used as $_SESSION key name. (Yasuo)
8888
. Improved bug #73100 fix. 'user' save handler can only be set by session_set_save_handler()
89+
. Fixed bug #69582 (session not readable by root in CLI). (EvgeniySpinov)
8990

9091
- SOAP:
9192
. Fixed bug #69137 (Peer verification fails when using a proxy with SoapClient)

ext/session/mod_files.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,14 @@ static void ps_files_open(ps_files *data, const char *key)
196196
if (data->fd != -1) {
197197
#ifndef PHP_WIN32
198198
/* check that this session file was created by us or root – we
199-
don't want to end up accepting the sessions of another webapp */
200-
if (fstat(data->fd, &sbuf) || (sbuf.st_uid != 0 && sbuf.st_uid != getuid() && sbuf.st_uid != geteuid())) {
199+
don't want to end up accepting the sessions of another webapp
200+
201+
If the process is ran by root, we ignore session file ownership
202+
Use case: session is initiated by Apache under non-root and then
203+
accessed by backend with root permissions to execute some system tasks.
204+
205+
*/
206+
if (zend_fstat(data->fd, &sbuf) || (sbuf.st_uid != 0 && sbuf.st_uid != getuid() && sbuf.st_uid != geteuid() && getuid() != 0)) {
201207
close(data->fd);
202208
data->fd = -1;
203209
php_error_docref(NULL, E_WARNING, "Session data file is not created by your uid");

0 commit comments

Comments
 (0)