summaryrefslogtreecommitdiff
path: root/doc/modules/pam_limits.sgml
blob: 3678376a654163771918b32d0d498eeee0f0d692 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<!--
   $Id$
   
   This file was written by Andrew G. Morgan <morgan@kernel.org>
   from information compiled by Cristian Gafton (author of module)
-->

<sect1>The resource limits module

<sect2>Synopsis

<p>
<descrip>

<tag><bf>Module Name:</bf></tag>
<tt/pam_limits/

<tag><bf>Authors:</bf></tag>
Cristian Gafton &lt;gafton@redhat.com&gt; <newline>
Thanks are also due to Elliot Lee &lt;sopwith@redhat.com&gt;
for his comments on improving this module.

<tag><bf>Maintainer:</bf></tag>
Cristian Gafton - 1996/11/20

<tag><bf>Management groups provided:</bf></tag>
session

<tag><bf>Cryptographically sensitive:</bf></tag>
	
<tag><bf>Security rating:</bf></tag>

<tag><bf>Clean code base:</bf></tag>

<tag><bf>System dependencies:</bf></tag>
requires an <tt>/etc/security/limits.conf</tt> file and kernel support
for resource limits.

<tag><bf>Network aware:</bf></tag>

</descrip>

<sect2>Overview of module

<p>
This module, through the <bf/Linux-PAM/ <em/open/-session hook, sets
limits on the system resources that can be obtained in a
user-session. Its actions are dictated more explicitly through the
configuration file discussed below.

<sect2>Session component

<p>
<descrip>

<tag><bf>Recognized arguments:</bf></tag>
<tt/debug/; <tt>conf=/path/to/file.conf</tt>; <tt>change_uid</tt>;
<tt>utmp_early</tt>

<tag><bf>Description:</bf></tag>

Through the contents of the configuration file,
<tt>/etc/security/limits.conf</tt>, resource limits are placed on
users' sessions. Users of <tt/uid=0/ are not affected by this
restriction.

<p>
The behavior of this module can be modified with the following
arguments:
<itemize>

<item><tt/debug/ -
verbose logging to <tt/syslog(3)/.

<item><tt>conf=/path/to/file.conf</tt> -
indicate an alternative <em/limits/ configuration file to the default.

<item><tt/change_uid/ - 
change real uid to the user for who the limits are set up.  Use this
option if you have problems like login not forking a shell for user
who has no processes. Be warned that something else may break when
you do this.

<item><tt/utmp_early/ - 
some broken applications actually allocate a utmp entry for the user
before the user is admitted to the system. If some of the services you
are configuring PAM for do this, you can selectively use this module
argument to compensate for this behavior and at the same time maintain
system-wide consistency with a single limits.conf file.

</itemize>

<tag><bf>Examples/suggested usage:</bf></tag>

In order to use this module the system administrator must first create
a <em/root-only-readable/ file (default is
<tt>/etc/security/limits.conf</tt>).  This file describes the resource
limits the superuser wishes to impose on users and groups. No limits
are imposed on <tt/uid=0/ accounts.

<p>
Each line of the configuration file describes a limit for a user in
the form:
<tscreen>
<verb>
<domain>	<type>	<item>		<value>
</verb>
</tscreen>

<p>
The fields listed above should be filled as follows...<newline>
<tt>&lt;domain&gt;</tt> can be:
<itemize>
<item> a username
<item> a groupname, with <tt>@group</tt> syntax
<item> the wild-card <tt/*/, for default entry
<item> the wild-card <tt/%/, for maxlogins limit only,
can also be used with <tt>%group</tt> syntax
</itemize>

<p>
<tt>&lt;type&gt;</tt> can have the three values:
<itemize>

<item> <tt/hard/ for enforcing <em/hard/ resource limits. These limits
are set by the superuser and enforced by the Linux Kernel. The user
cannot raise his requirement of system resources above such values.

<item> <tt/soft/ for enforcing <em/soft/ resource limits. These limits
are ones that the user can move up or down within the permitted range
by any pre-exisiting <em/hard/ limits. The values specified with this
token can be thought of as <em/default/ values, for normal system
usage.

<item> <tt/-/ for enforcing both <em/soft/ and <em/hard/ limits
together.

</itemize>

<p>
<tt>&lt;item&gt;</tt> can be one of the following:
<itemize>
<item><tt/core/ - limits the core file size (KB)
<item><tt/data/ - max data size (KB)
<item><tt/fsize/ - maximum filesize (KB)
<item><tt/memlock/ - max locked-in-memory address space (KB)
<item><tt/nofile/ - max number of open files
<item><tt/rss/ - max resident set size (KB)
<item><tt/stack/ - max stack size (KB)
<item><tt/cpu/ - max CPU time (MIN)
<item><tt/nproc/ - max number of processes
<item><tt/as/ - address space limit
<item><tt/maxlogins/ - max number of logins for this user
<item><tt/maxsyslogins/ - max number of logins on system
<item><tt/priority/ - the priority to run user process with (negative
values boost process priority)
<item><tt/locks/ - max locked files (Linux 2.4 and higher)
</itemize>

<p>
Note, if you specify a type of ``-'' but neglect to supply the
<tt/item/ and <tt/value/ fields then the module will never enforce any
limits on the corresponding user/group-members etc. . Note, the first
entry of the form which applies to the authenticating user will
override all other entries in the limits configuration file. In such
cases, the <tt/pam_limits/ module will always return <tt/PAM_SUCCESS/.

<p>
In general, individual limits have priority over group limits, so if
you impose no limits for <tt/admin/ group, but one of the members in
this group have a limits line, the user will have its limits set
according to this line.

<p>
Also, please note that all limit settings are set <em/per login/.
They are not global, nor are they permanent; existing only for the
duration of the session.

<p>
In the <em/limits/ configuration file, the ``<tt/#/'' character
introduces a comment - after which the rest of the line is ignored.

<p>
The <tt/pam_limits/ module does its best to report configuration
problems found in its configuration file via <tt/syslog(3)/.

<p>
The following is an example configuration file:
<tscreen>
<verb>
# EXAMPLE /etc/security/limits.conf file:
# =======================================
# <domain>	<type>	<item>		<value>
*               soft    core            0
*               hard    rss             10000
@student        hard    nproc           20
@faculty        soft    nproc           20
@faculty        hard    nproc           50
ftp             hard    nproc           0
@student        -       maxlogins       4
</verb>
</tscreen>
Note, the use of <tt/soft/ and <tt/hard/ limits for the same resource
(see <tt/@faculty/) -- this establishes the <em/default/ and permitted
<em/extreme/ level of resources that the user can obtain in a given
service-session.

<p>
Note, that wild-cards <tt/*/ and <tt/%/ have the following meaning when
used for maxlogins limit
<itemize>
<item> <tt/*/ every user
<item> <tt/%/ all users, or entire group when <tt>%group</tt> is specified 
</itemize>
See the following examples:
<tscreen>
<verb>
# EXAMPLE /etc/security/limits.conf file:
# <domain>	<type>	<item>		<value>
*               -       maxlogins       2
@faculty        -       maxlogins       4
%               -       maxlogins       30
%student        -       maxlogins       10
</verb>
</tscreen>
Explanation: every user can login 2 times, members of the <tt/faculty/
group can login 4 times, there can be only 30 logins, only 10 from
<tt/students/ group.

<p>
For the services that need resources limits (login for example) put
the following line in <tt>/etc/pam.conf</tt> as the last line for that
service (usually after the pam_unix session line:
<tscreen>
<verb>
#
# Resource limits imposed on login sessions via pam_limits
#
login   session    required     pam_limits.so
</verb>
</tscreen>

</descrip>

<!--
End of sgml insert for this module.
-->