In iakerb_acceptor_step(), avoid the use of goto for looping, and fix
a memory leak and possible double-free in some error cases. Also fold
some function calls into fewer lines.
Stop using a union in struct _iakerb_ctx_id_rec. We don't need the
space savings, and it was confusing to have u.gssc used without
checking the discriminator in the acceptor code.
Clean up IAKERB changes to init_sec_context.c in krb5 gss mech: add
back a CFX_EXERCISE block which is likely necessary for compilation
with that flag, and remove the unused exts parameter to mutual_auth().
If IAKERB is used with no TGT, return KRB5_CC_NOTFOUND instead of
going fruitlessly into the AS code path and returning EINVAL. Also
better handle the case where service credentials exist but are of an
unsupported enctype. Make a note that we aren't as consistent as we
would like to be in the case where the TGT exists but has expired.
Make IAKERB work properly when used in conjunction with default creds
or creds acquired with gss_acquire_cred (as opposed to
gss_acquire_cred_with_password). Previously it would fall back to the
krb5 mech too early and perform a blocking TGS request.
Register IAKERB after the krb5 mechs so it doesn't get used in
preference to the krb5 mech with SPNEGO or when no mech is specified
to gss_init_sec_context().
If gss_acquire_cred_with_password is used with no default ccache,
initialize the default ccache and fill it in, instead of creating a
memory ccache. Adjust gss-sample test cases to expect that there will
be cached creds.
On the iakerb branch, use krb5_auth_con_set_checksum_func for DES/DES3
enctypes as well as the modern ones. It works fine and it makes the
subkey available for the IAKERB checksum.
On the iakerb branch, fix spnego_gss_acquire_cred_with_password to
wrap the resulting creds. (The wrapping didn't exist when the code
was originally written.)
Split out the allocate-and-retrieve part of get_cached_tgt in
preparation for adding a cache check for the service creds. Also add
a field to remember KRB5_CC_NOT_KTYPE errors for the local TGT (and
later for service creds).
Fix a bug in make_request_for_service: use the caller-specified KCD
options as intended, not the field for options we remember between
request and response.
In get_creds.c, rewrite validate_or_renew_creds() and
get_credentials_val_renew_core() in terms of the new gc_frm_kdc_step.c
code. For now, create a static helper get_tkt_creds() to run
krb5_tkt_creds_init/get/get_creds; probably move that into
gc_frm_kdc_step.c at some point.
gc_frm_kdc_step.c was feeding the wrong in_creds to
krb5int_process_tgs_reply when performing TGT requests. Add
additional state to track what in_creds to use.
Also improve comments, and make the handling of ctx->realm_path a
little more obviously correct. (It never gets initialized twice, but
proving that is non-trivial, so we now free it before initialization.)
Move a little bit of logic out of step_referrals into
try_fallback_realm. If try_fallback_realm gives up because the
fallback realm is the same as the initial referral realm, return the
code from the TGS reply instead of KRB5_ERR_HOST_REALM_UNKNOWN.
In spnego_mech.c, revert r23225 from Luke's branch. The logic errors
were fixed independently on the trunk in r23742 (#6603) and the first
hunk would cause spnego_gss_init_sec_context to seg fault when passed
GSS_C_NO_BUFFER as input_token.
Greg Hudson [Fri, 26 Mar 2010 22:43:11 +0000 (22:43 +0000)]
In gc_frm_kdc.c, rename cur_kdc to cur_realm and nxt_kdc to nxt_realm,
to make it easier to distinguish them from cur_tgt and nxt_tgt. Make
similar name changes to lst_kdc and kdc_list, as well as the function
find_nxt_kdc().
Greg Hudson [Thu, 25 Mar 2010 03:08:12 +0000 (03:08 +0000)]
Straighten the if-ladder in encrypted challenge's process_preauth,
making it clearer that control drops through if one of the first
couple of steps fails.
Tom Yu [Tue, 23 Mar 2010 06:09:02 +0000 (06:09 +0000)]
krb5_typed_data not castable to krb5_pa_data on 64-bit MacOSX
Move krb5_typed_data to krb5.hin from k5-int-pkinit.h because
krb5int_fast_process_error was assuming that it was safe to cast it to
krb5_pa_data. It's not safe to do the cast on 64-bit MacOSX because
krb5.hin uses #pragma pack on that platform.
Greg Hudson [Sat, 20 Mar 2010 03:50:06 +0000 (03:50 +0000)]
Change KRB5_AUTHDATA_SIGNTICKET from 142 to 512
KRB5_AUTHDATA_SIGNTICKET, originally a Heimdal authorization data
type, was used to implement PAC-less constrained delegation in krb5
1.8. Unfortunately, it was found that Microsoft was using 142 for
other purposes, which could result in a ticket issued by an MIT or
Heimdal KDC being rejected by a Windows Server 2008 R2 application
server. Because KRB5_AUTHDATA_SIGNTICKET is only used to communicate
among a realm's KDCs, it is relatively easy to change the number, so
MIT and Heimdal are both migrating to a new number. This change will
cause a transitional interoperability issue when a realm mixes MIT
krb5 1.8 (or Heimdal 1.3.1) KDCs with MIT krb5 1.8.1 (or Heimdal
1.3.2) KDCs, but only for constrained delegation evidence tickets.
Ken Raeburn [Wed, 17 Mar 2010 06:00:56 +0000 (06:00 +0000)]
Merge users/raeburn/branches/network-merge
Re-integrates the forked versions of network.c in kdc and
kadmin/server. Server-specific initialization and SIGHUP-reset code
is moved into other source files; the more generic network-servicing
code is merged and moved into apputils library already used by both
programs.
Tom Yu [Tue, 16 Mar 2010 19:14:33 +0000 (19:14 +0000)]
handle NT_SRV_INST in service principal referrals
Handle NT_SRV_INST in service principal cross-realm referrals, as
Windows apparently uses that instead of NT_SRV_HST for at least some
service principals.
Greg Hudson [Thu, 11 Mar 2010 17:05:24 +0000 (17:05 +0000)]
Lazy history key creation
Create kadmin/history lazily when we need it (i.e. when a password is
changed on a principal with a policy) instead of whenever we open the
database. Allows kadmin.local to be used as a read-only tool on non-
kadmin-conformant database back ends such as the Samba bridge.
Greg Hudson [Mon, 8 Mar 2010 04:39:08 +0000 (04:39 +0000)]
Add a "make testrealm" target using the Python test framework. As
part of this, expose the environments in K5Realm as attributes so
that test scripts can modify them.
Ezra Peisach [Sun, 7 Mar 2010 20:01:36 +0000 (20:01 +0000)]
Make python test start_in_inetd function
util/k5test.py: Fix incorrect variable used
tests/dejagnu/t_inetd.c: Flush stdout after outputting "Ready!"
tests/dejagnu/Makefile.in: Always compile t_inetd - even in runtest is not
present
Greg Hudson [Fri, 5 Mar 2010 17:45:46 +0000 (17:45 +0000)]
Ignore improperly encoded signedpath AD elements
We have some reason to believe Microsoft and Heimdal are both using
the authdata value 142 for different purposes, leading to failures in
verify_ad_signedpath(). For better interoperability, treat such
tickets as unsigned, rather than invalid.
Greg Hudson [Thu, 4 Mar 2010 21:24:54 +0000 (21:24 +0000)]
Python test framework
Add a framework for writing tests in Python. Documentation is in the
initial docstring of util/k5test.py. Inaugurate the framework with
two test scripts, t_general.py and t_anonypkinit.py, which together
test the same operations as standalone.exp from the dejagnu test
suite.
Greg Hudson [Sun, 28 Feb 2010 20:32:00 +0000 (20:32 +0000)]
Remove some more test suite cruft:
* localhostname from get_hostname was unused.
* database_name is no longer used except (misleadingly) in kdb5_util
output.
* admin_database_name and admin_database_lockfile are no longer used.
* default_domain is only used for v4->v5 principal conversion, which
isn't tested.
* libkadm5's init-v2.exp had a copy of get_hostname; domain and
localhostname from it were unused.
Greg Hudson [Sat, 27 Feb 2010 09:49:32 +0000 (09:49 +0000)]
On Linux platforms, use -Wl,--enable-new-dtags when linking shared
libraries and programs using them. The primary effect is to get ld to
set DT_RUNPATH in addition to DT_RPATH, which in turn allows the
LD_LIBRARY_PATH environment variable to override the compiled-in
runpath, which is friendlier to the test framework.
Greg Hudson [Wed, 24 Feb 2010 18:57:08 +0000 (18:57 +0000)]
Two problems in kadm5_get_principal mask handling
KADM5_MOD_NAME was being applied to entry->principal instead of
entry->mod_name. KADM5_MKVNO was not being applied to entry->mkvno.
Patch from Marcus Watts <mdw@umich.edu>.
Greg Hudson [Mon, 22 Feb 2010 18:12:51 +0000 (18:12 +0000)]
Remove some unused cruft in the dejagnu test suite's default.exp:
* RLOGIN, RLOGIN_FLAGS, ROOT_PROMPT, ROOT_SHELL, check_k5login,
restore_kerberos_env, setup_root_shell, setup_root_shell_noremote,
setup_wrapper: No longer used now that the applications are in a
separate tree.
* v4_compatible_enctype: No longer used with krb4 support gone.
* tail1, krb_exit: Apparently never used.
* KERBEROS_SERVER: Added long ago in r5686 and removed shortly after
in r5695, but the test suite support for it never got excised.
Greg Hudson [Mon, 22 Feb 2010 04:52:30 +0000 (04:52 +0000)]
Fix two unrelated problems in SPNEGO which don't crop up with the krb5
mechanism.
1. The third call to spnego_init_accept_context uses faulty logic to
determine if the exchange is complete, preventing a third mech token
from being sent to the acceptor if no MIC exchange is required.
Follow the logic used in the second call (in init_ctx_nego), which is
correct.
2. If the acceptor selects a mech other than the optimistic mech, it
sets sc->mic_reqd to 1 whether or not the selected mech supports MICs
(which isn't known until the mech completes). Most code outside of
handle_mic checks sc->mic_reqd along with (sc->ctx_flags &
GSS_C_INTEG_FLAG), but the code in acc_ctx_call_acc neglected to do
so, so it could improperly delegate responsibility for deciding when
the negotiation was finished to handle_mic--which never gets called if
(sc->ctx_flags & GSS_C_INTEG_FLAG) is false. Fix acc_ctx_call_acc to
check sc->ctx_flags so that mechs which don't support integrity
protection can complete if they are selected non-optimistically.