I suggest that I have a log file with 666 permission and its owner is alice. So user 'bob' can change its owner by this:

cp log log.temp; rm log; mv log.temp log

So how can I fix this risk?

migrated from stackoverflow.com Jan 9 '13 at 8:23

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

  • Put its ownership as 600? – hd1 Jan 9 '13 at 3:54
  • 2
    'bob' can do that only if he has write permissions for the directory containing the file. – Andrey Voitenkov Jan 9 '13 at 8:34

As Andrey says above, bob can only do what you say if he has rights over the directory which contains the file. Just change the dir permissions to xx5 if you want bob to access but being unable to create new files.

from Understading UNIX permissions

Access permissions for files and folders mean different things from the user standpoint.

For Files

  • Read: If the file contents can be read
  • Write: If user or process can write to the file (change its contents)
  • Execute: If the file can be executed

For Directories

  • Read: If the directory listing can be obtained
  • Write: If user or process can change directory contents somehow: create new or delete existing files in the directory or rename files.
  • Execute: If user or process can access the directory, that is, go to it (make it to be the current working directory)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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