Commit Graph

28837 Commits

Author SHA1 Message Date
Luke Howard
5c8f48495e kdc: conform _kdc_make_anonymous_principalname() to RFC8062
The utility function _kdc_make_anonymous_principalname() previously returned a
principal of "anonymous" rather than "WELLKNOWN/ANONYMOUS", as specified by
RFC8062. This is not used by the AS-REQ code.
2019-05-14 15:16:19 -04:00
Luke Howard
7a7eb9de2f kdc: do not include PAC for anonymous AS requests
The PAC will typically contain information that may reveal the identity of a
principal. Do not include it for anonymous requests, at least until such time
as the PAC plugin API supports indicating that the request was anonymous.
2019-05-14 15:16:19 -04:00
Luke Howard
2f013b0d48 kdc: fix compliance with RFC 8062 Section 4.1
RFC 8062 states that if the client in the AS request is anonymous, the
anonymous KDC option must be set in the request; otherwise, KDC_ERR_BADOPTION
must be returned. We were previously returning KDC_ERR_C_PRINCIPAL_UNKNOWN.
2019-05-14 15:16:19 -04:00
Luke Howard
1bc2eb33f9 krb5: fix spelling error in debug log 2019-05-14 15:16:19 -04:00
Jeffrey Altman
e60955e835 roken: getuserinfo WIN32 fix username string termination
95eb83c424 ("roken: Add roken_get_username() and friends")
failed to copy the username C-String NUL terminator.  As a result
a "DOMAIN\user" is returned as "userIN\user".

Change-Id: I10027e4eef18364074eecf385fa9fab1ae68dbe7
2019-05-02 13:42:01 -04:00
Rod Widdowson
f1b27d77cd Windows: Make getaddrinfo-test work
Before we call gettaddrinfo we have to call rx_SOCK_INIT

In order to exercise the test we have to supply parameters to the command line
2019-03-25 16:38:56 -07:00
Quanah Gibson-Mount
aad5c71014 Fixes https://github.com/heimdal/heimdal/issues/533
Update certs to no longer be expired, last 500 years.
2019-03-22 20:59:04 -04:00
Quanah Gibson-Mount
2d193d380d For https://github.com/heimdal/heimdal/issues/392
Correctly reference the OID so gen-cert.sh works correctly
2019-03-22 18:23:45 -04:00
Quanah Gibson-Mount
98f904036c For https://github.com/heimdal/heimdal/issues/392
Modern OpenSSL no longer has the 2038 year restriction.  Update the
certs to last 500 years rather than 10 years.

Modern crypto requirements suggest a stronger key strength than 1024.
Update to use a minimum of 4096.

Fix executable bit on gen-req.sh
2019-03-22 17:49:46 -04:00
Roland C. Dowdeswell
c827cd48f6 Optimise stdio krb5_storage by tracking offset 2019-03-21 11:23:39 -05:00
Roland C. Dowdeswell
56a32a8dbd krb5_storage: normalise truncate behaviour w.r.t. file offset
We choose a semantic for the file offset during truncate operations
which is to leave the offset as is unless it is off the end of the
file in which case we pull it back in to the end.  We update fd and
stdio handling to match the {,e}mem behaviour.
2019-03-21 11:23:39 -05:00
Roland C. Dowdeswell
b2332b9684 add a couple of tests to test_store.c for fd, stdio w.r.t. trunc 2019-03-21 11:23:39 -05:00
Jeffrey Altman
43a34f6663 roken: tsearch use rk_UNCONST instead of __DECONST #307
The rk_UNCONST macro exists because neither __DECONST nor uintptr_t
are available on all platforms (for example, AIX).

Change-Id: Ie36f0dd7a9ce454d411761ee4dbd6fc1f7c6692c
2019-02-21 15:46:51 -05:00
Jeffrey Altman
f0d9289d86 roken: fix strtoll
b10ad7eb57
("roken: strtoll.c negation is a no-op on unsigned integer")
broke strtoll() by failing to assign 'ret' in the success case.

Change-Id: I30535d83a2bef305140f1a6bd1ed2eeba23db9b9
2019-01-22 00:02:57 -05:00
Jeffrey Altman
9ce2683f2d roken: strtoull.c negation is a no-op on unsigned integer
strtoull() returns an unsigned long long.  However, then the input
string represents a negative number the return value is supposed to
be the unsigned representation of the negative value.  Before applying
the negation the value must be cast to (long long).

Change-Id: Icf9e75400ff736819b1f7e0e6fb3c8abd707a23a
2019-01-21 22:28:02 -05:00
Jeffrey Altman
b10ad7eb57 roken: strtoll.c negation is a no-op on unsigned integer
strtoll() returns a signed long long not an unsigned long long.
When applying the negation for negatives the value must be cast
from unsigned to signed and then stored in a signed variable
before returning it.

Change-Id: If568afd2509d27c7bf206ca59d32ca150cb34857
2019-01-21 22:25:19 -05:00
Jeffrey Altman
3bbd8663b0 WIN32: fix roken build
__declspec not _declspec

Include "err.h" not <err.h>

Include "roken.h" before "err.h"

Indent "#if" as "# if" within roken.h.in when CPP rules must be copied
into the generated "roken.h".

Correct verr() attribute to be ROKEN_LIB_NORETURN_FUNCTION.

Change-Id: I4289ecaba4a097175b4a5a1cde529b59038c72e3
2019-01-21 22:04:06 -05:00
Nicolas Williams
18226819cd ASN.1 compiler: check write errors 2019-01-15 13:21:25 -06:00
Nicolas Williams
a3a8c1e4a4 ASN.1: Support wider bit sets (fix #514) 2019-01-15 13:21:25 -06:00
Jeffrey Altman
10164490b7 windows/installer: code sign all merge modules
The assembly, policy, command and gss merge modules were unsigned.

Change-Id: I0a12576ce1a465741cb91bf670981952d776b1a7
2019-01-14 06:12:36 -05:00
Jeffrey Altman
a205fe17c6 lib/kadm5: WIN32 fix callback calling conventions
chpass_principal_with_key_hook_cb added by 57c25d9828 must be
KRB5_LIB_CALL for 32-bit Windows builds.

Change-Id: Ifd61caeee76f9d048bb13f93e226b99ce7e8b75c
2019-01-14 06:12:36 -05:00
Jeffrey Altman
387684aa93 WIN32: fix calling conventions for 32-bit builds
On 32-bit Windows Intel builds the __cdecl and __stdcall calling
conventions are different so labeling the functions that are
exported or assigned to function pointers matters.

Change-Id: I03b6f34baeb9ffb2e683fd979f12f27a5078a4da
2019-01-14 06:12:36 -05:00
Jeffrey Altman
dcfcdd00d8 lib/asn1: WIN32 suppress "unreferenced local variable" warning
the code generated by asn1_compile.exe includes a large number
of unreferenced local variables.  The resulting warnings drown
out other potentially more serious warnings.

This change suppresses the C4101 warnings in the generated
source files.

Change-Id: I17642ff427f457c885b1eb0e62436f3bc9057ee1
2019-01-14 06:12:36 -05:00
Jeffrey Altman
63579e6eb1 packages/windows/sdk: include dlfcn.h
dlfcn.h is now included from roken.h so must be included in
the sdk.

Change-Id: I76d6d9df965785c47cfefd349462a2e71fc58b63
2019-01-14 06:12:36 -05:00
Jeffrey Altman
7d5b844538 lib/krb5: WIN32 disable warnings
Heimdal declares functions that never return as non-void.  Suppress
the following warnings now that functions are labeled 'noreturn'.

4646 - function declared with __declspec(noreturn) has non-void return type

4716 - 'function' must return a value

Change-Id: Id85cc435e99688bae7326a723a5a80d828859bf2
2019-01-14 06:12:36 -05:00
Jeffrey Altman
9d3e206b76 lib/krb5: WIN32 _krb5_load_plugins wrong constness
The 'plugin_prefix' variable was declared 'const' which generates
a warning because the C string is freed.

This change removes the 'const' designation.

Change-Id: I6f3838d6dbf1bb496f286c96aea96bae8948930d
2019-01-14 06:12:36 -05:00
Jeffrey Altman
9358747426 lib/gssapi/mech: gss_acquire_cred_from calling conventions
gss_acquire_cred_from() is an exported function and therefore
must be tagged with GSSAPI_LIB_FUNCTION and GSSAPI_LIB_CALL.

Change-Id: I80918cb8083eaeac2d0eba5347f7b428e997cfaa
2019-01-14 06:12:36 -05:00
Luke Howard
57c25d9828 kadm5: add chpass_with_key hook (#397)
Add a hook for changing a password with a key. This hook should be consolidated
into one shared with randkey and setkey, but for now I have continued to have
the hooks follow the kadm5 APIs themselves in both signature and quantity.

(This means the randkey one isn't actually very useful because it doesn't
provide the hook with the keys.)
2019-01-10 15:18:10 +11:00
Luke Howard
59ba12f832 kadm5: remove unused variable from sample_hook 2019-01-10 12:40:11 +11:00
Ake Sandgren
907b9ee6c4 Fix broken return from _krb5_erase_file on missing file.
The return of lstat should be handled like the "open" if errno = ENOENT.
2019-01-09 11:27:09 -06:00
Nicolas Williams
717a399bbd Fix ktutil weak password for principal creation
Now that we always enforce password quality policies, ktutil get fails
because it uses "x" as a password when creating a principal.

Of course, it's probably a misfeature that ktutil get creates principals when
they don't exist...
2019-01-09 00:14:11 -06:00
Nicolas Williams
c2b106def5 Fix wrong keepold default in kadmin and ktutil 2019-01-09 00:14:11 -06:00
Nicolas Williams
7808e898e5 Appveyor: fix SetEnv.cmd invocation 2019-01-07 11:55:40 -06:00
Luke Howard
5abb68c891 hdb: ensure Salt is zero'd in add_default_salts()
Ensure Salt is zero'd in add_default_salts(), as the structure has members
other than the salt type and value.
2019-01-07 18:07:53 +11:00
Luke Howard
ff21a49cb0 krb5: change "version" to "instance" in plugin error message
A mismatch of instance cookie just means that the instances of Heimdal do not
match; they may in fact be the same version.
2019-01-07 16:49:38 +11:00
Luke Howard
de1f37a6aa kdc: omit default salt from PA-ETYPE-INFO[2]
If the salt for the AS-REP client key matches the default password salt for the
client principal in the AS-REQ, then it can be omitted from the PA-ETYPE-INFO,
PA-ETYPE-INFO2 (RFC4120) as the client will assume the default salt in its
absence.
2019-01-07 16:33:08 +11:00
Luke Howard
a3fd75f368 hdb: generate default salts for entries missing them
Older databases may lack explicitly stored salts where the salt is the default
one. When fetching a client entry for an AS-REQ, add default salts to keys that
lack one.
2019-01-07 16:33:08 +11:00
Jeffrey Altman
828ddecd61 kdc: get_pa_etype_info_both comply with RFC4120
Heimdal's current behavior regarding the generation of PA-ETYPE-INFO2
and PA-ETYPE-INFO violates RFC4120 in two ways:

 1. when generating responding both PA-ETYPE-INFO2 and PA-ETYPE-INFO
    the hints returned in the inverse order: INFO then INFO2 instead
    of INFO2 then INFO.

 2. the determination that both PA-ETYPE-INFO2 and PA-ETYPE-INFO is
    currently based upon the KDC selected enctype when it should be
    determine based upon examining the entire enctype list specified
    by the requesting client.

This change corrects the behavior to follow the RFC4120 guidance.

Change-Id: I6ebda8a813c25f9296f10314e32e93a22380ca72
2019-01-07 15:43:54 +11:00
Luke Howard
83d2951c0d gssapi: SPNEGO does not reset NTLM RC4 state (#509) 2019-01-06 20:50:24 -06:00
Luke Howard
9750f2d915 hdb: force canonicalization of enterprise principal names
Whilst Windows does not canonicalize enterprise principal names if the
canonicalize flag is unset, the original specification in
draft-ietf-krb-wg-kerberos-referrals-03.txt says we should. Non-Windows
deployments of Heimdals are unlikely to understand enterprise principal names
in tickets, and are also unlikely to set the canonicalize flag, so this makes
sense. (It was also the behavior prior to moving the name canonicalization
logic into the KDC.)
2019-01-06 18:03:07 +11:00
Luke Howard
4ea5cc2eff kdc: only set HDB_F_GET_KRBTGT when requesting TGS principal 2019-01-06 17:54:58 +11:00
Luke Howard
0141e7a497 Revert "kdc: move more name canonicalization logic to KDC"
This reverts commit 1b7e196e66.

It turns out that, contrary to the referrals draft, Windows does not
canonicalize enterprise principal names if the canonicalize KDC option is
unset.
2019-01-06 17:45:05 +11:00
Luke Howard
79f84913c9 hdb: krb5_locl.h obviates need for forward declarations 2019-01-05 16:32:00 +11:00
Luke Howard
1b7e196e66 kdc: move more name canonicalization logic to KDC
Enterprise principal client names in AS-REQs should always be canonicalized
irrespective of the setting the canonicalize KDC option. Perform this check in
the KDC rather than HDB.

Do not set the HDB_F_GET_KRBTGT flag unless the client actually requested a TGS
principal.
2019-01-05 15:51:11 +11:00
Luke Howard
c6232299c3 kdc: perform AS-REQ canonicalization in kdc
Mirroring the logic recently introduced in the TGS, this patch modifies the KDC
to perform client and server canonicalization itself rather than relying on the
backend to do so. Per RFC 6806, the behavior is slightly different for the AS
in that the setting of the canonicalize flag in the AS-REQ does impact the
returned names in the ticket. In order to support realm canonicalization or
other custom behavior, we allow the backend to force the KDC to canonicalize by
setting the force-canonicalize flag in the returned client or server entries.
2019-01-05 15:51:11 +11:00
Luke Howard
6bb8eaca20 hdb: dereference principal aliases in all KDC lookups (#452)
e11abf41 added support in libhdb for always dereferencing principal aliases
during an AS-REQ (where dereferencing refers to enabling alias lookups, and
rewriting the returned entry with the alias name unless canonicalization was
enabled).

Due to the KDC setting HDB_F_FOR_AS_REQ for all lookups from the AS, this
allowed aliases on the TGS itself to be dereferenced during an AS-REQ; however,
on presenting the TGT, the TGS would fail to resolve. Creating an explicit TGS
principal for the aliased realm would work (at least prior to c555ed6a), but
this could be confusing to deploy.

This commit changes enables alias dereferencing when HDB_F_GET_ANY is set,
which essentially means dereference whenever the request is coming from the KDC
(as opposed to, say, kadmin).

We also backout c555ed6a, which changed the TGS to always canonicalize the
server realm, as this breaks serving multiple realms from a single KDC, where
server principals in different realms share a single canonical entry.
HDB_F_CANON is now passed to the backend as a hint only, and per RFC 6806 the
principal name is never changed in TGS replies. (However, for Samba interop,
backends can override this by setting the force-canonicalize HDB flag.)
2019-01-05 14:01:26 +11:00
Luke Howard
c6d00f2502 Revert "KDC: Allow hdb to set the issued ticket's realm"
This reverts commit c555ed6a1f.
2019-01-05 14:01:26 +11:00
Luke Howard
2287c250b2 Revert "Revert "Fix tests/plugin/windc.c""
windc doesn't link against libkdc, so it doesn't need to check its instance;
however, we will continue to export kdc_get_instance() from libkdc in case
other windc plugins do link against it.
2019-01-05 10:55:13 +11:00
Luke Howard
ac544a6da6 kdc: export kdc_get_instance() for windc plugins 2019-01-05 10:48:04 +11:00
Luke Howard
e776e6c5ed Revert "Fix tests/plugin/windc.c"
Will fix by exporting kdc_get_instance() from libkdc.
2019-01-05 10:47:42 +11:00