user3173526
user3173526

Reputation: 11

PHP permission denied to readdir even though its the same user and group

Ive created a folder in my Gnome Desktop called "olli" and put some files in there. The folder is owned by the user "olli" and group "olli"

I then run this script

<?php
    if ($handle = opendir('/root/Desktop/olli')) {
        while (false !== ($entry = readdir($handle))) {
            if ($entry != "." && $entry != "..") {
                echo "$entry\n";
            }
        }
        closedir($handle);
   }
?>

To try and list the files in there but it just gives permission denied. Even though the script is being ran by the user olli and group olli ?

Do i have to set something else in order to get permission to read this directory ?

Upvotes: 0

Views: 456

Answers (1)

Marc B
Marc B

Reputation: 360602

Doesn't matter what the olli directory's permissions are, a script running as olli:olli will NOT have the rights to access anything in /root.

What you've done is the equivalent of leaving a safety deposit box inside a bank vault wide open. The box is there for the taking, but you can't get into the vault to access the box in the first place.

Upvotes: 1

Related Questions