1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE book PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
7 <firstname>Stephen</firstname><surname>Langasek</surname>
9 <address><email>vorlon@netexpress.net</email></address>
12 <pubdate>May 31, 2003</pubdate>
15 <title>PAM-Based Distributed Authentication</title>
18 This chapter should help you to deploy Winbind-based authentication on any PAM-enabled
19 UNIX/Linux system. Winbind can be used to enable User-Level application access authentication
20 from any MS Windows NT Domain, MS Windows 200x Active Directory-based
21 domain, or any Samba-based domain environment. It will also help you to configure PAM-based local host access
22 controls that are appropriate to your Samba configuration.
26 In addition to knowing how to configure Winbind into PAM, you will learn generic PAM management
27 possibilities and in particular how to deploy tools like <filename>pam_smbpass.so</filename> to your advantage.
31 The use of Winbind requires more than PAM configuration alone.
32 Please refer to <link linkend="winbind">Winbind: Use of Domain Accounts</link>, for further information regarding Winbind.
36 <title>Features and Benefits</title>
39 A number of UNIX systems (e.g., Sun Solaris), as well as the xxxxBSD family and Linux,
40 now utilize the Pluggable Authentication Modules (PAM) facility to provide all authentication,
41 authorization and resource control services. Prior to the introduction of PAM, a decision
42 to use an alternative to the system password database (<filename>/etc/passwd</filename>)
43 would require the provision of alternatives for all programs that provide security services.
44 Such a choice would involve provision of alternatives to programs such as: <command>login</command>,
45 <command>passwd</command>, <command>chown</command>, and so on.
49 PAM provides a mechanism that disconnects these security programs from the underlying
50 authentication/authorization infrastructure. PAM is configured by making appropriate modifications to one file
51 <filename>/etc/pam.conf</filename> (Solaris), or by editing individual control files that are
52 located in <filename>/etc/pam.d</filename>.
56 On PAM-enabled UNIX/Linux systems, it is an easy matter to configure the system to use any
57 authentication backend so long as the appropriate dynamically loadable library modules
58 are available for it. The backend may be local to the system, or may be centralized on a
63 PAM support modules are available for:
67 <varlistentry><term><filename>/etc/passwd</filename></term><listitem>
69 There are several PAM modules that interact with this standard UNIX user
70 database. The most common are called: <filename>pam_unix.so</filename>, <filename>pam_unix2.so</filename>, <filename>pam_pwdb.so</filename>
71 and <filename>pam_userdb.so</filename>.
73 </listitem></varlistentry>
75 <varlistentry><term>Kerberos</term><listitem>
77 The <filename>pam_krb5.so</filename> module allows the use of any Kerberos compliant server.
78 This tool is used to access MIT Kerberos, Heimdal Kerberos, and potentially
79 Microsoft Active Directory (if enabled).
81 </listitem></varlistentry>
83 <varlistentry><term>LDAP</term><listitem>
85 The <filename>pam_ldap.so</filename> module allows the use of any LDAP v2 or v3 compatible backend
86 server. Commonly used LDAP backend servers include: OpenLDAP v2.0 and v2.1,
87 Sun ONE iDentity server, Novell eDirectory server, Microsoft Active Directory.
89 </listitem></varlistentry>
91 <varlistentry><term>NetWare Bindery</term><listitem>
93 The <filename>pam_ncp_auth.so</filename> module allows authentication off any bindery-enabled
94 NetWare Core Protocol-based server.
96 </listitem></varlistentry>
98 <varlistentry><term>SMB Password</term><listitem>
100 This module, called <filename>pam_smbpass.so</filename>, will allow user authentication off
101 the passdb backend that is configured in the Samba &smb.conf; file.
103 </listitem></varlistentry>
105 <varlistentry><term>SMB Server</term><listitem>
107 The <filename>pam_smb_auth.so</filename> module is the original MS Windows networking authentication
108 tool. This module has been somewhat outdated by the Winbind module.
110 </listitem></varlistentry>
112 <varlistentry><term>Winbind</term><listitem>
114 The <filename>pam_winbind.so</filename> module allows Samba to obtain authentication from any
115 MS Windows Domain Controller. It can just as easily be used to authenticate
116 users for access to any PAM-enabled application.
118 </listitem></varlistentry>
120 <varlistentry><term>RADIUS</term><listitem>
122 There is a PAM RADIUS (Remote Access Dial-In User Service) authentication
123 module. In most cases, administrators will need to locate the source code
124 for this tool and compile and install it themselves. RADIUS protocols are
125 used by many routers and terminal servers.
127 </listitem></varlistentry>
131 Of the above, Samba provides the <filename>pam_smbpasswd.so</filename> and the <filename>pam_winbind.so</filename> modules alone.
135 Once configured, these permit a remarkable level of flexibility in the location and use
136 of distributed Samba Domain Controllers that can provide wide area network bandwidth
137 efficient authentication services for PAM-capable systems. In effect, this allows the
138 deployment of centrally managed and maintained distributed authentication from a
139 single-user account database.
145 <title>Technical Discussion</title>
148 PAM is designed to provide the system administrator with a great deal of flexibility in
149 configuration of the privilege granting applications of their system. The local
150 configuration of system security controlled by PAM is contained in one of two places:
151 either the single system file, <filename>/etc/pam.conf</filename>, or the
152 <filename>/etc/pam.d/</filename> directory.
156 <title>PAM Configuration Syntax</title>
159 In this section we discuss the correct syntax of and generic options respected by entries to these files.
160 PAM-specific tokens in the configuration file are case insensitive. The module paths, however, are case
161 sensitive since they indicate a file's name and reflect the case
162 dependence of typical file systems.
163 The case-sensitivity of the arguments to any given module is defined for each module in turn.
167 In addition to the lines described below, there are two special characters provided for the convenience
168 of the system administrator: comments are preceded by a <quote>#</quote> and extend to the next end-of-line; also,
169 module specification lines may be extended with a <quote>\</quote> escaped newline.
173 If the PAM authentication module (loadable link library file) is located in the
174 default location, then it is not necessary to specify the path. In the case of
175 Linux, the default location is <filename>/lib/security</filename>. If the module
176 is located outside the default, then the path must be specified as:
181 auth required /other_path/pam_strange_module.so
186 <title>Anatomy of <filename>/etc/pam.d</filename> Entries</title>
189 The remaining information in this subsection was taken from the documentation of the Linux-PAM
190 project. For more information on PAM, see
191 <ulink url="http://ftp.kernel.org/pub/linux/libs/pam/">The Official Linux-PAM home page.</ulink>
195 A general configuration line of the <filename>/etc/pam.conf</filename> file has the following form:
200 service-name module-type control-flag module-path args
205 Below, we explain the meaning of each of these tokens. The second (and more recently adopted)
206 way of configuring Linux-PAM is via the contents of the <filename>/etc/pam.d/</filename> directory.
207 Once we have explained the meaning of the above tokens, we will describe this method.
211 <varlistentry><term>service-name</term><listitem>
213 The name of the service associated with this entry. Frequently, the service name is the conventional
214 name of the given application. For example, <command>ftpd</command>, <command>rlogind</command> and
215 <command>su</command>, and so on.
219 There is a special service-name reserved for defining a default authentication mechanism. It has
220 the name <parameter>OTHER</parameter> and may be specified in either lower- or upper-case characters.
221 Note, when there is a module specified for a named service, the <parameter>OTHER</parameter>
227 <varlistentry><term>module-type</term><listitem>
229 One of (currently) four types of module. The four types are as follows:
234 <parameter>auth:</parameter> This module type provides two aspects of authenticating the user.
235 It establishes that the user is who he claims to be by instructing the application
236 to prompt the user for a password or other means of identification. Secondly, the module can
237 grant group membership (independently of the <filename>/etc/groups</filename> file discussed
238 above) or other privileges through its credential granting properties.
242 <parameter>account:</parameter> This module performs non-authentication-based account management.
243 It is typically used to restrict/permit access to a service based on the time of day, currently
244 available system resources (maximum number of users) or perhaps the location of the applicant
245 user <quote>root</quote> login only on the console.
249 <parameter>session:</parameter> Primarily, this module is associated with doing things that need
250 to be done for the user before and after they can be given service. Such things include the logging
251 of information concerning the opening and closing of some data exchange with a user, mounting
252 directories, and so on.
256 <parameter>password:</parameter> This last module type is required for updating the authentication
257 token associated with the user. Typically, there is one module for each <quote>challenge/response</quote>
258 -based authentication <parameter>(auth)</parameter> module type.
264 <varlistentry><term>control-flag</term><listitem>
266 The control-flag is used to indicate how the PAM library will react to the success or failure of the
267 module it is associated with. Since modules can be stacked (modules of the same type execute in series,
268 one after another), the control-flags determine the relative importance of each module. The application
269 is not made aware of the individual success or failure of modules listed in the
270 <filename>/etc/pam.conf</filename> file. Instead, it receives a summary success or fail response from
271 the Linux-PAM library. The order of execution of these modules is that of the entries in the
272 <filename>/etc/pam.conf</filename> file; earlier entries are executed before later ones.
273 As of Linux-PAM v0.60, this control-flag can be defined with one of two syntaxes.
277 The simpler (and historical) syntax for the control-flag is a single keyword defined to indicate the
278 severity of concern associated with the success or failure of a specific module. There are four such
279 keywords: <parameter>required, requisite, sufficient and optional</parameter>.
283 The Linux-PAM library interprets these keywords in the following manner:
288 <parameter>required:</parameter> This indicates that the success of the module is required for the
289 module-type facility to succeed. Failure of this module will not be apparent to the user until all
290 of the remaining modules (of the same module-type) have been executed.
294 <parameter>requisite:</parameter> Like required, however, in the case that such a module returns a
295 failure, control is directly returned to the application. The return value is that associated with
296 the first required or requisite module to fail. This flag can be used to protect against the
297 possibility of a user getting the opportunity to enter a password over an unsafe medium. It is
298 conceivable that such behavior might inform an attacker of valid accounts on a system. This
299 possibility should be weighed against the not insignificant concerns of exposing a sensitive
300 password in a hostile environment.
304 <parameter>sufficient:</parameter> The success of this module is deemed <parameter>sufficient</parameter> to satisfy
305 the Linux-PAM library that this module-type has succeeded in its purpose. In the event that no
306 previous required module has failed, no more <quote>stacked</quote> modules of this type are invoked.
307 (In this case, subsequent required modules are not invoked). A failure of this module is not deemed
308 as fatal to satisfying the application that this module-type has succeeded.
312 <parameter>optional:</parameter> As its name suggests, this control-flag marks the module as not
313 being critical to the success or failure of the user's application for service. In general,
314 Linux-PAM ignores such a module when determining if the module stack will succeed or fail.
315 However, in the absence of any definite successes or failures of previous or subsequent stacked
316 modules, this module will determine the nature of the response to the application. One example of
317 this latter case, is when the other modules return something like PAM_IGNORE.
322 The more elaborate (newer) syntax is much more specific and gives the administrator a great deal of control
323 over how the user is authenticated. This form of the control flag is delimited with square brackets and
324 consists of a series of <parameter>value=action</parameter> tokens:
327 <para><programlisting>
328 [value1=action1 value2=action2 ...]
329 </programlisting></para>
332 Here, <parameter>value1</parameter> is one of the following return values:
334 <parameter>success; open_err; symbol_err; service_err; system_err; buf_err;</parameter>
335 <parameter>perm_denied; auth_err; cred_insufficient; authinfo_unavail;</parameter>
336 <parameter>user_unknown; maxtries; new_authtok_reqd; acct_expired; session_err;</parameter>
337 <parameter>cred_unavail; cred_expired; cred_err; no_module_data; conv_err;</parameter>
338 <parameter>authtok_err; authtok_recover_err; authtok_lock_busy;</parameter>
339 <parameter>authtok_disable_aging; try_again; ignore; abort; authtok_expired;</parameter>
340 <parameter>module_unknown; bad_item;</parameter> and <parameter>default</parameter>.
345 The last of these <parameter>(default)</parameter> can be used to set the action for those return values that are not explicitly defined.
349 The <parameter>action1</parameter> can be a positive integer or one of the following tokens:
350 <parameter>ignore; ok; done; bad; die;</parameter> and <parameter>reset</parameter>.
351 A positive integer, J, when specified as the action, can be used to indicate that the next J modules of the
352 current module-type will be skipped. In this way, the administrator can develop a moderately sophisticated
353 stack of modules with a number of different paths of execution. Which path is taken can be determined by the
354 reactions of individual modules.
359 <parameter>ignore:</parameter> When used with a stack of modules, the module's return status will not
360 contribute to the return code the application obtains.
364 <parameter>bad:</parameter> This action indicates that the return code should be thought of as indicative
365 of the module failing. If this module is the first in the stack to fail, its status value will be used
366 for that of the whole stack.
370 <parameter>die:</parameter> Equivalent to bad with the side effect of terminating the module stack and
371 PAM immediately returning to the application.
375 <parameter>ok:</parameter> This tells PAM that the administrator thinks this return code should
376 contribute directly to the return code of the full stack of modules. In other words, if the former
377 state of the stack would lead to a return of PAM_SUCCESS, the module's return code will override
378 this value. Note, if the former state of the stack holds some value that is indicative of a modules
379 failure, this <parameter>ok</parameter> value will not be used to override that value.
383 <parameter>done:</parameter> Equivalent to <parameter>ok</parameter> with the side effect of terminating the module stack and
384 PAM immediately returning to the application.
388 <parameter>reset:</parameter> Clears all memory of the state of the module stack and starts again with
389 the next stacked module.
394 Each of the four keywords: <parameter>required; requisite; sufficient;</parameter> and <parameter>optional</parameter>,
395 have an equivalent expression in terms of the [...] syntax. They are as follows:
401 <parameter>required</parameter> is equivalent to <parameter>[success=ok new_authtok_reqd=ok ignore=ignore default=bad]</parameter>.
405 <parameter>requisite</parameter> is equivalent to <parameter>[success=ok new_authtok_reqd=ok ignore=ignore default=die]</parameter>.
409 <parameter>sufficient</parameter> is equivalent to <parameter>[success=done new_authtok_reqd=done<?latex \linebreak ?> default=ignore]</parameter>.
413 <parameter>optional</parameter> is equivalent to <parameter>[success=ok new_authtok_reqd=ok default=ignore]</parameter>.
419 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,
420 the notion of client plug-in agents was introduced. This is something that makes it possible for PAM to support
421 machine-machine authentication using the transport protocol inherent to the client/server application. With the
422 <parameter>[ ... value=action ... ]</parameter> control syntax, it is possible for an application to be configured
423 to support binary prompts with compliant clients, but to gracefully fall over into an alternative authentication
424 mode for older, legacy applications.
429 <varlistentry><term>module-path</term><listitem>
431 The path-name of the dynamically loadable object file; the pluggable module itself. If the first character of the
432 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
433 to the default module path: <filename>/lib/security</filename> (but see the notes above).
437 The arguments are a list of tokens that are passed to the module when it is invoked, much like arguments to a typical
438 Linux shell command. Generally, valid arguments are optional and are specific to any given module. Invalid arguments
439 are ignored by a module, however, when encountering an invalid argument, the module is required to write an error
440 to syslog(3). For a list of generic options, see the next section.
444 If you wish to include spaces in an argument, you should surround that argument with square brackets. For example:
447 <para><programlisting>
448 squid auth required pam_mysql.so user=passwd_query passwd=mada \
449 db=eminence [query=select user_name from internet_service where \
450 user_name=<quote>%u</quote> and password=PASSWORD(<quote>%p</quote>) and service=<quote>web_proxy</quote>]
451 </programlisting></para>
454 When using this convention, you can include <quote>[</quote> characters inside the string, and if you wish to have a <quote>]</quote>
455 character inside the string that will survive the argument parsing, you should use <quote>\[</quote>. In other words:
458 <para><programlisting>
459 [..[..\]..] --> ..[..]..
460 </programlisting></para>
463 Any line in one of the configuration files that is not formatted correctly will generally tend (erring on the
464 side of caution) to make the authentication process fail. A corresponding error is written to the system log files
465 with a call to syslog(3).
476 <title>Example System Configurations</title>
479 The following is an example <filename>/etc/pam.d/login</filename> configuration file.
480 This example had all options uncommented and is probably not usable
481 because it stacks many conditions before allowing successful completion
482 of the login process. Essentially all conditions can be disabled
483 by commenting them out, except the calls to <filename>pam_pwdb.so</filename>.
487 <title>PAM: Original Login Config</title>
490 <smbfile name="pam-login-default">
493 # The PAM configuration file for the <quote>login</quote> service
495 auth required pam_securetty.so
496 auth required pam_nologin.so
497 # auth required pam_dialup.so
498 # auth optional pam_mail.so
499 auth required pam_pwdb.so shadow md5
500 # account requisite pam_time.so
501 account required pam_pwdb.so
502 session required pam_pwdb.so
503 # session optional pam_lastlog.so
504 # password required pam_cracklib.so retry=3
505 password required pam_pwdb.so shadow md5
512 <title>PAM: Login Using <filename>pam_smbpass</filename></title>
515 PAM allows use of replaceable modules. Those available on a sample system include:
518 <para><prompt>$</prompt><userinput>/bin/ls /lib/security</userinput>
520 pam_access.so pam_ftp.so pam_limits.so
521 pam_ncp_auth.so pam_rhosts_auth.so pam_stress.so
522 pam_cracklib.so pam_group.so pam_listfile.so
523 pam_nologin.so pam_rootok.so pam_tally.so
524 pam_deny.so pam_issue.so pam_mail.so
525 pam_permit.so pam_securetty.so pam_time.so
526 pam_dialup.so pam_lastlog.so pam_mkhomedir.so
527 pam_pwdb.so pam_shells.so pam_unix.so
528 pam_env.so pam_ldap.so pam_motd.so
529 pam_radius.so pam_smbpass.so pam_unix_acct.so
530 pam_wheel.so pam_unix_auth.so pam_unix_passwd.so
531 pam_userdb.so pam_warn.so pam_unix_session.so
532 </programlisting></para>
535 The following example for the login program replaces the use of
536 the <filename>pam_pwdb.so</filename> module that uses the system
537 password database (<filename>/etc/passwd</filename>,
538 <filename>/etc/shadow</filename>, <filename>/etc/group</filename>) with
539 the module <filename>pam_smbpass.so</filename>, which uses the Samba
540 database which contains the Microsoft MD4 encrypted password
541 hashes. This database is stored in either
542 <filename>/usr/local/samba/private/smbpasswd</filename>,
543 <filename>/etc/samba/smbpasswd</filename>, or in
544 <filename>/etc/samba.d/smbpasswd</filename>, depending on the
545 Samba implementation for your UNIX/Linux system. The
546 <filename>pam_smbpass.so</filename> module is provided by
547 Samba version 2.2.1 or later. It can be compiled by specifying the
548 <option>--with-pam_smbpass</option> options when running Samba's
549 <command>configure</command> script. For more information
550 on the <filename>pam_smbpass</filename> module, see the documentation
551 in the <filename>source/pam_smbpass</filename> directory of the Samba
556 <smbfile name="pam-login-smbpass">
559 # The PAM configuration file for the <quote>login</quote> service
561 auth required pam_smbpass.so nodelay
562 account required pam_smbpass.so nodelay
563 session required pam_smbpass.so nodelay
564 password required pam_smbpass.so nodelay
565 </programlisting></smbfile></para>
568 The following is the PAM configuration file for a particular
569 Linux system. The default condition uses <filename>pam_pwdb.so</filename>.
573 <smbfile name="pam-samba-default">
576 # The PAM configuration file for the <quote>samba</quote> service
578 auth required pam_pwdb.so nullok nodelay shadow audit
579 account required pam_pwdb.so audit nodelay
580 session required pam_pwdb.so nodelay
581 password required pam_pwdb.so shadow md5
582 </programlisting></smbfile></para>
585 In the following example, the decision has been made to use the
586 <command>smbpasswd</command> database even for basic Samba authentication. Such a
587 decision could also be made for the <command>passwd</command> program and would
588 thus allow the <command>smbpasswd</command> passwords to be changed using the
589 <command>passwd</command> program:
592 <para><smbfile name="pam-samba-smbpass">
595 # The PAM configuration file for the <quote>samba</quote> service
597 auth required pam_smbpass.so nodelay
598 account required pam_pwdb.so audit nodelay
599 session required pam_pwdb.so nodelay
600 password required pam_smbpass.so nodelay smbconf=/etc/samba.d/smb.conf
604 <note><para>PAM allows stacking of authentication mechanisms. It is
605 also possible to pass information obtained within one PAM module through
606 to the next module in the PAM stack. Please refer to the documentation for
607 your particular system implementation for details regarding the specific
608 capabilities of PAM in this environment. Some Linux implementations also
609 provide the <filename>pam_stack.so</filename> module that allows all
610 authentication to be configured in a single central file. The
611 <filename>pam_stack.so</filename> method has some devoted followers
612 on the basis that it allows for easier administration. As with all issues in
613 life though, every decision makes trade-offs, so you may want to examine the
614 PAM documentation for further helpful information.
622 <title>&smb.conf; PAM Configuration</title>
625 There is an option in &smb.conf; called <smbconfoption><name>obey pam restrictions</name></smbconfoption>.
626 The following is from the online help for this option in SWAT;
630 When Samba is configured to enable PAM support (i.e., <option>--with-pam</option>), this parameter will
631 control whether or not Samba should obey PAM's account and session management directives. The default behavior
632 is to use PAM for clear-text authentication only and to ignore any account or session management. Samba always
633 ignores PAM for authentication in the case of <smbconfoption><name>encrypt passwords</name><value>yes</value></smbconfoption>.
634 The reason is that PAM modules cannot support the challenge/response authentication mechanism needed in the presence of SMB
638 <para>Default: <smbconfoption><name>obey pam restrictions</name><value>no</value></smbconfoption></para>
643 <title>Remote CIFS Authentication Using <filename>winbindd.so</filename></title>
646 All operating systems depend on the provision of users credentials acceptable to the platform.
647 UNIX requires the provision of a user identifier (UID) as well as a group identifier (GID).
648 These are both simple integer type numbers that are obtained from a password backend such
649 as <filename>/etc/passwd</filename>.
653 Users and groups on a Windows NT server are assigned a relative ID (RID) which is unique for
654 the domain when the user or group is created. To convert the Windows NT user or group into
655 a UNIX user or group, a mapping between RIDs and UNIX user and group IDs is required. This
656 is one of the jobs that winbind performs.
660 As Winbind users and groups are resolved from a server, user and group IDs are allocated
661 from a specified range. This is done on a first come, first served basis, although all
662 existing users and groups will be mapped as soon as a client performs a user or group
663 enumeration command. The allocated UNIX IDs are stored in a database file under the Samba
664 lock directory and will be remembered.
668 The astute administrator will realize from this that the combination of <filename>pam_smbpass.so</filename>,
669 <command>winbindd</command> and a distributed <smbconfoption><name>passdb backend</name><value></value></smbconfoption>,
670 such as <parameter>ldap</parameter>, will allow the establishment of a centrally managed, distributed user/password
671 database that can also be used by all PAM-aware (e.g., Linux) programs and applications. This arrangement can have
672 particularly potent advantages compared with the use of Microsoft Active Directory Service (ADS) in so far as
673 the reduction of wide area network authentication traffic.
677 The RID to UNIX ID database is the only location where the user and group mappings are
678 stored by <command>winbindd</command>. If this file is deleted or corrupted, there is no way for <command>winbindd</command>
679 to determine which user and group IDs correspond to Windows NT user and group RIDs.
685 <title>Password Synchronization Using <filename>pam_smbpass.so</filename></title>
688 <filename>pam_smbpass</filename> is a PAM module that can be used on conforming systems to
689 keep the <filename>smbpasswd</filename> (Samba password) database in sync with the UNIX
690 password file. PAM (Pluggable Authentication Modules) is an API supported
691 under some UNIX operating systems, such as Solaris, HPUX and Linux, that provides a
692 generic interface to authentication mechanisms.
696 This module authenticates a local <filename>smbpasswd</filename> user database. If you require
697 support for authenticating against a remote SMB server, or if you are
698 concerned about the presence of SUID root binaries on your system, it is
699 recommended that you use <filename>pam_winbind</filename> instead.
703 Options recognized by this module are shown in <link linkend="smbpassoptions">next table</link>.
704 <table frame="all" id="smbpassoptions">
705 <title>Options recognized by <parameter>pam_smbpass</parameter></title>
706 <tgroup cols="2" align="left">
707 <colspec align="left"/>
708 <colspec align="justify" colwidth="1*"/>
710 <row><entry>debug</entry><entry>log more debugging info.</entry></row>
711 <row><entry>audit</entry><entry>like debug, but also logs unknown usernames.</entry></row>
712 <row><entry>use_first_pass</entry><entry>do not prompt the user for passwords; take them from PAM_ items instead.</entry></row>
713 <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>
714 <row><entry>use_authtok</entry>
715 <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>
716 <row><entry>not_set_pass</entry><entry>do not make passwords used by this module available to other modules.</entry></row>
717 <row><entry>nodelay</entry><entry>do not insert ~1 second delays on authentication failure.</entry></row>
718 <row><entry>nullok</entry><entry>null passwords are allowed.</entry></row>
719 <row><entry>nonull</entry><entry>null passwords are not allowed. Used to override the Samba configuration.</entry></row>
720 <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>
721 <row><entry>smbconf=<replaceable>file</replaceable></entry><entry>specify an alternate path to the &smb.conf; file.</entry></row>
728 The following are examples of the use of <filename>pam_smbpass.so</filename> in the format of Linux
729 <filename>/etc/pam.d/</filename> files structure. Those wishing to implement this
730 tool on other platforms will need to adapt this appropriately.
734 <title>Password Synchronization Configuration</title>
737 A sample PAM configuration that shows the use of pam_smbpass to make
738 sure <filename>private/smbpasswd</filename> is kept in sync when <filename>/etc/passwd (/etc/shadow)</filename>
739 is changed. Useful when an expired password might be changed by an
740 application (such as <command>ssh</command>).
744 <smbfile name="pam-synchronised-password">
749 auth requisite pam_nologin.so
750 auth required pam_unix.so
751 account required pam_unix.so
752 password requisite pam_cracklib.so retry=3
753 password requisite pam_unix.so shadow md5 use_authtok try_first_pass
754 password required pam_smbpass.so nullok use_authtok try_first_pass
755 session required pam_unix.so
756 </programlisting></smbfile></para>
760 <title>Password Migration Configuration</title>
763 A sample PAM configuration that shows the use of <filename>pam_smbpass</filename> to migrate
764 from plaintext to encrypted passwords for Samba. Unlike other methods,
765 this can be used for users who have never connected to Samba shares:
766 password migration takes place when users <command>ftp</command> in, login using <command>ssh</command>, pop
767 their mail, and so on.
770 <para><smbfile name="pam-password-migration">
775 auth requisite pam_nologin.so
776 # pam_smbpass is called IF pam_unix succeeds.
777 auth requisite pam_unix.so
778 auth optional pam_smbpass.so migrate
779 account required pam_unix.so
780 password requisite pam_cracklib.so retry=3
781 password requisite pam_unix.so shadow md5 use_authtok try_first_pass
782 password optional pam_smbpass.so nullok use_authtok try_first_pass
783 session required pam_unix.so
784 </programlisting></smbfile></para>
788 <title>Mature Password Configuration</title>
791 A sample PAM configuration for a mature <filename>smbpasswd</filename> installation.
792 <filename>private/smbpasswd</filename> is fully populated, and we consider it an error if
793 the SMB password does not exist or does not match the UNIX password.
796 <para><smbfile name="pam-fallback">
801 auth requisite pam_nologin.so
802 auth required pam_unix.so
803 account required pam_unix.so
804 password requisite pam_cracklib.so retry=3
805 password requisite pam_unix.so shadow md5 use_authtok try_first_pass
806 password required pam_smbpass.so use_authtok use_first_pass
807 session required pam_unix.so
808 </programlisting></smbfile></para>
812 <title>Kerberos Password Integration Configuration</title>
815 A sample PAM configuration that shows <parameter>pam_smbpass</parameter> used together with
816 <parameter>pam_krb5</parameter>. This could be useful on a Samba PDC that is also a member of
820 <para><smbfile name="pam-krb">
825 auth requisite pam_nologin.so
826 auth requisite pam_krb5.so
827 auth optional pam_smbpass.so migrate
828 account required pam_krb5.so
829 password requisite pam_cracklib.so retry=3
830 password optional pam_smbpass.so nullok use_authtok try_first_pass
831 password required pam_krb5.so use_authtok try_first_pass
832 session required pam_krb5.so
833 </programlisting></smbfile></para>
842 <title>Common Errors</title>
845 PAM can be fickle and sensitive to configuration glitches. Here we look at a few cases from
846 the Samba mailing list.
849 <!-- shouldn't this be in the Winbind chapter - Jelmer -->
851 <title>pam_winbind Problem</title>
854 A user reported: I have the following PAM configuration:
858 <smbfile name="pam-winbind-erratic">
860 auth required /lib/security/pam_securetty.so
861 auth sufficient /lib/security/pam_winbind.so
862 auth sufficient /lib/security/pam_unix.so use_first_pass nullok
863 auth required /lib/security/pam_stack.so service=system-auth
864 auth required /lib/security/pam_nologin.so
865 account required /lib/security/pam_stack.so service=system-auth
866 account required /lib/security/pam_winbind.so
867 password required /lib/security/pam_stack.so service=system-auth
868 </programlisting></smbfile>
872 When I open a new console with [ctrl][alt][F1], I can't log in with my user <quote>pitie</quote>.
873 I have tried with user <quote>scienceu\pitie</quote> also.
877 <emphasis>Answer:</emphasis> The problem may lie with your inclusion of <parameter>pam_stack.so
878 service=system-auth</parameter>. That file often contains a lot of stuff that may
879 duplicate what you are already doing. Try commenting out the <parameter>pam_stack</parameter> lines
880 for <parameter>auth</parameter> and <parameter>account</parameter> and see if things work. If they do, look at
881 <filename>/etc/pam.d/system-auth</filename> and copy only what you need from it into your
882 <filename>/etc/pam.d/login</filename> file. Alternately, if you want all services to use
883 Winbind, you can put the Winbind-specific stuff in <filename>/etc/pam.d/system-auth</filename>.
889 <title>Winbind Is Not Resolving Users and Groups</title>
893 My &smb.conf; file is correctly configured. I have specified
894 <smbconfoption><name>idmap uid</name><value>12000</value></smbconfoption>,
895 and <smbconfoption><name>idmap gid</name><value>3000-3500</value></smbconfoption>
896 and <command>winbind</command> is running. When I do the following it all works fine.
901 &rootprompt;<userinput>wbinfo -u</userinput>
908 &rootprompt;<userinput>wbinfo -g</userinput>
909 MIDEARTH\Domain Users
910 MIDEARTH\Domain Admins
911 MIDEARTH\Domain Guests
915 &rootprompt;<userinput>getent passwd</userinput>
916 root:x:0:0:root:/root:/bin/bash
917 bin:x:1:1:bin:/bin:/bin/bash
919 maryo:x:15000:15003:Mary Orville:/home/MIDEARTH/maryo:/bin/false
924 But this command fails:
927 &rootprompt;<userinput>chown maryo a_file</userinput>
928 chown: 'maryo': invalid user
930 <quote>This is driving me nuts! What can be wrong?</quote>
934 <emphasis>Answer:</emphasis> Your system is likely running <command>nscd</command>, the name service
935 caching daemon. Shut it down, do not restart it! You will find your problem resolved.