]> git.ipfire.org Git - thirdparty/krb5.git/log
thirdparty/krb5.git
7 years agoFix some omissions in make clean 808/head
Greg Hudson [Wed, 4 Jul 2018 14:58:35 +0000 (14:58 +0000)] 
Fix some omissions in make clean

7 years agoDisable canonicalization in ccselect tests 807/head
Greg Hudson [Wed, 4 Jul 2018 16:11:45 +0000 (16:11 +0000)] 
Disable canonicalization in ccselect tests

DNS canonicalization can interfere with the fallback tests by changing
"localhost" to have multiple components, or (less likely) changing the
parent domain of foo.krbtest.com or foo.krbtest2.com.

7 years agoImprove ulog memory hygiene 803/head
Greg Hudson [Thu, 28 Jun 2018 04:15:11 +0000 (00:15 -0400)] 
Improve ulog memory hygiene

Add a helper create_log_context() to initialize a krb5_context's
kdblog_context field, setting ulogfd to -1.  Use it in ulog_set_role()
and ulog_map().  In ulog_fini(), release ulogfd if it is not -1.

In ulog_map(), add a cleanup label and use it to finalize the log
context on failure, so that we don't (trivially) leak the mapped ulog.
To reduce the number of "retval = errno;" statements required for this
change, make extend_file_to() return a krb5_error_code.

The ulog leak on error was reported by Bean Zhang.

ticket: 8707

7 years agoFix OTP secret file leak and whitespace removal 802/head
Greg Hudson [Tue, 26 Jun 2018 16:47:10 +0000 (12:47 -0400)] 
Fix OTP secret file leak and whitespace removal

In read_secret_file() in the OTP kdcpreauth module, add a cleanup
label and free filename on exit.  Also fix the whitespace stripping
code to correctly find the end offset, and use size_t rather than int
offsets.  The leak was reported by Bean Zhang.

ticket: 8704
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

7 years agoFix memory handling in main in user_user/client.c 800/head
Robbie Harwood [Wed, 20 Jun 2018 15:18:46 +0000 (11:18 -0400)] 
Fix memory handling in main in user_user/client.c

Static analyzers (here, clang) prefer explicit exit() calls rather
than return statements from main() when resources are not to be
released.

Also, eliminate dead call to krb5_recvauth() and close the
communication socket.

7 years agoDon't leak work queue items in gss-server
Robbie Harwood [Tue, 19 Jun 2018 15:32:44 +0000 (11:32 -0400)] 
Don't leak work queue items in gss-server

On accept() failure in gss-server.c, we would leak the freshly
allocated work item.

7 years agoFix garbage return in extract_cammacs()
Robbie Harwood [Mon, 18 Jun 2018 21:49:52 +0000 (17:49 -0400)] 
Fix garbage return in extract_cammacs()

If no cammacs were present, we would never initialize ret before
returning it.  (extract_cammcs() is currently never called with an
empty or null list, so this does not manifest as a bug.)

[ghudson@mit.edu: amended commit message]

7 years agoFix double free in kdc hammer
Robbie Harwood [Tue, 3 Oct 2017 19:01:55 +0000 (15:01 -0400)] 
Fix double free in kdc hammer

If kdc5_hammer.c:krb5_string_to_key() fails, we didn't NULL out key
before returning it, leading to potential double-free.

7 years agoCorrectly handle fallback in KDC OTP callback 801/head
Robbie Harwood [Tue, 3 Oct 2017 18:28:47 +0000 (14:28 -0400)] 
Correctly handle fallback in KDC OTP callback

In otp_state.c:callback(), avoid invoking the failure callback when we
fall back to the next token.  Since request_send() consumes the
request, don't try to free it.

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

ticket: 8708
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

7 years agoClean up Windows build CPU detection 788/head
Greg Hudson [Sat, 19 May 2018 02:04:25 +0000 (22:04 -0400)] 
Clean up Windows build CPU detection

In the main build, set a variable BITS based on the detected CPU type,
and use it in library name expansions rather than repeatedly checking
for the same three 64-bit architectures.  Also remove an unused
variable WLIB, formerly used to name the winsock library.

In the installer build, detect the CPU type in the makefile and pass
it to candle with the -arch option.  This sets $(sys.BUILDARCH) in wix
scripts and also sets the default value of Win64 in components so we
don't have to set it for each one.

Update the build instructions and appveyor.yml to reflect that the
builder no longer needs to set CPU.

ticket: 8662

7 years agoFix minor leak in gssrpc UDP cache code 799/head
Greg Hudson [Tue, 19 Jun 2018 17:15:15 +0000 (13:15 -0400)] 
Fix minor leak in gssrpc UDP cache code

In svc_udp.c:cache_set(), if victim is allocated successfully but
allocation for newbuf fails, free victim before returning.  Reported
by Bean Zhang.

ticket: 8703

7 years agoFix minor leak in kdb5_util purge_mkeys 798/head
Greg Hudson [Tue, 19 Jun 2018 17:03:05 +0000 (13:03 -0400)] 
Fix minor leak in kdb5_util purge_mkeys

In kdb5_purge_mkeys(), if krb5_dbe_update_mkey_aux() fails, use the
cleanup label to free any allocated memory instead of returning
immediately.  Reported by Bean Zhang.

ticket: 8702

7 years agoAdd documentation on dictionary attacks 792/head
Greg Hudson [Thu, 14 Jun 2018 21:51:43 +0000 (17:51 -0400)] 
Add documentation on dictionary attacks

ticket: 8694 (new)

7 years agoFix minor leak in krb5_gss_inquire_cred() 796/head
Greg Hudson [Fri, 15 Jun 2018 15:40:13 +0000 (11:40 -0400)] 
Fix minor leak in krb5_gss_inquire_cred()

If mechs is created but one of the generic_gss_add_oid_set_member()
calls fails, it leaks.  Initialize mechs and free it in the fail
label.  Also null mechs when we transfer ownership of it to the
caller, in case we later unify the success and failure exit paths.
Reported by Bean Zhang.

ticket: 8697

7 years agoFix minor leak in localauth RULE handling 795/head
Greg Hudson [Fri, 15 Jun 2018 15:52:22 +0000 (11:52 -0400)] 
Fix minor leak in localauth RULE handling

In aname_replacer(), initialize current, null it when transferring
ownership to the caller, and free it on cleanup.  Otherwise it leaks
on failure.  Reported by Bean Zhang.

ticket: 8698

7 years agoFix minor leak in k5_os_hostaddr() 794/head
Greg Hudson [Fri, 15 Jun 2018 15:31:04 +0000 (11:31 -0400)] 
Fix minor leak in k5_os_hostaddr()

In k5_os_hostaddr(), if allocation of the result array fails, use the
cleanup handler so that the getaddrinfo() result is freed.  Also
initialize the pointers which are freed in the cleanup handler for
safety.  Reported by Bean Zhang.

ticket: 8699

7 years agoFix minor leaks in principal conversions 793/head
Greg Hudson [Fri, 15 Jun 2018 15:20:34 +0000 (11:20 -0400)] 
Fix minor leaks in principal conversions

In krb5_524_conv_principal(), if the realm we read from the profile is
too long for the result buffer, free the profile value before
returning.

In krb5_425_conv_principal(), if krb5_get_realm_domain() fails, still
free any leftover allocated data using a cleanup label.  The only one
that could be left over is dummy_value which we could address easily
enough within the loop, but we shouldn't sidestep the cleanup code.

Both bugs were reported by Bean Zhang.

ticket: 8695

7 years agoEliminate use of the 'register' keyword 797/head
Thomas Sondergaard [Sat, 16 Jun 2018 16:14:50 +0000 (18:14 +0200)] 
Eliminate use of the 'register' keyword

'register' is a reserved and unused keyword in C++17 so having it
present in the public headers presents a a compatibility issue. Also
in C the 'register' keyword is mostly obsolete, so remove all uses of
it.

[ghudson@mit.edu: adjusted style of some of the affected lines]

7 years agoFix minor leak in krb5_get_fallback_host_realm() 791/head
Greg Hudson [Thu, 14 Jun 2018 14:52:33 +0000 (10:52 -0400)] 
Fix minor leak in krb5_get_fallback_host_realm()

In domain_fallback_realm(), if profile_get_integer() fails, uhost is
leaked.  Fix this bug by using the cleanup handler instead of
returning immediately.  Reported by Bean Zhang.

ticket: 8693

7 years agoAdd flag to disable encrypted timestamp on client 789/head
Greg Hudson [Mon, 11 Jun 2018 17:53:27 +0000 (13:53 -0400)] 
Add flag to disable encrypted timestamp on client

ticket: 8655

7 years agoMake docs build python3-compatible 790/head
Robbie Harwood [Wed, 13 Jun 2018 19:07:48 +0000 (15:07 -0400)] 
Make docs build python3-compatible

python3 removed execfile(), which we use for loading version data and
paths information in docs.  Call exec() directly instead.

ticket: 8692 (new)

7 years agoRemove wshelper library 783/head
Greg Hudson [Sun, 3 Jun 2018 21:47:36 +0000 (17:47 -0400)] 
Remove wshelper library

ticket: 8687

7 years agoStop using wshelper for SRV/TXT lookups
Greg Hudson [Sun, 3 Jun 2018 20:41:18 +0000 (16:41 -0400)] 
Stop using wshelper for SRV/TXT lookups

Add Windows-specific versions of k5_try_realm_txt_rr(),
k5_make_uri_query(), and krb5int_make_srv_query_realm(), bypassing
wshelper and using DnsQuery_UTF8() directly.  Windows does not
currently know how to decode URI records and has no interface to allow
the caller to do so, so disable URI lookups on Windows for now.

Add a comment that dnsglue.h is not used on Windows (since DnsQuery
parses out and decodes SRV and TXT records for us), and remove the
header conditionals from it.

ticket: 8687

7 years agoReorganize internal DNS interfaces
Greg Hudson [Sat, 2 Jun 2018 22:25:43 +0000 (18:25 -0400)] 
Reorganize internal DNS interfaces

Move SRV lookup function declarations out of dnsglue.h into
os-proto.h, where the TXT lookup function is declared.  Only include
dnsglue.h within files which need to parse DNS records.

To avoid needing MAXDNAME, use dynamic allocation for the results of
DNS lookups (including hostname canonicalization) where we currently
use fixed buffers.  Remove clean_hostname from the accessor (nothing
uses it) and make it a static function within hostrealm.c.

7 years agoRequire Visual Studio 2013 in Windows README 780/head
Greg Hudson [Fri, 18 May 2018 05:05:46 +0000 (01:05 -0400)] 
Require Visual Studio 2013 in Windows README

The recently added SPAKE edwards25519 code, adapted from BoringSSL,
makes frequent use of mixed declarations and code, which is supported
by VS2013 but not VS2012 and earlier.  Require VS2013 as the minimum
version in the Windows README.  Add suport for VS2013 and VS2015 to
the installer.

ticket: 8662

7 years agoBuild and install SPAKE module for Windows
Greg Hudson [Wed, 16 May 2018 17:17:34 +0000 (10:17 -0700)] 
Build and install SPAKE module for Windows

For now only the edwards25519 group is supported, since we are not
adding an OpenSSL dependency.

ticket: 8657

7 years agoMake plugin auto-registration work on Windows
Greg Hudson [Wed, 16 May 2018 18:02:20 +0000 (11:02 -0700)] 
Make plugin auto-registration work on Windows

Make plugin_base_dir subject to parameter expansion, and set its
default to %{LIBDIR}\plugins on Windows (%{LIBDIR} expands to the
directory where the krb5 DLL lives).  For auto-registered modules,
assume that we will build 32-bit and 64-bit DLLs and name them
"modname32.dll" and "modname64.dll".  In k5_plugin_register_dyn(), use
k5_path_join() instead of assuming the path separator is "/".

ticket: 8685 (new)

7 years agoFix option parsing on Windows 778/head
Greg Hudson [Wed, 16 May 2018 04:52:08 +0000 (21:52 -0700)] 
Fix option parsing on Windows

Commit 8f9ade8ec50cde1176411085294f85ecfb2820a4 (ticket 8391) moved
the built-in getopt() and getopt_long() implementations from a static
library in util/windows to util/support, where (on Windows) it is
built into k5sprt32.dll or k5sprt64.dll.  The getopt() interface uses
global variables opterr, optind, optopt, and optarg, each renamed via
macro to have a k5_ prefix when we use the built-in implementation.
Data objects exported from DLLs need special handling in Windows; they
must be marked as DATA in the DLL .def file, and they must be declared
with "__declspec(dllimport)" in calling code.  Without this handling,
optind begins with a garbage value and getopt_long() returns -1
immediately, so client programs always behave as if they have no
arguments.

Stop unnecessarily declaring optind and optarg in client programs.
Declare the getopt() global variables with __declspec(dllimport) on
Windows, except when compiling getopt.c itself.  When creating
libkrb5support.exports on Windows (this file is later used by
lib/Makefile.in to create k5sprt32.def), add a DATA tag to the data
objects.

ticket: 8684 (new)
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

7 years agoUse pkg.m4 macros 787/head
Greg Hudson [Sun, 10 Jun 2018 22:32:13 +0000 (18:32 -0400)] 
Use pkg.m4 macros

Add pkg.m4 from pkg-config 0.29.2 and include it in aclocal.m4.  Use
PKG_CHECK_EXISTS for resolv_wrapper and PKG_CHECK_MODULES for libedit
and libverto.  Based on a patch from Timo Gurr.

ticket: 8691 (new)

7 years agoProcess profile includedir in sorted order 784/head
Greg Hudson [Wed, 6 Jun 2018 21:58:41 +0000 (17:58 -0400)] 
Process profile includedir in sorted order

In the profile library, use k5_dir_filenames() so that files within an
included directory are read in a predictable order (alphanumeric
within the C locale).

ticket: 8686

7 years agoAdd k5_dir_filenames() to libkrb5support
Greg Hudson [Tue, 5 Jun 2018 18:01:05 +0000 (14:01 -0400)] 
Add k5_dir_filenames() to libkrb5support

Add a support function to get a list of filenames from a directory in
sorted order.

7 years agoFix assert hygiene in t_path.c 786/head
Greg Hudson [Wed, 6 Jun 2018 22:33:59 +0000 (18:33 -0400)] 
Fix assert hygiene in t_path.c

Correct all uses of side-effecting asserts in t_path.c so that it
works correctly when NDEBUG is defined.  Reported by Nehal J Wani.

ticket: 8689

7 years agoFix Windows strerror_r() implementation 785/head
Greg Hudson [Wed, 6 Jun 2018 22:26:42 +0000 (18:26 -0400)] 
Fix Windows strerror_r() implementation

Commit 6351586a771e9a99e1e946cc9a0b6a87bbb14094 (ticket 7961)
introduced several variants of strerror_r().  The Windows one
contained a bug which made its return value undefined; fix that.

ticket: 8690 (new)

7 years agoPrune Leash sources 782/head
Greg Hudson [Mon, 21 May 2018 08:10:04 +0000 (01:10 -0700)] 
Prune Leash sources

When Leash was imported in 2011-2012, some of its functionality was
removed either at compile-time or runtime--most notably krb4 support,
AFS integration, and editing of "properties" (registry values).
Remove most of the unnecessary material.

7 years agoUse Visual Studio 2017 in appveyor build 779/head
Greg Hudson [Thu, 17 May 2018 01:19:43 +0000 (21:19 -0400)] 
Use Visual Studio 2017 in appveyor build

Update appveyor.yml to build all of the Windows code including Leash
and the installers, using VS2017.

7 years agoLog when non-root ksu authorization fails 776/head
Robbie Harwood [Mon, 7 May 2018 20:42:59 +0000 (16:42 -0400)] 
Log when non-root ksu authorization fails

If non-root user attempts to ksu but is denied by policy, log to
syslog at LOG_WARNING in keeping with other failure messages.

ticket: 8270

7 years agoAdd database type documentation 772/head
Greg Hudson [Thu, 26 Apr 2018 16:17:21 +0000 (12:17 -0400)] 
Add database type documentation

Document the new profile variables added for the LMDB KDB module and
the new configure option.  Add a new admin section on database types,
and document the behavior of all current modules.

ticket: 8674

7 years agoAdd LMDB KDB module tests
Greg Hudson [Thu, 26 Apr 2018 03:50:06 +0000 (23:50 -0400)] 
Add LMDB KDB module tests

Add a new k5test function multidb_realms() which yields a realm using
BDB and a realm using LMDB.  Run the tests in t_dump.py, t_iprop.py,
the lockout tests in t_policy.py, and kdbtest (in t_kdb.py) with both
databases.

If K5TEST_LMDB is set in the environment, use LMDB for all Python
tests and all tests in tests/dejagnu, with two exceptions
(t_unlockiter.py and t_kdb_locking.py) which test BDB-specific
behavior.  To support those exceptions, add the "bdb_only" realm
initialization flag.

In t_iprop.py, be sure to properly clean up kpropd daemons, using a
new k5test realm method stop_kpropd() to stop a kpropd daemon started
with start_kpropd() and remove it from the realm's list.

ticket: 8674

7 years agoAdd LMDB KDB module
Greg Hudson [Mon, 2 Apr 2018 17:34:54 +0000 (13:34 -0400)] 
Add LMDB KDB module

Add a new KDB module using LMDB.  For this module, combine policy and
principal databases into one environment with two databases, but split
out principal lockout fields into a separate environment so that
nothing blocks KDC writes for more than a trivial amount of time.

ticket: 8674 (new)

7 years agoRemove unused Windows sources 777/head
Greg Hudson [Fri, 11 May 2018 18:02:41 +0000 (14:02 -0400)] 
Remove unused Windows sources

windows/build and windows/installer/nsis are not used by the KfW 4.x
build process.  windows/wintel was removed from the build in commit
530043377ee6f39b9ca95c13f6260602e6fe7674.  windows/cns and most of the
windows/lib objects were removed from the build in commit
52fa910f413e016b3d432ce34e2d5bcea3230a7d.  Most of the Leash krb4
files were removed from the build in commit
9f097418620513813ecc086bcd9002b6e07bf2a1; some unnecessary includes of
the corresponding header files remain, so delete those now.
LeashControlPanel.cpp was not part of the leash build when the leash
sources were imported into this tree.

7 years agoStop building CNS for Windows
Greg Hudson [Fri, 11 May 2018 17:43:42 +0000 (13:43 -0400)] 
Stop building CNS for Windows

CNS is an old Windows ticket manager which was long ago supplanted by
leash.  We have been building it and copying it in "nmake install",
but not including it in the KfW installer.  Remove it from the build,
and trim windows/lib down to just the part used by leashdll and leash
(loadfuncs.obj).

Also stop generating a Makefile for windows/wintel; it was removed
from the build in commit 530043377ee6f39b9ca95c13f6260602e6fe7674.

ticket: 8682 (new)

7 years agoUpdate Windows build instructions 775/head
Greg Hudson [Wed, 9 May 2018 16:37:44 +0000 (12:37 -0400)] 
Update Windows build instructions

Modify windows/README for Visual Studio 2017, which has separate
32-bit and 64-bit command prompts (and which seems to omit uicc from
the 64-bit path).  Mention the need for MFC if building leash, and
describe how to build without leash.

ticket: 8662

7 years agoUpdate kfw installer for VS2017, WiX 3.11.1
Greg Hudson [Tue, 8 May 2018 14:31:26 +0000 (07:31 -0700)] 
Update kfw installer for VS2017, WiX 3.11.1

For Visual Studio 2017 (aka 15.0), add a Visual C tools version
number, and use %VCToolsRedistDir% to find the merge modules.  WiX
toolset 3.11.1 requires an xmlns attribute to the WixLocalization tag.

ticket: 8680 (new)

7 years agoRemove SCLIB references from Windows build
Greg Hudson [Mon, 7 May 2018 02:55:15 +0000 (22:55 -0400)] 
Remove SCLIB references from Windows build

The SCLIB make variable was introduced in commit
c53f7fd2ca7d605397091294683eaf63d6b922f2 and obsoleted in commit
1f0a33eba649194f1775210ca92a66df6a8b47c5.  Remove the remaining traces
of it.

7 years agoAdd Windows build artifacts to .gitignore
Greg Hudson [Mon, 7 May 2018 02:45:30 +0000 (22:45 -0400)] 
Add Windows build artifacts to .gitignore

7 years agoFix Leash build error with recent Visual Studio
Greg Hudson [Mon, 7 May 2018 02:29:40 +0000 (22:29 -0400)] 
Fix Leash build error with recent Visual Studio

Visual Studio 2015 and later do not allow manipulation of the _flag
field inside a file handle.  In Leash's out2con.cpp (used only for the
debugging -console flag), do not try to mark the allocated file handle
as free after copying it to *stdout; a one-time memory leak here is
unimportant.

ticket: 8679 (new)

7 years agoDon't specify MFC library in Leash build
Greg Hudson [Sat, 5 May 2018 21:53:54 +0000 (17:53 -0400)] 
Don't specify MFC library in Leash build

Since MFC 3.0 (which shipped with Visual C++ 2.0, decades ago) it has
been unnecessary to specify the MFC library in the link line; the
headers can magically add the right one.  Guessing the MFC version
from $(VISUALSTUDIOVERSION) does not work with Visual Studio 2017 (we
guess 150; the correct value is 140).

ticket: 8678 (new)

7 years agoEscape curly braces in def-check.pl regexes 774/head
Greg Hudson [Sat, 5 May 2018 17:40:37 +0000 (13:40 -0400)] 
Escape curly braces in def-check.pl regexes

Recent versions of Perl issue a warning or error when an unescaped
open curly brace is used in a position where it might introduce a
quantifier in a regular expression.  Escape all regexp literal curly
braces in def-check.pl.

ticket: 8677 (new)
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

7 years agoRemove "-nodes" option from make-certs scripts 773/head
Robbie Harwood [Thu, 3 May 2018 18:40:45 +0000 (14:40 -0400)] 
Remove "-nodes" option from make-certs scripts

The openssl command does not recognize options after positional
arguments, so in "openssl genrsa $KEYSIZE -nodes", the "-nodes" was
ignored as a excess positional argument prior to OpenSSL 1.1.0h, and
now causes an error.  "-nodes" is an option to the openssl req and
pkcs12 subcommands, but genrsa creates unencrypted keys by default.

[ghudson@mit.edu: edited commit message]

7 years agoSet error message on KCM get_princ failure 771/head
Robbie Harwood [Fri, 27 Apr 2018 17:51:39 +0000 (13:51 -0400)] 
Set error message on KCM get_princ failure

This matches the expected behavior from other ccache types.  Most
notably, the KEYRING equivalent was added in
c25fc42e8eac7350209df61e4a7b9960d17755ca

ticket: 8675 (new)
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

7 years agoMove zero argc check earlier in ksu 770/head
Greg Hudson [Tue, 24 Apr 2018 23:35:38 +0000 (19:35 -0400)] 
Move zero argc check earlier in ksu

For improved auditability, check for a zero argc value earlier in
main() so that the first two calls to com_err() can't pass a NULL
whoami value--which would be harmless, but that may not be obvious to
a reader.

ticket: 8661

7 years agoAvoid simultaneous KDB/ulog locks in ulog_replay 761/head
Greg Hudson [Sat, 14 Apr 2018 18:43:22 +0000 (14:43 -0400)] 
Avoid simultaneous KDB/ulog locks in ulog_replay

In ulog_replay(), instead of locking the KDB and ulog for the whole
operation, separately lock and update the ulog after each database
update, as we would for a locally initiated database operation (after
commit 444ef5fe9ec8d64a5db27b3a8aaf6813dd7ef0e0).

ticket: 8664 (new)

7 years agoFix PKINIT rule matching against UPN SANs 768/head
Greg Hudson [Thu, 22 Mar 2018 23:46:22 +0000 (19:46 -0400)] 
Fix PKINIT rule matching against UPN SANs

Commit 46ff765e1fb8cbec2bb602b43311269e695dbedc (for ticket 8528)
broke rule-based matching of UPN SANs using the <SAN> rule type.  To
fix this regression, make crypto_retrieve_cert_sans() return UPN SANs
in their original string form, and only parse them into principal
names in pkinit_srv.c:verify_client_san().  In
pkinit_cert_matching_data, store UPN SANs as strings separately from
PKINIT SANs instead of concatenating them together, and match original
UPN strings against <SAN> rule regexps.  Add a test case.

ticket: 8670
tags: pullup
target_version: 1.16-next

7 years agoImprove error for kadmind -proponly without iprop 764/head
sashan [Wed, 18 Apr 2018 20:40:33 +0000 (22:40 +0200)] 
Improve error for kadmind -proponly without iprop

If kadmind is run with the -proponly flag, check that iprop_enable is
set and output a reasonable error message if it isn't.  Otherwise we
see the confusing message "Invalid argument while initializing
network".

[ghudson@mit.edu: rewrote commit message; edited error message]

ticket: 8673 (new)

7 years agoCheck for zero argc in ksu 769/head
Greg Hudson [Tue, 24 Apr 2018 18:31:35 +0000 (14:31 -0400)] 
Check for zero argc in ksu

Most programs in the tree will perform a null dereference when argc is
zero, but as a setuid program ksu should be extra careful about memory
errors, even if this one is harmless.  Check and exit with status 1
immediately.

ticket: 8661

7 years agoFix KDC null dereference on large TGS replies 763/head
Robbie Harwood [Fri, 20 Apr 2018 20:16:02 +0000 (16:16 -0400)] 
Fix KDC null dereference on large TGS replies

For TGS requests, dispatch() doesn't set state->active_realm, which
leads to a NULL dereference in finish_dispatch() if the reply is too
big for UDP.  Prior to commit 0a2f14f752c32a24200363cc6b6ae64a92f81379
the active realm was a global and was set when process_tgs_req()
called setup_server_realm().

Move TGS decoding out of process_tgs_req() so that we can set
state->active_realm before any errors requiring response.  Add a test
case.

[ghudson@mit.edu: edited commit message; added test case; reduced code
duplication; removed server handle from process_tgs_req() parameters]

ticket: 8666
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

7 years agoAvoid peeking into server handle in kadmind 767/head
Greg Hudson [Mon, 23 Apr 2018 19:16:37 +0000 (15:16 -0400)] 
Avoid peeking into server handle in kadmind

setup_loop() does not need to peer into the server handle for network
parameters, as kadmind makes its own call to kadm5_get_config_params()
in main().  Use kadmind's copy of the parameters instead.

7 years agoFix doubled "kadmind:" in kadmind fail_to_start() 766/head
Greg Hudson [Mon, 23 Apr 2018 18:54:17 +0000 (14:54 -0400)] 
Fix doubled "kadmind:" in kadmind fail_to_start()

Commit 779a335f4e2deb2d76caf7d0dd3de847a040c050 added the
fail_to_start() helper in ovsec_kadmd.c, accidentally sending the
program name to stderr twice.  Remove one of them.

ticket: 8669 (new)
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

7 years agoAdd marks to longer Python test scripts 765/head
Greg Hudson [Wed, 18 Apr 2018 23:21:56 +0000 (19:21 -0400)] 
Add marks to longer Python test scripts

7 years agoAdd k5test mark() function
Greg Hudson [Wed, 18 Apr 2018 23:21:40 +0000 (19:21 -0400)] 
Add k5test mark() function

Make it easier to locate a failing command in long Python test scripts
by allowing the script to output marks, and displaying the most recent
mark with command failures.

7 years agoDisplay more extended errors in kdb5_util 762/head
Greg Hudson [Sat, 14 Apr 2018 23:17:30 +0000 (19:17 -0400)] 
Display more extended errors in kdb5_util

In kadm5_create(), use the global context instead of a newly created
context, so that extended error messages are displayed properly by
extended_com_err_fn().

ticket: 8665 (new)

7 years agoMerge duplicate subsections in profile library 760/head
Robbie Harwood [Tue, 10 Apr 2018 19:55:41 +0000 (15:55 -0400)] 
Merge duplicate subsections in profile library

Modify profile_add_node() to return the existing node, rather than
making a new one, when adding subsection configuration.

This fixes an issue where the first instance of a subsection will hide
the second instance entirely.  In particular, it was previously
impossible to split realm-specific configuration across multiple
config files.

[ghudson@mit.edu: adjusted style, added test case]

ticket: 7863
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

7 years agoFix small leak in wshelper DLL 759/head
Greg Hudson [Mon, 9 Apr 2018 15:00:05 +0000 (11:00 -0400)] 
Fix small leak in wshelper DLL

Remove a double initialization of dwHesPwUidIndex in wshelper which
caused the first initialization to leak a thread-local storage handle.
Reported by Sergey Ilinykh.

ticket: 8663

7 years agoRestrict pre-authentication fallback cases 758/head
Greg Hudson [Thu, 5 Apr 2018 20:23:34 +0000 (16:23 -0400)] 
Restrict pre-authentication fallback cases

Add a new callback disable_fallback() and call it from each clpreauth
module when it generates a client message using credentials to
authenticate.  (For SPAKE, this is the message responding to a
challenge; for all other current mechanisms, it is the first and only
client message.)  If disable_fallback() is called, do not try another
mechanism after a KDC error.

Remove k5_reset_preauth_types_tried() and its call sites, so that
preauth mechanisms which are tried optimistically will no longer be
retried after a failure.

ticket: 8654

7 years agoBe more careful asking for AS key in SPAKE client 757/head
Greg Hudson [Sat, 31 Mar 2018 14:43:49 +0000 (10:43 -0400)] 
Be more careful asking for AS key in SPAKE client

Asking for the AS key too early can result in password prompts in
situations where SPAKE won't proceed, such as when the KDC offers only
second factor types not supported by the client.

In spake_prep_questions(), decode the received message and make sure
it's a challenge with a supported group and second factor type
(SF-NONE at the moment).  Save the decoded message and use it in
spake_process().  Do not retrieve the AS key at the beginning of
spake_process(); instead do so in process_challenge() after checking
the challenge group and factor types.

Move contains_sf_none() earlier in the file so that it can be used by
spake_prep_questions() without a prototype.

ticket: 8659

7 years agoDocument comments in krb5.conf 756/head
Greg Hudson [Fri, 30 Mar 2018 20:54:44 +0000 (16:54 -0400)] 
Document comments in krb5.conf

ticket: 8660 (new)
tags: pullup
target_version: 1.16-next

7 years agoZap data when freeing krb5_spake_factor 754/head
Greg Hudson [Tue, 27 Mar 2018 19:42:28 +0000 (15:42 -0400)] 
Zap data when freeing krb5_spake_factor

krb5_spake_factor structures will sometimes hold sensitive data when
second-factor SPAKE is implemented, so should be zapped when freed.

ticket: 8647

7 years agoContinue after KRB5_CC_END in KCM cache iteration 755/head
Fabiano Fidêncio [Wed, 28 Mar 2018 16:27:06 +0000 (18:27 +0200)] 
Continue after KRB5_CC_END in KCM cache iteration

The KCM server returns KRB5_CC_END in response to a GET_CACHE_BY_UUID
request to indicate that the specified ccache uuid no longer exists.
In krb5_ptcursor_next(), ignore this error and continue the iteration,
as the Heimdal KCM client code does.

In addition to addressing the case where a third party deletes a cache
between the GET_CACHE_UUID_LIST request and when we reach that uuid in
the iteration, this change also fixes a bug in kdestroy -A where the
caller deletes the primary cache and we later request it by uuid when
iterating over the list.

[ghudson@mit.edu: rewrote commit message; edited comment]

ticket: 8658 (new)
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

7 years agoFix SPAKE memory leak 753/head
Greg Hudson [Tue, 27 Mar 2018 14:36:05 +0000 (10:36 -0400)] 
Fix SPAKE memory leak

In the NIST group implementations, ossl_fini() needs to free the
groupdata container as well as its fields.  Also in
spake_kdc.c:parse_data(), initialize the magic field of the resulting
data object to avoid a harmless uninitialized memory copy.

ticket: 8647

7 years agoSimplify ASN.1 encoding 751/head
Greg Hudson [Wed, 21 Mar 2018 22:17:08 +0000 (18:17 -0400)] 
Simplify ASN.1 encoding

Like most ASN.1 DER implementations, we encode backwards.  The
existing asn1buf implementation inserts bytes forward into a
resizeable buffer, then reallocates the number of bytes inserted and
reverses them.

Throw out this implementation and replace it with two simple inline
functions in asn1_encode.c, which conditionally insert bytes in
reverse order and unconditionally increment a count.  Make two passes
over the input representation, once to count the encoding size and
once to actually encode it into a precisely allocated buffer.  Remove
all of the explicit length counting from encoding functions; in the
places where we need intermediate lengths, compute them from the
difference in buffer byte count.  Make a few encoding functions return
void as they no longer have error cases.

7 years agoUse stdint types in ASN.1 code
Greg Hudson [Wed, 21 Mar 2018 15:04:32 +0000 (11:04 -0400)] 
Use stdint types in ASN.1 code

Replace krb5 fixed-width typedef names with [u]int{16,32}_t, and use
uint8_t in place of unsigned char and asn1_octet.  Use krb5_error_code
in place of asn1_error_code, and remove dependencies on internal ASN.1
headers from the tests.

7 years agoAdd doc index entries for SPAKE constants
Greg Hudson [Tue, 27 Mar 2018 04:49:43 +0000 (00:49 -0400)] 
Add doc index entries for SPAKE constants

ticket: 8647

7 years agoAdd SPAKE preauth support 741/head
Greg Hudson [Fri, 25 Sep 2015 21:47:35 +0000 (17:47 -0400)] 
Add SPAKE preauth support

This is an implementation of draft-ietf-kitten-krb-spake-preauth-05.
SPAKE preauth authenticates using the client principal long-term key,
but protects against offline dictionary attacks.

SPAKE preauth negotiates a group for use by the SPAKE2 algorithm.  The
edwards25519 group is implemented using code adapted from BoringSSL.
The P-256, P-384, and P-521 groups are implemented against OpenSSL.
edwards25519 is enabled by default on the client; no groups are
enabled by default on the KDC.

SPAKE preauth can also include a second factor.  Second factor support
isn't included in this implementation; comments have been left to
indicate what should change when it is added in.

Integration tests (tests/t_spake.py) are included with good coverage
of the negotiation scenarios.

Test vectors from the draft are checked against the group's "result"
operation.  The "keygen" operation is inherently random and is
therefore not tested against the vectors, but is effectively exercised
by the integration tests.

KDC optimistic challenge is implemented.  In the future we should
implement client optimistic SPAKE as well; this will require changes
to the generic client preauth framework.

In the future we should add per-realm configuration to deny encrypted
timestamp and encrypted challenge on a per-realm basis.  This
configuration should stick across client realm referrals.

In the future we should avoid attempting encrypting timestamp or
encrypted challenge if the KDC replies to a single-factor
SPAKEResponse message with PREAUTH_FAILED.  This will require a change
to the generic client preauth framework.

In the future we should make SPAKE support apply to the Windows build,
either by adding support for building plugin DLLs or by moving the
edwards25519 and client code to libkrb5.

[npmccallum@redhat.com: split up internal headers; split out group
registry contents; implemented P-384 and P-521]

ticket: 8647 (new)

7 years agoUse k5_buf_init_dynamic_zap where appropriate 752/head
Greg Hudson [Mon, 26 Mar 2018 15:24:49 +0000 (11:24 -0400)] 
Use k5_buf_init_dynamic_zap where appropriate

7 years agoImplement k5_buf_init_dynamic_zap
Greg Hudson [Mon, 26 Mar 2018 15:12:39 +0000 (11:12 -0400)] 
Implement k5_buf_init_dynamic_zap

Add a variant of dynamic k5buf objects which zeroes memory when
reallocating or freeing the buffer.

7 years agoMove zap() definition to k5-platform.h
Greg Hudson [Mon, 26 Mar 2018 14:54:29 +0000 (10:54 -0400)] 
Move zap() definition to k5-platform.h

Make it possible to use zap() in parts of the code which should not
include k5-int.h by moving its definition to k5-platform.h.

7 years agoAdd vector support to k5_sha256()
Greg Hudson [Sun, 4 Feb 2018 01:53:42 +0000 (20:53 -0500)] 
Add vector support to k5_sha256()

Add a length argument so that multiple krb5_data values can be passed
to k5_sha256(), for efficient computation of SHA-256 hashes over
concatenations of data values.

7 years agoRemove unneeded conditional in hex.c 750/head
Greg Hudson [Mon, 19 Mar 2018 16:23:19 +0000 (12:23 -0400)] 
Remove unneeded conditional in hex.c

hex_digit() accepts bval as an unsigned parameter, so we don't need to
test if bval >= 0.

7 years agoReport extended errors in kinit -k -t KDB: 749/head
Greg Hudson [Sun, 18 Mar 2018 02:47:34 +0000 (22:47 -0400)] 
Report extended errors in kinit -k -t KDB:

In kinit, if we recreate the context using kinit_kdb_init(), also
reset the global errctx so that we use the new context to retrieve
extended error messages.

ticket: 8652 (new)

7 years agoAvoid rereading non-regular profile files 748/head
Greg Hudson [Mon, 19 Mar 2018 01:41:02 +0000 (21:41 -0400)] 
Avoid rereading non-regular profile files

If a profile file is a special device such as a pipe, then reloading
it will cause us to discard its contents.  Repurpose the first
PROFILE_FILE flag bit to indicate that the file should not be
reloaded.  In profile_update_file_data_locked(), set the flag on the
first load if stat() doesn't indicate a regular file, and check the
flag before testing whether we need to perform any subsequent reload.

Later on in profile_update_file_data_locked(), specifically unset the
DIRTY flag rather than unsetting all flags other than SHARED, so that
we don't clear the NO_RELOAD flag.

ticket: 8651

7 years agoOmit AS-REP etype-info for replaced reply keys 743/head
Greg Hudson [Mon, 12 Mar 2018 19:44:39 +0000 (15:44 -0400)] 
Omit AS-REP etype-info for replaced reply keys

etype-info in AS-REP is currently only useful when no
pre-authentication took place.  Don't send it if a preauth mech
replaced the reply key, as we can't send something consistently
meaningful (the enctype must match the replaced reply key per RFC
4120, but the salt from the client key data corresponds to the initial
reply key).

ticket: 8642

7 years agoAlways use AS-REP enctype in PKINIT client
Greg Hudson [Tue, 13 Feb 2018 21:33:33 +0000 (16:33 -0500)] 
Always use AS-REP enctype in PKINIT client

The get_etype() callback originally only returned the AS-REP enctype
for PKINIT, but was changed for encrypted challenge to sometimes
return the enctype from etype-info.  (Encrypted challenge no longer
uses the callback; PKINIT is currently the only known consumer.)  Make
sure to always return the AS-REP enctype if an AS-REP has been
received, so that the PKINIT clpreauth module uses the correct enctype
even if the KDC sends a different enctype in etype-info in violation
of RFC 4120.

ticket: 8642

7 years agoInclude preauth name in trace output if possible 746/head
Robbie Harwood [Thu, 15 Mar 2018 18:37:28 +0000 (14:37 -0400)] 
Include preauth name in trace output if possible

Add a {patype} trace format specifier for a single pa-type value.  Add
a krb5_preauthtype to string conversion function to trace machinery
and use it when formatting {patype} or {patypes}.

[ghudson@mit.edu: wrote conversion function; edited commit message]

ticket: 8653 (new)

7 years agoAdd PKINIT KDC support for freshness token 742/head
Greg Hudson [Mon, 12 Mar 2018 15:31:46 +0000 (11:31 -0400)] 
Add PKINIT KDC support for freshness token

Send a freshness token in the preauth hint list if PKINIT is
configured and the request padata indicates support.  Verify the
freshness token if the client includes one in a PKINIT request, and
log whether one was received.  If pkinit_require_freshness is set to
true in the realm config, reject non-anonymous requests which don't
contain a freshness token.

Add freshness token tests to t_pkinit.py with some related changes.
Remove client long-term keys after testing password preauth so we get
better error reporting when pkinit_require_freshness is set and a
token is not sent.  Remove ./responder invocations for test cases
which don't ask PKINIT responder questions, or else the responder
would fail now that it isn't being asked for the password.  Leave
anonymous PKINIT enabled after the anonymous tests so that we can use
it again when testing enforcement of pkinit_require_freshness.  Add
expected trace messages for the basic test, including one for
receiving a freshness token.  Add minimal expected trace messages for
the RSA test.

ticket: 8648

7 years agoAdd PKINIT client support for freshness token
Greg Hudson [Tue, 31 Jan 2017 22:02:34 +0000 (17:02 -0500)] 
Add PKINIT client support for freshness token

Send an empty PA_AS_FRESHNESS padata item in unauthenticated AS
requests to indicate support for RFC 8070.  If the KDC includes a
PA_AS_FRESHNESS value in its method data, echo it back in the new
freshnessToken field of pkAuthenticator

ticket: 8648

7 years agoFix read overflow in KDC sort_pa_data() 747/head
Greg Hudson [Fri, 16 Mar 2018 00:27:30 +0000 (20:27 -0400)] 
Fix read overflow in KDC sort_pa_data()

sort_pa_data() could read past the end of pa_order if all preauth
systems in the table have the PA_REPLACES_KEY flag, causing a
dereference of preauth_systems[-1].  This situation became possible
after commit fea1a488924faa3938ef723feaa1ff12d22a91ff with the
elimination of static_preauth_systems; before that there were always
table entries which did not have PA_REPLACES_KEY set.

Fix this bug by removing the loop to count n_key_replacers, and
instead get the count from the prior loop by stopping once we move all
of the key-replacing modules to the front.

7 years agoExit with status 0 from kadmind 745/head
Robbie Harwood [Wed, 14 Mar 2018 18:31:22 +0000 (14:31 -0400)] 
Exit with status 0 from kadmind

Typically, 0 denotes successful exit.  In particular, init systems
will complain if another different value is returned.  This presents a
problem for automated installation jobs which want to restart kadmind.

`service kadmin stop` typically sends SIGTERM, which is caught by
verto and passed to our handler.  Besides cleanup, we then call
verto_break(), which causes the verto_run() event loop to return.  The
weird return code has been present since the addition of the kadmin
code, which used a similar event model for signals.

ticket: 8650 (new)

7 years agoAllow validation of PACs with enterprise names 744/head
Isaac Boukris [Tue, 13 Mar 2018 23:19:17 +0000 (01:19 +0200)] 
Allow validation of PACs with enterprise names

In k5_pac_validate_client(), if we are verifying against an enterprise
principal, parse the PAC_CLIENT_INFO field as an enterprise principal.
This scenario may arise in the response to an S4U2Self request for an
enterprise principal, as the KDC does not appear to canonicalize the
client principal requested in PA-FOR-USER.

[ghudson@mit.edu: rewrote commit message; adjusted style]

ticket: 8649 (new)
tags: pullup
target_version: 1.16-next

7 years agoSimplify kdc_preauth.c systems table 727/head
Greg Hudson [Sun, 11 Feb 2018 20:23:35 +0000 (15:23 -0500)] 
Simplify kdc_preauth.c systems table

Get rid of static_preauth_systems, and replace it with explicit calls
to helper functions in get_preauth_hint_list() and return_padata().
Stop preallocating pa-data lists, instead reallocating on each
addition using add_pa_data_element().  Also simplify
maybe_add_etype_info2() using add_pa_data_element().

The KRB5_PADATA_PAC_REQUEST table entry did nothing, and was probably
originally added back when the KDC would error out on unrecognized
padata types.  The KRB5_PADATA_SERVER_REFERRAL entry has been disabled
since it was first added.

7 years agoRefactor KDC krb5_pa_data utility functions
Greg Hudson [Thu, 21 Dec 2017 16:28:52 +0000 (11:28 -0500)] 
Refactor KDC krb5_pa_data utility functions

Move alloc_padata from fast_util.c to kdc_util.c and make it
non-static so it can be used by other files.  Rename it to
alloc_pa_data for consistency with add_pa_data_element.  Make it
correctly handle zero length using a null contents pointer.

Make add_pa_data_element claim both the container and contents memory
from the caller, now that callers can use alloc_pa_data to simplify
allocation and copying.  Remove the copy parameter and the unused
context parameter, and put the list parameter first.  Adjust all
callers accordingly, making small simplifications to memory handling
where applicable.

7 years agoFix capaths "." values on client 740/head
Greg Hudson [Sat, 3 Mar 2018 18:44:00 +0000 (13:44 -0500)] 
Fix capaths "." values on client

Commit b72aef2c1cbcc76f7fba14ddc54a4e66e7a4e66c (ticket 6966)
introduced k5_client_realm_path() for use on the client in place of
krb5_walk_realm_tree(), but failed to handle the special case of a
capaths "." value as is done in the latter function.  Correct that
omission and add a test case.

ticket: 8646 (new)
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

7 years agoUse libkrb5support hex decoder in PKINIT 723/head
Greg Hudson [Tue, 6 Mar 2018 05:14:49 +0000 (00:14 -0500)] 
Use libkrb5support hex decoder in PKINIT

In pkinit_crypto_openssl.c, remove hex_string_to_bin() (recently added
for ease of backporting) and instead use k5_hex_decode() in
pkinit_get_certs_pkcs11().  Change the type of cert_id and cert_id_len
in pkinit_identity_crypto_context to avoid needing type conversion
intermediates.

7 years agoFix hex conversion of PKINIT certid strings
Sumit Bose [Fri, 26 Jan 2018 16:47:50 +0000 (11:47 -0500)] 
Fix hex conversion of PKINIT certid strings

When parsing a PKCS11 token specification, correctly convert from hex
to binary instead of using OpenSSL bignum functions (which would strip
leading zeros).

[ghudson@mit.edu: made hex_string_to_bin() a bit less verbose; wrote
commit message]

ticket: 8636

7 years agoAdd ASN.1 encoders and decoders for SPAKE types 713/head
Greg Hudson [Sat, 13 Jun 2015 20:04:53 +0000 (16:04 -0400)] 
Add ASN.1 encoders and decoders for SPAKE types

Add a new internal header k5-spake.h.  Add ASN.1 encoder and decoder
functions and an internal free function for SPAKE types.  Add ASN.1
tests and asn1c test vectors the new types.

The additions to to make-vectors.c use C99 designated initializers in
order to initialize unions.  This is okay since make-vectors.c is only
compiled as part of "make test-vectors" and not as part of the regular
build.

7 years agoImprove KDC encrypting key memory management 733/head
Greg Hudson [Tue, 27 Feb 2018 18:09:51 +0000 (13:09 -0500)] 
Improve KDC encrypting key memory management

Commit 0ba5ccd7bb3ea15e44a87f84ca6feed8890f657d caused encrypting_key
to hold either an owned or alias pointer depending on the presence of
the KDC_OPT_ENC_TKT_IN_SKEY (u2u) flag in the request.  For better
memory management safety, introducing server_keyblock to hold owned
memory in the non-u2u case, and turning encrypting_key into an alias
pointer for both cases.

7 years agoFix KDC encrypting key memory leak on some errors
Greg Hudson [Tue, 27 Feb 2018 16:56:58 +0000 (11:56 -0500)] 
Fix KDC encrypting key memory leak on some errors

Commit 0ba5ccd7bb3ea15e44a87f84ca6feed8890f657d separated the
allocation and destruction of encrypting_key, causing it to leak when
any of the intervening calls jump to the cleanup label.  Currently the
leak manifests on transited or authdata failures.  Move encrypting_key
destruction to the cleanup label so that it can't leak.  Reported by
anedvedicky@gmail.com.

ticket: 8645 (new)
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

7 years agoUse libkrb5support hex functions where appropriate 739/head
Greg Hudson [Mon, 19 Feb 2018 05:52:35 +0000 (00:52 -0500)] 
Use libkrb5support hex functions where appropriate

7 years agoAdd libkrb5support hex functions and tests
Greg Hudson [Mon, 19 Feb 2018 05:51:44 +0000 (00:51 -0500)] 
Add libkrb5support hex functions and tests

7 years agoAdd malloc null checks to MSLSA ccache 728/head
sashan [Tue, 20 Feb 2018 22:05:13 +0000 (23:05 +0100)] 
Add malloc null checks to MSLSA ccache

7 years agoFix trivial KDC memory leak with test KDB module 734/head
sashan [Tue, 20 Feb 2018 21:35:51 +0000 (22:35 +0100)] 
Fix trivial KDC memory leak with test KDB module

If a KDB module zeroes out the master key in its fetch_master_key()
method (as the test KDB module does), krb5_db_fetch_mkey() will copy
it, allocating one byte of memory for the contents.  The KDC will then
leak it on exit, as the length is zero.  Simplify master key
destruction using zapfree().

[ghudson@mit.edu: wrote commit message]