Current location: Hot Scripts Forums » Programming Languages » PHP » Perplexing... and frustrating!


Perplexing... and frustrating!

Reply
  #1 (permalink)  
Old 08-28-07, 09:51 PM
ScottAN ScottAN is offline
Newbie Coder
 
Join Date: Aug 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Perplexing... and frustrating!

I am trying to create a script that I have accessible by http://server.host.name/scriptname.php. The script will need to download a file from a website and move it into a directory such as /home/username/public_html. It seems to be that the only way this script will work is if it runs as root.

The script, when you access through http, does not work because it does not have permission to move files into the other directory without it being CHMODed to 0777. I said okay, I can take care of that, but then I remembered that the script is unable to change permissions on the directory because, well, it doesn't have permission! It would need to be running as root to change the permissions of a directory in a different part of the file system................. right?

By the way, I DO have root access to the machine. So my question is, is there any way to access this script through http and have it run as root? If not, is there any other way to get this to work.

Hopefully this is clear to everyone.
Reply With Quote
  #2 (permalink)  
Old 08-29-07, 01:07 PM
Wolf1994 Wolf1994 is offline
Wannabe Coder
 
Join Date: Sep 2005
Location: Russia
Posts: 117
Thanks: 0
Thanked 0 Times in 0 Posts
You may use FTP access to set needed permission on folder.
Reply With Quote
  #3 (permalink)  
Old 08-29-07, 01:31 PM
bizzar528's Avatar
bizzar528 bizzar528 is offline
Community Liaison
 
Join Date: Sep 2004
Location: Pennsylvania, US
Posts: 1,550
Thanks: 2
Thanked 16 Times in 15 Posts
If you threw the security book out the window (I know), then you could change your apache httpd.conf file to have apache run as root instead of the apache user. That would allow you to keep the permissions set the way they are without having to mess with the user home folder permissions. This is of course a dangerous way of doing things, but it would accomplish the task without killing yourself over permissions.

The better answer to is to not have it so your web script is trying to put files in secure home folders. Why not have sub folders under your site/page and store your files in that location? Is there a reason your trying to put files in /home/user?
__________________
Yep, it's a signature...
Reply With Quote
  #4 (permalink)  
Old 08-30-07, 09:51 AM
ScottAN ScottAN is offline
Newbie Coder
 
Join Date: Aug 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for the replies. You are right, having HTTPd run as root would not be worth the risk. The servers that I am doing this for are hosting servers and have a few hundred users on each. There is going to be a main script where users will input their information and then the main script will call the script on whatever server the user is on. That's why the script will be located at http://ip.add.re.ss/script.php.

I suppose I can add each request to a queue and have a cron function run every few minutes and then take care of it. Cron runs as root right?
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 06:08 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.