Commit Graph

1941 Commits

Author SHA1 Message Date
Viktor Dukhovni
dbc95a3e53 Avoid unused assignment 2015-04-14 23:03:07 +00:00
Nicolas Williams
52b046c636 Fix off-by-one in daemon detach 2015-04-14 11:27:23 -05:00
Simon Wilkinson
e0dd26d963 roken: rand.c needs to include config.h
If we don't include config.h, we don't get the results of any
autoconf tests.
2015-04-13 08:38:14 +01:00
Jeffrey Altman
4cf66ae8e4 roken: use Win32 rand_s() for rk_random() when available
On Windows if the compiler and C RTL is >= 1400 then the rand_s()
function is available.  rand_s() unlike rand() makes use of the
RtlGenRandom() API to produce a random number between 0 and UINT_MAX.
If rand_s() is not available or fails, fallback to rand().

One of the benefits of rand_s() is that no initialization is required
so it will provide random output even if rk_random_init() is not called.

Change-Id: I2768155de744bd49604fc8237728bb205d637f2a
2015-04-11 01:35:32 -04:00
Nicolas Williams
e75f790fe6 Use getauxval() for issuid() on Linux 2015-03-24 11:50:00 -05:00
Nicolas Williams
b48bed5f42 Daemons detach atomically to avoid having to wait
Tests that start daemons have to "wait" for them to start.

This commit makes Heimdal daemons prep to detach (when requested) by
forking early, then having the child signal readiness to the parent when
the child really is ready.  The parent exits only which the child is
ready.  This means that tests will no longer need to wait for daemons.

However, tests will still need a pidfile or such so they can stop the
daemons.

Note that the --detach options should not be used on OS X from launchd,
only from tests.
2015-03-24 11:49:59 -05:00
Jeffrey Altman
902aa4ee02 tests on Windows
Modify the NTMakefile rules for tests so that a failed test does
not prevent subsequent tests from being executed.

Change-Id: I9595ad4a1527feae7c402241bf06ab21a0b76d4a
2015-03-21 15:44:48 -04:00
Simon Wilkinson
8485250989 roken: Add memset_s implementation
Add an implementation of memset_s to roken.

Some optimising compilers may remove the memset() instruction when it
is used immediately before a free, which defeats its purpose if the
intention is to zero memory before returning it to the heap or stack.

C11 added memset_s, provide a fallback in roken so that memset_s can
be used on all platforms.
2015-03-05 17:06:20 +00:00
Love Hörnquist Åstrand
95f86ad1b8 remove stray a 2014-08-22 21:23:30 -07:00
Love Hörnquist Åstrand
37afa01be3 rename roken base64, fixes #107 2014-08-22 20:57:24 -07:00
Love Hörnquist Åstrand
c93db5aa52 check for sys/errno.h 2014-07-18 17:46:25 +02:00
Jeffrey Altman
732bfd11be roken: Windows ELOOP definition
Microsoft VC 2010 defines ELOOP as 114

Change-Id: Iba6cfd83e4a9ea1d43ed8aff7893d557648fc7e5
2014-05-14 21:56:51 -04:00
Jelmer Vernooij
70e43e9808 Fix some typos. 2014-04-25 02:42:17 +02:00
Volker Lendecke
ba26fa5502 heimdal: Fix a format error on FreeBSD10
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-03-24 23:07:51 -05:00
Jeffrey Altman
6bfcd13506 Windows: add usleep() to roken
Add a version of usleep() which is capable of sleeping in one
millisecond increments instead of microseconds.

Change-Id: I173f7e6f91a947cdb66f7cc6df5520e1c03f10b7
2014-02-23 23:24:48 -05:00
Ken Dreyer
d0b70a463c roken: don't ignore HAVE_OPENPTY on linux
openpty() is not available on all Linux distributions. Trust autoconf's
determination for HAVE_OPENPTY instead of unconditionally using
openpty() on all Linux.
2014-02-17 14:40:33 -07:00
Nicolas Williams
fdabfd6040 Win32 dladdr() wasn't returning 0 in all failures 2014-02-04 15:43:28 -06:00
Nicolas Williams
2fd4c58338 dladdr() on Win32 should't leave dli_fname == NULL 2014-02-04 15:37:45 -06:00
Ross L Richardson
22a5077835 Minor language problems 2013-11-17 12:48:41 +01:00
Jeffrey Altman
017e502089 roken: win32 dlopen use LoadLibraryEx AltSearchPaths
LoadLibrary() is unable to load DLLs which are being loaded from
a global side by side assembly directory.   Instead, use

  LoadLibraryEx() with LOAD_WITH_ALTERED_SEARCH_PATH

This permits a DLL to be loaded from the WinSxs tree when a fully
qualified path is provided.

Change-Id: I0e5da1a8610c6b571f73c0e7b0beabeecbbb3b77
2013-09-13 22:19:21 -04:00
Jeffrey Altman
475a366a19 roken: win32 dladdr do not normalize paths to slash
The resulting path needs to be passed to LoadLibrary.

Change-Id: Idfc45a4af4996105a428d88d9327f0dee5510be7
2013-09-13 22:19:11 -04:00
Jeffrey Altman
2179c92245 roken: win32 dladdr kill warnings
illegal pointer cast

unused variable

Change-Id: Ie5ebd2fd6b6e1cb06fec97dcf947fc40660abd91
2013-09-13 22:19:02 -04:00
Jeffrey Altman
800da1a501 roken: prototype dladdr()
Change-Id: Ia21414ca327b6ede44beb53fe96a6adc73119797
2013-09-10 22:31:37 -04:00
Jeffrey Altman
d78fe0c80a roken: windows opendir() initialize path buffer
Change-Id: If6ef39b3a7b256c78ecd7786cc939903f7823931
2013-09-10 22:31:36 -04: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
Viktor Dukhovni
23b8ae825a Fix rk_cloexec_socket() prototype 2013-08-19 17:22:43 -05:00
Jeffrey Altman
3f1d795758 roken: introduce rk_cloexec_socket
Accepts type rk_socket_t and is a no-op on Windows

Change-Id: I82755872e86ef36445e60054dd752279aaceb6d1
2013-08-19 10:21:23 -04:00
Jeffrey Altman
c90b0398df roken: prevent rk_mkdir recursion due to macro
rk_mkdir() should not be redefined to mkdir() nor should mkdir()
be redefined to rk_mkdir() when compiling lib/roken/mkdir.c

Change-Id: I329fd2eb5794548635d33218a65df8958746a6f9
2013-08-01 12:39:26 -04:00
Jeffrey Altman
5b223c2caa roken: do not require use of rk_mkdir on all platforms
Although rk_mkdir can be provided on all platforms there is no
reason to require that it be used by unconditionally mapping

  mkdir -> rk_mkdir

Change-Id: Ic149500037abf446434332bf6ba67dfb3906cd72
2013-07-27 19:13:17 -04:00
Love Hornquist Astrand
3ad1bf2dcc provide O_NOFOLLOW if there is non 2013-07-10 22:06:19 +02:00
Jeffrey Altman
8fa446d75c roken: Add rk_mkdir()
The Windows version of mkdir() does not share the same signature
as the POSIX version.  Add rk_mkdir() with an POSIX compliant signature
to libroken.  The current implementation ignores the 'mode' parameter
on Windows but a future implementation could provide the required
functionality with native Win32 APIs.

Change-Id: I084d42e0f27932e9b8131d310dbf34849f5fe4b6
2013-06-22 21:17:26 -04:00
Jeffrey Altman
de305a6f4c roken: Define S_IRWXU and friends on Windows
POSIX mkdir (unlike the Windows version) takes a 'mode_t' parameter.
Provide definitions for the mode_t constants.

Change-Id: Ie57e746aa3e579e28f93064ab430f1128508cc84
2013-06-22 21:17:24 -04:00
Jeffrey Altman
63735cc066 roken: include direct.h if HAVE_DIRECT_H
the prototype for "mkdir() on Windows is provided by direct.h.

Change-Id: I15c1d8fcc6fe58ba763bae236e92cfac958c66d1
2013-06-22 21:17:23 -04:00
Jeffrey Altman
bdfb19128d roken: build writev.c on Windows
Change-Id: I3c3fb4abb7cd093355c26b4a18366fa2b5a3224c
2013-06-22 21:17:22 -04:00
Jeffrey Altman
9547a2ca9e Avoid unused variable warning on Windows
Windows has neither O_NONBLOCK nor FIOBIO and sockets aren't file
descriptors in any case.  Avoid warning that 'flags' is unused in
socket_set_nonblocking().

Change-Id: I431cfae3a88577e75b5230f645639b5a17832f5c
2013-06-22 21:17:20 -04:00
Jeffrey Altman
b935bf493e roken: include limits.h unconditionally
Everywhere that roken is used supports limits.h.  The behavior of
roken should not depend on whether or not the including application
includes limits.h before or after roken.h.   Include limits.h in
roken.h and be done with it.

Change-Id: Id0be5487c791592dfe722ce880b8400bb16d05b1
2013-06-21 16:06:59 -04:00
Ben Kaduk
c0328e1328 Always provide a usable PATH_MAX
If a program does not include limits.h (or includes it after roken.h),
it can end up with PATH_MAX defined to be MAX_PATH, but MAX_PATH
undefined.  This causes consumers of PATH_MAX to become unhappy.

Work around this case by only using MAX_PATH if it is available, and
a constant otherwise.
2013-06-14 13:31:42 -04:00
Love Hornquist Astrand
b2ff260e15 klist --json support 2013-05-07 16:47:45 -07:00
Love Hornquist Astrand
bb089a75a9 undef rk_getpwnam_r to make sure we get the real prototype and not the rewrite #define 2013-05-01 14:00:31 -07:00
Nicolas Williams
96a5b298f9 Fix nmake test in roken (Windows) 2013-03-21 19:45:29 -05:00
Nicolas Williams
f490acc526 Winsock connect returns WSAEWOULDBLOCK...
...instead of EINPROGRESS.  And we get to call WSAGetLasteError() too boot :(
2013-03-18 23:15:29 -05:00
Roland C. Dowdeswell
183b15c11b lib/roken must export rk_socket_set_nonblocking. 2013-02-13 16:50:09 +08:00
Love Hornquist Astrand
087c859db6 add socket_set_nonblocking 2012-12-20 12:03:54 +01:00
Michael Meffie
4a438db29d drop __restrict some more, to please old compilers
Avoid the __restrict keyword in roken to appease older compilers.
2012-08-16 15:19:44 -04:00
Jeffrey Altman
b8a53329fc Windows: rk_wcsdup allocator
patchset 3fe5572840 should have
replaced wcsdup().

Change-Id: Ib1e09477b430525267c6c930d7c4ab29858a68bb
2012-07-20 09:40:22 -04:00
Jeffrey Altman
0686ad5ece Windows: rk_strdup allocator
patchset 3fe5572840 should have
replaced strdup().

Change-Id: I7af7b3e953e379fb23fccd9fa7a9e02c354c2dc4
2012-07-20 00:50:47 -04:00
Jeffrey Altman
3fe5572840 roken: Use a common allocator for all windows
Windows applications become very unhappy when memory is allocated
in one module (exe or dll) and deallocated in another.  This is
because each of the C run time library instances uses its own
heap.  Mixing allocating in one heap and deallocating in another
will lead to memory leaks and heap corruption.   For modules that
build against roken avoid this problem by sharing roken's allocator
with the module that uses it.

Change-Id: I31e35c600a78350b168a281811160696dc327544
2012-07-01 22:09:31 -04:00
Jeffrey Altman
2f17afacda Revert "do not include stdint.h unprotected"
This reverts commit cb6f7ea40e.

stdint.h can be included everywhere now that the Windows
platform generates and installs a stdint.h when Visual
Studio does not provide one.

Change-Id: Ia3cab28d7f5806203cd45227765debda54ac7472
2012-06-26 17:05:54 -04:00
Nicolas Williams
98809e86ce Move base into lib
This involves reverting dd267e8fc3,
    but that gets lost in the move.

    This builds on Ubuntu and Windows at this time.
2012-06-20 19:32:08 -05:00
Love Hornquist Astrand
d2c37acf7c pull in <errno.h> 2012-06-08 17:57:02 +02:00