Commit Graph

30436 Commits

Author SHA1 Message Date
Romain F
5dd29ecd2c KCM: Memory leak in handle_read
The `inmsg` field of the client structure is malloc/realloc'ed in `handle_read` but never free'ed in `maybe_close`.
Seems like Apple already fixed that with this.
2022-03-21 13:54:04 -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
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
e6a543fa1a tests: Make tests/kdc/check-kadmin fast
Not sure why we ever needed the run-kadmind-for-one-operation approach
to testing.  Anyways, we probably don't.  Ditching that and using the
--detach mechanism of daemonization means we don't need to sleep in the
test (except when we need to restart kadmind with different options).
2022-03-20 18:24:19 -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
7827b3a91c kadm5: Make kadm5_get_principals() not quadratic 2022-03-18 18:33:53 -05:00
Nicolas Williams
fa92fe37e7 hdb: Make lmdb backend re-entrant 2022-03-18 18:33:53 -05:00
Nicolas Williams
5a0aaf9e19 krb5: Fix leak in default an2ln DB plugin 2022-03-18 18:33:53 -05:00
Nicolas Williams
a26c30b230 krb5: Initialize krb5_ret_string() output param 2022-03-18 18:33:53 -05:00
Nicolas Williams
aa04fb0fbe doc: Document principal aliasing in Texinfo docs 2022-03-17 20:43:32 -05:00
Nicolas Williams
c2ed63ba40 kadmin: Document hard and soft aliases 2022-03-17 20:43:32 -05:00
Nicolas Williams
1acb961bc1 kdc: Implement hard and soft principal aliases
We introduced a notion of soft vs. hard aliases in the previous commit
(hdb: Distinguish soft and hard principal aliases).

This commit corrects existing test cases and adds new test cases.

Soft aliases allow for the configuration of referrals using HDB entries.

Hard aliases are like copies of the aliased HDB entries.  These are
useful for renaming principals (and realms).

See the preceding commit.
2022-03-17 20:43:32 -05:00
Nicolas Williams
dcf2bdfb20 hdb: Distinguish soft and hard principal aliases
We introduce a notion of soft vs. hard aliases.

Soft aliases are aliases of WELLKNOWN/REFERRALS/TARGET@$some_realm,
where $some_realm is the realm we want the KDC to issue referrals to.

Hard aliases are all other aliases, where if the client requested
canonicalization then the KDC should update the names in the responses,
or else if the client did not request canonicalization, then the KDC
should treat the alias as a distinct principal with the same keys as the
alias' canonical name.

The logic for dealing with these is entirely located in the HDB
backends.

An HDB backend can implement hard aliases by replacing a found
HDB_entry's principal with the name used to look it up.

An HDB backend can implement soft aliases by returning
HDB_ERR_WRONG_REALM to trigger the AS or TGS to return a referral.

Currently only in-tree HDB backends support this feature that use
_hdb_fetch_kvno() as their hdb_fetch_kvno() method implementation.
That's all HDB backends other than SQLite3.

Out-of-tree backends should be unaffected.

We've added a decoration field to HDB_entry: aliased -- an int
(boolean).  This is only used internally in libhdb at this time.
Out-of-tree HDB backends could have a use for this decoration, but we
have not decided whether it is a public interface yet.
2022-03-17 20:43:32 -05:00
Nicolas Williams
db0ba731ca asn1: Allow comments and leading ws in opt files 2022-03-17 17:19:31 -05:00
Nicolas Williams
f072249d26 doc: Delete doc/kerberos4.texi 2022-03-16 18:24:25 -05:00
Nicolas Williams
a460911b03 doc: Document namespaces and synthetic principals 2022-03-16 17:50:33 -05:00
Nicolas Williams
0878a568f9 doc: Fix Texinfo docs; remove krb4 references 2022-03-16 17:50:33 -05:00
Nicolas Williams
dcef1341d3 kdc: Add error symbols for error logging
Having "KRB5KRB_AP_ERR_ILL_CR_TKT" in log messages is much better than
"UNKNOWN--1765328341".
2022-03-16 15:04:10 -05:00
Nicolas Williams
78162449b5 base: Correct UNKNOWN-0 error case
In some cases we were seeing UNKNOWN-0 when an actual error occurred.
2022-03-16 15:04:10 -05:00
Nicolas Williams
4eb80e0e93 kadm5: deltat2str(): Improve "unlimited" 2022-03-14 13:41:47 -05:00
Nicolas Williams
b14f9b1ac0 kadm5: Tolerate missing default principal 2022-03-14 13:41:47 -05:00
Joseph Sutton
698bbb5647 roken: Fix time_t overflow checking
INTxx_MIN plus a positive integer of the same type will always be
negative, and so the result will always compare less than a positive
integer. Fix this check so that we produce the correct result when
adding two negative time_t values.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2022-03-11 22:03:45 -05:00
Stefan Metzmacher
0861754a84 lib/krb5: before we create a new FAST armor we should clear the old strengthen_key
In a cross-realm situation the client KDC exchange may use on orphaned
strengthen_key (from the previous exchange) if the current KDC
doesn't not support FAST and the previous KDC supported it.

Otherwise init_creds_step() or fast_tgs_strengthen_key()
generate the reply key.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15005

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2022-03-12 12:51:03 +11:00
Nicolas Williams
953d944242 gss: Remove useless grep from check-context 2022-03-09 10:22:06 -06:00
Joseph Sutton
d5ad04a7f3 kdc: Add function to add encrypted padata
Since plugins no longer have a way of accessing the 'ek' member of the
request structure, this function provides a way for a plugin to add
encrypted padata to the response.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2022-03-08 18:58:17 +11:00
Joseph Sutton
4a23cd5e23 lib/krb5: Make parameters to PAC functions 'const'
This allows these functions to be used with PACs obtained from KDC
accessor functions such as kdc_request_get_pac().

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2022-03-08 18:58:01 +11:00
Stefan Metzmacher
7d103f8657 hdb: Fix crashes with WRONG_REALM
With HDB_ERR_WRONG_REALM the backend needs to expose the
principal, so we should not free the entry otherwise
the main kdc code will crash.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2022-03-04 10:24:01 +11:00
Jeffrey Altman
19b337a0fb lib/asn1: new ASN1 objects require new exports
free_KERB_AD_RESTRICTION_ENTRY
encode_KERB_AD_RESTRICTION_ENTRY
decode_KERB_AD_RESTRICTION_ENTRY
length_KERB_AD_RESTRICTION_ENTRY
copy_KERB_AD_RESTRICTION_ENTRY

free_PA_KERB_KEY_LIST_REP
encode_PA_KERB_KEY_LIST_REP
decode_PA_KERB_KEY_LIST_REP
length_PA_KERB_KEY_LIST_REP
copy_PA_KERB_KEY_LIST_REP

free_PA_KERB_KEY_LIST_REQ
encode_PA_KERB_KEY_LIST_REQ
decode_PA_KERB_KEY_LIST_REQ
length_PA_KERB_KEY_LIST_REQ
copy_PA_KERB_KEY_LIST_REQ

free_PA_PAC_OPTIONS
encode_PA_PAC_OPTIONS
decode_PA_PAC_OPTIONS
length_PA_PAC_OPTIONS
copy_PA_PAC_OPTIONS

free_PA_S4U_X509_USER
encode_PA_S4U_X509_USER
decode_PA_S4U_X509_USER
length_PA_S4U_X509_USER
copy_PA_S4U_X509_USER

Change-Id: I4ccbfcec64572b41878062e50a61de3f92fdf593
2022-03-03 12:05:14 -05:00
Jeffrey Altman
a8b2986b48 lib/krb5: make/copy principal init output to NULL
Initialize output principal pointer to NULL in case of failure.

Change-Id: Iaf7b204d33ddf28cdbadcceac2cb8a96ac0bdd94
2022-03-03 09:55:46 -05:00
Luke Howard
25fae63097 tests: update test KDC plugin for new PAC plugin signatures
Fixes regression introduced in 11d8a053.
2022-03-03 10:16:12 +11:00
Stefan Metzmacher
d4ac17d6d0 krb5: add new values and definitions from MS-KILE/MS-SFU
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2022-03-03 10:13:42 +11:00
Luke Howard
50fb794ef1 lib/krb5: re-allow data->length == 0 in krb5_pac_add_buffer()
PAC_TYPE_CLIENT_CLAIMS_INFO and PAC_TYPE_DEVICE_CLAIMS_INFO are
of zero length unless any claims are actually defined.

Signed-off-by: Stefan Metzmacher <metze@samba.org>

Closes: #969
2022-03-03 10:12:40 +11:00
Luke Howard
89cf441e8d Revert "lib/krb5: re-allow data->length == 0 in krb5_pac_add_buffer()"
This reverts commit f3301fc94c.
2022-03-03 10:11:32 +11:00
Stefan Metzmacher
f3301fc94c lib/krb5: re-allow data->length == 0 in krb5_pac_add_buffer()
PAC_TYPE_CLIENT_CLAIMS_INFO and PAC_TYPE_DEVICE_CLAIMS_INFO are
of zero length unless any claims are actually defined.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2022-03-03 10:10:57 +11:00
Luke Howard
df655cecd1 kdc: allow audit plugins to influence return code
Honor the return code of _kdc_audit_request(), propagating if non-zero. Note
that this is principally intended to allow the audit plugin to return
HDB_ERR_NOT_FOUND_HERE, which influences whether the KDC sends an error reply
or not. If the audit plugin also wishes to rewrite r->error_code, it must do so
separately.

Closes: #964
2022-03-03 10:10:37 +11:00
Stefan Metzmacher
8495f63bc3 kdc: provide kdc_request_get_explicit_armor_{clientdb,client,pac}()
_kdc_fast_check_armor_pac() already checks the PAC of the armor,
but it should also remember it if it's an TGS-REQ with explicit armor.

This will allow the kdc pac hooks to generate a compound identity PAC
with PAC_TYPE_DEVICE_INFO.

Signed-off-by: Stefan Metzmacher <metze@samba.org>

Closes: #967
2022-03-03 10:10:29 +11:00
Stefan Metzmacher
11d8a053f5 kdc-plugin: also pass astgs_request_t to the pac related functions
This is more consistent and allows the pac hooks to be more flexible.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2022-03-03 09:58:48 +11:00
Nicolas Williams
419610aa14 kdc: HDB max_life/max_renew == 0 -> unlimited 2022-02-15 20:16:29 -06:00
Nicolas Williams
5682be7704 roken: Test time add/sub overflow prot. 2022-02-15 20:16:29 -06:00
Nicolas Williams
fe8d4f2883 roken: Overflow prot. timeval add/sub 2022-02-15 20:12:25 -06:00
Nicolas Williams
1193bd5e74 roken: Add time_add()/time_sub() with overflow prot. 2022-02-15 20:11:37 -06:00
Nicolas Williams
9ae9902249 cf: Check if time_t is signed 2022-02-15 17:01:00 -06:00
Nicolas Williams
92d5b74c05 cf: Import AX_CHECK_SIGNED() autoconf macro 2022-02-15 17:00:19 -06:00
Nicolas Williams
e7e2c7a145 kdc: Honor "unlimited" max_life/max_renew 2022-02-15 16:56:27 -06:00
Nicolas Williams
2c8a078bcf bx509d: Do not leak temp ccaches 2022-02-14 21:07:47 -06:00
Nicolas Williams
61607fa6ea asn1: Add a GitHub Markdown manual (more) 2022-02-14 21:07:47 -06:00
Nicolas Williams
dda9aa2535 asn1: Add a GitHub Markdown manual (moar) 2022-02-14 00:05:28 -06:00
Nicolas Williams
0929561de3 Update badges at bottom of README.md 2022-02-12 15:00:59 -06:00