0

I have a php script in a directory called /manager. In it, I open and write to a file in the directory above /manager. However, if the permissions are set to allow owner write, I get "failed to open stream: Permission denied"

It only works when I change permissions to allow public write, but doesn't this allow anyone to write to my file? Could this be happening because it is reaching up a directory, or am I misunderstanding permissions?

cstack
  • 163
  • 1
  • 2
  • 7

1 Answers1

0

My first question is who owns the directory? is it Apache? If not, then you will probably have issue writing to that directory. Your next option is to allow group permissions to handle things -- is the owner in the www group? (Pardon if that is not the right name) If so, you can have the group permissions set to allow Apache and yourself to write (assuming that the owner is in the group).

As to public write -- that means that all users and services which are running on/logged in to that machine will be able to write to that directory. It does not mean that a malicious person operating outside of the machine will be able to futz with it... unless he happens to be able to sign on...

cwallenpoole
  • 325
  • 2
  • 13
  • So if I am on a shared server on a web host, does that mean anybody else who happens to be hosted on the same server as me could write to my files? – cstack Jul 24 '10 at 14:13
  • No... Most web servers make each user work in his own virtualized machine. Hostgator, for example, only shows the users I create in my /home/ directory. Now, if you happen to be sharing the same account with others, that would allow them to write to your directories. So, I happen to own Allen-Poole.com, if my wife were to log in, she might be able to change some data, but then she would need to actually log in to the server (she wouldn't want to...) . If you wanted to change my data (even chmod 777 stuff), you could not, even if you had a hostgator account. – cwallenpoole Jul 29 '10 at 18:35