Commit Graph

96 Commits

Author SHA1 Message Date
Nicolas Williams
316e0d2184 Store the canonical client princ in ipropd-slave
Otherwise we risk storing a name with the referral (empty) realm name,
which will then cause various knock-on effects, such as thinking that
the start_realm is "", and failing to find matching credentials in the
ccache.
2016-06-09 01:13:15 -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
2734102cc7 slave: quieten static analyzer false positives 2016-02-29 19:13:11 -06:00
Nicolas Williams
2415a5ee1d ipropd-slave: missing error check 2016-02-29 19:13:11 -06:00
Viktor Dukhovni
8fe294d0d7 Add SO_KEEPALIVE to iprop clients (slaves) 2016-02-26 15:43:13 -05:00
Nicolas Williams
f261ed4f58 Fix ipropd_slave: no EDQUOT on WIN32 2016-02-26 11:42:01 -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
05a919b94b iprop slave: try incremental after complete xfer
The following sequence of events results in slave B having a stale HDB:

 - slave A connects to master, master dumps HDB for the slave
 - kadm5 operations
 - slave B connects to master, master sends previously dumped HDB

slave B won't discover any updates until the next transaction.

The fix is simple: the slave should immediately call ihave() after
receiving a complete HDB.
2015-05-20 10:07:52 -05:00
Nicolas Williams
4158ddbc25 Fix HDB rename/close order in iprop slave 2015-05-20 10:07:52 -05:00
Nicolas Williams
b48bed5f42 Daemons detach atomically to avoid having to wait
Tests that start daemons have to "wait" for them to start.

This commit makes Heimdal daemons prep to detach (when requested) by
forking early, then having the child signal readiness to the parent when
the child really is ready.  The parent exits only which the child is
ready.  This means that tests will no longer need to wait for daemons.

However, tests will still need a pidfile or such so they can stop the
daemons.

Note that the --detach options should not be used on OS X from launchd,
only from tests.
2015-03-24 11:49:59 -05: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
Viktor Dukhovni
72f0690694 Temporary fix for high-priority iprop issues
Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2013-04-24 16:29:34 -07:00
Love Hornquist Astrand
65107e39ee fixup error messages 2012-10-01 09:54:13 -07:00
Roland C. Dowdeswell
8dc7c43a8b ipropd_slave.c: init data to zero or we free a random ptr. 2012-05-28 12:43:29 +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
Love Hörnquist Åstrand
a802c4799d Log client status changes 2012-02-15 21:05:05 -08:00
Love Hörnquist Åstrand
bf37778dbd make ipropd_slave tell its status in a status file
The ipropd_slave will log its status to /var/heimdal/ipropd-slave-status
if its connecting, up to date, or disconnected.

The master will now also confirm to slaves that are are in fact up to date
if they just restart, before there was no confirmation, the slave just didn't
get any deltas.
2012-02-15 20:59:54 -08:00
Nicolas Williams
40a7d4b62f More fixes for -Werror (GCC 4.6 catches more stuff) 2011-11-02 23:20:55 -05:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07: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
3b2e927c79 catch error from asprintf() 2011-04-23 18:57:57 -07:00
Asanka C. Herath
880d728e02 Un-const as necessary to silence compiler warnings 2010-11-24 15:33:07 -05:00
Asanka Herath
c6b8fad5dc Consistency updates for lib/kadm5 and don't check fd_set size if it's not necessary 2009-11-24 10:18:20 -08: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
11b955ea01 plug memory leak
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25093 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-04-04 17:10:52 +00:00
Love Hörnquist Åstrand
62ae550ab2 don't leak memory
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25087 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-04-04 17:09:39 +00:00
Love Hörnquist Åstrand
32218cc132 use krb5_cc_new_unique, use constants for cache types
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25057 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-04-03 04:07:07 +00:00
Love Hörnquist Åstrand
eb0549ea43 make vno set to a valid, so that in case master disconnects before it sent us any entries, don't print stack value.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24863 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-27 03:31:50 +00:00
Love Hörnquist Åstrand
3935b4ed34 wrap detach
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24410 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-01-25 00:39:36 +00:00
Love Hörnquist Åstrand
efccbcdeff init optidx
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24059 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-12-11 04:50:48 +00:00
Love Hörnquist Åstrand
49e70a4c41 Make slave more resiliant to master that go down, make them retry now and then.
The client tries connect every "[libdefault] reconnect-min" seconds,
and for every time it failes, it backs down "[libdefault]
reconnect-backoff" seconds until it reaches "[libdefault]
reconnect-max". On successful connect, the start value is reset to [libdefault] reconnect-min.

There are default values that make sense.

This patch was created by Buck Huppmann 2003, and been nursed along by
Alf Wachsmann until I merged it now.

While here, add IPv6 support.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23936 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-10-18 23:55:57 +00:00
Love Hörnquist Åstrand
8cf907f08a switch to krb5_clear_error_message
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23912 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-10-14 02:55:55 +00:00
Love Hörnquist Åstrand
29a746efd7 fix usage
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23860 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-22 06:32:23 +00:00
Love Hörnquist Åstrand
210cad9123 update(c)
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23856 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-22 06:32:07 +00:00
Love Hörnquist Åstrand
384d464e85 add master att the end as argument, from harald barth
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23854 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-22 06:31:58 +00:00
Love Hörnquist Åstrand
2e1dceceec s/slave/master/ for some strings, from harald barth.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23853 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-22 06:31:53 +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
e65761aac2 and right num of arguments
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23359 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-07-15 11:24:36 +00:00
Love Hörnquist Åstrand
7e91838407 use the right type for error message
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23358 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-07-15 11:24:24 +00:00
Love Hörnquist Åstrand
125f5659a7 Clear context error that is not useful.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23245 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-06-01 22:28:44 +00:00
Love Hörnquist Åstrand
811319445f warnings on platforms where sig_atomic_t is not a int, from netbsd via Michael van Elst, Havard Eidnes and T K Spindler
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22773 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-03-24 19:13:46 +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
3a51ba465b Provide better error why kadm5_log_replay failed.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21832 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-08-07 17:35:49 +00:00
Love Hörnquist Åstrand
000d2c1e6a Print what version the client starts at.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21817 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-08-03 14:17:52 +00:00
Love Hörnquist Åstrand
2991c6378d make more sane.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21814 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-08-03 14:16:24 +00:00
Love Hörnquist Åstrand
5bdb1c0e7f always update log version, because that is whats happning in reality.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21812 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-08-03 14:09:54 +00:00
Love Hörnquist Åstrand
2d7c7670b0 more paranoid check that the log entires are self consistant
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21809 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-08-03 13:59:14 +00:00
Love Hörnquist Åstrand
a569fb65a4 Spelling.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21788 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-08-02 11:54:33 +00:00