I have file with 777 permission. How can I prevent changing ownership of that file by others? ie I need to prevent
chown x:y myfile
myfile is actually a log file written from web. it's ownership is www-data.
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
Only root can change ownership of the file, so you don't have to worry about that.
You do however have to worry about the permissions. A logfile shouldn't be world writable. You don't want everybody to write the file in arbitrary ways. You only want them to append to the file. You cannot do that with conventional unix permissions, but you have other options.
You may be able to achieve this with ACLs. Otherwise this question has information about making a file append-only for everyone and not just others.
An even better approach may be to do your logging through syslog.