Commit Graph

968 Commits

Author SHA1 Message Date
Nicolas Williams
c015db46da windows: Do not make test in kadmin/
Somehow the dreaded C1041 error pops up.
2022-10-03 09:44:22 -05:00
Daria Phoebe Brashear
133f517482 rewrite fallthrough to HEIM_FALLTHROUGH to deal with new Apple SDKs
Apple clang version 14.0.0 (clang-1400.0.17.3.1) fails the build
because stds.h defines `fallthrough` as a macro which is then
expanded when base.h evaluates

  # if __has_attribute(fallthrough) && __clang_major__ >= 5

The macOS SDK defines `DISPATCH_FALLTHROUGH` as the macro instead
of `fallthrough`.

This change replaces the use of `fallthrough` in the tree with
`HEIM_FALLTHROUGH` and updates the declaration in configure logic
to define `HEIM_FALLTHROUGH` based upon existing definitions
(if any) of `fallthrough` or `DISPATCH_FALLTHROUGH`.
2022-09-16 15:58:45 -04:00
Nicolas Williams
a51708c356 kadmin: Fix kdb_attrs[] units order 2022-04-25 22:24:51 -05:00
Nicolas Williams
0068ff7a94 kadmin: Fix re-entrance in iterations (part 2) 2022-03-24 14:58:10 -05:00
Nicolas Williams
a4d3832675 kadmin: Remove unnecessary callback data ret field 2022-03-24 14:52:22 -05:00
Nicolas Williams
6b64ae2cde kadmin: Fix leak of dup context 2022-03-23 23:39:34 -05:00
Nicolas Williams
621deed047 kadmin: Fix re-entrance in iterations
Any callback of kadm5_iter_principals() that wants to call other kadm5
functions (such as kadm5_get_principal()) needs to do so on a different
kadm5 handle than the one used for kadm5_iter_principals().
2022-03-23 18:03:38 -05:00
Nicolas Williams
6b45c3512e kadmin: LIST interrupt message needs no reply
The online LIST interrupt message is a NOP, but it's expected to not
have a reply (the server doesn't send one if it receives it before the
LIST finishes).

However, if the interrupt message arrives after the LIST finished, then
it does get a reply, and this causes the client to get out of step with
the server.

Fixes include:

1) flavor the interrupt NOP to make sure it never gets a reply,
2) introduce a new kadm_list_interrtupt message that is like a NOP that
   produces no reply
3) always consume -after the LIST ends- a reply to any list interrupt
   NOP on the client side.

This implements (1).
2022-03-22 17:07:34 -05:00
Nicolas Williams
1dbfd4e835 kadmin: Use kadm5_iter_principals() to list princs
Now that we have a properly working API for listing principals in an
online way, and a server-side implementation of it, use it.

This should work with old and new servers, but it will only be online
and fast when talking to new servers.

(Old servers have a bug though that prevents LIST from working.)
2022-03-20 18:32:14 -05:00
Nicolas Williams
b92a02edda kadmind: Online LIST using kadm5_iter_principals()
Implement a variation on the op for listing principals where if the
client indicates support for the new variation then we stream the list
instead of collecting it into one reply.  This is the server-side
version of the associated, preceding commit:

    kadm5: Add online kadm5_iter_principals()
2022-03-20 18:30:21 -05:00
Nicolas Williams
14ce7bbaca kadmind: Send error code back... on error!
Seeing "End of file" errors from kadm5 client calls which were the
result of not sending back errors in many error paths in
kadmin/server.c:kadmind_dispatch().
2022-03-20 18:23:17 -05:00
Nicolas Williams
7556a114e1 kadmind: Fix typos leading to reply failures 2022-03-20 18:20:53 -05:00
Nicolas Williams
c2ed63ba40 kadmin: Document hard and soft aliases 2022-03-17 20:43:32 -05:00
Nicolas Williams
4eb80e0e93 kadm5: deltat2str(): Improve "unlimited" 2022-03-14 13:41:47 -05:00
Jeffrey Altman
dafbfa666f kadmin: add_one_principal avoid shadow warning
8dcc5e617b
("kadmin: add_one_principal refactor") made 'princ_name' a
top-level variable.  This precludes the need to declare
subsequent block-level variables with the same name.

Change-Id: I4bf9e54b49a0e366ed4cd39920d3fe58439beb33
2022-01-21 10:39:57 -05:00
Jeffrey Altman
04527412e3 Follow the Linux kernel's lead on "fallthrough"
The pseudo keyword 'fallthrough' is defined such that case statement
blocks must end with any of these keywords:
 * break;
 * fallthrough;
 * continue;
 * goto <label>;
 * return [expression];
 *
 *  gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes

The macro is defined either as

  __attribute__((__fallthrough__))

or as

  do {} while (0)  /* fallthrough */

not including the semicolon.

This change implements the Linux kernel style and updates several locations
where "/*fallthrough*/ and /* FALLTHROUGH */ were not previously replaced.

Externally imported code such as libedit, libtommath and sqlite are
restored to their unaltered state.

Change-Id: I69db8167b0d5884f55d96d72de3059a0235a1ba3
2022-01-21 10:39:47 -05:00
Jeffrey Altman
02bd267fbd kadmin: kadmind_dispatch fix broken commit
124b8d0f78 ("kadmin: kadmind_dispatch
do not write NULL 'rsp' to 'out'") was committed with an
unintentional source code removal.

Change-Id: I3de21e3624d713a9b5a1e89d147a5db5f1f55ab1
2022-01-21 09:24:34 -05:00
Jeffrey Altman
124b8d0f78 kadmin: kadmind_dispatch do not write NULL 'rsp' to 'out'
1b213c1082 ("kadmind: Add missing
error checks") altered the behavior of kadmin_dispatch() such that
it unconditionally called

      krb5_storage_to_data(rsp, out);

This change was unsafe because krb5_unparse_name_fixed() failure
would skip the allocation of the 'rsp' and 'sp' krb5_storage
objects.

This change allocates the krb5_storage objects prior to performing
any work.  If either of them fail, kadmin_dispatch() immediately
returns ENOMEM.

Change-Id: I14fd96afe029a4e74bb769605286ca0e17d25043
2022-01-21 09:16:35 -05:00
Jeffrey Altman
251cbf05c2 Revert "kadmin: kadmind_dispatch do not write to 'out' on error"
This reverts commit fb52fd1c53.

The change caused tests/kdc/check-kadmin to fail.
2022-01-21 09:04:31 -05:00
Jeffrey Altman
8dcc5e617b kadmin: add_one_principal refactor
If rand_password is true, allocate princ_name early to prevent
memory allocation errors after the principal was added.

Use memset_s to clear the 'password' so that it will not be
optimized away.

Change-Id: I80d11546166d2350e6a79c5a376cb9e8cb191fa3
2022-01-21 00:44:10 -05:00
Jeffrey Altman
912b20c4d7 kadmin: refactor set_random_password
Obtain the unparsed principal name early so that there is no
risk of memory allocation failure after kadm5_chpass_principal_3()
succeeds.

Change-Id: I389281004826da5752081c2f26127d55e3dc3989
2022-01-21 00:31:56 -05:00
Jeffrey Altman
fb52fd1c53 kadmin: kadmind_dispatch do not write to 'out' on error
1b213c1082 ("kadmind: Add missing
error checks") altered the behavior of kadmin_dispatch() such that
it unconditionally called

  krb5_storage_to_data(rsp, out);

Previously kadmin_dispatch() only wrote to 'out' on success.
Doing so is important because 'rsp' might be NULL on error.

Change-Id: I2688a5c47db0f94d955971e785037c578d3f3fa4
2022-01-21 00:25:15 -05:00
Jeffrey Altman
4ffd190b08 kadmin: kadmind_dispatch fix handling of HEIM_ERR_EOF error
1b213c1082 ("kadmind: Add missing
error checks") altered the scope of the

   if (ret == HEIM_ERR_EOF)
      ret = 0;

treatment of HEIM_ERR_EOF as a success code.  Prior to that
commit HEIM_ERR_EOF meant success only when reading the 'keepold'
value.  It indicated a premature failure if returned when reading
'princ' or 'n_key_data'.

This change corrects the scope of HEIM_ERR_EOF indicating success.

Change-Id: If5463b47dc3eabee6fa2f8e717147f02adc1586c
2022-01-20 23:43:06 -05:00
Nicolas Williams
1b213c1082 kadmind: Add missing error checks 2022-01-19 16:33:37 -06:00
Nicolas Williams
abb9a46ccc kadmin: Add missing error check in init() 2022-01-18 15:41:43 -06:00
Jeffrey Altman
51575264d4 kadmin: read_words pass correct type to sizeof
(char *) not (char **).

Change-Id: I2c34fa5b0ea9f81b08451ed1b4a816684b7ab638
2022-01-17 22:36:29 -05:00
Nicolas Williams
0f843189a4 kadmin: Check for errors in init 2022-01-17 00:45:37 -06:00
Jeffrey Altman
63f9fc172c kadmin: kadmind_dispatch free 'ks_tuple' before overwriting
Change-Id: I8719c610a34ca128cc8a0b3d7f94dafc26b21e01
2022-01-17 00:16:27 -05:00
Nicolas Williams
d974c37a90 kadmin: Remove dead code in add_one_namespace() 2022-01-16 23:08:32 -06:00
Jeffrey Altman
231aa68895 kadmin: add_one_namespace do not leak princ_ent
princ_ent must be saved to princ.principal early in order to
ensure that it is not leaked.

Change-Id: Ic74b48f434c727401c00e6fdcaecead988fe4263
2022-01-16 23:42:21 -05:00
Jeffrey Altman
54adba6023 kadmin: format_field KRB5_TL_ETYPES do not leak enctype string
Change-Id: I745216c334c038f55711c27f7885d8f96f656e79
2022-01-16 23:32:10 -05:00
Jeffrey Altman
f341fa7721 prevent unintended sign extension errors
When an unsigned char is shifted << 24 bits its type will be
promoted to signed 32-bits.   If the value is then assigned to
an unsigned 64-bit value sign extension will occur.

Prevent the unwanted sign extension by explicitly casting the
value to unsigned long before shifting.

Change-Id: Iabeac0f17dc3229a2dc89abe71960a8ffbf523f8
2022-01-16 00:23:05 -05:00
Jeffrey Altman
a84186653c kadmin: list_princs zero get_opt structure before use
Not all fields are assigned to.  Initialize the structure
to zero before use.

Change-Id: I2cfc60baaf8bf80389950a373c2a82f600a71aa2
2022-01-15 22:28:42 -05:00
Luke Howard
0e8c4ccc6e hdb: eliminate hdb_entry_ex
Remove hdb_entry_ex and revert to the original design of hdb_entry (except with
an additional context member in hdb_entry which is managed by the free_entry
method in HDB).
2022-01-15 18:54:57 +11:00
Luke Howard
c5551775e2 hdb: decorate HDB_entry with context member
Decorate HDB_entry with context and move free_entry callback into HDB structure
itself. Requires updating hdb_free_entry() signature to include HDB parameter.
A follow-up commit will consolidate hdb_entry_ex (which has a single hdb_entry
member) into hdb_entry.
2022-01-15 18:54:57 +11:00
Nicolas Williams
fc964cd545 klist: Fix warnings 2022-01-14 17:59:49 -06:00
Nicolas Williams
c607135a03 Use fallthrough statement attribute (moar) 2022-01-14 16:53:34 -06:00
Nicolas Williams
ddc6113610 Use fallthrough statement attribute 2022-01-14 16:32:58 -06:00
Nicolas Williams
b7bf5ca6e8 kadmin: Fix warnings 2022-01-14 14:59:02 -06:00
Nicolas Williams
d833ce4cbc hdb: Namespace referrals
Add a new method for issuing referrals for entire namespaces of hostnames.

An alias of the form WELLKNOWN/HOSTBASED-NAMESPACE/service/namespace-fqdn@REALM
will cause all requests for host-based principals in the given namespace to be
referred to the given realm.
2022-01-02 21:40:17 +11:00
Luke Howard
0165633964 hdb: add no-auth-data-reqd flag to HDB entry
Add a new flag, no-auth-data-reqd, to the HDB entry which indicates that a PAC
should not be included on issued service tickets.
2021-12-23 13:52:12 +11:00
Nicolas Williams
2a9b57cdad kadmin: Add command aliases to man page 2021-10-30 15:21:54 -05:00
Nicolas Williams
ba98690a0a kadmin: Add add_alias, del_alias 2021-10-11 13:58:15 -05:00
Luke Howard
49f3f5bd99 kdc: support for GSS-API pre-authentication
Add support for GSS-API pre-authentication to the KDC, using a simplified
variation of draft-perez-krb-wg-gss-preauth-02 that encodes GSS-API context
tokens directly in PADATA, and uses FX-COOKIE for state management.

More information on the protocol and implementation may be found in
lib/gssapi/preauth/README.md.
2021-08-12 17:37:01 +10:00
Nicolas Williams
8ac3452fd7 kadmin: Add missing attributes; sort units
Sorting the units fixes a bug introduced in:

    ae8908bf8 kadmin: Add disallow-client attribute

that I had fixed via:

    f6ac4ee86 roken: Fix parse flags bug

which wasn't a bug at all.
2021-06-22 14:47:38 -05:00
Nicolas Williams
ae8908bf81 kadmin: Add disallow-client attribute
This is useful for services that need not be clients.  For example, an
untrusted service that need only accept authentication from clients,
but not initiate authentication to other services.
2021-06-22 13:01:24 -05:00
Nicolas Williams
ea83f068e9 kadm5/kadmin: Add read-only mode
Now we can have read-only kadmind instances.
2020-09-08 00:25:40 -05:00
Nicolas Williams
5447b81fb1 hdb: Move virtual principals into HDB layer
This is a large commit that adds several features:

 - Revamps and moves virtual host-based service principal functionality
   from kdc/ to lib/hdb/ so that it may be automatically visible to
   lib/kadm5/, as well as kadmin(1)/kadmind(8) and ktutil(1).

   The changes are backwards-incompatible.

 - Completes support for documenting a service principal's supported
   enctypes in its HDB entry independently of its long-term keys.  This
   will reduce HDB bloat by not requiring that service principals have
   more long-term keys than they need just to document the service's
   supported enctypes.

 - Adds support for storing krb5.conf content in principals' HDB
   entries.  This may eventually be used for causing Heimdal KDC
   services to reconfigure primary/secondary roles automatically by
   discovering the configured primary in an HDB entry for the realm.

   For now this will be used to help reduce the amount of configuration
   needed by clients of an upcoming HTTP binding of the kadmin service.
2020-09-08 00:25:36 -05:00
Nicolas Williams
e17f78c738 kadmin: Allow negative time offsets 2020-09-07 22:15:52 -05:00
Nicolas Williams
7d50445d1b Generic: Fix warnings (fallthrough mosty) 2020-09-07 22:04:59 -05:00