]> git.ipfire.org Git - thirdparty/krb5.git/log
thirdparty/krb5.git
8 years agoFix thread support for Solaris and simplify 528/head
Greg Hudson [Fri, 26 Aug 2016 16:55:40 +0000 (12:55 -0400)] 
Fix thread support for Solaris and simplify

threads.c failed to build on Solaris afer commit
17932091cc0d5981c5a78d389ffa4a5c7b532bd6 because k5-thread.h did not
define the conditional k5_once_t structure (because NO_WEAK_PTHREADS
is defined) but threads.c tried to build the conditional k5_once()
function.

Use a single preprocessor symbol, USE_CONDITIONAL_PTHREADS, to
determine whether to use and define pthreads functions which
conditionalize on whether pthreads is loaded.  In threads.c, move the
new k5_once() definitions into the USE_CONDITIONAL_PTHREADS block,
defining a stub function if other code will not refer to it.

Also move #pragma weak declarations from k5-threads.h into threads.c,
as we should no longer be conditionally referring to those symbols
outside of threads.c.

Also eliminate some missing-prototype warnings where we define
functions for linker-visibility but don't have corresponding
prototypes in k5-threads.h.

8 years agoImprove checking of decoded DB2 principal values 522/head
Greg Hudson [Tue, 23 Aug 2016 17:41:00 +0000 (13:41 -0400)] 
Improve checking of decoded DB2 principal values

In krb5_decode_princ_entry(), verify the length of the principal name
before calling krb5_parse_name() or strlen(), to avoid a possible
buffer read overrun.  Check all length fields for negative values.
Avoid performing arithmetic as part of bounds checks.  If the value of
key_data_ver is unexpected, return KRB5_KDB_BAD_VERSION instead of
aborting.

ticket: 8481 (new)
target_version: 1.14-next
target_version: 1.13-next

8 years agoFix check-pytests-no 529/head
Tom Yu [Sat, 27 Aug 2016 21:04:11 +0000 (17:04 -0400)] 
Fix check-pytests-no

Commit 0db097ba8b605ea7a6e0364ad786da6528868179 accidentally removed
the $(SKIPTESTS) line from check-pytests-no, causing a syntax error
when running "make check" when python is missing or not sufficiently
new.

8 years agoGuess Samba client mutual flag using ap_options
Andreas Schneider [Thu, 25 Aug 2016 08:41:33 +0000 (10:41 +0200)] 
Guess Samba client mutual flag using ap_options

To work correctly with older Samba clients, we should guess the mutual
flag based on the ap_options from the AP-REQ and not set it
unconditionally.  Found by the Samba torture testsuite.

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

ticket: 8486 (new)
target_version: 1.14-next
tags: pullup

8 years agoRemove outdated TeX documentation from doc/api
Robbie Harwood [Fri, 19 Aug 2016 21:06:25 +0000 (17:06 -0400)] 
Remove outdated TeX documentation from doc/api

8 years agoFix leak in krb5_server_decrypt_ticket_keytab()
Seemant Choudhary [Wed, 24 Aug 2016 16:20:01 +0000 (12:20 -0400)] 
Fix leak in krb5_server_decrypt_ticket_keytab()

When we skip a keytab entry because it is of the wrong enctype, free
it before continuing.

ticket: 8482
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

8 years agoRemove svcauth_gss_creds
Greg Hudson [Tue, 23 Aug 2016 16:38:54 +0000 (12:38 -0400)] 
Remove svcauth_gss_creds

svcauth_gss_creds was in the libgssrpc library export list (as
gssrpc_svc_auth_gss_creds) but was not declared in a public header and
has no value to applications.  Remove it.

8 years agoFix GSSRPC server credential memory leak
Greg Hudson [Tue, 23 Aug 2016 16:35:50 +0000 (12:35 -0400)] 
Fix GSSRPC server credential memory leak

In svc_auth_gss.c, stop using the global svcauth_gss_creds, and
instead keep a credential in struct svc_rpc_gss_data.  This change
ensures that the same credential is used for each accept_sec_context
call for a particular context, and ensures that the credential is
freed when the authentication data is destroyed.  Also, do not acquire
a credential when the default name is used (as it is in kadmind) as it
is not needed.

Leave the svcauth_gss_creds around for the backportable fix as it is
in the library export list.  It will be removed in a subsequent
commit.

ticket: 8480 (new)
target_version: 1.14-next
target_version: 1.13-next

8 years agoConvert k5-thread macros to functions
Sarah Day [Mon, 8 Aug 2016 20:40:17 +0000 (16:40 -0400)] 
Convert k5-thread macros to functions

k5-thread.h has several pthread support calls defined as macros which
conditionally call pthread functions.  If a program is linked with
libkrb5support and uses these macros, and the program isn't compiled
with -fPIC, then it can crash if the pthread functions are linked at
runtime (via LD_PRELOAD, for instance) but not at compile time.
Convert the conditional macros to functions, so that libkrb5support is
responsible for determining whether pthreads is loaded and for calling
the pthreads functions if it is.

[ghudson@mit.edu: clarified commit message, adjusted whitespace]

8 years agoUse krb5_expand_hostname() to get admin service 349/head
Greg Hudson [Fri, 20 Nov 2015 00:32:11 +0000 (19:32 -0500)] 
Use krb5_expand_hostname() to get admin service

In libkadm5's kadm5_get_admin_service_name(), use
krb5_expand_hostname() instead of custom canonicalization code to
canonicalize the hostname.  There are some minor behavior differences;
in addition to the changes listed in the previous commit, the old code
did not downcase the result of the getaddrinfo() lookup, while the new
code does.

ticket: 8278

8 years agoUse krb5_expand_hostname() when creating KDB
Greg Hudson [Tue, 17 Nov 2015 18:33:21 +0000 (13:33 -0500)] 
Use krb5_expand_hostname() when creating KDB

In kdb5_util's add_admin_princs(), use krb5_expand_hostname() instead
of custom canonicalization code to canonicalize the hostname.  There
are some minor behavior differences:

* Canonicalization will no longer use AI_ADDRCONFIG.
* Canonicalization will use reverse DNS if configuration permits.
* Canonicalization will be affected by the dns_canonicalize_hostname
  and rdns profile variables.
* If name lookup fails, the original hostname will be used.
* A trailing dot will be removed from the name lookup result, if
  present.

ticket: 8278

8 years agoAdd krb5_expand_hostname() API
Greg Hudson [Tue, 17 Nov 2015 18:06:31 +0000 (13:06 -0500)] 
Add krb5_expand_hostname() API

Add a new public libkrb5 function expand_hostname().  It follows the
same contract as the Heimdal function, except that the caller should
use krb5_free_string() instead of krb5_xfree() to free the result.

As a small side effect, we no longer remove trailing dots from the
hostname in krb5_sname_to_principal() when invoked with type
KRB5_NT_UNKNOWN.  Adjust a test case in t_sn2princ.py accordingly.

ticket: 8278 (new)

8 years agoTest the minclasses policy field in LDAP
Sarah Day [Fri, 19 Aug 2016 20:06:48 +0000 (16:06 -0400)] 
Test the minclasses policy field in LDAP

[ghudson@mit.edu: added reference to ticket 8193 in comment]

8 years agoRemove "XXX" from KRB5_CC_IO error description
Robbie Harwood [Wed, 17 Aug 2016 20:00:46 +0000 (16:00 -0400)] 
Remove "XXX" from KRB5_CC_IO error description

[tlyu@mit.edu: edit commit message]

8 years agoBump copyright years in src/prototype 519/head
Tom Yu [Fri, 19 Aug 2016 20:17:00 +0000 (16:17 -0400)] 
Bump copyright years in src/prototype

[ci skip]

8 years agoFix SPNEGO imported cred initialization 488/head
Greg Hudson [Wed, 20 Jul 2016 21:08:55 +0000 (17:08 -0400)] 
Fix SPNEGO imported cred initialization

In spnego_gss_import_cred(), use create_spnego_cred() to create the
SPNEGO credential structure.  Prior to this change, an imported SPNEGO
cred did not initialize the no_ask_integ field (added by commit
cf39ed349976908626cad3e05e17788f8334bce9, ticket #6938).

ticket: 8460 (new)
target_version: 1.14-next
tags: pullup

8 years agoAdd another AD-SIGNTICKET corner case test 508/head
Greg Hudson [Mon, 8 Aug 2016 18:39:24 +0000 (14:39 -0400)] 
Add another AD-SIGNTICKET corner case test

Prior to the fix for #8139, forwarded TGTs obtained across a krbtgt
re-key could fail if the preferred krbtgt enctype changed, because
krb5_c_verify_checksum() returns an bad-enctype error due to the
mismatched checksum.  Add a test case for this scenario, using a new
test harness program which obtains a forwarded TGT.

8 years agoOutput last command info on k5test failures 515/head
Greg Hudson [Wed, 17 Aug 2016 15:50:31 +0000 (11:50 -0400)] 
Output last command info on k5test failures

When a k5test failure occurs, display the last executed command, its
command index, and its output.  This will make it easier to understand
"make check" failures when it is not easy to run subsequent commands
or investigate the filesystem of the build host.

8 years agoRefactor AS reply decryption code in get_in_tkt.c 504/head
Greg Hudson [Fri, 5 Aug 2016 16:39:41 +0000 (12:39 -0400)] 
Refactor AS reply decryption code in get_in_tkt.c

Expand the contract of decrypt_as_reply() to encompass more of the
logic in init_creds_step_reply(), and clarify comments.

8 years agoUse responder for non-preauth AS requests
Greg Hudson [Fri, 5 Aug 2016 16:28:03 +0000 (12:28 -0400)] 
Use responder for non-preauth AS requests

If no AS reply key is computed during pre-authentication (typically
because no pre-authentication was required by the KDC), ask for the
password using the responder before calling gak_fct for the key, and
supply any resulting responder items to gak_fct.

ticket: 8454
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

8 years agoRestore recursive dump functionality 510/head
Tom Yu [Thu, 11 Aug 2016 22:05:33 +0000 (18:05 -0400)] 
Restore recursive dump functionality

Use the new recursive traversal interface to restore recursive dump
functionality.

ticket: 8476

8 years agoHandle errors from curs_init in db2 back end
Tom Yu [Thu, 11 Aug 2016 20:27:33 +0000 (16:27 -0400)] 
Handle errors from curs_init in db2 back end

ctx_iterate could ignore errors from curs_init.  Actually pass them up
to the caller.

ticket: 8473 (new)
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

8 years agoRecursive btree traversal test case
Tom Yu [Tue, 9 Aug 2016 01:46:16 +0000 (21:46 -0400)] 
Recursive btree traversal test case

Add an unlink page command to the dbtest program.  This dbtest command
finds a page that has both a left and a right neighbor and unlinks it,
making it inaccessible to conventional sequential traversal.  This
simulates some btree corruption that has been seen in the field.

Unlike the bttest command, the dbtest unlink command always searches
for a leaf page with both a left and a right sibling, and doesn't
allow the user to specify internal pages or a specific page number.

Add a new dbtest command to recursively dump a btree database.

Add a new test case to run.test that uses these new commands to verify
the correct functioning of the recursive btree traversal options.

ticket: 8476

8 years agoAdd bttest unlink page command
Tom Yu [Mon, 8 Aug 2016 12:50:40 +0000 (08:50 -0400)] 
Add bttest unlink page command

To enable testing of recursive btree traversal, add an unlink page
command to the bttest program (used for debugging the libdb2 btree
back end).  This new bttest command can unlink a specified page
number, or it can search for and unlink a page that has both a left
and a right sibling.  (The user can specify whether to find an
internal page or a leaf page.)

This unlinking makes the page inaccessible to conventional sequential
traversal, simulating some btree corruption that has been seen in the
field.

ticket: 8476

8 years agoRefactor btree recursive traversal code
Tom Yu [Mon, 8 Aug 2016 13:15:42 +0000 (09:15 -0400)] 
Refactor btree recursive traversal code

Previous releases had a nonstandard entry point (bt_rseq) into libdb2
to perform recursive traversal of a btree database that might be
corrupt so that an operator could attempt data recovery.  This entry
point became inaccessible to user commands after krb5-1.5 due to
integration of the DAL.

Refactor the recursive traversal code into the existing btree
sequential traversal code, accepting new movement flags R_RNEXT
(recursively advance to next item) and R_RPREV.

Add commands to the libdb2 btree test program bttest to exercise this
functionality.  Fix up the existing "rlist" command of bttest to use
the updated interface.

ticket: 8476 (new)
subject: Restore recursive dump functionality

8 years agoFix MPOOL_IGNOREPIN to ease btree debugging
Tom Yu [Mon, 8 Aug 2016 13:06:16 +0000 (09:06 -0400)] 
Fix MPOOL_IGNOREPIN to ease btree debugging

Various libdb2 test programs use the MPOOL_IGNOREPIN flag to examine
arbitrary mpool pages that may or may not be pinned.  This flag is
apparently intended to allow fetching pages that are already pinned,
and to avoid setting the MPOOL_PINNED flag.  When there was a cache
hit, mpool_get was setting MPOOL_PINNED anyway, causing aborts when
using debugging programs such as dbtest and bttest.

Fix this inconsistency by not setting MPOOL_PINNED when returning a
cached page when the caller requested MPOOL_IGNOREPIN.  In bttest, add
MPOOL_IGNOREPIN to allow dumping of pages while they are pinned
without disrupting their pinned status.

ticket: 8478

8 years agoFix void return in __bt_dpage
Tom Yu [Mon, 8 Aug 2016 13:15:09 +0000 (09:15 -0400)] 
Fix void return in __bt_dpage

ticket: 8478

8 years agoMake bttest build with restricted lib exports
Tom Yu [Mon, 8 Aug 2016 13:13:59 +0000 (09:13 -0400)] 
Make bttest build with restricted lib exports

On platforms that use strict library export lists, the libdb2 btree
debugging program bttest won't build with -DDEBUG or -DSTATISTICS
because some needed functions aren't in the export list.

Add the missing bt_debug.c and mpool.c functions to libdb.exports.
Stub out these functions when built without -DDEBUG or -DSTATISTICS to
avoid unreferenced symbols, because conditionalizing library export
lists isn't easy.

ticket: 8478

8 years agoFix bttest printing of unterminated strings
Tom Yu [Mon, 8 Aug 2016 13:12:53 +0000 (09:12 -0400)] 
Fix bttest printing of unterminated strings

The libdb2 btree debugging program bttest can attempt to print keys or
data that aren't null-terminated, reading past the end of the
length-counted byte array.  Use the "%.*s" format specifier to provide
an explicit length when printing keys or data.

ticket: 8478

8 years agoImprove EINTR handling in bttest
Tom Yu [Mon, 8 Aug 2016 13:12:16 +0000 (09:12 -0400)] 
Improve EINTR handling in bttest

The libdb2 btree debugging program bttest doesn't handle EINTR in its
input loop.  This causes difficulties with debugging using lldb,
because bttest gets signals like SIGSTOP when being attached, and lldb
doesn't seem to share the terminal well with a program being debugged.

ticket: 8478 (new)
subject: usability improvements for bttest

8 years agoAllow libev to use pthreads on old platforms 513/head
Greg Hudson [Sun, 14 Aug 2016 23:00:12 +0000 (19:00 -0400)] 
Allow libev to use pthreads on old platforms

The upgrade to libev 4.22 introduced the use of "memory fences" for
more reliable signal processing.  Memory fences are usually
implemented using assembly or compiler primitives, but may be
implemented using pthreads as a last resort.  The unmodified libev
errors out at compile time if pthreads is used, but notes that this
error can be removed if relying on pthreads is okay.  Because the
project's nightly build infrastructure includes an old Solaris machine
whose toolchain is too old for any of the non-pthreads memory fence
implementations, remove the error to allow the build to succeed.  (A
dependency on pthreads functions on Solaris does not require linking
with libpthread.)

8 years agoFix KDC to drop repeated in-progress requests
Sarah Day [Mon, 15 Aug 2016 20:11:31 +0000 (16:11 -0400)] 
Fix KDC to drop repeated in-progress requests

When a KDC receives a repeated request while the original request is
still in progress, it is supposed to be to drop the request.  Commit
f07760088b72a11c54dd72efbc5739f231a4d4b0 introduced a bug in this
logic, causing the KDC to instead send an empty reply.  In
kdc_check_lookaside(), return a NULL reply_packet for empty entries,
restoring the expected behavior.

[ghudson@mit.edu: edited commit message, added a comment]

ticket: 8477 (new)
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

8 years agoWork around glibc OFD lock bug on 32-bit Linux 512/head
Greg Hudson [Sun, 14 Aug 2016 16:08:16 +0000 (12:08 -0400)] 
Work around glibc OFD lock bug on 32-bit Linux

A bug in Gnu libc causes OFD locking to fail unpredictably on 32-bit
Linux, typically leading to deadlocks.  Work around this bug by using
the fcntl64 system call and struct flock64.

See also: https://sourceware.org/bugzilla/show_bug.cgi?id=20251

ticket: 8474
target_version: 1.14-next
tags: pullup

8 years agoProperly escape quotes for otp set_string example 501/head
Ben Kaduk [Wed, 3 Aug 2016 15:23:56 +0000 (10:23 -0500)] 
Properly escape quotes for otp set_string example

The libss parser will consume paired double quotes, but within
a double-quoted region, repeated double quotes will be treated
as an escape and passed through as a single double quote.

(The new kadmin(1) parser in 1.14 that lets commands be specified
on the command line without -q does not go through the libss parser,
so standard shell methods for escaping quotes function as usual.)

ticket: 8469 (new)
target_version: 1.14-next
tags: pullup

8 years agoAdd asan build support 478/head
Greg Hudson [Thu, 30 Jun 2016 16:32:20 +0000 (12:32 -0400)] 
Add asan build support

Add the --enable-asan configure option.  This option suppresses the
undefined symbol check when building shared libraries on Linux, and
adds -fsanitize=address to the compiler and linker options.

8 years agoFix memory leaks in test programs 477/head
Greg Hudson [Thu, 23 Jun 2016 15:12:55 +0000 (11:12 -0400)] 
Fix memory leaks in test programs

Eliminate memory leaks detected by asan in test programs, to make it
easier to find more serious leaks.

8 years agoFix a variety of one-time leaks
Greg Hudson [Wed, 29 Jun 2016 21:13:33 +0000 (17:13 -0400)] 
Fix a variety of one-time leaks

Eliminate some memory leaks which should not affect normal operation,
but which make it harder to detect more serious memory leaks.

In kdb5_util, start using the already existing quit() function and
remove redundant DB and master key cleanup performed by individual
commands.  In kdb5_destroy(), use util_context instead of creating a
new one.  Add an mkey_fullname global variable and use it to make
a bunch of krb5_db_setup_mkey_name() calls unnecessary.

8 years agoAdd ulog_fini()
Greg Hudson [Wed, 29 Jun 2016 21:12:47 +0000 (17:12 -0400)] 
Add ulog_fini()

Add a function to unmap and free the iprop logging resources attached
to a krb5_context.

8 years agoFix leak on error in libkadm5_srv initialization 476/head
Greg Hudson [Thu, 14 Jul 2016 15:15:40 +0000 (11:15 -0400)] 
Fix leak on error in libkadm5_srv initialization

In init_any(), free handle->params on failure.

ticket: 8453 (new)
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

8 years agoFix leak in capaths processing
Greg Hudson [Wed, 29 Jun 2016 04:01:04 +0000 (00:01 -0400)] 
Fix leak in capaths processing

In k5_client_realm_path(), free the list of strings returned by
rtree_capaths_vals().

ticket: 8447 (new)
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

8 years agoFix leak in key change operations
Greg Hudson [Wed, 29 Jun 2016 02:20:22 +0000 (22:20 -0400)] 
Fix leak in key change operations

In preserve_one_old_key(), if the initial decryption in the current
master key succeeds, free the decrypted keyblock contents before
exiting.

ticket: 8446 (new)
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

8 years agoFix leak in kadm5_hook interface
Greg Hudson [Wed, 29 Jun 2016 02:15:17 +0000 (22:15 -0400)] 
Fix leak in kadm5_hook interface

In k5_kadm5_hook_free_handles(), free each handle structure as well as
its module data.

ticket: 8445 (new)
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

8 years agoFix unlikely leak in sendto_kdc
Greg Hudson [Wed, 29 Jun 2016 02:10:35 +0000 (22:10 -0400)] 
Fix unlikely leak in sendto_kdc

If a TCP connection is killed after it allocates the buffer (so is no
longer in READING state), free the buffer during cleanup.

ticket: 8444 (new)
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

8 years agoFix leak in FAST OTP client processing
Greg Hudson [Wed, 29 Jun 2016 01:38:57 +0000 (21:38 -0400)] 
Fix leak in FAST OTP client processing

In set_pa_data(), after encoding the OTP request and stealing the
pointer from the resulting krb5_data object, free the krb5_data
container.

ticket: 8443 (new)
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

8 years agoFix leak in DB2 krb5_db_promote() implementation
Greg Hudson [Tue, 28 Jun 2016 22:09:35 +0000 (18:09 -0400)] 
Fix leak in DB2 krb5_db_promote() implementation

In krb5_db2_merge_nra_iterator(), free the entry loaded from the
source DB.

ticket: 8442 (new)
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

8 years agoFix leak in ulog_replay()
Greg Hudson [Tue, 28 Jun 2016 22:01:55 +0000 (18:01 -0400)] 
Fix leak in ulog_replay()

ulog_conv_2dbentry() allocates a krb5_db_entry container; the caller
should not also do so.

ticket: 8441 (new)
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

8 years agoFix krb5_get_init_creds_password() pwchange leak
Greg Hudson [Tue, 28 Jun 2016 18:52:31 +0000 (14:52 -0400)] 
Fix krb5_get_init_creds_password() pwchange leak

When krb5_get_init_creds_password() attempts to change the password,
make sure to free code_string along all exit paths.

ticket: 8440 (new)
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

8 years agoFix leak in gss_display_name() for non-MN names
Greg Hudson [Tue, 28 Jun 2016 16:28:11 +0000 (12:28 -0400)] 
Fix leak in gss_display_name() for non-MN names

RFC 2744 states that the gss_display_name() output_name_type result is
"a pointer into static storage, and should be treated as read-only by
the caller (in particular, the application should not attempt to free
it)".  For non-mechanism names, we were making a copy of the name type
from the union name structure, causing a memory leak; stop doing that.

ticket: 8439 (new)
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

8 years agoFix leak in k5_free_cammac()
Greg Hudson [Mon, 27 Jun 2016 23:38:36 +0000 (19:38 -0400)] 
Fix leak in k5_free_cammac()

free_vmac(), a helper function used by k5_free_cammac(), must free its
val pointer as well as the contents; otherwise the krb5_verifier_mac
container is leaked.

ticket: 8438 (new)
target_version: 1.14-next
tags: pullup

8 years agoFix leaks on error in krb5 gss_acquire_cred()
Greg Hudson [Mon, 27 Jun 2016 21:49:57 +0000 (17:49 -0400)] 
Fix leaks on error in krb5 gss_acquire_cred()

In acquire_cred_context(), when releasing the partially constructed
cred on error, make sure to free the password and impersonator fields,
and to destroy the ccache if we created it.

ticket: 8437 (new)
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

8 years agoFix leak on error in libkadm5_clnt initialization
Greg Hudson [Mon, 27 Jun 2016 06:00:26 +0000 (02:00 -0400)] 
Fix leak on error in libkadm5_clnt initialization

In init_any(), free handle->lhandle on failure.

ticket: 8435 (new)
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

8 years agoFix memory leak in old gssrpc authentication
Greg Hudson [Mon, 27 Jun 2016 04:21:30 +0000 (00:21 -0400)] 
Fix memory leak in old gssrpc authentication

auth_gssapi_create(), which is now only used to connect to ancient
servers, can leak memory on error or when multiple GSSAPI_INIT calls
are required.  Ensure that call_res is freed along all exit paths and
before each repeat clnt_call() invocation.

ticket: 8434 (new)

8 years agoFix memory leak destroying DIR ccache
Greg Hudson [Sun, 26 Jun 2016 04:46:39 +0000 (00:46 -0400)] 
Fix memory leak destroying DIR ccache

Credential cache destroy methods are supposed to free the krb5_ccache
structure as well as its contents, but dcc_destroy() was not doing so.

ticket: 8433 (new)
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

8 years agoFix memory leak in db2 policy DB initialization
Greg Hudson [Fri, 24 Jun 2016 16:33:05 +0000 (12:33 -0400)] 
Fix memory leak in db2 policy DB initialization

osa_adb_init_db() maintains a static linked list mapping filenames to
lock structures.  Entries are never removed from the list; when their
reference counts hit 0, the lockfile is closed but the filename
remains allocated.  However, the filename is allocated each time the
lockfile is re-opened, leaking the old value.  Fix this leak by moving
filename initialization to entry creation.

ticket: 8432 (new)
target_version: 1.14-next
tags: pullup

8 years agoUpdate libev sources to 4.22
Greg Hudson [Mon, 27 Jun 2016 17:13:47 +0000 (13:13 -0400)] 
Update libev sources to 4.22

This update fixes a memory leak when freeing null pointers using
ev_realloc_emul().  In 4.04, that function assumed that realloc(x, 0)
is equivalent to free(x) under glibc, but in at least some versions of
glibc, realloc(NULL, 0) behaves like malloc(0) rather than free(NULL)
and allocates memory.

ticket: 8436 (new)

8 years agoAdd Host HTTP header to MS-KKDCP requests
Christian Heimes [Mon, 8 Aug 2016 10:38:17 +0000 (12:38 +0200)] 
Add Host HTTP header to MS-KKDCP requests

Some web servers require a Host HTTP header for TLS connections with
SNI (server name indicator).  It is also required for virtual hosts.

ticket: 8472 (new)
target_version: 1.14-next
tags: pullup

8 years agoAdd unit tests for sort_key_data
Sarah Day [Fri, 22 Jan 2016 14:37:10 +0000 (09:37 -0500)] 
Add unit tests for sort_key_data

8 years agoAdd unit tests for k5_parse_host_string
Sarah Day [Tue, 19 Jan 2016 14:50:33 +0000 (09:50 -0500)] 
Add unit tests for k5_parse_host_string

Make is_string_numeric() visible outside of parse_host_string.c as
k5_is_string_numeric() so it can be tested.  Make
k5_parse_host_string() return an error when address begins with ':',
for consistency with APR's apr_parse_addr_port().

[ghudson@mit.edu: squashed three commits; added t_parse_host_string to
.gitignore and clean rule; clarified commit message]

8 years agoAdd cmocka support
Sarah Day [Mon, 25 Jul 2016 17:20:08 +0000 (13:20 -0400)] 
Add cmocka support

8 years agoChange KDC error for encrypted timestamp preauth
Andreas Schneider [Mon, 8 Aug 2016 16:03:55 +0000 (18:03 +0200)] 
Change KDC error for encrypted timestamp preauth

When encrypted timestamp pre-authentication fails, respond with error
code KDC_ERR_PREAUTH_FAILED, rather than KRB_AP_ERR_BAD_INTEGRITY, for
consistency with other Kerberos implementations.

[ghudson@mit.edu: clarified commit message and comment]

ticket: 8471 (new)

8 years agoFix and simplify locate_kdc.c port byte order 506/head
Greg Hudson [Sun, 7 Aug 2016 04:02:00 +0000 (00:02 -0400)] 
Fix and simplify locate_kdc.c port byte order

Commit c89587b4476139f05f34aa2323bd7c7db348c44c introduced a bug in
the handling of KDC specifications using the default port, by passing
it to k5_parse_host_string() in network byte order.  Fix this by
removing all of the port byte order transformations in locate_kdc.c,
and storing the struct serverlist port field in host byte order.
Adjust other consumers of struct serverlist to expect the port to be
in host field to be in host byte order.

Reported by Isaac Boukris.

9 years agoMake Emacs tags actually work 503/head
Tom Yu [Thu, 28 Jul 2016 17:18:23 +0000 (13:18 -0400)] 
Make Emacs tags actually work

9 years agoRemove unused stuff from top-level Makefile.in
Tom Yu [Wed, 27 Jul 2016 23:42:22 +0000 (19:42 -0400)] 
Remove unused stuff from top-level Makefile.in

9 years agoWarn about dump -recurse nonfunctionality 502/head
Tom Yu [Wed, 3 Aug 2016 21:00:05 +0000 (17:00 -0400)] 
Warn about dump -recurse nonfunctionality

kdb5_util dump -recurse hasn't behaved as documented since krb5-1.5,
when the DAL was integrated.  Restoring it is a nontrivial amount of
work, so just document it for now.

ticket: 8470 (new)
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

9 years agoRemove unnecessary directories 500/head
Greg Hudson [Wed, 3 Aug 2016 15:26:13 +0000 (11:26 -0400)] 
Remove unnecessary directories

Remove the plugin modules wpse, cksum_body, and locate/python, which
aren't used by the test suite or built by default.

Remove util/collected-client-lib, as we no longer have a need to
create a smaller client-only library.

Remove util/gss-kernel-lib, as it turned out not to be useful for
facilitating kernel integrations.

9 years agoRemove all makefiles in make distclean 499/head
Greg Hudson [Sat, 30 Jul 2016 18:50:46 +0000 (14:50 -0400)] 
Remove all makefiles in make distclean

Change the build system to descend into every directory where we
create a Makefile, but not to build or run anything during "make all"
and "make check" in directories we previously didn't visit.  Document
specific build targets that can be used in those directories.

Do not generate a Makefile for the securid_sam2 module unless we are
building it, for consistency with other conditionally built
directories.

9 years agomake depend 498/head
Greg Hudson [Thu, 28 Jul 2016 17:37:59 +0000 (13:37 -0400)] 
make depend

9 years agoFix build system hygiene issues
Greg Hudson [Thu, 28 Jul 2016 17:37:53 +0000 (13:37 -0400)] 
Fix build system hygiene issues

Add some missing files to .gitignore, EXTRADEPSRCS, and clean rules.

9 years agoAdd skiptests notification for Python scripts 495/head
Greg Hudson [Tue, 26 Jul 2016 18:24:44 +0000 (14:24 -0400)] 
Add skiptests notification for Python scripts

If Python 2.5 or later is not found, add a notice to the skiptests
file to alert the user that Python test scripts were skipped.

Move the "cat $(SKIPTESTS)" command from check-postrecurse to
check-unix so that it executes after check-pytests-yes or
check-pytests-no.

9 years agoUse single-colon rules in makefiles
Greg Hudson [Tue, 26 Jul 2016 17:32:08 +0000 (13:32 -0400)] 
Use single-colon rules in makefiles

Double-colon rules allow the flexibility to specify commands in
multiple places, but they also make the order of commands and
dependencies dependent on the order of declarations in the Makefile.
Convert all of our double-colon rules to single-colon rules, with the
exception of "clean-unix" and "clean-windows" which have commands
defined in both post.in and in numerous Makefile.in files.

9 years agoMove CFLAGS and CPPFLAGS after local includes
Sarah Day [Wed, 27 Jul 2016 16:44:49 +0000 (12:44 -0400)] 
Move CFLAGS and CPPFLAGS after local includes

The gss-kernel-lib Makefile overrides ALL_CFLAGS.  It was setting
the CFLAGS and CPPFLAGS to occur before local includes, which
causes some compilers to include system header files before the
local header files.  Moving the CPPFLAGS and CFLAGS to the end of
ALL_CFLAGS corrects this behavior.

9 years agoRename k5-queue.h macros 497/head
Tom Yu [Wed, 27 Jul 2016 17:19:51 +0000 (13:19 -0400)] 
Rename k5-queue.h macros

Some BSD-derived systems (e.g., FreeBSD and Mac OS X) inappropriately
include sys/queue.h from some non-kernel network-related headers that
we include (net/if.h is one example).  Because our k5-queue.h is a
copy from a BSD sys/queue.h, many compilers will warn about macro
redefinitions on those systems.  Rename the queue macros to have a K5_
prefix.

Also delete the QUEUEDEBUG macros because they are only useful for
kernel use on the BSD systems where this header originated.

ticket: 8466 (new)

9 years agoImprove bad password inference in kinit 491/head
Greg Hudson [Mon, 25 Jul 2016 17:28:43 +0000 (13:28 -0400)] 
Improve bad password inference in kinit

kinit currently outputs "Password incorrect" if it sees a
bad-integrity error code, which results if the KDC reply couldn't be
decrypted, or when encrypted timestamp preauth fails against an MIT
krb5 1.14 or earlier KDC.  Expand this check to include general
preauth failures reported by the KDC, but only if a password was
prompted for.

ticket: 8465 (new)

9 years agoSet prompt type for OTP preauth prompt
Greg Hudson [Mon, 25 Jul 2016 17:23:31 +0000 (13:23 -0400)] 
Set prompt type for OTP preauth prompt

Add k5_set_prompt_type() calls around the prompter invocation in
preauth_otp.c, and add the comment we conventionally put before
prompter invocations.

ticket: 8464 (new)

9 years agoFix skiptests typo in lib/krb5/os/Makefile.in 494/head
Tom Yu [Mon, 25 Jul 2016 20:42:13 +0000 (16:42 -0400)] 
Fix skiptests typo in lib/krb5/os/Makefile.in

9 years agoComment why TRACE() is not used directly 490/head
Ben Kaduk [Sat, 23 Jul 2016 19:59:05 +0000 (14:59 -0500)] 
Comment why TRACE() is not used directly

Instead, a new TRACE_* macro should be defined for each trace point, and
that macro used from the library code.

9 years agoClean up some whitespace in configure.in 492/head
Tom Yu [Mon, 25 Jul 2016 18:58:08 +0000 (14:58 -0400)] 
Clean up some whitespace in configure.in

Delete trailing spaces at EOL.  Other whitespace issues remain for
now.

9 years agoBetter handle failures to resolve client keytab
Will Fiveash [Wed, 20 Jul 2016 00:20:51 +0000 (19:20 -0500)] 
Better handle failures to resolve client keytab

In krb5_gss_acquire_cred(), treat failure to resolve the client keytab
similarly to a client keytab which resolves but does not exist or has
no entries.  The client keytab could fail to resolve if its name
contains %{username} and the current process is acting on behalf of
the NSS system.

[ghudson@mit.edu: rewrote commit message; changed tracing call to use
a macro; cleared error message when ignoring krb5_kt_client_default()
error; added test case]

ticket: 8462 (new)

9 years agoAllow trace logging from GSS library
Greg Hudson [Thu, 21 Jul 2016 15:40:31 +0000 (11:40 -0400)] 
Allow trace logging from GSS library

Export krb5int_trace from the krb5 DLL on Windows, so that trace
logging points can be added to the GSS library.

9 years agoMinimize timing leaks in PKINIT decryption 466/head
Greg Hudson [Thu, 16 Jun 2016 20:38:07 +0000 (16:38 -0400)] 
Minimize timing leaks in PKINIT decryption

pkcs7_dataDecode() is derived from OpenSSL's PKCS7_datadecode() and is
used by PKINIT clients to decrypt ReplyKeyPack values in RSA mode.
The upstream function was changed for CVE-2012-0884 to minimize the
timing difference when RSA decryption results in the wrong padding.
Although the impact on Kerberos is negligible (because clients do not
ordinarily choose to use RSA mode, and cannot easily be induced to
make many thousands of requests with the same key), change
pkcs7_dataDecode() to match the upstream change, generating a random
symmetric key and using it when RSA decryption fails.  Also rename
"tmp" and "tmp_len" to "ek" and "eklen" to match the more descriptive
upstream variable names.

ticket: 8428 (new)

9 years agoSimplify pkcs7_dataDecode() in PKINIT
Greg Hudson [Thu, 16 Jun 2016 17:54:01 +0000 (13:54 -0400)] 
Simplify pkcs7_dataDecode() in PKINIT

RFC 4556 requires that the EnvelopedData in the encKeyPack contain
only one RecipientInfo.  Take advantage of this constraint to simplify
pkcs7_dataDecode().

9 years agoAdd a PKINIT test using RSA
Greg Hudson [Wed, 4 May 2016 15:25:32 +0000 (11:25 -0400)] 
Add a PKINIT test using RSA

In t_pkinit.py, add a simple PKINIT test using RSA encryption instead
of a Diffie-Hellman exchange.

9 years agoFix recent change to kdcdefaults processing 486/head
Greg Hudson [Tue, 19 Jul 2016 16:46:37 +0000 (12:46 -0400)] 
Fix recent change to kdcdefaults processing

When falling back to reading kdc_tcp_ports from [kdcdefaults], assign
the result to the correct variable.

ticket: 1093

9 years agoFix S4U2Self KDC crash when anon is restricted 485/head
Greg Hudson [Tue, 19 Jul 2016 15:00:28 +0000 (11:00 -0400)] 
Fix S4U2Self KDC crash when anon is restricted

In validate_as_request(), when enforcing restrict_anonymous_to_tgt,
use client.princ instead of request->client; the latter is NULL when
validating S4U2Self requests.

CVE-2016-3120:

In MIT krb5 1.9 and later, an authenticated attacker can cause krb5kdc
to dereference a null pointer if the restrict_anonymous_to_tgt option
is set to true, by making an S4U2Self request.

  CVSSv2 Vector: AV:N/AC:H/Au:S/C:N/I:N/A:C/E:H/RL:OF/RC:C

ticket: 8458 (new)
target_version: 1.14-next
target_version: 1.13-next

9 years agoFix error code on clpreauth module failure
Greg Hudson [Tue, 19 Jul 2016 14:52:06 +0000 (10:52 -0400)] 
Fix error code on clpreauth module failure

Commit 632260bd1fccfb420f0827b59c85c329203eafc9 (ticket #7517) allows
better error reporting for some client pre-authentication failures.
However, it breaks an assumption in the S4U2Self code that such errors
can be recognized by the KRB5_PREAUTH_FAILED error code.  Instead of
passing through the error code reported by the first real preauth
module, wrap that error and return KRB5_PREAUTH_FAILED.

ticket: 8457 (new)
target_version: 1.14-next
target_version: 1.13-next

9 years agoFix error handling in k5_expand_path() 484/head
Greg Hudson [Fri, 15 Jul 2016 22:51:31 +0000 (18:51 -0400)] 
Fix error handling in k5_expand_path()

In k5_expand_path_tokens_extra(), don't throw away non-zero return
statuses in the cleanup handler.  Reported by Will Fiveash.

ticket: 8455
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

9 years agoUpdate iprop tests for kadmind -k
Matt Rogers [Fri, 15 Jul 2016 14:32:51 +0000 (10:32 -0400)] 
Update iprop tests for kadmind -k

Test the use of the -k kprop-port option.

ticket: 8456

9 years agoAdd the kprop-port option to kadmind
Matt Rogers [Fri, 15 Jul 2016 14:17:45 +0000 (10:17 -0400)] 
Add the kprop-port option to kadmind

The -k option for kadmind sets the port number that kprop is spawned
with during an iprop full resync.  Fall back to checking the
KPROP_PORT environment variable if the option is not set.

ticket: 8456 (new)

9 years agoAllow user to restrict KDC to specific addresses
Sarah Day [Wed, 23 Dec 2015 20:01:44 +0000 (15:01 -0500)] 
Allow user to restrict KDC to specific addresses

krb5kdc has always only supported binding to the wildcard addresses.
Add two configuration options to allow specifying the address/port
that krb5kdc listens on for UDP and TCP connections.

[ghudson@mit.edu: edited documentation; preserved kdc_ports = ""
behavior; made kdc_ports and kdc_tcp_ports continue to work in
kdcdefaults section]

ticket: 1093

9 years agoAllow user to restrict kadmind bind addresses
Sarah Day [Wed, 23 Dec 2015 17:11:34 +0000 (12:11 -0500)] 
Allow user to restrict kadmind bind addresses

kadmind has always only supported binding to the wildcard addresses.
Add three configuration options to allow specifying the address/port
that kadmind listens on for kpasswd, kadmin, and iprop connections.

[ghudson@mit.edu: edited documentation; minimized changes to
setup_loop(); added iprop_listen]

ticket: 1093

9 years agoAdd ability to bind addresses to the net-server
Sarah Day [Mon, 21 Dec 2015 19:07:49 +0000 (14:07 -0500)] 
Add ability to bind addresses to the net-server

The net-server.c logic can accept individual addresses to bind to
using the standard host:port string format, in a list with a comma
delimiter.

Since pktinfo support was removed, users with systems lacking
pktinfo that have multiple NICs may specify each of the local
addresses directly that kadmind or krb5kdc should listen on in
kdc.conf.

[ghudson@mit.edu: edited comments and variable names; simplified
setup_socket()]

ticket: 1093

9 years agoRemove workaround when pktinfo is unsupported
Sarah Day [Mon, 21 Mar 2016 20:35:15 +0000 (16:35 -0400)] 
Remove workaround when pktinfo is unsupported

Currently if the system doesn't support pktinfo and kadmind or
krb5kdc are binding to a UDP address, then the net server binds to
all the local addresses.  Currently most systems support pktinfo,
so the workaround isn't really required anymore.  Removing the
workaround will only affect systems that don't have pktinfo
support, have multiple NICs, and are listening on a wildcard
address.

ticket: 8348

9 years agoUpdate LDAP docs for password lockout 482/head
Greg Hudson [Thu, 7 Jul 2016 20:58:02 +0000 (16:58 -0400)] 
Update LDAP docs for password lockout

The KDC now needs write access to the LDAP KDB, unless password
lockout and tracking of the last successful authentication time are
disabled.  Update the example LDAP access control configuration in
conf_ldap.rst to reflect this, add a note that only read access is
required if lockout is disabled, and add a section to lockout.rst
calling out the need for write access.  Reported by Will Fiveash.

ticket: 8452 (new)
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

9 years agoAdd hints for -A flag to kdestroy
Matt Rogers [Tue, 26 Jan 2016 19:59:43 +0000 (14:59 -0500)] 
Add hints for -A flag to kdestroy

When using a collection ccache, a user accustomed to the FILE ccache
behavior may not be aware of all active caches, and the default
kdestroy command could make it seem like there is no active cache
left.  Print a warning to use -A after kdestroy if there are other
caches.

ticket: 8451 (new)

9 years agoFix profile_flush_to_file() state corruption 475/head
Greg Hudson [Thu, 23 Jun 2016 16:01:56 +0000 (12:01 -0400)] 
Fix profile_flush_to_file() state corruption

In write_data_to_file(), do not clear the profile data object's flags.
If the call to this function resulted from profile_flush_to_file(), we
do not want to clear the DIRTY flag, and we especially do not want to
clear the SHARED flag for a data object which is part of
g_shared_trees.  Instead, clear the DIRTY flag in
profile_flush_file_data().

Add a test case to prof_test1 to exercise the bug in unfixed code.
Also modify test1 to abandon the altered profile after flushing it to
a file, to preserve the external behavior of the script before this
fix.

ticket: 8431
target_version: 1.14-next
tags: pullup

9 years agoImprove kdb5 error when default realm is unset 479/head
Greg Hudson [Fri, 1 Jul 2016 15:10:19 +0000 (11:10 -0400)] 
Improve kdb5 error when default realm is unset

When the default realm name is unspecified, and none was set in the
krb5_context object, return KRB5_CONFIG_NODEFREALM from libkdb5
instead of the confusing KRB5_KDB_DBTYPE_NOTFOUND.  To accomplish
this, make kdb_get_library_name() return a krb5_error_code.

ticket: 8448
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

9 years agoClarify directions when a Python test fails 470/head
Greg Hudson [Tue, 21 Jun 2016 16:44:51 +0000 (12:44 -0400)] 
Clarify directions when a Python test fails

In _onexit() in k5test.py, output an absolute path to the testlog
file, and output explicit directions on re-running the script with the
-v flag.

9 years agoFix recent memory leak in locate_kdc.c 473/head
Greg Hudson [Tue, 21 Jun 2016 22:46:28 +0000 (18:46 -0400)] 
Fix recent memory leak in locate_kdc.c

Commit ce112dec844e4650b5ad174bd40f21c32aebe1d1 introduced a memory
leak in locate_srv_conf_1() by moving the free(realmstr) call to the
cleanup handler, because there was an early return after realmstr is
allocated.  Convert that early return to a goto.

9 years agoFix incorrect recv() size calculation in libkrad
Nathaniel McCallum [Tue, 21 Jun 2016 20:12:36 +0000 (16:12 -0400)] 
Fix incorrect recv() size calculation in libkrad

Before this patch libkrad would always subtract the existing buffer
length from pktlen before passing it to recv().  In the case of stream
sockets, this is incorrect since krad_packet_bytes_needed() already
performs this calculation.  Subtracting the buffer length twice could
cause integer underflow on the len parameter to recv().

ticket: 8430 (new)
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

9 years agoFix and simplify auth-indicator authdata module 472/head
Greg Hudson [Tue, 21 Jun 2016 22:29:00 +0000 (18:29 -0400)] 
Fix and simplify auth-indicator authdata module

Remove the authind_context count field.  The indicators list must be
null-terminated because it is freed with k5_free_data_ptr_list().
authind_internalize() didn't null-terminate the list, and the presence
of the count field made it appear that this wasn't a bug.  Use a
different scheme for setting *more in authind_get_attribute() to avoid
requiring an element count.

Also check more thoroughly for errors in authind_externalize() and
authind_internalize(), and remove some unnecessary pointer casts.

ticket: 8425