Update ulog state after promoting DB when loading

If we are doing a full load, do not touch the ulog header until after
we promote the temporary DB to live.  This avoids the same bugs as the
#7588 fix, but more robustly.  Based on a patch from Richard Basch.

ticket: 7695
Clarify flag handling in dump.c

Get rid of "flags" bitfields and just use boolean values, to make the
internal contracts for dump and load functions more precise.  Rename
"add_update" to "iprop_load" and reverse its sense.
Fix KDC reply service principal for aliases

If a client requests a service ticket for the alias of a service
principal, RFC 6806 section 6 requires that the KDC issue a ticket
which appears to be for the alias and not for the canonical name.
After calling search_sprinc(), only replace request->server with
server->princ if the latter is a TGT; this will be the case for an
alternate cross-realm TGT or a host referral, but not for a simple
service alias.

ticket: 7698
target_version: 1.11.4
tags: pullup
Add tests for service aliases using LDAP module
Don't treat local krbtgt principal as referral

If we look up a principal and in the KDB and get back the local TGS
principal, the KDC should treat this as an alias, not a referral, and
should therefore issue a ticket for the requested principal rather the
canonical name.

ticket: 7698
Add test for alias to local TGS
Don't change realm in find_alternate_tgs

If a client makes a TGS request for a cross-realm TGS within a
different realm from the one we normally serve (e.g. the KDC realm is
X, and a client makes a TGS request for the server krbtgt/Y@Z), look
for alternate TGS principals within the requested server realm, not
the realm we normally serve.

This change shouldn't break any working well-formed TGS requests,
because changing the realm would trigger a failure in check_tgs_tgt.
It may fix some corner cases when multiple realms are served out of
the same KDB.  But primarily, this change makes referrals and aliases
easier to reason about, by eliminating a case where server->princ has
a different realm from request->server after the call to
search_sprinc().
Make it possible to renew aliased service tickets

We always allow aliases in the service principal when processing
AS-REQs and TGS-REQs.  If the ticket we issued is presented back to us
in a TGS-REQ as a header ticket for renewal or similar, we should
allow aliases when looking up its key to decode the AP-REQ.

ticket: 7699 (new)
Support FAST hide-client-names option

In the KDC, if we see the hide-client-names option, identify the
client as the anonymous principal in KDC-REP and KRB-ERROR responses.
The actual client name is present in encrypted FAST elements.

ticket: 7700 (new)
Fix FAST critical option bit checking

The FAST option bits 0-15 are intended to be critical--if they are
present and a KDC does not support them, the KDC is supposed to fail
the request.  Because of an incorrect constant, we were erroneously
recognizing bits 24-31 as critical.  Fix the constant.

ticket: 7701 (new)
Tighten up referral recognition in KDC TGS code

In do_tgs_req(), treat the search_sprinc() result as a referral only
if it is a cross-TGS principal and it doesn't match the requested
server principal.  This change fixes two corner cases: (1) when a
client requests a cross-realm TGT, we won't squash the name type in
the response; and (2) if we are serving multiple realms out of the
same KDB, we will properly handle aliases to any local-realm TGT, not
just the one for the configured realm name.

ticket: 7555
Explicitly prevent referrals for certain requests

For ticket modification requests (such as renewals), u2u requests, and
S4U2Self requests, the requested server principal is expected to match
a previously issued ticket.  If that principal no longer exists, we
must fail the request; we cannot issue a referral.  We are currently
doing that by rewriting request->server to the referral principal,
which causes the match against the ticket to fail.  Since we would
like to stop modifying the request, we must explicitly prevent
referrals in these cases.

We don't find out whether a request is S4U2Self until after we've
looked up the server principal, so for now we have to make a
retroactive check for a referral after calling
kdc_process_s4u2self_req.
Stop modifying TGS requests for referrals

It is no longer necessary to modify request->server when we receive a
referral.  The uses of request->server break down as follows:

* Matching against previously issued tickets (e.g. for renewals).  We
  now explicitly disallow referrals for requests where we need to do
  that.

* Using only the realm (e.g. for transited checking).  Referrals are
  cross-realm TGS entries within the same realm as the requested
  server principal, so this does not change.

* Comparing to a local TGS principal (for restrict_anonymous_to_tgt
  enforcement).  Local TGS principals are not treated as referrals, so
  the sense of this comparison will not change if we use the original
  request.

* Setting the sname and realm fields of a KRB-ERROR response.  RFC
  4120 and 6806 do not specify what we should put here for referrals
  or aliases and we are not aware of any uses of this field by
  clients, so putting the requested server principal here should be
  okay.
Add a flag to prevent all host canonicalization

If dns_canonicalize_hostname is set to false in [libdefaults],
krb5_sname_to_principal will not canonicalize the hostname using
either forward or reverse lookups.

ticket: 7703 (new)
Factor out context establishment in GSS tests

Add a new helper to common.c which runs gss_init_sec_context and
gss_accept_sec_context in a loop, and use it in test programs instead
of the open-coded one-token or two-token exchanges.
Add tests for GSS IOV and AEAD interfaces

Add a new test program t_iov.c which tests various combinations of
wrapping and unwrapping using the IOV and AEAD interfaces.  Run it
with and without SPNEGO in each enctype configuration.
Use gss_release_iov_buffer in t_iov.c
Get rid of G_VFY_TOKEN_HDR_IGNORE_SEQ_SIZE

This flag was introduced in the mskrb-integ merge but is not actually
used after r21742--while kg_unseal_iov_token sets it in vfyflags for
DCE-style contexts, it doesn't actually pass vfyflags to
g_verify_token_header or otherwise use it.  Moreover, the flag is not
necessary there; we correctly set input_length to the header length
(without data, padding, or trailer) for v1 tokens in a DCE-style
context.
Correct comments in ccselect_plugin.h

Some text mistakenly referred to password quality plugin.
Add GSSAPI IOV MIC functions

Add gss_get_mic_iov, gss_get_mic_iov_length, and gss_verify_mic_iov
functions, which work similarly to the corresponding IOV wrap
functions.  Add a new buffer type GSS_IOV_BUFFER_TYPE_MIC_TOKEN for
the destination buffer.

Most of the internal code for this was already present, and just
needed to be fixed up and adjusted to use the new buffer type for the
MIC token.

ticket: 7705 (new)