Commit Graph

1661 Commits

Author SHA1 Message Date
Andrew Bartlett
b01d527a35 Merge pull request #171 from jelmer/parallel
Fix parallel builds.
2016-05-14 22:28:25 +12:00
Viktor Dukhovni
1017a594ef Use OpenSSL include path as needed
For consistency make "-I" part of the macro value set by autoconf.

For now, don't attempt to handle OpenSSL rpath in cf/crypto.m4.
That's much easier by just setting LDFLAGS when running configure.
Otherwise too many Makefiles to edit and libtool and automake do
their best to undo the rpath.
2016-05-07 05:29:12 -04:00
Jelmer Vernooij
a460601ee3 Properly fix parallel builds. 2016-04-20 12:15:27 +00:00
Jeffrey Altman
ce4fd05b12 fixup pkinit-ec.c (kdc and lib/krb5) includes
All source files must start with

  include <config.h>
  include <roken.h>

when krb5_locl.h or kdc_locl.h are includes, they must come before
other Heimdal include files.

Do not include stdint.h when roken.h is included.
Do not include config.h more than once.

Change-Id: I0baecb5d48317996f48b1a6c41b051f42f2fde61
2016-04-17 17:10:08 -05:00
Nicolas Williams
1103fb19df Fix re-definition of keyex enum 2016-04-16 16:58:08 -05:00
Nicolas Williams
490337f4f9 Make OpenSSL an hcrypto backend proper
This adds a new backend for libhcrypto: the OpenSSL backend.

Now libhcrypto has these backends:

 - hcrypto itself (i.e., the algorithms coded in lib/hcrypto)
 - Common Crypto (OS X)
 - PKCS#11 (specifically for Solaris, but not Solaris-specific)
 - Windows CNG (Windows)
 - OpenSSL (generic)

The ./configure --with-openssl=... option no longer disables the use of
hcrypto.  Instead it enables the use of OpenSSL as a (and the default)
backend in libhcrypto.  The libhcrypto framework is now always used.

OpenSSL should no longer be used directly within Heimdal, except in the
OpenSSL hcrypto backend itself, and files where elliptic curve (EC)
crypto is needed.

Because libhcrypto's EC support is incomplete, we can only use OpenSSL
for EC.  Currently that means separating all EC-using code so that it
does not use hcrypto, thus the libhx509/hxtool and PKINIT EC code has
been moved out of the files it used to be in.
2016-04-15 00:16:17 -05:00
Nicolas Williams
69eb97a92d kdc: num_kdc_procs < 1 -> use NCPUs 2016-02-29 19:13:12 -06:00
Viktor Dukhovni
54d37fdba6 Fix memory leak 2016-02-26 15:43:13 -05:00
Nicolas Williams
b4cf4de807 Fix warnings (clang 3.6) 2016-02-26 01:04:31 -06:00
Nicolas Williams
c6f24e99f0 Revamp cf/db.m4; test LMDB 2016-02-26 00:55:32 -06:00
Brian May
6b5933337b Fix parallel build
Fix problem due to missing makefile dependency on a generated file.

See http://bugs.debian.org/800728 for details

Signed-off-by: Nicolas Williams <nico@twosigma.com>
2016-02-05 17:23:39 -06:00
Nicolas Williams
1575f4f69a KDC: Don't confuse master process with master 2016-01-21 12:43:31 -06:00
Nicolas Williams
a6e36356b5 KDC: fix C-style 2016-01-21 12:43:30 -06:00
Nicolas Williams
4f87d85d65 Fix Windows build: no fork for kdc 2016-01-20 15:03:30 -06:00
Luke Howard
d135020e8f kdc: Fix compile error on OS X
bonjour_kid() was missing the krb5_context parameter name, preventing
compilation on Darwin (where __APPLE__ is defined)
2015-12-09 10:46:38 +11:00
Roland C. Dowdeswell
352a7e94a3 Make the KDC use a multi-process model.
We now fork(2) a number of separate KDC processes rather than a single
process.  By default, the number is selected by asking how many CPUs
the machine has.  We also have a master process which monitors all
of the children (which do the actual work) and it will restart kids
who die for any reason.  The children will die when the parent dies.

In the case of MacOS X, we also move the bonjour code into another
separate child as it creates threads and this is known to play
rather poorly with fork(2).  We could move this logic into a
designated child at some point in the future.

We slow down the spawning to one every 25ms to prevent instant crashes
and restarts from consuming all available system time.  This approach
may want to be revisited in the future.
2015-11-06 15:39:30 -05:00
Stefan Metzmacher
078e6f5dd2 kdc: add support for HDB_ERR_WRONG_REALM
A backend can return this if asked with HDB_F_GET_CLIENT|HDB_F_FOR_AS_REQ
for a KRB5_NT_ENTERPRISE_PRINCIPAL record or for HDB_F_GET_SERVER | HDB_F_FOR_TGS_REQ.

entry_ex->entry.principal->realm needs to return the real realm of the principal
(or at least a the realm of the next cross-realm trust hop).

This is needed to route enterprise principals between AD domain trusts.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2015-07-31 17:30:23 +12:00
Stefan Metzmacher
81f9ed4a6c kdc: generic support for 3part servicePrincipalNames
This is not DRSUAPI specific, it works for all 3 part principals.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2015-07-31 17:30:23 +12:00
Stefan Metzmacher
a873e21d7c kdc: base _kdc_fast_mk_error() on krb5_mk_error_ext()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2015-07-31 17:30:23 +12:00
Stefan Metzmacher
358e2b7b0a kdc: remove KRB5_PADATA_CLIENT_CANONICALIZED handling
This got removed between draft-ietf-krb-wg-kerberos-referrals-11.txt
and the final rfc6806.txt.

The number 133 was reassigned to PA-FX-COOKIE in rfc6113.txt.

(Samba commit 9ebd10b3432c271625db9fbc1987759c02b23f83 forward-ported
to Heimdal master by Andrew Bartlett)
2015-06-17 17:41:27 -05:00
Andrew Bartlett
c450abd01a heimdal: Ensure that HDB_ERR_NOT_FOUND_HERE, critical for the RODC, is not overwritten
This change ensures that our RODC will correctly proxy when asked to provide
a ticket for a service or user where the keys are not on this RODC.

Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Pair-programmed-with: Garming Sam <garming@catalyst.net.nz>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2015-06-17 17:41:26 -05:00
Andrew Bartlett
324ac13b32 heimdal: remove checking of KDC PAC signature, delegate to wdc plugin
The checking of the KDC signature is more complex than it looks, it may be of a different
enc type to that which the ticket is encrypted with, and may even be prefixed
with the RODC number.

This is better handled in the plugin which can easily look up the DB for the
correct key to verify this with, and can also quickly determine if this is
an interdomain trust, which we cannot verify the PAC for.

Andrew Bartlett
2015-06-17 17:41:26 -05:00
Andrew Bartlett
95256a6129 kdc: Preserve error code from Pre Authentication .validate hook
This is required to ensure the client still gets errors like KRB5KDC_ERR_PREAUTH_FAILED, rather than
KRB5KDC_ERR_PREAUTH_REQUIRED, which become a confusing KRB5_GET_IN_TKT_LOOP.

Andrew Bartlett

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Pair-programmed-with: Garming Sam <garming@catalyst.net.nz>
Signed-off-by: Garming Sam <garming@catalyst.net.nz>
2015-06-17 17:41:25 -05:00
Love Hörnquist Åstrand
4c98e27eda call hdb_auth_status when password is wrong in the ENC-CHAL case too, thanks Andrew Bartlett for pointing this out 2015-04-28 08:54:24 -07:00
Jeffrey Altman
7b17e3015b YFS Coverity 11475
Change-Id: I3b6cde99859979e5db866c3f707f194144251ee1
2015-04-21 21:50:43 -04:00
Nicolas Williams
b48bed5f42 Daemons detach atomically to avoid having to wait
Tests that start daemons have to "wait" for them to start.

This commit makes Heimdal daemons prep to detach (when requested) by
forking early, then having the child signal readiness to the parent when
the child really is ready.  The parent exits only which the child is
ready.  This means that tests will no longer need to wait for daemons.

However, tests will still need a pidfile or such so they can stop the
daemons.

Note that the --detach options should not be used on OS X from launchd,
only from tests.
2015-03-24 11:49:59 -05:00
Jeffrey Altman
83011252d7 kdc: adjust flags passed to hdb_fetch_kvno()
The KDC's _kdc_db_fetch() cals the database's hdb_fetch_kvno() to obtain
one or more decrypted versioned key sets.  The KDC either requires one
specific key set if a non-zero key version number is provided or all key sets.
The key version zero indicates that the latest key version should be used.

Prior to this change the KDC called hdb_fetch_kvno() with the
HDB_F_KVNO_SPECIFIED flag when the kvno is zero breaking cross-realm
with Active Directory.

As of this change, HDB_F_KVNO_SPECIFIED is set for a non-zero kvno and
HDB_F_ALL_KVNOS is set otherwise.

Change-Id: I32f4d8da9b601d7bbec7d80cc34d0ff94f6670be
2015-03-14 16:08:20 -04:00
Love Hörnquist Åstrand
4b0121f545 release pool when done 2014-08-23 18:54:05 -07:00
Love Hörnquist Åstrand
4569c07522 Merge pull request #110 from cg2v/anonymous-pkinit
Anonymous pkinit improvements
2014-08-22 21:35:22 -07:00
Love Hörnquist Åstrand
37afa01be3 rename roken base64, fixes #107 2014-08-22 20:57:24 -07:00
Samuel Cabrero
f79326e960 Check _kdc_db_fetch return value before dereference entry pointer
This fixes a segfault if the _kdc_db_fetch function does not find
the entry in the database (the entry pointer will be NULL if entry
is not found).

Signed-off-by: Samuel Cabrero <scabrero@zentyal.com>
Signed-off-by: Love Hörnquist Åstrand <lha@h5l.org>
2014-07-18 17:46:25 +02:00
Chaskiel Grundman
f07ee07288 Use anon realm for anonymous PKINIT
When an AS request names the anonymous principal, use the anonymous
realm in the response and ticket.
2014-07-07 12:35:43 -04:00
Chaskiel Grundman
f3789f8cc5 Document logic in _krb5_is_anon_request
describe why we look at the different bits and fields
2014-07-06 14:37:49 -04:00
Chaskiel Grundman
c2e2de7384 When using PKINIT with DH, compute session key
RFC6112 provides a method of computing a session key when the PKINIT DH
is used, and mandates it for anonymous pkinit. The session key is computed
using KRB-FX-CF2 from the reply key and a random key chosen by the kdc.
The random key is provided to the client, which is supposed to verify
that the session key was computed this way.
2014-07-03 12:24:08 -04:00
Chaskiel Grundman
bf7f31ee09 Include empty PKINIT-KX padata
rfc6112 requires kdcs implementing anonymous PKINIT to include an
empty PKINIT-KX padata in PREAUTH_REQUIRED messages.
Including this improves compatibility with MIT kerberos.
2014-07-03 12:24:08 -04:00
Chaskiel Grundman
5f2a93f5ca Recognize anonymous AS requests using bit 14
Check KDC Option bit 14 in addition to 16 when identifying anonymous
AS-REQs. This provides compatibility with older heimdal releases.
2014-07-03 12:24:08 -04:00
Jelmer Vernooij
341f032cfd kdc.8: Remove references to kerberos 4. 2014-04-28 01:02:45 +02:00
Andrew Tridgell
6f0cafa6cf heimdal: handle referrals for 3 part DRSUAPI SPNs
This handles referrals for SPNs of the form
E3514235-4B06-11D1-AB04-00C04FC2DCD2/NTDSGUID/REALM, which are
used during DRS replication when we don't know the dnsHostName of the
target DC (which we don't know until the first replication from that
DC completes).

We use the 3rd part of the SPN directly as the realm name in the
referral.

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
2014-03-24 23:07:49 -05:00
Love Hörnquist Åstrand
4fb41b50cf use noinst_HEADERS for kdc-private.h 2014-02-16 09:16:18 -08:00
Nicolas Williams
2c265a8182 Add option to require initial kca_service tickets
Default to TRUE, and allow setting it on a per-realm basis.
2013-12-05 16:00:21 -06:00
Nicolas Williams
5807540e1b Fix kx509 to include realm 2013-12-05 16:00:21 -06:00
Jeffrey Altman
ad995f9b69 kx509: Prevent double free
Patchset 750a09bca2 introduced the
potential for a double free of 'name'.

Change-Id: I23bd4ddb7d9b41cbb3948ab06245f4052b309971
2013-12-04 14:21:56 -05:00
James Lee
750a09bca2 kx509: Create certs for principals with slashes
kx509 fails to create certs for principals with slashes in them.  For
example:

    client% kinit foo/admin
    foo/admin@EXAMPLE.COM's Password:
    client% kx509
    Timed out waiting on KCA

The KCA reports: "Principal is not a user."  However, there is a use
case set out in this post:

https://thestaticvoid.com/post/2012/10/25/protecting-puppet-with-kerberos/

that would create a kx509 cert for a host principal for authenticating
against a secure HTTP service.  This commit modifies the certificate
creation code to allow principals with slashes in them.
2013-12-04 13:49:38 -05:00
Nicolas Williams
b20bb509bd Fix never valid error condition in KDC
The TGS was incorrectly using authtime to compute renew_till for new
tickets, which was in turn leading to endtime potentially being equal to
starttime, which caused the TGS to return KRB5KDC_ERR_NEVER_VALID.

This happens when the TGT renewal lifetime is longer than the max renew
lifetime of any other services, after that much time (target services'
max renew life) passes.  The TGT is still good but TGS-REQs fail.
2013-11-26 16:57:19 -06:00
Nicolas Williams
9e084ca1d7 Fix MIT dump entry parsing bug that forced 2048 sz 2013-11-20 01:08:22 -06:00
Love Hornquist Astrand
1d84562886 add HDBGET: that only supports get, iteration doesnt really make sense for the HDB keytab except when dumping 2013-10-15 12:40:39 +02:00
Jeffrey Altman
3c3e2ad5e6 Windows: ktutil.exe requires libkadmsrv and libhdb
Include libkadmsrv.dll and libhdb.dll in the assembly which are
required for ktutil.exe to load.

Change-Id: Ic72d51e72daac71683a7f7000fe084197ee3c94a
2013-09-13 22:17:43 -04:00
Nicolas Williams
9aa7883ff2 Really bug in KDC handling of enterprise princs 2013-08-01 20:17:17 -05:00
Ragnar Sundblad
1bed48b75c tgs_make_reply: fix temp weak enctype exception
The default heimdal KDC chokes when trying to encrypt a ticket with a weak
server key that has a different type than the session key. The problem
happens in the krb5_crypto_init function called from the _kdc_encode_reply
function.

The existing work-around of the problem temporarily enabled the weak
enctype in case it was disabled but the principal was on the (hard-coded)
exception list.

Unfortunately the code used the keytype of the key encoded in the ticked
(the session key) instead of the keytype of the key used to encrypt the ticket
(the serverkey) thus enabling the incorrect encryption type if those two
are different, for instance des-cbc-md5 and des-cbc-crc.

Change-Id: Ia55dc344e3e5fc9ec1eb93c9e8ebb0a58c673d57
2013-07-30 14:16:20 -04:00
Jeffrey Altman
c4aa2f9067 _kdc_find_etype: prefer default salt for preauth
if the query is "preauth" and the caller is seeking a Key, search
try to find a Key that has the default salt but do not exclude keys
that have a non-default salt.

Move the assignment of 'ret' and 'enctype' before the preauth
default salt test.  If the only key of the given type is the non-default
salt key, it should be used.

If the caller is not seeking a Key, do not bother with the preauth
test at all since the Key itself doesn't matter and we are simply
seeking an enctype.

Change-Id: I7cd37c579c0bfdd88bccfbc9eb5e5f55cd1910cb
2013-07-30 14:16:19 -04:00