LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-14-2008, 02:29 PM   #1
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 316

Rep: Reputation: 30
Permission issues


I have this PHP code:
Code:
<?php
$filename = "configuration.php";
if (file_exists($filename)) {
    echo "The file $filename exists<br />";
} else {
    echo "The file $filename does not exist<br />";
}
        $perms = fileperms($filename);
echo "ENTERING 1<br />";
        if ($perms !== FALSE)
echo "IFCHECK 1<br />";
                if (@chmod($file, $perms ^ 0001)) {
echo "IFCHECK 2<br />";
                        @chmod($file, $perms);
                        return TRUE;
                } // if
           echo "FAILED";
        return FALSE;

?>
Generates this output:
Quote:
The file configuration.php exists
ENTERING 1
IFCHECK 1
FAILED
So chmod failed. But the user is able to chmod this file via SSH and FTP. Why is it failing here?

[EDIT] More tests:
Code:
<?php
$filename = "testconfig.php";
if (file_exists($filename)) {
    echo "The file $filename exists<br />";
} else {
    echo "The file $filename does not exist<br />";
}
        $perms = fileperms($filename);
echo "ENTERING 1<br />";
        if ($perms !== FALSE)
echo "IFCHECK 1<br />";
                //if (@chmod($file, $perms ^ 0001)) {
echo "IFCHECK 2<br />";
                        chmod($file, $perms);
                        return TRUE;
                //} // if
           echo "FAILED";
        return FALSE;
Quote:
The file testconfig.php exists
ENTERING 1
IFCHECK 1
IFCHECK 2

Warning: chmod() [function.chmod]: No such file or directory in /home/protect/public_html/data/test.php on line 14
Why is chmod not seeing the file?

Last edited by Zeno McDohl; 01-14-2008 at 03:18 PM.
 
Old 01-15-2008, 03:17 AM   #2
jazzgossen
LQ Newbie
 
Registered: Jan 2008
Posts: 2

Rep: Reputation: 0
Quote:
Originally Posted by Zeno McDohl View Post
So chmod failed. But the user is able to chmod this file via SSH and FTP. Why is it failing here?
Which user is able to chmod the file? The PHP code is probably not being run by an ordinary user. I think Apache (if that's your web server) runs as the "nobody" user per default. Try changing the User directive in Apache's config, or look at the suEXEC feature, if you want to allow changing such things via a web interface.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Permission issues on ksh everest9k Linux - Newbie 1 09-25-2006 03:04 PM
permission issues CiscoGeek Linux - Newbie 4 07-30-2006 09:27 AM
Permission Issues turbo_acura Linux - Software 3 02-20-2006 05:24 PM
nfs permission issues. rtaft Linux - Networking 2 02-19-2004 03:20 PM
permission issues. neuroX Linux - Software 7 02-17-2004 07:40 AM


All times are GMT -5. The time now is 10:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration