Add Python scripts to check for C style issues

util/cstyle-file.py checks a file for C style issues and displays
line-by-line output.  It is not terribly sophisticated, and can
probably be improved upon (e.g. by doing an emacs batch-reindent of
the file and checking for differences in indentation).

util/cstyle.py produces diffs using git, runs the file checker on each
modified C source file in each diff, and displays the output lines
attribute to the diff.
Improve kpropd behavior in iprop mode

 - Make kpropd in iprop mode fork a child to listen for kprops from the
   master.  The child writes progress and outcome reports to the parent
   for each kprop.  This fixes a race between asking for a full resync
   and setting up a listener socket for it.

 - Add runonce (-t) for kpropd do_standalone() too.

 - Add a new iprop parameter: iprop_resync_timeout.  kpropd will keep
   asking for incremental updates while waiting for a full resync to
   finish, and will re-request a full resync if kadmind continues to
   indicate that one is needed after this timeout passes since the
   previous full resync was requested.

 - Allow polling intervals less than 10 seconds.

[ghudson@mit.edu: split out debug output changes; note polling interval
change in commit message]

ticket: 7373
Improve kpropd debug and syslog output

Add additional debug output and syslogs.  Remove "kpropd:" from
syslogs.  Always call openlog().  Clean up C style of a few messages.

[ghudson@mit.edu: split and combine commits; commit message]
Use a single global dump for iprop full syncs

Use a global dump (the default dump file) for full syncs for iprop.
When a slave asks for a fullsync we kprop the existing global dump to it
if that is good enough, else we dump the DB and send the new global
dump.

Before this change kadmind would run kdb5_util dump -i... each time a
slave asked for a full dump.  This was done in a sub-process,
thankfully, but it was still a waste of time and storage (e.g., if one
has a huge KDB).

Also, long dump times might cause a slave to give up (the timeout for
this is now configurable).  But since iprop dumps bear a serial number
and timestamp and since slaves will resync from that point forward, it
doesn't matter if the dump we send a slave is fresh as long as it is
fresh enough (i.e., that its sno and timestamp are in the ulog).

Also:

 - Rename dumps into place instead of unlink, create, write (but we
   still keep the dump ok files as lock files and as a method of
   signaling to kprop that the dump is complete).

ticket: 7371
Cleanup dump_db()
Fix kdb5_util dump race

ticket: 7377
ipropd_svc.c DPRINT improvements

Make DPRINT a varargs macro and add some new debug prints.
Add -p, -F, -K options to kadmind

New options:

    -p path-to-kdb5_util
    -K path-to-kprop
    -F dump-file

These are needed for testing without first having to install.

ticket: 7372
Correct docs re: kpropd usage w/ iprop

ticket: 7379
Deprecate kpropd -S option

ticket: 7376
kdb5_util load needs iprop safety net

ticket: 7370
Sync iprop header in kdb5_util dump

[ghudson@mit.edu: split out from previous commit]
Fix policy refcount corruption race in dump

ticket: 7384
Add -R option to kproplog to force full resyncs

ticket: 7375
Remove MAX_ULOGENTRIES

If a master KDC uses only a 64-bit libkadm5srv then there is no reason
to impose any limit on ulog size: the practical maximum will be given by
the filesystem and available storage space.

Even when using a 32-bit libkadm5srv the maximum practical ulog size
will be found easily enough when mmap() fails.

ticket: 7368
Make kadmind iprop never return UPDATE_BUSY

Currently kadmind allows slaves to poll for updates as often as they
like, but not within 10s of the last update.  This means that iprop will
appear to fail to synchronize the KDC at any site whose master KDC
processes at least one write transaction every 10 seconds consistently.

The original intention must have been to throttle iprop clients (slave
KDCs) that poll too often.  But UPDATE_BUSY as implemented is not that,
and implementing a throttle would be difficult (requires keeping state
in a table) and mostly useless (admins can manage their poll timers just
fine without a throttle in kadmind).

ticket: 7369
Fix a minor race in kdb5_util load

If a kdb5_util load gets killed between rename()ing the new KDB file
into place and resetting the iprop ulog then the ulog can reflect the
pre-load state, which will almost certainly be incorrect.

This matters because we want to impose a timeout on full resyncs in
kpropd when iprop dictates that a full resync is needed, and the
simplest timeout scheme involves signaling the kdb5_util load process.
But also, we want no such races in general.

The fix is simple: re-initialize the ulog before renaming the new KDB
file into place, then proceed as usual.  If the ulog is not properly
updated at the end of the load it will at least always result in
subsequent iprop get updates operations always indicating that a full
resync is required.

ticket: 7399
Enforce TGS principals having 2 components

RFC 4120 section 7.3 says that TGS principal names have two
components.  Make krb5_is_tgs_principal() and is_cross_tgs_principal()
enforce this constraint.  Code elsewhere in the KDC already checks for
two components anyway.
Don't use kdc_active_realm in kdc/rtest.c

Too many parts of the KDC rely on the global variable
kdc_active_realm.  rtest.c doesn't actually need any of the
KDC-specific information that's avaiable through kdc_active_realm, so
delete references to it.
Eliminate some KDC globals

Make kdc_active_realm a local variable in every function that needs
it.  Pass it around in various state structures as needed.