Commit Graph

1186 Commits

Author SHA1 Message Date
Nicolas Williams
f90f055659 iprop: Enable secondary KDC bootstrapping w/ PKINIT
With this change it's possible to bootstrap a KDC using a client
certificate with a PKINIT SAN for iprop/fqdn.  Given such a certificate
one could run ipropd-slave via kinit to pull down the initial copy of
the HDB, then start the KDC services using the HDBGET: keytab.

That should make bootstrapping new secondary KDCs very easy.

One could bootstrap the KDC with such a certificate using, e.g.,
Safeboot (https://github.com/osresearch/safeboot), enrolling the host as
a KDC.
2022-10-02 22:46:37 -05:00
Joseph Sutton
f6d26bce66 kadm5: Correctly set userAccountControl bits
We meant to clear only the UF_SMARTCARD_REQUIRED bit, but we were
instead clearing all bits excepting it.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2022-09-16 15:43:44 -04:00
Nicolas Williams
990250e462 kadm5: Fix leak in kadm5_c_dup_context() 2022-03-23 23:39:34 -05:00
Nicolas Williams
1e1d663bb5 kadm5: Fix failure to connect in dup handle 2022-03-23 23:39:34 -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
f037a0a57f kadm5: Add missing kadm5_ret_principal_ent() check 2022-03-22 17:07:34 -05:00
Nicolas Williams
ed4b1be5bb kadm5: Add online kadm5_iter_principals()
kadm5_get_principals() is not online.  If you have... many principals,
it will be slow.  At least it's no longer quadratic, but it, it's still
slow.  Time to add a version that uses a callback:

    kadm5_ret_t
    kadm5_iter_principals(void *server_handle,
                          const char *expression,
                          int (*cb)(void *, const char *),
                          void *cbdata)

The callback gets called with the given callback data and one principal
name (unparsed).

Note that the callback MUST NOT re-enter the kadm5 library with the
*same* kadm handle.  For example, the kadmin protocol doesn't really
multiplex requests well, though it could pipeline them, but it can't
pipeline when LIST is running, not with the protocol implemented here,
so a separate connection is needed, and that requires a separate kadm
handle.  We add kadm5_dup_context() to deal with this.
2022-03-20 18:27:03 -05:00
Nicolas Williams
7827b3a91c kadm5: Make kadm5_get_principals() not quadratic 2022-03-18 18:33:53 -05:00
Nicolas Williams
b14f9b1ac0 kadm5: Tolerate missing default principal 2022-03-14 13:41:47 -05:00
Jeffrey Altman
693191b23d lib/kadm5: kadm5_c_randkey_principal check store_int return
do not ignore failures to krb5_store_int() ks_salttype.

Change-Id: I4144376f24ac00f45073daec4fa5835706b1ad09
2022-01-23 22:49:57 -05:00
Nicolas Williams
be6305b601 kadm5: Fix ENOMEM path leak 2022-01-20 12:41:39 -06:00
Nicolas Williams
9203c4a3f4 ipropd: Ignore setsockopt() result 2022-01-19 23:37:32 -06:00
Nicolas Williams
4a0e01f9ed kadm5: Add missing error checks 2022-01-19 16:57:06 -06:00
Nicolas Williams
97cef99f54 iprop: Fix coverity warnings 2022-01-19 16:53:45 -06:00
Nicolas Williams
655c057769 kadm5: Add missing error checks 2022-01-19 16:33:17 -06:00
Nicolas Williams
9d6dd21256 iprop-log: Add missing error checks 2022-01-19 13:59:04 -06:00
Nicolas Williams
d658aa9b11 kadm5: Fix error-path leak 2022-01-17 10:48:07 -06:00
Nicolas Williams
6fc38099f7 ipropd: Initialize struct sigaction 2022-01-16 23:09:17 -06:00
Jeffrey Altman
3065730b8a lib/kadm5: find_db_spec do not leak 'info'
If a memory allocation failure occurs 'info' is leaked.

Change-Id: Ie9cfff3f7d63a1af8e053d47d5ff66411916a795
2022-01-16 21:03:00 -05:00
Jeffrey Altman
1247ca977c lib/kadm5: kadm5_ad_init_with_password_ctx free 'ctx'
kadm5_ad_destroy() frees the contents of the kadm5_ad_context
but not the kadm5_ad_context itself.

Change-Id: I70dc1fc0236166ed9725f681dfeb935f449e38cb
2022-01-16 20:09:12 -05:00
Jeffrey Altman
7c01b2af68 lib/kadm5: _kadm5_c_get_cred_cache free 'client'
If the cache principal name cannot be determined free the client
principal created from the input client name.

Change-Id: I75f96ef9f490bd9eb761a900e7a26250f1ac2b9c
2022-01-16 20:01:45 -05:00
Jeffrey Altman
e8ccb2b86b lib/kadm5: send_diffs() init 'ver'
warning: ‘ver’ may be used uninitialized in this function [-Wmaybe-uninitialized]

'ver' can be uninitialized if get_right() fails.

Change-Id: If6019cc3c491b8be321ff3e08f3d27292f0f1f95
2022-01-16 15:54:53 -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
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
Jeffrey Altman
923067e099 lib/kadm5: kadm_connect do not close 's' more than once
If 's' is closed before exiting, it must be set to rk_INVALID_SOCKET.

Change-Id: I63caf992aa3a6b2c86c918a660025fc054d396d6
2022-01-14 23:21:16 -05:00
Nicolas Williams
367f9ddd7d kadm5: Revert part of 69eee19541 2022-01-14 15:41:32 -06:00
Nicolas Williams
69eee19541 kadm5: Fix warnings 2022-01-14 14:58:59 -06: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
4aa8677081 kadm5: Use KADM5_PASS_Q_GENERIC 2021-12-16 10:40:01 +11:00
Nicolas Williams
437d4e95ec kadm5: Add KADM5_PASS_Q_GENERIC, note MIT diffs 2021-12-16 10:40:01 +11:00
Nicolas Williams
5f63215d0d Always perform == or != operation on cmp function result
Although not required to address bad code generation in
some versions of gcc 9 and 10, a coding style that requires
explicit comparison of the result to zero before use is
both clearer and would have avoided the generation of bad
code.

This change converts all use of cmp function usage from

```
    if (strcmp(a, b) || !strcmp(c, d)) ...
```

to

```
    if (strcmp(a, b) != 0 || strcmp(c, d)) == 0
```

for all C library cmp functions and related:

 - strcmp(), strncmp()
 - strcasecmp(), strncasecmp()
 - stricmp(), strnicmp()
 - memcmp()

Change-Id: Ic60c15e1e3a07e4faaf10648eefe3adae2543188
2021-11-24 22:30:44 -05:00
Nicolas Williams
6cbe35ad5d kadm5: Fix crash in principal creation
This manifests with an upcomming patch that adds support for
aliasing of namespaces.
2021-10-30 15:21:54 -05:00
Nicolas Williams
8671858178 kadm5: Fix KRB5_TL_LAST_PWD_CHANGE handling 2021-10-11 13:58:15 -05:00
Nicolas Williams
fb298a023b kadm5: Teach perform_tl_data() about aliases
Sort of.  It already knew.

We have a mess where new things get sent to the server as
KRB5_TL_EXTENSION, but old things get sent to the client as whatever
appropriate KRB5_TL we have, and... we call perform_tl_data() on all TL,
but we don't remove unmodified TL on the client side, and...

Anyways.  This commit is a band-aid, but it works.
2021-10-11 13:58:15 -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
5aaf12351a iprop: More default HDB type fixes 2021-05-04 14:53:40 -05:00
Nicolas Williams
0c1cd18e03 iprop: Fix default dbname choice on initial prop
If a DB does not already exist, ipropd-slave will use the compiled
default, which is not necessarily what is desired or configured in
`[kdc]`.

This change makes `hdb_default_db()` return the first dbanme in the
`[kdc]` configuration, falling back on `HDB_DEFAULT_DB`.

Also, this adds a `--database` option to `ipropd-slave`.
2021-05-03 15:02:43 -05:00
Nicolas Williams
6216117da0 iprop: Optional async slave HDB writes
New command-line option for ipropd-slave to disable sync HDB writes
also when replaying the log.
2021-03-31 22:59:38 -05:00
Nicolas Williams
7845bda1e0 kadm5: Do not apply new service key delay in get
Using HDB_F_DELAY_NEW_KEYS in kadm5_s_get_principal() breaks OSKT's
expectations.
2020-09-19 21:48:49 -05:00
Nicolas Williams
95de81c9a7 kadm5: Avoid close(-1) 2020-09-18 14:31:43 -05:00
Nicolas Williams
461f360b58 iprop: Slight test race condition fix
tests/kdc/check-iprop.in tends to wait for a log message then it reads a
status file.  Well, we shouldn't write the log message before writing
the status file then!
2020-09-18 14:31:43 -05:00
Nicolas Williams
916cafe4e5 iprop: Warn about failures to write to iprop log 2020-09-18 14:31:43 -05:00
Nicolas Williams
7c947df247 ipropd: Improve multi-realm support
Running ipropd-slave on a system whose hostname's realm is not the
requested realm breaks.  Since the iprop client principal should really
be in the same realm as the master, we now force it after calling
krb5_sname_to_principal().
2020-09-18 14:31:43 -05:00
Nicolas Williams
0e09fa7fde iprop: Support hierarchical iprop 2020-09-18 14:31:43 -05:00
Nicolas Williams
f2f2cd18b6 kadm5: Fix auth_context leak on reconnect 2020-09-14 17:11:08 -05:00
Nicolas Williams
ff13573ce5 hdb: Do not apply new service key delay to clients
The new [hdb] new_service_key_delay parameter should not apply to
principal entries when used as clients.  Otherwise new passwords would
not take effect immediately, and that would be very confusing.
2020-09-09 21:48:29 -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
a12fe376ae Revert "kadm5: Allow princ creation with keys"
This reverts commit 5b70a0cac6.
2020-09-07 23:58:46 -05:00