Skip to content

Commit a2c461d

Browse files
author
Evgeniy Spinov
committed
*[Sessions]: Now session is accessible if process is ran by root. Fixing bug: https://bugs.php.net/bug.php?id=69582
1 parent 2424b34 commit a2c461d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

ext/session/mod_files.c

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

0 commit comments

Comments
 (0)