Server Administration
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesServer Administration

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old August 26th, 2003, 03:04 PM
resare resare is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Fort Lauderdale, FL
Posts: 3 resare User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Is it safe mode or...

Hey you guys, I'm just curious if anyone knows anything about safe mode PHP. My server is running with safe mode on. The problem is that I can't delete files. http://www.haifu.org/test.php will give you all the info about my php enviroment, and the whole page looks like this:

<?php
phpinfo();
$c_dir = "/home/httpd/vhosts/haifu.org/httpdocs/1"; // current directory

function delete($dir) {
if (file_exists($dir)) {
umask(0);
chmod($dir,0777);
if (is_dir($dir)) {
$handle = opendir($dir);
while($dirname = readdir($handle)) {
if ($dirname != "." && $dirname != "..") {
delete($dir."/".$dirname);
}
}
closedir($handle);
rmdir($dir);
} else { unlink($dir);
}
}
}

delete ($c_dir);

?>

Note: This is the code at http://www.haifu.org/test.php, so you can see all error messages at the bottom of the page.

I do have file that I've named "1", it's just an empty file meant for testing. Now the problem that I'm getting is that nither chmod nor unlink work, both blame permissions. Script and the file are in the same category, with same user, and I've even tried to manually set "1"'s permissions to 777.

Any ideas oh what I am missing?

Thanks

Reply With Quote
  #2  
Old August 27th, 2003, 04:05 AM
resare resare is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Fort Lauderdale, FL
Posts: 3 resare User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Is it safe mode or...

Ok, I figured out why chmod does not work, my apache is running as a different user, not the same one as the one who owns a file. And I also see that if I allow public execusion of the directory in which I am trying to delete the file, unlink works.

Any ideas of how I can go about executing chmod on directories that are owned by users other then the one apache is running under?

Cheers

Reply With Quote
  #3  
Old August 28th, 2003, 11:31 AM
postalcow postalcow is offline
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Ford CIty, PA USA
Posts: 1,267 postalcow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via Yahoo to postalcow
RE: RE: Is it safe mode or...

Quote:
Any ideas of how I can go about executing chmod on directories that are owned by users other then the one apache is running under?


You have root? Is this your server?

Reply With Quote
  #4  
Old August 28th, 2003, 11:56 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Is it safe mode or...

Yes, postalcow, to both your questions. The only thing is that I would like to do it though PHP, I don't want to go manually through telnet and make changes.

Reply With Quote
  #5  
Old August 28th, 2003, 12:00 PM
xs0 xs0 is offline
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Ljubljana, Slovenia
Posts: 760 xs0 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Is it safe mode or...

You can't.. that's the whole point of Apache being a different user So, unless you're root (don't make Apache root!), you're out of luck from PHP...

Well, there's one exception - if you own the containing directory, you can change permissions (i.e. if you own dir/ and someone owns dir/file.txt, you can take ownership of that file). Or, I might be wrong

Reply With Quote
  #6  
Old August 28th, 2003, 12:49 PM
postalcow postalcow is offline
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Ford CIty, PA USA
Posts: 1,267 postalcow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via Yahoo to postalcow
RE: Is it safe mode or...

Ok, You have an exe cgi-bin that is chmod 755 correct?

then place your script in there have the very first line in the script to be

#!/usr/bin/php -q

or whatever your path to php is. do a

whereis php

this line should be before the <?php

end the file with a .pl extention and chmod 755 it and own it by root. This should work. REMEMBER!!! this is a security risk!!! Use at your own risk!!!

Good Luck

~Cow

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesServer Administration > Is it safe mode or...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

IBM developerWorks




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway