Get time offsets for all keyring ccaches

Move the time offset lookup from krb5_krcc_resolve to make_cache, so
that we fetch time offsets for caches created by
krb5_krcc_ptcursor_next.

(cherry picked from commit e99c688913a7761c6adea9488ea9355f43539883)

ticket: 7820
version_fixed: 1.12.2
status: resolved
Clean up rcache if GSS krb5 acquire_cred fails

The error handler in acquire_cred_context didn't release the rcache,
which would cause it to leak if we failed after acquire_accept_cred.

(cherry picked from commit 9df0c4bdce6b88a01af51e4bbb9a365db00256d5)

ticket: 7818
version_fixed: 1.12.2
status: resolved
Avoid assertion failure in error_message

r17942 added a call to get_thread_buffer in the first part of
error_message, prior to the call to com_err_initialize.  This can
cause an assertion failure from k5_getspecific if error_message is
called on a system error before any other com_err functions are
called.  Move the initialization call earlier to prevent this.

(cherry picked from commit 6bdaa746fec1cf29adcbe5b8e65c4b8993770b84)

ticket: 7822
version_fixed: 1.12.2
status: resolved
Allow empty store in gss_acquire_cred_from

There is no reason to deny a zero-length cred store, so don't check
for it in val_acq_cred_args or val_add_cred_args.

(cherry picked from commit 970304b558a360e08d8421ef92245d2df0ac5e49)

ticket: 7836
version_fixed: 1.12.2
status: resolved
Reinitialize ulog when wrapping serial number

When we wrap the serial number, reinitialize the ulog so that kdb_num
starts counting from 1, instead of leaving the ulog in a weird state
where kdb_num == ulogentries but kdb_last_sno == 1 and the serial
numbers in the circular array aren't necessarily contiguous.

(cherry picked from commit 3c147860df11d8ef24dabf07d32f36915f3b640c)

ticket: 7839
version_fixed: 1.12.2
status: resolved
Check for unstable ulog in ulog_get_entries

If a process terminates in the middle of a logged database update, it
will release its lock and leave the ulog in the KDB_UNSTABLE state.
kadmind should notice this when it calls ulog_get_entries, but right
now it only checks for the KDB_CORRUPT state (which is never set any
more) and does not recover.  Check for any state other than KDB_STABLE
and recover by resetting the ulog and forcing full resyncs to slaves.

(cherry picked from commit 91ef7d4c3f892b99630422a71780788f2d1c04d7)

ticket: 7853
version_fixed: 1.12.2
status: resolved