4. The Linux-PAM configuration file

Contents of this section

Linux-PAM is designed to provide the system administrator with a great deal of flexibility in configuring the privilege granting applications of their system. The local configuration of those aspects of system security controlled by Linux-PAM is contained in the system file, /etc/pam.conf. In this section we discuss the correct syntax of and generic options respected by entries to this file.

4.1 Configuration file syntax

The reader should note that the Linux-PAM specific tokens in this file are case insensitive. The module paths, however, are case sensitive since they indicate a file's name and reflect the case dependence of typical Linux file-systems. The case-sensitivity of the arguments to any given module is defined for each module in turn.

In addition to the lines described below, there are two special characters provided for the convenience of the system administrator: comments are preceded by a `#' and extend to the next end-of-line; also, module specification lines may be extended with a `\'.

A general configuration line of the /etc/pam.conf file has the following form:

service-name   module-type   control-flag   module-path   arguments
Here we explain the meaning of each of these tokens.

service-name

The name of the service associated with this entry. Frequently the service name is the conventional name of the given application. For example, `ftpd', `rlogind' and `su', etc. .

There is a special service-name, reserved for defining a default authentication mechanism. It has the name `OTHER' and may be specified in either lower or upper case characters. Note, when there is a module specified for a named service, the `OTHER' entries are ignored.

module-type

One of (currently) four types of module. The four types are as follows:

control-flag

One of (currently) four tokens that indicate the severity of concern associated with the success or failure of a given module. Linux-PAM provides for the stacking of similar modules, providing a method of sequentially exposing the user to more than one authentication mechanism per service application. The application is not made aware of the individual success or failure of modules listed in the `/etc/pam.conf' file. Instead, it receives a summary success or fail response from the Linux-PAM library. The order of execution of these modules is that of the entries in the /etc/pam.conf file; earlier entries are executed before later ones.

The policy for determining this response is based on these three control-flags:

module-path

The path-name of the dynamically loadable object file; the pluggable module itself.

args

The args are a list of tokens that are passed to the module when it is invoked. Much like arguments to a typical Linux shell command. Generally, valid arguments are optional and are specific to any given module. Invalid arguments are ignored by a module, however, when encountering an invalid argument, the module is required to write an error to syslog(3). For a list of generic options see the next section.

Any line, in /etc/pam.conf, that is not formatted correctly is ignored by Linux-PAM; however, a corresponding error is written to the system log files with a call to syslog(3).

4.2 Generic optional arguments

The following are optional arguments which are likely to be understood by any module. Arguments (including these) are in general optional.

debug

Use the syslog(3) call to log debugging information to the system log files.

no_warn

Instruct module to not give warning messages to the application.

use_first_pass

The module should not prompt the user for a password. Instead, it should obtain the previously typed password (from the preceding auth module), and use that. If that doesn't work, then the user will not be authenticated. (This option is intended for auth and password modules only).

try_first_pass

The module should attempt authentication with the previously typed password (from the preceding auth module). If that doesn't work, then the user is prompted for a password. (This option is intended for auth modules only).

use_mapped_pass

This argument is not currently supported by any of the modules in the Linux-PAM distribution because of possible consequences associated with U.S. encryption exporting restrictions. Within the U.S., module developers are, of course, free to implement it (as are developers in other countries). For compatibility reasons we describe its use as suggested in the DCE-RFC 86.0, see section bibliography for a pointer to this document.

The use_mapped_pass argument instructs the module to take the clear text authentication token entered by a previous module (that requests such a token) and use it to generate an encryption/decryption key with which to safely store/retrieve the authentication token required for this module. In this way the user can enter a single authentication token and be quietly authenticated by a number of stacked modules. Obviously a convenient feature that necessarily requires some reliably strong encryption to make it secure. This argument is intended for the auth and password module types only.

4.3 An example /etc/pam.conf file

In this section, we give some examples of entries that can be present in the Linux-PAM configuration file. As a first attempt at configuring your system you could do worse than to implement these.

Default policy

If a system is to be considered secure, it had better have a reasonably secure `OTHER' entry. The following is a paranoid setting (which is not a bad place to start!):

#
# default; deny access
#

OTHER   auth     required       /usr/lib/security/pam_deny.so
OTHER   account  required       /usr/lib/security/pam_deny.so
OTHER   password required       /usr/lib/security/pam_deny.so
OTHER   session  required       /usr/lib/security/pam_deny.so
Whilst fundamentally a secure default, this is not very sympathetic to a misconfigured system. For example, such a system is vulnerable to locking everyone out should the rest of the file become badly written.

The module pam_deny (documented in a later section) is not very sophisticated. For example, it logs no information when it is invoked so unless the users of a system contact the administrator when failing to execute a service application, the administrator may go for a long while in ignorance of the fact that his system is misconfigured.

The addition of the following line before those in the above example would provide a suitable warning to the administrator.

#
# default; wake up! This application is not configured
#

OTHER   auth     required       /usr/lib/security/pam_warn.so
OTHER   password required       /usr/lib/security/pam_warn.so
Having two ``OTHER auth'' lines is an example of stacking.

On a less sensitive computer, one on which the system administrator wishes to remain ignorant of the power of Linux-PAM, the following selection of lines is likely to mimic the historically familiar Linux setup.

#
# default; standard UNIX access
#

OTHER   auth     required       /usr/lib/security/pam_unix_auth.so
OTHER   account  required       /usr/lib/security/pam_unix_acct.so
OTHER   password required       /usr/lib/security/pam_unix_passwd.so
OTHER   session  required       /usr/lib/security/pam_unix_sess.so
In general this will provide a starting place for most applications. Unfortunately, most is not all. One application that might require additional lines is ftpd if you wish to enable anonymous-ftp.

To enable anonymous-ftp, the following lines might be used to replace the default (OTHER) ones. (*WARNING* as of 1996/11/14 this does not work correctly with any ftpd. Consequently, this description may be subject to change or the application will be fixed.)

#
# default; add ftp-specifics. These lines enable anonymous ftp over
#          standard UNIX access (the listfile entry blocks access to
#          users listed in /etc/ftpusers)
#

ftpd    auth    sufficient  /usr/lib/security/pam_ftp.so
ftpd    auth    required    /usr/lib/security/pam_unix_auth.so use_first_pass
ftpd    auth    required    /usr/lib/security/pam_listfile.so \
                        onerr=succeed item=user sense=deny file=/etc/ftpusers
Note, the second line is necessary since the default entries are ignored by a service application (here ftpd) if there are any entries in /etc/pam.conf for that specified service. Again, this is an example of authentication module stacking. Note the use of the sufficient control-flag. It says that ``if this module authenticates the user, ignore the subsequent auth modules''. Also note the use of the ``use_first_pass'' module-argument, this instructs the UNIX authentication module that it is not to prompt for a password but rely one already having been obtained by the ftp module.

The standard UNIX modules used above are strongly tied to using the default `libc' user database functions (see for example, man getpwent). It is the opinion of the author that these functions are not sufficently flexible to make full use of the power of Linux-PAM. For this reason, and as a small plug, I mention in passing that there is a pluggable replacement for the pam_unix_.. modules; pam_pwdb. See the section below for a more complete description.


Next Chapter, Previous Chapter

Table of contents of this chapter, General table of contents

Top of the document, Beginning of this Chapter