source: vendor/3.6.23/docs-xml/Samba3-HOWTO/TOSHARG-PAM.xml

Last change on this file was 414, checked in by Herwig Bauernfeind, 15 years ago

Samba 3.5.0: Initial import

File size: 42.7 KB
Line 
1<?xml version="1.0" encoding="iso-8859-1"?>
2<!DOCTYPE chapter PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
3<chapter id="pam">
4<chapterinfo>
5 &author.jht;
6 <author>
7 <firstname>Stephen</firstname><surname>Langasek</surname>
8 <affiliation>
9 <address><email>vorlon@netexpress.net</email></address>
10 </affiliation>
11 </author>
12 <pubdate>May 31, 2003</pubdate>
13</chapterinfo>
14
15<title>PAM-Based Distributed Authentication</title>
16
17<para>
18<indexterm><primary>PAM-enabled</primary></indexterm>
19<indexterm><primary>Winbind</primary></indexterm>
20<indexterm><primary>ADS</primary></indexterm>
21<indexterm><primary>Winbind-based authentication</primary></indexterm>
22This chapter should help you to deploy Winbind-based authentication on any PAM-enabled
23UNIX/Linux system. Winbind can be used to enable user-level application access authentication
24from any MS Windows NT domain, MS Windows 200x Active Directory-based
25domain, or any Samba-based domain environment. It will also help you to configure PAM-based local host access
26controls that are appropriate to your Samba configuration.
27</para>
28
29<para>
30<indexterm><primary>PAM management</primary></indexterm>
31<indexterm><primary>pam_smbpass.so</primary></indexterm>
32In addition to knowing how to configure Winbind into PAM, you will learn generic PAM management
33possibilities and in particular how to deploy tools like <filename>pam_smbpass.so</filename> to your advantage.
34</para>
35
36<note><para>
37The use of Winbind requires more than PAM configuration alone.
38Please refer to <link linkend="winbind">Winbind: Use of Domain Accounts</link>, for further information regarding Winbind.
39</para></note>
40
41<sect1>
42<title>Features and Benefits</title>
43
44<para>
45<indexterm><primary>Sun Solaris</primary></indexterm>
46<indexterm><primary>xxxxBSD</primary></indexterm>
47<indexterm><primary>Linux</primary></indexterm>
48<indexterm><primary>Pluggable Authentication Modules</primary><see>PAM</see></indexterm>
49<indexterm><primary>/etc/passwd</primary></indexterm>
50<indexterm><primary>login</primary></indexterm>
51<indexterm><primary>passwd</primary></indexterm>
52<indexterm><primary>chown</primary></indexterm>
53A number of UNIX systems (e.g., Sun Solaris), as well as the xxxxBSD family and Linux,
54now utilize the Pluggable Authentication Modules (PAM) facility to provide all authentication,
55authorization, and resource control services. Prior to the introduction of PAM, a decision
56to use an alternative to the system password database (<filename>/etc/passwd</filename>)
57would require the provision of alternatives for all programs that provide security services.
58Such a choice would involve provision of alternatives to programs such as <command>login</command>,
59<command>passwd</command>, <command>chown</command>, and so on.
60</para>
61
62<para>
63<indexterm><primary>PAM</primary></indexterm>
64<indexterm><primary>/etc/pam.conf</primary></indexterm>
65<indexterm><primary>Solaris</primary></indexterm>
66<indexterm><primary>/etc/pam.d</primary></indexterm>
67PAM provides a mechanism that disconnects these security programs from the underlying
68authentication/authorization infrastructure. PAM is configured by making appropriate modifications to one file,
69<filename>/etc/pam.conf</filename> (Solaris), or by editing individual control files that are
70located in <filename>/etc/pam.d</filename>.
71</para>
72
73<para>
74<indexterm><primary>PAM-enabled</primary></indexterm>
75<indexterm><primary>dynamically loadable library modules</primary></indexterm>
76On PAM-enabled UNIX/Linux systems, it is an easy matter to configure the system to use any
77authentication backend so long as the appropriate dynamically loadable library modules
78are available for it. The backend may be local to the system or may be centralized on a
79remote server.
80</para>
81
82<para>
83PAM support modules are available for:
84</para>
85
86<variablelist>
87 <varlistentry><term><filename>/etc/passwd</filename></term><listitem>
88 <para>
89<indexterm><primary>/etc/passwd</primary></indexterm>
90<indexterm><primary>PAM modules</primary></indexterm>
91<indexterm><primary>pam_unix.so</primary></indexterm>
92<indexterm><primary>pam_unix2.so</primary></indexterm>
93<indexterm><primary>pam_pwdb.so</primary></indexterm>
94<indexterm><primary>pam_userdb.so</primary></indexterm>
95 There are several PAM modules that interact with this standard UNIX user database. The most common are called
96 <filename>pam_unix.so</filename>, <filename>pam_unix2.so</filename>, <filename>pam_pwdb.so</filename> and
97 <filename>pam_userdb.so</filename>.
98 </para>
99 </listitem></varlistentry>
100
101 <varlistentry><term>Kerberos</term><listitem>
102 <para>
103<indexterm><primary>pam_krb5.so</primary></indexterm>
104<indexterm><primary>Kerberos</primary></indexterm>
105<indexterm><primary>Heimdal</primary></indexterm>
106<indexterm><primary>MIT Kerberos</primary></indexterm>
107<indexterm><primary>ADS</primary></indexterm>
108 The <filename>pam_krb5.so</filename> module allows the use of any Kerberos-compliant server.
109 This tool is used to access MIT Kerberos, Heimdal Kerberos, and potentially
110 Microsoft Active Directory (if enabled).
111 </para>
112 </listitem></varlistentry>
113
114 <varlistentry><term>LDAP</term><listitem>
115 <para>
116<indexterm><primary>LDAP</primary></indexterm>
117<indexterm><primary>pam_ldap.so</primary></indexterm>
118<indexterm><primary>OpenLDAP</primary></indexterm>
119<indexterm><primary>Sun ONE iDentity server</primary></indexterm>
120<indexterm><primary>Novell eDirectory server</primary></indexterm>
121<indexterm><primary>Microsoft Active Directory</primary></indexterm>
122 The <filename>pam_ldap.so</filename> module allows the use of any LDAP v2- or v3-compatible backend
123 server. Commonly used LDAP backend servers include OpenLDAP v2.0 and v2.1,
124 Sun ONE iDentity server, Novell eDirectory server, and Microsoft Active Directory.
125 </para>
126 </listitem></varlistentry>
127
128 <varlistentry><term>NetWare Bindery</term><listitem>
129 <para>
130<indexterm><primary>NetWare Bindery</primary></indexterm>
131<indexterm><primary>pam_ncp_auth.so</primary></indexterm>
132<indexterm><primary>bindery-enabled</primary></indexterm>
133<indexterm><primary>NetWare Core Protocol-based server</primary></indexterm>
134 The <filename>pam_ncp_auth.so</filename> module allows authentication off any bindery-enabled
135 NetWare Core Protocol-based server.
136 </para>
137 </listitem></varlistentry>
138
139 <varlistentry><term>SMB Password</term><listitem>
140 <para>
141<indexterm><primary>SMB Password</primary></indexterm>
142<indexterm><primary>pam_smbpass.so</primary></indexterm>
143<indexterm><primary>passdb backend</primary></indexterm>
144 This module, called <filename>pam_smbpass.so</filename>, allows user authentication of
145 the passdb backend that is configured in the Samba &smb.conf; file.
146 </para>
147 </listitem></varlistentry>
148
149 <varlistentry><term>SMB Server</term><listitem>
150 <para>
151<indexterm><primary>SMB Server</primary></indexterm>
152<indexterm><primary>pam_smb_auth.so</primary></indexterm>
153 The <filename>pam_smb_auth.so</filename> module is the original MS Windows networking authentication
154 tool. This module has been somewhat outdated by the Winbind module.
155 </para>
156 </listitem></varlistentry>
157
158 <varlistentry><term>Winbind</term><listitem>
159 <para>
160<indexterm><primary>Winbind</primary></indexterm>
161<indexterm><primary>pam_winbind.so</primary></indexterm>
162<indexterm><primary>domain controller</primary></indexterm>
163<indexterm><primary>authentication</primary></indexterm>
164 The <filename>pam_winbind.so</filename> module allows Samba to obtain authentication from any
165 MS Windows domain controller. It can just as easily be used to authenticate
166 users for access to any PAM-enabled application.
167 </para>
168 </listitem></varlistentry>
169
170 <varlistentry><term>RADIUS</term><listitem>
171 <para>
172<indexterm><primary>Remote Access Dial-In User Service</primary><see>RADIUS</see></indexterm>
173 There is a PAM RADIUS (Remote Access Dial-In User Service) authentication
174 module. In most cases, administrators need to locate the source code
175 for this tool and compile and install it themselves. RADIUS protocols are
176 used by many routers and terminal servers.
177 </para>
178 </listitem></varlistentry>
179</variablelist>
180
181<para>
182<indexterm><primary>pam_smbpasswd.so</primary></indexterm>
183<indexterm><primary>pam_winbind.so</primary></indexterm>
184Of the modules listed, Samba provides the <filename>pam_smbpasswd.so</filename> and the
185<filename>pam_winbind.so</filename> modules alone.
186</para>
187
188<para>
189<indexterm><primary>wide-area network bandwidth</primary></indexterm>
190<indexterm><primary>efficient authentication</primary></indexterm>
191<indexterm><primary>PAM-capable</primary></indexterm>
192<indexterm><primary>centrally managed</primary></indexterm>
193Once configured, these permit a remarkable level of flexibility in the location and use
194of distributed Samba domain controllers that can provide wide-area network bandwidth,
195efficient authentication services for PAM-capable systems. In effect, this allows the
196deployment of centrally managed and maintained distributed authentication from a
197single-user account database.
198</para>
199
200</sect1>
201
202<sect1>
203<title>Technical Discussion</title>
204
205<para>
206<indexterm><primary>PAM</primary></indexterm>
207<indexterm><primary>privilege-granting applications</primary></indexterm>
208<indexterm><primary>/etc/pam.conf</primary></indexterm>
209<indexterm><primary>/etc/pam.d/</primary></indexterm>
210PAM is designed to provide system administrators with a great deal of flexibility in
211configuration of the privilege-granting applications of their system. The local
212configuration of system security controlled by PAM is contained in one of two places:
213either the single system file <filename>/etc/pam.conf</filename> or the
214<filename>/etc/pam.d/</filename> directory.
215</para>
216
217<sect2>
218<title>PAM Configuration Syntax</title>
219
220<para>
221<indexterm><primary>PAM-specific tokens</primary></indexterm>
222<indexterm><primary>case sensitivity</primary></indexterm>
223In this section we discuss the correct syntax of and generic options respected by entries to these files.
224PAM-specific tokens in the configuration file are case insensitive. The module paths, however, are case
225sensitive, since they indicate a file's name and reflect the case dependence of typical file systems. The
226case sensitivity of the arguments to any given module is defined for each module in turn.
227</para>
228
229<para>
230In addition to the lines described below, there are two special characters provided for the convenience
231of the system administrator: comments are preceded by a <quote>#</quote> and extend to the next end-of-line; also,
232module specification lines may be extended with a <quote>\</quote>-escaped newline.
233</para>
234
235<para>
236<indexterm><primary>PAM authentication module</primary></indexterm>
237<indexterm><primary>/lib/security</primary></indexterm>
238If the PAM authentication module (loadable link library file) is located in the
239default location, then it is not necessary to specify the path. In the case of
240Linux, the default location is <filename>/lib/security</filename>. If the module
241is located outside the default, then the path must be specified as:
242<programlisting>
243auth required /other_path/pam_strange_module.so
244</programlisting>
245</para>
246
247<sect3>
248<title>Anatomy of <filename>/etc/pam.d</filename> Entries</title>
249
250<para>
251The remaining information in this subsection was taken from the documentation of the Linux-PAM
252project. For more information on PAM, see
253<ulink url="http://ftp.kernel.org/pub/linux/libs/pam/">the Official Linux-PAM home page</ulink>.
254</para>
255
256<para>
257<indexterm><primary>/etc/pam.conf</primary></indexterm>
258A general configuration line of the <filename>/etc/pam.conf</filename> file has the following form:
259<programlisting>
260service-name module-type control-flag module-path args
261</programlisting>
262</para>
263
264<para>
265We explain the meaning of each of these tokens. The second (and more recently adopted)
266way of configuring Linux-PAM is via the contents of the <filename>/etc/pam.d/</filename> directory.
267Once we have explained the meaning of the tokens, we describe this method.
268</para>
269
270<variablelist>
271 <varlistentry><term>service-name</term><listitem>
272 <para>
273<indexterm><primary>ftpd</primary></indexterm>
274<indexterm><primary>rlogind</primary></indexterm>
275<indexterm><primary>su</primary></indexterm>
276 The name of the service associated with this entry. Frequently, the service-name is the conventional
277 name of the given application &smbmdash; for example, <command>ftpd</command>, <command>rlogind</command> and
278 <command>su</command>, and so on.
279 </para>
280
281 <para>
282 There is a special service-name reserved for defining a default authentication mechanism. It has
283 the name <parameter>OTHER</parameter> and may be specified in either lower- or uppercase characters.
284 Note, when there is a module specified for a named service, the <parameter>OTHER</parameter>
285 entries are ignored.
286 </para>
287 </listitem>
288 </varlistentry>
289
290 <varlistentry><term>module-type</term><listitem>
291 <para>
292 One of (currently) four types of module. The four types are as follows:
293 </para>
294
295 <itemizedlist>
296 <listitem><para>
297<indexterm><primary>auth</primary></indexterm>
298<indexterm><primary>/etc/groups</primary></indexterm>
299 <parameter>auth:</parameter> This module type provides two aspects of authenticating the user.
300 It establishes that the user is who he or she claims to be by instructing the application
301 to prompt the user for a password or other means of identification. Second, the module can
302 grant group membership (independently of the <filename>/etc/groups</filename> file)
303 or other privileges through its credential-granting properties.
304 </para></listitem>
305
306 <listitem><para>
307<indexterm><primary>account</primary></indexterm>
308<indexterm><primary>non-authentication-based account management</primary></indexterm>
309 <parameter>account:</parameter> This module performs non-authentication-based account management.
310 It is typically used to restrict/permit access to a service based on the time of day, currently
311 available system resources (maximum number of users), or perhaps the location of the user
312 login. For example, the <quote>root</quote> login may be permitted only on the console.
313 </para></listitem>
314
315 <listitem><para>
316<indexterm><primary>session</primary></indexterm>
317 <parameter>session:</parameter> Primarily, this module is associated with doing things that need
318 to be done for the user before and after he or she can be given service. Such things include logging
319 information concerning the opening and closing of some data exchange with a user, mounting
320 directories, and so on.
321 </para></listitem>
322
323 <listitem><para>
324<indexterm><primary>password</primary></indexterm>
325 <parameter>password:</parameter> This last module type is required for updating the authentication
326 token associated with the user. Typically, there is one module for each
327 <quote>challenge/response</quote> authentication <parameter>(auth)</parameter> module type.
328 </para></listitem>
329 </itemizedlist>
330 </listitem>
331 </varlistentry>
332
333 <varlistentry><term>control-flag</term><listitem>
334 <para>
335 The control-flag is used to indicate how the PAM library will react to the success or failure of the
336 module it is associated with. Since modules can be stacked (modules of the same type execute in series,
337 one after another), the control-flags determine the relative importance of each module. The application
338 is not made aware of the individual success or failure of modules listed in the
339 <filename>/etc/pam.conf</filename> file. Instead, it receives a summary success or fail response from
340 the Linux-PAM library. The order of execution of these modules is that of the entries in the
341 <filename>/etc/pam.conf</filename> file; earlier entries are executed before later ones.
342 As of Linux-PAM v0.60, this control-flag can be defined with one of two syntaxes.
343 </para>
344
345 <para>
346<indexterm><primary>required</primary></indexterm>
347<indexterm><primary>requisite</primary></indexterm>
348<indexterm><primary>sufficient</primary></indexterm>
349<indexterm><primary>optional</primary></indexterm>
350 The simpler (and historical) syntax for the control-flag is a single keyword defined to indicate the
351 severity of concern associated with the success or failure of a specific module. There are four such
352 keywords: <parameter>required</parameter>, <parameter>requisite</parameter>,
353 <parameter>sufficient</parameter>, and <parameter>optional</parameter>.
354 </para>
355
356 <para>
357 The Linux-PAM library interprets these keywords in the following manner:
358 </para>
359
360 <itemizedlist>
361 <listitem><para>
362 <parameter>required:</parameter> This indicates that the success of the module is required for the
363 module-type facility to succeed. Failure of this module will not be apparent to the user until all
364 of the remaining modules (of the same module-type) have been executed.
365 </para></listitem>
366
367 <listitem><para>
368 <parameter>requisite:</parameter> Like required, except that if such a module returns a
369 failure, control is directly returned to the application. The return value is that associated with
370 the first required or requisite module to fail. This flag can be used to protect against the
371 possibility of a user getting the opportunity to enter a password over an unsafe medium. It is
372 conceivable that such behavior might inform an attacker of valid accounts on a system. This
373 possibility should be weighed against the not insignificant concerns of exposing a sensitive
374 password in a hostile environment.
375 </para></listitem>
376
377 <listitem><para>
378 <parameter>sufficient:</parameter> The success of this module is deemed <parameter>sufficient</parameter> to satisfy
379 the Linux-PAM library that this module-type has succeeded in its purpose. In the event that no
380 previous required module has failed, no more <quote>stacked</quote> modules of this type are invoked.
381 (In this case, subsequent required modules are not invoked). A failure of this module is not deemed
382 as fatal to satisfying the application that this module-type has succeeded.
383 </para></listitem>
384
385 <listitem><para>
386 <parameter>optional:</parameter> As its name suggests, this control-flag marks the module as not
387 being critical to the success or failure of the user's application for service. In general,
388 Linux-PAM ignores such a module when determining if the module stack will succeed or fail.
389 However, in the absence of any definite successes or failures of previous or subsequent stacked
390 modules, this module will determine the nature of the response to the application. One example of
391 this latter case is when the other modules return something like PAM_IGNORE.
392 </para></listitem>
393 </itemizedlist>
394
395 <para>
396 The more elaborate (newer) syntax is much more specific and gives the administrator a great deal of control
397 over how the user is authenticated. This form of the control-flag is delimited with square brackets and
398 consists of a series of <parameter>value=action</parameter> tokens:
399 </para>
400
401<para><programlisting>
402[value1=action1 value2=action2 ...]
403</programlisting></para>
404
405 <para>
406 Here, <parameter>value1</parameter> is one of the following return values:
407<screen>
408<parameter>success; open_err; symbol_err; service_err; system_err; buf_err;</parameter>
409<parameter>perm_denied; auth_err; cred_insufficient; authinfo_unavail;</parameter>
410<parameter>user_unknown; maxtries; new_authtok_reqd; acct_expired; session_err;</parameter>
411<parameter>cred_unavail; cred_expired; cred_err; no_module_data; conv_err;</parameter>
412<parameter>authtok_err; authtok_recover_err; authtok_lock_busy;</parameter>
413<parameter>authtok_disable_aging; try_again; ignore; abort; authtok_expired;</parameter>
414<parameter>module_unknown; bad_item;</parameter> and <parameter>default</parameter>.
415</screen>
416</para>
417
418 <para>
419 The last of these (<parameter>default</parameter>) can be used to set the action for those return values that are not explicitly defined.
420 </para>
421
422 <para>
423 The <parameter>action1</parameter> can be a positive integer or one of the following tokens:
424 <parameter>ignore</parameter>; <parameter>ok</parameter>; <parameter>done</parameter>;
425 <parameter>bad</parameter>; <parameter>die</parameter>; and <parameter>reset</parameter>.
426 A positive integer, J, when specified as the action, can be used to indicate that the next J modules of the
427 current module-type will be skipped. In this way, the administrator can develop a moderately sophisticated
428 stack of modules with a number of different paths of execution. Which path is taken can be determined by the
429 reactions of individual modules.
430 </para>
431
432 <itemizedlist>
433 <listitem><para>
434 <parameter>ignore:</parameter> When used with a stack of modules, the module's return status will not
435 contribute to the return code the application obtains.
436 </para></listitem>
437
438 <listitem><para>
439 <parameter>bad:</parameter> This action indicates that the return code should be thought of as indicative
440 of the module failing. If this module is the first in the stack to fail, its status value will be used
441 for that of the whole stack.
442 </para></listitem>
443
444 <listitem><para>
445 <parameter>die:</parameter> Equivalent to bad with the side effect of terminating the module stack and
446 PAM immediately returning to the application.
447 </para></listitem>
448
449 <listitem><para>
450 <parameter>ok:</parameter> This tells PAM that the administrator thinks this return code should
451 contribute directly to the return code of the full stack of modules. In other words, if the former
452 state of the stack would lead to a return of PAM_SUCCESS, the module's return code will override
453 this value. Note, if the former state of the stack holds some value that is indicative of a module's
454 failure, this <parameter>ok</parameter> value will not be used to override that value.
455 </para></listitem>
456
457 <listitem><para>
458 <parameter>done:</parameter> Equivalent to <parameter>ok</parameter> with the side effect of terminating the module stack and
459 PAM immediately returning to the application.
460 </para></listitem>
461
462 <listitem><para>
463 <parameter>reset:</parameter> Clears all memory of the state of the module stack and starts again with
464 the next stacked module.
465 </para></listitem>
466 </itemizedlist>
467
468 <para>
469 Each of the four keywords, <parameter>required</parameter>; <parameter>requisite</parameter>;
470 <parameter>sufficient</parameter>; and <parameter>optional</parameter>, have an equivalent expression in terms
471 of the [...] syntax. They are as follows:
472 </para>
473
474 <para>
475 <itemizedlist>
476 <listitem><para>
477 <parameter>required</parameter> is equivalent to <parameter>[success=ok new_authtok_reqd=ok ignore=ignore default=bad]</parameter>.
478 </para></listitem>
479
480 <listitem><para>
481 <parameter>requisite</parameter> is equivalent to <parameter>[success=ok new_authtok_reqd=ok ignore=ignore default=die]</parameter>.
482 </para></listitem>
483
484 <listitem><para>
485 <parameter>sufficient</parameter> is equivalent to <parameter>[success=done new_authtok_reqd=done default=ignore]</parameter>.
486 </para></listitem>
487
488 <listitem><para>
489 <parameter>optional</parameter> is equivalent to <parameter>[success=ok new_authtok_reqd=ok default=ignore]</parameter>.
490 </para></listitem>
491 </itemizedlist>
492 </para>
493
494 <para>
495 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,
496 the notion of client plug-in agents was introduced. This makes it possible for PAM to support
497 machine-machine authentication using the transport protocol inherent to the client/server application. With the
498 <parameter>[ ... value=action ... ]</parameter> control syntax, it is possible for an application to be configured
499 to support binary prompts with compliant clients, but to gracefully fail over into an alternative authentication
500 mode for legacy applications.
501 </para>
502 </listitem>
503 </varlistentry>
504
505 <varlistentry><term>module-path</term><listitem>
506 <para>
507 The pathname of the dynamically loadable object file; the pluggable module itself. If the first character of the
508 module path is <quote>/</quote>, it is assumed to be a complete path. If this is not the case, the given module path is appended
509 to the default module path: <filename>/lib/security</filename> (but see the previous notes).
510 </para>
511
512 <para>
513 The arguments are a list of tokens that are passed to the module when it is invoked, much like arguments to a typical
514 Linux shell command. Generally, valid arguments are optional and are specific to any given module. Invalid arguments
515 are ignored by a module; however, when encountering an invalid argument, the module is required to write an error
516 to syslog(3). For a list of generic options, see the next section.
517 </para>
518
519 <para>
520 If you wish to include spaces in an argument, you should surround that argument with square brackets. For example:
521 </para>
522
523<para><programlisting>
524squid auth required pam_mysql.so user=passwd_query passwd=mada \
525db=eminence [query=select user_name from internet_service where \
526user_name=<quote>%u</quote> and password=PASSWORD(<quote>%p</quote>) and service=<quote>web_proxy</quote>]
527</programlisting></para>
528
529 <para>
530 When using this convention, you can include <quote>[</quote> characters inside the string, and if you wish to have a <quote>]</quote>
531 character inside the string that will survive the argument parsing, you should use <quote>\[</quote>. In other words,
532 </para>
533
534<para><programlisting>
535[..[..\]..] --> ..[..]..
536</programlisting></para>
537
538 <para>
539 Any line in one of the configuration files that is not formatted correctly will generally tend (erring on the
540 side of caution) to make the authentication process fail. A corresponding error is written to the system log files
541 with a call to syslog(3).
542 </para>
543 </listitem>
544 </varlistentry>
545</variablelist>
546
547</sect3>
548
549</sect2>
550
551<sect2>
552<title>Example System Configurations</title>
553
554<para>
555The following is an example <filename>/etc/pam.d/login</filename> configuration file.
556This example had all options uncommented and is probably not usable
557because it stacks many conditions before allowing successful completion
558of the login process. Essentially, all conditions can be disabled
559by commenting them out, except the calls to <filename>pam_pwdb.so</filename>.
560</para>
561
562<sect3>
563<title>PAM: Original Login Config</title>
564
565<para>
566 <programlisting>
567#%PAM-1.0
568# The PAM configuration file for the <quote>login</quote> service
569#
570auth required pam_securetty.so
571auth required pam_nologin.so
572# auth required pam_dialup.so
573# auth optional pam_mail.so
574auth required pam_pwdb.so shadow md5
575# account requisite pam_time.so
576account required pam_pwdb.so
577session required pam_pwdb.so
578# session optional pam_lastlog.so
579# password required pam_cracklib.so retry=3
580password required pam_pwdb.so shadow md5
581</programlisting>
582</para>
583
584</sect3>
585
586<sect3>
587<title>PAM: Login Using <filename>pam_smbpass</filename></title>
588
589<para>
590PAM allows use of replaceable modules. Those available on a sample system include:
591</para>
592
593<para><prompt>$</prompt><userinput>/bin/ls /lib/security</userinput>
594<programlisting>
595pam_access.so pam_ftp.so pam_limits.so
596pam_ncp_auth.so pam_rhosts_auth.so pam_stress.so
597pam_cracklib.so pam_group.so pam_listfile.so
598pam_nologin.so pam_rootok.so pam_tally.so
599pam_deny.so pam_issue.so pam_mail.so
600pam_permit.so pam_securetty.so pam_time.so
601pam_dialup.so pam_lastlog.so pam_mkhomedir.so
602pam_pwdb.so pam_shells.so pam_unix.so
603pam_env.so pam_ldap.so pam_motd.so
604pam_radius.so pam_smbpass.so pam_unix_acct.so
605pam_wheel.so pam_unix_auth.so pam_unix_passwd.so
606pam_userdb.so pam_warn.so pam_unix_session.so
607</programlisting></para>
608
609<para>
610The following example for the login program replaces the use of
611the <filename>pam_pwdb.so</filename> module that uses the system
612password database (<filename>/etc/passwd</filename>,
613<filename>/etc/shadow</filename>, <filename>/etc/group</filename>) with
614the module <filename>pam_smbpass.so</filename>, which uses the Samba
615database containing the Microsoft MD4 encrypted password
616hashes. This database is stored either in
617<filename>/usr/local/samba/private/smbpasswd</filename>,
618<filename>/etc/samba/smbpasswd</filename> or in
619<filename>/etc/samba.d/smbpasswd</filename>, depending on the
620Samba implementation for your UNIX/Linux system. The
621<filename>pam_smbpass.so</filename> module is provided by
622Samba version 2.2.1 or later. It can be compiled by specifying the
623<option>--with-pam_smbpass</option> options when running Samba's
624<command>configure</command> script. For more information
625on the <filename>pam_smbpass</filename> module, see the documentation
626in the <filename>source/pam_smbpass</filename> directory of the Samba
627source distribution.
628</para>
629
630<para>
631 <programlisting>
632#%PAM-1.0
633# The PAM configuration file for the <quote>login</quote> service
634#
635auth required pam_smbpass.so nodelay
636account required pam_smbpass.so nodelay
637session required pam_smbpass.so nodelay
638password required pam_smbpass.so nodelay
639</programlisting></para>
640
641<para>
642The following is the PAM configuration file for a particular
643Linux system. The default condition uses <filename>pam_pwdb.so</filename>.
644</para>
645
646<para>
647 <programlisting>
648#%PAM-1.0
649# The PAM configuration file for the <quote>samba</quote> service
650#
651auth required pam_pwdb.so nullok nodelay shadow audit
652account required pam_pwdb.so audit nodelay
653session required pam_pwdb.so nodelay
654password required pam_pwdb.so shadow md5
655</programlisting></para>
656
657<para>
658In the following example, the decision has been made to use the
659<command>smbpasswd</command> database even for basic Samba authentication. Such a
660decision could also be made for the <command>passwd</command> program and would
661thus allow the <command>smbpasswd</command> passwords to be changed using the
662<command>passwd</command> program:
663</para>
664
665<para>
666 <programlisting>
667#%PAM-1.0
668# The PAM configuration file for the <quote>samba</quote> service
669#
670auth required pam_smbpass.so nodelay
671account required pam_pwdb.so audit nodelay
672session required pam_pwdb.so nodelay
673password required pam_smbpass.so nodelay smbconf=/etc/samba.d/smb.conf
674</programlisting>
675</para>
676
677<note><para>PAM allows stacking of authentication mechanisms. It is
678also possible to pass information obtained within one PAM module through
679to the next module in the PAM stack. Please refer to the documentation for
680your particular system implementation for details regarding the specific
681capabilities of PAM in this environment. Some Linux implementations also
682provide the <filename>pam_stack.so</filename> module that allows all
683authentication to be configured in a single central file. The
684<filename>pam_stack.so</filename> method has some devoted followers
685on the basis that it allows for easier administration. As with all issues in
686life, though, every decision has trade-offs, so you may want to examine the
687PAM documentation for further helpful information.
688</para></note>
689
690</sect3>
691
692</sect2>
693
694<sect2>
695<title>&smb.conf; PAM Configuration</title>
696
697<para>
698There is an option in &smb.conf; called <smbconfoption name="obey pam restrictions"/>.
699The following is from the online help for this option in SWAT:
700</para>
701
702<blockquote>
703<para>
704When Samba is configured to enable PAM support (i.e., <option>--with-pam</option>), this parameter will
705control whether or not Samba should obey PAM's account and session management directives. The default behavior
706is to use PAM for clear-text authentication only and to ignore any account or session management. Samba always
707ignores PAM for authentication in the case of <smbconfoption name="encrypt passwords">yes</smbconfoption>.
708The reason is that PAM modules cannot support the challenge/response authentication mechanism needed in the presence of SMB
709password encryption.
710</para>
711
712<para>Default: <smbconfoption name="obey pam restrictions">no</smbconfoption></para>
713</blockquote>
714
715</sect2>
716
717<sect2>
718<title>Remote CIFS Authentication Using <filename>winbindd.so</filename></title>
719
720<para>
721All operating systems depend on the provision of user credentials acceptable to the platform.
722UNIX requires the provision of a user identifier (UID) as well as a group identifier (GID).
723These are both simple integer numbers that are obtained from a password backend such
724as <filename>/etc/passwd</filename>.
725</para>
726
727<para>
728Users and groups on a Windows NT server are assigned a relative ID (RID) which is unique for
729the domain when the user or group is created. To convert the Windows NT user or group into
730a UNIX user or group, a mapping between RIDs and UNIX user and group IDs is required. This
731is one of the jobs that winbind performs.
732</para>
733
734<para>
735As winbind users and groups are resolved from a server, user and group IDs are allocated
736from a specified range. This is done on a first come, first served basis, although all
737existing users and groups will be mapped as soon as a client performs a user or group
738enumeration command. The allocated UNIX IDs are stored in a database file under the Samba
739lock directory and will be remembered.
740</para>
741
742<para>
743The astute administrator will realize from this that the combination of <filename>pam_smbpass.so</filename>,
744<command>winbindd</command>, and a distributed <smbconfoption name="passdb backend"></smbconfoption>
745such as <parameter>ldap</parameter> will allow the establishment of a centrally managed, distributed user/password
746database that can also be used by all PAM-aware (e.g., Linux) programs and applications. This arrangement can have
747particularly potent advantages compared with the use of Microsoft Active Directory Service (ADS) insofar as
748the reduction of wide-area network authentication traffic.
749</para>
750
751<warning><para>
752The RID to UNIX ID database is the only location where the user and group mappings are
753stored by <command>winbindd</command>. If this file is deleted or corrupted, there is no way for <command>winbindd</command>
754to determine which user and group IDs correspond to Windows NT user and group RIDs.
755</para></warning>
756
757</sect2>
758
759<sect2>
760<title>Password Synchronization Using <filename>pam_smbpass.so</filename></title>
761
762<para>
763<filename>pam_smbpass</filename> is a PAM module that can be used on conforming systems to
764keep the <filename>smbpasswd</filename> (Samba password) database in sync with the UNIX
765password file. PAM is an API supported
766under some UNIX operating systems, such as Solaris, HPUX, and Linux, that provides a
767generic interface to authentication mechanisms.
768</para>
769
770<para>
771This module authenticates a local <filename>smbpasswd</filename> user database. If you require
772support for authenticating against a remote SMB server, or if you are
773concerned about the presence of SUID root binaries on your system, it is
774recommended that you use <filename>pam_winbind</filename> instead.
775</para>
776
777<para>
778Options recognized by this module are shown in <link linkend="smbpassoptions">next table</link>.
779<table frame="all" id="smbpassoptions">
780 <title>Options recognized by <parameter>pam_smbpass</parameter></title>
781 <tgroup cols="2" align="left">
782 <colspec align="left"/>
783 <colspec align="justify" colwidth="1*"/>
784 <tbody>
785 <row><entry>debug</entry><entry>Log more debugging info.</entry></row>
786 <row><entry>audit</entry><entry>Like debug, but also logs unknown usernames.</entry></row>
787 <row><entry>use_first_pass</entry><entry>Do not prompt the user for passwords; take them from PAM_ items instead.</entry></row>
788 <row><entry>try_first_pass</entry><entry>Try to get the password from a previous PAM module; fall back to prompting the user.</entry></row>
789 <row><entry>use_authtok</entry>
790 <entry>Like try_first_pass, but *fail* if the new PAM_AUTHTOK has not been previously set (intended for stacking password modules only).</entry></row>
791 <row><entry>not_set_pass</entry><entry>Do not make passwords used by this module available to other modules.</entry></row>
792 <row><entry>nodelay</entry><entry>dDo not insert ~1-second delays on authentication failure.</entry></row>
793 <row><entry>nullok</entry><entry>Null passwords are allowed.</entry></row>
794 <row><entry>nonull</entry><entry>Null passwords are not allowed. Used to override the Samba configuration.</entry></row>
795 <row><entry>migrate</entry><entry>Only meaningful in an <quote>auth</quote> context; used to update smbpasswd file with a password used for successful authentication.</entry></row>
796 <row><entry>smbconf=<replaceable>file</replaceable></entry><entry>Specify an alternate path to the &smb.conf; file.</entry></row>
797 </tbody>
798</tgroup>
799</table>
800</para>
801
802<para>
803The following are examples of the use of <filename>pam_smbpass.so</filename> in the format of the Linux
804<filename>/etc/pam.d/</filename> files structure. Those wishing to implement this
805tool on other platforms will need to adapt this appropriately.
806</para>
807
808<sect3>
809<title>Password Synchronization Configuration</title>
810
811<para>
812The following is a sample PAM configuration that shows the use of pam_smbpass to make
813sure <filename>private/smbpasswd</filename> is kept in sync when <filename>/etc/passwd (/etc/shadow)</filename>
814is changed. It is useful when an expired password might be changed by an
815application (such as <command>ssh</command>).
816</para>
817
818<para>
819 <programlisting>
820#%PAM-1.0
821# password-sync
822#
823auth requisite pam_nologin.so
824auth required pam_unix.so
825account required pam_unix.so
826password requisite pam_cracklib.so retry=3
827password requisite pam_unix.so shadow md5 use_authtok try_first_pass
828password required pam_smbpass.so nullok use_authtok try_first_pass
829session required pam_unix.so
830</programlisting></para>
831</sect3>
832
833<sect3>
834<title>Password Migration Configuration</title>
835
836<para>
837The following PAM configuration shows the use of <filename>pam_smbpass</filename> to migrate
838from plaintext to encrypted passwords for Samba. Unlike other methods,
839this can be used for users who have never connected to Samba shares:
840password migration takes place when users <command>ftp</command> in, login using <command>ssh</command>, pop
841their mail, and so on.
842</para>
843
844<para>
845 <programlisting>
846#%PAM-1.0
847# password-migration
848#
849auth requisite pam_nologin.so
850# pam_smbpass is called IF pam_unix succeeds.
851auth requisite pam_unix.so
852auth optional pam_smbpass.so migrate
853account required pam_unix.so
854password requisite pam_cracklib.so retry=3
855password requisite pam_unix.so shadow md5 use_authtok try_first_pass
856password optional pam_smbpass.so nullok use_authtok try_first_pass
857session required pam_unix.so
858</programlisting></para>
859</sect3>
860
861<sect3>
862<title>Mature Password Configuration</title>
863
864<para>
865The following is a sample PAM configuration for a mature <filename>smbpasswd</filename> installation.
866<filename>private/smbpasswd</filename> is fully populated, and we consider it an error if
867the SMB password does not exist or does not match the UNIX password.
868</para>
869
870<para>
871<programlisting>
872#%PAM-1.0
873# password-mature
874#
875auth requisite pam_nologin.so
876auth required pam_unix.so
877account required pam_unix.so
878password requisite pam_cracklib.so retry=3
879password requisite pam_unix.so shadow md5 use_authtok try_first_pass
880password required pam_smbpass.so use_authtok use_first_pass
881session required pam_unix.so
882</programlisting></para>
883</sect3>
884
885<sect3>
886<title>Kerberos Password Integration Configuration</title>
887
888<para>
889The following is a sample PAM configuration that shows <parameter>pam_smbpass</parameter> used together with
890<parameter>pam_krb5</parameter>. This could be useful on a Samba PDC that is also a member of
891a Kerberos realm.
892</para>
893
894<para>
895 <programlisting>
896#%PAM-1.0
897# kdc-pdc
898#
899auth requisite pam_nologin.so
900auth requisite pam_krb5.so
901auth optional pam_smbpass.so migrate
902account required pam_krb5.so
903password requisite pam_cracklib.so retry=3
904password optional pam_smbpass.so nullok use_authtok try_first_pass
905password required pam_krb5.so use_authtok try_first_pass
906session required pam_krb5.so
907</programlisting></para>
908
909</sect3>
910
911</sect2>
912
913</sect1>
914
915<sect1>
916<title>Common Errors</title>
917
918<para>
919PAM can be fickle and sensitive to configuration glitches. Here we look at a few cases from
920the Samba mailing list.
921</para>
922
923 <sect2>
924 <title>pam_winbind Problem</title>
925
926 <para>
927 A user reported, <emphasis>I have the following PAM configuration</emphasis>:
928 </para>
929
930<para>
931<programlisting>
932auth required /lib/security/pam_securetty.so
933auth sufficient /lib/security/pam_winbind.so
934auth sufficient /lib/security/pam_unix.so use_first_pass nullok
935auth required /lib/security/pam_stack.so service=system-auth
936auth required /lib/security/pam_nologin.so
937account required /lib/security/pam_stack.so service=system-auth
938account required /lib/security/pam_winbind.so
939password required /lib/security/pam_stack.so service=system-auth
940</programlisting>
941</para>
942
943 <para>
944 <emphasis>When I open a new console with [ctrl][alt][F1], I can't log in with my user <quote>pitie.</quote>
945 I have tried with user <quote>scienceu\pitie</quote> also.</emphasis>
946 </para>
947
948 <para>
949 The problem may lie with the inclusion of <parameter>pam_stack.so
950 service=system-auth</parameter>. That file often contains a lot of stuff that may
951 duplicate what you are already doing. Try commenting out the <parameter>pam_stack</parameter> lines
952 for <parameter>auth</parameter> and <parameter>account</parameter> and see if things work. If they do, look at
953 <filename>/etc/pam.d/system-auth</filename> and copy only what you need from it into your
954 <filename>/etc/pam.d/login</filename> file. Alternatively, if you want all services to use
955 Winbind, you can put the Winbind-specific stuff in <filename>/etc/pam.d/system-auth</filename>.
956 </para>
957
958 </sect2>
959
960 <sect2>
961 <title>Winbind Is Not Resolving Users and Groups</title>
962
963 <para>
964 <quote>
965 My &smb.conf; file is correctly configured. I have specified
966 <smbconfoption name="idmap uid">12000</smbconfoption>
967 and <smbconfoption name="idmap gid">3000-3500,</smbconfoption>
968 and <command>winbind</command> is running. When I do the following it all works fine.
969 </quote>
970 </para>
971
972<para><screen>
973&rootprompt;<userinput>wbinfo -u</userinput>
974MIDEARTH\maryo
975MIDEARTH\jackb
976MIDEARTH\ameds
977...
978MIDEARTH\root
979
980&rootprompt;<userinput>wbinfo -g</userinput>
981MIDEARTH\Domain Users
982MIDEARTH\Domain Admins
983MIDEARTH\Domain Guests
984...
985MIDEARTH\Accounts
986
987&rootprompt;<userinput>getent passwd</userinput>
988root:x:0:0:root:/root:/bin/bash
989bin:x:1:1:bin:/bin:/bin/bash
990...
991maryo:x:15000:15003:Mary Orville:/home/MIDEARTH/maryo:/bin/false
992</screen></para>
993
994 <para>
995 <quote>
996 But this command fails:
997 </quote>
998<screen>
999&rootprompt;<userinput>chown maryo a_file</userinput>
1000chown: 'maryo': invalid user
1001</screen>
1002 <quote>This is driving me nuts! What can be wrong?</quote>
1003 </para>
1004
1005 <para>
1006 Your system is likely running <command>nscd</command>, the name service
1007 caching daemon. Shut it down, do not restart it! You will find your problem resolved.
1008 </para>
1009
1010 </sect2>
1011</sect1>
1012
1013</chapter>
Note: See TracBrowser for help on using the repository browser.