Sophie

Sophie

distrib > Mandriva > 8.1 > i586 > by-pkgid > a46cbe42e0ff9f3a2a3ed9d4555310d0 > files > 10

pam-doc-0.75-7mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
 <TITLE>The Linux-PAM System Administrators' Guide: The Linux-PAM configuration file</TITLE>
 <LINK HREF="pam-5.html" REL=next>
 <LINK HREF="pam-3.html" REL=previous>
 <LINK HREF="pam.html#toc4" REL=contents>
</HEAD>
<BODY>
<A HREF="pam-5.html">Next</A>
<A HREF="pam-3.html">Previous</A>
<A HREF="pam.html#toc4">Contents</A>
<HR>
<H2><A NAME="configuration"></A> <A NAME="s4">4. The Linux-PAM configuration file</A></H2>

<P><B>Linux-PAM</B> 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 <CODE>Linux-PAM</CODE> is contained in one of
two places: either the single system file, <CODE>/etc/pam.conf</CODE>; or
the <CODE>/etc/pam.d/</CODE> directory.  In this section we discuss the
correct syntax of and generic options respected by entries to these
files.
<P>
<H2><A NAME="ss4.1">4.1 Configuration file syntax</A>
</H2>

<P>The reader should note that the <B>Linux-PAM</B> specific tokens in this
file are case <EM>insensitive</EM>. The module paths, however, are case
sensitive since they indicate a file's <EM>name</EM> 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.
<P>
<P>In addition to the lines described below, there are two <EM>special</EM>
characters provided for the convenience of the system administrator:
comments are preceded by a `<CODE>#</CODE>' and extend to the
next end-of-line; also, module specification lines may be extended
with a `<CODE>\</CODE>' escaped newline.
<P>
<P>A general configuration line of the <CODE>/etc/pam.conf</CODE> file has
the following form:
<BLOCKQUOTE><CODE>
<PRE>
service-name   module-type   control-flag   module-path   arguments
</PRE>
</CODE></BLOCKQUOTE>

Below, we explain the meaning of each of these tokens. The second (and
more recently adopted) way of configuring <B>Linux-PAM</B> is via the
contents of the <CODE>/etc/pam.d/</CODE> directory. Once we have explained
the meaning of the above tokens, we will describe this method.
<P>
<P>
<DL>
<DT><B><CODE>service-name</CODE></B><DD><P>The name of the service associated with this entry. Frequently the
service name is the conventional name of the given application. For
example, `<CODE>ftpd</CODE>', `<CODE>rlogind</CODE>' and `<CODE>su</CODE>', <EM>etc.</EM> .
<P>
<P>There is a special <CODE>service-name</CODE>, reserved for defining a default
authentication mechanism. It has the name `<CODE>OTHER</CODE>' and may be
specified in either lower or upper case characters. Note, when there
is a module specified for a named service, the `<CODE>OTHER</CODE>' entries
are ignored.
<P>
<DT><B><CODE>module-type</CODE></B><DD><P>One of (currently) four types of module. The four types are as
follows:
<UL>
<LI> <CODE>auth</CODE>; this module type provides two aspects of
authenticating the user. Firstly, it establishes that the user is who
they claim to be, by instructing the application to prompt the user
for a password or other means of identification. Secondly, the module
can grant <CODE>group</CODE> membership (independently of the
<CODE>/etc/groups</CODE> file discussed above) or other privileges through
its <EM>credential</EM> granting properties.
</LI>
<LI> <CODE>account</CODE>; this module performs non-authentication based
account management. It is typically used to restrict/permit access to
a service based on the time of day, currently available system
resources (maximum number of users) or perhaps the location of the
applicant user---`<CODE>root</CODE>' login only on the console.
</LI>
<LI> <CODE>session</CODE>; primarily, this module is associated with doing
things that need to be done for the user before/after they can be
given service.  Such things include the logging of information
concerning the opening/closing of some data exchange with a user,
mounting directories, etc. .
</LI>
<LI> <CODE>password</CODE>; this last module type is required for updating the
authentication token associated with the user. Typically, there is one
module for each `challenge/response' based authentication (<CODE>auth</CODE>)
module-type.
</LI>
</UL>
<P>
<DT><B><CODE>control-flag</CODE></B><DD><P>The control-flag is used to indicate how the PAM library will react to
the success or failure of the module it is associated with.  Since
modules can be <EM>stacked</EM> (modules of the same type execute in
series, one after another), the control-flags determine the relative
importance of each module.  The application is not made aware of the
individual success or failure of modules listed in the
`<CODE>/etc/pam.conf</CODE>' file.  Instead, it receives a summary
<EM>success</EM> or <EM>fail</EM> response from the <B>Linux-PAM</B> library.
The order of execution of these modules is that of the entries in the
<CODE>/etc/pam.conf</CODE> file; earlier entries are executed before later
ones.  As of Linux-PAM v0.60, this <EM>control-flag</EM> can be defined
with one of two syntaxes.
<P>
<P>The simpler (and historical) syntax for the control-flag is a single
keyword defined to indicate the severity of concern associated with
the success or failure of a specific module.  There are four such
keywords: <CODE>required</CODE>, <CODE>requisite</CODE>, <CODE>sufficient</CODE> and
<CODE>optional</CODE>.
<P>
<P>The Linux-PAM library interprets these keywords in the following
manner:
<P>
<UL>
<LI> <CODE>required</CODE>; this indicates that the success of the module is
required for the <CODE>module-type</CODE> facility to succeed. Failure of this
module will not be apparent to the user until all of the remaining
modules (of the same <CODE>module-type</CODE>) have been executed.
</LI>
<LI> <CODE>requisite</CODE>; like <CODE>required</CODE>, however, in the case that
such a module returns a failure, control is directly returned to the
application.  The return value is that associated with the <EM>first</EM>
<CODE>required</CODE> or <CODE>requisite</CODE> module to fail.  Note, this flag can be
used to protect against the possibility of a user getting the
opportunity to enter a password over an unsafe medium.  It is
conceivable that such behavior might inform an attacker of valid
accounts on a system. This possibility should be weighed against the
not insignificant concerns of exposing a sensitive password in a
hostile environment.
</LI>
<LI> <CODE>sufficient</CODE>; the success of this module is deemed
`<EM>sufficient</EM>' to satisfy the <B>Linux-PAM</B> library that this
module-type has succeeded in its purpose. In the event that no
previous <CODE>required</CODE> module has failed, no more `<EM>stacked</EM>'
modules of this type are invoked. (Note, in this case subsequent
<CODE>required</CODE> modules are <B>not</B> invoked.). A failure of this module
is not deemed as fatal to satisfying the application that this
<CODE>module-type</CODE> has succeeded.
</LI>
<LI> <CODE>optional</CODE>; as its name suggests, this <CODE>control-flag</CODE>
marks the module as not being critical to the success or failure of
the user's application for service.  In general, <B>Linux-PAM</B>
ignores such a module when determining if the module stack will
succeed or fail.  However, in the absence of any definite successes or
failures of previous or subsequent stacked modules this module will
determine the nature of the response to the application.  One example
of this latter case, is when the other modules return something like
<CODE>PAM_IGNORE</CODE>.
</LI>
</UL>
<P>
<P>The more elaborate (newer) syntax is much more specific and gives the
administrator a great deal of control over how the user is
authenticated.  This form of the control flag is delimeted with square
brackets and consists of a series of <CODE>value=action</CODE> tokens:
<BLOCKQUOTE><CODE>
<PRE>
    [value1=action1 value2=action2 ...]
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>Here, <CODE>valueI</CODE> is one of the following <EM>return values</EM>:
<CODE>success</CODE>; <CODE>open_err</CODE>; <CODE>symbol_err</CODE>; <CODE>service_err</CODE>;
<CODE>system_err</CODE>; <CODE>buf_err</CODE>; <CODE>perm_denied</CODE>; <CODE>auth_err</CODE>;
<CODE>cred_insufficient</CODE>; <CODE>authinfo_unavail</CODE>; <CODE>user_unknown</CODE>;
<CODE>maxtries</CODE>; <CODE>new_authtok_reqd</CODE>; <CODE>acct_expired</CODE>;
<CODE>session_err</CODE>; <CODE>cred_unavail</CODE>; <CODE>cred_expired</CODE>; <CODE>cred_err</CODE>;
<CODE>no_module_data</CODE>; <CODE>conv_err</CODE>; <CODE>authtok_err</CODE>;
<CODE>authtok_recover_err</CODE>; <CODE>authtok_lock_busy</CODE>;
<CODE>authtok_disable_aging</CODE>; <CODE>try_again</CODE>; <CODE>ignore</CODE>; <CODE>abort</CODE>;
<CODE>authtok_expired</CODE>; <CODE>module_unknown</CODE>; <CODE>bad_item</CODE>; and
<CODE>default</CODE>.  The last of these (<CODE>default</CODE>) can be used to set the
action for those return values that are not explicitly defined.
<P>
<P>The <CODE>actionI</CODE> can be a positive integer or one of the following
tokens: <CODE>ignore</CODE>; <CODE>ok</CODE>; <CODE>done</CODE>; <CODE>bad</CODE>; <CODE>die</CODE>; and
<CODE>reset</CODE>.  A positive integer, <CODE>J</CODE>, when specified as the action,
can be used to indicate that the next <EM>J</EM> modules of the current
type will be skipped.  In this way, the administrator can develop a
moderately sophisticated stack of modules with a number of different
paths of execution.  Which path is taken can be determined by the
reactions of individual modules.
<P>
<P>
<UL>
<LI><CODE>ignore</CODE> - when used with a stack of modules, the module's
return status will not contribute to the return code the application
obtains.</LI>
<LI><CODE>bad</CODE> - this action indicates that the return code should be
thought of as indicative of the module failing. If this module is
the first in the stack to fail, its status value will be used for
that of the whole stack.</LI>
<LI><CODE>die</CODE> - equivalent to <CODE>bad</CODE> with the side effect of
terminating the module stack and PAM immediately returning to the
application.</LI>
<LI><CODE>ok</CODE> - this tells <B>PAM</B> that the administrator thinks this
return code should contribute directly to the return code of the full
stack of modules. In other words, if the former state of the stack
would lead to a return of <CODE>PAM_SUCCESS</CODE>, the module's return code
will override this value.  Note, if the former state of the stack
holds some value that is indicative of a modules failure, this 'ok'
value will not be used to override that value.</LI>
<LI><CODE>done</CODE> - equivalent to <CODE>ok</CODE> with the side effect of
terminating the module stack and PAM immediately returning to the
application.</LI>
<LI><CODE>reset</CODE> - clear all memory of the state of the module stack and
start again with the next stacked module.</LI>
</UL>
<P>
<P>Just to get a feel for the power of this new syntax, here is a taste
of what you can do with it.  With <B>Linux-PAM-0.63</B>, the notion of
client plug-in agents was introduced.  This is something that makes it
possible for PAM to support machine-machine authentication using the
transport protocol inherent to the client/server application.  With
the ``<CODE>[ ... value=action ... ]</CODE>'' control syntax, it is possible
for an application to be configured to support binary prompts with
compliant clients, but to gracefully fall over into an alternative
authentication mode for older, legacy, applications.  Flexible eh?
<P>
<DT><B> <CODE>module-path</CODE></B><DD><P>The path-name of the dynamically loadable object file; <EM>the
pluggable module</EM> itself. If the first character of the module path is
`<CODE>/</CODE>', it is assumed to be a complete path. If this is not the
case, the given module path is appended to the default module path:
<CODE>/usr/lib/security</CODE> (but see the notes 
<A HREF="pam-2.html#text-conventions">above</A>).
<P>
<DT><B> <CODE>args</CODE></B><DD><P>The <CODE>args</CODE> 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 <CODE>syslog(3)</CODE>. For a list of <EM>generic</EM> options see the
next section.
<P>
</DL>
<P>
<P>Any line in (one of) the configuration file(s), that is not formatted
correctly, will generally tend (erring on the side of caution) to make
the authentication process fail.  A corresponding error is written to
the system log files with a call to <CODE>syslog(3)</CODE>.
<P>
<H2><A NAME="ss4.2">4.2 Directory based configuration</A>
</H2>

<P>More flexible than the single configuration file, as of version 0.56,
it is possible to configure <CODE>libpam</CODE> via the contents of the
<CODE>/etc/pam.d/</CODE> directory.  In this case the directory is filled
with files each of which has a filename equal to a service-name (in
lower-case): it is the personal configuration file for the named
service.
<P>
<P><B>Linux-PAM</B> can be compiled in one of two modes.  The preferred
mode uses either <CODE>/etc/pam.d/</CODE> or <CODE>/etc/pam.conf</CODE>
configuration but not both.  That is to say, if there is a
<CODE>/etc/pam.d/</CODE> directory then libpam only uses the files
contained in this directory.  However, in the absence of the
<CODE>/etc/pam.d/</CODE> directory the <CODE>/etc/pam.conf</CODE> file is
used.  The other mode (and the one currently supported by Red Hat 4.2
and higher) is to use both <CODE>/etc/pam.d/</CODE> and
<CODE>/etc/pam.conf</CODE> in sequence.  In this mode, entries in
<CODE>/etc/pam.d/</CODE> override those of <CODE>/etc/pam.conf</CODE>.
<P>The syntax of each file in <CODE>/etc/pam.d/</CODE> is similar to that of
the <CODE>/etc/pam.conf</CODE> file and is made up of lines of the
following form:
<BLOCKQUOTE><CODE>
<PRE>
module-type   control-flag   module-path   arguments
</PRE>
</CODE></BLOCKQUOTE>

The only difference being that the <CODE>service-name</CODE> is not
present.   The service-name is of course the name of the given
configuration file.  For example, <CODE>/etc/pam.d/login</CODE> contains
the configuration for the <EM>login</EM> service.
<P>
<P>This method of configuration has a number of advantages over the
single file approach. We list them here to assist the reader in
deciding which scheme to adopt:
<P>
<P>
<UL>
<LI>A lower chance of misconfiguring an application. There is one
less field to mis-type when editing the configuration files by hand.
</LI>
<LI>Easier to maintain. One application may be reconfigured without
risk of interfering with other applications on the system.
</LI>
<LI>It is possible to symbolically link different services
configuration files to a single file. This makes it easier to keep the
system policy for access consistent across different applications.
(It should be noted, to conserve space, it is equally possible to
<EM>hard</EM> link a number of configuration files.  However, care
should be taken when administering this arrangement as editing a hard
linked file is likely to break the link.)
</LI>
<LI>A potential for quicker configuration file parsing. Only the
relevant entries are parsed when a service gets bound to its modules.
</LI>
<LI>It is possible to limit read access to individual <B>Linux-PAM</B>
configuration files using the file protections of the filesystem.
</LI>
<LI>Package management becomes simpler.  Every time a new
application is installed, it can be accompanied by an
<CODE>/etc/pam.d/</CODE><EM>xxxxxx</EM> file.
</LI>
</UL>
<P>
<H2><A NAME="ss4.3">4.3 Generic optional arguments</A>
</H2>

<P>The following are optional arguments which are likely to be understood
by any module. Arguments (including these) are in general
<EM>optional</EM>.
<P>
<P>
<DL>
<DT><B><CODE>debug</CODE></B><DD><P>Use the <CODE>syslog(3)</CODE> call to log debugging information to the system
log files.
<P>
<DT><B> <CODE>no_warn</CODE></B><DD><P>Instruct module to not give warning messages to the application.
<P>
<DT><B> <CODE>use_first_pass</CODE></B><DD><P>The module should not prompt the user for a password. Instead, it
should obtain the previously typed password (from the preceding
<CODE>auth</CODE> module), and use that. If that doesn't work, then the user
will not be authenticated. (This option is intended for <CODE>auth</CODE>
and <CODE>password</CODE> modules only).
<P>
<DT><B> <CODE>try_first_pass</CODE></B><DD><P>The module should attempt authentication with the previously typed
password (from the preceding <CODE>auth</CODE> module). If that doesn't work,
then the user is prompted for a password. (This option is intended for
<CODE>auth</CODE> modules only).
<P>
<DT><B> <CODE>use_mapped_pass</CODE></B><DD><P>This argument is not currently supported by any of the modules in the
<B>Linux-PAM</B> 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 <B>DCE-RFC 86.0</B>, see section 
<A HREF="pam-8.html#see-also-sec">bibliography</A> for a pointer to this document.
<P>
<P>The <CODE>use_mapped_pass</CODE> 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 <CODE>auth</CODE> and <CODE>password</CODE> module
types only.
<P>
<DT><B><CODE>expose_account</CODE></B><DD><P>
<P>In general the leakage of some information about user accounts is not
a secure policy for modules to adopt. Sometimes information such as
users names or home directories, or preferred shell, can be used to
attack a user's account. In some circumstances, however, this sort of
information is not deemed a threat: displaying a user's full name when
asking them for a password in a secured environment could also be
called being 'friendly'. The <CODE>expose_account</CODE> argument is a
standard module argument to encourage a module to be less discrete
about account information as it is deemed appropriate by the local
administrator.
<P>
</DL>
<P>
<H2><A NAME="ss4.4">4.4 Example configuration file entries</A>
</H2>

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

<P>If a system is to be considered secure, it had better have a
reasonably secure `<CODE>OTHER</CODE>' entry. The following is a paranoid
setting (which is not a bad place to start!):
<BLOCKQUOTE><CODE>
<PRE>
#
# 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
</PRE>
</CODE></BLOCKQUOTE>

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.
<P>
<P>The module <CODE>pam_deny</CODE> (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.
<P>
<P>The addition of the following line before those in the above example
would provide a suitable warning to the administrator.
<BLOCKQUOTE><CODE>
<PRE>
#
# 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
</PRE>
</CODE></BLOCKQUOTE>

Having two ``<CODE>OTHER auth</CODE>'' lines is an example of stacking.
<P>
<P>On a system that uses the <CODE>/etc/pam.d/</CODE> configuration, the
corresponding default setup would be achieved with the following file:
<BLOCKQUOTE><CODE>
<PRE>
#
# default configuration: /etc/pam.d/other
#
auth     required       /usr/lib/security/pam_warn.so
auth     required       /usr/lib/security/pam_deny.so
account  required       /usr/lib/security/pam_deny.so
password required       /usr/lib/security/pam_warn.so
password required       /usr/lib/security/pam_deny.so
session  required       /usr/lib/security/pam_deny.so
</PRE>
</CODE></BLOCKQUOTE>

This is the only explicit example we give for an <CODE>/etc/pam.d/</CODE>
file. In general, it should be clear how to transpose the remaining
examples to this configuration scheme.
<P>
<P>On a less sensitive computer, one on which the system administrator
wishes to remain ignorant of much of the power of <CODE>Linux-PAM</CODE>, the
following selection of lines (in <CODE>/etc/pam.conf</CODE>) is likely to
mimic the historically familiar Linux setup.
<BLOCKQUOTE><CODE>
<PRE>
#
# 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_session.so
</PRE>
</CODE></BLOCKQUOTE>

In general this will provide a starting place for most applications.
Unfortunately, most is not all. One application that might require
additional lines is <EM>ftpd</EM> if you wish to enable
<EM>anonymous-ftp</EM>.
<P>
<P>To enable anonymous-ftp, the following lines might be used to replace
the default (<CODE>OTHER</CODE>) ones. (<B>*WARNING*</B> as of 1996/12/28 this
does not work correctly with any ftpd. Consequently, this description
may be subject to change or the application will be fixed.)
<BLOCKQUOTE><CODE>
<PRE>
#
# ftpd; 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
</PRE>
</CODE></BLOCKQUOTE>

Note, the second line is necessary since the default entries are
ignored by a service application (here <EM>ftpd</EM>) if there are
<EM>any</EM> entries in <CODE>/etc/pam.conf</CODE> for that specified service.
Again, this is an example of authentication module stacking.  Note the
use of the <CODE>sufficient</CODE> control-flag. It says that ``if this module
authenticates the user, ignore the subsequent <CODE>auth</CODE>
modules''. Also note the use of the ``<CODE>use_first_pass</CODE>''
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.
<P>
<HR>
<A HREF="pam-5.html">Next</A>
<A HREF="pam-3.html">Previous</A>
<A HREF="pam.html#toc4">Contents</A>
</BODY>
</HTML>