From a2c461d58ae48e0643b93e9783839bdce2efd9e9 Mon Sep 17 00:00:00 2001 From: Evgeniy Spinov Date: Wed, 24 Jun 2015 15:26:25 +0400 Subject: *[Sessions]: Now session is accessible if process is ran by root. Fixing bug: https://bugs.php.net/bug.php?id=69582 --- ext/session/mod_files.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'ext/session') diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c index 0ee4500010..57c5277a4b 100644 --- a/ext/session/mod_files.c +++ b/ext/session/mod_files.c @@ -195,8 +195,14 @@ static void ps_files_open(ps_files *data, const char *key) if (data->fd != -1) { #ifndef PHP_WIN32 /* check that this session file was created by us or root – we - don't want to end up accepting the sessions of another webapp */ - if (fstat(data->fd, &sbuf) || (sbuf.st_uid != 0 && sbuf.st_uid != getuid() && sbuf.st_uid != geteuid())) { + don't want to end up accepting the sessions of another webapp + + If the process is ran by root, we ignore session file ownership + Use case: session is initiated by Apache under non-root and then + accessed by backend with root permissions to execute some system tasks. + + */ + if (fstat(data->fd, &sbuf) || (sbuf.st_uid != 0 && sbuf.st_uid != getuid() && sbuf.st_uid != geteuid() && getuid() != 0)) { close(data->fd); data->fd = -1; return; -- cgit v1.2.1 From 650e073f7a88350002436baabe778957388d1411 Mon Sep 17 00:00:00 2001 From: Evgeniy Spinov Date: Sun, 28 Jun 2015 12:02:57 +0400 Subject: *[Sessions]: Now session is accessible if process is ran by root. Fixing bug: https://bugs.php.net/bug.php?id=69582 *[Sessions]: Replaced fstat with zend_fstat --- ext/session/mod_files.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/session') diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c index 57c5277a4b..8fdce47a65 100644 --- a/ext/session/mod_files.c +++ b/ext/session/mod_files.c @@ -202,7 +202,7 @@ static void ps_files_open(ps_files *data, const char *key) accessed by backend with root permissions to execute some system tasks. */ - if (fstat(data->fd, &sbuf) || (sbuf.st_uid != 0 && sbuf.st_uid != getuid() && sbuf.st_uid != geteuid() && getuid() != 0)) { + if (zend_fstat(data->fd, &sbuf) || (sbuf.st_uid != 0 && sbuf.st_uid != getuid() && sbuf.st_uid != geteuid() && getuid() != 0)) { close(data->fd); data->fd = -1; return; -- cgit v1.2.1