Commit Graph

104 Commits

Author SHA1 Message Date
Luke Howard
47282cae34 krb5: import Heimdal-597.121.1 AS/TGS client
Sync with most changes in AS/TGS client from Apple's Heimdal-597.121.1
(opensource.apple.com).

Changes include:

 - FAST support in TGS client
 - Refactored pre-auth client to be more easily extensible
 - Pin KDC host and AD site name in API calls

Note the completely refactored TGS client loop is not imported as that was
considered too intrusive.
2021-12-14 09:03:42 +11:00
Luke Howard
3ac48a8dfd krb5: KRB5_KRBHST_TKTBRIDGEAP
Add a new krbhst type, KRB5_KRBHST_TKTBRIDGEAP to krb5_krbhst_init_flags(),
that looks for the DNS SRV record kerberos-tkt-bridge. This is to support a new
PADL project.
2021-09-13 19:20:11 +10:00
Nicolas Williams
ea83f068e9 kadm5/kadmin: Add read-only mode
Now we can have read-only kadmind instances.
2020-09-08 00:25:40 -05:00
Nicolas Williams
0a0bf32935 krb5: Fix leak in gethostlist() 2020-09-07 22:04:59 -05:00
Nicolas Williams
ea90ca8666 Move some infra bits of lib/krb5/ to lib/base/ (2)
This is the second of two commits in a series that must be picked together.

This series of two commits moves parts of lib/krb5/ infrastructure
functionality to lib/base/, leaving behind wrappers.

Some parts of libkrb5 are entirely generic or easily made so, and could
be useful in various parts of Heimdal that are not specific to the krb5
API, such as:

 - lib/gssapi/  (especially since the integration of NegoEx)
 - lib/hx509/
 - bx509d       (which should really move out of kdc/)

For the above we need to move these bits of lib/krb5/:

 - lib/krb5/config_file.c   (all of it, leaving forwardings behind)
 - lib/krb5/config_reg.c    (all of it)
 - lib/krb5/plugin.c        (all of it, leaving forwardings behind)
 - lib/krb5/log.c           (all of it, ditto)
 - lib/krb5/heim_err.et     (all of it)

And because of those two, these too must also move:

 - lib/krb5/expand_path.c   (all of it, leaving forwardings behind)
 - lib/krb5/warn.c          (just the warning functions, ditto)

The changes to the moved files are mostly quite straightforward and are
best reviewed with --word-diff=color.

We're also creating a heim_context and a heim API to go with it.  But
it's as thin as possible, with as little state as necessary to enable
this move.  Functions for dealing with error messages use callbacks.

Moving plugin.c does have one knock-on effect on all users of the old
krb5 plugin API (which remains), which is that a global search and
replace of struct krb5_plugin_data to struct heim_plugin_data was
needed, though the layout and size of that structure doesn't change, so
the ABI doesn't either.

As well, we now build lib/vers/ and lib/com_err/ before lib/base/ so as
to be able to move lib/krb5/heim_err.et to lib/base/ so that we can make
use of HEIM_ERR_* in lib/base/, specifically in the files that moved.

Once this is all done we'll be able to use config files and plugins in
lib/hx509/, we'll be able to move bx509d out of kdc/, and so on.

Most if not all of the new functions in lib/base/ are Heimdal-private,
thus calling conventions for them are not declared.

Status:

 - builds and passes CIs (Travis, Appveyor)
 - ran make check-valgrind and no new leaks or other memory errors
 - ready for review

HOW TO REVIEW:

     $ # Review file moves:
     $ git log --stat -n1 HEAD^
     $
     $ # Review changes to moved files using --word-diff=color
     $ git log -p -b -w --word-diff=color HEAD^..HEAD   \
               lib/base/config_file.c                   \
               lib/base/config_reg.c                    \
               lib/base/expand_path.c                   \
               lib/base/warn.c                          \
               lib/krb5/config_file.c                   \
               lib/krb5/config_reg.c                    \
               lib/krb5/expand_path.c                   \
               lib/krb5/warn.c
     $
     $ # Review the whole thing, possibly adding -b and/or -w, and
     $ # maybe --word-diff=color:
     $ git log -p origin/master..HEAD
     $ git log -p -b -w origin/master..HEAD
     $ git log -p -b -w --word-diff=color origin/master..HEAD

TBD (future commits):

 - make lib/gssapi use the new heimbase functions
 - move kx509/bx509d common code to lib/hx509/ or other approp. location
 - move bx509d out of kdc/
2020-03-02 10:56:13 -06:00
Luke Howard
803efebca5 krb5, kadm5: refactor plugin API
Refactor plugin framework to use a single list of loaded plugins; add a new
plugin API where DSOs export a load function that can declare dependencies and
export multiple plugins; refactor kadm5 hook API to use krb5 plugin framework.

More information in krb5-plugin(7).
2019-01-03 20:06:27 -06:00
Andrew Bartlett
2ea34666d9 heimdal: Fix printing a short int into a string
The size of portstr is too small to print an integer.

Instead just let snprintf do the work.

This fixes building with GCC 7.1

Based on feedback by Jeffrey Altman

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12930

(Inspired by Samba commit abd74c3ba5e3ee3f5320bff6ed7dff4fbcb79373)

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2018-12-20 12:52:12 +11:00
Nicolas Williams
b2f6ba0fff Revert "lib: Fix printing a short into portstr"
This reverts commit ccb63bb0aa, which was
unnecessary and broke tests/kdc/check-kadmin (and other things).

host->port happens to be an unsigned short, so that promotion to an integer in
the snprintf() call is safe in that the promoted value will still be
non-negative, and no larger than an unsigned short's maximum value.  We're
still assuming that 7 bytes is sufficient to hold the text representation of
that maximum value, which indeed it is, assuming sizeof(unsigned short) == 2
and CHAR_BIT == 8, which are fair assumptions here.  A better patch, if we
needed it, would be to just make portstr[] an array of 11 char, or perhaps make
it a VLA (but we can't yet use VLAs, I don't think, because of older Windows
systems that must be supported still).
2017-10-05 10:43:42 -05:00
Andreas Schneider
ccb63bb0aa lib: Fix printing a short into portstr
The size of portstr is too small to print an integer and we should print
a short anyway.

This fixes building with GCC 7.1
2017-09-25 18:16:18 -05:00
Nicolas Williams
3ba12317a0 Misc fixes (coverity) 2016-11-28 15:09:55 -06:00
Nicolas Williams
616aaf95a8 Don't suppress DNS search list by appending '.'
The original motivation was to avoid extra timeouts when the network is
broken.  However this doesn't avoid one of the timeouts and adds
complexity and introduced bugs.

To really suppress search lists use ndots.
2016-11-10 13:17:19 -06:00
Nicolas Williams
13cb3b5646 Don't inhibit /etc/services matches 2016-11-09 22:49:03 -06:00
Nicolas Williams
6a68376a33 Don't inhibit /etc/hosts matches (fix #32)
Apending '.' to the hostname passed to `getaddrinfo()` is good for
avoiding extra timeouts when the search list is non-empty and the
network is broken, but searches in /etc/hosts are typically inhibited
then.  The fix is to try again without the trailing '.' if the first
lookup failed for any reason other than a timeout.
2016-11-09 22:49:03 -06:00
Jeffrey Altman
cc62c1a4ae lib/krb5: fix srv_find_realm invalid gTLD test
In srv_find_realm() the conditional for testing whether an entry
is the invalid gTLD response was inverted.  Refactor the conditional
into a helper function is_invalid_tld_srv_target().  Use the helper
to simplify the conditional making it easier to confirm that the
test is correct.

Change-Id: I3220753b5585ac535862c4617030377c7a1f4bbe
2016-04-13 18:52:55 -05:00
Jeffrey Altman
13568961ec krb5: DNS A record fallback test for invalid gTLD
As per
https://www.icann.org/en/system/files/files/name-collision-mitigation-01aug14-en.pdf
prior to a new top-level domain being put into service there is controlled
interuption service which will return explicit responses to DNS A, MX, SRV, and TXT
queries that can be used to detect private namespace collisions.

When performing fallback_get_hosts() check the AF_INET responses to ensure
that they are not the gTLD name collision address 127.0.53.53.  If so, add
an error message to the context and return KRB5_KDC_UNREACH.

Write a warning to the log (if any).

Change-Id: I2578f13948b8327cc3f06542c1e489f02410143a
2016-04-10 17:05:07 -05:00
Jeffrey Altman
4b45355162 krb5: DNS SRV records test for invalid gTLD
As per
https://www.icann.org/en/system/files/files/name-collision-mitigation-01aug14-en.pdf
prior to a new top-level domain being put into service there is a
controlled interuption service which will return explicit responses to DNS
A, MX, SRV, and TXT queries that can be used to detect private namespace collisions.

Modify SRV records lookups to detect the special hostname returned in the
SRV response, skip the response, and record an appropriate error if it is detected.

Write a warning to the log (if any).

Change-Id: I47e049b617e39e49939bc92d513a547de1d04624
2016-04-10 17:05:07 -05:00
Jeffrey Altman
5f138a16ef libkrb5: Add missing KRB5_LIB_FUNCTION/KRB5_LIB_CALL
KRB5_LIB_FUNCTION and KRB5_LIB_CALL are necessary even on private
functions that are exported.

Change-Id: Iccd0cfe87ff0a9d851e29890e9cb55b3ae517ce1
2013-06-22 21:17:32 -04:00
Roland C. Dowdeswell
f0f07ff408 Use krb5_enomem() more consistently in lib/krb5. 2013-02-13 16:15:00 +08:00
Love Hornquist Astrand
58ff480763 rewrite send to kdc to be more agressive, try kdcs in paralell and easier to configure behavior 2013-02-10 19:02:52 -08:00
Love Hornquist Astrand
dff11de56b use new plugin system for locate kdc plugins (30 as-req/s faster for kdc-tester on MacBookAir5,2) 2012-12-27 12:23:29 +01:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Love Hornquist Astrand
1072afd6bf Andrew Bartlet pointed out that the patch was incomplete, update and write doxygen. 2010-09-30 00:44:35 -07:00
Love Hornquist Astrand
f454f45fbf If the hostname contains a dot, assumes it's a FQAN and don't use
search domains since that might be painfully slow when machine is
disconnected from that network.

Found by Tridge
2010-09-28 22:37:01 -07:00
Love Hornquist Astrand
788189805c catch error from as.*printf 2010-05-30 13:28:49 -07:00
Love Hornquist Astrand
687db64c56 Patch from Secure Endpoints/Asanka Herath for windows support 2009-12-21 08:45:28 +01:00
Love Hornquist Astrand
4c06438189 Add _krb5_krbhst_get_realm() to get what realm was used 2009-09-07 20:54:48 -07:00
Love Hornquist Astrand
6770fd45e1 Sprinkle _krb5_debug() for more info about what the framework is actually doing behind our back 2009-09-07 20:22:44 -07:00
Love Hornquist Astrand
ede8ad11ad Support IPv6 numeric style addresses, example [2001:10:300::1]:88 2009-08-14 04:34:10 +02:00
Love Hörnquist Åstrand
db149370e1 dns: switch to rk types
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24893 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-03-22 17:18:55 +00:00
Love Hörnquist Åstrand
bd5229d126 prefix dns_ symbols
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24883 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-03-22 17:17:02 +00:00
Love Hörnquist Åstrand
c2c1e95ccf dont increment nhost since its no longer used
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24852 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-27 03:29:58 +00:00
Love Hörnquist Åstrand
3767202e6e drop RCSID
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24359 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-01-25 00:31:10 +00:00
Love Hörnquist Åstrand
50d02c49b9 Only claime configuration exists if the plugin returned some useful data.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23816 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 09:43:32 +00:00
Love Hörnquist Åstrand
6937d41a02 remove trailing whitespace
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23815 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 09:21:03 +00:00
Love Hörnquist Åstrand
e172367898 switch to utf8 encoding of all files
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23814 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 08:53:55 +00:00
Love Hörnquist Åstrand
c808db85c0 N_()ify
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23786 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-07 21:27:47 +00:00
Love Hörnquist Åstrand
dbc55c9bec indent
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23447 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-07-27 12:09:05 +00:00
Love Hörnquist Åstrand
2a4e18eb43 handle KRB5_PLUGIN_NO_HANDLE for lookup plugin.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23366 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-07-15 11:26:11 +00:00
Love Hörnquist Åstrand
e3af27dfa4 use constant KRB5_PLUGIN_LOCATE
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23350 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-07-15 11:22:26 +00:00
Love Hörnquist Åstrand
7fcd266fdd use krb5_set_error_message
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23316 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-06-23 04:32:32 +00:00
Love Hörnquist Åstrand
f19dec620a use krb5_set_error_message
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23294 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-06-23 03:28:29 +00:00
Love Hörnquist Åstrand
c0e76182db Set error string when there is no KDC for a realm.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21457 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-07-10 12:53:25 +00:00
Love Hörnquist Åstrand
8ab80e3238 Host is static memory, don't free.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21131 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-18 20:48:09 +00:00
Love Hörnquist Åstrand
31c6637aca (plugin_get_hosts): be more paranoid and pass in a NULLed plugin list
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19198 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-11-30 17:23:08 +00:00
Love Hörnquist Åstrand
feca1fb894 Fill in hints for picky getaddrinfo()s.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19010 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-11-13 05:06:08 +00:00
Love Hörnquist Åstrand
35ac6d4651 Use plugin for the other realm locate types too.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19008 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-11-13 04:46:37 +00:00
Love Hörnquist Åstrand
51bdcbd088 Use the resolve plugin interface.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19000 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-11-12 20:05:20 +00:00
Love Hörnquist Åstrand
7a2077bff3 (common_init): don't try DNS when there is realm w/o a dot.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18272 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-10-06 17:11:02 +00:00
Love Hörnquist Åstrand
cf9efd9db1 (fallback_get_hosts): limit the fallback lookups to 5.
Patch from Wesley Craig, umich.edu


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17958 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-09-01 10:16:28 +00:00
Love Hörnquist Åstrand
d9b82bea73 fix spelling
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16958 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-04-02 10:32:20 +00:00