Commit Graph

1965 Commits

Author SHA1 Message Date
Nicolas Williams
87b234e154 roken_detach_prep() close pipe 2016-12-06 22:44:23 -06:00
Nicolas Williams
d609264a00 Only rm pidfile if PID matches 2016-12-06 22:44:23 -06:00
Nicolas Williams
a6e8ff2ae5 pidfile(): write newline too 2016-12-06 22:44:23 -06:00
Nicolas Williams
12eb54d03f rk_pidfile() should call pidfile() if HAVE_PIDFILE
This is necessary so we can use --detach in tests even on NetBSD and
OpenBSD.
2016-12-06 22:44:23 -06:00
Jeffrey Altman
2f62c7c77e roken: rk_undumpdata free allocation on error
Do not return allocated memory and an error code.
Free it instead so as to avoid memory leaks.

Change-Id: I47d42be0f6bc52062c57c00c37b665ee2f2811ce
2016-11-19 02:08:58 -05:00
Nicolas Williams
1c81ddf4e2 Round #2 of scan-build warnings cleanup 2016-11-16 17:03:14 -06:00
Nicolas Williams
953dc07391 Round #1 of scan-build warnings cleanup 2016-11-15 21:27:20 -06:00
Viktor Dukhovni
da8052fefc Don't scale SRV weights when none have weight zero 2016-11-13 15:22:17 +11:00
Viktor Dukhovni
ee8b2b4253 Drop code that's been dead for 10 years or more 2016-11-13 05:36:11 +11:00
Viktor Dukhovni
c8753450b1 Fix (linux) compiler warnings in libroken 2016-11-13 03:41:33 +11:00
Roland C. Dowdeswell
eb682c1bf4 Fix weight zero entries when ordering SRV RR results.
In lib/roken/resolve.c, we find rk_dns_srv_order() which re-orders
the results of an SRV RR lookup by the algorithm in RFC2782.  We
note that the algorithm doesn't behave according to the RFC w.r.t.
entries of weight zero.  We solve this by scaling out the remaining
weights by the number of zeros we find at a particular priority
level and acting like the zero weights have a weight of one.
2016-11-10 04:45:07 -05:00
Roland C. Dowdeswell
44a1a2a273 Fix bias in ordering SRV RR results by weight.
In lib/roken/resolve.c, we find rk_dns_srv_order() which re-orders
the results of an SRV RR lookup by the algorithm in RFC2782.  We
fix a bias in the random weight sorting by changing the order of
operations when selecting rnd.  rnd should be a non-zero random
number less than the sum of the weights at a particular priority,
but zero was included as a legitimate output thus biasing the
selection process.  rk_random() % sum is still biased as a 32
bit int modulo a number which doesn't divide 2^32 does not have
a uniform distribution, but the bias should be small enough to
live with for our purposes here.
2016-11-10 04:45:07 -05:00
Roland C. Dowdeswell
8b93901db7 lib/roken/simple_exec_w32.c: forgot to assign tmp var back to original
after calling realloc(3).
2016-11-08 17:20:42 -05:00
Ed Maste
54e85ad099 Remove duplicate symbols from libroken version-script.map
Commit efed5633 (r24759) prefixed some symbols with rk_, but
introduced 6 duplicate symbols in the version script (because the
rk_-prefixed versions of the symbols were already present).
2016-07-21 14:36:59 -04:00
Viktor Dukhovni
9f0e64d5b8 Revert inadvertent change 2016-02-28 20:34:26 -05:00
Nicolas Williams
b4cf4de807 Fix warnings (clang 3.6) 2016-02-26 01:04:31 -06:00
Nicolas Williams
0271b171e5 Add bswap64() 2016-02-16 20:49:33 -06:00
Nicolas Williams
e4b61df46f Test parse_time() with minutes 2016-02-16 20:49:31 -06:00
Nicolas Williams
ec2204f435 Use volatile to keep ct_memcmp() ct 2016-02-16 20:49:29 -06:00
Jeffrey Altman
26c7affa70 roken: fix 0acef7729f
Should have used -- instead of == in the prior commit.

Change-Id: I90f8886b754dda19970c6579ffa477634e8dc4a5
2015-05-20 11:05:38 -04:00
Jeffrey Altman
0acef7729f roken: fix append_string "%.s" non-nul termination
It should be possible to pass a format string of "%.s" to permit
a non-nul terminated string to be used as input.  The test of remaining
precision and the test for NUL needs to be reversed to permit this
behavior to function correctly.

Change-Id: I200f9c2886419dc4c3870f5f44bc10e81245f56c
2015-05-20 10:27:12 -04:00
Kiran S J
a350c5265a Fix compilation error when in dlfcn.h
When dlfcn.h is included from a C++ file causes a compilation error due to missing '{'.
2015-04-30 12:30:28 +05:30
Jeffrey Altman
bcb92ceaa7 YFS Coverity 11694
Change-Id: If43c93b8dc1088710a0cd48987cb9e69acb6ec23
2015-04-21 21:22:15 -04:00
Jeffrey Altman
2b168c8be2 YFS Coverity 11525
Change-Id: I1e0a33ee1ae1a61dbdecc731451852590aa3883c
2015-04-21 21:14:54 -04:00
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