18.12.2012 Views

O'Reilly - Practical UNIX & Internet Sec... 7015KB

O'Reilly - Practical UNIX & Internet Sec... 7015KB

O'Reilly - Practical UNIX & Internet Sec... 7015KB

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

As the superuser, you might also want to sweep through the /tmp directory on a periodic basis and delete any files that are<br />

more than three or five days old:[9]<br />

[9] Beware that this command may be vulnerable to the filename attacks described in Chapter 11.<br />

# find /tmp -mtime +5 -print | xargs rm -rf<br />

This line is a simple addition to your crontab for nightly execution.<br />

25.2.5 Soft Process Limits: Preventing Accidental Denial of Service<br />

Most modern versions of <strong>UNIX</strong> allow you to set limits on the maximum amount of memory or CPU time a process can<br />

consume, as well as the maximum file size it can create. These limits are handy if you are developing a new program and do<br />

not want to accidentally make the machine very slow or unusable for other people with whom you're sharing.<br />

The Korn shell ulimit and C shell limit commands display the current process limits:<br />

$ ulimit -Sa -H for hard limits, -S for soft limits<br />

time(seconds) unlimited<br />

file(blocks) unlimited<br />

data(kbytes) 2097148 kbytes<br />

stack(kbytes) 8192 kbytes<br />

coredump(blocks) unlimited<br />

nofiles(descriptors) 64<br />

vmemory(kbytes) unlimited<br />

$<br />

These limits have the following meanings:<br />

time<br />

file<br />

[Chapter 25] 25.2 Overload Attacks<br />

data<br />

stack<br />

Maximum number of CPU seconds your process can consume.<br />

Maximum file size that your process can create, reported in 512-byte blocks.<br />

Maximum amount of memory for data space that your process can reference.<br />

Maximum stack your process can consume.<br />

coredump<br />

Maximum size of a core file that your process will write; setting this value to 0 prevents you from writing core files.<br />

nofiles<br />

Number of file descriptors (open files) that your process can have.<br />

vmemory<br />

Total amount of virtual memory your process can consume.<br />

You can also use the ulimit command to change a limit. For example, to prevent any future process you create from writing a<br />

data file longer than 5000 Kilobytes, execute the following command:<br />

$ ulimit -Sf 10000<br />

$ ulimit -Sa<br />

time(seconds) unlimited<br />

file(blocks) 10000<br />

data(kbytes) 2097148 kbytes<br />

stack(kbytes) 8192 kbytes<br />

file:///C|/Oreilly Unix etc/<strong>O'Reilly</strong> Reference Library/networking/puis/ch25_02.htm (10 of 11) [2002-04-12 10:44:54]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!