File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments