Commit Graph

80 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
6cbe35ad5d kadm5: Fix crash in principal creation
This manifests with an upcomming patch that adds support for
aliasing of namespaces.
2021-10-30 15:21:54 -05:00
Nicolas Williams
0e09fa7fde iprop: Support hierarchical iprop 2020-09-18 14:31:43 -05: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
Viktor Dukhovni
d0211ef475 Refactor send_diffs making it progressive
When a slave is many diffs behind, send these in batches of up to
50, then handle other slaves.

This also implements a fast-path that makes incremental diffs faster
when the log has not rolled over.

Related code cleanup.
2019-10-03 15:52:15 -05:00
Jeffrey Altman
00c590e4ff fix null pointer dereference errors
Change-Id: I82a849afe9f432a1084ad2505ce88b1fe4d3d3af
2019-01-04 01:02:59 -05:00
Jeffrey Altman
db859520b4 lib/kadm5: use krb5_enomem() where possible
Change-Id: I487fbc640a8f793f0aa02ef4c94099e09241d616
2018-12-25 16:57:55 -06:00
Nicolas Williams
122cdc578e Fix some krb5_storage_write() usages 2017-05-26 23:24:30 -04:00
Nicolas Williams
953dc07391 Round #1 of scan-build warnings cleanup 2016-11-15 21:27:20 -06:00
Sergio Gelato
7c8b66d76b Use off_t in for constants used in iprop log seeks
On 32-bit architectures with _FILE_OFFSET_BITS=64,
 sizeof(off_t) > sizeof(size_t) .

LOG_HEADER_SZ was #define'd as an expression of type size_t, so in order
to get the sign extension right we need -(off_t)LOG_HEADER_SZ instead of
(off_t)(-LOG_HEADER_SZ).  However, we can just define the *_SZ macros to
cast to off_t, then we don't need to worry about negation.

Fixes Debian bug #822749, PR 175.

Signed-off-by (and updated by): Nicolas Williams <nico@twosigma.com>
2016-11-09 13:35:08 -06:00
Viktor Dukhovni
74f598e159 Set uber record nominal version when truncating
It needs to match the version of the last record saved and have a
reasonable timestamp.
2016-06-09 08:30:59 -04:00
Viktor Dukhovni
a5237e6940 Fix handling of uber record nominal version
When flushing the uber record, retain the current log version.  When the
uber record is the only (thus last) record in the log, return its nominal
version as the last version, not 0.  Upgrade the log if the current uber
record version number is not 0.
2016-06-09 07:04:01 -04:00
Viktor Dukhovni
ffd0dda237 Fix iprop against legacy master with full log
When the master's log has all entries from version 1 to now, and no
uber entry (legacy master), then new slaves will not pull version 1,
because their uber record has version 1.

The fix is to force the uber version to 0 always, and avoid adding a
truncate nop when doing a full prop.  The uber record now records the
database version even in the absence of any other log entries so that
we know what to pull going forward.
2016-06-09 01:03:10 -04: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
d5bc673e31 Fix HDB two-phase commit for /dev/null log 2016-02-29 19:13:14 -06:00
Nicolas Williams
1236238cde kadm5/log.c: missing error checking 2016-02-29 19:13:11 -06:00
Nicolas Williams
6cc69e0b1f Shut up VC 2016-02-29 19:13:10 -06:00
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
ebc1ad34ba ipropd-master/slave: enhancements and bug fixes
- fix int/uint confusion and use unsigned integral types for time
 - improve messages
 - add --verbose option
 - attempt transaction recovery in ipropd-master during idle times
 - begin hardening daemons against dying at the slightest provocation
 - better recovery from various errors
 - daemons now restart automatically in most of the many error cases
   where the daemons still die
2016-02-26 00:59:04 -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
2d238b9d15 Backwards interop for older iprop peers
Don't abort() when seeing as-yet-unimplemented things we know about.

Patch from Harald Barth <haba@kth.se>.
2013-08-12 11:40:23 -05:00
Roland C. Dowdeswell
f9f78a2cbf kadm5_log_reinit() needs to obtain its lock before truncating the file.
We can't use O_TRUNC on open because (without O_EXLOCK which is
not portable) we would be modifying the file without an exclusive
lock.  So, we drop the use of O_TRUNC and use ftruncate(2) after
obtaining the lock via flock(2).
2012-05-31 17:30:29 +01:00
Nicolas Williams
ef9012aef5 Fix ipropd-slave assert when doing del_enctype
Change a paranoid heim_assert into something better.  Update block
    comment.

    Next commit: add a test for del_enctype and iprop.
2012-03-15 18:57:32 -05: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
a7717ae4f9 Use heim_assert() instead of assert() 2011-07-24 11:10:37 -05:00
Nicolas Williams
909653e50f Add comment and assert about key history to kadm5_log_replay_modify() 2011-07-22 16:07:07 -05:00
Nicolas Williams
7e0a801e28 Changed decrypt key history logic and added HDB_F_ALL_KVNOS. 2011-07-22 16:05:21 -05:00
Love Hornquist Astrand
f5f9014c90 Warning fixes from Christos Zoulas
- shadowed variables
- signed/unsigned confusion
- const lossage
- incomplete structure initializations
- unused code
2011-04-29 20:25:05 -07:00
Love Hornquist Astrand
9427bcc22e log more version numbers 2011-01-03 12:12:18 +01:00
Love Hornquist Astrand
965836509b switch to hdb_fetch_kvno 2010-11-28 11:43:02 -08:00
Asanka Herath
d84119813e No AF_UNIX on Windows and no SIGPIPE and SIGXCPU 2009-11-24 10:12:44 -08: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
Love Hörnquist Åstrand
a8a2e8140b catch failure
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25203 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-05-09 14:21:29 +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
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
5fed824f37 its vs it\'s etc. From Bjorn Sandell
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22071 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-11-14 20:04:50 +00:00
Love Hörnquist Åstrand
fb492fba05 Unexport the specific log replay operations.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21908 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-08-16 10:14:16 +00:00
Love Hörnquist Åstrand
5670ef2f52 Sprinkle krb5_set_error_string().
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21834 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-08-07 18:55:46 +00:00
Love Hörnquist Åstrand
61f73a98ff (kadm5_log_foreach): check that the postamble contains the right data.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21807 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-08-03 13:44:40 +00:00
Love Hörnquist Åstrand
a883bbfd49 only free the orignal entries extentions if there was any.
Bug reported byg Peter Meinecke.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21764 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-07-31 22:35:08 +00:00
Love Hörnquist Åstrand
0382061b7b add configuration for signal file and acl file, let user select hostname, catch signals and print why we are quiting, make nop cause one new version, not two
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21756 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-07-31 22:15:08 +00:00
Love Hörnquist Åstrand
8d40c2994b check return value of alloc functions, from Charles Longeau
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21745 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-07-31 16:11:25 +00:00
Love Hörnquist Åstrand
871b9cab4a make it slightly more working.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20600 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-05-08 03:01:25 +00:00
Love Hörnquist Åstrand
0018da82f1 (kadm5_log_previous): document assumptions and make less broken.
Bug report from Ronny Blomme.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20584 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-05-08 00:40:47 +00:00
Love Hörnquist Åstrand
cb704efeeb Rename u_intXX_t to uintXX_t
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17445 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-05-05 10:37:46 +00:00
Love Hörnquist Åstrand
eea5f34855 Pass in HDB_F_GET_ANY to all ->hdb fetch to hint what entries we are looking for
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17313 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-04-27 11:18:52 +00:00
Love Hörnquist Åstrand
5f22b44baa Break out the that we request from principal from the entry and pass
it in as a separate argument.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17310 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-04-27 11:09:30 +00:00