Commit Graph

102 Commits

Author SHA1 Message Date
Luke Howard
fb81598d44 krb5: port MIT Linux keyring credentials cache (#166) 2018-12-24 18:17:32 +11:00
Nicolas Williams
c01c48e0f4 Add stdio-based krb5_storage 2017-05-26 23:24:30 -04:00
Florian Best
7422cd1f6b Implement krb5_get_init_creds_opt_set_change_password_prompt() 2016-11-11 11:48:43 -06:00
Luke Howard
7b720cf61c krb5: implement draft-ietf-kitten-aes-cts-hmac-sha2-07 2016-10-08 08:17:11 +02:00
Viktor Dukhovni
1501740952 Fix transit path validation
Also implement KDC hierarchical transit policy checks.  The "hier_capaths"
parameter defaults to "yes" in [libdefaults] or can be set explicitly in
[realms] per-realm.
2016-08-08 16:29:18 -05: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
996d4c5db3 Add krb5_ret/store_[u]int64() 2016-02-26 00:55:30 -06:00
Stefan Metzmacher
25f3db919f lib/krb5: add krb5_mk_error_ext() helper function
This gives the caller the ability to skip the client_name
and only provide client_realm. This is required for
KDC_ERR_WRONG_REALM messages.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2015-07-31 17:30:23 +12:00
Nicolas Williams
0306d70a91 Add --debug option to kgetcred 2015-04-13 16:59:20 -05:00
Nicolas Williams
febe23a399 Improve and export krb5_principal_set_comp_string 2015-04-13 16:59:20 -05:00
Jeffrey Altman
dba026b5ef Introduce and apply krb5_storage_from_socket
On Windows a file descriptor is an int value allocated by the
local module instance of the C Run Time Library.  A socket handle is a
SOCKET value allocated by a Winsock Provider for the requested family and
protocol.   These two values cannot be mixed and there is no mechanism for
converting between the two.   The _get_osfhandle() and _open_osfhandle()
functions can work with a standard HANDLE (file, pipe, etc) but cannot be
used for a SOCKET.

The Heimdal krb5_storage_from_fd() routine counted on the osf conversion
functions working on SOCKET values.  Since they do not any attempt to call
krb5_storage_from_fd() on a socket resulted in an assertion being thrown
by the C RTL.

Another problem is SOCKET value truncation when storing a 64-bit value
into a 32-bit int.

To address these problems a new krb5_storage_from_socket() routine is
introduced.  This routine setups a krb5_storage that stores a socket value
as a rk_socket_t and provides a set of helper routines that always use
network ready functions.

The krb5_storage_from_fd() routines no longer use net_read() and
net_write() but provide helpers that follow their logic so that pipes can
be processed.

All call sites that allocate a socket now store the socket as rk_socket_t
and call krb5_storage_from_socket().

All locations that previously called the bare close() on a socket value
now call rk_closesocket().

Change-Id: I045f775b2a5dbf5cf803751409490bc27fffe597
2014-02-04 23:20:08 -05:00
Jeffrey Altman
b845424a86 krb5: sync export lists
Sync the Windows and UNIX export lists for lib/krb5

Change-Id: I992921058c463335d0a3037ec035afd7f9d511b0
2013-09-10 22:31:39 -04:00
Love Hornquist Astrand
a3f21747aa move to new plugin system 2013-06-04 00:16:55 -07:00
Love Hornquist Astrand
060474df16 quel 64bit warnings, fixup implicit encoding for template, fix spelling 2013-06-03 21:46:20 -07:00
Viktor Dukhovni
2433496ea6 Simplify user_realm support by removing krb5_parse_name_flags_realm()
and setting the realm as necessary in the caller.
2013-05-16 23:15:00 -04:00
Viktor Dukhovni
a2127d091d New krb5_parse_name_flags_realm supports explicit default realm.
Set the realm argument to NULL to get the usual default realm.

The krb5_parse_name_flags() function is now a wrapper around
krb5_parse_name_flags_realm().
2013-05-16 00:32:08 -04:00
Love Hornquist Astrand
de61953108 handle creation of DIR caches 2013-04-29 22:54:11 -07:00
Love Hornquist Astrand
a7e86affd8 add basic DIR support for file caches 2013-04-29 12:30:21 -07:00
Nicolas Williams
d4f23fe2ae Revert c1423a8 and fix things up
Also, we were stopping as soon as one registered plugin returned
something other than KRB5_PLUGIN_NO_HANDLE, but we weren't doing the
same for discovered plugins.  Add KRB5_PLUGIN_INVOKE_ALL flag to deal
with this; by default we'll stop at the first plugin that returns
anything other than KRB5_PLUGIN_NO_HANDLE.

Other buglets fixed as in c1423a8.
2013-03-05 21:44:43 -06:00
Love Hornquist Astrand
54078654e7 add _krb5_plugin_run_f 2013-03-04 10:28:18 -08:00
Love Hornquist Astrand
c1423a8eea redo plugin interface 2013-02-10 22:50:49 -08:00
Nicolas Williams
dadcf3beb4 Fix bug in _krb5_expand_path_tokensv() 2012-07-15 01:30:09 -05:00
Jeffrey Altman
21b03df57a Remove krb5_425_xx and krb4 compat glue from exports
The lib/krb5 export lists contained the following functions
that are no longer in the tree:

  krb5_425_conv_principal
  krb5_425_conv_principal_ext2
  krb5_425_conv_principal_ext
  krb5_524_conv_principal
  _krb5_krb_tf_setup
  _krb5_krb_dest_tkt
  _krb5_krb_life_to_time
  _krb5_krb_decomp_ticket
  _krb5_krb_create_ticket
  _krb5_krb_create_ciph
  _krb5_krb_create_auth_reply
  _krb5_krb_rd_req
  _krb5_krb_free_auth_data
  _krb5_krb_time_to_life
  _krb5_krb_cr_err_reply

Change-Id: I1f73768de2f7e9243e4e7a623b54af282ec54641
2012-06-12 18:55:32 -04:00
Jeffrey Altman
aed7a3b948 Windows: missing exports on Windows
synchronize the export lists on Windows and UNIX.
When new functions are exported on UNIX or Windows,
the "test" build target on Windows will verify if
the export lists are in sync.

Change-Id: I9df3607983b03ee8dc6fa7cd22f85b07a6cee784
2012-06-12 18:48:37 -04:00
Roland C. Dowdeswell
df42274d96 Add krb5_storage_fsync().
We add a function to cause krb5_storage's to be sync'd to their backing
store.  For memory backed storages, this is a NOP.  For files, it calls
fsync on the file descriptor.
2012-05-28 13:14:55 +01:00
Nicolas Williams
ad60b236a0 Add missing symbols to export list 2011-11-22 17:04:03 -06:00
Love Hörnquist Åstrand
1a1bd736c0 merge support for FAST in as-req codepath 2011-10-28 19:25:48 -07:00
Love Hornquist Astrand
b1012edee3 add
krb5_auth_con_getsendsubkey
2011-10-19 21:11:12 +02:00
Love Hornquist Astrand
777b24fbb5 add krb5_is_enctype_weak 2011-09-26 08:47:37 +02:00
Linus Nordberg
bebb50797f Add krb5_init_creds symbols needed by kinit.
Signed-off-by: Love Hörnquist Åstrand <lha@h5l.org>
2011-07-24 20:24:39 -07:00
Love Hörnquist Åstrand
888780c9e7 add fast symbols 2011-07-24 20:24:39 -07:00
Love Hornquist Astrand
19e572db60 add krb5_process_last_request 2011-07-24 20:24:38 -07:00
Roland C. Dowdeswell
77c8ef2c06 krb5_free_default_realm() from mit_glue.c needs to be exported to be useful.
Signed-off-by: Love Hörnquist Åstrand <lha@h5l.org>
2011-07-19 21:25:47 -07:00
Love Hörnquist Åstrand
0f489b7b28 unexport krb5_init_etype, remove duplicate code 2011-06-14 21:08:52 -07:00
Love Hornquist Astrand
bd2d4c2f79 ->max_alloc to krb5_storage and use it 2011-05-08 00:16:02 -07:00
Love Hornquist Astrand
372db4d853 add krb5_kt_have_content 2011-04-07 07:15:27 -07:00
Love Hornquist Astrand
a70217d371 include krb5_copy_context 2011-04-01 00:27:32 -07:00
Luke Howard
841a5ed3ba export krb5_kcm_call/krb5_kcm_storage_request
Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2011-03-20 23:27:04 -07:00
Love Hornquist Astrand
ea2534a55f export krb5_enomem 2010-11-24 14:35:56 -08:00
Love Hornquist Astrand
8f2e0a7010 export internal functions so we dont need private headers 2010-11-20 14:05:54 -08:00
Love Hornquist Astrand
15f0adad02 add krb5_data_ct_cmp 2010-11-06 20:36:12 +01:00
Jan Rękorajski
99f690fd19 krb5_cc_last_change_time is missing 2010-10-18 16:07:59 -07:00
Love Hornquist Astrand
ba5c014af0 add krb5_get_permitted_enctypes 2010-09-08 22:04:03 -07:00
Russ Allbery
811d9003c1 Remove remnants of srvtab support
Support for manipulating srvtabs was previously removed, but there
were still remnants in command documentation in the ktutil man page
and some declared and exported variables for the keytab ops
definitions for srvtab manipulation.  Remove these additional
remnants.

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2010-08-03 09:09:32 -07:00
Love Hornquist Astrand
71150bb1bc add krb5_principal_is_krbtgt 2010-03-07 01:00:48 -08:00
Russ Allbery
8a57d5cb08 Add krb5_allow_weak_crypto API to enable weak enctypes
Add krb5_allow_weak_crypto parallel to the API introduced in MIT
Kerberos 1.8.  Enables or disables all enctypes marked as weak.
Add a new enctype flag marking weak enctypes (all of the ones that
are disabled by default).

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2010-01-27 21:50:58 -08:00
Russ Allbery
4038832098 Export krb5_principal_get_num_comp
krb5_principal_get_num_comp was prototyped as a public function but
not exported from libkrb5.  Add it to the export version map.

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2010-01-25 22:39:14 -08:00
Love Hornquist Astrand
8df64cb195 add krb5_auth_con_getremoteseqnumber 2009-12-13 13:33:41 -08:00
Love Hornquist Astrand
722a54f6ba add missing ; 2009-12-13 13:29:02 -08:00
Gabor Gombas
b6fe5a95d3 kdc and kinit wanted to use some symbols that were not exported by
libkrb5/libkdc

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2009-11-25 05:18:49 -08:00