Commit Graph

30053 Commits

Author SHA1 Message Date
Nicolas Williams
472509fd46 gsskrb5: Do not leak authenticator on retry
We have a Heimdal special where when the acceptor sends back an error
token for clock skew or ticket-not-yet-valid errors then the acceptor
application will get GSS_S_CONTINUE_NEEDED from gss_accept_sec_context()
so that the initiator may retry with the same context.

But we were retaining the auth_context, which means that when the
initiator does send a new token, the acceptor leaks memory because
krb5_verify_ap_req2() doesn't clean up the auth_context on reuse.  The
end result is that we leak a lot in those cases.
2022-01-07 21:04:19 -06:00
Nicolas Williams
2d83a0b8cd gss: Make sure to indicate PAC buffers 2022-01-08 10:38:01 +11:00
Nicolas Williams
c2e3c5b66e gss: Add way to set authenticator authz-data
Now we can set Authenticator authorization-data with
gss_set_name_attribute().
2022-01-08 10:38:01 +11:00
Nicolas Williams
fe11481cc5 gss: Make krb5 name attrs table-driven
The implementation of GSS name attributes for Kerberos (or any mechanism
with more than a tiny handful) is much nicer as a table-driven
implementation.

We now have stubs for setting and deleting attributes as well, though
these currently always fail.
2022-01-08 10:38:01 +11:00
Luke Howard
27d62bb27e gss: avoid showing PAC in test_context if anon
The Heimdal KDC does not add a PAC if an anonymous ticket was issued. As such,
test_context should not expect PAC naming attributes to be present if the
--anonymous option was passed. (This is irrelevant for now as GSS_C_ANON_FLAG
is not honored by the krb5 mechanism.)
2022-01-08 10:12:07 +11:00
Luke Howard
402884a310 gss: validate attr enumeration in test_context
Ensure the "urn:mspac:client-info" name attribute is enumerated by
gss_inquire_name(), as well as being available via gss_get_name_attribute().
2022-01-08 09:38:30 +11:00
Luke Howard
e5e87497b1 hdb: use memset_s to zero HDB keys 2022-01-08 08:49:45 +11:00
Nicolas Williams
768d193e01 krb5: Fix warnings (from 54581d2d) 2022-01-06 16:24:08 -06:00
Nicolas Williams
2b9b701dc4 gss: Fix warnings (from be708ca3cf) 2022-01-06 16:21:55 -06:00
Nicolas Williams
3af6926c7d gss: Fix sign extension bug (from be708ca3cf)
When unsigned char values are shifted, they are promoted to int (unless
sizeof(int) == sizeof(char)).  This means that the change in be708ca3cf
ultimately leads to a sign extension bug.
2022-01-06 15:25:38 -06:00
Luke Howard
e06eeb5256 roken: use %zu format string for size_t 2022-01-06 22:36:48 +11:00
Luke Howard
90704baf76 asn1: use %zu format string for size_t 2022-01-06 17:52:09 +11:00
Luke Howard
0a4830068f roken: use %zu format string for size_t 2022-01-06 17:52:00 +11:00
Luke Howard
97cca6f921 base: use uintptr_t for hash type
Use uintptr_t for hash type; this is consistent with CoreFoundation, which uses
32-bit integers on 32-bit platforms for the hash code, and 64-bit integers on
64-bit platforms. (libheimbase is modelled on CoreFoundation.)

Previously we used unsigned long, which would have the same behavior on
LP32/LP64 systems, but not on Windows (where unsigned long is 32-bits on 64-bit
platforms).
2022-01-06 17:21:06 +11:00
Jeffrey Altman
6b788c2378 lib/asn1: template cast integer const to uintptr_t then void ptr
Cast integer constants to (void *) with an intermediate cast to
(uintptr_t).   On Windows this avoid warnings about a signed
integer being cast to a pointer of larger size.

No functional change.

Change-Id: I7289fb772870c5f492c1a8b988e0d80cf008b7f4
2022-01-05 19:56:43 -05:00
Nicolas Williams
2375fa9d1e gss: Too many compilers don't support 'restrict' 2022-01-05 18:03:39 -06:00
Nicolas Williams
01b1916ec2 asn1: Close _files output last 2022-01-05 17:50:00 -06:00
Jeffrey Altman
9427796f1a Generate .x source files as .c source files
The generated .x source and .hx header files are plain C source files.
Generate them as .c source files and avoid unnecessary file copying
and special makefile rules.

Change-Id: Ifc4bbe3c46dd357fdd642040ad964c7cfe1d395c
2022-01-05 17:36:24 -06:00
Nicolas Williams
4919daa7ab appveyor: Use VS 2019 image to get working msys2
The msys2 installation on Appveyor's Windows build images older than
Visual Studio 2019 are hopelessly out of date.

Diagnostics from the msys2 crew:

 - https://github.com/msys2/MSYS2-packages/issues/2785
 - 5fc9d54289

Ticket opened with Appveyor about this:

 - https://help.appveyor.com/discussions/problems/31153-default-windows-image-msys2-repos-out-of-date
2022-01-05 12:59:35 -06:00
Jeffrey Altman
fb1ded497a lib/asn1: gen_template cast integer const to uintptr_t then void ptr
When generating code cast integer constants to (void *) with an
intermediate cast to (uintptr_t).   On Windows this avoid hundreds
of warnings about a signed integer being cast to a pointer of larger
size.

No functional change.

Change-Id: Ifd2acd0cfe99a7859aad58e79ab0f0c12b28fdeb
2022-01-05 12:58:48 -06:00
Jeffrey Altman
42ad8b4c55 lib/asn1: build static runtime version of libasn1 on Windows
This commit builds a static runtime version of the asn1 library
which is required for some thirdparty applications.

  LIBASN1_S   =$(LIBDIR)\libasn1_s.lib

This differs from libasn1.lib which is compiled to use the
dynamic runtime.

Change-Id: Ib04f5b53a7f16d7bbe9d2debb75e944322a6792a
2022-01-05 12:58:48 -06:00
Jeffrey Altman
6694f98791 lib/asn1: gen require ASN1_LIB be defined on Windows when compiling
Instead of defining ASN1_LIB in each of the generated ASN1 source
files require that the generated source file be compiled with the
ASN1_LIB symbol defined (on Windows).  All of the compiled objects
linked into the same library which might be accessing an ASN1 exported
symbol must have ASN1_LIB defined to ensure that the use of the
exported symbols will not be via an import.

Change-Id: Ie38c105d1d376419717fce0830dc28f5b82547d4
2022-01-05 12:58:48 -06:00
Jeffrey Altman
4f4d1a0288 lib/hdb: define LIB_ASN1 on Windows if ASN1 generated objects
The LIB_ASN1 definition instructs the library objects to access
exported ASN1 generated DATA symbols as internal symbols.

Change-Id: I58b055808893c6f3af48fc2dd997e0dedea2ffcb
2022-01-05 12:58:48 -06:00
Jeffrey Altman
3efca1e98a lib/gssapi: define LIB_ASN1 on Windows if ASN1 generated objects
The LIB_ASN1 definition instructs the library objects to access
exported ASN1 generated DATA symbols as internal symbols.

Change-Id: Ia8c674c879c9bc46ca9dc7f249114f22b1d0dfd5
2022-01-05 12:58:48 -06:00
Jeffrey Altman
0a7d227788 lib/asn1: define LIB_ASN1 when building Windows ASN1 libraries
The LIB_ASN1 definition instructs the library objects to access
exported DATA symbols as internal symbols.

Change-Id: Ifbc80a4e3c357cb323f7763c116101ae495b11df
2022-01-05 12:58:48 -06:00
Jeffrey Altman
a4ba38ff7e asn1: NTMakefile include oid_resolution.obj in LIBASN1_OBJS
oid_resolution.obj does not depend upon $(LIBASN1_OBJ) object
files.  It depends upon the generated .x files produced by
asn1_compile.exe when building $(gen_files_xxx).   Create a
new list of those dependencies explicitly for oid_resolution.obj.

Change-Id: I09a4dc9efb7a84e68da939b6a3ec5f55354c02ee
2022-01-05 12:58:48 -06:00
Luke Howard
ec866e635e Windows 10 SDK build fixes
Build without Win32.mak, and using Universal C Runtime (UCRT)

windows: Check for APPVER, not VCVER for UCRT

When deciding whether UCRT is used (and thus no CRT merge modules), check for
Windows 10 rather than the version of Visual Studio, as we may be building with
an older SDK.
2022-01-05 12:58:48 -06:00
Luke Howard
7cc4b7a9e6 kdc: KDC plugin API contract notes
Add some notes about the KDC plugin API contract, and require plugins to
explicitly indicate which version of the API they support (remove the macro
alias for the current version).
2022-01-05 13:08:11 +11:00
Luke Howard
78ad37ee47 kdc: use r->canon_client_princ field in AS
r->canon_client_princ is always an alias to r->client->entry.principal in the
AS, but use it for consistency with the TGS. (In the TGS, it may also come from
te PAC.)
2022-01-05 13:01:06 +11:00
Luke Howard
0287558838 kdc: move Services for User implementation out of krb5tgs.c
Move the Services for User (SFU/S4U) implementation -- protocol transition and
constrained delegation -- into its own compilation unit, with an interface that
only takes an astgs_request_t, so it can be easily factored out into a plugin
module in the future.

This refactoring is also careful to update all client names in the request
structure after the SFU/S4U validation has successfully completed.
2022-01-05 13:01:06 +11:00
Luke Howard
06f8985c55 hdb: consolidate preauth audit event types
Instead of having distinct preauth success/failure events for different
mechanisms, have a single event; the mechanism can be disambiguated by querying
the HDB_REQUEST_KV_PA_NAME key.

Note: there is still an explicit event for long-term key-based success/failure
in order to help the backend implement lockout.

Audit failure (HDB_AUTH_EVENT_PREAUTH_FAILED) in the main preauth loop, rather
than in each mechanism. Success is still audited in the mechanism to allow
client pre-authentication success to be noted even if something subsequent
(e.g. encoding a reply, memory allocation) fails. The generic catch-all for
success remains.
2022-01-05 09:42:03 +11:00
Luke Howard
68c4fd6572 kdc: audit preauth event only at end of PA loop
Don't audit preauth event if the preauth mech returns
KRB5_KDC_ERR_MORE_PREAUTH_DATA_REQUIRED; only set the event on (final) failure
or success.
2022-01-05 09:37:55 +11:00
Luke Howard
d90718c9b6 base: set HEIM_JSON_F_NO_DATA_DICT in heim_audit_setkv_object()
Fixes pretty-printing data print to work with heim_audit_setkv_object() as well
as heim_audit_addkv_object().
2022-01-04 06:30:32 +00:00
Luke Howard
503cb27740 base: add heim_data_t support to heim_audit_trail()
Allow heim_audit_trail() to log heim_data_t types.
2022-01-04 17:17:56 +11:00
Luke Howard
2574648308 base: pretty-print heim_data_t when debug logging 2022-01-04 17:10:33 +11:00
Jeffrey Altman
bda5919f6b Windows: MSVC does not support 'restrict' keyword
Use of the C99 'restrict' keyword was introduced by
be708ca3cf
("gsskrb5: Add simple name attributes support")

Change-Id: I8272f595af53741ee7c59750bb2d388faeb01f8f
2022-01-03 22:46:08 -05:00
Luke Howard
466658e929 Revert "Windows 10 SDK build fixes"
This reverts commit ceef0a0089.
2022-01-04 14:44:13 +11:00
Luke Howard
6d505df510 gss: link test_names.exe against Heimdal DLL 2022-01-04 14:35:28 +11:00
Nicolas Williams
b102c3c27f krb5: Fix canon name w/ attrs issue 2022-01-03 20:39:12 -06:00
Nicolas Williams
9e683f3d9a asn1: Fix template decoration copy moar 2022-01-03 20:39:12 -06:00
Luke Howard
bb699fb819 kdc: audit requestor SID in altsecid GSS PA plugin 2022-01-04 02:30:42 +00:00
Luke Howard
efdd0bda24 base: export heim_audit_addkv_{number,object} 2022-01-04 02:22:23 +00:00
Luke Howard
d0c861a2d3 kdc: fix build regression in fixing Windows build
Fix regression introduced in 7bb00a40; need to pass -E KDC_LIB to make-proto.pl
in Makefile.am, as well as NTMakefile.
2022-01-04 13:14:06 +11:00
Luke Howard
daf1eacfdb base: cast int64_t to long long
In heim_audit_{add,set}kv_number, cast int64_t to long long/use %lld format
string, to avoid compiler warnings.
2022-01-04 13:12:41 +11:00
Luke Howard
7bb00a40ea kdc: fix Windows build 2022-01-04 13:08:35 +11:00
Luke Howard
a1fd5c176d kdc: fix misplaced semi-colons in ASTGS_REQUEST
ASTGS_REQUEST_DESC_COMMON_ELEMENTS should not terminate in a semi-colon;
the consuming structure should include it. This is consistent with
HEIM_SVC_REQUEST_DESC_COMMON_ELEMENTS. This fixes the build on Windows.
2022-01-04 13:07:18 +11:00
Luke Howard
4803969580 gssapi: add name_attrs.c to Windows build 2022-01-04 13:06:48 +11:00
Luke Howard
e0ea123e1c asn1: export CompositePrincipal on Windows
Export CompositePrincipal functions on Windows, because libasn1
functions are explictiyl exported (unlike with libtool).
2022-01-04 13:06:02 +11:00
Luke Howard
d77e9988ec kdc: add _kdc_audit_addkv_{number,object}
Wrappers for new auditing functions in libheimbase.
2022-01-04 12:37:39 +11:00
Luke Howard
3b7a17e8b1 base: heim_audit_{add,set}kv_number should take int64_t
heim_number_t holds int64_t, not intptr_t; adjust heim_audit_{add,set}kv_number
accordingly. The libkdc wrapper functions were previously updated.
2022-01-04 12:35:57 +11:00