2

A PHP script accidentially changed the right flags (chmod) of a directory to 0. (No access to anybody, including owner). If I have no root access to this server, is it possible to delete the file again with FTP or PHP?

3 Answers 3

6

Barring some use of ACLs outside the basic permission system, a chmod 000 can be undone without extra authority. The permission bits control access to the contents of the file, but they do not control write access to the permission bits themselves. Typically, root and the file's owner always have write access to the permission bits. So, you should be able to ‘recover’ the file, as long as you can take actions as the file's owner.

$ id -u                                       
501
$ echo foo > foo                              
$ stat -f '%u %p' foo; cat foo                
501 100644
foo
$ chmod 000 foo
$ stat -f '%u %p' foo; cat foo
501 100000
cat: foo: Permission denied
$ chmod 644 foo
$ stat -f '%u %p' foo; cat foo
501 100644
foo

If you have shell access and your shell user owns the file (or your user can change to the file's owner (su/sudo/…)), then just chmod it back by hand. Otherwise, if you can edit the PHP script (and the PHP runs as the file's owner), just edit it to chmod the file to the desired permissions.

0

If you can amend the PHP that created the file in the first place, perhaps you could make the PHP reset the permissions to what you want...

-1

Basically, no. You lost all access to the file. Only root can change the permissions on that file. Contact your system administrator, or the admins of the hosting company or ISP hosting the site.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .