Commit Graph

766 Commits

Author SHA1 Message Date
Luke Howard
e11abf414c hdb: support "hard" alias path in AS-REQ (#452)
Adds support for "hard" aliases when initially authenticating, that is,
allowing a client or server principal to be known by many names without
requiring that the client support name canonicalization.

In order to avoid changing the behavior for other backends such as Samba, this
is implemented in the HDB backend rather than the KDC.

To use, add an alias for both the client and TGS ("krbtgt") principals using
kadmin. This behavior is unchanged if name canonicalization is enabled.
2018-12-20 17:59:18 +11:00
Luke Howard
176fe6c06c hdb: fix uninitialized variable use in MIT bridge 2018-12-20 16:25:51 +11:00
Romain Fihue
b0e4fcd257 hdb-mitdb: Commit 57f1545a broke support of REQUIRES_PWCHANGE during MIT DB imports 2018-10-03 20:03:03 -04:00
Daria Phoebe Brashear
3bcc031939 hdb-mitdb: correct missing equals in initialization 2017-10-19 19:49:22 -04:00
Nicolas Williams
5bcbe2125b Add hdb_set_sync() method 2017-10-10 13:07:18 -05:00
Nicolas Williams
e3cc7dfb94 Set def page size for HDB SQLite3 backend to 8KB 2017-10-10 13:07:06 -05:00
Francisco Blas (klondike) Izquierdo Riera
d6979fcc40 Allow LDAP modifications for entry creation
Heimdal will refuse to create new entries when an entry already exists even
if said entry has no kerberos info and is a new entry.

This patch fixes this issue by allowing object modifications even if the
flags disallow them when we are inserting a new principal on the database.

Signed-off-by: Francisco Blas Izquierdo Riera (klondike) <klondike@gentoo.org>
2017-09-25 18:24:23 -05:00
Nicolas Williams
122cdc578e Fix some krb5_storage_write() usages 2017-05-26 23:24:30 -04:00
Jeffrey Altman
93518bfab4 use memset_s
lib roken includes support for memset_s() but it was not applied
to the Heimdal source tree.

Change-Id: I8362ec97a9be50205bb2d398e65b629b88ce1acd
2017-04-29 01:05:59 -04:00
Nicolas Williams
d8a112ae1a Fix lib/hdb make race 2017-03-17 13:20:06 -05:00
Jeffrey Altman
5360a6dee6 hdb: export hdb_generate_key_set_password_with_ks_tuple
Must export hdb_generate_key_set_password_with_ks_tuple() on Windows
which was introduced in 4303174a49.

Change-Id: Iea2993a17aba44c7cb0360716138c26239254e05
2017-02-16 13:14:50 -05:00
Roland C. Dowdeswell
4303174a49 Fix signature of hdb_generate_key_set_password()
The change to the signature of hdb_generate_key_set_password() in
Heimdal 7.1 broke API/ABI compatibility with previous releases.  We
fix this by renaming it hdb_generate_key_set_password_with_ks_tuple()
and creating a new hdb_generate_key_set_password() which calls our
new function with zeroes for the added arguments.

Issue #246      https://github.com/heimdal/heimdal/issues/246
2017-01-29 19:40:59 -05:00
Viktor Dukhovni
24206682d7 Move external libdeps after our own
If some external library lives in a directory in which Heimdal is
already installed, we may pick up LD_LIBRARY_PATH Heimdal objects
from a different release.  Move the external deps to the end, to
ensure a more appropriate LD_LIBRARY_PATH.
2016-12-19 19:39:22 -05:00
Nicolas Williams
f38089257b Misc fixes (coverity) 2016-11-20 17:43:51 -06:00
Jeffrey Altman
a33b6d6b78 hdb: more read_master_key leaks
Change-Id: Icf0bb8dc3cdcd2babb91b4180cec37737772373d
2016-11-19 08:18:39 -05:00
Jeffrey Altman
6f917463ff hdb: read_master_key use free_master_key on error
If an error occurs during read_masker_key() processing, use
free_master_key() to perform cleanup.

Change-Id: Idc0ad0131ea4855207232e9773772106cb4f5945
2016-11-19 07:25:40 -05:00
Jeffrey Altman
0dc3d21724 hdb: read_master_key add parens around (*mkey)
Add parens around the use of (*mkey)->next.

Change-Id: I3b60c2432d1c5dee8483795bed52ff24c7aa6a70
2016-11-19 01:26:08 -05:00
Jeffrey Altman
9e72c475ae hdb: need prototypes for hdb_ldap[i]_create
Commit 4b6bd40106 made hdb_ldap_create and
hdb_ldapi_create static in the OPENLDAP_MODULE case.  However, by
failing to leave a blank line between the static and the function
declaration the perl program that produces the hdb-protos.h file
skips the functions.

Add appropriate spacing.

Change-Id: I9ad24176fc31a0bce92b51f7adab141e8fa70fa3
2016-11-19 01:23:08 -05:00
Jeffrey Altman
e772511b78 hdb: read_master_keytab free memory on failure
read_master_keytab() should always return with *mkey == NULL on
failure.  Doing otherwise can result in memory leaks or use of
an uninitialized pointer.

Change-Id: Ice1fd504ca573d73bb51dd3b01770c3f8bc59fd4
2016-11-19 00:16:59 -05:00
Nicolas Williams
52a562a3a4 Misc fixes (coverity) 2016-11-18 22:21:45 -06:00
Nicolas Williams
4b6bd40106 Quiet warning in --enable-hdb-openldap-module case
Functions that are not exported in this case should be static in this
case.
2016-11-18 22:21:45 -06:00
Jeffrey Altman
97a40d8838 hdb: hdb_add_aliases frees uninitialized memory
This bug was never shipped in a release.  It was introduced by commit
1c81ddf4e2.

Change-Id: Ia9f6d69b2858a75cc51e50034fe70e29f13b8fc1
2016-11-18 20:58:39 -05:00
Nicolas Williams
7fa85e6d6d Round #3 of scan-build warnings cleanup 2016-11-16 23:27:27 -06:00
Nicolas Williams
1c81ddf4e2 Round #2 of scan-build warnings cleanup 2016-11-16 17:03:14 -06:00
Nicolas Williams
953dc07391 Round #1 of scan-build warnings cleanup 2016-11-15 21:27:20 -06:00
Nicolas Williams
995966f9d1 Fix hdb_create() HDB dbname parsing 2016-11-15 15:35:19 -06:00
Nicolas Williams
475c222472 Fix lib/hdb/test_hdbplugin 2016-11-15 13:54:45 -06:00
Nicolas Williams
09f0a25fda kdc --builtin-hdb should list loadable backends
This fixes the following problems from #210:

 - hdb_ldap doesn't load even when installed correctly
 - loadable hdb backends not listed by kdc --builtin-hdb

Not fixed:

 - hdb_ldap.so not installed in plugin dir
2016-11-15 11:34:54 -06:00
Jeffrey Altman
19e8852697 hdb: hdb_ldap_common NULL dereference
In hdb_ldap_common() the test

  if (search_base == NULL && search_base[0] == '\0')
     error handling ...

must be

  if (search_base == NULL || search_base[0] == '\0')
     error handling ...

Change-Id: I8d876a9c56833431b3c4b582fbb0a8cc7353893d
2016-11-14 16:33:51 -05:00
Jeffrey Altman
95c2940a02 hdb: LDAP_message2entry fix ntPasswordIN leak
free ntPasswordIN from all exit paths.  Do not leak it.

Change-Id: I90c5240439eefabca4458fe4791eb0de693a50f7
2016-11-14 16:25:36 -05:00
Viktor Dukhovni
e1c1cdb1b6 HDB compiler warnings 2016-11-14 02:22:51 -05:00
Viktor Dukhovni
cf69f3321d Fix cut/paste error from f5f76ee7 that breaks LDAP 2016-11-14 16:39:42 +11:00
Nicolas Williams
b83cf2f3bd Support db1 and db3 at the same time 2016-11-08 15:41:38 -06:00
Marcin Cieślak
033001e732 Prefer BDB3/4/5 to BDB1/2 2016-11-08 15:48:40 -05:00
Luke Howard
7b720cf61c krb5: implement draft-ietf-kitten-aes-cts-hmac-sha2-07 2016-10-08 08:17:11 +02:00
Roland C. Dowdeswell
82054b4b79 lib/hdb/hdb-mitdb.c: this was failing to build due to undefined variables. 2016-05-12 16:44:51 -04: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
Jeffrey Altman
278cd63306 lib/hdb: hdb_method functions !KRB5_LIB_CALL
The hdb_method functions cannot be KRB5_LIB_CALL as lib/hdb is not
lib/krb5.  KRB5_LIB_CALL will be inconsistently defined.

This inconsistency resulted in crashes of test_hdbplugin on 32-bit
Windows.

Change-Id: I4cf8d3ef76f31a3cae923df234a19610d956e7ee
2016-04-11 00:33:42 -05:00
Nicolas Williams
a114690bde Fix HDB two-phase commit for LDAP backend
We can't replay log entries when recovering if the backend is shared by
writers with separate logs (or no logs at all), i.e., on other hosts.
2016-02-29 22:12:51 -06:00
Nicolas Williams
2b5ddafab5 HDB sqlite backend: fix error NULL deref 2016-02-29 19:13:10 -06:00
Viktor Dukhovni
579393c8b9 Optionally prune old keys when setting new keys.
When new keys are added (typically via kadm5_setkey_principal_3),
truncate the key history to remove old keys, that is keys older than
the newest key which was in effect prior longer ago than the principal's
maximum ticket lifetime.  This feature is controlled via the "[kadmin]"
section's "prune-key-history" boolean parameter, which defaults to false.

Currently this happens only when kadm5_setkey_principal_3()
is called directly on the server, the client API simulates
kadm5_setkey_principal_3() via a get, update, modify sequence that does
not prune the key history.  The plan is to add a new kadm5 protocol RPC
and convert clients to call that instead.

In setkey_principal_3 seal keys after entry key update

Also, for now, don't check the return value of kadm5_log_modify() in
the new kadm5_s_setkey_principal_3().  This has to be addressed more
globally.

Censor stale keys in kadm5_s_get_principal
2016-02-26 15:43:12 -05:00
Nicolas Williams
047daa077a Windows: build lib/hdb/hdb-mdb.c (LMDB) 2016-02-26 12:08:30 -06:00
Nicolas Williams
50a45a946d Fix more HDB SQLite3 issues
Fix some issues reported by Jeffrey Hutzelman.
2016-02-26 01:04:32 -06:00
Nicolas Williams
5867aa6873 hdb-sqlite: fix error code confusion 2016-02-26 01:04:32 -06:00
Nicolas Williams
20df2c8706 Two-phase HDB commit via iprop log, + GC for log
We used to update the iprop log and HDB in different orders depending on
the kadm5 operation, which then led to various race conditions.

The iprop log now functions as a two-phase commit (with roll forward)
log for HDB changes.  The log is auto-truncated, keeping the latest
entries that fit in a configurable maximum number of bytes (defaults to
50MB).  See the log-max-size parameter description in krb5.conf(5).

The iprop log format and the protocol remain backwards-compatible with
earlier versions of Heimdal.  This is NOT a flag-day; there is NO need
to update all the slaves at once with the master, though it is advisable
in general.  Rolling upgrades and downgrades should work.

The sequence of updates is now (with HDB and log open and locked):

a) check that the HDB operation will succeed if attempted,
b) append to iprop log and fsync() it,
c) write to HDB (which should fsync()),
d) mark last log record committed (no fsync in this case).

Every kadm5 write operation recover transactions not yet confirmed as
committed, thus there can be at most one unconfirmed commit on a master
KDC.

Reads via kadm5_get_principal() also attempt to lock the log, and if
successful, recover unconfirmed transactions; readers must have write
access and must win any race to lock the iprop log.

The ipropd-master daemon also attempts to recover unconfirmed
transactions when idle.

The log now starts with a nop record whose payload records the offset of
the logical end of the log: the end of the last confirmed committed
transaction.  This is kown as the "uber record".  Its purpose is
two-fold: act as the confirmation of committed transactions, and provide
an O(1) method of finding the end of the log (i.e., without having to
traverse the entire log front to back).

Two-phase commit makes all kadm5 writes single-operation atomic
transactions (though some kadm5 operations, such as renames of
principals, and changes to principals' aliases, use multiple low-level
HDB write operations, but still all in one transaction).  One can still
hold a lock on the HDB across many operations (e.g., by using the lock
command in a kadmin -l or calling kadm5_lock()) in order to push
multiple transactions in sequence, but this sequence will not be atomic
if the process or host crashes in the middle.

As before, HDB writes which do not go through the kadm5 API are excluded
from all of this, but there should be no such writes.

Lastly, the iprop-log(1) command is enhanced as follows:

 - The dump, last-version, truncate, and replay sub-commands now have an
   option to not lock the log.  This is useful for inspecting a running
   system's log file, especially on slave KDCs.

 - The dump, last-version, truncate, and replay sub-commands now take an
   optional iprop log file positional argument, so that they may be used
   to inspect log files other than the running system's
   configured/default log file.

Extensive code review and some re-writing for clarity by Viktor Dukhovni.
2016-02-26 00:55:33 -06:00
Nicolas Williams
16275048b8 Prefer LMDB to Berkeley DB 2016-02-26 00:55:32 -06:00
Nicolas Williams
a94dc50114 Add --with-db-type-preference config param 2016-02-26 00:55:32 -06:00
Nicolas Williams
c6f24e99f0 Revamp cf/db.m4; test LMDB 2016-02-26 00:55:32 -06:00
Nicolas Williams
76c26281a7 Fix sqlite HDB backend SQLITE_BUSY bug 2016-02-26 00:55:32 -06:00
Nicolas Williams
fbc87e46fd Fix sqlite HDB backend init bug 2016-02-26 00:55:31 -06:00