Permission Problems in PHP

Message boards : Web interfaces : Permission Problems in PHP
Message board moderation

To post messages, you must log in.

AuthorMessage
Abel Licon

Send message
Joined: 31 Jan 08
Posts: 5
United States
Message 15184 - Posted: 31 Jan 2008, 18:02:04 UTC

Hi, I'm new to BOINC and I'm hoping someone can help. I'm not sure if this is the right place to put this but here it goes anyway.

I am a graduate student new to a project at UDEL (Docking@home). I am trying to set up a server on one of my machines at school so I can get familiar with the infrastructure of BOINC before I go tinkering around with the real deal.

Here is my problem. I am having trouble getting the automatically generated web-site that BOINC comes with to work. I keep having problems with permissions. PHP is not able to create new files in the directories.

I have tried setting the permissions of the entire example uperCASE project to 777 to no avail. I still get permission denied errors in my /var/log/apache2/error_log file and a blank web-site.

I put an echo ("test"); on the first line of the /html/users/ folder and it will print out to my browser, so it is reading from the proper directory. But if I put an echo("test"); after the first include directive I get nothing in the browser. (Could it be an include problem?)

I followed the instructions the best I could, I have a boinc_admin user that created the project using ./make_project --test_app myProject, I have a boinc group that wwwrun is a part of. I even copied the required configuration file to my httpd.conf file.

The ./make_project seemed to run flawlessly, but I still can't see the web-site in the browser. I've searched high and low for some answers and all I get is that I have not set my permissions properly in the folders, but I've tried everything.

Somewhere is was suggested that my php.ini file might have safe_mode turned on, but I checked and this is not the case.

Any help or redirection would be greatly appreciated, if I am doing something totally stupid please be gentle, I'm new to BIONC.


ID: 15184 · Report as offensive
Nicolas

Send message
Joined: 19 Jan 07
Posts: 1179
Argentina
Message 15187 - Posted: 31 Jan 2008, 18:45:54 UTC - in response to Message 15184.  

Looks like the include file is causing an error, which stops further execution; but the error isn't being shown. Make sure you have error reporting turned on in php.ini.

ID: 15187 · Report as offensive
Abel Licon

Send message
Joined: 31 Jan 08
Posts: 5
United States
Message 15190 - Posted: 31 Jan 2008, 20:52:10 UTC - in response to Message 15187.  

Looks like the include file is causing an error, which stops further execution; but the error isn't being shown. Make sure you have error reporting turned on in php.ini.



Ok after digging through the include files I found that translation.inc was crashing PHP at line 422. While it was calling the buildLanguages() function.

After commenting out that line (and turning on the error reporting in php.ini) I get the following error in the browser.

Warning: %v%v() [function.%v]: failed to open stream: Permission denied in /data/home/boinc_admin/projects/licon/html/inc/translation.inc on line 414

Warning: fwrite(): supplied argument is not a valid stream resource in /data/home/boinc_admin/projects/licon/html/inc/translation.inc on line 415

Warning: fclose(): supplied argument is not a valid stream resource in /data/home/boinc_admin/projects/licon/html/inc/translation.inc on line 416
ERROR: Could not load language interface. This is a fatal error, exiting.
Notice: Use of undefined constant flush - assumed 'flush' in /data/home/boinc_admin/projects/licon/html/inc/translation.inc on line 438


I'm assuming it is a result of not being able to create the file and write to it, but I still can't get the stupid permissions to work.

NOTE: With the line uncommented I only get the permission errors and no fatal errors from PHP.

ID: 15190 · Report as offensive
Abel Licon

Send message
Joined: 31 Jan 08
Posts: 5
United States
Message 15193 - Posted: 31 Jan 2008, 22:44:09 UTC - in response to Message 15190.  

Ok, I think I figures out what happened. I followed the instructions from ./make_project to copy the boinc configuration information to the httpd.conf file. This creates aliases to the directories where my project. is. For some reason or another, PHP wasn't able to create files in the folder specified in the alias. So I checked my document root, which was in a different location than my project folder.(/srv/www/htdocs/) In here I created a short php script that opens a file, an viola, it works!

Ok, so I an create files here but not over there, so yes, I copy the project folder to the document root, and yes, php can create files again. I assure you that all the permissions where the same as when I had them elsewhere, so it was location that was the factor. (I think)

So I'm not to familiar with how aliases work, but do they have to be in a sub-directory that is in the document root? If so, that was my problem. Otherwise I just don't know what's going on.

In my schools httpd.conf file they set up a virtual host and set the document root to the project folder, I'm gonna copy their config file and see if I can get it working on from my project directory, otherwise I'll just leave it in the default document root where it works.


ID: 15193 · Report as offensive
Profile Ananas

Send message
Joined: 27 Jun 06
Posts: 305
Germany
Message 15196 - Posted: 1 Feb 2008, 5:35:26 UTC

It could be a PHP security setting that doesn't allow access to directories below the web root directory (like a restricted shell).
ID: 15196 · Report as offensive
Abel Licon

Send message
Joined: 31 Jan 08
Posts: 5
United States
Message 15240 - Posted: 6 Feb 2008, 4:30:55 UTC - in response to Message 15196.  

Ok, so I didn't figure out what causing me so many problems but here is how I solved it. After much frustration with getting the permissions right, I thought, hell, if chmod -R 777 doesn't work then maybe changing the owner and group to that of apache will. So, to the project directory (outside of the document root of apache) as root I changed owner to wwwrun and the group to www of all the project folders.


chown -R wwwrun ./projects/licon
chgrp -R www ./projects/licon

Then tried refreshing the page. Wholly crap it works! Ok, so I can't leave it like that so I figured I'd change it back and see what happens.

chown -R boinc_admin ./projects/licon
chgrp -R boinv ./projects/licon

And it still works. I couldn't believe it. The owner and group where back to what they where when it wasn't working and yet ... now it is. I tried the same thing again, this time without refreshing the browser between changing ownership from boin_admin to wwwrun, and it didn't work, permission still denied.

So for some reason unknown to me, I was able to get it working by 1st changing ownership to wwwrun, and group to www, refreshing the browser then back to boinc_admin and boinc. God knows this was driving me crazy.

The way I figured out was by creating new folders and trying to open a file through php. Any new folder I created was able to have a index.php file and be able to create a test file. If i tried to put an index.php in any of the boinc project folders, it wouldn't have it and it would give me a permission denied error, even though the permissions/owners/groups where exactly the same on both the project folders and the new folders I created in the project sub-directory.

I really don't understand why what I did fixed the problem, ... but it did.
ID: 15240 · Report as offensive
Eric Myers
Avatar

Send message
Joined: 12 Feb 06
Posts: 232
United States
Message 15422 - Posted: 14 Feb 2008, 14:29:45 UTC - in response to Message 15240.  


I really don't understand why what I did fixed the problem, ... but it did.

If you chmod 777 then it doesn't really matter what the owner and group are, eh?

-- Eric Myers

"Education is not the filling of a pail, but the lighting of a fire." -- William Butler Yeats
ID: 15422 · Report as offensive
Abel Licon

Send message
Joined: 31 Jan 08
Posts: 5
United States
Message 15572 - Posted: 25 Feb 2008, 17:19:51 UTC - in response to Message 15422.  


I really don't understand why what I did fixed the problem, ... but it did.

If you chmod 777 then it doesn't really matter what the owner and group are, eh?



I finally figured out the culprit but I have no solution yet. Apparently anything in the top folder of where I had the BOINC project didn't respect any of the group permissions. Only owners could access the files. If you are a member of the group that the file was attached to, you still where denied permission. This is why even chmod 777 didn't work because it would only allow the owner to modify the files, no matter what. I created a new folder at the root level. This one did respect permissions accordingly and it worked as expected. I am still not sure why anything in that other folder wouldn't. I have since left that little project since I was only doing it to get some knowledge on BOINC.

If anyone has some insight at to what would cause a folder to not respect group permissions I am all ears.

ID: 15572 · Report as offensive
Thyme Lawn

Send message
Joined: 2 Sep 05
Posts: 102
United Kingdom
Message 15573 - Posted: 25 Feb 2008, 18:13:07 UTC - in response to Message 15572.  

If anyone has some insight at to what would cause a folder to not respect group permissions I am all ears.

It's probably due to the group (or other, depending on the ownership) permissions on the directory or one of its parents. Check the relevant permissions on the path to the file.

  • If you are accessing specific files in a directory (includes traversing through it) you'll need access permission (--x).

  • If you need to scan the contents of a directory you'll also need read permission (r-x).

  • You only need write permission (rwx) if you're going to create files in a directory.


"The ultimate test of a moral society is the kind of world that it leaves to its children." - Dietrich Bonhoeffer
ID: 15573 · Report as offensive

Message boards : Web interfaces : Permission Problems in PHP

Copyright © 2021 University of California. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.