Commit Graph

30431 Commits

Author SHA1 Message Date
Jeffrey Altman
1e67fd6c01 krb5: rfc3526-MODP-group14 incorrect bit size
Heimdal supports the 2 mandatory MODP groups (group 2 and group 14)
according to RFC4556, however group 14 is defined with a size of
1760 bits instead of 2048.

Fixes #1001

Reported-by: Julien Rische (GitHub: jrisc)
2022-09-16 16:36:42 -04:00
Sergei Trofimovich
e7efa7783a gssapi: add dependency on gkrb5_err.h
Noticed missing target directory dependency as a build failure in
`make --shuffle` mode (added in https://savannah.gnu.org/bugs/index.php?62100):

      CC       test_common.o
    In file included from test_common.c:34:
    krb5/gsskrb5_locl.h:42:10: fatal error: gkrb5_err.h: No such file or directory
       42 | #include <gkrb5_err.h>
          |          ^~~~~~~~~~~~~
    compilation terminated.
    make[3]: *** [Makefile:2347: test_common.o] Error 1 shuffle=1656680590

The change moves gkrb5_err.h and friends to BUILT_SOURCES
to guarantee their presence when main build starts.
2022-09-16 16:13:50 -04:00
Sergei Trofimovich
254e40294e doc: add dependency on vars.texi
Noticed missing target directory dependency as a build failure in
`make --shuffle` mode (added in https://savannah.gnu.org/bugs/index.php?62100):

    Making all in doc
    make[1]: Entering directory '/build/heimdal/doc'
      MAKEINFO hx509.info
    hx509.texi:15: @include: could not find vars.texi
    hx509.texi:31: warning: undefined flag: PACKAGE_VERSION
    hx509.texi:186: warning: undefined flag: PACKAGE_VERSION
    make[1]: *** [Makefile:622: hx509.info] Error 1 shuffle=1656683556

The change moves vars.texi to BUILT_SOURCES to guarantee it's
presence when .info files start the build.
2022-09-16 16:13:50 -04:00
Sergei Trofimovich
eb8da07a7b hdb: add missing build dependency on "hdb-protos.h"
Noticed missing target directory dependency as a build failure in
`make --shuffle` mode (added in https://savannah.gnu.org/bugs/index.php?62100):

    make[2]: Leaving directory '/build/heimdal/lib/gss_preauth'
    Making all in hdb
    make[2]: Entering directory '/build/heimdal/lib/hdb'
    ../../lib/asn1/asn1_compile --option-file=./hdb.opt ./hdb.asn1 hdb_asn1
    for genfile in 'asn1_Event.c asn1_GENERATION.c asn1_HDB_EncTypeList.c asn1_HDB_Ext_Aliases.c asn1_HDB_Ext_Constrained_delegation_acl.c asn1_HDB_Ext_KeyRotation.c asn1_HDB_Ext_KeySet.c asn1_HDB_Ext_Lan_Manager_OWF.c asn1_HDB_Ext_Password.c asn1_HDB_Ext_PKINIT_acl.c asn1_HDB_Ext_PKINIT_cert.c asn1_HDB_Ext_PKINIT_hash.c asn1_HDB_EntryOrAlias.c asn1_HDB_entry_alias.c asn1_HDB_entry.c asn1_HDB_extension.c asn1_HDB_extensions.c asn1_HDB_keyset.c asn1_HDBFlags.c asn1_Key.c asn1_KeyRotation.c asn1_KeyRotationFlags.c asn1_Keys.c asn1_Salt.c'; do \
            true -style='{BasedOnStyle: Mozilla, AlwaysBreakAfterReturnType: TopLevelDefinitions, IndentWidth: 4, SortIncludes: false}' -i ${genfile}; \
    done
    ../../lib/com_err/compile_et hdb_err.et
    make  all-am
    make[3]: Entering directory '/build/heimdal/lib/hdb'
      CC       hdb-ldap.lo
    In file included from hdb_locl.h:67,
                     from hdb-ldap.c:36:
    ./hdb.h:337:10: fatal error: hdb-protos.h: No such file or directory
      337 | #include <hdb-protos.h>
          |          ^~~~~~~~~~~~~~
    compilation terminated.

The change moves hdb-protos.ha and hdb-private.h to BUILT_SOURCES
to guarantee their presence when main build starts.
2022-09-16 16:13:50 -04:00
Jeffrey Altman
88eb44fd8b ipc: mach_complete_[a]sync avoid 'ret' set but not used warning
The variable 'ret' is set but not used.   As the value is ignored
remove it.  Restructure the initialization of 'replyinCnt', 'replyout',
and 'replyoutCnt' such that a failure of vm_read() results in a
properly initialized reply structure.
2022-09-16 15:58:45 -04:00
Jeffrey Altman
de7b452dcb kuser: kinit renew_func do not update expire if no new tickets
If neither get_new_tickets() nor renew_validate() succeeded, do not
bother recomputing the 'expire' time as it is unchanged.
2022-09-16 15:58:45 -04:00
Jeffrey Altman
7b914bfb64 roken: getaddrinfo get_null return errors
get_null() can fail for two reasons.  There can be a memory allocation
issue or the hints->ai_family could be unsupported.  This change
informs the caller of the error state instead of returning success
with an invalid struct addrinfo output parameter.

Fixes #1007
Reported-by: opless
2022-09-16 15:58:45 -04:00
Daria Phoebe Brashear
76c110e1ef hx509: hx509_verify_path remove spurious fallthrough
fallthrough needs to be directly before the next case, and this duplicate
inside an else is unneeded
2022-09-16 15:58:45 -04: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
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
Joseph Sutton
f165d1e942 lib/krb5: Avoid undefined pointer arithmetic
If the AP len is large enough, we might end up computing an address
beyond the end of the 'reply' array, which is undefined behaviour.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2022-09-16 15:43:44 -04:00
Nicolas Williams
f40ac787b1 hxtool: Allow ca command to generate subject key
This commit makes the hxtool ca sub-command, when invoked with
--generate-key=TYPE and --certificate-private-key=STORE, write the
private key only to the given --certificate-private-key store and not
also the --certificate=STORE.

Before this commit, invoking the hxtool ca sub-command with both,
--generate-key=TYPE and --certificate-private-key=STORE, caused the
--generate-key option to be ignored and the private key to be read from
the given store and copied to the --certificate=STORE.  That was clearly
a bug and non-sensical.
2022-08-10 19:07:54 -05:00
Nicolas Williams
9c0bc47efc Add hxtool(1) manual page 2022-08-07 18:59:28 -05:00
Nicolas Williams
4c71d1bf06 bx509: Fix typos in commentary 2022-08-07 18:59:28 -05:00
Joseph Sutton
b19633f9b9 Use constant-time memcmp when comparing sensitive buffers
This helps to avoid timing attacks.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2022-04-30 13:35:52 -04:00
Joseph Sutton
20f038f4f0 hcrypto: Use memset_s() when clearing sensitive buffers
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2022-04-30 13:35:52 -04:00
Joseph Sutton
88ea8039e3 hcrypto: Fix typo when clearing context structure
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2022-04-30 13:35:52 -04:00
Nicolas Williams
c0bc8beb07 httpkadmind: Test attributes defaulting 2022-04-26 17:54:12 -05:00
Nicolas Williams
d93f0d103d httpkadmind: Clarify namespace in man page 2022-04-26 17:54:12 -05:00
Nicolas Williams
a5271cd765 httpkadmind: Enable materialization 2022-04-25 22:24:52 -05:00
Nicolas Williams
18f44e7e90 httpkadmind: Make get_keys_max_spns configurable 2022-04-25 22:24:51 -05:00
Nicolas Williams
a5273d18cd httpkadmind: Support ok-as-delegate and such
Add support for configuring the attributes of new principals created via
httpkadmind.  This can be done via virtual host-based service
namespaces, which will provide default attributes even if disabled (but
the created principals will not be disabled, naturally), or via
krb5.conf.
2022-04-25 22:24:51 -05:00
Nicolas Williams
cd2e423d10 hdb: Derive pw_end for virtual services
We derive keysets for virtual host-based service principals, and that
includes the `set_time` field of keys.  But applications using the kadm5
API lose that information.  Our httpkadmind wants to set a Cache-Control
header with an appropriate max-age so that clients know when to re-fetch
keytabs.

We could extract some of the lib/hdb/common.c functions so that
httpkadmind could re-create an HDB_entry from a kadm5 entry then compute
the desired time, but ultimately we already have an appropriate field in
the HDB_entry and kadm5_principal_ent_rec types: "password expiration".

So let's set the `pw_end` of a virtual host-based service's HDB entry to
the time when a client should next fetch the principal's keys, and we'll
use that in httpkadmind as the `pw_expiration` field of the kadm5 entry
type.
2022-04-25 22:24:51 -05:00
Nicolas Williams
a51708c356 kadmin: Fix kdb_attrs[] units order 2022-04-25 22:24:51 -05:00
Nicolas Williams
17104ea2f2 hdb: Ignore disabled namespaces
If a virtual host-based service namespace is disabled, then the virtual
services below it cease existing.

This will be useful in a later commit where we'll use virtual host-based
service namespace for providing default attributes for new concrete
host-based service principals created via httpkadmind, whether the
namespace be enabled or disabled.
2022-04-25 22:24:51 -05:00
Nicolas Williams
13611702f9 roken: Fix parse_flags() orig argument type 2022-04-25 22:24:51 -05:00
Nicolas Williams
642990620c GHA: Also build just on WIN32 windows-build 2022-04-25 22:24:51 -05:00
Nicolas Williams
b503100677 GHA: Fix Windows build (install texinfo) 2022-04-25 22:24:51 -05:00
Nicolas Williams
56b60a1a40 asn1: Fix printing of decorated types 2022-03-28 16:18:10 -05:00
Steffen Kieß
9a47ec2b02 kcm: Allow disabling automatic TGT renewal
Add --no-automatic-renewal option to disable automatic TGT renewal.
Renewal can also be disabled by setting automatic_renewal to false
in the [kcm] section of krb5.conf.
2022-03-25 23:33:02 -05:00
Nicolas Williams
6932819419 kadmind: Test other operations after LIST
Test that we can still do other things after `kadmin list` to make sure
we're not leaving -after listing- the connection in a state where other
operations can't work.

Also, no more sleeps at all in the test.
2022-03-24 17:17:22 -05:00
Nicolas Williams
d1e7650988 krb5: Fix skew bug, or krb5_copy_context() moar
Now that we use krb5_copy_context() via kadm5_c_dup_context(), we see
occasional skew errors in the tests because context->max_skew was not
being initialized, so it was set to 0s of skew, and krb5_rd_priv() or
others could fail.
2022-03-24 16:41:22 -05:00
Nicolas Williams
d5e21b7771 GitHub: Do not build docs in OS X
Texinfo in the GitHub OS X runners must be ancient.  Even Texinfo 5.1
can handle UTF-8.

    ```
      MAKEINFO /Users/runner/work/heimdal/heimdal/doc/heimdal.info
    /Users/runner/work/heimdal/heimdal/doc/hx509.texi:11: warning: unrecognized encoding name `UTF-8'.
    /Users/runner/work/heimdal/heimdal/doc/heimdal.texi:12: warning: unrecognized encoding name `UTF-8'.
    /Users/runner/work/heimdal/heimdal/doc//setup.texi:380: Next field of node `Using soft aliases for configuring referrals' not pointed to (perhaps incorrect sectioning?).
    /Users/runner/work/heimdal/heimdal/doc//setup.texi:404: This node (Checking the setup) has the bad Prev.
    /Users/runner/work/heimdal/heimdal/doc//setup.texi:350: Prev field of node `Using hard aliases for realm migration' not pointed to.
    /Users/runner/work/heimdal/heimdal/doc//setup.texi:310: This node (Using namespaces and synthetic principals to keep the database small) has the bad Next.
    makeinfo: Removing output file `/Users/runner/work/heimdal/heimdal/doc/heimdal.info' due to errors; use --force to preserve.
    make[1]: *** [/Users/runner/work/heimdal/heimdal/doc/heimdal.info] Error 1
    ```
2022-03-24 15:00:37 -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
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
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
c667c28f61 doc: Revert part of 0878a568f9 for Texinfo 5.1
0878a568f9 fixed a warning from Texinfo 6.7:

    doc/whatis.texi:33: warning: redefining Texinfo language command: @sub

but the fix makes the doc build fail w/ Texinfo 5.1.

There may still be other problems when using Texinfo 5.1.
2022-03-23 15:13:36 -05:00
Nicolas Williams
2f6a276251 hdb: Tolerate duplicate aliases
One user had an entry with duplicate aliases.  This happened with an
earlier version of Heimdal.

This commit does not remove the duplicates, but it does tolerate them.
2022-03-23 15:02:05 -05:00
Nicolas Williams
d172a8bd79 kdc: More testing of hard aliases
This is an attempt to make sure we test realm migration aliases by doing
kinit w/ a hard alias name in a different realm, and that we can get
service tickets for services in the same and other realms some of which
are hard aliases in one direction, and some in the other.
2022-03-23 12:46:00 -05:00
Nicolas Williams
4b9faa02b0 krb5: Fix KCM for root user 2022-03-22 23:36:18 -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
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