Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Mon Jan 11, 2010 9:21 am 
Offline
Junior Member
User avatar

Joined: Thu Sep 03, 2009 10:47 pm
Posts: 35
Website: http://www.kavoir.com/
So I exec 'rm -rf sth' from a php script run by /usr/bin/php5 /path/to/phpscript.php.

sth is a directory with the status:

drwxr-sr-x 2 www-data www-data 4096 Jan 11 12:58 sth

An everything in it has the status:

-rw-r--r-- 1 www-data www-data 5189 Jan 11 12:58 blahblahblah

The phpscript.php status is:

-rw-r--r-- 1 myuser www-data 544 Jan 10 07:00 phpscript.php

Everytime I try to run /usr/bin/php5 /path/to/phpscript.php, it fails to delete sth and gives me permission denied error:

rm: cannot remove `/path/to/sth': Permission denied

How can I make it work? I tried to change the ownership of phpscript.php to that of sth, but it didn't work.

_________________
I have a passion for building websites. I love Usable Databases.


Top
   
 Post subject:
PostPosted: Mon Jan 11, 2010 10:33 am 
Offline
Senior Newbie

Joined: Sun Jan 03, 2010 1:09 pm
Posts: 13
Website: http://adrianm.com
Location: NJ, USA
Did you try adding sudo before rm?


Top
   
 Post subject:
PostPosted: Mon Jan 11, 2010 8:17 pm 
Offline
Senior Member
User avatar

Joined: Mon Dec 10, 2007 4:30 pm
Posts: 341
Website: http://markwalling.org
Who's executing the script? Does that person have rights to remove that directory?


Top
   
 Post subject:
PostPosted: Mon Jan 11, 2010 10:52 pm 
Offline
Junior Member
User avatar

Joined: Thu Sep 03, 2009 10:47 pm
Posts: 35
Website: http://www.kavoir.com/
Quote:
Did you try adding sudo before rm?


Wouldn't that be prompting you for password? The rm command is executed in a php script via exec(). I don't know if I can do that.

Quote:
Who's executing the script? Does that person have rights to remove that directory?


So the person who's executing the script should have the permissions to delete the thing rather than the owner of the script?

So www-data should be the person who executes the script instead of me (myuser)?

_________________
I have a passion for building websites. I love Usable Databases.


Top
   
 Post subject:
PostPosted: Mon Jan 11, 2010 10:56 pm 
Offline
Junior Member
User avatar

Joined: Thu Sep 03, 2009 10:47 pm
Posts: 35
Website: http://www.kavoir.com/
mwalling wrote:
Who's executing the script? Does that person have rights to remove that directory?


That's a great insight. I've added a crontab entry for user www-data instead of my user myuser:

sudo crontab -e -u www-data

Will see if it works.

_________________
I have a passion for building websites. I love Usable Databases.


Top
   
 Post subject:
PostPosted: Tue Jan 12, 2010 9:18 am 
Offline
Senior Member
User avatar

Joined: Mon Dec 10, 2007 4:30 pm
Posts: 341
Website: http://markwalling.org
The script owner doesn't change who the script runs as (unless you use magical incantations (sticky bits)).


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group