]> git.ipfire.org Git - thirdparty/krb5.git/log
thirdparty/krb5.git
2 years agoUpdate for krb5-1.19.4-postrelease krb5-1.19
Greg Hudson [Sun, 13 Nov 2022 06:16:25 +0000 (01:16 -0500)] 
Update for krb5-1.19.4-postrelease

2 years agoUpdate for krb5-1.19.4 krb5-1.19.4-final
Greg Hudson [Fri, 11 Nov 2022 21:51:24 +0000 (16:51 -0500)] 
Update for krb5-1.19.4

2 years agomake regen
Greg Hudson [Fri, 11 Nov 2022 18:50:20 +0000 (13:50 -0500)] 
make regen

2 years agoFix integer overflows in PAC parsing
Greg Hudson [Tue, 18 Oct 2022 00:25:11 +0000 (20:25 -0400)] 
Fix integer overflows in PAC parsing

In krb5_parse_pac(), check for buffer counts large enough to threaten
integer overflow in the header length and memory length calculations.
Avoid potential integer overflows when checking the length of each
buffer.  Credit to OSS-Fuzz for discovering one of the issues.

CVE-2022-42898:

In MIT krb5 releases 1.8 and later, an authenticated attacker may be
able to cause a KDC or kadmind process to crash by reading beyond the
bounds of allocated memory, creating a denial of service.  A
privileged attacker may similarly be able to cause a Kerberos or GSS
application service to crash.  On 32-bit platforms, an attacker can
also cause insufficient memory to be allocated for the result,
potentially leading to remote code execution in a KDC, kadmind, or GSS
or Kerberos application server process.  An attacker with the
privileges of a cross-realm KDC may be able to extract secrets from a
KDC process's memory by having them copied into the PAC of a new
ticket.

(cherry picked from commit ea92d2f0fcceb54a70910fa32e9a0d7a5afc3583)

ticket: 9074
version_fixed: 1.19.4

2 years agoFix uncommon PKINIT memory leak
sashan [Sun, 29 May 2022 08:32:57 +0000 (10:32 +0200)] 
Fix uncommon PKINIT memory leak

PKINIT per-request module data objects are normally created by
pkinit_server_verify_padata() and freed by
pkinit_server_return_padata().  In some unusual circumstances, the KDC
may not call the return_padata method after verification succeeds.
Add a free_modreq method and free the object there instead.

[ghudson@mit.edu: rewrote commit message]

(cherry picked from commit 883415036a4b4e0372b84a5a6e46c10b3a67aba0)

ticket: 9065
version_fixed: 1.19.4

2 years agoFree verto context later in KDC cleanup
Greg Hudson [Fri, 3 Jun 2022 18:38:45 +0000 (14:38 -0400)] 
Free verto context later in KDC cleanup

The KDC supplies the verto context to kdcpreauth modules via the loop
method (added in commit 83b4ecd20e50ad330cd761977d5dadefe30a785b).
This context should remain valid until kdcpreauth modules are
unloaded, as modules might refer to it during cleanup.  In particular,
the OTP module references the verto context when freeing the RADIUS
client object (commit e89abc2d4ea1fea1ec28d470f297514b828e4842), which
can cause a memory error during KDC shutdown without this change.

(cherry picked from commit 8dcace04945723cd6a3c8ea2c1ba467c22eb6584)

ticket: 9064
version_fixed: 1.19.4

2 years agoFix memory leak in OTP kdcpreauth module
Greg Hudson [Fri, 3 Jun 2022 18:30:42 +0000 (14:30 -0400)] 
Fix memory leak in OTP kdcpreauth module

In otp_edata(), free the generated nonce.

(cherry picked from commit 5ad465bc8e0d957a4945218bea487b77622bf433)

ticket: 9063
version_fixed: 1.19.4

3 years agoUpdate for krb5-1.19.3-postrelease
Greg Hudson [Fri, 18 Mar 2022 21:35:37 +0000 (17:35 -0400)] 
Update for krb5-1.19.3-postrelease

3 years agoUpdate for krb5-1.19.3 krb5-1.19.3-final
Greg Hudson [Thu, 10 Mar 2022 06:48:26 +0000 (01:48 -0500)] 
Update for krb5-1.19.3

3 years agomake regen
Greg Hudson [Thu, 10 Mar 2022 05:47:26 +0000 (00:47 -0500)] 
make regen

3 years agoUpdate copyright years to 2022
Greg Hudson [Wed, 23 Feb 2022 06:27:01 +0000 (01:27 -0500)] 
Update copyright years to 2022

3 years agoFix conformance issue in GSSAPI tests
Greg Hudson [Wed, 18 Aug 2021 16:07:04 +0000 (12:07 -0400)] 
Fix conformance issue in GSSAPI tests

Although some C compilers allow a function returning void to be called
in a return statement from another function returning void, it isn't
conformant and generates an error from (at least) the HP-UX native
compiler.  Reported by Michael Osipov.

(cherry picked from commit 6fe25e755f510c0fc86b899d96db9f80acf03ac5)

ticket: 9023
version_fixed: 1.19.3

3 years agoFix KDC null deref on TGS inner body null server
Greg Hudson [Tue, 3 Aug 2021 05:15:27 +0000 (01:15 -0400)] 
Fix KDC null deref on TGS inner body null server

After the KDC decodes a FAST inner body, it does not check for a null
server.  Prior to commit 39548a5b17bbda9eeb63625a201cfd19b9de1c5b this
would typically result in an error from krb5_unparse_name(), but with
the addition of get_local_tgt() it results in a null dereference.  Add
a null check.

Reported by Joseph Sutton of Catalyst.

CVE-2021-37750:

In MIT krb5 releases 1.14 and later, an authenticated attacker can
cause a null dereference in the KDC by sending a FAST TGS request with
no server field.

(cherry picked from commit d775c95af7606a51bf79547a94fa52ddd1cb7f49)

ticket: 9008
version_fixed: 1.19.3

4 years agoUpdate for krb5-1.19.2 krb5-1.19.2-final
Greg Hudson [Thu, 22 Jul 2021 04:40:48 +0000 (00:40 -0400)] 
Update for krb5-1.19.2

4 years agomake regen
Greg Hudson [Thu, 22 Jul 2021 03:32:22 +0000 (23:32 -0400)] 
make regen

4 years agoFix defcred leak in krb5 gss_inquire_cred()
Greg Hudson [Wed, 21 Jul 2021 17:43:39 +0000 (13:43 -0400)] 
Fix defcred leak in krb5 gss_inquire_cred()

Commit 1cd2821c19b2b95e39d5fc2f451a035585a40fa5 altered the memory
management of krb5_gss_inquire_cred(), introducing defcred to act as
an owner pointer when the function must acquire a default credential.
The commit neglected to update the code to release the default cred
along the successful path.  The old code does not trigger because
cred_handle is now reassigned, so the default credential is leaked.

Reported by Pavel Březina.

(a minimal alternative to commit 593e16448e1af23eef74689afe06a7bcc86e79c7)

ticket: 9016
version_fixed: 1.19.2

4 years agoFix use-after-free during krad remote_shutdown()
Robbie Harwood [Sat, 29 May 2021 17:25:59 +0000 (13:25 -0400)] 
Fix use-after-free during krad remote_shutdown()

Since elements of the queue can be removed on out-of-memory errors,
the correct call is K5_TAILQ_FOREACH_SAFE, not K5_TAILQ_FOREACH.
Reported by Coverity.

(cherry picked from commit 8c88defb16b34937d5b72b4832c854ce2dbe32d1)

ticket: 9015
version_fixed: 1.19.2

4 years agoUsing locking in MEMORY krb5_cc_get_principal()
Greg Hudson [Sun, 20 Jun 2021 23:24:07 +0000 (19:24 -0400)] 
Using locking in MEMORY krb5_cc_get_principal()

Without locking, the principal pointer could be freed out from under
krb5_copy_principal() by another thread calling krb5_cc_initialize()
or krb5_cc_destroy().

(cherry picked from commit 1848447291c68e21311f441b0458ae53471d00d3)

ticket: 9014
version_fixed: 1.19.2

4 years agoUpdate IRC pointer in resources.rst
Greg Hudson [Thu, 27 May 2021 19:20:16 +0000 (15:20 -0400)] 
Update IRC pointer in resources.rst

(cherry picked from commit dbdde71a924777f271288f64012c6f2fa08fdda9)

4 years agoFix KDC null deref on bad encrypted challenge
Joseph Sutton [Tue, 6 Jul 2021 23:47:44 +0000 (11:47 +1200)] 
Fix KDC null deref on bad encrypted challenge

The function ec_verify() in src/kdc/kdc_preauth_ec.c contains a check
to avoid further processing if the armor key is NULL.  However, this
check is bypassed by a call to k5memdup0() which overwrites retval
with 0 if the allocation succeeds.  If the armor key is NULL, a call
to krb5_c_fx_cf2_simple() will then dereference it, resulting in a
crash.  Add a check before the k5memdup0() call to avoid overwriting
retval.

CVE-2021-36222:

In MIT krb5 releases 1.16 and later, an unauthenticated attacker can
cause a null dereference in the KDC by sending a request containing a
PA-ENCRYPTED-CHALLENGE padata element without using FAST.

[ghudson@mit.edu: trimmed patch; added test case; edited commit
message]

(cherry picked from commit fc98f520caefff2e5ee9a0026fdf5109944b3562)

ticket: 9007
version_fixed: 1.19.2

4 years agoFix doc build for Sphinx 4.0
Greg Hudson [Wed, 26 May 2021 19:08:28 +0000 (15:08 -0400)] 
Fix doc build for Sphinx 4.0

Use app.add_css_file() to register krb5.css if possible (it was added
in Sphinx 1.8), since the old name app.add_stylesheet() was removed in
Sphinx 4.0.

Use the highlight directive instead of the highlightlang directive,
which was removed in Sphinx 4.0.

Remove two duplicate table of contents entries to fix warnings.

In the Github Actions configuration, add a second doc build using the
newest version of Sphinx.

(cherry picked from commit 3fa40a32e22cb9de91fa1d18deddcba446515855)

ticket: 9006
version_fixed: 1.19.2

4 years agoFix argument type errors on Windows
Greg Hudson [Mon, 26 Apr 2021 18:46:31 +0000 (14:46 -0400)] 
Fix argument type errors on Windows

Fix three Windows-specific argument type errors, including a crash bug
in the default replay cache type.  Change the compiler flags to treat
several argument type warnings as errors.

The replay cache bug was reported by Thomas Wagner.

(cherry picked from commit 65b21aee6ab5e7d0851302b98647261c15c71c96)

ticket: 9005
version_fixed: 1.19.2

4 years agoAvoid rand() in aes-gen test program
Greg Hudson [Thu, 25 Mar 2021 16:00:54 +0000 (12:00 -0400)] 
Avoid rand() in aes-gen test program

rand() can output different sequences on different platforms with the
same seed, and (since commit cb5f190056ef4d123c5fe5d4923982b830288438)
we want fixed output.  Use specified inputs instead.  Reported by Ken
Hornstein.

(cherry picked from commit ae40b2eabb8954679e55f0ae79c3aaa96974fb40)

ticket: 8992
version_fixed: 1.19.2

4 years agoFix typo in enctypes.rst
Weijun Wang [Thu, 25 Feb 2021 18:13:53 +0000 (13:13 -0500)] 
Fix typo in enctypes.rst

(cherry picked from commit 61375be10beed5e95ea241e22fc580483caabf52)

ticket: 8989
version_fixed: 1.19.2

4 years agoUpdate for krb5-1.19.1-postrelease
Greg Hudson [Fri, 19 Feb 2021 06:39:26 +0000 (01:39 -0500)] 
Update for krb5-1.19.1-postrelease

4 years agoUpdate for krb5-1.19.1 krb5-1.19.1-final
Greg Hudson [Thu, 18 Feb 2021 16:30:14 +0000 (11:30 -0500)] 
Update for krb5-1.19.1

4 years agomake regen
Greg Hudson [Thu, 18 Feb 2021 16:24:28 +0000 (11:24 -0500)] 
make regen

4 years agoSynchronize command-line option documentation
Robbie Harwood [Fri, 15 Jan 2021 20:55:01 +0000 (15:55 -0500)] 
Synchronize command-line option documentation

Command-line options are described in the following places:

- .rst file "SYNOPSIS" section
- .rst file "OPTIONS" section
- parameters to getopt()
- results of getopt() that are actually handled
- a usage() or xusage() function
- occasionally, a long form in usage()/xusage()
- occasionally, libss subcommand specifications

Over time, these have drifted.  Make an effort to correct this drift,
marking deprecated options as such.  For consistency, remove mention
of long arguments that have an equivalent short form.

(cherry picked from commit bd912c8583261f1f2521a06e5c05757cec032580)

ticket: 8987
version_fixed: 1.19.1

4 years agoLoad certs when checking pkinit_identities values
Ken Hornstein [Thu, 28 Jan 2021 02:21:19 +0000 (21:21 -0500)] 
Load certs when checking pkinit_identities values

Move the crypto_load_certs() probe from pkinit_identity_initialize()
to process_option_identity().  This will attempt to load a certificate
for each pkinit_identities value, and if the certificate load fails to
move to the next line.

For PKCS11, return an error if pkinit_open_session() fails, but do not
fail in pkinit_open_session() just because identity prompts are
deferred.

[ghudson@mit.edu: added test case; moved cert probe to
process_option_identity(); rewrote commit message]

(cherry picked from commit 13ae08e70a05768d4f65978ce1a8d4e16fec0d35)

ticket: 8984
version_fixed: 1.19.1

4 years agoRestore krb5_set_default_tgs_ktypes()
Greg Hudson [Fri, 12 Feb 2021 20:11:25 +0000 (15:11 -0500)] 
Restore krb5_set_default_tgs_ktypes()

Samba only uses the correct name (krb5_set_default_tgs_enctypes) if it
cannot find the old one in the library, so removing the name causes a
linker error for existing builds.

(cherry picked from commit 17ee97788611f8f8f4a6bd69968a9499f4db2215)

ticket: 8985
version_fixed: 1.19.1

4 years agoUpdate for krb5-1.19-postrelease
Greg Hudson [Mon, 1 Feb 2021 23:31:09 +0000 (18:31 -0500)] 
Update for krb5-1.19-postrelease

4 years agoUpdate for krb5-1.19 krb5-1.19-final
Greg Hudson [Mon, 1 Feb 2021 19:04:23 +0000 (14:04 -0500)] 
Update for krb5-1.19

4 years agoUpdate for krb5-1.19-beta2-postrelease
Greg Hudson [Mon, 11 Jan 2021 18:02:17 +0000 (13:02 -0500)] 
Update for krb5-1.19-beta2-postrelease

4 years agoUpdate for krb5-1.19-beta2 krb5-1.19-beta2
Greg Hudson [Mon, 11 Jan 2021 17:41:15 +0000 (12:41 -0500)] 
Update for krb5-1.19-beta2

4 years agomake regen
Greg Hudson [Mon, 11 Jan 2021 17:27:59 +0000 (12:27 -0500)] 
make regen

4 years agoUpdate copyright years to 2021
Greg Hudson [Mon, 11 Jan 2021 17:24:35 +0000 (12:24 -0500)] 
Update copyright years to 2021

4 years agoFix runstatedir makefile substitution
Greg Hudson [Tue, 5 Jan 2021 19:37:44 +0000 (14:37 -0500)] 
Fix runstatedir makefile substitution

Set localstatedir and runstatedir in config/pre.in so that the default
runstatedir value of ${localstatedir}/run works.  Reported by Mike
Jetzer.

(cherry picked from commit fd005a1967510004c9197f7da9f1d85ee81f4734)

ticket: 8975
version_fixed: 1.19

4 years agoRevert dns_canonicalize_hostname default to true
Greg Hudson [Mon, 21 Dec 2020 15:25:58 +0000 (10:25 -0500)] 
Revert dns_canonicalize_hostname default to true

Field testing of dns_canonicalize_hostname=fallback (ticket 8911)
revealed more disruptive edge cases than anticipated.  Many were fixed
by ticket 8930, but host-based GSS initiator names were recently
discovered to not work, and one other edge case could not be resolved
without a change to external code.

Restore the default to true for now.  Set the value to fallback in the
test suite, to continue testing the desired configuration and to avoid
restoring tests/resolve.

(cherry picked from commit 15f8c4fd7d62d07ea2759a7b6d684c000430559e)

ticket: 8973
version_fixed: 1.19

4 years agoImplement fallback for GSS acceptor names
Greg Hudson [Mon, 28 Dec 2020 20:41:46 +0000 (15:41 -0500)] 
Implement fallback for GSS acceptor names

Commit 3fcc365a6f049730b3f47168f7112c03997c5c0b added fallback support
to krb5_rd_req(), but acquiring acceptor creds for a host-based name
could still fail within check_keytab() in the krb5 mech.

Add an internal libkrb5 API k5_kt_have_match() to check for a matching
keytab entry with canonicalization, and use it in check_keytab().  Add
a library-internal function k5_sname_wildcard_host() to share logic
between rd_req and k5_kt_have_match().

(cherry picked from commit 7e0a2a7a3a76205ebd7192f06a99f23bad8dc5bd)

ticket: 8971
version_fixed: 1.19

4 years agoUpdate kvno(1) synopsis with missing options
Robbie Harwood [Tue, 24 Nov 2020 17:52:02 +0000 (12:52 -0500)] 
Update kvno(1) synopsis with missing options

Commit becd1ad6830b526d08ddaf5b2b6f213154c6446c attempted to unify the
synopsis, option descriptions, and xusage(), but missed several
options in the synopsis.

(cherry picked from commit b89d63a51271bd0258b9d24732e9f0cb0ba5d006)

ticket: 8969
version_fixed: 1.19

4 years agoContinue on KRB5_FCC_NOFILE in KCM cache iteration
Greg Hudson [Sat, 21 Nov 2020 06:41:41 +0000 (01:41 -0500)] 
Continue on KRB5_FCC_NOFILE in KCM cache iteration

Although Heimdal's KCM client only continues after KRB5_CC_END,
Heimdal's and macOS's KCM server returns KRB5_FCC_NOFILE if a cache
uuid no longer exists.  Check for both errors during iteration.  Also
set ret to 0 when continuing, in case the skipped uuid is the last one
in the list.

(cherry picked from commit f7b3cb8bbe90817f7bfbc545f1e427c16f52a79c)

ticket: 8967
version_fixed: 1.19

4 years agoAdd support for start_realm cache config
Greg Hudson [Mon, 14 Dec 2020 18:16:17 +0000 (13:16 -0500)] 
Add support for start_realm cache config

When making TGS requests, if start_realm is set in the cache, use the
named realm to look up the initial TGT for referral or cross-realm
requests.  (Also correct a comment in struct _tkt_creds_context: the
ccache field is an owner pointer, not an alias.)

Add an internal API k5_cc_store_primary_cred(), which sets start_realm
if the cred being stored is a TGT for a realm other than the client
realm.  Use this API when acquiring initial tickets with a
caller-specified output ccache, when renewing or validating tickets
with kinit, when accepting a delegated credential in a GSS context,
and when storing a single cred with kvno --out-cache.

(cherry picked from commit 0d56740ab9fcc40dc7f46c6fbebdf8f1214f9d96)

ticket: 8332
version_fixed: 1.19

4 years agoUpdate for krb5-1.19-beta1-postrelease
Greg Hudson [Mon, 30 Nov 2020 17:56:19 +0000 (12:56 -0500)] 
Update for krb5-1.19-beta1-postrelease

4 years agoUpdate for krb5-1.19-beta1 krb5-1.19-beta1
Greg Hudson [Mon, 30 Nov 2020 06:41:37 +0000 (01:41 -0500)] 
Update for krb5-1.19-beta1

4 years agomake regen
Greg Hudson [Mon, 30 Nov 2020 06:33:39 +0000 (01:33 -0500)] 
make regen

4 years agoUpdate config.guess and config.sub
Greg Hudson [Sun, 29 Nov 2020 20:23:11 +0000 (15:23 -0500)] 
Update config.guess and config.sub

Update from https://git.savannah.gnu.org/cgit/config.git commit
888c8e3d5f7bf7464bba83aaf54304a956eefa60.

4 years agoUpdate README for krb5-1.19
Greg Hudson [Fri, 27 Nov 2020 06:21:51 +0000 (01:21 -0500)] 
Update README for krb5-1.19

4 years agoUpdate features list for 1.19 1140/head
Greg Hudson [Sun, 22 Nov 2020 17:41:22 +0000 (12:41 -0500)] 
Update features list for 1.19

4 years agoImprove duplicate checking in gss_add_cred() 1137/head
sashan [Fri, 20 Nov 2020 15:22:52 +0000 (16:22 +0100)] 
Improve duplicate checking in gss_add_cred()

If both input and output credentials are provided to gss_add_cred() or
gss_add_cred_from(), check for a duplicate element in the input handle.

[ghudson@mit.edu: reorganized code; rewrote commit message]

ticket: 8966 (new)

4 years agoInstall shared libraries as executable 1135/head
Robbie Harwood [Tue, 23 Aug 2016 20:45:26 +0000 (16:45 -0400)] 
Install shared libraries as executable

RPM expects this behavior, and systems with contrary policies (like
Debian) address permissions at the packaging layer.  Most other build
systems appear to install shared libraries as executable.

[ghudson@mit.edu: edited commit message]

ticket: 8965 (new)

4 years agoAdd GSS credential store documentation 1115/head
Greg Hudson [Fri, 13 Nov 2020 20:32:31 +0000 (15:32 -0500)] 
Add GSS credential store documentation

Add documentation for gss_acquire_cred_from() and
gss_store_cred_into(), including descriptions of the currently
supported options for the krb5 mechanism.

ticket: 8964 (new)

4 years agoAdd verify option to cred store
Simo Sorce [Tue, 6 Oct 2020 20:12:35 +0000 (16:12 -0400)] 
Add verify option to cred store

The verify option instructs acquire_cred_from to verify a credential
obtained via a password, using the default keytab or the keytab
provided via the "keytab" key.  The value is a principal name (in
string form) for a key in the selected keytab, or the empty string to
use any host key in the keytab.

[ghudson@mit.edu: fleshed out tests; adjusted verify params contracts;
rewrote commit message]

ticket: 8963 (new)

4 years agoAdd password option to cred store
Simo Sorce [Wed, 16 Sep 2020 19:07:09 +0000 (15:07 -0400)] 
Add password option to cred store

Add an option for initial creds acquisition via password to
gss_acquire_cred_from(), storing credentials in a new MEMORY ccache.

Move existing cred store tests from t_gssapi.py to t_credstore.py and
add new ones for password acquisition.

[ghudson@mit.edu: squashed commits; rewrote commit message]

ticket: 8962 (new)

4 years agoFix gss_acquire_cred_from() IAKERB handling
Simo Sorce [Mon, 26 Oct 2020 18:47:19 +0000 (14:47 -0400)] 
Fix gss_acquire_cred_from() IAKERB handling

Add a separate IAKERB entry point for gss_acquire_cred_from() and
correctly pass down the iakerb flag to acquire_cred_context(), so that
we don't attempt to acquire initial credentials directly.

[ghudson@mit.edu: rebased earlier in sequence; rewrote commit message]

ticket: 8961 (new)

4 years agoBe stricter about ASN.1 decoding 1129/head
Demi M. Obenour [Sun, 25 Oct 2020 15:05:23 +0000 (11:05 -0400)] 
Be stricter about ASN.1 decoding

Remove support for BER indefinite-length encodings, which are not
valid in DER.  Enforce validity of digits in GeneralizedTime values.
Reject signed integer encodings large enough to possibly overflow
intmax_t, and use regular arithmetic to avoid the undefined behavior
of left-shifting a negative integer.  Reject trailing garbage in
explicitly-tagged single values.  Remove the unnecessary
KRB5_GENEROUS_LR_TYPE workaround; our KDC doesn't generate last-req
information, so the broken pre-2000 encoding behavior had no impact.

[ghudson@mit.edu: edited commit message]

4 years agoFix compatibility with upcoming autoconf 2.70 1133/head
Sergei Trofimovich [Fri, 6 Nov 2020 08:14:57 +0000 (08:14 +0000)] 
Fix compatibility with upcoming autoconf 2.70

Mainline autoconf generates no shell code for AC_CONFIG_AUX_DIR().
Call it unconditionally to avoid a syntax error.

[ghudson@mit.edu: rewrote commit message]

ticket: 8960 (new)
tags: pullup
target_version: 1.18-next
target_version: 1.17-next

4 years agoAdd recursion limit for ASN.1 indefinite lengths
Greg Hudson [Sat, 31 Oct 2020 21:07:05 +0000 (17:07 -0400)] 
Add recursion limit for ASN.1 indefinite lengths

The libkrb5 ASN.1 decoder supports BER indefinite lengths.  It
computes the tag length using recursion; the lack of a recursion limit
allows an attacker to overrun the stack and cause the process to
crash.  Reported by Demi Obenour.

CVE-2020-28196:

In MIT krb5 releases 1.11 and later, an unauthenticated attacker can
cause a denial of service for any client or server to which it can
send an ASN.1-encoded Kerberos message of sufficient length.

ticket: 8959 (new)
tags: pullup
target_version: 1.18-next
target_version: 1.17-next

4 years agoAllow KDC to canonicalize realm in TGS client 1108/head
Greg Hudson [Wed, 26 Aug 2020 20:49:37 +0000 (16:49 -0400)] 
Allow KDC to canonicalize realm in TGS client

Active Directory canonicalizes the srealm field of TGS replies,
whether or not the client requests canonicalization.  Allow this for
regular TGS and S4U2Self referrals queries by comparing only the name
part of the service principal.  The S4U2Proxy code is already correct.

ticket: 8943 (new)

4 years agoAvoid daylight savings time issues in tests 1132/head
Greg Hudson [Sun, 1 Nov 2020 04:35:05 +0000 (00:35 -0400)] 
Avoid daylight savings time issues in tests

4 years agoMove more KDC checks to validate_tgs_request() 1122/head
Greg Hudson [Mon, 5 Oct 2020 16:01:32 +0000 (12:01 -0400)] 
Move more KDC checks to validate_tgs_request()

Move the following validity checks:

* the INVALID ticket flag check from kdc_process_tgs_req()
* the lineage check from process_tgs_req()
* the user-to-user second ticket client check from process_tgs_req()
* all S4U2Self validity checks from kdc_process_s4u2self_req()
* S4U2Proxy validity checks (but not KDB authorization checks) from
  kdc_process_s4u2proxy_req()

In process_tgs_req(), call validate_tgs_request() after
kdc_process_s4u2self_req() and decrypt_2ndtkt() so that their outputs
can be used as validation inputs.  Add stkt and is_crossrealm locals
for convenience, and remove st_idx.

There are some minor behavior changes:

* For invalid S4U2Self request options, the status string is changed
  from "INVALID AS OPTIONS" to "INVALID S4U2SELF OPTIONS".

* For a header ticket with the INVALID flag, the reply code is changed
  to KRB_AP_ERR_TKT_NYV (as specified in RFC 4120) and the status
  string to "TICKET NOT VALID".

* For a lineage check failure, the explicit KDC log is removed, and
  the status string is changed to "INVALID LINEAGE".

* For a user-to-user second ticket client mismatch, the explicit audit
  call is removed, and the log message does not include the second
  ticket client.

* e_data returned from the KDB check_policy_as() method will be
  included in the error for S4U2Self requests.

ticket: 8953 (new)

4 years agoUse PKG_CHECK_MODULES for system library com_err 1111/head
Anonymous Maarten [Fri, 4 Sep 2020 20:45:43 +0000 (16:45 -0400)] 
Use PKG_CHECK_MODULES for system library com_err

[ghudson@mit.edu: whitespace changes; reverted man page change]

ticket: 8957 (new)

4 years agoFix minor static analysis defects 1126/head
Robbie Harwood [Thu, 15 Oct 2020 22:15:29 +0000 (18:15 -0400)] 
Fix minor static analysis defects

Remove an unused variable in krb5_ldap_create().  Handle the return
value from krb5_dbe_get_string() in the certauth test plugin module.
Handle the return value from k5_expand_path_tokens() in
k5_rc_default().  Remove dead assignments in
krb5_get_credentials_for_user() and kg_accept_krb5().

[ghudson@mit.edu: squashed and edited commit message; simplified
k5_rc_default() change]

4 years agoUnregister thread key in SPNEGO finalization 1127/head
Greg Hudson [Fri, 16 Oct 2020 15:35:18 +0000 (11:35 -0400)] 
Unregister thread key in SPNEGO finalization

Commit d160bc733a3dbeb6d84f4e175234ff18738d9f66 (ticket 7045) added a
new thread key K5_KEY_GSS_SPNEGO_STATUS and registered it in SPNEGO
library initialization, but neglected to unregister it in
finalization.  As a result, loading, unloading, and reloading
libgssapi_krb5 could throw an assertion failure if libkrb5support
remained loaded.  Unregister the key in SPNEGO finalization and add a
test case.

Reported and investigated by Adam Dabrowski.

ticket: 8614
tags: pullup
target_version: 1.18-next
target_version: 1.17-next

4 years agoUpdate Gladman AES code 1124/head
Greg Hudson [Sat, 10 Oct 2020 15:18:12 +0000 (11:18 -0400)] 
Update Gladman AES code

Update lib/crypto/builtin/aes to commit
8798ad829374cd5ff312f55ba3ccccfcf586fa11 of
https://github.com/BrianGladman/aes .

The following changes are made to the upstream code:

* In aes.h, #defines are added to give the linker-visible symbols a
  prefix.

* In aes.h, AES_192 is undefined, since we only need AES-128 and
  AES-256.

* In aesopt.h, USE_INTEL_AES_IF_PRESENT and USE_VIA_ACE_IF_PRESENT are
  suppressed by changing the corresponding "#if 1"s to "#if 0"s.

* In aesopt.h, the conditionals for ENC_UNROLL, DEC_UNROLL, ENC_ROUND,
  LAST_ENC_ROUND, DEC_ROUND, LAST_DEC_ROUND, and KEY_SCHED are changed
  from "#if 1" to "#if !defined(CONFIG_SMALL) ||
  defined(CONFIG_SMALL_NO_CRYPTO)".

bigredbutton: whitespace

ticket: 8954

4 years agoFix Python deprecation warnings 1123/head
Greg Hudson [Wed, 7 Oct 2020 05:25:01 +0000 (01:25 -0400)] 
Fix Python deprecation warnings

Address all warnings issued by "python -Werror::DeprecationWarning"
in the test suite and doc build, as of Python 3.8.2.

4 years agoMinimize usage of tgs_server in KDC 1120/head
Greg Hudson [Fri, 25 Sep 2020 15:12:34 +0000 (11:12 -0400)] 
Minimize usage of tgs_server in KDC

Where possible, use the realm of the request server principal
(canonicalized via KDB lookup, if available) in preference to
tgs_server.  This change facilitates alias realm support and potential
future support for serving multiple realms from the same KDB.

S4U2Self local user testing currently uses the uncanonicalized request
realm after this change, which will require attention for alias realm
support.

FAST armor ticket checking is unaffected by this change (it still
compares against tgs_server).  This check poses no issue for realm
aliases, as both tgs_server and the armor ticket server should have
canonical realms, but it will require attention for multi-realm KDB
support.

Remove is_local_principal() as it is no longer used.  Add an
is_local_tgs_principal() helper and shorten is_cross_tgs_principal().

Move the header ticket lineage check from kdc_process_tgs_req() to
process_tgs_req(), where we have the canonical request server name and
a more natural indication of whether the request was an S4U2Self
request.

4 years agoAvoid passing DB entry structures in KDC 1121/head
Greg Hudson [Wed, 30 Sep 2020 06:12:00 +0000 (02:12 -0400)] 
Avoid passing DB entry structures in KDC

When validating AS or TGS requests, pass pointers to DB entry
structures, not the structures themselves.

4 years agoFix doc issues with newer Doxygen and Sphinx 1119/head
Greg Hudson [Tue, 22 Sep 2020 15:32:00 +0000 (11:32 -0400)] 
Fix doc issues with newer Doxygen and Sphinx

In krb5.hin, fix some apparently harmless whitespace nits in comments
which cause newer Doxygen versions to generate <detaileddescription>
content containing <linebreak/> tags.  Also remove the explicit "@n"
linebreaks in the responder JSON schemas, instead relying on Doxygen
markup support (added in Doxygen 1.8).  Add a verbatim handler in
doxybuilder_types.py to translate the resulting section, replacing the
linebreak handler which is no longer needed.

css_files is deprecated in Sphinx.  Instead use app.add_stylesheet()
in a setup function in conf.py.  (Sphinx 1.8 has a slightly simpler
method, but that is currently too recent to depend on.)  Also remove
the obsolete html_use_smartypants setting.

In func_document.tmpl, fix an incorrent use of "is".

ticket: 8952 (new)

4 years agoUpdate SRV record documentation 1117/head
Greg Hudson [Sun, 20 Sep 2020 16:02:38 +0000 (12:02 -0400)] 
Update SRV record documentation

The KDC has listened to TCP connections by default since commit
8d88e2ab00be126237569dc72827ced2ce6b7d04 (ticket 6731).  Update the
documentation for _kerberos._tcp accordingly.

Correct a formatting error introduced by commit
10eb93809b1af06e2b1147aee2e3e50058ba1bbd (ticket 8921).

For _kpasswd._udp, if the _kerberos-adm._tcp fallback is used, the
port number is changed to 464, not 749.

Add entries for _kerberos-master._tcp and _kpasswd._tcp.

ticket: 8948

4 years agoAdd doc build to Github Actions config 1118/head
Greg Hudson [Sun, 20 Sep 2020 20:41:08 +0000 (16:41 -0400)] 
Add doc build to Github Actions config

Add a second workflow to build documentation, with the HTML output as
a generated artifact.  Skip the doc workflow if no documentation files
were changed.  Skip the existing build workflow if no source files
were changed.

4 years agoAllow aliases when matching U2U second ticket 1116/head
Isaac Boukris [Mon, 21 Sep 2020 22:17:11 +0000 (01:17 +0300)] 
Allow aliases when matching U2U second ticket

In process_tgs_req() when verifying the user-to-user second ticket,
compare the canonical names of the request server and the second
ticket client.

[ghudson@mit.edu: expanded commit message; trimmed tests]

ticket: 8951 (new)

4 years agoAdjust KDC alias helper function contract
Isaac Boukris [Mon, 21 Sep 2020 22:11:39 +0000 (01:11 +0300)] 
Adjust KDC alias helper function contract

Change the name of is_client_alias() to is_client_db_alias(), and
change the contract so that the already-canonical principal name comes
from a DB entry (which is less flexible, but clearer since DB entries
always contain canonical principal names).  Make the function
available outside of kdc_util.c.

[ghudson@mit.edu: clarified commit message]

4 years agoDocument enctype migration 1114/head
Greg Hudson [Wed, 16 Sep 2020 23:12:34 +0000 (19:12 -0400)] 
Document enctype migration

In enctypes.rst, note that des3-cbc-sha1 and arcfour-hmac are
deprecated, and add a paragraph about des3-cbc-sha1 support being
removed in the future.  Add a section on migrating away from legacy
enctypes (briefer than the existing advanced/retiring-des.rst and not
specific to single-DES).

In kdc_conf.rst, note that des3-cbc-sha1 and arcfour-hmac are
deprecated.

ticket: 8950 (new)

4 years agoWarn when des3-cbc-sha1 is used for initial auth
Greg Hudson [Tue, 15 Sep 2020 00:40:29 +0000 (20:40 -0400)] 
Warn when des3-cbc-sha1 is used for initial auth

During initial authentication, if des3-cbc-sha1 is used for either the
reply key or session key, display a warning that it will be disabled.

ticket: 8947 (new)

4 years agoImprove KDC alias checking for S4U requests 1113/head
Isaac Boukris [Fri, 4 Sep 2020 11:05:50 +0000 (14:05 +0300)] 
Improve KDC alias checking for S4U requests

When processing an S4U2Self request, check for DB aliases when
matching the TGT client against the request server.  When processing
an S4U2Proxy request, check for DB aliases when matching the TGT
client against the evidence ticket server.

[ghudson@mit.edu: minor edits; rewrote commit message]

ticket: 8946 (new)

4 years agoRemove Leash import functionality 1112/head
Greg Hudson [Thu, 20 Aug 2020 03:03:28 +0000 (23:03 -0400)] 
Remove Leash import functionality

Copying tickets from the MSLSA cache to another cache is no longer
possible in most circumstances, and the Leash ribbon UI does not have
an import button.  Remove all remaining support for importing tickets.

ticket: 8940 (new)

4 years agoFix Leash crash when ticket autorenewal fails 1103/head
Greg Hudson [Wed, 19 Aug 2020 15:37:12 +0000 (11:37 -0400)] 
Fix Leash crash when ticket autorenewal fails

CLeashView::RenewTicket() falls back to an ImportTicket or InitTicket
operation if ticket renewal fails.  A 2004 commit (from the old
pismere repository) added code to heuristically determine whether
Leash's cache was imported by comparing the MSLSA cache principal name
to ticketinfo.Krb5.principal.  Commit
9bc411e72fce5bed3ed00ae5b09f8c239309bae0 broke this code by removing
the call to initialize ticketinfo.Krb5 and by making
ticketinfo.Krb5.principal ephemeral.  The strcmp() call now crashes
the process with a null dereference.

Fix the crash by removing the heuristic detection of imported tickets,
using the current value of m_importedTickets (which should be correct
unless Leash was restarted after the tickets were obtained) to decide
whether to import or initialize tickets.

ticket: 8938
tags: pullup
target_version: 1.17-next
target_version: 1.18-next

4 years agoFix Leash console option 1102/head
Greg Hudson [Tue, 18 Aug 2020 16:46:50 +0000 (12:46 -0400)] 
Fix Leash console option

Remove out2con.cpp, which no longer works.  Replace it with a simple
method for creating a console and redirecting stdout and stderr to it.

ticket: 8937 (new)

4 years agoFix input length checking in SPNEGO DER decoding 1098/head
Greg Hudson [Tue, 28 Jul 2020 16:58:26 +0000 (12:58 -0400)] 
Fix input length checking in SPNEGO DER decoding

In get_mech_set(), check the length before reading the first byte, and
decrease the length by the tag byte when reading and verifying the
sequence length.

In get_req_flags(), check the length before reading the first byte,
and check the context tag length after decoding it.

ticket: 8933 (new)
tags: pullup
target_version: 1.18-next
target_version: 1.17-next

4 years agoDo proper length decoding in SPNEGO gss_get_oid()
Greg Hudson [Tue, 28 Jul 2020 16:51:06 +0000 (12:51 -0400)] 
Do proper length decoding in SPNEGO gss_get_oid()

When reading an OID in a SPNEGO token, use gssint_get_der_length()
rather than assuming the length fits in one byte.  Although OID
lengths greater than 127 are unlikely, some NetApp products have been
observed to incorrectly encode the length in multiple bytes.  Reported
by Richard Sharpe.

ticket: 8932 (new)

4 years agoFix KRB5_GC_CACHED for S4U2Self requests 1107/head
Greg Hudson [Wed, 26 Aug 2020 15:15:11 +0000 (11:15 -0400)] 
Fix KRB5_GC_CACHED for S4U2Self requests

In krb5_get_credentials_for_user(), always exit after the first cache
check if KRB5_GC_CACHED is specified.  Not making network requests
with this flag is more important than finding a post-realm-discovery
cached entry.

If KRB5_GC_CACHED is specified without a principal name, fail
immediately, as we cannot check the cache by certificate.

ticket: 8942 (new)

4 years agoRename master_kdc and iprop_master_ulogsize 1090/head
Greg Hudson [Sun, 12 Jul 2020 01:47:08 +0000 (21:47 -0400)] 
Rename master_kdc and iprop_master_ulogsize

Use "primary_kdc" and "iprop_ulogsize" as the preferred names of the
two relations.  Fall back to the old keys if the new ones are not set.

ticket: 8921

4 years agoUse the term "primary KDC" in source and docs
Greg Hudson [Thu, 25 Jun 2020 00:48:14 +0000 (20:48 -0400)] 
Use the term "primary KDC" in source and docs

Where it does not affect program behavior, use the term "primary KDC".
This commit does not change any profile variables, DNS labels,
pathnames, or externally visible identifiers, nor does it change the
term "master key".

ticket: 8921 (new)

4 years agoSuppress Leash error popup on MSLSA renew failure 1104/head
Greg Hudson [Wed, 19 Aug 2020 15:49:29 +0000 (11:49 -0400)] 
Suppress Leash error popup on MSLSA renew failure

Attempting to renew the MSLSA cache can commonly fail with
KRB5_CC_NOTFOUND due to LSA policy.  Do not display an error popup in
this case.  Also fix a logic error in the existing suppressions.

ticket: 8939 (new)
tags: pullup
target_version: 1.18-next
target_version: 1.17-next

4 years agoHarmonize macOS pack declarations with Heimdal 1109/head
Greg Hudson [Tue, 1 Sep 2020 04:33:42 +0000 (00:33 -0400)] 
Harmonize macOS pack declarations with Heimdal

Replace the TARGET_OS_MAC conditionals with the conditionals used in
Heimdal, so that we do not pack structures inconsistently with macOS
on ARM.  Suggested by Luke Howard.

ticket: 8944 (new)

4 years agomake regen
Greg Hudson [Wed, 2 Sep 2020 20:50:32 +0000 (16:50 -0400)] 
make regen

4 years agoUnify kvno option documentation 1105/head
Robbie Harwood [Thu, 20 Aug 2020 21:49:29 +0000 (17:49 -0400)] 
Unify kvno option documentation

Add missing kvno options to the kvno.rst synopsis and option
descriptions, and to the kvno usage message.  Remove mention of '-h'
(help text), from kvno.rst as it is an implicit option.  Note that the
three new caching options were added in release 1.19.

Indicate the two exclusions (-u/-S and --u2u with the S4U2Self options)
and dependency (-P on S4U2Self) where they are missing.

Switch xusage() to print only a single localized string, rather than
running each line of output through localization separately.

Leave kvno -C undocumented for now, as the semantics of
KRB5_GC_CANONICALIZE are minimally useful and likely to change.

[ghudson@mit.edu: edited documentation and commit message]

ticket: 7476
tags: pullup
target_version: 1.18-next

4 years agoSet lockdown attribute when creating LDAP KDB 1101/head
Greg Hudson [Mon, 10 Aug 2020 16:44:21 +0000 (12:44 -0400)] 
Set lockdown attribute when creating LDAP KDB

In kdb5_ldap_util, set lockdown_keys on the special principals when
creating an LDAP KDB, as we do in kdb5_util when creating a regular
KDB.

ticket: 8936 (new)
tags: pullup
target_version: 1.18-next
target_version: 1.17-next

5 years agoRefactor cache checking in TGS client code 1095/head
Greg Hudson [Thu, 23 Jul 2020 05:52:43 +0000 (01:52 -0400)] 
Refactor cache checking in TGS client code

5 years agoCache S4U2Proxy requests by second ticket
Isaac Boukris [Mon, 20 Jul 2020 22:40:06 +0000 (00:40 +0200)] 
Cache S4U2Proxy requests by second ticket

krb5_get_credentials() does not know the client principal for an
S4U2Proxy request until the end, because it is in the encrypted part
of the evidence ticket.  However, we can check the cache by second
ticket, since all S4U2Proxy requests in a cache will generally be made
with the same evidence ticket.

In the ccache types, allow mcreds->client and mcreds->server to be
NULL (as Heimdal does) to ignore them for the purpose of matching.  In
krb5int_construct_matching_creds(), set mcreds->client to NULL for
S4U2Proxy requests.  Add a cache check to
k5_get_proxy_cred_from_kdc(), and remove the cache check from
krb5_get_credentials_for_proxy() and the krb5 mech's
get_credentials().

In get_proxy_cred_from_kdc(), fix a bug where cross-realm S4U2Proxy
would cache the evidence ticket used in the final request, rather than
the original evidence ticket.

[ghudson@mit.edu: debugged cache check and cross-realm caching;
switched from new flag to null matching cred principals; wrote commit
message]

ticket: 8931 (new)

5 years agoExpand dns_canonicalize_host=fallback support
Greg Hudson [Sat, 18 Jul 2020 02:57:45 +0000 (22:57 -0400)] 
Expand dns_canonicalize_host=fallback support

In krb5_sname_to_principal(), when using fallback, defer realm lookup
and any kind of hostname canonicalization until use.  Add a
lightweight iterator k5_canonprinc() to yield the one or two possible
candidates for a principal.  In the iterator, don't yield the same
hostname part twice.

Add fallback processing to the stepwise TGS state machine, and remove
it from krb5_get_credentials().  Add fallback processing to
k5_get_proxy_cred_from_kdc().

Add fallback processing to krb5_init_creds_set_keytab(), and use the
principal we find in the keytab as the request client principal.
Defer restart_init_creds_loop() to the first step call so that server
principal is built using the correct realm.

Add fallback processing to krb5_rd_req().

ticket: 8930 (new)

5 years agoDon't create hostbased principals in new KDBs 1099/head
Greg Hudson [Thu, 30 Jul 2020 16:14:27 +0000 (12:14 -0400)] 
Don't create hostbased principals in new KDBs

Unix-like platforms do not provide a simple method to find the
fully-qualified local hostname as the machine is expected to appear to
other hosts.  Canonicalizing the gethostname() result with
getaddrinfo() usually works, but potentially uses DNS.  Now that
dns_canonicalize_hostname=true is no longer the default, KDB creation
would generally create the wrong host-based principals.

kadmin/hostname is unnecessary because the client software can also
use kadmin/admin, and kiprop/hostname is one of several principals
that must be created for incremental propagation.

ticket: 8935 (new)

5 years agoTry kadmin/admin first in libkadm5clnt
Greg Hudson [Mon, 27 Jul 2020 05:19:01 +0000 (01:19 -0400)] 
Try kadmin/admin first in libkadm5clnt

The MIT krb5 kadmin protocol originally used kadmin/admin as the
service principal.  Commits 493f0da5fbf92b0ac2f10e887706d1964d8a15e8
and 5cfaec38a8e8f1c4b76228ba0a252987af797ca4 changed it to use
kadmin/hostname preferentially, with kadmin/admin as a fallback, for
interoperability with the Solaris SEAM administrative protocol.

Change the preference order so that kadmin/admin is tried first, with
kadmin/hostname as a fallback.

ticket: 8934 (new)

5 years agoFix three configure tests for Xcode 12 1100/head
Greg Hudson [Fri, 31 Jul 2020 22:35:15 +0000 (18:35 -0400)] 
Fix three configure tests for Xcode 12

Xcode 12 will change its clang to have
-Werror=implicit-function-declaration by default.  Fix three autoconf
tests which generate this warning due to missing include declarations.
Reported by Misty De Meo.

ticket: 8928

5 years agoFix leak in KERB_AP_OPTIONS_CBT server support 1097/head
Greg Hudson [Fri, 24 Jul 2020 20:05:24 +0000 (16:05 -0400)] 
Fix leak in KERB_AP_OPTIONS_CBT server support

In check_cbt(), use a local variable to hold the retrieved authdata
list, and free it before returning.

ticket: 8900

5 years agoFix token and type declarations in getdate.y 1096/head
Greg Hudson [Tue, 21 Jul 2020 05:41:21 +0000 (01:41 -0400)] 
Fix token and type declarations in getdate.y

Bison 3.5 adds a POSIX yacc compliance warning that %type should only
be applied to non-terminals.  Use %token for terminals in getdate.y.
Reported by Norm Green.

ticket: 8927

5 years agoIgnore bad enctypes in krb5_string_to_keysalts() 1094/head
Robbie Harwood [Wed, 15 Jul 2020 19:42:20 +0000 (15:42 -0400)] 
Ignore bad enctypes in krb5_string_to_keysalts()

Fixes a problem where the presence of legacy/unrecognized keysalts in
supported_enctypes would prevent the kadmin programs from starting.

[ghudson@mit.edu: ideally we would put a warning in the kadmind log,
but that is difficult to do when the parsing is done inside a library.
Even adding a trace log is difficult because the kadm5 str_conv
functions do not accept contexts.]

ticket: 8929 (new)

5 years agoAllow gss_unwrap_iov() of unpadded RC4 tokens 1093/head
Greg Hudson [Sun, 12 Jul 2020 01:57:30 +0000 (21:57 -0400)] 
Allow gss_unwrap_iov() of unpadded RC4 tokens

Windows Remote Management, when used with an RC4 session key, appears
to generate GSS wrap tokens with no padding instead of the expected
one byte (RFC 4757 section 7.3).  These tokens cannot be decoded with
gss_unwrap() or a STREAM buffer (even with Microsoft SSPI), but SSPI
allows them to be decoded using explicit IOVs with either a
zero-length padding buffer or no padding buffer.  Allow these cases to
work in kg_fixup_padding_iov().  (It is already possible to make this
work with HEADER | DATA | DATA, but only by
accident--kg_fixup_padding_iov() doesn't find a data buffer because
kg_locate_iov() only looks for singleton buffers, so it exits early.)

ticket: 8926 (new)
tags: pullup
target_version: 1.18-next

5 years agoAvoid backward seeks when reading keytab files 1092/head
Joshua Neuheisel [Fri, 3 Jul 2020 15:29:26 +0000 (11:29 -0400)] 
Avoid backward seeks when reading keytab files

When considering or bypassing an empty record in a keytab file, check
for a lenth of INT32_MIN.  Otherwise we could perform a backwards
seek, as the inverse of INT32_MIN is still negative.

[ghudson@mit.edu: adjusted comments; wrote commit message]

ticket: 8914

5 years agoAvoid using LMDB environments across forks 1088/head
Greg Hudson [Fri, 19 Jun 2020 19:05:37 +0000 (15:05 -0400)] 
Avoid using LMDB environments across forks

In krb5kdc and kadmind, reinitialize the DB state after daemonizing,
to prevent using an LMDB environment in a different process than it
was created.  Otherwise the daemon's reader table slot appears to be
stale and can be claimed by another process.

In kadmind, this change means that global_server_handle changes value
after the loop setup.  Add an extra level of pointer indirection so
that the handle passed to the loop remains valid.

kdb_init_hist() is now called twice by kadmind.  Change it to avoid
leaking hist_princ on the second invocation.

ticket: 8918
tags: pullup
target_version: 1.18-next
target_version: 1.17-next