summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Terpstra <jht@samba.org>2003-05-31 23:16:43 +0000
committerJohn Terpstra <jht@samba.org>2003-05-31 23:16:43 +0000
commitf3fc1229b054aaed93b2e62611327891f7f39a34 (patch)
tree712cc928478071eac72b4a141551e9481946ba6c
parente91f9af1c8e3836243aa4a6e87bace2d51bfe590 (diff)
downloadsamba-f3fc1229b054aaed93b2e62611327891f7f39a34.tar.gz
samba-f3fc1229b054aaed93b2e62611327891f7f39a34.tar.bz2
samba-f3fc1229b054aaed93b2e62611327891f7f39a34.zip
Added more on anatomy of PAM. Note: This file is broken!
(This used to be commit 471d7480a793a1325559e2f75e3c85b88a0dedff)
-rw-r--r--docs/docbook/projdoc/PAM-Authentication-And-Samba.xml375
1 files changed, 338 insertions, 37 deletions
diff --git a/docs/docbook/projdoc/PAM-Authentication-And-Samba.xml b/docs/docbook/projdoc/PAM-Authentication-And-Samba.xml
index ef1496c7a6..b609e3243c 100644
--- a/docs/docbook/projdoc/PAM-Authentication-And-Samba.xml
+++ b/docs/docbook/projdoc/PAM-Authentication-And-Samba.xml
@@ -20,6 +20,11 @@ based domain environment. It will also help you to configure PAM based local hos
controls that are appropriate to your Samba configuration.
</para>
+<para>
+In addition to knowing how to configure winbind into PAM, you will learn generic PAM managment
+possibilities and in particular how to deploy tools like pam_smbpass.so to your adavantage.
+</para>
+
<sect1>
<title>Features and Benefits</title>
@@ -133,44 +138,317 @@ user account database.
<title>Technical Discussion</title>
<para>
-All operating systems depend on the authentication sub-systems to provide for authenticated users
-credentials accecptable to the platform. Unix requires the provision of a user identifier (UID)
-as well as a group identifier (GID). These are both simple integer type numbers that are obtained
-from a password backend such as <filename>/etc/passwd</filename>.
+PAM is designed to provide the system administrator with a great deal of flexibility in
+configuration of the privilege granting applications of their system. The local
+configuration of system security controlled by PAM is contained in one of two places:
+either the single system file, /etc/pam.conf; or the /etc/pam.d/ directory.
</para>
+<sect2>
+<title>PAM Configuration Syntax</title>
+
<para>
-Users and groups on a Windows NT server are assigned a relative id (rid) which is unique for
-the domain when the user or group is created. To convert the Windows NT user or group into
-a unix user or group, a mapping between rids and unix user and group ids is required. This
-is one of the jobs that winbind performs.
+In this section we discuss the correct syntax of and generic options respected by entries to these files.
+PAM specific tokens in the configuration 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 file-systems.
+The case-sensitivity of the arguments to any given module is defined for each module in turn.
</para>
<para>
-As winbind users and groups are resolved from a server, user and group ids are allocated
-from a specified range. This is done on a first come, first served basis, although all
-existing users and groups will be mapped as soon as a client performs a user or group
-enumeration command. The allocated unix ids are stored in a database file under the Samba
-lock directory and will be remembered.
+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 `\' escaped newline.
</para>
-<warning><para>
-The rid to unix id database is the only location where the user and group mappings are
-stored by winbindd. If this file is deleted or corrupted, there is no way for winbindd
-to determine which user and group ids correspond to Windows NT user and group rids.
-</para></warning>
-
<para>
If the PAM authentication module (loadable link library file) is located in the
default location then it is not necessary to specify the path. In the case of
Linux, the default location is <filename>/lib/security</filename>. If the module
is located outside the default then the path must be specified as:
+</para>
+<para>
<screen>
auth required /other_path/pam_strange_module.so
</screen>
</para>
+<sect3>
+<title>Anatomy of <filename>/etc/pam.d</filename> Entries</title>
+
+<para>
+The remaining information in this subsection was taken from the documentation of the Linux-PAM
+project.
+</para>
+
+<para>
+A general configuration line of the /etc/pam.conf file has the following form:
+</para>
+
+<para>
+<screen>
+service-name module-type control-flag module-path args
+</screen>
+</para>
+
+<para>
+Below, we explain the meaning of each of these tokens. The second (and more recently adopted)
+way of configuring Linux-PAM is via the contents of the <filename>/etc/pam.d/</filename> directory.
+Once we have explained the meaning of the above tokens, we will describe this method.
+</para>
+
+<variablelist>
+ <varlistentry><term>service-name</term><listitem><para>-</para>
+ <para>
+ 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. .
+ </para>
+
+ <para>
+ 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.
+ </para></listitem>
+ </varlistentry>
+
+ <varlistentry><term>module-type</term><listitem><para>-</para>
+ <para>
+ One of (currently) four types of module. The four types are as follows:
+ </para>
+
+ <itemizedlist>
+ <listitem><para>
+ <emphasis>auth:</emphasis> 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 group membership (independently of the <filename>/etc/groups</filename> file discussed
+ above) or other privileges through its credential granting properties.
+ </para></listitem>
+
+ <listitem><para>
+ <emphasis>account:</emphasis> 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 `root' login only on the console.
+ </para></listitem>
+
+ <listitem><para>
+ <emphasis>session:</emphasis> 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 loggin
+ of information concerning the opening/closing of some data exchange with a user, mountin
+ directories, etc.
+ </para></listitem>
+
+ <listitem><para>
+ <emphasis>password:</emphasis> 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 (auth) module-type.
+ </para></listitem>
+ </itemizedlist>
+ </varlistentry>
+
+ <varlistentry><term>control-flag</term><listitem><para>-</para>
+ <para>
+ 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 stacked (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
+ <filename>/etc/pam.conf</filename> 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
+ <filename>/etc/pam.conf</filename> file; earlier entries are executed before later ones.
+ As of Linux-PAM v0.60, this control-flag can be defined with one of two syntaxes.
+ </para>
+
+ <para>
+ 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
+ <emphasis>keywords: required, requisite, sufficient and optional</emphasis>.
+ </para>
+
+ <para>
+ The Linux-PAM library interprets these keywords in the following manner:
+ </para>
+
+ <itemizedlist>
+ <listitem><para>
+ <empahsis>required:</emphasis> this indicates that the success of the module is required for the
+ module-type facility to succeed. Failure of this module will not be apparent to the user until all
+ of the remaining modules (of the same module-type) have been executed.
+ </para></listitem>
+
+ <listitem><para>
+ <emphasis>requisite:</emphasis> like required, 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 first required or requisite 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.
+ </para></listitem>
+
+ <listitem><para>
+ <emphasis>sufficient:</emphasis> the success of this module is deemed `sufficient' to satisfy
+ the Linux-PAM library that this module-type has succeeded in its purpose. In the event that no
+ previous required module has failed, no more `stacked' modules of this type are invoked. (Note,
+ in this case subsequent required modules are not invoked.). A failure of this module is not deemed
+ as fatal to satisfying the application that this module-type has succeeded.
+ </para></listitem>
+
+ <listitem><para>
+ <emphasis>optional:</emphasis> as its name suggests, this control-flag marks the module as not
+ being critical to the success or failure of the user's application for service. In general,
+ Linux-PAM 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 PAM_IGNORE.
+ </para>
+ </itemizedlist>
+
+ <para>
+ 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 value=action tokens:
+ </para>
+
+ <para><screen>
+ [value1=action1 value2=action2 ...]
+ </screen></para>
+
+ <para>
+ Here, valueI is one of the following return values: success; open_err; symbol_err; service_err;
+ system_err; buf_err; perm_denied; auth_err; cred_insufficient; authinfo_unavail; user_unknown; maxtries;
+ new_authtok_reqd; acct_expired; session_err; cred_unavail; cred_expired; cred_err; no_module_data; conv_err;
+ authtok_err; authtok_recover_err; authtok_lock_busy; authtok_disable_aging; try_again; ignore; abort;
+ authtok_expired; module_unknown; bad_item; and default. The last of these (default) can be used to set
+ the action for those return values that are not explicitly defined.
+ </para>
+
+ <para>
+ The actionI can be a positive integer or one of the following tokens: ignore; ok; done; bad; die; and reset.
+ A positive integer, J, when specified as the action, can be used to indicate that the next J modules of the
+ current module-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.
+ </para>
+
+ <itemizedlist>
+ <listitem><para>
+ <emphasis>ignore:</emphasis> when used with a stack of modules, the module's return status will not
+ contribute to the return code the application obtains.
+ </para></listitem>
+
+ <listitem><para>
+ <emphasis>bad:</emphasis> 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.
+ </para></listitem>
+
+ <listitem><para>
+ <emphasis>die:</emphasis> equivalent to bad with the side effect of terminating the module stack and
+ PAM immediately returning to the application.
+ </para></listitem>
+
+ <listitem><para>
+ <emphasis>ok:</emphasis> this tells PAM 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 PAM_SUCCESS, 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.
+ </para></listitem>
+
+ <listitem><para>
+ <emphasis>done:</emphasis> equivalent to ok with the side effect of terminating the module stack and
+ PAM immediately returning to the application.
+ </para></listitem>
+
+ <listitem><para>
+ <emphasis>reset:</emphasis> clear all memory of the state of the module stack and start again with
+ the next stacked module.
+ </para></listitem>
+ </itemizedlist>
+
+ <para>
+ Each of the four keywords: required; requisite; sufficient; and optional, have an equivalent expression in
+ terms of the [...] syntax. They are as follows:
+ </para>
+
+ <itemizedlist>
+ <listitem><para>
+ required is equivalent to [success=ok new_authtok_reqd=ok ignore=ignore default=bad]
+ </para></listitem>
+
+ <listitem><para>
+ requisite is equivalent to [success=ok new_authtok_reqd=ok ignore=ignore default=die]
+ </para></listitem>
+
+ <listitem><para>
+ sufficient is equivalent to [success=done new_authtok_reqd=done default=ignore]
+ </para></listitem>
+
+ <listitem><para>
+ optional is equivalent to [success=ok new_authtok_reqd=ok default=ignore]
+ </para></listitem>
+ </itemizedlist>
+
+ <para>
+ Just to get a feel for the power of this new syntax, here is a taste of what you can do with it. With Linux-PAM-0.63,
+ 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
+ <emphasis>[ ... value=action ... ]</emphasis> 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.
+ </para>
+ </varlistentry>
+
+ <varlistentry><term>module-path</term><listitem><para>-</para>
+ <para>
+ The path-name of the dynamically loadable object file; the pluggable module itself. If the first character of the
+ module path is `/', 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: <filename>/lib/security</filename> (but see the notes above).
+ </para>
+
+ <para>
+ 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.
+ </para>
+
+ <para>
+ Note, if you wish to include spaces in an argument, you should surround that argument with square brackets. For example:
+ </para>
+
+<para><screen>
+squid auth required pam_mysql.so user=passwd_query passwd=mada \
+ db=eminence [query=select user_name from internet_service where \
+ user_name='%u' and password=PASSWORD('%p') and \
+ service='web_proxy']
+</screen></para>
+
+ <para>
+ Note, when using this convention, you can include `[' characters inside the string, and if you wish to include a `]'
+ character inside the string that will survive the argument parsing, you should use `\['. In other words:
+ </para>
+
+<para><screen>
+[..[..\]..] --> ..[..]..
+</screen></para>
+
+ <para>
+ 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 syslog(3).
+ </para>
+ </varlistentry>
+</variablelist>
+
+</sect3>
+
+</sect2>
+
+<sect2>
+<title>Example System Configurations</title>
+
<para>
The following is an example <filename>/etc/pam.d/login</filename> configuration file.
This example had all options been uncommented is probably not usable
@@ -321,6 +599,47 @@ password encryption.
</sect2>
<sect2>
+<title>Authentication off a remote CIFS Server using winbindd.so</title>
+
+<para>
+All operating systems depend on the provision of users credentials accecptable to the platform.
+Unix requires the provision of a user identifier (UID) as well as a group identifier (GID).
+These are both simple integer type numbers that are obtained from a password backend such
+as <filename>/etc/passwd</filename>.
+</para>
+
+<para>
+Users and groups on a Windows NT server are assigned a relative id (rid) which is unique for
+the domain when the user or group is created. To convert the Windows NT user or group into
+a unix user or group, a mapping between rids and unix user and group ids is required. This
+is one of the jobs that winbind performs.
+</para>
+
+<para>
+As winbind users and groups are resolved from a server, user and group ids are allocated
+from a specified range. This is done on a first come, first served basis, although all
+existing users and groups will be mapped as soon as a client performs a user or group
+enumeration command. The allocated unix ids are stored in a database file under the Samba
+lock directory and will be remembered.
+</para>
+
+<para>
+The astute administrator will realize from this that the combination of <filename>pam_smbpass.so</filename>,
+<command>winbindd</command>, and a distributed passdb backend, such as ldap, will allow the establishment of a
+centrally managed, distributed user/password database that can also be used by all PAM (eg: Linux) aware
+programs and applications. This arrangement can have particularly potent advantages compared with the use of
+Microsoft Active Directory Service (ADS) in so far as reduction of wide area network authentication traffic.
+</para>
+
+<warning><para>
+The rid to unix id database is the only location where the user and group mappings are
+stored by winbindd. If this file is deleted or corrupted, there is no way for winbindd
+to determine which user and group ids correspond to Windows NT user and group rids.
+</para></warning>
+
+</sect2>
+
+<sect2>
<title>Password Synchronisation using pam_smbpass.so</title>
<para>
@@ -487,24 +806,6 @@ session required pam_krb5.so
</sect1>
<sect1>
-<title>Distributed Authentication</title>
-
-<para>
-The astute administrator will realize from this that the
-combination of <filename>pam_smbpass.so</filename>,
-<command>winbindd</command>, and a distributed
-passdb backend, such as ldap, will allow the establishment of a
-centrally managed, distributed
-user/password database that can also be used by all
-PAM (eg: Linux) aware programs and applications. This arrangement
-can have particularly potent advantages compared with the
-use of Microsoft Active Directory Service (ADS) in so far as
-reduction of wide area network authentication traffic.
-</para>
-
-</sect1>
-
-<sect1>
<title>Common Errors</title>
<para>