Home » Questions » Computers [ Ask a new question ]

Deleting a chmod 0 file without superuser rights?

Deleting a chmod 0 file without superuser rights?

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?

Asked by: Guest | Views: 269
Total answers/comments: 2
Guest [Entry]

"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."
Guest [Entry]

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.