Commit Graph

102 Commits

Author SHA1 Message Date
Viktor Dukhovni
49d56916e1 Make slave-stats updates atomic 2017-12-13 17:33:28 -06:00
Viktor Dukhovni
7dc4481ed2 Avoid interposing pidfile(), use rk_pidfile() instead 2016-12-19 19:10:49 -05:00
Viktor Dukhovni
b39a4f7c78 Update old_version after timeout
On a low update rate master, if we don't update old_version after
processing a poll timeout, we will generate spurious warnings about
missed (change) signals every time the timer expires, and will
needlessly contact the slaves.
2016-08-09 21:02:44 -04:00
Viktor Dukhovni
2d32982ed4 Fix slave boostrap from incomplete master log
When the master's log does not contain the complete history, slaves
that bootstrap from scratch encountered a loop, because the master
falsely assumed a race with log truncation.
2016-07-07 23:00:29 -04:00
Nicolas Williams
8394778f92 master: quieten static analyzers 2016-02-29 19:13:11 -06:00
Nicolas Williams
cfd9d59a15 ipropd-master: missing error check 2016-02-29 19:13:10 -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
d774aeda38 ipropd-master: add missing ret = 2016-02-26 00:55:33 -06:00
Nicolas Williams
d1fcf3dc67 ipropd_master: fix dump bug 2016-02-26 00:55:31 -06:00
Nicolas Williams
409501e5e4 Tolerate some time-travel by slaves 2015-05-20 10:07:51 -05:00
Nicolas Williams
854aaab182 iprop master: Don't ignore flock() result 2015-05-20 10:07:51 -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
Viktor Dukhovni
eface6d31f Fix free before use in ipropd_master slaves-stats open function
Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2013-04-24 16:27:34 -07:00
Love Hornquist Astrand
60472d48ea set vno to unconfuse coverity 2012-11-27 21:58:05 -08:00
Love Hornquist Astrand
0a237dc778 don't use free'd string 2012-10-01 09:53:52 -07:00
Roland C. Dowdeswell
539ba5fb87 Fix issue where master HDB can be locked while waiting for network I/O.
We should not hold locks on the master's database while waiting
for network I/O which may take a terribly long time to complete as
this will block out all writers and could therefore be slightly
problematic.  ipropd-master was holding a shared lock on the database
while sending a complete propation to slaves which are out of sync
with the log file.  We fix this by writing what we intend to send
in record format into a file hdb_db_dir()/ipropd.dumpfile while
holding a shared lock on the database and then we send the contents
of the file after releasing the lock.  We also save and re-use the file
that we generated during future complete propagation events as long
as the log is long enough to get us back to the state previously
dumped.
2012-06-06 22:29:03 +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
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
b3811999f7 fix error condition 2011-04-23 20:03:57 -07:00
Love Hornquist Astrand
311b3c4f32 catch error from asprintf()
Patch from Tom Payerle
2011-04-23 19:31:43 -07:00
Love Hornquist Astrand
9427bcc22e log more version numbers 2011-01-03 12:12:18 +01:00
Asanka C. Herath
880d728e02 Un-const as necessary to silence compiler warnings 2010-11-24 15:33:07 -05:00
Love Hornquist Astrand
dd9e076e47 reorder to remove if (0); 2009-12-25 10:45:26 +01:00
Love Hornquist Astrand
15cff173a2 Use #ifdef SIGXCPU instead of #ifndef NO_SIGXCPU 2009-12-25 10:44:40 +01:00
Love Hornquist Astrand
160ddd0e43 use rk_closesocket 2009-12-23 14:06:37 +01:00
Love Hornquist Astrand
f1c0c1bba3 prefix SOCKET symbols with rk_ 2009-11-25 05:29:18 +01: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 Hornquist Astrand
d3d9e5ecb5 free sp on error/full send 2009-10-06 11:19:27 -07: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 Hornquist Astrand
3b761fddc0 check the clients with current_version, and if client have newer, whine 2009-09-05 14:41:03 -07:00
Love Hornquist Astrand
03b6f9a09b Don't send diffs to dead slaves 2009-09-05 14:31:49 -07:00
Love Hornquist Astrand
0d49d0f1c4 Free ticket earlier [CID-108] 2009-07-30 10:39:52 +02:00
Love Hörnquist Åstrand
a96fa6cacd plug memory leak
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25092 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-04-04 17:10:41 +00:00
Love Hörnquist Åstrand
cbfc88f691 wrap detach
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24411 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-01-25 00:39:45 +00:00
Love Hörnquist Åstrand
7beb192394 update (c)
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23855 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-22 06:32:03 +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
c6f6defa06 Only log "sending AYT" once, pointed out by Dr A V Le Blanc.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23074 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-04-23 15:06:51 +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
5a0bf63c71 Update (c).
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21831 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-08-07 17:34:51 +00:00
Love Hörnquist Åstrand
3d9f731d98 - don't push whole database to the new client every time.
- make slaves get the whole new database if they have a newer log the
  the master (and thus have them go back in time).


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21824 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-08-06 02:18:13 +00:00
Love Hörnquist Åstrand
0b286093fe Sprinkle more info about what versions the master thinks about the client versions.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21806 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-08-03 13:09:20 +00:00