trying to get HEAD building again. If you want the code
[metze/samba/wip.git] / docs / htmldocs / pam.html
1 <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 25. PAM based Distributed Authentication</title><link rel="stylesheet" href="samba.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.60.1"><link rel="home" href="index.html" title="SAMBA Project Documentation"><link rel="up" href="optional.html" title="Part III. Advanced Configuration"><link rel="previous" href="ProfileMgmt.html" title="Chapter 24. Desktop Profile Management"><link rel="next" href="integrate-ms-networks.html" title="Chapter 26. Integrating MS Windows networks with Samba"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 25. PAM based Distributed Authentication</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ProfileMgmt.html">Prev</a> </td><th width="60%" align="center">Part III. Advanced Configuration</th><td width="20%" align="right"> <a accesskey="n" href="integrate-ms-networks.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="pam"></a>Chapter 25. PAM based Distributed Authentication</h2></div><div><div class="author"><h3 class="author"><span class="firstname">John</span> <span class="othername">H.</span> <span class="surname">Terpstra</span></h3><div class="affiliation"><span class="orgname">Samba Team<br></span><div class="address"><p><tt class="email">&lt;<a href="mailto:jht@samba.org">jht@samba.org</a>&gt;</tt></p></div></div></div></div><div><div class="author"><h3 class="author"><span class="firstname">Stephen</span> <span class="surname">Langasek</span></h3><div class="affiliation"><div class="address"><p><tt class="email">&lt;<a href="mailto:vorlon@netexpress.net">vorlon@netexpress.net</a>&gt;</tt></p></div></div></div></div><div><p class="pubdate">May 31, 2003</p></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="pam.html#id2995804">Features and Benefits</a></dt><dt><a href="pam.html#id2996071">Technical Discussion</a></dt><dd><dl><dt><a href="pam.html#id2996089">PAM Configuration Syntax</a></dt><dt><a href="pam.html#id2996760">Example System Configurations</a></dt><dt><a href="pam.html#id2997062">smb.conf PAM Configuration</a></dt><dt><a href="pam.html#id2997119">Remote CIFS Authentication using winbindd.so</a></dt><dt><a href="pam.html#id2997203">Password Synchronization using pam_smbpass.so</a></dt></dl></dd><dt><a href="pam.html#id2997570">Common Errors</a></dt><dd><dl><dt><a href="pam.html#id2997583">pam_winbind problem</a></dt></dl></dd></dl></div><p>
2 This chapter you should help you to deploy winbind based authentication on any PAM enabled
3 Unix/Linux system. Winbind can be used to enable user level application access authentication
4 from any MS Windows NT Domain, MS Windows 200x Active Directory based domain, or any Samba
5 based domain environment. It will also help you to configure PAM based local host access
6 controls that are appropriate to your Samba configuration.
7 </p><p>
8 In addition to knowing how to configure winbind into PAM, you will learn generic PAM management
9 possibilities and in particular how to deploy tools like pam_smbpass.so to your advantage.
10 </p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
11 The use of Winbind require more than PAM configuration alone. Please refer to <a href="winbind.html" title="Chapter 21. Integrated Logon Support using Winbind">the Winbind chapter</a>.
12 </p></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2995804"></a>Features and Benefits</h2></div></div><div></div></div><p>
13 A number of Unix systems (eg: Sun Solaris), as well as the xxxxBSD family and Linux,
14 now utilize the Pluggable Authentication Modules (PAM) facility to provide all authentication, 
15 authorization and resource control services. Prior to the introduction of PAM, a decision
16 to use an alternative to the system password database (<tt class="filename">/etc/passwd</tt>) 
17 would require the provision of alternatives for all programs that provide security services.
18 Such a choice would involve provision of alternatives to such programs as: <b class="command">login</b>, 
19 <b class="command">passwd</b>, <b class="command">chown</b>, etc.
20 </p><p>
21 PAM provides a mechanism that disconnects these security programs from the underlying
22 authentication/authorization infrastructure.  PAM is configured either through one file
23 <tt class="filename">/etc/pam.conf</tt> (Solaris), or by editing individual files that are
24 located in <tt class="filename">/etc/pam.d</tt>.
25 </p><p>
26 On PAM enabled Unix/Linux systems it is an easy matter to configure the system to use any
27 authentication backend, so long as the appropriate dynamically loadable library modules
28 are available for it. The backend may be local to the system, or may be centralised on a
29 remote server.
30 </p><p>
31 PAM support modules are available for:
32 </p><div class="variablelist"><dl><dt><span class="term"><tt class="filename">/etc/passwd</tt></span></dt><dd><p>-</p><p>
33                 There are several PAM modules that interact with this standard Unix user
34                 database. The most common are called: pam_unix.so, pam_unix2.so, pam_pwdb.so
35                 and pam_userdb.so.
36                 </p></dd><dt><span class="term">Kerberos</span></dt><dd><p>-</p><p>
37                 The pam_krb5.so module allows the use of any Kerberos compliant server.
38                 This tool is used to access MIT Kerberos, Heimdal Kerberos, and potentially
39                 Microsoft Active Directory (if enabled).
40                 </p></dd><dt><span class="term">LDAP</span></dt><dd><p>-</p><p>
41                 The pam_ldap.so module allows the use of any LDAP v2 or v3 compatible backend
42                 server. Commonly used LDAP backend servers include: OpenLDAP v2.0 and v2.1,
43                 Sun ONE iDentity server, Novell eDirectory server, Microsoft Active Directory.
44                 </p></dd><dt><span class="term">NetWare Bindery</span></dt><dd><p>-</p><p>
45                 The pam_ncp_auth.so module allows authentication off any bindery enabled
46                 NetWare Core Protocol based server.
47                 </p></dd><dt><span class="term">SMB Password</span></dt><dd><p>-</p><p>
48                 This module, called pam_smbpass.so, will allow user authentication off
49                 the passdb backend that is configured in the Samba <tt class="filename">smb.conf</tt> file.
50                 </p></dd><dt><span class="term">SMB Server</span></dt><dd><p>-</p><p>
51                 The pam_smb_auth.so module is the original MS Windows networking authentication
52                 tool. This module has been somewhat outdated by the Winbind module.
53                 </p></dd><dt><span class="term">Winbind</span></dt><dd><p>-</p><p>
54                 The pam_winbind.so module allows Samba to obtain authentication from any
55                 MS Windows Domain Controller. It can just as easily be used to authenticate
56                 users for access to any PAM enabled application.
57                 </p></dd><dt><span class="term">RADIUS</span></dt><dd><p>-</p><p>
58                 There is a PAM RADIUS (Remote Access Dial-In User Service) authentication
59                 module. In most cases the administrator will need to locate the source code
60                 for this tool and compile and install it themselves. RADIUS protocols are
61                 used by many routers and terminal servers.
62                 </p></dd></dl></div><p>
63 Of the above, Samba provides the pam_smbpasswd.so and the pam_winbind.so modules alone.
64 </p><p>
65 Once configured, these permit a remarkable level of flexibility in the location and use
66 of distributed samba domain controllers that can provide wide are network bandwidth
67 efficient authentication services for PAM capable systems. In effect, this allows the
68 deployment of centrally managed and maintained distributed authentication from a single
69 user account database.
70 </p></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2996071"></a>Technical Discussion</h2></div></div><div></div></div><p>
71 PAM is designed to provide the system administrator with a great deal of flexibility in
72 configuration of the privilege granting applications of their system. The local
73 configuration of system security controlled by PAM is contained in one of two places:
74 either the single system file, /etc/pam.conf; or the /etc/pam.d/ directory.
75 </p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2996089"></a>PAM Configuration Syntax</h3></div></div><div></div></div><p>
76 In this section we discuss the correct syntax of and generic options respected by entries to these files.
77 PAM specific tokens in the configuration file are case insensitive. The module paths, however, are case
78 sensitive since they indicate a file's name and reflect the case dependence of typical file-systems.
79 The case-sensitivity of the arguments to any given module is defined for each module in turn.
80 </p><p>
81 In addition to the lines described below, there are two special characters provided for the convenience
82 of the system administrator: comments are preceded by a `#' and extend to the next end-of-line; also,
83 module specification lines may be extended with a `\' escaped newline. 
84 </p><p>
85 If the PAM authentication module (loadable link library file) is located in the
86 default location then it is not necessary to specify the path. In the case of
87 Linux, the default location is <tt class="filename">/lib/security</tt>. If the module
88 is located outside the default then the path must be specified as:
89 </p><p>
90 </p><pre class="screen">
91 auth  required  /other_path/pam_strange_module.so
92 </pre><p>
93 </p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2996146"></a>Anatomy of <tt class="filename">/etc/pam.d</tt> Entries</h4></div></div><div></div></div><p>
94 The remaining information in this subsection was taken from the documentation of the Linux-PAM
95 project. For more information on PAM, see 
96 <a href="http://ftp.kernel.org/pub/linux/libs/pam/" target="_top">
97 http://ftp.kernel.org/pub/linux/libs/pam</a> The Official Linux-PAM home page.
98 </p><p>
99 A general configuration line of the /etc/pam.conf file has the following form:
100 </p><p>
101 </p><pre class="screen">
102 service-name   module-type   control-flag   module-path   args
103 </pre><p>
104 </p><p>
105 Below, we explain the meaning of each of these tokens. The second (and more recently adopted)
106 way of configuring Linux-PAM is via the contents of the <tt class="filename">/etc/pam.d/</tt> directory.
107 Once we have explained the meaning of the above tokens, we will describe this method.
108 </p><div class="variablelist"><dl><dt><span class="term">service-name</span></dt><dd><p>-</p><p>
109                 The name of the service associated with this entry. Frequently the service name is the conventional
110                 name of the given application. For example, `ftpd', `rlogind' and `su', etc. .
111                 </p><p>
112                 There is a special service-name, reserved for defining a default authentication mechanism. It has
113                 the name `OTHER' and may be specified in either lower or upper case characters. Note, when there
114                 is a module specified for a named service, the `OTHER' entries are ignored.
115                 </p></dd><dt><span class="term">module-type</span></dt><dd><p>-</p><p>
116                 One of (currently) four types of module. The four types are as follows:
117                 </p><div class="itemizedlist"><ul type="disc"><li><p>
118                         <span class="emphasis"><em>auth:</em></span> this module type provides two aspects of authenticating the user.
119                         Firstly, it establishes that the user is who they claim to be, by instructing the application
120                         to prompt the user for a password or other means of identification. Secondly, the module can
121                         grant group membership (independently of the <tt class="filename">/etc/groups</tt> file discussed
122                         above) or other privileges through its credential granting properties.
123                         </p></li><li><p>
124                         <span class="emphasis"><em>account:</em></span> this module performs non-authentication based account management.
125                         It is typically used to restrict/permit access to a service based on the time of day, currently
126                         available system resources (maximum number of users) or perhaps the location of the applicant
127                         user `root' login only on the console.
128                         </p></li><li><p>
129                         <span class="emphasis"><em>session:</em></span> primarily, this module is associated with doing things that need
130                         to be done for the user before/after they can be given service. Such things include the logging
131                         of information concerning the opening/closing of some data exchange with a user, mounting
132                         directories, etc.
133                         </p></li><li><p>
134                         <span class="emphasis"><em>password:</em></span> this last module type is required for updating the authentication
135                         token associated with the user. Typically, there is one module for each `challenge/response'
136                         based authentication (auth) module-type.
137                         </p></li></ul></div></dd><dt><span class="term">control-flag</span></dt><dd><p>-</p><p>
138                 The control-flag is used to indicate how the PAM library will react to the success or failure of the
139                 module it is associated with. Since modules can be stacked (modules of the same type execute in series,
140                 one after another), the control-flags determine the relative importance of each module. The application
141                 is not made aware of the individual success or failure of modules listed in the
142                 <tt class="filename">/etc/pam.conf</tt> file. Instead, it receives a summary success or fail response from
143                 the Linux-PAM library. The order of execution of these modules is that of the entries in the
144                 <tt class="filename">/etc/pam.conf</tt> file; earlier entries are executed before later ones.
145                 As of Linux-PAM v0.60, this control-flag can be defined with one of two syntaxes.
146                 </p><p>
147                 The simpler (and historical) syntax for the control-flag is a single keyword defined to indicate the
148                 severity of concern associated with the success or failure of a specific module. There are four such
149                 <span class="emphasis"><em>keywords: required, requisite, sufficient and optional</em></span>.
150                 </p><p>
151                 The Linux-PAM library interprets these keywords in the following manner:
152                 </p><div class="itemizedlist"><ul type="disc"><li><p>
153                         <span class="emphasis"><em>required:</em></span> this indicates that the success of the module is required for the
154                         module-type facility to succeed. Failure of this module will not be apparent to the user until all
155                         of the remaining modules (of the same module-type) have been executed.
156                         </p></li><li><p>
157                         <span class="emphasis"><em>requisite:</em></span> like required, however, in the case that such a module returns a
158                         failure, control is directly returned to the application. The return value is that associated with
159                         the first required or requisite module to fail. Note, this flag can be used to protect against the
160                         possibility of a user getting the opportunity to enter a password over an unsafe medium. It is
161                         conceivable that such behavior might inform an attacker of valid accounts on a system. This
162                         possibility should be weighed against the not insignificant concerns of exposing a sensitive
163                         password in a hostile environment.
164                         </p></li><li><p>
165                         <span class="emphasis"><em>sufficient:</em></span> the success of this module is deemed `sufficient' to satisfy
166                         the Linux-PAM library that this module-type has succeeded in its purpose. In the event that no
167                         previous required module has failed, no more `stacked' modules of this type are invoked. (Note,
168                         in this case subsequent required modules are not invoked.). A failure of this module is not deemed
169                         as fatal to satisfying the application that this module-type has succeeded.
170                         </p></li><li><p>
171                         <span class="emphasis"><em>optional:</em></span> as its name suggests, this control-flag marks the module as not
172                         being critical to the success or failure of the user's application for service. In general,
173                         Linux-PAM ignores such a module when determining if the module stack will succeed or fail.
174                         However, in the absence of any definite successes or failures of previous or subsequent stacked
175                         modules this module will determine the nature of the response to the application. One example of
176                         this latter case, is when the other modules return something like PAM_IGNORE.
177                         </p></li></ul></div><p>
178                 The more elaborate (newer) syntax is much more specific and gives the administrator a great deal of control
179                 over how the user is authenticated. This form of the control flag is delimited with square brackets and
180                 consists of a series of value=action tokens:
181                 </p><pre class="screen">
182                 [value1=action1 value2=action2 ...]
183                 </pre><p>
184                 Here, value1 is one of the following return values: success; open_err; symbol_err; service_err;
185                 system_err; buf_err; perm_denied; auth_err; cred_insufficient; authinfo_unavail; user_unknown; maxtries;
186                 new_authtok_reqd; acct_expired; session_err; cred_unavail; cred_expired; cred_err; no_module_data; conv_err;
187                 authtok_err; authtok_recover_err; authtok_lock_busy; authtok_disable_aging; try_again; ignore; abort;
188                 authtok_expired; module_unknown; bad_item; and default. The last of these (default) can be used to set
189                 the action for those return values that are not explicitly defined.
190                 </p><p>
191                 The action1 can be a positive integer or one of the following tokens: ignore; ok; done; bad; die; and reset.
192                 A positive integer, J, when specified as the action, can be used to indicate that the next J modules of the
193                 current module-type will be skipped. In this way, the administrator can develop a moderately sophisticated
194                 stack of modules with a number of different paths of execution. Which path is taken can be determined by the
195                 reactions of individual modules.
196                 </p><div class="itemizedlist"><ul type="disc"><li><p>
197                         <span class="emphasis"><em>ignore:</em></span> when used with a stack of modules, the module's return status will not
198                         contribute to the return code the application obtains.
199                         </p></li><li><p>
200                         <span class="emphasis"><em>bad:</em></span> this action indicates that the return code should be thought of as indicative
201                         of the module failing. If this module is the first in the stack to fail, its status value will be used
202                         for that of the whole stack.
203                         </p></li><li><p>
204                         <span class="emphasis"><em>die:</em></span> equivalent to bad with the side effect of terminating the module stack and
205                         PAM immediately returning to the application.
206                         </p></li><li><p>
207                         <span class="emphasis"><em>ok:</em></span> this tells PAM that the administrator thinks this return code should
208                         contribute directly to the return code of the full stack of modules. In other words, if the former
209                         state of the stack would lead to a return of PAM_SUCCESS, the module's return code will override
210                         this value. Note, if the former state of the stack holds some value that is indicative of a modules
211                         failure, this 'ok' value will not be used to override that value.
212                         </p></li><li><p>
213                         <span class="emphasis"><em>done:</em></span> equivalent to ok with the side effect of terminating the module stack and
214                         PAM immediately returning to the application.
215                         </p></li><li><p>
216                         <span class="emphasis"><em>reset:</em></span> clear all memory of the state of the module stack and start again with
217                         the next stacked module.
218                         </p></li></ul></div><p>
219                 Each of the four keywords: required; requisite; sufficient; and optional, have an equivalent expression in
220                 terms of the [...] syntax. They are as follows:
221                 </p><p>
222                 </p><div class="itemizedlist"><ul type="disc"><li><p>
223                         required is equivalent to [success=ok new_authtok_reqd=ok ignore=ignore default=bad]
224                         </p></li><li><p>
225                         requisite is equivalent to [success=ok new_authtok_reqd=ok ignore=ignore default=die]
226                         </p></li><li><p>
227                         sufficient is equivalent to [success=done new_authtok_reqd=done default=ignore]
228                         </p></li><li><p>
229                         optional is equivalent to [success=ok new_authtok_reqd=ok default=ignore]
230                         </p></li></ul></div><p>
231                 </p><p>
232                 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,
233                 the notion of client plug-in agents was introduced. This is something that makes it possible for PAM to support
234                 machine-machine authentication using the transport protocol inherent to the client/server application. With the
235                 <span class="emphasis"><em>[ ... value=action ... ]</em></span> control syntax, it is possible for an application to be configured
236                 to support binary prompts with compliant clients, but to gracefully fall over into an alternative authentication
237                 mode for older, legacy, applications.
238                 </p></dd><dt><span class="term">module-path</span></dt><dd><p>-</p><p>
239                 The path-name of the dynamically loadable object file; the pluggable module itself. If the first character of the
240                 module path is `/', it is assumed to be a complete path. If this is not the case, the given module path is appended
241                 to the default module path: <tt class="filename">/lib/security</tt> (but see the notes above).
242                 </p><p>
243                 The args are a list of tokens that are passed to the module when it is invoked. Much like arguments to a typical
244                 Linux shell command. Generally, valid arguments are optional and are specific to any given module. Invalid arguments
245                 are ignored by a module, however, when encountering an invalid argument, the module is required to write an error
246                 to syslog(3). For a list of generic options see the next section.
247                 </p><p>
248                 Note, if you wish to include spaces in an argument, you should surround that argument with square brackets. For example:
249                 </p><pre class="screen">
250 squid auth required pam_mysql.so user=passwd_query passwd=mada \
251         db=eminence [query=select user_name from internet_service where \
252                      user_name='%u' and password=PASSWORD('%p') and \
253                      service='web_proxy']
254 </pre><p>
255                 Note, when using this convention, you can include `[' characters inside the string, and if you wish to include a `]'
256                 character inside the string that will survive the argument parsing, you should use `\['. In other words:
257                 </p><pre class="screen">
258 [..[..\]..]    --&gt;   ..[..]..
259 </pre><p>
260                 Any line in (one of) the configuration file(s), that is not formatted correctly, will generally tend (erring on the
261                 side of caution) to make the authentication process fail. A corresponding error is written to the system log files
262                 with a call to syslog(3). 
263                 </p></dd></dl></div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2996760"></a>Example System Configurations</h3></div></div><div></div></div><p>
264 The following is an example <tt class="filename">/etc/pam.d/login</tt> configuration file. 
265 This example had all options been uncommented is probably not usable 
266 as it stacks many conditions before allowing successful completion 
267 of the login process. Essentially all conditions can be disabled 
268 by commenting them out except the calls to <tt class="filename">pam_pwdb.so</tt>.
269 </p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2996790"></a>PAM: original login config</h4></div></div><div></div></div><pre class="screen">
270 #%PAM-1.0
271 # The PAM configuration file for the `login' service
272 #
273 auth         required    pam_securetty.so
274 auth         required    pam_nologin.so
275 # auth       required    pam_dialup.so
276 # auth       optional    pam_mail.so
277 auth         required    pam_pwdb.so shadow md5
278 # account    requisite   pam_time.so
279 account      required    pam_pwdb.so
280 session      required    pam_pwdb.so
281 # session    optional    pam_lastlog.so
282 # password   required    pam_cracklib.so retry=3
283 password     required    pam_pwdb.so shadow md5
284 </pre></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2996817"></a>PAM: login using pam_smbpass</h4></div></div><div></div></div><p>
285 PAM allows use of replaceable modules. Those available on a sample system include:
286 </p><p><tt class="prompt">$</tt><b class="userinput"><tt>/bin/ls /lib/security</tt></b>
287 </p><pre class="screen">
288 pam_access.so    pam_ftp.so          pam_limits.so     
289 pam_ncp_auth.so  pam_rhosts_auth.so  pam_stress.so     
290 pam_cracklib.so  pam_group.so        pam_listfile.so   
291 pam_nologin.so   pam_rootok.so       pam_tally.so      
292 pam_deny.so      pam_issue.so        pam_mail.so       
293 pam_permit.so    pam_securetty.so    pam_time.so       
294 pam_dialup.so    pam_lastlog.so      pam_mkhomedir.so  
295 pam_pwdb.so      pam_shells.so       pam_unix.so       
296 pam_env.so       pam_ldap.so         pam_motd.so       
297 pam_radius.so    pam_smbpass.so      pam_unix_acct.so  
298 pam_wheel.so     pam_unix_auth.so    pam_unix_passwd.so
299 pam_userdb.so    pam_warn.so         pam_unix_session.so
300 </pre><p>
301 The following example for the login program replaces the use of 
302 the <tt class="filename">pam_pwdb.so</tt> module which uses the system 
303 password database (<tt class="filename">/etc/passwd</tt>,
304 <tt class="filename">/etc/shadow</tt>, <tt class="filename">/etc/group</tt>) with 
305 the module <tt class="filename">pam_smbpass.so</tt> which uses the Samba 
306 database which contains the Microsoft MD4 encrypted password 
307 hashes. This database is stored in either 
308 <tt class="filename">/usr/local/samba/private/smbpasswd</tt>, 
309 <tt class="filename">/etc/samba/smbpasswd</tt>, or in 
310 <tt class="filename">/etc/samba.d/smbpasswd</tt>, depending on the 
311 Samba implementation for your Unix/Linux system. The 
312 <tt class="filename">pam_smbpass.so</tt> module is provided by 
313 Samba version 2.2.1 or later. It can be compiled by specifying the 
314 <tt class="option">--with-pam_smbpass</tt> options when running Samba's
315 <b class="command">configure</b> script.  For more information
316 on the <tt class="filename">pam_smbpass</tt> module, see the documentation
317 in the <tt class="filename">source/pam_smbpass</tt> directory of the Samba 
318 source distribution.
319 </p><pre class="screen">
320 #%PAM-1.0
321 # The PAM configuration file for the `login' service
322 #
323 auth        required    pam_smbpass.so nodelay
324 account     required    pam_smbpass.so nodelay
325 session     required    pam_smbpass.so nodelay
326 password    required    pam_smbpass.so nodelay
327 </pre><p>
328 The following is the PAM configuration file for a particular 
329 Linux system. The default condition uses <tt class="filename">pam_pwdb.so</tt>.
330 </p><pre class="screen">
331 #%PAM-1.0
332 # The PAM configuration file for the `samba' service
333 #
334 auth       required     pam_pwdb.so nullok nodelay shadow audit
335 account    required     pam_pwdb.so audit nodelay
336 session    required     pam_pwdb.so nodelay
337 password   required     pam_pwdb.so shadow md5
338 </pre><p>
339 In the following example the decision has been made to use the 
340 smbpasswd database even for basic samba authentication. Such a 
341 decision could also be made for the passwd program and would 
342 thus allow the smbpasswd passwords to be changed using the passwd 
343 program.
344 </p><pre class="screen">
345 #%PAM-1.0
346 # The PAM configuration file for the `samba' service
347 #
348 auth       required     pam_smbpass.so nodelay
349 account    required     pam_pwdb.so audit nodelay
350 session    required     pam_pwdb.so nodelay
351 password   required     pam_smbpass.so nodelay smbconf=/etc/samba.d/smb.conf
352 </pre><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>PAM allows stacking of authentication mechanisms. It is 
353 also possible to pass information obtained within one PAM module through 
354 to the next module in the PAM stack. Please refer to the documentation for 
355 your particular system implementation for details regarding the specific 
356 capabilities of PAM in this environment. Some Linux implementations also 
357 provide the <tt class="filename">pam_stack.so</tt> module that allows all 
358 authentication to be configured in a single central file. The 
359 <tt class="filename">pam_stack.so</tt> method has some very devoted followers 
360 on the basis that it allows for easier administration. As with all issues in 
361 life though, every decision makes trade-offs, so you may want examine the 
362 PAM documentation for further helpful information.
363 </p></div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2997062"></a>smb.conf PAM Configuration</h3></div></div><div></div></div><p>
364 There is an option in smb.conf called <a href="smb.conf.5.html#OBEYPAMRESTRICTIONS" target="_top">obey pam restrictions</a>. 
365 The following is from the on-line help for this option in SWAT;
366 </p><p>
367 When Samba-3 is configured to enable PAM support (i.e. 
368 <tt class="option">--with-pam</tt>), this parameter will 
369 control whether or not Samba should obey PAM's account 
370 and session management directives. The default behavior 
371 is to use PAM for clear text authentication only and to 
372 ignore any account or session management. Note that Samba always 
373 ignores PAM for authentication in the case of 
374 <a href="smb.conf.5.html#ENCRYPTPASSWORDS" target="_top">encrypt passwords = yes</a>. 
375 The reason is that PAM modules cannot support the challenge/response 
376 authentication mechanism needed in the presence of SMB 
377 password encryption. 
378 </p><p>Default: <i class="parameter"><tt>obey pam restrictions = no</tt></i></p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2997119"></a>Remote CIFS Authentication using winbindd.so</h3></div></div><div></div></div><p>
379 All operating systems depend on the provision of users credentials acceptable to the platform.
380 Unix requires the provision of a user identifier (UID) as well as a group identifier (GID).
381 These are both simple integer type numbers that are obtained from a password backend such
382 as <tt class="filename">/etc/passwd</tt>.
383 </p><p>
384 Users and groups on a Windows NT server are assigned a relative id (rid) which is unique for
385 the domain when the user or group is created. To convert the Windows NT user or group into
386 a  unix user or group, a mapping between rids and unix user and group ids is required. This
387 is one of the jobs that winbind performs.
388 </p><p>
389 As winbind users and groups are resolved from a server, user and group ids are allocated
390 from a specified range. This is done on a first come, first served basis, although all
391 existing users and groups will be mapped as soon as a client performs a user or  group 
392 enumeration command.  The allocated unix ids are stored in a database file under the Samba
393 lock directory and will be remembered.
394 </p><p>
395 The astute administrator will realize from this that the combination of <tt class="filename">pam_smbpass.so</tt>, 
396 <b class="command">winbindd</b>, and a distributed passdb backend, such as ldap, will allow the establishment of a
397 centrally managed, distributed user/password database that can also be used by all PAM (eg: Linux) aware
398 programs and applications. This arrangement can have particularly potent advantages compared with the use of
399 Microsoft Active Directory Service (ADS) in so far as reduction of wide area network authentication traffic.
400 </p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>
401 The rid to unix id database is the only location where the user and group  mappings are 
402 stored by winbindd.  If this file is deleted or corrupted, there is no way for winbindd
403 to determine which user and group ids correspond to Windows NT user and group rids.
404 </p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2997203"></a>Password Synchronization using pam_smbpass.so</h3></div></div><div></div></div><p>
405 pam_smbpass is a PAM module which can be used on conforming systems to
406 keep the smbpasswd (Samba password) database in sync with the unix
407 password file. PAM (Pluggable Authentication Modules) is an API supported
408 under some Unices, such as Solaris, HPUX and Linux, that provides a
409 generic interface to authentication mechanisms.
410 </p><p>
411 This module authenticates a local smbpasswd user database.  If you require
412 support for authenticating against a remote SMB server, or if you're
413 concerned about the presence of suid root binaries on your system, it is
414 recommended that you use pam_winbind instead.
415 </p><p>
416 Options recognized by this module are as follows:
417 </p><div class="table"><a name="id2997236"></a><p class="title"><b>Table 25.1. Options recognized by pam_smbpass</b></p><table summary="Options recognized by pam_smbpass" border="1"><colgroup><col><col></colgroup><tbody><tr><td align="left">debug</td><td align="left">log more debugging info</td></tr><tr><td align="left">audit</td><td align="left">like debug, but also logs unknown usernames</td></tr><tr><td align="left">use_first_pass</td><td align="left">don't prompt the user for passwords; take them from PAM_ items instead</td></tr><tr><td align="left">try_first_pass</td><td align="left">try to get the password from a previous PAM module, fall back to prompting the user</td></tr><tr><td align="left">use_authtok</td><td align="left">like try_first_pass, but *fail* if the new PAM_AUTHTOK has not been previously set. (intended for stacking password modules only)</td></tr><tr><td align="left">not_set_pass</td><td align="left">don't make passwords used by this module available to other modules.</td></tr><tr><td align="left">nodelay</td><td align="left">don't insert ~1 second delays on authentication failure.</td></tr><tr><td align="left">nullok</td><td align="left">null passwords are allowed.</td></tr><tr><td align="left">nonull</td><td align="left">null passwords are not allowed. Used to override the Samba configuration.</td></tr><tr><td align="left">migrate</td><td align="left">only meaningful in an &quot;auth&quot; context; used to update smbpasswd file with a password used for successful authentication.</td></tr><tr><td align="left">smbconf=<i class="replaceable"><tt>file</tt></i></td><td align="left">specify an alternate path to the <tt class="filename">smb.conf</tt> file.</td></tr></tbody></table></div><p>
418 </p><p>
419 Thanks go to the following people:
420 </p><table class="simplelist" border="0" summary="Simple list"><tr><td><a href="mailto:morgan@transmeta.com" target="_top">Andrew Morgan</a>, for providing the Linux-PAM
421         framework, without which none of this would have happened</td></tr><tr><td><a href="gafton@redhat.com" target="_top">Christian Gafton</a> and Andrew Morgan again, for the
422         pam_pwdb module upon which pam_smbpass was originally based</td></tr><tr><td><a href="lkcl@switchboard.net" target="_top">Luke Leighton</a> for being receptive to the idea,
423         and for the occasional good-natured complaint about the project's status
424         that keep me working on it :)</td></tr></table><p>.
425 </p><p>
426 The following are examples of the use of pam_smbpass.so in the format of Linux
427 <tt class="filename">/etc/pam.d/</tt> files structure. Those wishing to implement this
428 tool on other platforms will need to adapt this appropriately.
429 </p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2997436"></a>Password Synchronisation Configuration</h4></div></div><div></div></div><p>
430 A sample PAM configuration that shows the use of pam_smbpass to make
431 sure private/smbpasswd is kept in sync when /etc/passwd (/etc/shadow)
432 is changed.  Useful when an expired password might be changed by an
433 application (such as ssh).
434 </p><pre class="screen">
435 #%PAM-1.0
436 # password-sync
437 #
438 auth       requisite    pam_nologin.so
439 auth       required     pam_unix.so
440 account    required     pam_unix.so
441 password   requisite    pam_cracklib.so retry=3
442 password   requisite    pam_unix.so shadow md5 use_authtok try_first_pass
443 password   required     pam_smbpass.so nullok use_authtok try_first_pass
444 session    required     pam_unix.so
445 </pre></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2997469"></a>Password Migration Configuration</h4></div></div><div></div></div><p>
446 A sample PAM configuration that shows the use of pam_smbpass to migrate
447 from plaintext to encrypted passwords for Samba.  Unlike other methods,
448 this can be used for users who have never connected to Samba shares:
449 password migration takes place when users ftp in, login using ssh, pop
450 their mail, etc.
451 </p><pre class="screen">
452 #%PAM-1.0
453 # password-migration
454 #
455 auth       requisite   pam_nologin.so
456 # pam_smbpass is called IF pam_unix succeeds.
457 auth       requisite   pam_unix.so
458 auth       optional    pam_smbpass.so migrate
459 account    required    pam_unix.so
460 password   requisite   pam_cracklib.so retry=3
461 password   requisite   pam_unix.so shadow md5 use_authtok try_first_pass
462 password   optional    pam_smbpass.so nullok use_authtok try_first_pass
463 session    required    pam_unix.so
464 </pre></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2997504"></a>Mature Password Configuration</h4></div></div><div></div></div><p>
465 A sample PAM configuration for a 'mature' smbpasswd installation.
466 private/smbpasswd is fully populated, and we consider it an error if
467 the smbpasswd doesn't exist or doesn't match the Unix password.
468 </p><pre class="screen">
469 #%PAM-1.0
470 # password-mature
471 #
472 auth       requisite    pam_nologin.so
473 auth       required     pam_unix.so
474 account    required     pam_unix.so
475 password   requisite    pam_cracklib.so retry=3
476 password   requisite    pam_unix.so shadow md5 use_authtok try_first_pass
477 password   required     pam_smbpass.so use_authtok use_first_pass
478 session    required     pam_unix.so
479 </pre></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2997536"></a>Kerberos Password Integration Configuration</h4></div></div><div></div></div><p>
480 A sample PAM configuration that shows pam_smbpass used together with
481 pam_krb5.  This could be useful on a Samba PDC that is also a member of
482 a Kerberos realm.
483 </p><pre class="screen">
484 #%PAM-1.0
485 # kdc-pdc
486 #
487 auth       requisite   pam_nologin.so
488 auth       requisite   pam_krb5.so
489 auth       optional    pam_smbpass.so migrate
490 account    required    pam_krb5.so
491 password   requisite   pam_cracklib.so retry=3
492 password   optional    pam_smbpass.so nullok use_authtok try_first_pass
493 password   required    pam_krb5.so use_authtok try_first_pass
494 session    required    pam_krb5.so
495 </pre></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2997570"></a>Common Errors</h2></div></div><div></div></div><p>
496 PAM can be a very fickle and sensitive to configuration glitches. Here we look at a few cases from
497 the Samba mailing list.
498 </p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2997583"></a>pam_winbind problem</h3></div></div><div></div></div><p>
499         I have the following PAM configuration:
500         </p><p>
501 </p><pre class="screen">
502 auth required /lib/security/pam_securetty.so
503 auth sufficient /lib/security/pam_winbind.so
504 auth sufficient /lib/security/pam_unix.so use_first_pass nullok
505 auth required /lib/security/pam_stack.so service=system-auth
506 auth required /lib/security/pam_nologin.so
507 account required /lib/security/pam_stack.so service=system-auth
508 account required /lib/security/pam_winbind.so
509 password required /lib/security/pam_stack.so service=system-auth
510 </pre><p>
511 </p><p>
512         When I open a new console with [ctrl][alt][F1], then I cant log in with my user &quot;pitie&quot;.
513         I've tried with user &quot;scienceu+pitie&quot; also.
514         </p><p>
515         Answer: The problem may lie with your inclusion of <i class="parameter"><tt>pam_stack.so
516         service=system-auth</tt></i>. That file often contains a lot of stuff that may
517         duplicate what you're already doing. Try commenting out the pam_stack lines
518         for auth and account and see if things work. If they do, look at
519         <tt class="filename">/etc/pam.d/system-auth</tt> and copy only what you need from it into your
520         <tt class="filename">/etc/pam.d/login</tt> file.  Alternatively, if you want all services to use
521         winbind, you can put the winbind-specific stuff in <tt class="filename">/etc/pam.d/system-auth</tt>.
522         </p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ProfileMgmt.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="optional.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="integrate-ms-networks.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 24. Desktop Profile Management </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 26. Integrating MS Windows networks with Samba</td></tr></table></div></body></html>