<?xml version="1.0" encoding="UTF-8"?>
<!--RSS generated by Flaimo.com RSS Builder [2009-12-07 13:21:52]-->
<rss version="2.0"><channel><docs>http://bank.mylivepage.com</docs><link>http://bank.mylivepage.com</link><description>Bank Focus :: MyLivePage</description><title>Bank Focus</title><image><title>Bank Focus</title><url>http://common.mylivepage.net/global/avatar_social.png</url><link>http://bank.mylivepage.com</link><description>Bank Focus :: MyLivePage</description></image><category>Other</category><ttl>60</ttl><item><title>SECURITY Limit User Processes</title><link>http://bank.mylivepage.com/blog/5/6/SECURITY%20Limit%20User%20Processes</link><description>&lt;p&gt;&lt;a href="http://bank.mylivepage.com/page/fr%3AS%C3%89CURIT%C3%89_Limiter_les_processus_utilisateur"&gt;fr:SÉCURITÉ Limiter les processus utilisateur&lt;/a&gt;&#13;
{{SECURITY Index}}&#13;
&lt;a name=wiki_anchor&gt;&lt;/a&gt;&lt;h2&gt;Introduction&lt;/h2&gt;&#13;
&lt;p&gt;Limiting user processes is one way to make sure that one user can not "commandeer" the system making it unusable for others.  To limit the processes a user on your system can we have two files to edit&#13;
&lt;dl&gt;&lt;dt&gt; /etc/limits &lt;/dt&gt;&lt;dd&gt; owned by the sys-apps/shadow package&#13;
&lt;/dd&gt;&lt;dt&gt; /etc/security/limits.conf : owned the the sys-libs/pam package : This only affects programs affected by PAM, so the pam USE flag should be set.&#13;
&lt;/dt&gt;&lt;/dl&gt;
&lt;a name=wiki_anchor1&gt;&lt;/a&gt;&lt;h2&gt;/etc/limits&lt;/h2&gt;&#13;
&lt;a name=wiki_anchor2&gt;&lt;/a&gt;&lt;h3&gt;File format&lt;/h3&gt;&#13;
&lt;p&gt;Each line consists of username followed by a limit string. The limit string describes limits for particular user. The options are:&#13;
&lt;ul&gt;&lt;li&gt; A: max address space (KB)&#13;
&lt;/li&gt;&lt;li&gt; C: max core file size (KB)&#13;
&lt;/li&gt;&lt;li&gt; D: max data size (KB)&#13;
&lt;/li&gt;&lt;li&gt; F: maximum filesize (KB)&#13;
&lt;/li&gt;&lt;li&gt; M: max locked-in-memory address space (KB)&#13;
&lt;/li&gt;&lt;li&gt; N: max number of open files&#13;
&lt;/li&gt;&lt;li&gt; R: max resident set size (KB)&#13;
&lt;/li&gt;&lt;li&gt; S: max stack size (KB)&#13;
&lt;/li&gt;&lt;li&gt; T: max CPU time (MIN)&#13;
&lt;/li&gt;&lt;li&gt; U: max number of processes&#13;
&lt;/li&gt;&lt;li&gt; L: max number of logins for this user&#13;
&lt;/li&gt;&lt;li&gt;  : file creation mask, set by umask&#13;
&lt;/li&gt;&lt;li&gt;  : process priority, set by setpriority&#13;
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=wiki_anchor3&gt;&lt;/a&gt;&lt;h3&gt;Example&lt;/h3&gt;&#13;
&lt;p&gt;{{Box File| /etc/limits |&#13;
&lt;pre&gt;&#13;
# This will limit all users to 40 processes max.  This can be used to prevent a "fork bomb".&#13;
# Be warned, if the user logs into a Desktop Environment like GNOME or KDE, &#13;
#   this could cause problems due to how many processes they launch.&#13;
* U 40&#13;
&#13;
# Limit fred to logging in no more than twice.  NOTE:  This does not affect virtual terminals for some reason.&#13;
fred L 2&#13;
&lt;/pre&gt;&#13;
&lt;p&gt;}}&#13;
&lt;a name=wiki_anchor4&gt;&lt;/a&gt;&lt;h2&gt;/etc/security/limits.conf&lt;/h2&gt;&#13;
&lt;p&gt;Most people prefer to edit this file because its more readable and offers more flexibility.  This file can also enforce both hard and soft limits.  Soft limits can be exceeded, and will usually issue a warning of some kind.  Hard limits can not.  Also, unlike the other limits file, limits.conf can match groups.  To match a group, preceed the group name with a "@".  &#13;
&lt;a name=wiki_anchor5&gt;&lt;/a&gt;&lt;h3&gt;File Format&lt;/h3&gt;&#13;
&lt;p&gt;&lt;br /&gt;&#13;
 can be:&#13;
&lt;ol&gt;&lt;li&gt;an user name&#13;
&lt;/li&gt;&lt;li&gt;a group name, with @group syntax&#13;
&lt;/li&gt;&lt;li&gt;the wildcard *, for default entry&#13;
&lt;/li&gt;&lt;li&gt;the wildcard %, can be also used with %group syntax,&#13;
&lt;/li&gt;&lt;/ol&gt;
for maxlogin limit&#13;
&lt;/p&gt;&lt;p&gt; can have the two values:&#13;
&lt;ol&gt;&lt;li&gt;"soft" for enforcing the soft limits&#13;
&lt;/li&gt;&lt;li&gt;"hard" for enforcing hard limits&#13;
&lt;/li&gt;&lt;/ol&gt;
&lt;/p&gt;&lt;p&gt; can be one of the following:&#13;
&lt;ol&gt;&lt;li&gt;core - limits the core file size (KB)&#13;
&lt;/li&gt;&lt;li&gt;data - max data size (KB)&#13;
&lt;/li&gt;&lt;li&gt;fsize - maximum filesize (KB)&#13;
&lt;/li&gt;&lt;li&gt;memlock - max locked-in-memory address space (KB)&#13;
&lt;/li&gt;&lt;li&gt;nofile - max number of open files&#13;
&lt;/li&gt;&lt;li&gt;rss - max resident set size (KB)&#13;
&lt;/li&gt;&lt;li&gt;stack - max stack size (KB)&#13;
&lt;/li&gt;&lt;li&gt;cpu - max CPU time (MIN)&#13;
&lt;/li&gt;&lt;li&gt;nproc - max number of processes&#13;
&lt;/li&gt;&lt;li&gt;as - address space limit&#13;
&lt;/li&gt;&lt;li&gt;maxlogins - max number of logins for this user&#13;
&lt;/li&gt;&lt;li&gt;priority - the priority to run user process with&#13;
&lt;/li&gt;&lt;li&gt;locks - max number of file locks the user can hold&#13;
&lt;/li&gt;&lt;/ol&gt;
&lt;a name=wiki_anchor6&gt;&lt;/a&gt;&lt;h3&gt;Example&lt;/h3&gt;&#13;
&lt;p&gt;{{Box File| /etc/security/limits.conf |&#13;
&lt;pre&gt;&#13;
# Prevents anyone from dumping core files.&#13;
*               hard    core   0&#13;
&#13;
# This will prevent anyone in the 'users' group from having more than 150 processes, and a warning will be given at 100 processes.&#13;
@users          soft    nproc  100&#13;
@users          hard    nproc  150&#13;
&#13;
&lt;/pre&gt;&#13;
&lt;p&gt;}}&#13;
&lt;a name=wiki_anchor7&gt;&lt;/a&gt;&lt;h2&gt;Testing&lt;/h2&gt;&#13;
&lt;p&gt;To check, if you are protected. You can run this cute little forkbomb:&#13;
&lt;pre&gt;&#13;
:(){ :|:&amp; };:&#13;
&lt;/pre&gt;&#13;
&lt;p&gt;Be warned that this might lock-up your system, so you'd better be close to the reset-button just in case something went wrong. Of course you should close all applications which might not like a sudden termination.&#13;
&lt;/p&gt;&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;</description><category>General</category><pubDate>24 Jan 06 16:59:09 GMT</pubDate><guid>http://bank.mylivepage.com/blog/5/6/SECURITY%20Limit%20User%20Processes</guid></item></channel></rss>
