tags:

views:

54

answers:

1

I am trying to make a lightweight frontend for my fileserver. I use PHP to display all the files, but readdir() is executed as the http user, because apache is started as this user.

This is a problem, because I want to view all my files. Therefore, readdir() has to be run as root, but I don't know how to do that. Can you guys help me?

+1  A: 

This cannot be done. You can't run a single function as another user unless you started out as that user and then are shifting back to them temporarily.

Ignacio Vazquez-Abrams
Okay. Do you have any other suggestions of how I can achieve the same? Maybe with exec('sudo ls') or something like that?Or is it easier to just start apache as root, switch to http and then switch back? (don't really know how to do that either)
Ben
You could look at using ACLs to control access to the directories.
Ignacio Vazquez-Abrams
How can ACLs give me access to files I do not own, seeing that it does not communicate with the system? What I have done now is setting the apache owner to my own user and now I can see my own folder. But you said something about changing users. Can I switch a live apache server started from my user back to http and back to my user again?
Ben