41 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
Nicolas Williams
123f702001 lib/roken: add fseeko()/ftello() 2017-05-26 23:24:30 -04: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
Nicolas Williams
490337f4f9 Make OpenSSL an hcrypto backend proper
This adds a new backend for libhcrypto: the OpenSSL backend.

Now libhcrypto has these backends:

 - hcrypto itself (i.e., the algorithms coded in lib/hcrypto)
 - Common Crypto (OS X)
 - PKCS#11 (specifically for Solaris, but not Solaris-specific)
 - Windows CNG (Windows)
 - OpenSSL (generic)

The ./configure --with-openssl=... option no longer disables the use of
hcrypto.  Instead it enables the use of OpenSSL as a (and the default)
backend in libhcrypto.  The libhcrypto framework is now always used.

OpenSSL should no longer be used directly within Heimdal, except in the
OpenSSL hcrypto backend itself, and files where elliptic curve (EC)
crypto is needed.

Because libhcrypto's EC support is incomplete, we can only use OpenSSL
for EC.  Currently that means separating all EC-using code so that it
does not use hcrypto, thus the libhx509/hxtool and PKINIT EC code has
been moved out of the files it used to be in.
2016-04-15 00:16:17 -05:00
Bernard Spil
858480145b Refactor EGD conditional support
As per Jeremy's request in #124
Windows does not define HAVE_RAND_EGD resulting in the same conditional
support for EGD.
2015-04-21 10:04:08 +02:00
Nicolas Williams
3e74e2e3bb Fix some DLL hell: use dladdr() to find plugin dir
Normally one would dlopen() a shared object's basename, not its absolute
path.  However, lib/krb5/plugin.c, in an effort to be zero-conf-ish,
wants to readdir() to find plugins to load, and in the process it ends
up defeating the RTLD's search-the-caller's-rpath.

This commit partially addresses this by allowing the use of $ORIGIN in
plugin_dir values and using them for the default (except on OS X).

This allows multiple Heimdal versions installed on the same host, but
with different plugin ABIs, to co-exist.  A step forward for doing make
check on hosts where Heimdal is installed.

For now we hardcode $ORIGIN/../lib/plugin/krb5 (linux, Solaris, *BSD),
or $ORIGIN (Windows; for assemblies objects need to be in the same
directory) and we eval $ORIGIN by using dladdr() (Linux, Solaris) or
GetModuleHandleEx() (Win32, via a dladdr() wrapper in libroken) to find
the path to libkrb5 whose dirname to use as $ORIGIN.  For Windows,
because we need the plugins to be in the same directory as libkrb5, we
require a prefix on plugin DLLs ("plugin_krb5_") to distinguish them
from other objects.

We should add a special token to mean "look in $ORIGIN, sure, but
dlopen() the plugin basenames only (so the RTLD can search the rpath)".
2013-09-06 16:51:53 -05:00
Asanka C. Herath
370e245ffc Windows: Only export through .def files
While we use __declspec(dllimport) to import from DLLs, we don't
use __declspec(dllexport) to export them.
2010-11-24 15:33:25 -05:00
Asanka C. Herath
d3582b56c6 Define and use a path separator string
A colon can't be used to separate paths on Windows since they are used
in drive sepecification.  Define a macro that can be used as a path
separator string.  On Windows, this is defined as ";".  It is a ":"
everywhere else.
2010-11-24 15:32:56 -05:00
Asanka Herath
efd02d929a Windows: No Fortuna method 2010-08-20 13:06:55 -04:00
Asanka Herath
8363d30a47 Remove commented code 2010-08-20 15:21:15 +08:00
Asanka Herath
e7337145ee Define HAVE_WINDNS and NO_LIMIT_FD_SETSIZE
HAVE_WINDNS is defined when we want to use DNSAPI on Windows which
handles most of the resolver work for us.

NO_LIMIT_FD_SETSIZE is defined if the value of a socket FD does not
imply anything about the number of sockets so far assigned.
I.e. checking if the socket is larger than FD_SETSIZE is incorrect.
2010-05-26 10:38:39 -04:00
Love Hornquist Astrand
b914fd57c5 remove NO_INETD by shuffling code around 2009-12-25 06:37:57 +01:00
Asanka Herath
b191b1e12f Make kdc build on windows
Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2009-11-24 22:19:37 -08:00
Asanka Herath
1650607d4c Windows prebuild filess
Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2009-11-25 02:07:24 +01:00