[plug] file options

Andrew Pamment pamment at iinet.net.au
Fri May 30 10:15:19 WST 2003


I'm pretty sure it is possible using ext2 file attributes. from:

http://www.tldp.org/HOWTO/mini/Ext2fs-Undeletion-2.html

	On an ext2 file system, it is possible to use ext2 attributes to
	protect things. These attributes are manipulated with the chattr
	command. There is an `append-only' attribute: a file with this
	attribute may be appended to, but may not be deleted, and the existing
	contents of the file may not be overwritten. If a directory has this
	attribute, any files or directories within it may be modified as
	normal, but no files may be deleted. The `append-only' attribute 	is
set with 


	$ chattr +a FILE...

I tested this out on my spare ext2fs partition, (it doesn't work with
reiserfs and i don't know about ext3) I couldn't make it work because I
don't have a program that i can think of that opens in append mode.. i
had a look at nano and I am guessing it wants to write out the whole
file again, and of course it wont let me because that would be modifying
the existing contents..

I think possibly this would be a good attribute to use for log files as
I suspect they are opened in append mode, and a nasty evil computer
criminal wanting to hide his tracks and doesn't know about chattr would
be foiled.

So, I'm pretty sure it *is* possible.. but you said proof and you'll buy
me an ice cream.. ooh I need ice cream

$ touch test.txt

$ chattr +a test.txt

$ nano

*change the file*

*save*

nano reports "Operation not permitted"

so I write a program.. 

#include <stdio.h>

int main (void ){
        FILE *testfile;

        testfile = fopen("test.txt", "a");

        fprintf(testfile, "an appended line\n");

        fclose(testfile);
        return 0;
}

$ gcc program.c

$ ./a.out

$ cat test.txt
an appended line
$

See.. it is possible.. can I have my ice cream now?

Andrew


On Fri, 2003-05-30 at 08:34, Nima Talebi wrote:
> ooh, _not delete what is already there_, you can't. If you prove me
> wrong, I'll buy you an ice cream.
> 
> Nima
> 
> Craig Dyke wrote:
> > Howdy all
> > 
> > Can anyone tell me how and if possible to have a file
> > that I can let people read and write to but not delete from?
> > 
> > eg. file called hello has one line of text in it saying:
> > "Hello I am a file"
> > 
> > I want everyone to be able to read this file or add extra lines but not
> > delete
> > what is already there???
> > 
> > Craig
> > 
> > 
> >   
> 
> -- 
> 
> Nima Talebi
> Network Consultant
> 
> prusikloop
> eml: nima at it.net.au
> phn: +61 4 02911122
> fax: +61 8 93804354
> abn: 70 256 152 007
-- 
Andrew Pamment <pamment at iinet.net.au>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.plug.org.au/pipermail/plug/attachments/20030530/23793278/attachment.pgp>


More information about the plug mailing list