]> git.ipfire.org Git - thirdparty/krb5.git/log
thirdparty/krb5.git
11 years agoMark AESNI files as not needing executable stacks
Greg Hudson [Fri, 3 Jan 2014 18:50:48 +0000 (13:50 -0500)] 
Mark AESNI files as not needing executable stacks

Some Linux systems now come with facilities to mark the stack as
non-executable, making it more difficult to exploit buffer overrun
bugs.  For this to work, object files built from assembly need a
section added to note whether they require an executable stack.

Patch from Dhiru Kholia with comments added.  More information at:
https://bugzilla.redhat.com/show_bug.cgi?id=1045699
https://wiki.gentoo.org/wiki/Hardened/GNU_stack_quickstart

ticket: 7813
target_version: 1.12.1
tags: pullup

11 years agoTest bogus KDC-REQs
Tom Yu [Wed, 1 Jan 2014 00:43:28 +0000 (19:43 -0500)] 
Test bogus KDC-REQs

Send encodings that are invalid KDC-REQs, but pass krb5_is_as_req()
and krb5_is_tgs_req(), to make sure that the KDC recovers correctly
from failures in decode_krb5_as_req() and decode_krb5_tgs_req().  Also
send an encoding that isn't a valid KDC-REQ.

ticket: 7811 (new)
target_version: 1.12.1
tags: pullup

11 years agoFix possible null deref in previous
Tom Yu [Wed, 1 Jan 2014 00:41:12 +0000 (19:41 -0500)] 
Fix possible null deref in previous

My rework of the do_tgs_req.c patch introduced a null deref if
decode_krb5_tgs_req() failed.

ticket: 7802

11 years agoLog service princ in KDC more reliably
rbasch [Mon, 16 Dec 2013 15:54:41 +0000 (10:54 -0500)] 
Log service princ in KDC more reliably

Under some error conditions, the KDC would log "<unknown server>" for
the service principal because service principal information is not yet
available to the logging functions.  Set the appropriate variables
earlier.

do_as_req.c: After unparsing the client, immediately unparse the
server before searching for the client principal in the KDB.

do_tgs_req.c: Save a pointer to the client-requested service
principal, to make sure it gets logged if an error happens before
search_sprinc() successfully completes.

[tlyu@mit.edu: commit message; fix TGS to catch more error cases]

ticket: 7802
target_version: 1.12.1
tags: pullup

11 years agoFix uninitialized warning in client_init.c
Greg Hudson [Sat, 21 Dec 2013 15:08:06 +0000 (10:08 -0500)] 
Fix uninitialized warning in client_init.c

ticket: 7800

11 years agoAllow realm in kadm5_init service names
Greg Hudson [Thu, 19 Dec 2013 18:33:33 +0000 (13:33 -0500)] 
Allow realm in kadm5_init service names

Previously, if you passed a service name with a realm part to a
kadm5_init function, you would get a KRB5_PARSE_MALFORMED error
because the code would internally append its own '@realm' suffix
before parsing the name.  Fix this as follows:

Change gic_iter so instead of producing a full service name, it
produces a krb5_principal which is taken from the cred it acquires.
Pass the client and full service name around as principals, rather
than strings, and use the gss_nt_krb5_principal name type to import
them in setup_gss().  Don't append a realm to the input service name;
instead, pass the input service name directly to the gic functions
(which do not need a realm in the service name and will ignore the
realm if one is present).  For the INIT_CREDS case, parse the input
service name with KRB5_PRINCIPAL_PARSE_IGNORE_REALM and then set the
realm.

ticket: 7800

11 years agoSimplify libkadm5 client realm initialization
Greg Hudson [Thu, 19 Dec 2013 17:22:47 +0000 (12:22 -0500)] 
Simplify libkadm5 client realm initialization

The "realm" variable in init_any is used only to fill in the realm of
the service principal in gic_iter().  The service principal realm
should always be the realm we looked up config parameters for, so we
can supply that realm to get_init_creds() unconditionally and
eliminate the case where we use the client principal realm.

Also get rid of an outdated comment and an #if 0 block we will never
need again, and use SNPRINTF_OVERFLOW to check the snprintf result.

11 years agomake depend
Greg Hudson [Sat, 21 Dec 2013 04:13:57 +0000 (23:13 -0500)] 
make depend

11 years agoRequire built-in verto for make depend
Greg Hudson [Fri, 20 Dec 2013 23:42:04 +0000 (18:42 -0500)] 
Require built-in verto for make depend

A tree configured to use the system libverto will be missing
$(VERTO_DEPS) in dependencies, so disallow make depend.

11 years agoAvoid keyctl purge in keyring ccache tests
Greg Hudson [Fri, 20 Dec 2013 20:19:06 +0000 (15:19 -0500)] 
Avoid keyctl purge in keyring ccache tests

keyctl purge was added in keyutils 1.5 (released in March 2011).  Use
keyctl unlink to clean up keys instead, as it is more universal.

ticket: 7810
target_version: 1.12.1
tags: pullup

11 years agoUse an extended com_err hook in klist
Greg Hudson [Fri, 20 Dec 2013 16:06:52 +0000 (11:06 -0500)] 
Use an extended com_err hook in klist

Add an adapted version of extended_com_err_fn from kinit to klist and
use it.  In do_ccache(), rely on the ccache type to set a reasonable
message if krb5_cc_set_flags() or krb5_cc_get_principal() fails due to
a nonexistent or unreadable ccache, and don't confuse the user with
the name of the ccache operation that failed.

ticket: 7809

11 years agoSet an error message when keyring get_princ fails
Nalin Dahyabhai [Thu, 5 Dec 2013 18:54:09 +0000 (13:54 -0500)] 
Set an error message when keyring get_princ fails

When attempting to use a keyring cache that doesn't exist, set an error
message when we fail to read a principal name, as we do when we return
the same error code when using a file ccache.

[ghudson: removed unnecessary check for d->name nullity.]

ticket: 7809
target_version: 1.12.1
tags: pullup

11 years agoTest for verto_set_flags in system libverto
Greg Hudson [Fri, 20 Dec 2013 04:47:22 +0000 (23:47 -0500)] 
Test for verto_set_flags in system libverto

libkrad relies on verto_set_flags, which was added to libverto in
release 0.2.4.  Make sure the system libverto has this function before
choosing it over the built-in version.

ticket: 7808 (new)
target_version: 1.12.1
tags: pullup

11 years agoMove kdc log routines into a separate file
Zhanna Tsitkov [Sat, 21 Dec 2013 00:18:57 +0000 (19:18 -0500)] 
Move kdc log routines into a separate file

Their previous location - kdc_util.c - seems to be overloaded with
various helper functions. No code changes.

11 years agoFix typo that broke 'make clean'
Zhanna Tsitkov [Fri, 20 Dec 2013 16:06:19 +0000 (11:06 -0500)] 
Fix typo that broke 'make clean'

Missing $

11 years agoMove kprop error explanation into Troubleshooting
Zhanna Tsitkov [Thu, 19 Dec 2013 18:08:56 +0000 (13:08 -0500)] 
Move kprop error explanation into Troubleshooting

The plan is to make Troubleshooting section of the documentation a
one-stop-shop place for all error diagnostics, explanations and possible
solutions.  The relocation of kprop error messages descriptions is part of
this consolidation effort.

11 years agoAdd a test program for krb5_copy_context
Greg Hudson [Wed, 18 Dec 2013 18:08:25 +0000 (13:08 -0500)] 
Add a test program for krb5_copy_context

This test program isn't completely proof against the kind of mistakes
we've made with krb5_copy_context in the past, but it at least
exercises krb5_copy_context and can detect some kinds of bugs.

ticket: 7807

11 years agoFix krb5_copy_context
Greg Hudson [Wed, 18 Dec 2013 20:03:03 +0000 (15:03 -0500)] 
Fix krb5_copy_context

krb5_copy_context has been broken since 1.8 (it broke in r22456)
because k5_copy_etypes crashes on null enctype lists.  Subsequent
additions to the context structure were not reflected in
krb5_copy_context, creating double-free bugs.  Make k5_copy_etypes
handle null input and account for all new fields in krb5_copy_context.
Reported by Arran Cudbard-Bell.

ticket: 7807 (new)
target_version: 1.12.1
tags: pullup

11 years agoTest SPNEGO error message in t_s4u.py
Greg Hudson [Wed, 18 Dec 2013 21:03:16 +0000 (16:03 -0500)] 
Test SPNEGO error message in t_s4u.py

Now that #7045 is fixed, we can check for the correct error message
from t_s4u2proxy_krb5 with --spnego.

ticket: 7045

11 years agoLet SPNEGO display mechanism errors
Simo Sorce [Tue, 17 Dec 2013 21:15:14 +0000 (16:15 -0500)] 
Let SPNEGO display mechanism errors

To avoid potential recursion we use a thread local variable that tells
us whether the ancestor was called via spnego_gss_display_name().  If
we detect recursion, we assume that we returned a com_err code like
ENOMEM and call error_message(); in the worst case that will result in
an "Unknown error" message.

[ghudson@mit.edu: Edited comments and commit message; removed an
unneeded line of code.]

ticket: 7045
target_version: 1.12.1
tags: pullup

11 years agoRemove unused krb5_context fields
Greg Hudson [Wed, 18 Dec 2013 16:59:56 +0000 (11:59 -0500)] 
Remove unused krb5_context fields

The vtbl and locate_fptrs fields were ostensibly related to the locate
pluggable interface, but weren't actually used.

11 years agoClarify klist -s documentation
Greg Hudson [Tue, 17 Dec 2013 21:56:41 +0000 (16:56 -0500)] 
Clarify klist -s documentation

The documentation for klist -s erroneously suggests that it doesn't
affect the exit status behavior and that it merely checks for the
existence of the ccache (only mentioning the expired ticket check at
the end).  Make it clearer and simpler, but avoid going into a lot of
detail about the nature of the expiration check.

ticket: 7806 (new)
target_version: 1.12.1
tags: pullup

11 years agoRemove BADSYMS
Greg Hudson [Mon, 16 Dec 2013 22:09:31 +0000 (17:09 -0500)] 
Remove BADSYMS

We haven't been using it or keeping it up to date, and there's no
need to keep it checked in.

11 years agoDon't require krb5.conf without KRB5_DNS_LOOKUP
Greg Hudson [Mon, 16 Dec 2013 22:09:00 +0000 (17:09 -0500)] 
Don't require krb5.conf without KRB5_DNS_LOOKUP

For a long time we have allowed krb5 contexts to be initialized in the
absence of krb5.conf--but only if KRB5_DNS_LOOKUP is defined,
presumably on the theory that no KDCs could be contacted without
either DNS support or profile configuration.  But locate plugins could
provide the ability to find KDCs, and some libkrb5 operations (such as
IAKERB initiation) could succeed without needing to locate KDCs.

Also get rid of the profile_in_memory context flag, since we don't use
it any more.

11 years agoFix GSS krb5 acceptor acquire_cred error handling
Greg Hudson [Mon, 16 Dec 2013 20:37:56 +0000 (15:37 -0500)] 
Fix GSS krb5 acceptor acquire_cred error handling

When acquiring acceptor creds with a specified name, if we fail to
open a replay cache, we leak the keytab handle.  If there is no
specified name and we discover that there is no content in the keytab,
we leak the keytab handle and return the wrong major code.  Memory
leak reported by Andrea Campi.

ticket: 7805
target_version: 1.12.1
tags: pullup

11 years agoFix memory leak in SPNEGO initiator
Simo Sorce [Fri, 13 Dec 2013 17:00:41 +0000 (12:00 -0500)] 
Fix memory leak in SPNEGO initiator

If we eliminate a mechanism from the initiator list because
gss_init_sec_context fails, free the memory for that mech OID before
removing it from the list.

[ghudson@mit.edu: clarified commit message]

ticket: 7803 (new)
target_version: 1.12.1
tags: pullup

11 years agoRemove unneeded check in SPNEGO initiator
Greg Hudson [Mon, 16 Dec 2013 16:35:42 +0000 (11:35 -0500)] 
Remove unneeded check in SPNEGO initiator

In init_ctx_cont, if the response token contains no fields, we set a
return value but don't actually quit out of the function.  We do not
need this check (we will fail later on if a piece of required
information isn't present), so just remove it.  Reported by
simo@redhat.com.

11 years agoFix SPNEGO one-hop interop against old IIS
Greg Hudson [Tue, 10 Dec 2013 17:04:18 +0000 (12:04 -0500)] 
Fix SPNEGO one-hop interop against old IIS

IIS 6.0 and similar return a zero length reponse buffer in the last
SPNEGO packet when context initiation is performed without mutual
authentication.  In this case the underlying Kerberos mechanism has
already completed successfully on the first invocation, and SPNEGO
does not expect a mech response token in the answer.  If we get an
empty mech response token when the mech is complete during
negotiation, ignore it.

[ghudson@mit.edu: small code style and commit message changes]

ticket: 7797 (new)
target_version: 1.12.1
tags: pullup

11 years agoFix up tests directory ignores, deps, cleanup
Greg Hudson [Thu, 12 Dec 2013 05:23:02 +0000 (00:23 -0500)] 
Fix up tests directory ignores, deps, cleanup

A few test programs didn't make it into .gitignore, OBJS, or
EXTRADEPSRCS.

11 years agoAdd tests for krb5_sname_to_principal
Greg Hudson [Mon, 9 Dec 2013 05:45:08 +0000 (00:45 -0500)] 
Add tests for krb5_sname_to_principal

11 years agoAllow ":port" suffixes in sn2princ hostnames
Greg Hudson [Sun, 8 Dec 2013 23:05:26 +0000 (18:05 -0500)] 
Allow ":port" suffixes in sn2princ hostnames

MSSQLSvc principal names can contain a ":port" or ":instance" trailer
on the hostname part.  If we see that in the hostname argument of
krb5_sname_to_principal(), remove it before canonicalizing the
hostname and put it back on afterwards.

ticket: 7795 (new)

11 years agoModernize sn2princ.c
Greg Hudson [Tue, 3 Dec 2013 21:19:35 +0000 (16:19 -0500)] 
Modernize sn2princ.c

Refactor and edit sn2princ.c to match current coding style.  No
behavior changes, except to be less chatty in trace logs.

11 years agoUpdate man pages
Tom Yu [Wed, 11 Dec 2013 03:26:17 +0000 (22:26 -0500)] 
Update man pages

11 years agomake depend
Tom Yu [Wed, 11 Dec 2013 03:24:03 +0000 (22:24 -0500)] 
make depend

11 years agoBetter keysalt docs
Tom Yu [Mon, 9 Dec 2013 20:48:02 +0000 (15:48 -0500)] 
Better keysalt docs

Add a new section to kdc_conf.rst to describe keysalt lists, and
update other documentation to better distinguish enctype lists from
keysalt lists.

ticket: 7608
target_version: 1.12
tags: pullup

11 years agoAvoid malloc(0) in SPNEGO get_input_token
Greg Hudson [Fri, 6 Dec 2013 23:56:56 +0000 (18:56 -0500)] 
Avoid malloc(0) in SPNEGO get_input_token

If we read a zero-length token in spnego_mech.c's get_input_token(),
set the value pointer to NULL instead of calling malloc(0).

ticket: 7794 (new)

11 years agoFix S4U2Self against non-FAST KDCs
Greg Hudson [Fri, 6 Dec 2013 01:32:05 +0000 (20:32 -0500)] 
Fix S4U2Self against non-FAST KDCs

When we added FAST TGS support in 1.11, we broke S4U2Self against KDCs
which don't support FAST, because the S4U2Self padata is only present
within the FAST request.  For now, duplicate that padata in the outer
request so that both FAST and non-FAST KDCs can see it.

ticket: 7791
target_version: 1.11.5
tags: pullup

11 years agoFix error message quotations in install_kdc.rst
Tom Yu [Tue, 3 Dec 2013 19:47:51 +0000 (14:47 -0500)] 
Fix error message quotations in install_kdc.rst

Some error messages that kprop could print were quoted incorrectly in
install_kdc.rst.

Also fix minor typos.

ticket: 7785 (new)
target_version: 1.12
tags: pullup

11 years agoEdit README.asn1
Greg Hudson [Tue, 3 Dec 2013 07:05:46 +0000 (02:05 -0500)] 
Edit README.asn1

Add another blank line before section headers.  Avoid contractions.
Change some whiches to thats where it seems appropriate.  Fix some
missing or extra words.

11 years agoBump libgssrpc minor version
Tom Yu [Wed, 27 Nov 2013 20:15:14 +0000 (15:15 -0500)] 
Bump libgssrpc minor version

Bump minor version for the new log_badauth2 interfaces.

ticket: 7770

11 years agoCorrectly log IPv6 addresses in kadmind
Greg Hudson [Mon, 25 Nov 2013 16:46:47 +0000 (11:46 -0500)] 
Correctly log IPv6 addresses in kadmind

Define client_addr() in server_stubs.c and use it consistently in that
file and ipropd_svc.c to get the client address from a transport
handle.  In it, call getpeername() on the client socket and use
inet_ntop() on the result, instead of using inet_ntoa() on the IPv4
socket address.  Provide a log_badauth2 callback to GSSRPC, so that we
get a transport handle instead of an IPv4 socket address, and use
client_addr() within it instead of inet_ntoa().

ticket: 7770
target_version: 1.12
tags: pullup

11 years agoAdd new versions of log_badauth gssrpc callbacks
Greg Hudson [Mon, 25 Nov 2013 16:33:35 +0000 (11:33 -0500)] 
Add new versions of log_badauth gssrpc callbacks

libgssrpc supports two callbacks for gss_accept_sec_context failures
on servers (one for AUTH_GSS and one for AUTH_GSSAPI), which are
IPv4-specific.  Provide an alternate version which supplies the
transport handle instead of the address, so that we can get the
address via the file descriptor for TCP connections.

ticket: 7770

11 years agoRemove inet_ntoa() prototype from getrpcent.c
Ben Kaduk [Mon, 25 Nov 2013 18:36:34 +0000 (13:36 -0500)] 
Remove inet_ntoa() prototype from getrpcent.c

It is not needed.

In general, we shouldn't be using inet_ntoa(), anyway, as it is
IPv4-specific and we have IPv6 support almost everywhere.

11 years agoUpdate doc for current kdb5_util dump version
Tom Yu [Fri, 22 Nov 2013 23:23:52 +0000 (18:23 -0500)] 
Update doc for current kdb5_util dump version

kdb5_util.rst incorrectly describes the current default dump format
version as 6 when it should be 7.  Reported by Jeff D'Angelo.

ticket: 7777
target_version: 1.12
tags: pullup

11 years agoEdit ccache_def.rst
Greg Hudson [Fri, 22 Nov 2013 21:53:35 +0000 (16:53 -0500)] 
Edit ccache_def.rst

Re-fill to 70 columns.  Replace non-ascii apostrophes with ASCII ones.
Edit wording slightly.

ticket: 7776

11 years agoAdded a new ccache doc to "Kerberos V5 concepts"
Zhanna Tsitkov [Fri, 22 Nov 2013 19:02:57 +0000 (14:02 -0500)] 
Added a new ccache doc to "Kerberos V5 concepts"

This is to add a short introductory document on credential
caches to the Concepts section of Kerberos documentation.

ticket: 7776 (new)
target_version: 1.12
tags: pullup

11 years agoImprove default ccache name API documentation
Greg Hudson [Thu, 21 Nov 2013 22:30:54 +0000 (17:30 -0500)] 
Improve default ccache name API documentation

Document the lifetime and caching behavior of the
krb5_cc_default_name() return value.  Document that
krb5_cc_set_default_name() may be called with NULL to purge the cached
value.  Correct a typo in the krb5_cc_default() summary and explicitly
reference krb5_cc_default_name().

ticket: 7775 (new)
target_version: 1.12
tags: pullup

11 years agoCorrect kadm5.acl back-reference documentation
Greg Hudson [Thu, 21 Nov 2013 21:22:48 +0000 (16:22 -0500)] 
Correct kadm5.acl back-reference documentation

In kadm5.acl, *N in the target principal name refers to the Nth
wildcard in the acting principal pattern, not the Nth component.

ticket: 7774 (new)
target_version: 1.12
tags: pullup

11 years agoAdd another kadmin ACL test for backreferences
Greg Hudson [Thu, 21 Nov 2013 21:18:27 +0000 (16:18 -0500)] 
Add another kadmin ACL test for backreferences

Add a test using backreferences which don't correspond directly to
principal components, to verify that *N refers to the Nth wildcard and
not the Nth component.

11 years agoClarify lockout replication issues in docs
Greg Hudson [Mon, 18 Nov 2013 23:59:17 +0000 (18:59 -0500)] 
Clarify lockout replication issues in docs

In the "KDC replication and account lockout" section of lockout.rst,
specifically call out kprop and incremental propagation as the
mechanisms which do not replicate account lockout state, and add a
note that KDCs using LDAP may not be affected by that section's
concerns.

ticket: 7773 (new)
target_version: 1.12
tags: pullup

11 years agoRemove dangling --with-kdc-kdb-update references
Greg Hudson [Sun, 17 Nov 2013 17:37:09 +0000 (12:37 -0500)] 
Remove dangling --with-kdc-kdb-update references

This configure option hasn't done anything since 1.8, so don't mention
it in configure --help or the documentation.  The disable_last_success
and disable_lockout DB options are now used to turn it off.

11 years agoRemove a warning in AES string-to-key
Greg Hudson [Sat, 16 Nov 2013 04:38:15 +0000 (23:38 -0500)] 
Remove a warning in AES string-to-key

On 32-bit platforms, the code to translate an iteration count of 0 to
2^32 can trigger a compiler warning.  Since we will basically never
accept an iteration count that high (right now we reject anything
above 2^24), just reject it out of hand.

11 years agoSet expiration time on keys and keyrings
Simo Sorce [Fri, 15 Nov 2013 21:36:05 +0000 (16:36 -0500)] 
Set expiration time on keys and keyrings

By setting the timeout based on the credetial's timeout we let the
system automatically cleanup expired credentials.

[ghudson@mit.edu: simplified code slightly]

ticket: 7769 (new)
target_version: 1.12
tags: pullup

11 years agoAdd support to store time offsets in cc_keyring
Simo Sorce [Thu, 14 Nov 2013 22:23:59 +0000 (17:23 -0500)] 
Add support to store time offsets in cc_keyring

The code follows the same model used for the memory ccache type.  Time
offsets are stored in each credential cache in a special key just like
the principal name.  Legacy session caches do not store timestamps as
legacy code would fail when iterating over the new offset key.

[ghudson@mit.edu: minor formatting changes; note legacy session
exception in commit message]

ticket: 7768 (new)
target_version: 1.12
tags: pullup

11 years agoEnforce minimum PBKDF2 iteration count
Tom Yu [Fri, 15 Nov 2013 21:11:32 +0000 (16:11 -0500)] 
Enforce minimum PBKDF2 iteration count

Also add a testing interface to allow weak iteration counts.
(Published test vectors use weak iteration counts.)

ticket: 7465
target_version: 1.12
tags: pullup

11 years agoCatch more strtol() failures when using KEYRINGs
Nalin Dahyabhai [Mon, 11 Nov 2013 18:10:08 +0000 (13:10 -0500)] 
Catch more strtol() failures when using KEYRINGs

When parsing what should be a UID while resolving a KEYRING ccache
name, don't just depend on strtol() to set errno when the residual
that we pass to it can't be parsed as a number.  In addition to
checking errno, pass in and check the value of an "endptr".

[ghudson@mit.edu: simplified slightly]

ticket: 7764 (new)
target_version: 1.12
tags: pullup

11 years agoClarify realm and dbmodules configuration docs
Greg Hudson [Wed, 6 Nov 2013 18:33:04 +0000 (13:33 -0500)] 
Clarify realm and dbmodules configuration docs

In kdc_conf.rst, add examples showing how to configure a realm
parameter and a database parameter.  Document that the default DB
configuration section is the realm name, and use that in the example.
Move the db_module_dir description to the end of the [dbmodules]
documentation since it is rarely used and could confuse a reader about
the usual structure of the section.

ticket: 7759 (new)
target_version: 1.12
tags: pullup

11 years agoMulti-realm KDC null deref [CVE-2013-1418]
Tom Yu [Mon, 4 Nov 2013 18:44:29 +0000 (13:44 -0500)] 
Multi-realm KDC null deref [CVE-2013-1418]

If a KDC serves multiple realms, certain requests can cause
setup_server_realm() to dereference a null pointer, crashing the KDC.

CVSSv2: AV:N/AC:M/Au:N/C:N/I:N/A:P/E:POC/RL:OF/RC:C

A related but more minor vulnerability requires authentication to
exploit, and is only present if a third-party KDC database module can
dereference a null pointer under certain conditions.

ticket: 7755 (new)
target_version: 1.12
tags: pullup

11 years agoRemove rtm_type_name()
Ben Kaduk [Fri, 1 Nov 2013 19:12:33 +0000 (15:12 -0400)] 
Remove rtm_type_name()

It has been unused since 2009 when Ken decided that the routing log
messages were too verbose (commit 91fc077c96926dd60).

11 years agoClean up the code to eliminate some clang warnings
Ben Kaduk [Wed, 30 Oct 2013 18:51:12 +0000 (14:51 -0400)] 
Clean up the code to eliminate some clang warnings

In ure.c, though k is a short, the literal 1 is of type 'int', and
so the operation 'k + 1' is performed at the (32-bit) width of int,
and therefore the "%d" format string is correct.

In accept_sec_context.c, the 'length' field of krb5_data is an
unsigned type, so checking for a negative value has no effect.

In net-server.c, the helper routine rtm_type_name() is only used
in code that is disabled with #if 0 conditionals; make the
definition also disabled in the same way to avoid warnings of an
unused function.

In kdc_authdata.c, equality checks in double parentheses elicit
a warning from clang.  The double-parentheses idiom is normally used
to indicate that an assignment is being performed, but the value of
the assignment is also to be used as the value for the conditional.
Since assignment and equality checking differ only by a single
character, clang considers this worthy of a warning.  Since the extra
set of parentheses is redundant and against style, it is correct to
remove them.

In several places (sim_server.c, dump.c, kdb5_destroy.c,
ovsec_kadmd.c), there are declarations of extern variables relating
to getopt() functionality that are now unused in the code.  Remove
these unused variables.

11 years agoMake set_cloexec_fd return void
Ben Kaduk [Wed, 30 Oct 2013 18:11:40 +0000 (14:11 -0400)] 
Make set_cloexec_fd return void

We never check its return value (causing clang to emit warnings),
and its use is primarily in cases where we should continue processing
in the event of failure.  Just ignore errors from the underlying
fcntl() call (if present) and treat this operation as best-effort.

The #if 0 code should probably be removed.

11 years agoAvoid deprecated krb5_get_in_tkt_with_keytab
Ben Kaduk [Tue, 10 Jul 2012 14:14:52 +0000 (10:14 -0400)] 
Avoid deprecated krb5_get_in_tkt_with_keytab

The kprop code has been pretty unloved, and uses some routines that
are marked as deprecated (which show up as warnings in the build log).
Use the documented replacement for krb5_get_in_tkt_with_keytab,
krb5_get_init_creds_keytab, instead.  As a bonus, there is no longer
a side effect of a credentials cache that needs to be destroyed.

The also-deprecated function krb5_get_in_tkt_with_skey was backending
to it when no keyblock was passed in; we can unroll the call to
krb5_get_init_creds_keytab ourselves as the documented workaround.
While here, improve style compliance with regards to cleanup.

The setkey test just wants to know whether it can use the key it
just put into a keytab to get credentials; as such the recommended
krb5_get_init_creds_keytab is quite sufficient.
While here, use that interface to request the particular enctype
as well, reducing the scope of an XXX comment.

ticket: 6366

11 years agoRemove last uses of "possibly-insecure" mktemp(3)
Ben Kaduk [Tue, 3 Jul 2012 14:27:20 +0000 (10:27 -0400)] 
Remove last uses of "possibly-insecure" mktemp(3)

Many libc implementations include notations to the linker to generate
warnings upon references to mktemp(3), due to its potential for
insecure operation.  This has been the case for quite some time,
as was noted in RT #6199.  Our usage of the function has decreased
with time, but has not yet disappeared entirely.  This commit
removes the last few instances from our tree.

kprop's credentials never need to hit the disk, so a MEMORY ccache
is sufficient (and does not need randomization).
store_master_key_list is explicitly putting keys on disk so as to
do an atomic rename of the stash file, but since the stash file
should be in a root-only directory, we can just use a fixed name
for the temporary file.  When using this fixed name, we must detect
(and error out) if the temporary file already exists; add a test to
confirm that we do so.

ticket: 1794

11 years agoClean up stash file error handling
Ben Kaduk [Wed, 18 Jul 2012 14:05:33 +0000 (10:05 -0400)] 
Clean up stash file error handling

The comment previously failed to match the behavior. The intent was
that if we failed to write out the entire stash file into the
temporary location, we should remove the partial file.  However, the
code was actually checking whether the *real* stash file existed,
not whether the temporary one existed.

It is safe to always try to unlink the partial file, and not worry
about whether it already exists.

11 years agoUse retval, not errno, when stashing master keys
Ben Kaduk [Mon, 4 Nov 2013 18:09:13 +0000 (13:09 -0500)] 
Use retval, not errno, when stashing master keys

The krb5_db_store_master_key{,_list} functions return a
krb5_error_code, and do not necessarily set errno on failure.
Use the correct variable while reporting errors with com_err().

11 years agoClarify kpropd standalone mode documentation
Greg Hudson [Wed, 30 Oct 2013 22:22:00 +0000 (18:22 -0400)] 
Clarify kpropd standalone mode documentation

The kpropd -S option is no longer needed to run kpropd in standalone
mode, but its functionality is not deprecated; standalone mode is
automatically activated when appropriate.  Clarify the kpropd
documentation on standalone mode to avoid giving the impression that
the mode is deprecated.

ticket: 7751 (new)
target_version: 1.12
tags: pullup

11 years agoDocument master key rollover
Greg Hudson [Fri, 25 Oct 2013 16:30:48 +0000 (12:30 -0400)] 
Document master key rollover

Add a new section to database.rst documenting the procedure for
rolling the master key.

ticket: 7732 (new)
target_version: 1.12
tags: pullup

11 years agoImprove LDAP KDB initialization error messages
Greg Hudson [Mon, 28 Oct 2013 15:23:11 +0000 (11:23 -0400)] 
Improve LDAP KDB initialization error messages

In krb5_ldap_initialize, don't just blat the LDAP error into the
extended message; give an indication of which LDAP operation we were
trying to do and show what parameters we gave to it.

(Also, krb5_set_error_message can handle a null context argument, so
don't bother to check before calling.)

ticket: 7739 (new)
target_version: 1.12
tags: pullup

11 years agoAdd tests for anonymous kadmin
Greg Hudson [Mon, 28 Oct 2013 17:34:04 +0000 (13:34 -0400)] 
Add tests for anonymous kadmin

11 years agoUse correct default principal for kadmin -n
Greg Hudson [Mon, 28 Oct 2013 17:33:05 +0000 (13:33 -0400)] 
Use correct default principal for kadmin -n

Use WELLKNOWN/ANONYMOUS@realm as the default principal for kadmin -n,
just like we do for kinit -n.

ticket: 7741 (new)
target_version: 1.12
tags: pullup

11 years agoAccept anonymous GSS names in kadmind
Greg Hudson [Mon, 28 Oct 2013 17:09:15 +0000 (13:09 -0400)] 
Accept anonymous GSS names in kadmind

The krb5 implementation of gss_display_name() reports the name type as
GSS_C_NT_ANONYMOUS if the client uses an anonymous principal.  Accept
this name type in gss_name_to_string and gss_to_krb5_name so that
anonymous kadmin can work.

Also improve code hygiene: call gss_name_to_string from
gss_to_krb5_name to reduce code repetition; use gss_oid_equal instead
of pointer comparison for name types; and don't assume that the
gss_display_name result buffer is zero-terminated.

ticket: 7740 (new)
target_version: 1.12
tags: pullup

11 years agoFix decoding of mkey kvno in mkey_aux tl-data
Greg Hudson [Sun, 27 Oct 2013 00:17:10 +0000 (20:17 -0400)] 
Fix decoding of mkey kvno in mkey_aux tl-data

krb5_dbe_lookup_mkey_aux was decoding a 16-bit value directly into an
int, resulting in the wrong value on big-endian platforms.  The
consequences are mostly invisible because we ignore this field and try
all mkey_aux nodes in krb5_def_fetch_mkey_list.

ticket: 7738 (new)
target_version: 1.12
tags: pullup

11 years agoAdd tests for different salt combinations
Ben Kaduk [Fri, 25 Oct 2013 17:33:23 +0000 (13:33 -0400)] 
Add tests for different salt combinations

Create a principal with a pair of enctypes using different salt types.
Confirm that the non-default salt type appears only once in the principal's
key list.

Also verify that the afs3 salt type is rejected by non-DES enctypes
The afs3 salt type is for compatibility with AFS-3 kaservers, which
are roughly krb4.  As such, it only makes sense for single-DES
enctypes.  The PBKDF2 and arcfour enctypes correctly reject the
key-creation parameters from the afs3 salt, but triple-DES currently
does not.

11 years agoReset key-generation parameters for each enctype
Ben Kaduk [Fri, 25 Oct 2013 18:00:29 +0000 (14:00 -0400)] 
Reset key-generation parameters for each enctype

In add_key_pwd, initialize s2k_params to NULL inside the loop over
enctypes instead of outside the loop, so that if the afs3 salt type
is used it does not contaminate later enctype/salt pairs in the list.

ticket: 7733
tags: pullup
target_version: 1.12

11 years agoSimplify kdb5_list_mkeys actkvno list retrieval
Greg Hudson [Thu, 24 Oct 2013 17:16:54 +0000 (13:16 -0400)] 
Simplify kdb5_list_mkeys actkvno list retrieval

After recent changes, krb5_dbe_lookup_actkvno cannot yield an empty
list and cannot return KRB5_KDB_NOACTMASTERKEY.

11 years agoRemove old master key tests
Greg Hudson [Wed, 23 Oct 2013 15:20:50 +0000 (11:20 -0400)] 
Remove old master key tests

Remove tests/mkeystash_compat and tests/mk_migr.  These are superseded
by t_mkey.py, with two exceptions:

tests/mk_migr included tests for password history across master key
rollovers.  Historical keys are encrypted in the kadmin/history key
(which is accessed like any other key), so there isn't a specific need
to test this unless we implement #1221.

tests/mk_migr had provisions for testing master key rollover with the
LDAP KDB module.  All master key logic used in the LDAP KDB module is
shared with the DB2 module in lib/kdb, so there is no specific need to
test this combination.

11 years agoAdd master key rollover tests in k5test framework
Greg Hudson [Wed, 23 Oct 2013 15:17:00 +0000 (11:17 -0400)] 
Add master key rollover tests in k5test framework

Add a new script t_mkey.py using the k5test framework.  Test the fixes
for #6507, #7685, and #7686 as well as basic functionality and
old-stashfile compatibility.

dump.16 was created by running "kdb5_util create -s -P footes" and
"kdb5_util dump dumpfile" with krb5 1.6.  The key from the resulting
stash file was extracted and placed in the struct.pack() call in the
new test script.

11 years agoCorrectly activate master keys in pre-1.7 KDBs
Greg Hudson [Thu, 24 Oct 2013 16:51:18 +0000 (12:51 -0400)] 
Correctly activate master keys in pre-1.7 KDBs

Starting with 1.7, databases are created with actkvno tl-data in the
K/M entry which gives the initial master key version an activation
time of 0.  A database created before 1.7 will not have this tl-data,
but we should behave in the same way as we do for a more recent
database.

Move the actkvno list synthesis code from krb5_dbe_fetch_act_key_list
to krb5_dbe_lookup_actkvno so it applies to kdb5_util commands as well
as libkadm5.  Synthesize the same list as we would have initialized
the KDB with, with an activation time of 0 for the earliest master
key.

ticket: 7686
target_version: 1.12
tags: pullup

11 years agoDon't cache active master key list in kadmind
Greg Hudson [Wed, 23 Oct 2013 22:56:20 +0000 (18:56 -0400)] 
Don't cache active master key list in kadmind

"kdb5_util use_mkey" should not require a kadmind restart to take
effect.  At the cost of fetching the K/M principal once for each key
change operation, make kadmind use the current active master key list
for each operation.

ticket: 7685
target_version: 1.12
tags: pullup

11 years agoReload master keys to find active mkey if needed
Greg Hudson [Wed, 23 Oct 2013 22:56:14 +0000 (18:56 -0400)] 
Reload master keys to find active mkey if needed

Refactor krb5_dbe_find_act_mkey and make it reload the master key list
if it doesn't find a master key matching the active mkvno.

ticket: 7685

11 years agoUse active master key in update_princ_encryption
Greg Hudson [Wed, 23 Oct 2013 15:55:19 +0000 (11:55 -0400)] 
Use active master key in update_princ_encryption

kdb5_util update_princ_encryption should update to the active master
key version, not the most recent.

ticket: 6507
target_version: 1.12
tags: pullup

11 years agoFix typos in kdb5_util master key command outputs
Greg Hudson [Mon, 21 Oct 2013 20:46:15 +0000 (16:46 -0400)] 
Fix typos in kdb5_util master key command outputs

kdb5_util list_mkeys was beginning lines with "KNVO" instead of
"KVNO".  kdb5_util purge_mkeys was displaying "follwing" instead of
"following" for both dry-run and normal cases.

ticket: 7730 (new)
target_version: 1.12
tags: pullup

11 years agoFix race in util/profile/Makefile.in
Greg Hudson [Thu, 17 Oct 2013 18:02:14 +0000 (14:02 -0400)] 
Fix race in util/profile/Makefile.in

$(BUILDTOP)/include/profile.h was being updated by two different
rules, which could collide with make -j.  Use a dependency from
includes instead of a redundant rule.

11 years agoDiscuss cert expiry, no-key princs in PKINIT docs
Greg Hudson [Mon, 14 Oct 2013 22:14:00 +0000 (18:14 -0400)] 
Discuss cert expiry, no-key princs in PKINIT docs

In pkinit.rst, add "-days" options to the example commands for
creating certificate and briefly discuss the issue of expiration dates
so that the administrator thinks about it.  In troubleshoot.rst, add
an entry for the "certificate has expired" error which results from
PKINIT (when linked with OpenSSL) when a certificate has expired.

ticket: 7719 (new)
target_version: 1.12
tags: pullup

11 years agoUse protocol error for PKINIT cert expiry
Greg Hudson [Mon, 14 Oct 2013 21:02:31 +0000 (17:02 -0400)] 
Use protocol error for PKINIT cert expiry

If we fail to create a cert chain in cms_signeddata_create(), return
KRB5KDC_ERR_PREAUTH_FAILED, which corresponds to a protocol code,
rather than KRB5_PREAUTH_FAILED, which doesn't.  This is also more
consistent with other error clauses in the same function.

ticket: 7718 (new)
target_version: 1.12
tags: pullup

11 years agoFix gss_accept_sec_context error tokens
Greg Hudson [Tue, 8 Oct 2013 21:07:34 +0000 (17:07 -0400)] 
Fix gss_accept_sec_context error tokens

A GSS krb5 error response contains a KRB-ERROR message, which is
required to have a server principal name, although few recipients
actually use it.  Starting in 1.3, accept_sec_context would fail to
encode the error in the GSS_C_NO_NAME/GSS_C_NO_CREDENTIAL case
(introduced by #1370) because cred->princ (which became
cred->name->princ in 1.8) is unset.

This problem got worse in 1.10 because we stopped setting the server
field in all cases due to the changes for #6855.  In 1.11 the problem
got worse again when a misguided change to the mechglue started
discarding output tokens when the mechanism returns an error; the
mechglue should only do so when it itself causes the error.

Fix krb5 gss_accept_sec_context by unconditionally decoding the AP-REQ
and using krb5_rd_req_decoded, and then using the requested ticket
server in the KRB-ERROR message.  Fix the mechglue
gss_accept_sec_context by reverting that part of commit
56feee187579905c9101b0cdbdd8c6a850adcfc9.  Add a test program which
artificially induces a replay cache failure (the easiest failure we
can produce which has an associated RFC 4120 error code) and checks
that this can be communicated back to the initiator via an error
token.

ticket: 1445
target_version: 1.12
tags: pullup

11 years agoAdd missing entries to tests/gssapi Makefile.in
Greg Hudson [Tue, 8 Oct 2013 16:35:51 +0000 (12:35 -0400)] 
Add missing entries to tests/gssapi Makefile.in

Some test sources files, objects, or programs were missing from SRCS,
OBJS, all, check-pytests, or clean.  t_oid was also out of order in a
couple of places.

11 years agoChange KRB5KDC_ERR_NO_ACCEPTABLE_KDF to 100
Greg Hudson [Wed, 9 Oct 2013 17:37:17 +0000 (13:37 -0400)] 
Change KRB5KDC_ERR_NO_ACCEPTABLE_KDF to 100

draft-ietf-krb-wg-pkinit-alg-agility-07 specifies
KDC_ERR_NO_ACCEPTABLE_KDF as 82, but this value conflicts with
KRB_AP_ERR_PRINCIPAL_UNKNOWN from RFC 6111.  The former value has been
reassigned to 100 to fix the conflict.  Use the correct value.

We believe that this error won't crop up in practice for a long time
(when SHA-2 has been superceded by other hash algorithms and people
are desupporting it), by which time implementations will mostly have
been upgraded to use the new value.

ticket: 7715 (new)
target_version: 1.12

11 years agoFix GSSAPI krb5 cred ccache import
Greg Hudson [Mon, 7 Oct 2013 13:51:56 +0000 (09:51 -0400)] 
Fix GSSAPI krb5 cred ccache import

json_to_ccache was incorrectly indexing the JSON array when restoring
a memory ccache.  Fix it.

Add test coverage for a multi-cred ccache by exporting/importing the
synthesized S4U2Proxy delegated cred in t_s4u2proxy_krb5.c; move
export_import_cred from t_export_cred.c to common.c to facilitate
this.  Make a note in t_export_cred.py that this case is covered in
t_s4u.py.

ticket: 7706
target_version: 1.11.4

11 years agoPerform complete referrals in t_referral.py
Greg Hudson [Wed, 9 Oct 2013 16:56:13 +0000 (12:56 -0400)] 
Perform complete referrals in t_referral.py

t_referral.py was written to exercise KDC host referral logic, and did
not actually create the target realm, instead just looking at the
error message from gcred to determine whether the KDC returned a
referral or not.  It's only a small amount of additional work to
actually set up the target realm and check that the client code
successfully retrieves the referral, so do that instead.

Since the referral and non-referral outcomes aren't all that similar
any more, split test() into testref() and testfail().  Get rid of the
message argument, since it wouldn't be output in most cases where we
get an unexpected result.

11 years agoUpdate for krb5-1.13-prerelease
Tom Yu [Sat, 5 Oct 2013 01:25:46 +0000 (21:25 -0400)] 
Update for krb5-1.13-prerelease

11 years agoFix audit test module initialization
Greg Hudson [Sun, 6 Oct 2013 00:13:39 +0000 (20:13 -0400)] 
Fix audit test module initialization

Check if the fopen result is NULL, not whether it's less than zero.

ticket: 7713 (new)
target_version: 1.12
tags: pullups

11 years agoKDC Audit infrastructure and plugin implementation
Zhanna Tsitkov [Sat, 20 Jul 2013 19:47:42 +0000 (15:47 -0400)] 
KDC Audit infrastructure and plugin implementation

Per project http://k5wiki.kerberos.org/wiki/Projects/Audit

The purpose of this project is to create an Audit infrastructure to monitor
security related events on the KDC.

The following events are targeted in the initial version:
- startup and shutdown of the KDC;
- AS_REQ and TGS_REQ exchanges.  This includes client address and port, KDC
  request and request ID, KDC reply, primary and derived ticket and their
  ticket IDs, second ticket ID, cross-realm referral, was ticket renewed and
  validated, local policy violation and protocol constraints, and KDC status
  message.

Ticket ID is introduced to allow to link tickets to their initial TGT at any
stage of the Kerberos exchange. For the purpose of this project it is a private
to KDC ticket ID: each successfully created ticket is hashed and recorded
into audit log. The administrators can correlate the primary and derived
ticket IDs after the fact.

Request ID is a randomly generated alpha-numeric string. Using this ID an
administrator can easily correlate multiple audit events related to a single
request. It should be informative both in cases when the request is sent to
multiple KDCs, or to the same KDC multiple times.

For the purpose of testing and demo of the Audit, the JSON based modules are
implemented: "test" and "simple" audit modules respectively.
The file plugins/audit/j_dict.h is a dictionary used in this implememtations.

The new Audit system is build-time enabled and run-time pluggable.

[kaduk@mit.edu: remove potential KDC crashes, minor reordering]

ticket: 7712
target_version: 1.12

11 years agoBe smarter about installing debug symbols
Ben Kaduk [Tue, 2 Jul 2013 20:45:59 +0000 (16:45 -0400)] 
Be smarter about installing debug symbols

We know when we're going to generate debug symbols, so only attempt
to install them when we know they should be present.

This eliminates the need to tell make to ignore errors from the shell
on these steps.

ticket: 7317
tags: pullup
target_version: 1.11.4

11 years agoUse better URL for kerberos documentation
Ben Kaduk [Tue, 2 Jul 2013 20:02:43 +0000 (16:02 -0400)] 
Use better URL for kerberos documentation

We have added a krb5-latest symlink for the latest stable release,
which is preferred to the krb5-current link (which points to a nightly
build of master).

ticket: 7673 (new)
ticket: 7493
queue: kfw
tags: pullup
target_version: 1.11.4

11 years agoRemove OldCC/rpc.cxx
Ben Kaduk [Mon, 1 Jul 2013 18:22:58 +0000 (14:22 -0400)] 
Remove OldCC/rpc.cxx

It is only linked on one place, which does not use any of the
exported routines, since an alternate implementation is linked first.

Remove the dead code and reduce the number of warnings omitted by
the build process.

11 years agoUse new-style variable expansion for light.exe
Ben Kaduk [Fri, 28 Jun 2013 22:08:21 +0000 (18:08 -0400)] 
Use new-style variable expansion for light.exe

With WiX 3.x, the preprocessor candle.exe expands variables using
$(); the linker light.exe expands localization and similar variables
using !(), though it accepts the $() form and prints a warning.

Switch to using the expected form to silence the warnings.

ticket: 7390
tags: pullup
target_version 1.11.4

11 years agoRemove unneeded variable enc_tkt_transited
Ben Kaduk [Fri, 4 Oct 2013 16:58:30 +0000 (12:58 -0400)] 
Remove unneeded variable enc_tkt_transited

There's no need to use an intermediate variable to initialize the
contents of enc_tkt_reply.transited.

Instead of setting each field to zero individually (and misspelling NULL),
use memset and set the one field which is being initialized to a nonzero
value explicitly.

11 years agoZero out stack variables in process_tgs_req()
Ben Kaduk [Thu, 3 Oct 2013 17:57:40 +0000 (13:57 -0400)] 
Zero out stack variables in process_tgs_req()

It is general good hygeine, preventing stack garbage from accidentally
leaking out into other consumers.

Don't bother with variables that are only used in a single place, but
do initialize the 'magic' field of nolrentry before it is used.

11 years agoUse constant-time comparisons for checksums
Greg Hudson [Wed, 2 Oct 2013 21:58:06 +0000 (17:58 -0400)] 
Use constant-time comparisons for checksums