247 Commits

Author SHA1 Message Date
Taylor R Campbell
997916e3f6 krb5: Make heimdal_version and heimdal_long_version const.
Pretty sure it is not useful for applications to be able to write to
this.

However, caveat: this could break programs that expect to pass around
&heimdal_version or &heimdal_long_version to functions that expect
pointers to non-const objects even if they don't modify them.
2023-06-20 12:19:48 -05:00
Jeffrey Altman
36cf07bc44 Windows: define __func__ in terms of __FUNCTION__
_MSC_VER < 1900 does not provide __func__.   Where it is not
available use __FUNCTION__ instead.

Change-Id: I6624d2d429e90c993ad103cb83e6f61a58a5f800
2022-11-16 21:40:02 -05:00
Nicolas Williams
3a5e91eca2 hcrypto: Remove MD2 with prejudice
We don't use it anywhere for anything.
2022-11-01 16:10:57 -05: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
Jeffrey Altman
04527412e3 Follow the Linux kernel's lead on "fallthrough"
The pseudo keyword 'fallthrough' is defined such that case statement
blocks must end with any of these keywords:
 * break;
 * fallthrough;
 * continue;
 * goto <label>;
 * return [expression];
 *
 *  gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes

The macro is defined either as

  __attribute__((__fallthrough__))

or as

  do {} while (0)  /* fallthrough */

not including the semicolon.

This change implements the Linux kernel style and updates several locations
where "/*fallthrough*/ and /* FALLTHROUGH */ were not previously replaced.

Externally imported code such as libedit, libtommath and sqlite are
restored to their unaltered state.

Change-Id: I69db8167b0d5884f55d96d72de3059a0235a1ba3
2022-01-21 10:39:47 -05:00
Luke Howard
ec24edf700 kdc: add accessor functions for KDC request structure
Add accessor functions for use by Samba and other plugin developers.
Documentation is in kdc/kdc-accessors.h.
2022-01-20 17:23:24 +11:00
Luke Howard
f4e936c893 include: fix token_validator_plugin.h typo
token_validator_plugin.h was also missing in Makefile.am:CLEANFILES.
2022-01-20 17:23:11 +11:00
Luke Howard
0c26edd468 include: add more generated files to CLEANFILES
take #2, fix build breakage.

Recently added features for Heimdal 8 did not update
include/Makefile.am:CLEANFILES appropriately.
2022-01-20 17:17:58 +11:00
Luke Howard
d74b411f12 Revert "include: add more generated files to CLEANFILES"
This reverts commit 622527d9ca.
2022-01-20 17:17:09 +11:00
Luke Howard
622527d9ca include: add more generated files to CLEANFILES
Recently added features for Heimdal 8 did not update
include/Makefile.am:CLEANFILES appropriately.
2022-01-20 17:15:51 +11:00
Nicolas Williams
ddc6113610 Use fallthrough statement attribute 2022-01-14 16:32:58 -06:00
Nicolas Williams
94bb267a8b roken: Delete getcap/cgetent/cgetstr() 2022-01-14 12:01:33 -06:00
Jeffrey Altman
4caaa7ca0b include: bits conditionalize behavior on HAVE_SNPRINTF
ee2a92c547 ("bits: Fix warnings")
introduced unconditional use of snprintf().   Use of snprintf in
most of the tree is acceptable whenever roken is available because
roken provides snprintf() for platforms that do not provide it.
However, bits.c cannot use roken and therefore must not
unconditionally call snprintf().

This change restores the prior implementation of BITSIZE(TYPE)
when HAVE_SNPRINTF is undefined.

Change-Id: Ibbd2f003abe9f9fb612719266544cfd545809a18
2022-01-14 12:17:39 -05:00
Nicolas Williams
ee2a92c547 bits: Fix warnings 2022-01-13 15:33:04 -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
466658e929 Revert "Windows 10 SDK build fixes"
This reverts commit ceef0a0089.
2022-01-04 14:44:13 +11:00
Luke Howard
ce58eb9081 kdc: annotate libkdc Windows function annotations
Annotate libkdc APIs with KDC_LIB_{CALL,FUNCTION} to ensure correct calling
convention and optimized DLL importing on Windows.

Ensure Windows and libtool export tables are consistent.
2022-01-04 12:27:43 +11:00
Luke Howard
ceef0a0089 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-03 09:25:18 -05:00
Luke Howard
fcff5933ad kdc: rename windc to kdc plugin
Rename the "windc" plugin API to the more general "kdc" plugin API, for two
reasons: the Heimdal KDC uses the Windows PAC even when not emulating a domain
controller, and the plugin API has accreted methods that are not specific to
emulating a domain controller (such as referral_policy and finalize_reply).
2022-01-03 16:17:01 +11:00
Nicolas Williams
bacc484b2a krb5: Fix umask issue with SQLite3 2021-11-30 11:42:00 -05:00
Nicolas Williams
beae9c3c43 roken: Use ptsname_r() if we have it 2021-11-30 11:42:00 -05:00
Nicolas Williams
ed6f3f1786 autoconf: Remove unused tests 2021-11-30 11:42:00 -05:00
Luke Howard
504d059580 base: use heim_base_atomic_load in heimqueue.h
Use heim_base_atomic_load() rather than heim_base_exchange_pointer() when
iterating an atomic SLIST
2020-07-14 09:35:14 +10:00
Nicolas Williams
ea90ca8666 Move some infra bits of lib/krb5/ to lib/base/ (2)
This is the second of two commits in a series that must be picked together.

This series of two commits moves parts of lib/krb5/ infrastructure
functionality to lib/base/, leaving behind wrappers.

Some parts of libkrb5 are entirely generic or easily made so, and could
be useful in various parts of Heimdal that are not specific to the krb5
API, such as:

 - lib/gssapi/  (especially since the integration of NegoEx)
 - lib/hx509/
 - bx509d       (which should really move out of kdc/)

For the above we need to move these bits of lib/krb5/:

 - lib/krb5/config_file.c   (all of it, leaving forwardings behind)
 - lib/krb5/config_reg.c    (all of it)
 - lib/krb5/plugin.c        (all of it, leaving forwardings behind)
 - lib/krb5/log.c           (all of it, ditto)
 - lib/krb5/heim_err.et     (all of it)

And because of those two, these too must also move:

 - lib/krb5/expand_path.c   (all of it, leaving forwardings behind)
 - lib/krb5/warn.c          (just the warning functions, ditto)

The changes to the moved files are mostly quite straightforward and are
best reviewed with --word-diff=color.

We're also creating a heim_context and a heim API to go with it.  But
it's as thin as possible, with as little state as necessary to enable
this move.  Functions for dealing with error messages use callbacks.

Moving plugin.c does have one knock-on effect on all users of the old
krb5 plugin API (which remains), which is that a global search and
replace of struct krb5_plugin_data to struct heim_plugin_data was
needed, though the layout and size of that structure doesn't change, so
the ABI doesn't either.

As well, we now build lib/vers/ and lib/com_err/ before lib/base/ so as
to be able to move lib/krb5/heim_err.et to lib/base/ so that we can make
use of HEIM_ERR_* in lib/base/, specifically in the files that moved.

Once this is all done we'll be able to use config files and plugins in
lib/hx509/, we'll be able to move bx509d out of kdc/, and so on.

Most if not all of the new functions in lib/base/ are Heimdal-private,
thus calling conventions for them are not declared.

Status:

 - builds and passes CIs (Travis, Appveyor)
 - ran make check-valgrind and no new leaks or other memory errors
 - ready for review

HOW TO REVIEW:

     $ # Review file moves:
     $ git log --stat -n1 HEAD^
     $
     $ # Review changes to moved files using --word-diff=color
     $ git log -p -b -w --word-diff=color HEAD^..HEAD   \
               lib/base/config_file.c                   \
               lib/base/config_reg.c                    \
               lib/base/expand_path.c                   \
               lib/base/warn.c                          \
               lib/krb5/config_file.c                   \
               lib/krb5/config_reg.c                    \
               lib/krb5/expand_path.c                   \
               lib/krb5/warn.c
     $
     $ # Review the whole thing, possibly adding -b and/or -w, and
     $ # maybe --word-diff=color:
     $ git log -p origin/master..HEAD
     $ git log -p -b -w origin/master..HEAD
     $ git log -p -b -w --word-diff=color origin/master..HEAD

TBD (future commits):

 - make lib/gssapi use the new heimbase functions
 - move kx509/bx509d common code to lib/hx509/ or other approp. location
 - move bx509d out of kdc/
2020-03-02 10:56:13 -06:00
Luke Howard
4fb6a6adc9 gss: port NegoEx implementation from MIT
An implementation of draft-zhu-negoex-04 for MIT Kerberos was developed in
2011. This has been recently integrated, with many fixes from Greg Hudson. This
commit ports it to Heimdal. The implementation has been interoperability tested
with MIT Kerberos and Windows, using the GSS EAP mechanism developed as part of
the Moonshot project.

The SPNEGO code was also updated to import the state machine from Apple which
improves mechListMIC processing and avoids discarding initial context tokens
generated during mechanism probing, that can be used for optimistic tokens.

Finally, to aid in testing, the GSS-API mechanism glue configuration file can
be changed using the environment variable GSS_MECH_CONFIG. This environment
variable name, along with the format of the configuration file, is compatible
with MIT (although it would be difficult for a single mechanism binary to
support both implementations).
2020-02-04 17:28:35 +11:00
Luke Howard
31af9ba703 gss: use tail queue instead of singly linked list in mechglue
The GSS mechglue uses singly linked lists for mechanisms and mechanism objects,
to which new entries are inserted at the head. This breaks ordering of
mechanisms specified in OID sets and in /etc/gss/mech, as they will be back to
front. Use a tail queue instead so that new entries are inserted at the end.
2020-02-04 17:28:35 +11:00
Luke Howard
d7138cfbe7 base: make heimqueue.h a shared header
Share heimqueue.h between base and asn1, to avoid duplication of code.
2020-02-04 17:28:35 +11:00
Viktor Dukhovni
96fd393d29 Disable Nagle in iprop master and slave 2019-10-03 15:52:15 -05:00
Rod Widdowson
e143639400 Windows: Windows CRT doesn't support %k as format for strftime
The fix involves:
  - Removing HAVE_STRFTIME from config.h.w32
  - Adding strftime.c to the makefile
  - Defining timezone and tzname to their windows equivalent
    for the compile of this module
2019-05-22 09:47:59 -04:00
Jeffrey Altman
1dd38cc3de lib/hx509: declare and apply HX509_LIB_xxx macros
libhx509 is not built according to the same export and calling conventions
on Windows as the other libraries.  This change declares and applies
HX509_LIB_FUNCTION, HX509_LIB_NORETURN_FUNCTION, HX509_LIB_CALL and
HX509_LIB_VARIABLE to lib/hx509.

As a result of this change the calling convention for exported functions
will be __stdcall instead of __cdecl.

Change-Id: Ibc3f05e8088030ef7d13798f1d9c9b190bc57797
2019-01-02 10:23:39 -06:00
Jeffrey Altman
bec4818943 WIN32: hint noreturn functions
apply __declspec(noreturn) compiler hints to functions that
do not return.

Change-Id: I3c6c4703c7235d1df3e21dccad5272ea4cddfd36
2019-01-02 10:23:39 -06:00
Luke Howard
7098aa038b Windows: remove reference to NetInfo 2019-01-01 12:53:17 +11:00
Luke Howard
b9dcbe505d Windows: default client keytab to %{LOCAL_APPDATA}/Kerberos/client.keytab 2019-01-01 12:53:17 +11:00
Luke Howard
af0d8ef677 gssapi: support for client keytab in gss_acquire_cred (#383)
For compatibility with MIT Kerberos, support automatic acquisition of initiator
credentials if a client keytab is available. The default path on non-Windows is
/var/heimdal/user/%{euid}/client.keytab, but can be overriden with the
KRB5_CLIENT_KTNAME environment variable or the default_client_keytab_name
configuration option. If a client keytab does not exist, or exists but does not
contain the principal for which initiator credentials are being acquired, the
system keytab is tried.
2018-12-31 18:20:37 +11:00
Nicolas Williams
e2685c5b7c Add check for getpw*_r() 2018-12-25 22:11:19 -06:00
Nicolas Williams
a988692434 Add check for getlogin_r() 2018-12-25 22:11:19 -06:00
Nicolas Williams
8fae8a1826 Remove iruserok() 2018-12-25 22:11:19 -06:00
Nicolas Williams
3b8c762dd0 Remove lib/roken glob()
We no longer use it since removing ftp from appl/.

Note that expansion of ~username/ couldn't have been working because
k_getpwnam() was being called with an unsigned short * that was forcibly
cast to char *, but it really was shorts, not chars...  Anyone who ever
feels like reviving lib/roken/glob.[ch] will want to fix that...
2018-12-25 22:11:19 -06:00
Luke Howard
fb81598d44 krb5: port MIT Linux keyring credentials cache (#166) 2018-12-24 18:17:32 +11:00
Daria Phoebe Brashear
39b78ad6ce sunpro c defines __SUNPRO_C not __SUNPRO_CC
CC is the c++ compiler; C is the c compiler. use the correct define
2018-04-19 13:12:59 -04:00
Nicolas Williams
123f702001 lib/roken: add fseeko()/ftello() 2017-05-26 23:24:30 -04:00
Nicolas Williams
6a0f45c4d7 Use __attribute__ ((__name__)) form
Protect against macros named noreturn and so on.
2017-03-13 18:39:41 -04:00
Nicolas Williams
3e65dfbc32 Fix make dist missing files (#228) 2016-12-15 12:15:56 -06:00
Nicolas Williams
e75be174e0 Fix Windows build perl issue 2016-12-08 17:52:52 -06:00
Nicolas Williams
1c81ddf4e2 Round #2 of scan-build warnings cleanup 2016-11-16 17:03:14 -06:00
Viktor Dukhovni
a3eb786491 Finish X removal 2016-11-14 16:02:43 -05:00
Viktor Dukhovni
bb507cd4d4 Goodbye push 2016-11-14 14:19:58 -05:00
Viktor Dukhovni
b77e701a22 Goodbye login 2016-11-14 02:59:12 -05:00
Viktor Dukhovni
63d2935c4f Goodbye FTP 2016-11-14 02:42:08 -05:00
Jelmer Vernooij
0113798b18 Don't put system architecture in generated headers.
Including HOST causes the build to be unreproducible.
2016-05-15 23:04:49 +00:00