Friday, July 13, 2007

Re: [BLUG] Unix conventions for controlling file access

On Fri, Jul 13, 2007 at 04:16:50PM GMT, Dave Monnier REN-ISAC [dmonnier@ren-isac.net] said the following:
>
> So I wonder, how does this come into play with reserve blocks, quotas, etc?
> I wonder how much stuff depends on intact metadata.

Fortunately, it doesn't seem to be affected by it. At least in Linux
2.2.19 (machine I have access to that has quotas turned on):

Here is a program I quickly wrote in perl to do this:

-------------------------------------------------------------------------------
#!/usr/bin/perl -w

# This is a test to see if I can defeat quota limits by deleting a file
# with an open file handle.

open(FILE, ">/home/markk/largefile");

$i = 0;
$limit = 4600000;
while ($i < $limit) {
print FILE "0";
$i++;
}

sleep 10;
unlink('/home/markk/largefile');

sleep 300;
-------------------------------------------------------------------------------

$ ./test.pl &
[1] 2012
$ ls -l largefile
-rw-r--r-- 1 markk business 393216 Jul 13 13:42 largefile
$ ls -lh largefile
-rw-r--r-- 1 markk business 4.2M Jul 13 13:43 largefile
$ ls -lh largefile
-rw-r--r-- 1 markk business 4.4M Jul 13 13:43 largefile
$ quota -v
Disk quotas for user markk (uid 4505):
Filesystem blocks quota limit grace files quota limit
/dev/sdb1 4640 5000 5500 27 0 0
$ ls -lh largefile
ls: largefile: No such file or directory
$ quota -v
Disk quotas for user markk (uid 4505):
Filesystem blocks quota limit grace files quota limit
/dev/sdb1 4640 5000 5500 27 0 0
$ dd if=/dev/zero of=anotherfile bs=1M count=1000
/home: write failed, user disk quota exceeded too long.
/home: write
failed, user disk quota exceeded too long.
dd:
anotherfile: Disk quota exceeded
1+0 records in
0+0 records out

$ jobs
[1]+ Running ./test.pl &
$ kill %
[1]+ Terminated ./test.pl
$
$ quota -v
Disk quotas for user markk (uid 4505):
Filesystem blocks quota limit grace files quota limit
/dev/sdb1 472 5000 5500 27 0 0

I'm guessing that this also doesn't work in 2.6, but probably checking
is not a bad idea. It would be interesting if it did work and you could
somehow write a program that used FUSE to have a hidden filesystem
inside a deleted file that exceeded your quota.


--
Mark Krenz
Bloomington Linux Users Group
http://www.bloomingtonlinux.org/
_______________________________________________
BLUG mailing list
BLUG@linuxfan.com
http://mailman.cs.indiana.edu/mailman/listinfo/blug

No comments: