PHPAPI int php_checkuid(const char *filename, char *fopen_mode, int mode)
{
struct stat sb;
- int ret;
+ int ret, nofile=0;
long uid=0L, gid=0L, duid=0L, dgid=0L;
char path[MAXPATHLEN];
char *s;
php_error(E_WARNING, "Unable to access %s", filename);
return 1;
}
+ nofile = 1;
} else {
uid = sb.st_uid;
gid = sb.st_gid;
*s = 0;
}
}
+
+ if (nofile) {
+ uid = duid;
+ gid = dgid;
+ filename = path;
+ }
+
if (PG(safe_mode_gid)) {
php_error(E_WARNING, "SAFE MODE Restriction in effect. The script whose uid/gid is %ld/%ld is not allowed to access %s owned by uid/gid %ld/%ld", php_getuid(), php_getgid(), filename, uid, gid);
} else {