LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 11-23-2014, 07:54 AM   #1
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,430

Rep: Reputation: 55
Is there a way to designate a file append only?


Is there a way to designate a file append only?
 
Old 11-23-2014, 08:45 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,791

Rep: Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304
can you explain it better? "file append" is not good enough?
 
Old 11-23-2014, 08:58 AM   #3
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,430

Original Poster
Rep: Reputation: 55
Quote:
Originally Posted by pan64 View Post
can you explain it better? "file append" is not good enough?
Forgot a comma, sorry.

Is there a way to designate a file, as append only? IE. it can only be appended to.
 
Old 11-23-2014, 10:51 AM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
As far as I know, the Linux/ Unix filesystem does not distinguish between appending and writing, so there is no way to do this directly. I stand corrected

You could allow write permission only for a dedicated user, who would run a program that appends the data it reads from a socket/pipe. Effectively, write permission on the pipe == append permission on the file.

Last edited by ntubski; 11-24-2014 at 10:15 AM. Reason: Apparently many Linux file systems do support this
 
1 members found this post helpful.
Old 11-23-2014, 01:52 PM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
With SElinux you can grant append-only capability if you are willing to go through the work to create a new type and set up all the needed access permissions. Of course you would have to be running in enforcing mode for that to be effective.
 
1 members found this post helpful.
Old 11-24-2014, 08:40 AM   #6
Kenhelm
Member
 
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 360

Rep: Reputation: 170Reputation: 170
Setting the 'a' attribute with 'chattr' can make a file append-only.
chattr +a filename

http://en.wikipedia.org/wiki/Chattr
Quote:
chattr and lsattr utilities on Linux and the attributes they manipulate were originally specific to the Second Extended Filesystem family (ext2, ext3, ext4), and are available as part of the e2fsprogs package. The functionality has since been extended to many other Linux file systems, including XFS, ReiserFS, JFS, OCFS2 and others, although not all file systems support all flags.
http://www.linuxintheshell.org/2013/...tr-and-chattr/
Quote:
a - append only: Writing to a file will only allow the file to be opened in append mode for writing. That is you cannot redirect output to overwrite the file, only append to it. Most normal file edit operations, like opening the file with a text editor, will most likely fail as the program will attempt to overwrite the file with the changes and "permission denied" will be displayed. This attribute can only be set by an account with superuser privileges.
 
Old 11-25-2014, 06:59 AM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,640
Blog Entries: 4

Rep: Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933
Also, generally speaking, this sort of file-access has pretty severe limitations. Consider, for example, the problem of what-to-do if more than one process wishes to append to the file at the same time. Given that the operating system will, of course, do it properly, the order of the records that would get written-to the file would of course be random. None of the programs could, so to speak, "see" what they are writing. Construction of any sort of data-structure would be impossible. Really, it would only be useful for some kind of log-file. And if you want to do that, a simple "logging daemon" that accepts network-connections or pipes is a much more satisfactory solution. As long as the daemon can be trusted to do its job correctly, it alone defines what sort of requests it will and won't respond-to.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
append file name watcher69b Linux - Newbie 8 10-21-2009 07:31 PM
how to append contents of one file to another existing file amit_pansuria Programming 1 11-17-2008 10:01 AM
Append file ust Linux - Newbie 2 11-06-2008 09:51 PM
how to append columns form a column file in another file adam_blackice Programming 4 09-17-2007 11:33 PM
append to file d-rez Linux - Newbie 2 06-20-2002 04:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 11:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration