Merge from vendor branch BIND:
[dragonfly.git] / contrib / libpam / doc / pam_source.sgml
1 <!doctype linuxdoc system>
2
3 <!--
4
5  $Id: pam_source.sgml,v 1.5 1997/04/05 06:49:14 morgan Exp morgan $
6  $FreeBSD: src/contrib/libpam/doc/pam_source.sgml,v 1.1.1.1.6.2 2001/06/11 15:28:10 markm Exp $
7  $DragonFly: src/contrib/libpam/doc/Attic/pam_source.sgml,v 1.2 2003/06/17 04:24:02 dillon Exp $
8
9     Copyright (c) Andrew G. Morgan 1996,1997.  All rights reserved.
10
11 Redistribution and use in source (sgml) and binary (derived) forms,
12 with or without modification, are permitted provided that the
13 following conditions are met:
14
15 1. Redistributions of source code must retain the above copyright
16    notice, and the entire permission notice in its entirety,
17    including the disclaimer of warranties.
18
19 2. Redistributions in binary form must reproduce the above copyright
20    notice, this list of conditions and the following disclaimer in the
21    documentation and/or other materials provided with the distribution.
22
23 3. The name of the author may not be used to endorse or promote
24    products derived from this software without specific prior
25    written permission.
26
27 ALTERNATIVELY, this product may be distributed under the terms of the
28 GNU General Public License, in which case the provisions of the GNU
29 GPL are required INSTEAD OF the above restrictions.  (This clause is
30 necessary due to a potential bad interaction between the GNU GPL and
31 the restrictions contained in a BSD-style copyright.)
32
33 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
34 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
35 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
36 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
37 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
38 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
39 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
40 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
41 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
42 USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
43 DAMAGE.
44
45  -->
46
47 <article>
48
49 <title>The Linux-PAM System Administrators' Guide
50 <author>Andrew G. Morgan, <tt>morgan@linux.kernel.org</tt>
51 <date>DRAFT v0.59 1998/1/7
52 <abstract>
53 This manual documents what a system-administrator needs to know about
54 the <bf>Linux-PAM</bf> library. It covers the correct syntax of the
55 PAM configuration file and discusses strategies for maintaining a
56 secure system.
57 </abstract>
58
59 <!-- Table of contents -->
60 <toc>
61
62 <!-- Begin the document -->
63
64 <sect>Introduction
65
66 <p><bf/Linux-PAM/ (Pluggable Authentication Modules for Linux) is a
67 suite of shared libraries that enable the local system administrator
68 to choose how applications authenticate users.
69
70 <p>In other words, without (rewriting and) recompiling a PAM-aware
71 application, it is possible to switch between the authentication
72 mechanism(s) it uses. Indeed, one may entirely upgrade the local
73 authentication system without touching the applications themselves.
74
75 <p>Historically an application that has required a given user to be
76 authenticated, has had to be compiled to use a specific authentication
77 mechanism.  For example, in the case of traditional UN*X systems, the
78 identity of the user is verified by the user entering a correct
79 password.  This password, after being prefixed by a two character
80 ``salt'', is encrypted (with crypt(3)). The user is then authenticated
81 if this encrypted password is identical to the second field of the
82 user's entry in the system password database (the <tt>/etc/passwd</tt>
83 file).  On such systems, most if not all forms of privileges are
84 granted based on this single authentication scheme. Privilege comes in
85 the form of a personal user-identifier (<tt/uid/) and membership of
86 various groups. Services and applications are available based on the
87 personal and group identity of the user. Traditionally, group
88 membership has been assigned based on entries in the
89 <tt>/etc/group</tt> file.
90
91 <p>
92 Unfortunately, increases in the speed of computers and the
93 widespread introduction of network based computing, have made once
94 secure authentication mechanisms, such as this, vulnerable to
95 attack. In the light of such realities, new methods of authentication
96 are continuously being developed.
97
98 <p>
99 It is the purpose of the <bf/Linux-PAM/ project to separate the
100 development of privilege granting software from the development of
101 secure and appropriate authentication schemes.  This is accomplished
102 by providing a library of functions that an application may use to
103 request that a user be authenticated. This PAM library is configured
104 locally with a system file, <tt>/etc/pam.conf</tt> (or a series of
105 configuration files located in <tt>/etc/pam.d/</tt>) to authenticate a
106 user request via the locally available authentication modules. The
107 modules themselves will usually be located in the directory
108 <tt>/usr/lib/security</tt> and take the form of dynamically loadable
109 object files (see <tt/dlopen(3)/).
110
111 <sect>Some comments on the text<label id="text-conventions">
112
113 <p>
114 Before proceeding to read the rest of this document, it should be
115 noted that the text assumes that certain files are placed in certain
116 directories.  Where they have been specified, the conventions we adopt
117 here for locating these files are those of the relevant RFC (RFC-86.0,
118 see <ref id="see-also-sec" name="bibliography">).  If you are using a
119 distribution of Linux (or some other operating system) that supports
120 PAM but chooses to distribute these files in a diferent way (Red Hat
121 is one such distribution), you should be careful when copying examples
122 directly from the text.
123
124 <p>
125 As an example of the above, where it is explicit, the text assumes
126 that PAM loadable object files (the <em/modules/) are to be located in
127 the following directory: <tt>/usr/lib/security/</tt>. However, Red Hat
128 Linux, in agreement with the Linux File System Standard (the FSSTND),
129 places these files in <tt>/lib/security</tt>. Please be careful to
130 perform the necessary transcription when using the examples from the
131 text.
132
133 <sect>Overview<label id="overview-section">
134
135 <p>
136 For the uninitiated, we begin by considering an example.  We take an
137 application that grants some service to users; <em/login/ is one such
138 program. <em/Login/ does two things, it first establishes that the
139 requesting user is whom they claim to be and second provides them with
140 the requested service: in the case of <em/login/ the service is a
141 command shell (<em>bash, tcsh, zsh, etc.</em>) running with the
142 identity of the user.
143
144 <p>
145 Traditinally, the former step is achieved by the <em/login/
146 application prompting the user for a password and then verifying that
147 it agrees with that located on the system; hence verifying that the
148 so far as the system is concerned the user is who they claim to be.
149 This is the task that is delegated to <bf/Linux-PAM/.
150
151 <p>
152 From the perspective of the application programmer (in this case the
153 person that wrote the <em/login/ application), <bf/Linux-PAM/ takes
154 care of this authentication task -- verifying the identity of the user.
155
156 <p>
157 The flexibility of <bf/Linux-PAM/ is that <em/you/, the system
158 administrator, have the freedom to stipulate which authentication
159 scheme is to be used.  You have the freedom to set the scheme for
160 any/all PAM-aware applications on your Linux system.  That is, you can
161 authenticate from anything as naive as <em/simple trust/
162 (<tt/pam_permit/) to something as paranoid as a combination of a
163 retinal scan, a voice print and a one-time password!
164
165 <p>
166 To illustrate the flexibility you face, consider the following
167 situation: a system administrator (parent) wishes to improve the
168 mathematical ability of her users (children). She can configure their
169 favorite ``Shoot 'em up game'' (PAM-aware of course) to authenticate
170 them with a request for the product of a couple of random numbers less
171 than 12. It is clear that if the game is any good they will soon learn
172 their <em/multiplication tables/.   As they mature, the authentication
173 can be upgraded to include (long) division!
174
175 <p>
176 <bf/Linux-PAM/ deals with four separate types of (management)
177 task. These are: <em/authentication management/; <em/account
178 management/; <em/session management/; and <em/password management/.
179 The association of the preferred management scheme with the behavior
180 of an application is made with entries in the relevant <bf/Linux-PAM/
181 configuration file.  The management functions are performed by
182 <em/modules/ specified in the configuration file. The syntax for this
183 file is discussed in the section <ref id="configuration"
184 name="below">.
185
186 <p>
187 Here is a figure that describes the overall organization of
188 <bf/Linux-PAM/.
189 <tscreen>
190 <verb>
191          +----------------+
192          | application: X |
193          +----------------+       /  +----------+     +================+
194          | authentication-[---->--\--] Linux-   |--<--| PAM config file|
195          |       +        [----<--/--]   PAM    |     |================|
196          |[conversation()][--+    \  |          |     | X auth .. a.so |
197          +----------------+  |    /  +-n--n-----+     | X auth .. b.so |
198          |                |  |       __|  |           |           _____/
199          |  service user  |  A      |     |           |____,-----' 
200          |                |  |      V     A                        
201          +----------------+  +------|-----|---------+ -----+------+
202                                 +---u-----u----+    |      |      |
203                                 |   auth....   |--[ a ]--[ b ]--[ c ]
204                                 +--------------+
205                                 |   acct....   |--[ b ]--[ d ]
206                                 +--------------+
207                                 |   password   |--[ b ]--[ c ]
208                                 +--------------+
209                                 |   session    |--[ e ]--[ c ]
210                                 +--------------+
211 </verb>
212 </tscreen>
213 By way of explanation, the left of the figure represents the
214 application; application X.  Such an application interfaces with the
215 <bf/Linux-PAM/ library and knows none of the specifics of its
216 configured authentication method.  The <bf/Linux-PAM/ library (in the
217 center) consults the contents of the PAM configuration file and loads
218 the modules that are appropriate for application-X. These modules fall
219 into one of four management groups (lower-center) and are stacked in
220 the order they appear in the configuaration file. These modules, when
221 called by <bf/Linux-PAM/, perform the various authentication tasks for
222 the application. Textual information, required from/or offered to the
223 user, can be exchanged through the use of the application-supplied
224 <em/conversation/ function.
225
226 <sect>The Linux-PAM configuration file
227 <label id="configuration">
228
229 <p>
230 <bf/Linux-PAM/ is designed to provide the system administrator with a
231 great deal of flexibility in configuring the privilege granting
232 applications of their system. The local configuration of those aspects
233 of system security controlled by <tt/Linux-PAM/ is contained in one of
234 two places: either the single system file, <tt>/etc/pam.conf</tt>; or
235 the <tt>/etc/pam.d/</tt> directory.  In this section we discuss the
236 correct syntax of and generic options respected by entries to these
237 files.
238
239 <sect1>Configuration file syntax
240
241 <p>
242 The reader should note that the <bf/Linux-PAM/ specific tokens in this
243 file are case <em/insensitive/. The module paths, however, are case
244 sensitive since they indicate a file's <em/name/ and reflect the case
245 dependence of typical Linux file-systems. The case-sensitivity of the
246 arguments to any given module is defined for each module in turn.
247
248 <p>
249 In addition to the lines described below, there are two <em/special/
250 characters provided for the convenience of the system administrator:
251 comments are preceded by a `<tt/&num;/' and extend to the
252 next end-of-line; also, module specification lines may be extended
253 with a `<tt/&bsol;/' escaped newline.
254
255 <p>
256 A general configuration line of the <tt>/etc/pam.conf</tt> file has
257 the following form:
258 <tscreen>
259 <verb>
260 service-name   module-type   control-flag   module-path   arguments
261 </verb>
262 </tscreen>
263 Below, we explain the meaning of each of these tokens. The second (and
264 more recently adopted) way of configuring <bf/Linux-PAM/ is via the
265 contents of the <tt>/etc/pam.d/</tt> directory. Once we have explained
266 the meaning of the above tokens, we will describe this method.
267
268 <p>
269 <descrip>
270 <tag><tt/service-name/</tag>
271 The name of the service associated with this entry. Frequently the
272 service name is the conventional name of the given application. For
273 example, `<tt/ftpd/', `<tt/rlogind/' and `<tt/su/', <em/etc./ .
274
275 <p>
276 There is a special <tt/service-name/, reserved for defining a default
277 authentication mechanism. It has the name `<tt/OTHER/' and may be
278 specified in either lower or upper case characters. Note, when there
279 is a module specified for a named service, the `<tt/OTHER/' entries
280 are ignored.
281
282 <tag><tt/module-type/</tag>
283 One of (currently) four types of module. The four types are as
284 follows:
285 <itemize>
286 <item> <tt/auth/; this module type provides two aspects of
287 authenticating the user. Firstly, it establishes that the user is who
288 they claim to be, by instructing the application to prompt the user
289 for a password or other means of identification. Secondly, the module
290 can grant <tt/group/ membership (independently of the
291 <tt>/etc/groups</tt> file discussed above) or other privileges through
292 its <em/credential/ granting properties.
293
294 <item> <tt/account/; this module performs non-authentication based
295 account management. It is typically used to restrict/permit access to
296 a service based on the time of day, currently available system
297 resources (maximum number of users) or perhaps the location of the
298 applicant user---`<tt/root/' login only on the console.
299
300 <item> <tt/session/; primarily, this module is associated with doing
301 things that need to be done for the user before/after they can be
302 given service.  Such things include the logging of information
303 concerning the opening/closing of some data exchange with a user,
304 mounting directories, etc. .
305
306 <item> <tt/password/; this last module type is required for updating the
307 authentication token associated with the user. Typically, there is one
308 module for each `challenge/response' based authentication (<tt/auth/)
309 module-type.
310
311 </itemize>
312
313 <tag><tt/control-flag/</tag>
314
315 The control-flag is used to indicate how the PAM library will react to
316 the success or failure of the module it is associated with.  Since
317 modules can be <em/stacked/ (modules of the same type execute in
318 series, one after another), the control-flags determine the relative
319 importance of each module.  The application is not made aware of the
320 individual success or failure of modules listed in the
321 `<tt>/etc/pam.conf</tt>' file.  Instead, it receives a summary
322 <em/success/ or <em/fail/ response from the <bf/Linux-PAM/ library.
323 The order of execution of these modules is that of the entries in the
324 <tt>/etc/pam.conf</tt> file; earlier entries are executed before later
325 ones.  As of Linux-PAM v0.60, this <em/control-flag/ can be defined
326 with one of two syntaxes.
327
328 <p>
329 The simpler (and historical) syntax for the control-flag is a single
330 keyword defined to indicate the severity of concern associated with
331 the success or failure of a specific module.  There are four such
332 keywords: <tt/required/, <tt/requisite/, <tt/sufficient/ and
333 <tt/optional/.
334
335 <p>
336 The Linux-PAM library interprets these keywords in the following
337 manner:
338
339 <itemize>
340
341 <item> <tt/required/; this indicates that the success of the module is
342 required for the <tt/module-type/ facility to succeed. Failure of this
343 module will not be apparent to the user until all of the remaining
344 modules (of the same <tt/module-type/) have been executed.
345
346 <item> <tt/requisite/; like <tt/required/, however, in the case that
347 such a module returns a failure, control is directly returned to the
348 application.  The return value is that associated with the <em/first/
349 <tt/required/ or <tt/requisite/ module to fail.  Note, this flag can be
350 used to protect against the possibility of a user getting the
351 opportunity to enter a password over an unsafe medium.  It is
352 conceivable that such behavior might inform an attacker of valid
353 accounts on a system. This possibility should be weighed against the
354 not insignificant concerns of exposing a sensitive password in a
355 hostile environment.
356
357 <item> <tt/sufficient/; the success of this module is deemed
358 `<em/sufficient/' to satisfy the <bf/Linux-PAM/ library that this
359 module-type has succeeded in its purpose. In the event that no
360 previous <tt/required/ module has failed, no more `<em/stacked/'
361 modules of this type are invoked. (Note, in this case subsequent
362 <tt/required/ modules are <bf/not/ invoked.). A failure of this module
363 is not deemed as fatal to satisfying the application that this
364 <tt/module-type/ has succeeded.
365
366 <item> <tt/optional/; as its name suggests, this <tt/control-flag/
367 marks the module as not being critical to the success or failure of
368 the user's application for service. However, in the absence of any
369 successes of previous or subsequent stacked modules this module will
370 determine the nature of the response to the application.
371
372 </itemize>
373
374 <p>
375 The more elaborate (newer) syntax is much more specific and gives the
376 administrator a great deal of control over how the user is
377 authenticated.  This form of the control flag is delimeted with square
378 brackets and consists of a series of <tt/value=action/ tokens:
379 <tscreen>
380 <verb>
381     [value1=action1 value2=action2 ...]
382 </verb>
383 </tscreen>
384
385 <p>
386 Here, <tt/valueI/ is one of the following <em/return values/:
387 <tt/success/; <tt/open_err/; <tt/symbol_err/; <tt/service_err/;
388 <tt/system_err/; <tt/buf_err/; <tt/perm_denied/; <tt/auth_err/;
389 <tt/cred_insufficient/; <tt/authinfo_unavail/; <tt/user_unknown/;
390 <tt/maxtries/; <tt/new_authtok_reqd/; <tt/acct_expired/;
391 <tt/session_err/; <tt/cred_unavail/; <tt/cred_expired/; <tt/cred_err/;
392 <tt/no_module_data/; <tt/conv_err/; <tt/authtok_err/;
393 <tt/authtok_recover_err/; <tt/authtok_lock_busy/;
394 <tt/authtok_disable_aging/; <tt/try_again/; <tt/ignore/; <tt/abort/;
395 <tt/authtok_expired/; <tt/module_unknown/; <tt/bad_item/; and
396 <tt/default/.  The last of these (<tt/default/) can be used to set the
397 action for those return values that are not set explicitly.
398
399 <p>
400 The <tt/actionI/ can be a positive integer or one of the following
401 tokens: <tt/ignore/; <tt/ok/; <tt/done/; <tt/bad/; <tt/die/; and
402 <tt/reset/.  A positive integer, <tt/J/, when specified as the action
403 can be used to indicate that the next <em/J/ modules of the current
404 type will be skipped.  In this way, the administrator can develop a
405 moderately sophisticated stack of modules with a number of different
406 paths of execution.  Which path is taken can be determined by the
407 reactions of individual modules.
408
409 <p>
410 <bf>Note, at time of writing, this newer syntax is so new that I don't
411 want to write too much about it.  Please play with this.  Report all
412 the bugs and make suggestions for new actions (etc.).</bf>
413
414 <tag> <tt/module-path/</tag>
415
416 The path-name of the dynamically loadable object file; <em/the
417 pluggable module/ itself. If the first character of the module path is
418 `<tt>/</tt>', it is assumed to be a complete path. If this is not the
419 case, the given module path is appended to the default module path:
420 <tt>/usr/lib/security</tt> (but see the notes <ref
421 id="text-conventions" name="above">).
422
423 <tag> <tt/args/</tag>
424
425 The <tt/args/ are a list of tokens that are passed to the module when
426 it is invoked. Much like arguments to a typical Linux shell command.
427 Generally, valid arguments are optional and are specific to any given
428 module. Invalid arguments are ignored by a module, however, when
429 encountering an invalid argument, the module is required to write an
430 error to <tt/syslog(3)/. For a list of <em/generic/ options see the
431 next section.
432
433 </descrip>
434
435 <p>
436 Any line in (one of) the confiuration file(s), that is not formatted
437 correctly, will generally tend (erring on the side of caution) to make
438 the authentication process fail.  A corresponding error is written to
439 the system log files with a call to <tt/syslog(3)/.
440
441 <sect1>Directory based configuration
442
443 <p>
444 More flexible than the single configuration file, as of version 0.56,
445 it is possible to configure <tt>libpam</tt> via the contents of the
446 <tt>/etc/pam.d/</tt> directory.  In this case the directory is filled
447 with files each of which has a filename equal to a service-name (in
448 lower-case): it is the personal configuration file for the named
449 service.
450
451 <p>
452 <bf/Linux-PAM/ can be compiled in one of two modes.  The preferred
453 mode uses either <tt>/etc/pam.d/</tt> or <tt>/etc/pam.conf</tt>
454 configuration but not both.  That is to say, if there is a
455 <tt>/etc/pam.d/</tt> directory then libpam only uses the files
456 contained in this directory.  However, in the absence of the
457 <tt>/etc/pam.d/</tt> directory the <tt>/etc/pam.conf</tt> file is
458 used.  The other mode (and the one currently supported by Red Hat 4.2)
459 is to use both <tt>/etc/pam.d/</tt> and <tt>/etc/pam.conf</tt> in
460 sequence.  In this mode, entries in <tt>/etc/pam.d/</tt> override
461 those of <tt>/etc/pam.conf</tt>.
462
463 The syntax of each file in <tt>/etc/pam.d/</tt> is similar to that of
464 the <tt>/etc/pam.conf</tt> file and is made up of lines of the
465 following form:
466 <tscreen>
467 <verb>
468 module-type   control-flag   module-path   arguments
469 </verb>
470 </tscreen>
471 The only difference being that the <tt>service-name</tt> is not
472 present.   The service-name is of course the name of the given
473 configuration file.  For example, <tt>/etc/pam.d/login</tt> contains
474 the configuration for the <em>login</em> service.
475
476 <p>
477 This method of configuration has a number of advantages over the
478 single file approach. We list them here to assist the reader in
479 deciding which scheme to adopt:
480
481 <p>
482 <itemize>
483
484 <item>A lower chance of misconfiguring an application. There is one
485 less field to mis-type when editing the configuration files by hand.
486
487 <item>Easier to maintain. One application may be reconfigured without
488 risk of interfering with other applications on the system.
489
490 <item>It is possible to symbolically link different services
491 configuration files to a single file. This makes it easier to keep the
492 system policy for access consistent across different applications.
493 (It should be noted, to conserve space, it is equally possible to
494 <em>hard</em> link a number of configuration files.  However, care
495 should be taken when administering this arrangement as editing a hard
496 linked file is likely to break the link.)
497
498 <item>A potential for quicker configuration file parsing. Only the
499 relevant entries are parsed when a service gets bound to its modules.
500
501 <item>It is possible to limit read access to individual <bf/Linux-PAM/
502 configuration files using the file protections of the filesystem.
503
504 <item>Package management becomes simpler.  Every time a new
505 application is installed, it can be accompanied by an
506 <tt>/etc/pam.d/</tt><em>xxxxxx</em> file.
507
508 </itemize>
509
510 <sect1>Generic optional arguments
511
512 <p>
513 The following are optional arguments which are likely to be understood
514 by any module. Arguments (including these) are in general
515 <em/optional/.
516
517 <p>
518 <descrip>
519 <tag><tt/debug/</tag>
520
521 Use the <tt/syslog(3)/ call to log debugging information to the system
522 log files.
523
524 <tag> <tt/no_warn/</tag>
525
526 Instruct module to not give warning messages to the application.
527
528 <tag> <tt/use_first_pass/</tag>
529
530 The module should not prompt the user for a password. Instead, it
531 should obtain the previously typed password (from the preceding
532 <tt/auth/ module), and use that. If that doesn't work, then the user
533 will not be authenticated. (This option is intended for <tt/auth/
534 and <tt/password/ modules only).
535
536 <tag> <tt/try_first_pass/</tag>
537
538 The module should attempt authentication with the previously typed
539 password (from the preceding <tt/auth/ module). If that doesn't work,
540 then the user is prompted for a password. (This option is intended for
541 <tt/auth/ modules only).
542
543 <tag> <tt/use_mapped_pass/</tag>
544
545 This argument is not currently supported by any of the modules in the
546 <bf/Linux-PAM/ distribution because of possible consequences
547 associated with U.S. encryption exporting restrictions. Within the
548 U.S., module developers are, of course, free to implement it (as are
549 developers in other countries). For compatibility reasons we describe
550 its use as suggested in the <bf/DCE-RFC 86.0/, see section <ref
551 id="see-also-sec" name="bibliography"> for a pointer to this document.
552
553 <p>
554 The <tt/use_mapped_pass/ argument instructs the module to take the
555 clear text authentication token entered by a previous module (that
556 requests such a token) and use it to generate an encryption/decryption
557 key with which to safely store/retrieve the authentication token
558 required for this module. In this way the user can enter a single
559 authentication token and be quietly authenticated by a number of
560 stacked modules.  Obviously a convenient feature that necessarily
561 requires some reliably strong encryption to make it secure.
562 This argument is intended for the <tt/auth/ and <tt/password/ module
563 types only.
564
565 </descrip>
566
567 <sect1>Example configuration file entries
568
569 <p>
570 In this section, we give some examples of entries that can be present
571 in the <bf/Linux-PAM/ configuration file. As a first attempt at
572 configuring your system you could do worse than to implement these.
573
574 <sect2>Default policy
575
576 <p>
577 If a system is to be considered secure, it had better have a
578 reasonably secure `<tt/OTHER/' entry. The following is a paranoid
579 setting (which is not a bad place to start!):
580 <tscreen>
581 <verb>
582 #
583 # default; deny access
584 #
585 OTHER   auth     required       /usr/lib/security/pam_deny.so
586 OTHER   account  required       /usr/lib/security/pam_deny.so
587 OTHER   password required       /usr/lib/security/pam_deny.so
588 OTHER   session  required       /usr/lib/security/pam_deny.so
589 </verb>
590 </tscreen>
591 Whilst fundamentally a secure default, this is not very sympathetic to
592 a misconfigured system. For example, such a system is vulnerable to
593 locking everyone out should the rest of the file become badly written.
594
595 <p>
596 The module <tt/pam_deny/ (documented in a later section) is not very
597 sophisticated. For example, it logs no information when it is invoked
598 so unless the users of a system contact the administrator when failing
599 to execute a service application, the administrator may go for a long
600 while in ignorance of the fact that his system is misconfigured.
601
602 <p>
603 The addition of the following line before those in the above example
604 would provide a suitable warning to the administrator.
605 <tscreen>
606 <verb>
607 #
608 # default; wake up! This application is not configured
609 #
610 OTHER   auth     required       /usr/lib/security/pam_warn.so
611 OTHER   password required       /usr/lib/security/pam_warn.so
612 </verb>
613 </tscreen>
614 Having two ``<tt/OTHER auth/'' lines is an example of stacking.
615
616 <p>
617 On a system that uses the <tt>/etc/pam.d/</tt> configuration, the
618 corresponding default setup would be achieved with the following file:
619 <tscreen>
620 <verb>
621 #
622 # default configuration: /etc/pam.d/other
623 #
624 auth     required       /usr/lib/security/pam_warn.so
625 auth     required       /usr/lib/security/pam_deny.so
626 account  required       /usr/lib/security/pam_deny.so
627 password required       /usr/lib/security/pam_warn.so
628 password required       /usr/lib/security/pam_deny.so
629 session  required       /usr/lib/security/pam_deny.so
630 </verb>
631 </tscreen>
632 This is the only explicit example we give for an <tt>/etc/pam.d/</tt>
633 file. In general, it should be clear how to transpose the remaining
634 examples to this configuration scheme.
635
636 <p>
637 On a less sensitive computer, one on which the system administrator
638 wishes to remain ignorant of much of the power of <tt/Linux-PAM/, the
639 following selection of lines (in <tt>/etc/pam.conf</tt>) is likely to
640 mimic the historically familiar Linux setup.
641 <tscreen>
642 <verb>
643 #
644 # default; standard UNIX access
645 #
646 OTHER   auth     required       /usr/lib/security/pam_unix_auth.so
647 OTHER   account  required       /usr/lib/security/pam_unix_acct.so
648 OTHER   password required       /usr/lib/security/pam_unix_passwd.so
649 OTHER   session  required       /usr/lib/security/pam_unix_session.so
650 </verb>
651 </tscreen>
652 In general this will provide a starting place for most applications.
653 Unfortunately, most is not all. One application that might require
654 additional lines is <em/ftpd/ if you wish to enable
655 <em/anonymous-ftp/.
656
657 <p>
658 To enable anonymous-ftp, the following lines might be used to replace
659 the default (<tt/OTHER/) ones. (<bf/*WARNING*/ as of 1996/12/28 this
660 does not work correctly with any ftpd. Consequently, this description
661 may be subject to change or the application will be fixed.)
662 <tscreen>
663 <verb>
664 #
665 # ftpd; add ftp-specifics. These lines enable anonymous ftp over
666 #       standard UNIX access (the listfile entry blocks access to
667 #       users listed in /etc/ftpusers)
668 #
669 ftpd    auth    sufficient  /usr/lib/security/pam_ftp.so
670 ftpd    auth    required    /usr/lib/security/pam_unix_auth.so use_first_pass
671 ftpd    auth    required    /usr/lib/security/pam_listfile.so \
672                         onerr=succeed item=user sense=deny file=/etc/ftpusers
673 </verb>
674 </tscreen>
675 Note, the second line is necessary since the default entries are
676 ignored by a service application (here <em/ftpd/) if there are
677 <em/any/ entries in <tt>/etc/pam.conf</tt> for that specified service.
678 Again, this is an example of authentication module stacking.  Note the
679 use of the <tt/sufficient/ control-flag. It says that ``if this module
680 authenticates the user, ignore the subsequent <tt/auth/
681 modules''. Also note the use of the ``<tt/use_first_pass/''
682 module-argument, this instructs the UNIX authentication module that it
683 is not to prompt for a password but rely one already having been
684 obtained by the ftp module.
685
686 <p>
687 The standard UNIX modules, used above, are strongly tied to using the
688 default `<tt/libc/' user database functions (see for example, <tt/man
689 getpwent/).  It is the opinion of the author that these functions are
690 not sufficently flexible to make full use of the power of
691 <bf/Linux-PAM/.  For this reason, and as a small plug, I mention in
692 passing that there is a pluggable replacement for the <tt/pam_unix_../
693 modules; <tt/pam_pwdb/. See the section below for a more complete
694 description.
695
696
697 <sect>Security issues of Linux-PAM
698
699 <p>
700 This section will discuss good practices for using Linux-PAM in a
701 secure manner.  <em>It is currently sadly lacking...suggestions are
702 welcome!</em>
703
704 <sect1>If something goes wrong
705
706 <p>
707 <bf/Linux-PAM/ has the potential to seriously change the security of
708 your system.  You can choose to have no security or absolute security
709 (no access permitted).  In general, <bf/Linux-PAM/ errs towards the
710 latter.  Any number of configuration errors can dissable access to
711 your system partially, or completely.
712
713 <p>
714 The most dramatic problem that is likely to be encountered when
715 configuring <bf/Linux-PAM/ is that of <em>deleting</em> the
716 configuration file(s): <tt>/etc/pam.d/*</tt> and/or
717 <tt>/etc/pam.conf</tt>.  This will lock you out of your own system!
718
719 <p>
720 To recover, your best bet is to reboot the system in single user mode
721 and set about correcting things from there.  The following has been
722 <em>adapted</em> from a life-saving email on the subject from David
723 Wood:
724 <verb>
725 > What the hell do I do now?
726
727 OK, don't panic. The first thing you have to realize is that
728 this happens to 50% of users who ever do anything with PAM.
729 It happened here, not once, not twice, but three times, all
730 different, and in the end, the solution was the same every
731 time.
732
733 First, I hope you installed LILO with a delay. If you can,
734 reboot, hit shift or tab or something and type:
735
736     LILO boot: linux single
737
738 (Replace 'linux' with 'name-of-your-normal-linux-image').
739 This will let you in without logging in.  Ever wondered how
740 easy it is to break into a linux machine from the console?
741 Now you know.
742
743 If you can't do that, then get yourself a bootkernel floppy
744 and a root disk a-la slackware's rescue.gz.  (Red Hat's
745 installation disks can be used in this mode too.)
746
747 In either case, the point is to get back your root prompt.
748
749 Second, I'm going to assume that you haven't completely
750 nuked your pam installation - just your configuration files.
751 Here's how you make your configs nice again:
752
753     cd /etc
754     mv pam.conf pam.conf.orig
755     mv pam.d pam.d.orig
756     mkdir pam.d
757     cd pam.d
758
759 and then use vi to create a file called "other" in this
760 directory.  It should contain the following four lines:
761
762     auth     required       pam_unix_auth.so
763     account  required       pam_unix_acct.so
764     password required       pam_unix_passwd.so
765     session  required       pam_unix_session.so
766
767 Now you have the simplest possible PAM configuration that
768 will work the way you're used to.  Everything should
769 magically start to work again.  Try it out by hitting ALT-F2
770 and logging in on another virtual console.  If it doesn't
771 work, you have bigger problems, or you've mistyped
772 something.  One of the wonders of this system (seriously,
773 perhaps) is that if you mistype anything in the conf files,
774 you usually get no error reporting of any kind on the
775 console - just some entries in the log file.  So look there!
776 (Try 'tail /var/log/messages'.)
777
778 From here you can go back and get a real configuration
779 going, hopefully after you've tested it first on a machine
780 you don't care about screwing up.  :/
781
782 Some pointers (to make everything "right" with Red Hat...):
783
784     Install the newest pam, pamconfig, and pwdb from the
785     redhat current directory, and do it all on the same
786     command line with rpm...
787
788         rpm -Uvh [maybe --force too] pam-* pamconfig-* pwdb-*
789
790     Then make sure you install (or reinstall) the newest
791     version of libc, util-linux, wuftp, and NetKit. For
792     kicks you might try installing the newest versions of
793     the affected x apps, like xlock, but I haven't gotten
794     those to work at all yet.
795
796 </verb>
797
798 <sect1>Avoid having a weak `other' configuration
799
800 <p>
801 It is not a good thing to have a weak default (<tt/OTHER/) entry.
802 This service is the default configuration for all PAM aware
803 applications and if it is weak, your system is likely to be vulnerable
804 to attack.
805
806 <sect>A reference guide for available modules
807
808 <p>
809 Here, we collect together some descriptions of the various modules
810 available for <bf/Linux-PAM/.  In general these modules should be
811 freely available.  Where this is not the case, it will be indicated.
812
813 <p>
814 Also please note the comments contained in the section <ref 
815 id="text-conventions" name="on text conventions above"> when copying
816 the examples listed below.
817
818 <!-- insert-file MODULES-SGML -->
819
820 <sect>Files
821
822 <p><descrip>
823
824 <tag><tt>/usr/lib/libpam.so.*</tt></tag>
825
826 the shared library providing applications with access to
827 <bf/Linux-PAM/.
828
829 <tag><tt>/etc/pam.conf</tt></tag>
830
831 the <bf/Linux-PAM/ configuration file.
832
833 <tag><tt>/usr/lib/security/pam_*.so</tt></tag>
834
835 the primary location for <bf/Linux-PAM/ dynamically loadable object
836 files; the modules.
837
838 </descrip>
839
840 <sect>See also<label id="see-also-sec">
841
842 <p><itemize>
843
844 <item>The <bf/Linux-PAM/ Application Writers' Guide.
845
846 <item>The <bf/Linux-PAM/ Module Writers' Guide.
847
848 <item>The V. Samar and R. Schemers (SunSoft), ``UNIFIED LOGIN WITH
849 PLUGGABLE AUTHENTICATION MODULES'', Open Software Foundation Request
850 For Comments 86.0, October 1995. See this url:
851 <tt><htmlurl
852 url="http://www.pilgrim.umass.edu/pub/osf_dce/RFC/rfc86.0.txt"
853 name="http://www.pilgrim.umass.edu/pub/osf&lowbar;dce/RFC/rfc86.0.txt"></tt>
854
855 </itemize>
856
857 <sect>Notes
858
859 <p>
860 I intend to put development comments here... like ``at the moment
861 this isn't actually supported''. At release time what ever is in
862 this section will be placed in the Bugs section below! :)
863
864 <p>
865 Are we going to be able to support the <tt/use_mapped_pass/ module
866 argument? Anyone know a cheap (free) good lawyer?!
867
868 <p>
869 <itemize>
870 <item>
871 This issue may go away, as Sun have investigated adding a new
872 management group for mappings. In this way, libpam would have mapping
873 modules that could securely store passwords using strong cryptography
874 and in such a way that they need not be distributed with Linux-PAM.
875 </itemize>
876
877 <sect>Author/acknowledgments
878
879 <p>
880 This document was written by Andrew G. Morgan (morgan@parc.power.net)
881 with many contributions from
882 <!-- insert credits here -->
883 <!--
884  an sgml list of people to credit for their contributions to Linux-PAM
885  $Id: pam_source.sgml,v 1.5 1997/04/05 06:49:14 morgan Exp morgan $
886   -->
887 Craig S. Bell,
888 Derrick J. Brashear,
889 Ben Buxton,
890 Oliver Crow,
891 Marc Ewing,
892 Cristian Gafton,
893 Eric Hester,
894 Eric Jacksch,
895 Michael K. Johnson,
896 David Kinchlea,
897 Elliot Lee,
898 Al Longyear,
899 Marek Michalkiewicz,
900 Aleph One,
901 Sean Reifschneider,
902 Eric Troan,
903 Theodore Ts'o,
904 Jeff Uphoff,
905 Ronald Wahl,
906 John Wilmes,
907 Joseph S. D. Yao
908 and
909 Alex O.  Yuriev.
910
911
912 <p>
913 Thanks are also due to Sun Microsystems, especially to Vipin Samar and
914 Charlie Lai for their advice. At an early stage in the development of
915 <bf/Linux-PAM/, Sun graciously made the documentation for their
916 implementation of PAM available. This act greatly accelerated the
917 development of <bf/Linux-PAM/.
918
919 <sect>Bugs/omissions
920
921 <p>
922 More PAM modules are being developed all the time. It is unlikely that
923 this document will ever be truely up to date!
924
925 <p>
926 Currently there is no documentation for PAM-aware applications.
927
928 <p>
929 This manual is unfinished. Only a partial list of people is credited
930 for all the good work they have done.
931
932 <sect>Copyright information for this document
933
934 <p>
935 Copyright (c) Andrew G. Morgan 1996.  All rights reserved.
936 <newline>
937 Email: <tt>&lt;morgan@parc.power.net&gt;</tt>
938
939 <p>
940 Redistribution and use in source and binary forms, with or without
941 modification, are permitted provided that the following conditions are
942 met:
943
944 <p>
945 <itemize>
946
947 <item>
948 1. Redistributions of source code must retain the above copyright
949    notice, and the entire permission notice in its entirety,
950    including the disclaimer of warranties.
951
952 <item>
953 2. Redistributions in binary form must reproduce the above copyright
954    notice, this list of conditions and the following disclaimer in the
955    documentation and/or other materials provided with the distribution.
956
957 <item>
958 3. The name of the author may not be used to endorse or promote
959    products derived from this software without specific prior
960    written permission.
961
962 </itemize>
963
964 <p>
965 <bf/Alternatively/, this product may be distributed under the terms of
966 the GNU General Public License (GPL), in which case the provisions of
967 the GNU GPL are required <bf/instead of/ the above restrictions.
968 (This clause is necessary due to a potential bad interaction between
969 the GNU GPL and the restrictions contained in a BSD-style copyright.)
970
971 <p>
972 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
973 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
974 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
975 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
976 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
977 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
978 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
979 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
980 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
981 USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
982 DAMAGE.
983
984 <p>
985 <tt>$Id: pam_source.sgml,v 1.5 1997/04/05 06:49:14 morgan Exp morgan $</tt>
986
987 </article>