Commit Graph

30913 Commits

Author SHA1 Message Date
Nicolas Williams
788e2ee3c3 roken: Fix getarg run-on help bug 2026-01-18 16:08:39 -06:00
Nicolas Williams
5fa7d6edd8 roken: Add getdelim()/getline()
Ported from lib/libedit's.
2026-01-18 16:08:39 -06:00
Nicolas Williams
e60f02aed1 roken: Use secure_getenv() in socket_wrapper 2026-01-07 17:49:17 -06:00
Nicolas Williams
771fb1c367 roken: Split up mini_inetd_addrinfo()
To speed up tests/gss/check-gssmask we need to remove the `sleep 10`
found there, and to do that we need to make the gssmask daemons use
roken_detach_prep()/roken_detach_finish(), and to do that we need to
split up mini_inetd_addrinfo().

This commit authored by Claude with human guidance and review.
2026-01-07 17:49:17 -06:00
Nicolas Williams
0d2ee355ee tests: Fix intr --version 2026-01-07 17:49:17 -06:00
Nicolas Williams
7cc3f3bbc8 cf: Add support for using Helgrind 2026-01-07 17:49:17 -06:00
Nicolas Williams
f052cdc8e5 cf: Use valgrind w/ --show-leak-kinds=definite to reduce noise 2026-01-07 17:49:17 -06:00
Nicolas Williams
c3a88a61b7 include: Fix leak in bits.c 2026-01-07 17:49:17 -06:00
Nicolas Williams
7c8ef887d4 doc: Obsolete the Layman's Guide to ASN.1 2026-01-07 17:49:17 -06:00
Nicolas Williams
907d6195f5 GHA: Set core pattern on Linux 2026-01-07 16:20:46 -06:00
Nicolas Williams
55a8949f2a GHA: Always grab the test logs, core dumps 2026-01-07 16:20:46 -06:00
Nicolas Williams
1c9f184561 GHA: Get GHA working again 2025-12-08 20:32:13 -06:00
Jan Palus
7510cc5ba2 cf/largefile.m4: improve compatibility with autoconf 2.72
as of autoconf 2.72 neither ac_cv_sys_large_files nor
ac_cv_sys_file_offset_bits are populated. 1b57b62 introduced a
workaround just for ac_cv_sys_file_offset_bits by checking if it's not
empty.

expand fix to cover ac_cv_sys_large_files as well and check
ac_cv_sys_largefile_opts which is populated in autoconf 2.72 [1]

1. https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=cf09f48841b66fe76f606dd6018bb3a93242a7c9
2025-10-09 12:46:44 -04:00
Jeffrey Altman
de6776e66b appl/test: AUTOMAKE_OPTIONS = subdir-objects
Avoid the following warning

   warning: source file '../../kuser/kinit.c' is in a subdirectory,
   but option 'subdir-objects' is disabled
2025-10-09 12:41:39 -04:00
Ivan Korytov
5cf652bf35 kdc: Fix memory leak of encrypted preauthentication data
Deallocate r->ek.encrypted_pa_data after response was sent to client.

Signed-off-by: Ivan Korytov <korytovip@basealt.ru>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2025-10-09 12:33:43 -04:00
Daria Phoebe Brashear
de065a739b update workflow artifacts to v4 to get the check infrastructure working again 2025-10-09 10:46:05 -04:00
Daria Phoebe Brashear
7e4950042c update artifacts version to v4 for github workflows 2025-10-09 10:39:57 -04:00
abstrm
14c78d8837 Update copyright.texi with LibTomMath Unlicense (#1283)
Co-authored-by: Alexander Boström <abo@root.snowtree.se>
2025-10-09 09:56:02 -04:00
Stefan Metzmacher
8c3c97bdf6 gsskrb5: let GSS_C_DCE_STYLE imply GSS_C_MUTUAL_FLAG as acceptor
Windows clients forget GSS_C_MUTUAL_FLAG in some situations where they
use GSS_C_DCE_STYLE, in the assumption that GSS_C_MUTUAL_FLAG is
implied.

Both Windows and MIT as server already imply GSS_C_MUTUAL_FLAG
when GSS_C_DCE_STYLE is used.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2025-04-16 12:59:37 -04:00
Ihar Hrachyshka
f0fd2d51b6 Link tests with -lresolv that depend on it 2025-04-16 10:37:27 -04:00
Stefan Metzmacher
50067e8171 kdc: clear et->flags.ok_as_delegate if cross-realm krbtgt does not have it
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2025-04-16 10:27:45 -04:00
Stefan Metzmacher
225d1c4c0e kdc: Constrained delegation requires a local delegating server
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15837

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2025-04-16 10:27:19 -04:00
Stefan Metzmacher
c0f63fba5c kdc: KRB5_ANON_REALM needs 'const Realm'
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2025-04-16 10:25:39 -04:00
Jeffrey Altman
c3bd400fa2 base: heim_config_parse_file_multi fix plist config parsing
4c34168b01 ("base: Fix use of
HEIM_USE_PATH_TOKENS") relocated the expansion of path tokens
within heim_config_parse_file_multi() so it is only performed
for non-plist files.  However, parse_plist_config() does not
understand tokens and will treat them as path components.  As
a result, plist paths such as

  %{USERCONFIG}/Library/Preferences/com.apple.Kerberos.plist

will not be expanded. If parse_plist_config() fails with ENOENT,
then the plist configuration will be skipped and krb5_init_context()
will succeed.  However, if the current working directory is invalid,
then parse_plist_config() would return ENOMEM which is a fatal
error and krb5_init_context() would fail.

For example, on macOS, if the cwd is in /afs and the user's
tokens have expired:

  user@MacBookAir user % ~/src/heimdal/kuser/heimtools klist
  shell-init: error retrieving current directory:
  getcwd: cannot access parent directories: Permission denied
  chdir: error retrieving current directory:
  getcwd: cannot access parent directories: Permission denied
  heimtools: krb5_init_context failed: 12

With this change %{USERCONFIG} is expanded and parse_plist_config()
is called with an absolute path.  Even though the specified file
is inaccessible, the krb5_init_context() call succeeds.
2025-04-16 10:25:24 -04:00
Jeffrey Altman
fd85f7ccb6 base: parse_plist_config CFReadStreamCreateWithFile fail errors
If parse_plist_config() is called with a non-absolute path which
is defined as a path whose first character is not '/', then
CFReadStreamCreateWithFile() must determine the current working
directory in order to return a CFURLRef to an absolute path.
If getcwd() fails, then CFReadStreamCreateWithFile() returns
NULL.

Instead of unconditionally returning ENOMEM when NULL is returned,
check if the path is non-absolute and call getcwd().  If getcwd()
fails, return errno.  Otherwise, return ENOMEM.  This permits
ENOENT (a component of the pathname no longer exists) or EACCES
(read or search permission was denied for a component of the
pathname) to be returned as the reason.

ENOMEM is a fatal error when constructing the configuration for
krb5_init_context() whereas ENOENT and EACCES are not fatal.

Without this patch on macOS, if the cwd is in /afs and the user's
tokens have expired, then krb5_init_context() fails with ENOMEM (12).

  user@MacBookAir user % ~/src/heimdal/kuser/heimtools klist
  shell-init: error retrieving current directory: \
    getcwd: cannot access parent directories: Permission denied
  chdir: error retrieving current directory: \
    getcwd: cannot access parent directories: Permission denied
  heimtools: krb5_init_context failed: 12

With this change krb5_init_context() succeeds.
2025-04-16 10:25:24 -04:00
Jeffrey Altman
caf18a8ef4 cf: dns_search test requires resolv library
When building for Apple operating systems rk_dns_lookup() must
use dns_search() instead of res_search().  Although res_search()
is available, it only issues queries using the /etc/resolv.conf
configuration.  Whereas dns_search() will issue the query against
alternate resolver configurations such as those created by VPN
services.
2025-04-16 09:30:28 -04:00
czurnieden
fd2d434dd3 libtommath: Fix possible integer overflow CVE-2023-36328
Cherry picked from libtommath 7bbc1f8e4fe6dce75055957645117180768efb15.

Vulnerability Detail:
  CVE Identifier: CVE-2023-36328
  Description: Integer Overflow vulnerability in mp_grow in libtom
    libtommath before commit beba892bc0d4e4ded4d667ab1d2a94f4d75109a9,
    allows attackers to execute arbitrary code and cause a denial of
    service (DoS).
  Reference: https://nvd.nist.gov/vuln/detail/CVE-2023-36328

Reported-by: https://github.com/Crispy-fried-chicken
2024-09-10 09:00:32 -04:00
Jeffrey Altman
614bc16130 update .gitignore
/confdefs.h
/conftest.c
/conftest.err
/tmp.h
2024-09-04 10:24:44 -04:00
Nicolas Williams
305ab03155 krb5: Fix DNS SRV name collision handling 2024-09-03 15:14:42 -04:00
Jeffrey Altman
8d20888e09 krb5: Red Hat gssproxy FILE ccache remove cred compatibility
gssproxy stores its credentials to the ccache with endtime == 0.
Therefore, it is not safe to skip ccache entries unless authtime
is non-zero as well.
2024-09-03 14:19:20 -04:00
Jeffrey Altman
b7e699597e krb5: MIT krb5 FILE ccache remove cred compatibility
MIT commit d3b39a8bac6206b5ea78b0bf6a2958c1df0b0dd5 implemented
krb5_cc_remove_cred() for FILE ccaches by setting endtime to zero
and authtime to minus one and then filtering out those credentials
from get_next().

This change sets "authtime = -1" for the removed cred to permit
MIT krb5 to ignore removed credentials from a shared FILE ccache.

MIT commit 4c0838bb4c232866b95c9f2f72a55bf77cfc1308 modified the
cred_removed() check to restore compatibility with Heimdal.
2024-09-03 14:19:20 -04:00
Jeffrey Altman
68dbf1ba10 krb5: fcc_next_cred do not return removed creds
commit a9bd3c6e50 ("Fix racy file ccache
corruption in cred_delete()") implemented krb5_cc_remove_cred() for
"FILE" ccaches by overwriting the removed credential endtime value
with zero (Unix Epoch).  However, it did not modify fcc_get_next()
to filter out these deleted entries.  As a result, invalid credentials
can be returned from the FILE ccache where endtime < starttime.
RFC4120 requires endtime >= starttime for all tickets.

MIT Kerberos since d3b39a8bac6206b5ea78b0bf6a2958c1df0b0dd5
("Implement krb5_cc_remove_cred for remaining types") modifies a
removed cred by setting

  endtime = 0
  authtime = -1

and then filters out removed creds from the fcc_next_cred() results.

In 2013 Heimdal broke interop with MIT processes that share the
FILE ccache by implementing remove by setting "endtime = 0" and
now MIT has broken interop with the Heimdal implementation of
fcc_remove_cred() by checking for both "endtime = 0" and "authtime = -1".

This change filters results from fcc_get_next() when the "endtime == 0"
which is acceptable because a KDC is not permitted to return a
ticket with an endtime == 0.
2024-09-03 14:19:20 -04:00
Jeffrey Altman
ec37879038 appl/tests: auditdns eliminate use of 'restrict' keyword if !C99
The 'restrict' keyword was introduced in C99 and provides a hint to
the compiler that can be used to better optimized code.  The 'restrict'
keyword results in build failures when the compiler is not C99.

  auditdns.c:101:37: error: expected ‘;’, ‘,’ or ‘)’ before ‘hints’
     const struct addrinfo *restrict hints,
                                     ^
  auditdns.c:409:45: error: expected ‘;’, ‘,’ or ‘)’ before ‘sa’
     getnameinfo(const struct sockaddr *restrict sa, socklen_t salen,
                                                 ^

This change defines 'register' to nothing if the compiler does not
implement the C99 standard.

Observed with gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44).
2024-09-03 13:41:22 -04:00
Stefan Metzmacher
2262e19a40 lib/gssapi/krb5: don't ignore _gsskrb5_decapsulate() result in init_sec_context responses
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15603

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2024-09-03 13:38:15 -04:00
Jo Sutton
99a53d76e6 krb5: Correct inverted conditions
Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
2024-09-03 13:35:38 -04:00
Jeffrey Altman
347822cf76 ENABLE_AFS_STRING_TO_KEY requires crypt()
If crypt() is unavailable then DES_AFS3_string_to_key() cannot be
implemented for passwords up to 8 characters in length.  Do not
advertise support for "afs3-salt" when crypt() is missing.
2024-09-03 13:31:34 -04:00
Jeffrey Altman
b09f3b3c28 otp: prevent implicit function declarations if HAVE_DB_NDBM
include ndbm.h if HAVE_DB_NDBM is defined to avoid implicit function
declarations.
2024-09-03 13:30:37 -04:00
Florian Weimer
323d555c82 cf: Do not use headers and argument lists in AC_FIND_FUNC_NO_LIBS2
The callers of this macro generally do not supply this information.
Without it, the checks rely on compiler support for implicit function
declarations.  It would be possible to supply this information in
the callers.  But even then, with the existing macro interface, it
would be necessary to pass eg. null pointers where they trigger
undefined behavior.  Therefore, use the same kludge that autoconf
uses to make up prototypes, avoiding those implicit function
declarations.

The includes/arguments macro parameters are now ignored, but preserved
for interface compatibility.
2024-09-03 11:12:23 -04:00
Florian Weimer
c711cbf7cc cf: Include <string.h> for memset in AC_HAVE_STRUCT_FIELD
Otherwise, the check relies on an implicit function declaration,
and will fail unconditionally with compilers that do not support
them.
2024-09-03 11:12:23 -04:00
Robert Manner
78f017fe01 krb5/fast.c: fix copying source/dest for copy_KrbFastArmor
if using armoring service.
2024-09-02 14:01:39 -04:00
Stefan Metzmacher
ba8c3dbc62 lib/gssapi/krb5: implement GSS_C_CHANNEL_BOUND_FLAG for gss_init_sec_context()
This will force KERB_AP_OPTIONS_CBT to be sent.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2024-07-06 16:14:43 -04:00
Jo Sutton
6b08c05258 kdc: Enforce hardware authentication for accounts requiring it
Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
2024-07-06 16:08:56 -04:00
Ralph Boehme
a2a765f88e lib/krb5: initialize kdc_offset in the memory ccache from the krb5_context
This ensures we inherit the clock skew adjustment from the AS-REQ/REP into the
memory ccache in a similar way done for the file ccache.

This means krb5_cc_get_kdc_offset() will return the correct value and
_krb5_get_cred_kdc_any() uses the adjusted time in the authenticator of
subsequent TGS-REQ.

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

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2024-07-06 16:07:17 -04:00
Ralph Boehme
c2e68593a5 lib/krb5: use check_fast() in _krb5_fast_unwrap_error()
At least Windows KDCs return KRB5KRB_AP_ERR_SKEW without edata in
response to TGS-REQ.

This ensures the callers see the KRB5KRB_AP_ERR_SKEW error and not
KRB5_KDCREP_MODIFIED "FAST fast response is missing FX-FAST".

For the response to an amored AS-REQ, we'll now return
KRB5KRB_AP_ERR_MODIFIED instead of KRB5_KDCREP_MODIFIED,
but if there's an attack the exact error code doesn't matter.

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

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2024-07-06 16:07:17 -04:00
Simon Wilkinson
2f7a9d9530 gssapi: Fix ordering logic in _gssapi_msg_order_check
A typo in _gssapi_msg_order_check means that sequence numbers
received out of sequence are not correctly added to the internal
order array.
2024-07-06 16:06:54 -04:00
Simon Wilkinson
05e292e1af gssapi: Sequence errors should not be fatal
Sequence errors are supplemental information in GSSAPI. This means
that they are not fatal, unless they are returned alongside a failure
error code. This change makes our behaviour the same as MIT's - sequence
errors are non-fatal, and return valid output information.
2024-07-06 16:06:54 -04:00
Bernd Kuhls
1b57b62d82 cf/largefile.m4: Fix build with autoconf-2.72
Fixes https://github.com/heimdal/heimdal/issues/1201
2024-06-16 23:31:51 -04:00
Minsoo Choo
aff90c322e Fix spelling 2024-06-16 23:30:48 -04:00
Michael Tokarev
c80c04b235 spelling fixes (underun prefered relase encyption confunder)
[abartlet@samba.org: From Samba debian package at
 https://salsa.debian.org/samba-team/samba/-/blob/master/debian/patches/heimdal-spelling.patch?ref_type=heads]

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2024-06-16 23:28:43 -04:00
Jeffrey Altman
c753ed5b7f kdc: APPLE disable enable-pkinit by default as documented
commit 4d48b172ab ("add pkinit
configration for btmm") introduced automatic configuration of
the 'pkinit_kdc_identity' and 'pkinit_kdc_friendly_name' on macOS
but also modified the default for the 'enable_pkinit' setting
such that pkinit is enabled on all __APPLE__ platforms overriding
the [kdc] enable-pkinit setting obtained from the configuration.

This change modifies the enable-pkinit behavior on __APPLE__ platforms
to match those on every other platform.  __APPLE__ platforms will
continue to auto-configure the [kdc] pkinit_identity and
[kdc] pkinit_anchors if they are not specified in the configuration.
2024-06-16 23:27:37 -04:00