Commit Graph

14 Commits

Author SHA1 Message Date
Nicolas Williams
1976e012b8 Automatically upgrade iprop logs to add uber rec
We need the uber record all the time now, actually, except when merely
inspecting a log file.  This is important as we depend on replaying
entries written to the log in order to complete the HDB writes, and if
we don't have an uber record we can't do this step.

Also, log_init() should cleanup on error.
2016-02-26 19:10:14 -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
dfc7ec92fa Make kadm5_lock() and unlock work, and add kadmin commands for them.
The libkadm5 functions hdb_open() and close around all HDB ops.  This
meant the previous implementation of kadm5_lock() and unlock would
always result in a core dump.  Now we hdb_open() for write in
kadm5_lock() and hdb_close() in kadm5_unlock(), with all kadm5_s_*()
functions now not opening nor closing the HDB when the server context
keep_open flag is set.

Also, there's now kadmin(8) lock and unlock commands.  These are there
primarily as a way to test the kadm5_lock()/unlock() operations, but
MIT's kadmin.local also has lock/unlock commands, and these can be
useful for scripting (though they require much care).
2011-07-22 21:07:48 -05:00
Nicolas Williams
87742e8118 Add missing KADM5_AUTH_GET_KEYS error and use it. 2011-07-22 16:07:07 -05:00
Nicolas Williams
0d90e0c4d0 Complete --keepold support and fix crasher in kadmin cpw -r --keepold. 2011-07-22 16:07:06 -05:00
Nicolas Williams
26f9924bb3 Added stubs for the kadm5 policy functions. 2011-07-22 16:04:53 -05:00
Nicolas Williams
3d0019d3ce Added kadm5_setkey_principal*() and kadm5_decrypt_key(). 2011-07-22 16:04:52 -05:00
Love Hörnquist Åstrand
cdc1726021 (PASS_REUSE): Spelling, from Václav H?la <ax@natur.cuni.cz>
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16683 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-02-02 13:11:47 +00:00
Love Hörnquist Åstrand
8669df7f34 Make BAD_TL_TYPE error more helpful.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15885 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-08-11 13:31:42 +00:00
Assar Westerlund
98c7ce0bbf then -> that, from Thomas Klausner <wiz@netbsd.org>
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10800 ec53bebd-3082-4978-b11e-865c3cabbd6b
2001-12-06 17:02:55 +00:00
Johan Danielsson
fd08ae6a68 Swap error_table arguments.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@4418 ec53bebd-3082-4978-b11e-865c3cabbd6b
1998-02-16 16:37:17 +00:00
Johan Danielsson
e92035bdcf Add quotes.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@4415 ec53bebd-3082-4978-b11e-865c3cabbd6b
1998-02-16 16:29:30 +00:00
Johan Danielsson
21772f8038 Illegal -> invalid, cannot -> can't, and some other cleanup.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@3767 ec53bebd-3082-4978-b11e-865c3cabbd6b
1997-11-03 15:39:42 +00:00
Johan Danielsson
68d77a285f Beginning of a kadm5-library
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@3662 ec53bebd-3082-4978-b11e-865c3cabbd6b
1997-10-25 06:19:27 +00:00