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