8000 Merge branch 'pull-request/1360' into PHP-7.0 · php/php-src@b0ff9ee · GitHub
[go: up one dir, main page]

Skip to content

Commit b0ff9ee

Browse files
committed
Merge branch 'pull-request/1360' into PHP-7.0
* pull-request/1360: Fixed bug #69582 session not readable by root in CLI news entry for PR #1360
2 parents 6a03b43 + 650e073 commit b0ff9ee

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ PHP NEWS
88
- ZIP:
99
DE57 . Fixed bug #70103 (ZipArchive::addGlob ignores remove_all_path option). (cmb)
1010

11+
- Session:
12+
. Fixed bug #69582 (session not readable by root in CLI). (EvgeniySpinov)
13+
1114
19 Jan 2017 PHP 7.0.15
1215

1316
- Core:

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)
0