Commit Graph

49 Commits

Author SHA1 Message Date
Luke Howard
0e8c4ccc6e hdb: eliminate hdb_entry_ex
Remove hdb_entry_ex and revert to the original design of hdb_entry (except with
an additional context member in hdb_entry which is managed by the free_entry
method in HDB).
2022-01-15 18:54:57 +11:00
Luke Howard
c5551775e2 hdb: decorate HDB_entry with context member
Decorate HDB_entry with context and move free_entry callback into HDB structure
itself. Requires updating hdb_free_entry() signature to include HDB parameter.
A follow-up commit will consolidate hdb_entry_ex (which has a single hdb_entry
member) into hdb_entry.
2022-01-15 18:54:57 +11:00
Nicolas Williams
5447b81fb1 hdb: Move virtual principals into HDB layer
This is a large commit that adds several features:

 - Revamps and moves virtual host-based service principal functionality
   from kdc/ to lib/hdb/ so that it may be automatically visible to
   lib/kadm5/, as well as kadmin(1)/kadmind(8) and ktutil(1).

   The changes are backwards-incompatible.

 - Completes support for documenting a service principal's supported
   enctypes in its HDB entry independently of its long-term keys.  This
   will reduce HDB bloat by not requiring that service principals have
   more long-term keys than they need just to document the service's
   supported enctypes.

 - Adds support for storing krb5.conf content in principals' HDB
   entries.  This may eventually be used for causing Heimdal KDC
   services to reconfigure primary/secondary roles automatically by
   discovering the configured primary in an HDB entry for the realm.

   For now this will be used to help reduce the amount of configuration
   needed by clients of an upcoming HTTP binding of the kadmin service.
2020-09-08 00:25:36 -05:00
Nicolas Williams
5bcbe2125b Add hdb_set_sync() method 2017-10-10 13:07:18 -05:00
Nicolas Williams
953dc07391 Round #1 of scan-build warnings cleanup 2016-11-15 21:27:20 -06:00
Nicolas Williams
b83cf2f3bd Support db1 and db3 at the same time 2016-11-08 15:41:38 -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
c6f24e99f0 Revamp cf/db.m4; test LMDB 2016-02-26 00:55:32 -06:00
Nicolas Williams
ccb148eedb lib/hdb/db3.c:DB_open() needs to DB_close() more
Without this the KDC can trip the assert in DB_open().
2013-09-12 12:14:39 -05:00
Love Hornquist Astrand
82d71b063b support db6 too, based on patch from Lars Wendler <wendler@fasihi.net> 2013-07-18 14:58:54 +02:00
Viktor Dukhovni
1614c49354 DB_CURSOR_BULK requires DB 4.8 or later 2012-05-29 18:56:44 +01:00
Roland C. Dowdeswell
2a27d50fa1 Formatting: unnecessary lines and trailing whitespace. 2012-05-22 23:08:18 +01:00
Viktor Dukhovni
e41ff9c0f5 Open cursor for bulk retrieval 2012-05-22 22:33:25 +01:00
Roland C. Dowdeswell
fde1d8cb72 Fix locking issues in DB3 HDB backend.
Multiple concurrent writers would cause the HDB to become corrupted
as the locking was not sufficient to prevent these sorts of issues
from occurring.  We fix this in a similar way to the prior DB1 patch.
2012-05-18 13:03:23 +01:00
Roland C. Dowdeswell
cc47c8fa7b Turn on -Wextra -Wno-sign-compare -Wno-unused-paramter and fix issues.
We turn on a few extra warnings and fix the fallout that occurs
when building with --enable-developer.  Note that we get different
warnings on different machines and so this will be a work in
progress.  So far, we have built on NetBSD/amd64 5.99.64 (which
uses gcc 4.5.3) and Ubuntu 10.04.3 LTS (which uses gcc 4.4.3).

Notably, we fixed

	1.  a lot of missing structure initialisers,

	2.  unchecked return values for functions that glibc
	    marks as __attribute__((warn-unused-result)),

	3.  made minor modifications to slc and asn1_compile
	    which can generate code which generates warnings,
	    and

	4.  a few stragglers here and there.

We turned off the extended warnings for many programs in appl/ as
they are nearing the end of their useful lifetime, e.g.  rsh, rcp,
popper, ftp and telnet.

Interestingly, glibc's strncmp() macro needed to be worked around
whereas the function calls did not.

We have not yet tried this on 32 bit platforms, so there will be
a few more warnings when we do.
2012-02-20 19:45:41 +00:00
Nicolas Williams
95262936c7 s/assert/heim_assert/ and remove dead code 2011-07-24 11:07:27 -05:00
Nicolas Williams
abd94953e2 Fixes to lock nesting code. 2011-07-22 16:04:52 -05:00
Nicolas Williams
58d72035f1 Added kadm5_lock() and unlock. 2011-07-22 16:04:52 -05:00
Love Hornquist Astrand
6c6726d76c drop hdb_fetch 2010-11-28 11:46:46 -08:00
Love Hornquist Astrand
ee8c2e45b4 use _hdb_fetch_kvno 2010-11-28 11:20:31 -08:00
Love Hornquist Astrand
f225af82c1 if db_create() returns non zero, fail 2010-10-06 21:37:50 -07:00
Eray Aslan
a1c14b2319 Add --with-berkeley-db-include option
Adds --with-berkeley-db-include=dir option to configure to use berkeley
db headers in dir.  Default is to let configure check.  Also adds
support for checking for and using db5/db.h

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2010-09-05 18:41:30 -07:00
Love Hörnquist Åstrand
5a9dd54e95 drop RCSID
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25319 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-07-05 05:09:16 +00:00
Love Hörnquist Åstrand
ef92d8485a Push enterprise support into the bdblayer.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25317 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-07-05 05:08:48 +00:00
Love Hörnquist Åstrand
4beac004a1 set hdb_capability_flags = 0
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25310 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-07-05 05:07:30 +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
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
cf0784bee6 avoid type-punned pointer warning.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21610 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-07-17 07:10:45 +00:00
Love Hörnquist Åstrand
44ab849d59 Wrap function call pointer calls in (*func) to avoid macros rewriting
open and close.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18551 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-10-18 07:28:32 +00:00
Love Hörnquist Åstrand
91026474ad memset hdb_entry_ex before use
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16395 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-12-13 11:54:10 +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
0fa794702c (hdb_db_create): use calloc to callocate memory
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16304 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-11-28 23:33:24 +00:00
Love Hörnquist Åstrand
8443e8221a (DB_open): catch errors from the d->open calls instead of letting them
slip though to d->cursor. Bug repport from Andrew Bartlett <abartlet@samba.org>


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15853 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-08-09 09:28:39 +00:00
Love Hörnquist Åstrand
d6560fb1ed (DB_open): in case of error, close database
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15510 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-06-23 13:41:08 +00:00
Love Hörnquist Åstrand
0e11d3a6ee (DB_open): correct the check for O_RDONLY
From: Chaskiel M Grundman <cg2v@andrew.cmu.edu>


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14578 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-02-15 17:45:38 +00:00
Love Hörnquist Åstrand
483b0b78c3 fix all db >= 4.1 cases
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13398 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-02-22 12:48:39 +00:00
Love Hörnquist Åstrand
7ec533b6db improve readability of ->open ifdef, check if version >= 4.1
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12882 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-09-19 02:38:02 +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
c0d1c74757 try to include more db headers
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12699 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-08-29 16:53:37 +00:00
Love Hörnquist Åstrand
32276ee7b7 patch for working with DB4 on heimdal-discuss
From: Luke Howard <lukeh@PADL.COM>


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12697 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-08-29 16:37:25 +00:00
Assar Westerlund
334c7ffa33 merge of DB-NEW
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10453 ec53bebd-3082-4978-b11e-865c3cabbd6b
2001-08-09 08:41:49 +00:00
Assar Westerlund
c7562eda65 add some more error strings
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10338 ec53bebd-3082-4978-b11e-865c3cabbd6b
2001-07-13 06:30:42 +00:00
Assar Westerlund
c7c19f07f3 adapt to new hdb_seal_keys and hdb_unseal_keys
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9595 ec53bebd-3082-4978-b11e-865c3cabbd6b
2001-01-30 01:24:29 +00:00
Assar Westerlund
29e5e9d37e always create a cursor with db3. From Derrick J Brashear
<shadow@dementia.org>


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8828 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-07-26 10:27:42 +00:00
Assar Westerlund
0aa12ef99f only use a cursor when needed, from Derrick J Brashear
<shadow@dementia.org>


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8563 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-07-06 21:40:29 +00:00
Johan Danielsson
bb90aecaee pass context to seal/unseal_keys
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8551 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-07-05 13:17:32 +00:00
Assar Westerlund
9ba818277f bump copyright
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8313 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-06-05 01:09:45 +00:00
Assar Westerlund
f498ac3c40 add berkeley db3 interface. contributed by Derrick J Brashear <shadow@dementia.org>
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8312 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-06-05 01:08:47 +00:00