Commit Graph

34 Commits

Author SHA1 Message Date
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
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
Jeffrey Altman
dba026b5ef Introduce and apply krb5_storage_from_socket
On Windows a file descriptor is an int value allocated by the
local module instance of the C Run Time Library.  A socket handle is a
SOCKET value allocated by a Winsock Provider for the requested family and
protocol.   These two values cannot be mixed and there is no mechanism for
converting between the two.   The _get_osfhandle() and _open_osfhandle()
functions can work with a standard HANDLE (file, pipe, etc) but cannot be
used for a SOCKET.

The Heimdal krb5_storage_from_fd() routine counted on the osf conversion
functions working on SOCKET values.  Since they do not any attempt to call
krb5_storage_from_fd() on a socket resulted in an assertion being thrown
by the C RTL.

Another problem is SOCKET value truncation when storing a 64-bit value
into a 32-bit int.

To address these problems a new krb5_storage_from_socket() routine is
introduced.  This routine setups a krb5_storage that stores a socket value
as a rk_socket_t and provides a set of helper routines that always use
network ready functions.

The krb5_storage_from_fd() routines no longer use net_read() and
net_write() but provide helpers that follow their logic so that pipes can
be processed.

All call sites that allocate a socket now store the socket as rk_socket_t
and call krb5_storage_from_socket().

All locations that previously called the bare close() on a socket value
now call rk_closesocket().

Change-Id: I045f775b2a5dbf5cf803751409490bc27fffe597
2014-02-04 23:20:08 -05:00
Roland C. Dowdeswell
932c4c1859 We use a struct defined in sys/un.h. 2012-02-25 17:19:44 +00:00
Roland C. Dowdeswell
12b24ad876 Add a server side implementation of kadm5_create_principal_3(). 2012-02-24 18:56:30 +00:00
Roland C. Dowdeswell
af011f57fc Provide server side kadm5_chpass_principal_3() with ks_tuple implementation.
We enable kadm5_chpass_principal_3() in the server side of the
library.  The client kadm5 library calls will still return the
error KAMD5_KS_TUPLE_NO_SUPP.

Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2011-11-29 14:47:37 -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
0d90e0c4d0 Complete --keepold support and fix crasher in kadmin cpw -r --keepold. 2011-07-22 16:07:06 -05:00
Nicolas Williams
e16360e2db Add --keepold option to cpw. 2011-07-22 16:07:05 -05:00
Nicolas Williams
58d72035f1 Added kadm5_lock() and unlock. 2011-07-22 16:04:52 -05:00
Nicolas Williams
6e04b05e9d Initial support for kadm5_randkey_principal_3(), needed by krb5_admin.
NOT TESTED YET.
2011-07-22 16:04:52 -05:00
Love Hornquist Astrand
f1c0c1bba3 prefix SOCKET symbols with rk_ 2009-11-25 05:29:18 +01:00
Asanka Herath
d84119813e No AF_UNIX on Windows and no SIGPIPE and SIGXCPU 2009-11-24 10:12:44 -08: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
284d45bbbc use hdb_db_dir() and hdb_default_db()
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22211 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-12-07 19:27:27 +00:00
Love Hörnquist Åstrand
5118c90498 Rename u_intXX_t to uintXX_t
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17450 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-05-05 11:11:43 +00:00
Love Hörnquist Åstrand
ee050659b1 Constify password
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16044 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-09-08 11:30:53 +00:00
Love Hörnquist Åstrand
0b7181dd58 add kadm5_ad_context
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13872 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-05-26 16:55:25 +00:00
Johan Danielsson
23edf06a5b rename header file flag macro
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11113 ec53bebd-3082-4978-b11e-865c3cabbd6b
2002-08-16 20:57:44 +00:00
Johan Danielsson
53d1dfb3a1 add more fields to client context; remove prototypes
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8654 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-07-11 15:58:57 +00:00
Assar Westerlund
b003cf8c08 (_kadm5_acl_check_permission): update prototype
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8351 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-06-07 11:13:06 +00:00
Assar Westerlund
22da605365 (kadm_ops): add kadm_nop
more prototypes


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8319 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-06-05 17:05:34 +00:00
Assar Westerlund
6e30943f99 (struct kadm_func): add chpass_principal_with_key
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8063 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-03-23 23:05:49 +00:00
Assar Westerlund
4b0b470708 (_kadm5_set_keys_randomly): add prototype
(kadm5_log_foreach): update prototype


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7513 ec53bebd-3082-4978-b11e-865c3cabbd6b
1999-12-04 23:09:34 +00:00
Johan Danielsson
a64011fae7 prototype
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7480 ec53bebd-3082-4978-b11e-865c3cabbd6b
1999-12-03 13:00:52 +00:00
Johan Danielsson
c5b916ca6f remove advertising clause
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7464 ec53bebd-3082-4978-b11e-865c3cabbd6b
1999-12-02 17:05:13 +00:00
Johan Danielsson
e7b9616810 (kadm5_server_context): add config_params struct and remove acl_file;
bump protocol version number


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7330 ec53bebd-3082-4978-b11e-865c3cabbd6b
1999-11-09 17:57:03 +00:00
Assar Westerlund
1e21aad9f0 (_kadm5_client_recv): update prototype
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6957 ec53bebd-3082-4978-b11e-865c3cabbd6b
1999-09-13 02:56:53 +00:00
Assar Westerlund
98e06393a7 (_kadm5_setup_entry): change prototype
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6132 ec53bebd-3082-4978-b11e-865c3cabbd6b
1999-05-04 18:44:30 +00:00
Johan Danielsson
8e1f2aba53 proto
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6099 ec53bebd-3082-4978-b11e-865c3cabbd6b
1999-05-03 17:11:11 +00:00
Johan Danielsson
a6b3246ddd move stuff from kadm5_locl.h
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6071 ec53bebd-3082-4978-b11e-865c3cabbd6b
1999-05-03 16:32:03 +00:00
Johan Danielsson
7f969a9fdd Move _kadm5_{privs,string{_to_{string,privs} from kadm5_locl.h.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@4515 ec53bebd-3082-4978-b11e-865c3cabbd6b
1998-03-01 05:10:24 +00:00
Johan Danielsson
569d00f1b8 Private functions.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@4024 ec53bebd-3082-4978-b11e-865c3cabbd6b
1997-11-16 10:51:37 +00:00