3

I have some php scripts that need to move, create and delete files and folders. Unless I CHMOD the folders to 777 the php scripts die with errors about permissions. CHMOD'ing the folders to 777 fixes the problem, but after a lot of reading I'm still confused as to whether it's OK to do or not.

I've read that it can be dangerous on shared hosting, but my question is, is it safe to do on a VPS?

Nate
  • 26,164
  • 34
  • 130
  • 214

1 Answers1

6

VPS or not it does not really matter. Chmod 777 means you are giving anyone (any user, incl. system daemons) all permissions possible (which includes read, write and execute) to given file or directory. if you are the only user on the machine, then it reduces the risk (still, if anyone break in, then he would still be able to mess using hacked daemon's user id). Additionally, if there're other user accounts on that VPS, setting 777 lets them put their content into files with said permission (or launch them). Will they do that - who knows. They might, just because they can due to 777. In general, rule of the thumb should be give as much permissions as really needed, and nothing beyond that.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
  • Can you elaborate what you mean by "other users"? I'm kind of a newbie and am not sure what you mean :) – Nate Sep 16 '12 at 20:17
  • "users" are usually people who can log in onto the machine (you are the user there too). If you got root permisions, do `vipw` (or `cat /etc/passwd`)- these are your users there too - all people's account AND all system accounts. If `777` is set then anyone can play with the file. – Marcin Orlowski Sep 16 '12 at 20:20
  • Thanks for your answer. It sounds like I need to find out how to manipulate files without setting their permissions to 777. – Nate Sep 16 '12 at 20:32