Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Im setting 444 permissions on a file, but still, Im able to rename files.

I tried it through php with the rename() function and in terminal with the mv command.

I list my file and it appears as -r--r--r-- 1

So my question is, for renaming files you dont need permissions so the file. I think this is a security concern since, someone without permissions could just change all my files names and break my system.

share|improve this question

migrated from stackoverflow.com Jun 17 '13 at 17:56

This question came from our site for professional and enthusiast programmers.

2 Answers 2

up vote 3 down vote accepted

Renaming is done at the directory level. If a user has write permissions on a directory, they can rename files in that directory, even if they have no access to the files themselves.

e.g. the filename is stored in the directory "file". This is how hardlinks are accomplished, allowing one single file to have multiple filenames associated with it.

in other words, this is working as expected, and is not a "security concern".

share|improve this answer
    
Not sure about your brief mention of how hardlinks works. Surely to explain that properly you need to introduce the concept of the inode and how (possibly multiple) names map to them in the directory file. I would remove the reference to hardlinks unless you can explain it better. –  trojanfoe Jun 17 '13 at 17:10
    
Thanks a lot for your answer, I really thought something was wrong with my environment, because most of the info I found was about having issues because I didnt had permissions and not the other way around. –  user2494096 Jun 17 '13 at 22:59

Renaming the file changes the directory and not the file itself. Remove the w permissions from the directory to prevent it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.