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