Commit Graph

81 Commits

Author SHA1 Message Date
Nicolas Williams
5bcbe2125b Add hdb_set_sync() method 2017-10-10 13:07:18 -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
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
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
Love Hornquist Astrand
1eb4e2516e unify hdb_so_method and hdb_method 2013-03-04 10:18:16 -08:00
Tollef Fog Heen
4787ea76a9 Update hdb's use of the plugin interface
The various _krb5_plugin_* functions are gone, replace this with the new world order.

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2013-03-04 10:00:41 -08:00
Roland C. Dowdeswell
7de08cd5d0 hdb.h uses FILE * and so should #include <stdio.h>. 2012-06-27 01:58:19 +01:00
Nicolas Williams
57f1545a46 Add support for writing to KDB and dumping HDB to MIT KDB dump format
Before this change Heimdal could read KDBs.  Now it can write to
    them too.

    Heimdal can now also dump HDBs (including KDBs) in MIT format, which
    can then be imported with kdb5_util load.

    This is intended to help in migrations from MIT to Heimdal by
    allowing migrations from Heimdal to MIT so that it is possible
    to rollback from Heimdal to MIT should there be any issues.  The
    idea is to allow a) running Heimdal kdc/kadmind with a KDB, or
    b) running Heimdal with an HDB converted from a KDB and then
    rollback by dumping the HDB and loading a KDB.

    Note that not all TL data types are supported, only two: last
    password change and modify-by.  This is the minimum necessary.
    PKINIT users may need to add support for KRB5_TL_USER_CERTIFICATE,
    and for databases with K/M history we may need to add KRB5_TL_MKVNO
    support.

    Support for additional TL data types can be added in
    lib/hdb/hdb-mitdb.c:_hdb_mdb_value2entry() and
    lib/hdb/print.c:entry2mit_string_int().
2012-05-03 14:24:18 -05:00
Stefan Metzmacher
272d7511ca lib/hdb: add HDB_F_FOR_AS_REQ and HDB_F_FOR_TGS_REQ flags
This will be used to indicate to the backend if a fetch is for
an AS REQ or TGS REQ. Samba needs to take some action in the
HDB_F_FOR_TGS_REQ case and always canonicalize the principal
names, even without HDB_F_CANON.

metze

Signed-off-by: Love Hörnquist Åstrand <lha@h5l.org>
2011-07-30 11:56:46 -07:00
Nicolas Williams
308e53a4a8 Initial support for filtering out "dead" historical keys. 2011-07-22 16:05:21 -05:00
Nicolas Williams
7e0a801e28 Changed decrypt key history logic and added HDB_F_ALL_KVNOS. 2011-07-22 16:05:21 -05:00
Nicolas Williams
58d72035f1 Added kadm5_lock() and unlock. 2011-07-22 16:04:52 -05:00
Nicolas Williams
fca53990e4 Initial commit for second approach for multiple kvno. NOT TESTED! 2011-07-22 16:04:51 -05:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Jelmer Vernooij
1ad64fe599 hdb.h: Include krb5.h first, so hdb.h can be included standalone.
This makes it a bit easier to find libhdb in e.g. configure tests and
is consistent with the main header files for the other Heimdal
libraries, none of which has any prerequisite other headers.

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2011-01-03 11:51:09 +01:00
Love Hornquist Astrand
6c6726d76c drop hdb_fetch 2010-11-28 11:46:46 -08:00
Love Hornquist Astrand
8ece8672ae kvno is krb5_kvno not unsigned 2010-11-28 11:19:15 -08:00
Andrew Bartlett
f469fc6d49 heimdal Add support for extracting a particular KVNO from the database
This should allow master key rollover.

(but the real reason is to allow multiple krbtgt accounts, as used by
Active Directory to implement RODC support)

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2010-11-28 09:52:54 -08:00
Love Hornquist Astrand
37fcf33d7c document hdb_entry_ex 2010-11-18 23:40:09 -08:00
Love Hornquist Astrand
c71d2bf0d3 spelling, From Kaiting Chen <kaitocracy@gmail.com> 2010-11-18 23:25:18 -08:00
Andrew Bartlett
0e128912af s4:heimdal Add hooks to check with the DB before we allow s4u2self
This allows us to resolve multiple forms of a name, allowing for
example machine$@REALM to get an S4U2Self ticket for
host/machine@REALM.

Andrew Bartlett

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2010-09-26 15:11:05 -07:00
Karolin Seeger
260e19ac09 s4-heimdal: Fix typo in comment.
Karolin

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2010-09-26 15:06:58 -07:00
Love Hornquist Astrand
83e2a17c0f document more assumptions about hdb_rename 2010-03-21 14:56:57 -07:00
Love Hornquist Astrand
70835f3119 add hdb_get_realms 2009-11-22 06:34:29 -08:00
Love Hornquist Astrand
39a751d6fb expose hdb_interface_version 2009-10-13 09:35:39 -07:00
Love Hornquist Astrand
ff87429593 Make LDAP code fetch less attributes from LDAP server when KDC is asking
Johan Gadsjö did a awesome analysis of the LDAP access pattens
and sent us a patch that reduced the calls the ldap server by 4
times as many. The patch was adopted and change to avoid compile
time depencies and make the determination runtime instead. Thanks!
2009-10-03 13:20:41 -07:00
Andrew Bartlett
f8c121b282 Add support for user principal names in certificates [HEIMDAL-602]
This extends the PKINIT code in Heimdal to ask the HDB layer if the
User Principal Name name in the certificate is an alias (perhaps just
by case change) of the name given in the AS-REQ.  (This was a TODO in
the Heimdal KDC)

The testsuite is extended to test this behaviour, and the other PKINIT
certficate (using the standard method to specify a principal name in a
certificate) is updated to use a Administrator (not administrator).
(This fixes the kinit test).
2009-08-04 09:34:58 +02:00
Love Hörnquist Åstrand
45ef83f6fd add hdb_check_constrained_delegation
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25302 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-07-03 04:26:25 +00:00
Love Hörnquist Åstrand
5c104ef172 add ->hdb_password and ->hdb_auth_status
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25298 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-07-03 04:25:29 +00:00
Love Hörnquist Åstrand
a28a9a1b30 comment about hdb_capability_flags
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25296 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-07-03 04:24:48 +00:00
Love Hörnquist Åstrand
ba04bad361 From Andrew Bartlet via heimdal-bugs@h5l.org
s4:heimdal Allow KRB5_NT_ENTERPRISE names in all DB lookups

    The previous code only allowed an KRB5_NT_ENTERPRISE name (an e-mail
    list user principal name) in an AS-REQ.  Evidence from the wild
    (Win2k8 reportadely) indicates that this is instead valid for all
    types of requests.

    While this is now handled in heimdal/kdc/misc.c, a flag is now defined
    in Heimdal's hdb so that we can take over this handling in future (once we start
    using a system Heimdal, and if we find out there is more to be done
    here).

    Andrew

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25293 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-07-03 03:16:35 +00:00
Love Hörnquist Åstrand
e6b3f6f796 document hdb__ functions.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25083 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-04-03 17:45:01 +00:00
Love Hörnquist Åstrand
6fac16450a doxygen
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25081 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-04-03 17:22:10 +00:00
Love Hörnquist Åstrand
f90c2b8194 don't use hdb_dbc.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24974 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-03-28 17:08:21 +00:00
Love Hörnquist Åstrand
7cbcadcb21 document
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24973 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-03-28 17:08:10 +00:00
Love Hörnquist Åstrand
037366a584 document part of hdb.h
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24972 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-03-28 17:07:58 +00:00
Love Hörnquist Åstrand
1dd8ec4fe7 Provide a more standard way to produce hdb plugins. From Andrew Bartlett
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24030 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-11-12 04:19:00 +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
8d8507fbf8 move static path into local headers that are not installed to prepare for configure-time relocations. Prompted by Hai Zaars FHS thread on heimdal-discuss
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22198 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-12-07 13:09:25 +00:00
Love Hörnquist Åstrand
2af7094535 Forward declaration for struct hdb_dbinfo;
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20535 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-04-23 07:49:16 +00:00
Love Hörnquist Åstrand
f8217f8b04 Add HDB_F_CANON.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20241 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-02-17 00:02:38 +00:00
Love Hörnquist Åstrand
0db21e2b07 Bump hdb interface version to 4.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17328 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-04-28 07:37:11 +00:00
Love Hörnquist Åstrand
47d79a7568 Break out the that we request from principal from the entry and pass
it in as a seprate argument. Add more flags to ->hdb_get(). Re-indent.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17305 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-04-27 10:59:32 +00:00
Love Hörnquist Åstrand
0c2369acd0 Wrap hdb_entry with hdb_entry_ex, patch originally from Andrew Bartlet
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16378 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-12-12 12:40:12 +00:00
Love Hörnquist Åstrand
475b015e3c Update (c).
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15877 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-08-11 13:16:44 +00:00
Love Hörnquist Åstrand
848bf1b529 Update interface version (and indent).
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15876 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-08-11 13:16:29 +00:00
Love Hörnquist Åstrand
0540f13b86 prefix all struct HDB elements with hdb_
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12880 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-09-19 00:25:35 +00:00
Love Hörnquist Åstrand
c12e22c5ee add struct hdb_so_method and HDB_INTERFACE_VERSION
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12410 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-06-29 12:08:34 +00:00