/    Sign up×
Community /Pin to ProfileBookmark

file_exists issue

Hi all,
On a Debian server in which I have full root access, I have:

A domain file, with path
/var/www/sites/myuser/mydomain.tld/subdomains/www/html/images

And a file in
/usr/share/mycms
which is as follows;

[code=php]$picpath = “/var/www/sites/myuser/mydomain.tld/subdomains/www/html/images”;
$image = “/images/ball.jpg”;
$pathtoimage = $picpath.”/ball.jpg”;
print “Path To Image: “.$pathtoimage.”<br/>”;
if(!file_exists($pathtoimage))
{
print “Tested If File Exists… Result: NO FILE<br/>”;
}
else
{
print “<img src='”.$image.”‘>”;
}[/code]

The server is configured such that a domain file /mycms/is included in the root path of each domain.

While my problem is one of Apache permissions, I post here because I am wondering if my problem is php configuration related.

I have a user ‘cms’ and a group ‘cmsgroup’. All files in the domain are owned by cms:cmsgroup.
All files in the usr/share/mycms folder are owned by root:cmsgroup.
Or at least, that’s the way it’s supposed to be.

My problem is that if the above php script is owned by root:cmsgroup, it can not detect that the target file exists.

If it is owned by cms/cmsgroup, it can detect the file. Unfortunately, in this configuration, a user could alter a file in his domain, and then read/alter files in /usr/share/mycms.

You can see for yourself at the following addresses…
[URL=”http://www.wroof.com/wroof/test.php”]www.wroof.com/wroof/test.php[/URL] (root:cmsgrp)
and
[URL=”http://www.wroof.com/wroof/testcms.php”]www.wroof.com/wroof/testcms.php[/URL] (cms:cmsgrp)

I have checked the groups file to make sure the user is part of that group, and I have tried setting individual file permissions in the domain to 777. The result does not change.

Is there a php configuration that would cause this?
Can anyone suggest some other configuration that might be the source of the problem?

Thanks
CTB

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @chestertb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...