xref: /freebsd/contrib/pam-krb5/docs/docknot.yaml (revision bf6873c5786e333d679a7838d28812febf479a8a)
1*bf6873c5SCy Schubert# Package metadata for pam-krb5.
2*bf6873c5SCy Schubert#
3*bf6873c5SCy Schubert# This file contains configuration for DocKnot used to generate
4*bf6873c5SCy Schubert# documentation files (like README.md) and web pages.  Other documentation
5*bf6873c5SCy Schubert# in this package is generated automatically from these files as part of
6*bf6873c5SCy Schubert# the release process.  For more information, see DocKnot's documentation.
7*bf6873c5SCy Schubert#
8*bf6873c5SCy Schubert# DocKnot is available from <https://www.eyrie.org/~eagle/software/docknot/>.
9*bf6873c5SCy Schubert#
10*bf6873c5SCy Schubert# Copyright 2017, 2020-2021 Russ Allbery <eagle@eyrie.org>
11*bf6873c5SCy Schubert#
12*bf6873c5SCy Schubert# SPDX-License-Identifier: BSD-3-clause or GPL-1+
13*bf6873c5SCy Schubert
14*bf6873c5SCy Schubertformat: v1
15*bf6873c5SCy Schubert
16*bf6873c5SCy Schubertname: pam-krb5
17*bf6873c5SCy Schubertmaintainer: Russ Allbery <eagle@eyrie.org>
18*bf6873c5SCy Schubertversion: '4.11'
19*bf6873c5SCy Schubertsynopsis: PAM module for Kerberos authentication
20*bf6873c5SCy Schubert
21*bf6873c5SCy Schubertlicense:
22*bf6873c5SCy Schubert  name: BSD-3-clause-or-GPL-1+
23*bf6873c5SCy Schubertcopyrights:
24*bf6873c5SCy Schubert  - holder: Russ Allbery <eagle@eyrie.org>
25*bf6873c5SCy Schubert    years: 2005-2010, 2014-2015, 2017, 2020-2021
26*bf6873c5SCy Schubert  - holder: The Board of Trustees of the Leland Stanford Junior University
27*bf6873c5SCy Schubert    years: 2009-2011
28*bf6873c5SCy Schubert  - holder: Andres Salomon <dilinger@debian.org>
29*bf6873c5SCy Schubert    years: '2005'
30*bf6873c5SCy Schubert  - holder: Frank Cusack <fcusack@fcusack.com>
31*bf6873c5SCy Schubert    years: 1999-2000
32*bf6873c5SCy Schubert
33*bf6873c5SCy Schubertbuild:
34*bf6873c5SCy Schubert  autoconf: '2.64'
35*bf6873c5SCy Schubert  automake: '1.11'
36*bf6873c5SCy Schubert  autotools: true
37*bf6873c5SCy Schubert  kerberos: true
38*bf6873c5SCy Schubert  manpages: true
39*bf6873c5SCy Schubert  middle: |
40*bf6873c5SCy Schubert    The module will be installed in `/usr/local/lib/security` by default, but
41*bf6873c5SCy Schubert    expect to have to override this using `--libdir`.  The correct
42*bf6873c5SCy Schubert    installation path for PAM modules varies considerably between systems.
43*bf6873c5SCy Schubert    The module will always be installed in a subdirectory named `security`
44*bf6873c5SCy Schubert    under the specified value of `--libdir`.  On Red Hat Linux, for example,
45*bf6873c5SCy Schubert    `--libdir=/usr/lib64` is appropriate to install the module into the system
46*bf6873c5SCy Schubert    PAM directory.  On Debian's amd64 architecture,
47*bf6873c5SCy Schubert    `--libdir=/usr/lib/x86_64-linux-gnu` would be correct.
48*bf6873c5SCy Schubert  reduced_depends: true
49*bf6873c5SCy Schubert  type: Autoconf
50*bf6873c5SCy Schubert  valgrind: true
51*bf6873c5SCy Schubertdistribution:
52*bf6873c5SCy Schubert  packaging:
53*bf6873c5SCy Schubert    debian:
54*bf6873c5SCy Schubert      package: libpam-krb5
55*bf6873c5SCy Schubert      summary: |
56*bf6873c5SCy Schubert        Debian packages are available from Debian in Debian 4.0 (etch) and
57*bf6873c5SCy Schubert        later releases as libpam-krb5 and libpam-heimdal.  The former packages
58*bf6873c5SCy Schubert        are built against the MIT Kerberos libraries and the latter against
59*bf6873c5SCy Schubert        the Heimdal libraries.
60*bf6873c5SCy Schubert  section: kerberos
61*bf6873c5SCy Schubert  tarname: pam-krb5
62*bf6873c5SCy Schubert  version: pam-krb5
63*bf6873c5SCy Schubertsupport:
64*bf6873c5SCy Schubert  email: eagle@eyrie.org
65*bf6873c5SCy Schubert  github: rra/pam-krb5
66*bf6873c5SCy Schubert  web: https://www.eyrie.org/~eagle/software/pam-krb5/
67*bf6873c5SCy Schubertvcs:
68*bf6873c5SCy Schubert  browse: https://git.eyrie.org/?p=kerberos/pam-krb5.git
69*bf6873c5SCy Schubert  github: rra/pam-krb5
70*bf6873c5SCy Schubert  openhub: https://www.openhub.net/p/pamkrb5
71*bf6873c5SCy Schubert  status:
72*bf6873c5SCy Schubert    workflow: build
73*bf6873c5SCy Schubert  type: Git
74*bf6873c5SCy Schubert  url: https://git.eyrie.org/git/kerberos/pam-krb5.git
75*bf6873c5SCy Schubert
76*bf6873c5SCy Schubertquote:
77*bf6873c5SCy Schubert  author: Joyce McGreevy
78*bf6873c5SCy Schubert  date: 2003-11-17
79*bf6873c5SCy Schubert  text: |
80*bf6873c5SCy Schubert    "You're always going to have some people who can't appreciate the thrill
81*bf6873c5SCy Schubert    of a tepid change for the somewhat better," explained one source.
82*bf6873c5SCy Schubert  title: '"Look, ma, no hands!"'
83*bf6873c5SCy Schubert  work: Salon
84*bf6873c5SCy Schubertadvisories:
85*bf6873c5SCy Schubert  - date: 2020-03-30
86*bf6873c5SCy Schubert    threshold: '4.9'
87*bf6873c5SCy Schubert    versions: 4.8 and earlier
88*bf6873c5SCy Schubert  - date: 2009-02-11
89*bf6873c5SCy Schubert    threshold: '3.13'
90*bf6873c5SCy Schubert    versions: 3.12 and earlier
91*bf6873c5SCy Schubertdocs:
92*bf6873c5SCy Schubert  user:
93*bf6873c5SCy Schubert    - name: pam-krb5
94*bf6873c5SCy Schubert      title: Manual page
95*bf6873c5SCy Schubert
96*bf6873c5SCy Schubertblurb: |
97*bf6873c5SCy Schubert  pam-krb5 is a Kerberos PAM module for either MIT Kerberos or Heimdal.  It
98*bf6873c5SCy Schubert  supports ticket refreshing by screen savers, configurable authorization
99*bf6873c5SCy Schubert  handling, authentication of non-local accounts for network services,
100*bf6873c5SCy Schubert  password changing, and password expiration, as well as all the standard
101*bf6873c5SCy Schubert  expected PAM features.  It works correctly with OpenSSH, even with
102*bf6873c5SCy Schubert  ChallengeResponseAuthentication and PrivilegeSeparation enabled, and
103*bf6873c5SCy Schubert  supports extensive configuration either by PAM options or in krb5.conf or
104*bf6873c5SCy Schubert  both.  PKINIT is supported with recent versions of both MIT Kerberos and
105*bf6873c5SCy Schubert  Heimdal and FAST is supported with recent MIT Kerberos.
106*bf6873c5SCy Schubert
107*bf6873c5SCy Schubertdescription: |
108*bf6873c5SCy Schubert  pam-krb5 provides a Kerberos PAM module that supports authentication, user
109*bf6873c5SCy Schubert  ticket cache handling, simple authorization (via .k5login or checking
110*bf6873c5SCy Schubert  Kerberos principals against local usernames), and password changing.  It can
111*bf6873c5SCy Schubert  be configured through either options in the PAM configuration itself or
112*bf6873c5SCy Schubert  through entries in the system krb5.conf file, and it tries to work around
113*bf6873c5SCy Schubert  PAM implementation flaws in commonly-used PAM-enabled applications such as
114*bf6873c5SCy Schubert  OpenSSH and xdm.  It supports both PKINIT and FAST to the extent that the
115*bf6873c5SCy Schubert  underlying Kerberos libraries support these features.
116*bf6873c5SCy Schubert
117*bf6873c5SCy Schubert  This is not the Kerberos PAM module maintained on Sourceforge and used on
118*bf6873c5SCy Schubert  Red Hat systems.  It is an independent implementation that, if it ever
119*bf6873c5SCy Schubert  shared any common code, diverged long ago.  It supports some features that
120*bf6873c5SCy Schubert  the Sourceforge module does not (particularly around authorization), and
121*bf6873c5SCy Schubert  does not support some options (particularly ones not directly related to
122*bf6873c5SCy Schubert  Kerberos) that it does.  This module will never support Kerberos v4 or AFS.
123*bf6873c5SCy Schubert  For an AFS session module that works with this module (or any other Kerberos
124*bf6873c5SCy Schubert  PAM module), see
125*bf6873c5SCy Schubert  [pam-afs-session](https://www.eyrie.org/~eagle/software/pam-afs-session/).
126*bf6873c5SCy Schubert
127*bf6873c5SCy Schubert  If there are other options besides AFS and Kerberos v4 support from the
128*bf6873c5SCy Schubert  Sourceforge PAM module that you're missing in this module, please let me
129*bf6873c5SCy Schubert  know.
130*bf6873c5SCy Schubert
131*bf6873c5SCy Schubertrequirements: |
132*bf6873c5SCy Schubert  Either MIT Kerberos (or Kerberos implementations based on it) or Heimdal are
133*bf6873c5SCy Schubert  supported.  MIT Keberos 1.3 or later may be required; this module has not
134*bf6873c5SCy Schubert  been tested with earlier versions.
135*bf6873c5SCy Schubert
136*bf6873c5SCy Schubert  For PKINIT support, Heimdal 0.8rc1 or later or MIT Kerberos 1.6.3 or later
137*bf6873c5SCy Schubert  are required.  Earlier MIT Kerberos 1.6 releases have a bug in their
138*bf6873c5SCy Schubert  handling of PKINIT options.  MIT Kerberos 1.12 or later is required to use
139*bf6873c5SCy Schubert  the use_pkinit PAM option.
140*bf6873c5SCy Schubert
141*bf6873c5SCy Schubert  For FAST (Flexible Authentication Secure Tunneling) support, MIT Kerberos
142*bf6873c5SCy Schubert  1.7 or higher is required.  For anonymous FAST support, anonymous
143*bf6873c5SCy Schubert  authentication (generally anonymous PKINIT) support is required in both the
144*bf6873c5SCy Schubert  Kerberos libraries and in the local KDC.
145*bf6873c5SCy Schubert
146*bf6873c5SCy Schubert  This module should work on Linux and build with gcc or clang.  It may still
147*bf6873c5SCy Schubert  work on Solaris and build with the Sun C compiler, but I have only tested it
148*bf6873c5SCy Schubert  on Linux recently.  There is beta-quality support for the AIX NAS Kerberos
149*bf6873c5SCy Schubert  implementation that has not been tested in years.  Other PAM implementations
150*bf6873c5SCy Schubert  will probably require some porting, although untested build system support
151*bf6873c5SCy Schubert  is present for FreeBSD, Mac OS X, and HP-UX.  I personally can only test on
152*bf6873c5SCy Schubert  Linux and rely on others to report problems on other operating systems.
153*bf6873c5SCy Schubert
154*bf6873c5SCy Schubert  Old versions of OpenSSH are known to call `pam_authenticate` followed by
155*bf6873c5SCy Schubert  `pam_setcred(PAM_REINITIALIZE_CRED)` without first calling
156*bf6873c5SCy Schubert  `pam_open_session`, thereby requesting that an existing ticket cache be
157*bf6873c5SCy Schubert  renewed (similar to what a screensaver would want) rather than requesting a
158*bf6873c5SCy Schubert  new ticket cache be created.  Since this behavior is indistinguishable at
159*bf6873c5SCy Schubert  the PAM level from a screensaver, pam-krb5 when used with these old versions
160*bf6873c5SCy Schubert  of OpenSSH will refresh the ticket cache of the OpenSSH daemon rather than
161*bf6873c5SCy Schubert  setting up a new ticket cache for the user.  The resulting ticket cache will
162*bf6873c5SCy Schubert  have the correct permissions (this is not a security concern), but will not
163*bf6873c5SCy Schubert  be named correctly or referenced in the user's environment and will be
164*bf6873c5SCy Schubert  overwritten by the next user login.  The best solution to this problem is to
165*bf6873c5SCy Schubert  upgrade OpenSSH.  I'm not sure exactly when this problem was fixed, but at
166*bf6873c5SCy Schubert  the very least OpenSSH 4.3 and later do not exhibit it.
167*bf6873c5SCy Schubert
168*bf6873c5SCy Schuberttest:
169*bf6873c5SCy Schubert  lancaster: true
170*bf6873c5SCy Schubert  prefix: |
171*bf6873c5SCy Schubert    pam-krb5 comes with a comprehensive test suite, but it requires some
172*bf6873c5SCy Schubert    configuration in order to test anything other than low-level utility
173*bf6873c5SCy Schubert    functions.  For the full test suite, you will need to have a running KDC
174*bf6873c5SCy Schubert    in which you can create two test accounts, one with admin access to the
175*bf6873c5SCy Schubert    other.  Using a test KDC environment, if you have one, is recommended.
176*bf6873c5SCy Schubert
177*bf6873c5SCy Schubert    Follow the instructions in `tests/config/README` to configure the test
178*bf6873c5SCy Schubert    suite.
179*bf6873c5SCy Schubert
180*bf6873c5SCy Schubert    Now, you can run the test suite with:
181*bf6873c5SCy Schubert  suffix: |
182*bf6873c5SCy Schubert    The default libkadm5clnt library on the system must match the
183*bf6873c5SCy Schubert    implementation of your KDC for the module/expired test to work, since the
184*bf6873c5SCy Schubert    two kadmin protocols are not compatible.  If you use the MIT library
185*bf6873c5SCy Schubert    against a Heimdal server, the test will be skipped; if you use the Heimdal
186*bf6873c5SCy Schubert    library against an MIT server, the test suite may hang.
187*bf6873c5SCy Schubert
188*bf6873c5SCy Schubert    Several `module/expired` tests are expected to fail with Heimdal 1.5 due
189*bf6873c5SCy Schubert    to a bug in Heimdal with reauthenticating immediately after a
190*bf6873c5SCy Schubert    library-mediated password change of an expired password.  This is fixed in
191*bf6873c5SCy Schubert    later releases of Heimdal.
192*bf6873c5SCy Schubert
193*bf6873c5SCy Schubert    To run the full test suite, Perl 5.10 or later is required.  The following
194*bf6873c5SCy Schubert    additional Perl modules will be used if present:
195*bf6873c5SCy Schubert
196*bf6873c5SCy Schubert    * Test::Pod
197*bf6873c5SCy Schubert    * Test::Spelling
198*bf6873c5SCy Schubert
199*bf6873c5SCy Schubert    All are available on CPAN.  Those tests will be skipped if the modules are
200*bf6873c5SCy Schubert    not available.
201*bf6873c5SCy Schubert
202*bf6873c5SCy Schubertsections:
203*bf6873c5SCy Schubert  - title: Configuring
204*bf6873c5SCy Schubert    body: |
205*bf6873c5SCy Schubert      Just installing the module does not enable it or change anything about
206*bf6873c5SCy Schubert      your system authentication configuration.  To use the module for all
207*bf6873c5SCy Schubert      system authentication on Debian systems, put something like:
208*bf6873c5SCy Schubert
209*bf6873c5SCy Schubert      ```
210*bf6873c5SCy Schubert          auth  sufficient   pam_krb5.so minimum_uid=1000
211*bf6873c5SCy Schubert          auth  required     pam_unix.so try_first_pass nullok_secure
212*bf6873c5SCy Schubert      ```
213*bf6873c5SCy Schubert
214*bf6873c5SCy Schubert      in `/etc/pam.d/common-auth`, something like:
215*bf6873c5SCy Schubert
216*bf6873c5SCy Schubert      ```
217*bf6873c5SCy Schubert          session  optional  pam_krb5.so minimum_uid=1000
218*bf6873c5SCy Schubert          session  required  pam_unix.so
219*bf6873c5SCy Schubert      ```
220*bf6873c5SCy Schubert
221*bf6873c5SCy Schubert      in `/etc/pam.d/common-session`, and something like:
222*bf6873c5SCy Schubert
223*bf6873c5SCy Schubert      ```
224*bf6873c5SCy Schubert          account  required  pam_krb5.so minimum_uid=1000
225*bf6873c5SCy Schubert          account  required  pam_unix.so
226*bf6873c5SCy Schubert      ```
227*bf6873c5SCy Schubert
228*bf6873c5SCy Schubert      in `/etc/pam.d/common-account`.  The `minimum_uid` setting tells the PAM
229*bf6873c5SCy Schubert      module to pass on any users with a UID lower than 1000, thereby
230*bf6873c5SCy Schubert      bypassing Kerberos authentication for the root account and any system
231*bf6873c5SCy Schubert      accounts.  You normally want to do this since otherwise, if the network
232*bf6873c5SCy Schubert      is down, the Kerberos authentication can time out and make it difficult
233*bf6873c5SCy Schubert      to log in as root and fix matters.  This also avoids problems with
234*bf6873c5SCy Schubert      Kerberos principals that happen to match system accounts accidentally
235*bf6873c5SCy Schubert      getting access to those accounts.
236*bf6873c5SCy Schubert
237*bf6873c5SCy Schubert      Be sure to include the module in the session group as well as the auth
238*bf6873c5SCy Schubert      group.  Without the session entry, the user's ticket cache will not be
239*bf6873c5SCy Schubert      created properly for ssh logins (among possibly others).
240*bf6873c5SCy Schubert
241*bf6873c5SCy Schubert      If your users should normally all use Kerberos passwords exclusively,
242*bf6873c5SCy Schubert      putting something like:
243*bf6873c5SCy Schubert
244*bf6873c5SCy Schubert      ```
245*bf6873c5SCy Schubert          password sufficient pam_krb5.so minimum_uid=1000
246*bf6873c5SCy Schubert          password required   pam_unix.so try_first_pass obscure md5
247*bf6873c5SCy Schubert      ```
248*bf6873c5SCy Schubert
249*bf6873c5SCy Schubert      in `/etc/pam.d/common-password` will change users' passwords in Kerberos
250*bf6873c5SCy Schubert      by default and then only fall back on Unix if that doesn't work.  (You
251*bf6873c5SCy Schubert      can make this tighter by using the more complex new-style PAM
252*bf6873c5SCy Schubert      configuration.)  If you instead want to synchronize local and Kerberos
253*bf6873c5SCy Schubert      passwords and change them both at the same time, you can do something
254*bf6873c5SCy Schubert      like:
255*bf6873c5SCy Schubert
256*bf6873c5SCy Schubert      ```
257*bf6873c5SCy Schubert          password required   pam_unix.so obscure sha512
258*bf6873c5SCy Schubert          password required   pam_krb5.so use_authtok minimum_uid=1000
259*bf6873c5SCy Schubert      ```
260*bf6873c5SCy Schubert
261*bf6873c5SCy Schubert      If you have multiple environments that you want to synchronize and you
262*bf6873c5SCy Schubert      don't want password changes to continue if the Kerberos password change
263*bf6873c5SCy Schubert      fails, use the `clear_on_fail` option.  For example:
264*bf6873c5SCy Schubert
265*bf6873c5SCy Schubert      ```
266*bf6873c5SCy Schubert          password required   pam_krb5.so clear_on_fail minimum_uid=1000
267*bf6873c5SCy Schubert          password required   pam_unix.so use_authtok obscure sha512
268*bf6873c5SCy Schubert          password required   pam_smbpass.so use_authtok
269*bf6873c5SCy Schubert      ```
270*bf6873c5SCy Schubert
271*bf6873c5SCy Schubert      In this case, if `pam_krb5` cannot change the password (due to password
272*bf6873c5SCy Schubert      strength rules on the KDC, for example), it will clear the stored
273*bf6873c5SCy Schubert      password (because of the `clear_on_fail` option), and since `pam_unix`
274*bf6873c5SCy Schubert      and `pam_smbpass` are both configured with `use_authtok`, they will both
275*bf6873c5SCy Schubert      fail.  `clear_on_fail` is not the default because it would interfere
276*bf6873c5SCy Schubert      with the more common pattern of falling back to local passwords if the
277*bf6873c5SCy Schubert      user doesn't exist in Kerberos.
278*bf6873c5SCy Schubert
279*bf6873c5SCy Schubert      If you use a more complex configuration with the Linux PAM `[]` syntax
280*bf6873c5SCy Schubert      for the session and account groups, note that `pam_krb5` returns a
281*bf6873c5SCy Schubert      status of ignore, not success, if the user didn't log on with Kerberos.
282*bf6873c5SCy Schubert      You may need to handle that explicitly with `ignore=ignore` in your
283*bf6873c5SCy Schubert      action list.
284*bf6873c5SCy Schubert
285*bf6873c5SCy Schubert      There are many, many other possibilities.  See the Linux PAM
286*bf6873c5SCy Schubert      documentation for all the configuration options.
287*bf6873c5SCy Schubert
288*bf6873c5SCy Schubert      On Red Hat systems, modify `/etc/pam.d/system-auth` instead, which
289*bf6873c5SCy Schubert      contains all of the configuration for the different stacks.
290*bf6873c5SCy Schubert
291*bf6873c5SCy Schubert      You can also use pam-krb5 only for specific services.  In that case,
292*bf6873c5SCy Schubert      modify the files in `/etc/pam.d` for that particular service to use
293*bf6873c5SCy Schubert      `pam_krb5.so` for authentication.  For services that are using passwords
294*bf6873c5SCy Schubert      over TLS to authenticate users, you may want to use the `ignore_k5login`
295*bf6873c5SCy Schubert      and `no_ccache` options to the authenticate module.  `.k5login`
296*bf6873c5SCy Schubert      authorization is only meaningful for local accounts and ticket caches
297*bf6873c5SCy Schubert      are usually (although not always) only useful for interactive sessions.
298*bf6873c5SCy Schubert
299*bf6873c5SCy Schubert      Configuring the module for Solaris is both simpler and less flexible,
300*bf6873c5SCy Schubert      since Solaris (at least Solaris 8 and 9, which are the last versions of
301*bf6873c5SCy Schubert      Solaris with which this module was extensively tested) use a single
302*bf6873c5SCy Schubert      `/etc/pam.conf` file that contains configuration for all programs.  For
303*bf6873c5SCy Schubert      console login on Solaris, try something like:
304*bf6873c5SCy Schubert
305*bf6873c5SCy Schubert      ```
306*bf6873c5SCy Schubert          login auth sufficient /usr/local/lib/security/pam_krb5.so minimum_uid=100
307*bf6873c5SCy Schubert          login auth required /usr/lib/security/pam_unix_auth.so.1 use_first_pass
308*bf6873c5SCy Schubert          login account required /usr/local/lib/security/pam_krb5.so minimum_uid=100
309*bf6873c5SCy Schubert          login account required /usr/lib/security/pam_unix_account.so.1
310*bf6873c5SCy Schubert          login session required /usr/local/lib/security/pam_krb5.so retain_after_close minimum_uid=100
311*bf6873c5SCy Schubert          login session required /usr/lib/security/pam_unix_session.so.1
312*bf6873c5SCy Schubert      ```
313*bf6873c5SCy Schubert
314*bf6873c5SCy Schubert      A similar configuration could be used for other services, such as ssh.
315*bf6873c5SCy Schubert      See the pam.conf(5) man page for more information.  When using this
316*bf6873c5SCy Schubert      module with Solaris login (at least on Solaris 8 and 9), you will
317*bf6873c5SCy Schubert      probably also need to add `retain_after_close` to the PAM configuration
318*bf6873c5SCy Schubert      to avoid having the user's credentials deleted before they are logged
319*bf6873c5SCy Schubert      in.
320*bf6873c5SCy Schubert
321*bf6873c5SCy Schubert      The Solaris Kerberos library reportedly does not support prompting for a
322*bf6873c5SCy Schubert      password change of an expired account during authentication.  Supporting
323*bf6873c5SCy Schubert      password change for expired accounts on Solaris with native Kerberos may
324*bf6873c5SCy Schubert      therefore require setting the `defer_pwchange` or `force_pwchange`
325*bf6873c5SCy Schubert      option for selected login applications.  See the description and
326*bf6873c5SCy Schubert      warnings about that option in the pam_krb5(5) man page.
327*bf6873c5SCy Schubert
328*bf6873c5SCy Schubert      Some configuration options may be put in the `krb5.conf` file used by
329*bf6873c5SCy Schubert      your Kerberos libraries (usually `/etc/krb5.conf` or
330*bf6873c5SCy Schubert      `/usr/local/etc/krb5.conf`) instead or in addition to the PAM
331*bf6873c5SCy Schubert      configuration.  See the man page for more details.
332*bf6873c5SCy Schubert
333*bf6873c5SCy Schubert      The Kerberos library, via pam-krb5, will prompt the user to change their
334*bf6873c5SCy Schubert      password if their password is expired, but when using OpenSSH, this will
335*bf6873c5SCy Schubert      only work when `ChallengeResponseAuthentication` is enabled.  Unless
336*bf6873c5SCy Schubert      this option is enabled, OpenSSH doesn't pass PAM messages to the user
337*bf6873c5SCy Schubert      and can only respond to a simple password prompt.
338*bf6873c5SCy Schubert
339*bf6873c5SCy Schubert      If you are using MIT Kerberos, be aware that users whose passwords are
340*bf6873c5SCy Schubert      expired will not be prompted to change their password unless the KDC
341*bf6873c5SCy Schubert      configuration for your realm in `[realms]` in `krb5.conf` contains a
342*bf6873c5SCy Schubert      `master_kdc` setting or, if using DNS SRV records, you have a DNS entry
343*bf6873c5SCy Schubert      for `_kerberos-master` as well as `_kerberos`.
344*bf6873c5SCy Schubert  - title: Debugging
345*bf6873c5SCy Schubert    body: |
346*bf6873c5SCy Schubert      The first step when debugging any problems with this module is to add
347*bf6873c5SCy Schubert      `debug` to the PAM options for the module (either in the PAM
348*bf6873c5SCy Schubert      configuration or in `krb5.conf`).  This will significantly increase the
349*bf6873c5SCy Schubert      logging from the module and should provide a trace of exactly what
350*bf6873c5SCy Schubert      failed and any available error information.
351*bf6873c5SCy Schubert
352*bf6873c5SCy Schubert      Many Kerberos authentication problems are due to configuration issues in
353*bf6873c5SCy Schubert      `krb5.conf`.  If pam-krb5 doesn't work, first check that `kinit` works
354*bf6873c5SCy Schubert      on the same system.  That will test your basic Kerberos configuration.
355*bf6873c5SCy Schubert      If the system has a keytab file installed that's readable by the process
356*bf6873c5SCy Schubert      doing authentication via PAM, make sure that the keytab is current and
357*bf6873c5SCy Schubert      contains a key for `host/<system>` where <system> is the fully-qualified
358*bf6873c5SCy Schubert      hostname.  pam-krb5 prevents KDC spoofing by checking the user's
359*bf6873c5SCy Schubert      credentials when possible, but this means that if a keytab is present it
360*bf6873c5SCy Schubert      must be correct or authentication will fail.  You can check the keytab
361*bf6873c5SCy Schubert      with `klist -k` and `kinit -k`.
362*bf6873c5SCy Schubert
363*bf6873c5SCy Schubert      Be sure that all libraries and modules, including PAM modules, loaded by
364*bf6873c5SCy Schubert      a program use the same Kerberos libraries.  Sometimes programs that use
365*bf6873c5SCy Schubert      PAM, such as current versions of OpenSSH, also link against Kerberos
366*bf6873c5SCy Schubert      directly.  If your sshd is linked against one set of Kerberos libraries
367*bf6873c5SCy Schubert      and pam-krb5 is linked against a different set of Kerberos libraries,
368*bf6873c5SCy Schubert      this will often cause problems (such as segmentation faults, bus errors,
369*bf6873c5SCy Schubert      assertions, or other strange behavior).  Similar issues apply to the
370*bf6873c5SCy Schubert      com_err library or any other library used by both modules and shared
371*bf6873c5SCy Schubert      libraries and by the application that loads them.  If your OS ships
372*bf6873c5SCy Schubert      Kerberos libraries, it's usually best if possible to build all Kerberos
373*bf6873c5SCy Schubert      software on the system against those libraries.
374*bf6873c5SCy Schubert  - title: Implementation Notes
375*bf6873c5SCy Schubert    body: |
376*bf6873c5SCy Schubert      The normal sequence of actions taken for a user login is:
377*bf6873c5SCy Schubert
378*bf6873c5SCy Schubert      ```
379*bf6873c5SCy Schubert          pam_authenticate
380*bf6873c5SCy Schubert          pam_setcred(PAM_ESTABLISH_CRED)
381*bf6873c5SCy Schubert          pam_open_session
382*bf6873c5SCy Schubert          pam_acct_mgmt
383*bf6873c5SCy Schubert      ```
384*bf6873c5SCy Schubert
385*bf6873c5SCy Schubert      and then at logout:
386*bf6873c5SCy Schubert
387*bf6873c5SCy Schubert      ```
388*bf6873c5SCy Schubert          pam_close_session
389*bf6873c5SCy Schubert      ```
390*bf6873c5SCy Schubert
391*bf6873c5SCy Schubert      followed by closing the open PAM session.  The corresponding `pam_sm_*`
392*bf6873c5SCy Schubert      functions in this module are called when an application calls those
393*bf6873c5SCy Schubert      public interface functions.  Not all applications call all of those
394*bf6873c5SCy Schubert      functions, or in particularly that order, although `pam_authenticate` is
395*bf6873c5SCy Schubert      always first and has to be.
396*bf6873c5SCy Schubert
397*bf6873c5SCy Schubert      When `pam_authenticate` is called, pam-krb5 creates a temporary ticket
398*bf6873c5SCy Schubert      cache in `/tmp` and sets the PAM environment variable `PAM_KRB5CCNAME`
399*bf6873c5SCy Schubert      to point to it.  This ticket cache will be automatically destroyed when
400*bf6873c5SCy Schubert      the PAM session is closed and is there only to pass the initial
401*bf6873c5SCy Schubert      credentials to the call to `pam_setcred`.  The module would use a memory
402*bf6873c5SCy Schubert      cache, but memory caches will only work if the application preserves the
403*bf6873c5SCy Schubert      PAM environment between the calls to `pam_authenticate` and
404*bf6873c5SCy Schubert      `pam_setcred`.  Most do, but OpenSSH notoriously does not and calls
405*bf6873c5SCy Schubert      `pam_authenticate` in a subprocess, so this method is used to pass the
406*bf6873c5SCy Schubert      tickets to the `pam_setcred` call in a different process.
407*bf6873c5SCy Schubert
408*bf6873c5SCy Schubert      `pam_authenticate` does a complete authentication, including checking
409*bf6873c5SCy Schubert      the resulting TGT by obtaining a service ticket for the local host if
410*bf6873c5SCy Schubert      possible, but this requires read access to the system keytab.  If the
411*bf6873c5SCy Schubert      keytab doesn't exist, can't be read, or doesn't include the appropriate
412*bf6873c5SCy Schubert      credentials, the default is to accept the authentication.  This can be
413*bf6873c5SCy Schubert      controlled by setting `verify_ap_req_nofail` to true in `[libdefaults]`
414*bf6873c5SCy Schubert      in `/etc/krb5.conf`.  `pam_authenticate` also does a basic authorization
415*bf6873c5SCy Schubert      check, by default calling `krb5_kuserok` (which uses `~/.k5login` if
416*bf6873c5SCy Schubert      available and falls back to checking that the principal corresponds to
417*bf6873c5SCy Schubert      the account name).  This can be customized with several options
418*bf6873c5SCy Schubert      documented in the pam_krb5(5) man page.
419*bf6873c5SCy Schubert
420*bf6873c5SCy Schubert      pam-krb5 treats `pam_open_session` and `pam_setcred(PAM_ESTABLISH_CRED)`
421*bf6873c5SCy Schubert      as synonymous, as some applications call one and some call the other.
422*bf6873c5SCy Schubert      Both copy the initial credentials from the temporary cache into a
423*bf6873c5SCy Schubert      permanent cache for this session and set `KRB5CCNAME` in the
424*bf6873c5SCy Schubert      environment.  It will remember when the credential cache has been
425*bf6873c5SCy Schubert      established and then avoid doing any duplicate work afterwards, since
426*bf6873c5SCy Schubert      some applications call `pam_setcred` or `pam_open_session` multiple
427*bf6873c5SCy Schubert      times (most notably X.Org 7 and earlier xdm, which also throws away the
428*bf6873c5SCy Schubert      module settings the last time it calls them).
429*bf6873c5SCy Schubert
430*bf6873c5SCy Schubert      `pam_acct_mgmt` finds the ticket cache, reads it in to obtain the
431*bf6873c5SCy Schubert      authenticated principal, and then does is another authorization check
432*bf6873c5SCy Schubert      against `.k5login` or the local account name as described above.
433*bf6873c5SCy Schubert
434*bf6873c5SCy Schubert      After the call to `pam_setcred` or `pam_open_session`, the ticket cache
435*bf6873c5SCy Schubert      will be destroyed whenever the calling application either destroys the
436*bf6873c5SCy Schubert      PAM environment or calls `pam_close_session`, which it should do on user
437*bf6873c5SCy Schubert      logout.
438*bf6873c5SCy Schubert
439*bf6873c5SCy Schubert      The normal sequence of events when refreshing a ticket cache (such as
440*bf6873c5SCy Schubert      inside a screensaver) is:
441*bf6873c5SCy Schubert
442*bf6873c5SCy Schubert      ```
443*bf6873c5SCy Schubert          pam_authenticate
444*bf6873c5SCy Schubert          pam_setcred(PAM_REINITIALIZE_CRED)
445*bf6873c5SCy Schubert          pam_acct_mgmt
446*bf6873c5SCy Schubert      ```
447*bf6873c5SCy Schubert
448*bf6873c5SCy Schubert      (`PAM_REFRESH_CRED` may be used instead.)  Authentication proceeds as
449*bf6873c5SCy Schubert      above.  At the `pam_setcred` stage, rather than creating a new ticket
450*bf6873c5SCy Schubert      cache, the module instead finds the current ticket cache (from the
451*bf6873c5SCy Schubert      `KRB5CCNAME` environment variable or the default ticket cache location
452*bf6873c5SCy Schubert      from the Kerberos library) and then reinitializes it with the
453*bf6873c5SCy Schubert      credentials from the temporary `pam_authenticate` ticket cache.  When
454*bf6873c5SCy Schubert      refreshing a ticket cache, the application should not open a session.
455*bf6873c5SCy Schubert      Calling `pam_acct_mgmt` is optional; pam-krb5 doesn't do anything
456*bf6873c5SCy Schubert      different when it's called in this case.
457*bf6873c5SCy Schubert
458*bf6873c5SCy Schubert      If `pam_authenticate` apparently didn't succeed, or if an account was
459*bf6873c5SCy Schubert      configured to be ignored via `ignore_root` or `minimum_uid`,
460*bf6873c5SCy Schubert      `pam_setcred` (and therefore `pam_open_session`) and `pam_acct_mgmt`
461*bf6873c5SCy Schubert      return `PAM_IGNORE`, which tells the PAM library to proceed as if that
462*bf6873c5SCy Schubert      module wasn't listed in the PAM configuration at all.
463*bf6873c5SCy Schubert      `pam_authenticate`, however, returns failure in the ignored user case by
464*bf6873c5SCy Schubert      default, since otherwise a configuration using `ignore_root` with
465*bf6873c5SCy Schubert      pam-krb5 as the only PAM module would allow anyone to log in as root
466*bf6873c5SCy Schubert      without a password.  There doesn't appear to be a case where returning
467*bf6873c5SCy Schubert      `PAM_IGNORE` instead would improve the module's behavior, but if you
468*bf6873c5SCy Schubert      know of a case, please let me know.
469*bf6873c5SCy Schubert
470*bf6873c5SCy Schubert      By default, `pam_authenticate` intentionally does not follow the PAM
471*bf6873c5SCy Schubert      standard for handling expired accounts and instead returns failure from
472*bf6873c5SCy Schubert      `pam_authenticate` unless the Kerberos libraries are able to change the
473*bf6873c5SCy Schubert      account password during authentication.  Too many applications either do
474*bf6873c5SCy Schubert      not call `pam_acct_mgmt` or ignore its exit status.  The fully correct
475*bf6873c5SCy Schubert      PAM behavior (returning success from `pam_authenticate` and
476*bf6873c5SCy Schubert      `PAM_NEW_AUTHTOK_REQD` from `pam_acct_mgmt`) can be enabled with the
477*bf6873c5SCy Schubert      `defer_pwchange` option.
478*bf6873c5SCy Schubert
479*bf6873c5SCy Schubert      The `defer_pwchange` option is unfortunately somewhat tricky to
480*bf6873c5SCy Schubert      implement.  In this case, the calling sequence is:
481*bf6873c5SCy Schubert
482*bf6873c5SCy Schubert      ```
483*bf6873c5SCy Schubert          pam_authenticate
484*bf6873c5SCy Schubert          pam_acct_mgmt
485*bf6873c5SCy Schubert          pam_chauthtok
486*bf6873c5SCy Schubert          pam_setcred
487*bf6873c5SCy Schubert          pam_open_session
488*bf6873c5SCy Schubert      ```
489*bf6873c5SCy Schubert
490*bf6873c5SCy Schubert      During the first `pam_authenticate`, we can't obtain credentials and
491*bf6873c5SCy Schubert      therefore a ticket cache since the password is expired.  But
492*bf6873c5SCy Schubert      `pam_authenticate` isn't called again after `pam_chauthtok`, so
493*bf6873c5SCy Schubert      `pam_chauthtok` has to create a ticket cache.  We however don't want it
494*bf6873c5SCy Schubert      to do this for the normal password change (`passwd`) case.
495*bf6873c5SCy Schubert
496*bf6873c5SCy Schubert      What we do is set a flag in our PAM data structure saying that we're
497*bf6873c5SCy Schubert      processing an expired password, and `pam_chauthtok`, if it sees that
498*bf6873c5SCy Schubert      flag, redoes the authentication with password prompting disabled after
499*bf6873c5SCy Schubert      it finishes changing the password.
500*bf6873c5SCy Schubert
501*bf6873c5SCy Schubert      Unfortunately, when handling password changes this way, `pam_chauthtok`
502*bf6873c5SCy Schubert      will always have to prompt the user for their current password again
503*bf6873c5SCy Schubert      even though they just typed it.  This is because the saved
504*bf6873c5SCy Schubert      authentication tokens are cleared after `pam_authenticate` returns, for
505*bf6873c5SCy Schubert      security reasons.  We could hack around this by saving the password in
506*bf6873c5SCy Schubert      our PAM data structure, but this would let the application gain access
507*bf6873c5SCy Schubert      to it (exactly what the clearing is intended to prevent) and breaks a
508*bf6873c5SCy Schubert      PAM library guarantee.  We could also work around this by having
509*bf6873c5SCy Schubert      `pam_authenticate` get the `kadmin/changepw` authenticator in the
510*bf6873c5SCy Schubert      expired password case and store it for `pam_chauthtok`, but it doesn't
511*bf6873c5SCy Schubert      seem worth the hassle.
512*bf6873c5SCy Schubert  - title: History and Acknowledgements
513*bf6873c5SCy Schubert    body: |
514*bf6873c5SCy Schubert      Originally written by Frank Cusack <fcusack@fcusack.com>, with the
515*bf6873c5SCy Schubert      following acknowledgement:
516*bf6873c5SCy Schubert
517*bf6873c5SCy Schubert      > Thanks to Naomaru Itoi <itoi@eecs.umich.edu>, Curtis King
518*bf6873c5SCy Schubert      > <curtis.king@cul.ca>, and Derrick Brashear <shadow@dementia.org>, all
519*bf6873c5SCy Schubert      > of whom have written and made available Kerberos 4/5 modules.
520*bf6873c5SCy Schubert      > Although no code in this module is directly from these author's
521*bf6873c5SCy Schubert      > modules, (except the get_user_info() routine in support.c; derived
522*bf6873c5SCy Schubert      > from whichever of these authors originally wrote the first module the
523*bf6873c5SCy Schubert      > other 2 copied from), it was extremely helpful to look over their code
524*bf6873c5SCy Schubert      > which aided in my design.
525*bf6873c5SCy Schubert
526*bf6873c5SCy Schubert      The module was then patched for the FreeBSD ports collection with
527*bf6873c5SCy Schubert      additional modifications by unknown maintainers and then was modified by
528*bf6873c5SCy Schubert      Joel Kociolek <joko@logidee.com> to be usable with Debian GNU/Linux.
529*bf6873c5SCy Schubert
530*bf6873c5SCy Schubert      It was packaged by Sam Hartman as the Kerberos v5 PAM module for Debian
531*bf6873c5SCy Schubert      and improved and modified by him and later by Russ Allbery to fix bugs
532*bf6873c5SCy Schubert      and add additional features.  It was then adopted by Andres Salomon, who
533*bf6873c5SCy Schubert      added support for refreshing credentials.
534*bf6873c5SCy Schubert
535*bf6873c5SCy Schubert      The current distribution is maintained by Russ Allbery, who also added
536*bf6873c5SCy Schubert      support for reading configuration from `krb5.conf`, added many features
537*bf6873c5SCy Schubert      for compatibility with the Sourceforge module, commented and
538*bf6873c5SCy Schubert      standardized the formatting of the code, and overhauled the
539*bf6873c5SCy Schubert      documentation.
540*bf6873c5SCy Schubert
541*bf6873c5SCy Schubert      Thanks to Douglas E. Engert for the initial implementation of PKINIT
542*bf6873c5SCy Schubert      support.  I have since modified and reworked it extensively, so any bugs
543*bf6873c5SCy Schubert      or compilation problems are my fault.
544*bf6873c5SCy Schubert
545*bf6873c5SCy Schubert      Thanks to Markus Moeller for lots of debugging and multiple patches and
546*bf6873c5SCy Schubert      suggestions for improved portability.
547*bf6873c5SCy Schubert
548*bf6873c5SCy Schubert      Thanks to Booker Bense for the implementation of the `alt_auth_map`
549*bf6873c5SCy Schubert      option.
550*bf6873c5SCy Schubert
551*bf6873c5SCy Schubert      Thanks to Sam Hartman for the FAST support implementation.
552