LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   Is there a way to specify append only permissions for a file? (https://www.linuxquestions.org/questions/linux-security-4/is-there-a-way-to-specify-append-only-permissions-for-a-file-754726/)

abefroman 09-12-2009 05:44 PM

Is there a way to specify append only permissions for a file?
 
Is there a way to specify append only permissions for a file?

TIA

tommylovell 09-12-2009 09:46 PM

If your filesystem is ext2/3, you can set the 'a' extended attribute using the chattr command.

From the chattr man page:
Quote:

A file with the ‘a’ attribute set can only be open in append mode for writing. Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute.
That'll prevent a file from being opened for output but won't automatically change it to append (that is, it won't change an fopen's mode from 'w' to 'a', it'll just prevent the file from being overwritten).

abefroman 09-12-2009 09:52 PM

Quote:

Originally Posted by tommylovell (Post 3680591)
If your filesystem is ext2/3, you can set the 'a' extended attribute using the chattr command.

From the chattr man page:


That'll prevent a file from being opened for output but won't automatically change it to append (that is, it won't change an fopen's mode from 'w' to 'a', it'll just prevent the file from being overwritten).

EXACTLY WHAT I NEEDED!!

I am using this for the .bash_history files for underprivileged users.


All times are GMT -5. The time now is 04:43 PM.