Commit Graph

2034 Commits

Author SHA1 Message Date
Nicolas Williams
34728ce79e rk_base64_encode(): set errno in all error cases 2019-10-03 13:09:18 -05:00
Nicolas Williams
1ae941af9b roken_detach_prep() should return fd 2019-10-03 13:09:18 -05:00
Nicolas Williams
141289f14b roken: add roken_get_loginname() 2019-09-25 23:09:20 -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
e60955e835 roken: getuserinfo WIN32 fix username string termination
95eb83c424 ("roken: Add roken_get_username() and friends")
failed to copy the username C-String NUL terminator.  As a result
a "DOMAIN\user" is returned as "userIN\user".

Change-Id: I10027e4eef18364074eecf385fa9fab1ae68dbe7
2019-05-02 13:42:01 -04:00
Rod Widdowson
f1b27d77cd Windows: Make getaddrinfo-test work
Before we call gettaddrinfo we have to call rx_SOCK_INIT

In order to exercise the test we have to supply parameters to the command line
2019-03-25 16:38:56 -07:00
Jeffrey Altman
43a34f6663 roken: tsearch use rk_UNCONST instead of __DECONST #307
The rk_UNCONST macro exists because neither __DECONST nor uintptr_t
are available on all platforms (for example, AIX).

Change-Id: Ie36f0dd7a9ce454d411761ee4dbd6fc1f7c6692c
2019-02-21 15:46:51 -05:00
Jeffrey Altman
f0d9289d86 roken: fix strtoll
b10ad7eb57
("roken: strtoll.c negation is a no-op on unsigned integer")
broke strtoll() by failing to assign 'ret' in the success case.

Change-Id: I30535d83a2bef305140f1a6bd1ed2eeba23db9b9
2019-01-22 00:02:57 -05:00
Jeffrey Altman
9ce2683f2d roken: strtoull.c negation is a no-op on unsigned integer
strtoull() returns an unsigned long long.  However, then the input
string represents a negative number the return value is supposed to
be the unsigned representation of the negative value.  Before applying
the negation the value must be cast to (long long).

Change-Id: Icf9e75400ff736819b1f7e0e6fb3c8abd707a23a
2019-01-21 22:28:02 -05:00
Jeffrey Altman
b10ad7eb57 roken: strtoll.c negation is a no-op on unsigned integer
strtoll() returns a signed long long not an unsigned long long.
When applying the negation for negatives the value must be cast
from unsigned to signed and then stored in a signed variable
before returning it.

Change-Id: If568afd2509d27c7bf206ca59d32ca150cb34857
2019-01-21 22:25:19 -05:00
Jeffrey Altman
3bbd8663b0 WIN32: fix roken build
__declspec not _declspec

Include "err.h" not <err.h>

Include "roken.h" before "err.h"

Indent "#if" as "# if" within roken.h.in when CPP rules must be copied
into the generated "roken.h".

Correct verr() attribute to be ROKEN_LIB_NORETURN_FUNCTION.

Change-Id: I4289ecaba4a097175b4a5a1cde529b59038c72e3
2019-01-21 22:04:06 -05:00
Nicolas Williams
a3a8c1e4a4 ASN.1: Support wider bit sets (fix #514) 2019-01-15 13:21:25 -06:00
Nicolas Williams
99188ea797 Bump roken SONAME version (fix #279) 2019-01-04 12:49:58 -06:00
Luke Howard
befe1b8f90 always load plugins with RTLD_LOCAL/RTLD_GROUP if available 2019-01-03 20:06:27 -06:00
Nicolas Williams
7c449afbf8 Fix lib/roken test macro redefinition 2019-01-02 13:56:04 -05:00
Nicolas Williams
299fbf5dac Fix warning in roken test on Windows 2019-01-02 13:56:04 -05: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
Jeffrey Altman
c1c98d3cfd lib/roken: is_special_auxv_p test for AT_HWCAP2
fix breakage introduced by 6341132175
("roken: fix build breakage, AT_HWCAP2 may be undefined (#446)").
Detected by Coverity.

Change-Id: Iefdb73d4392e5184a69a99208945ece6b7b8ecb3
2019-01-01 14:59:19 -05:00
Jeffrey Altman
134b53ead1 lib/roken: roken_get_shell unreachable code warning
When WIN32 is undefined an unreachable code warning was generated
since "/bin/sh" is returned as the default resposne.

Change-Id: I757c9d05db62c1d52fee0e510259098d73273a84
2018-12-28 14:31:21 -05:00
Jeffrey Altman
434f76bcb7 lib/roken: rk_random_init HAVE_ARC4RANDOM #401
When arc4random() is available, rk_random_init() does not have to
call arc4random_stir().  ac4random_stir() will be called as a result
of the first call to arc4random().

Change-Id: I6f4a3be7c39752746657945ed15896472908f889
2018-12-26 16:49:06 -06:00
Luke Howard
6ce1aa84c5 Remove rk_getpw*_r() functions 2018-12-25 22:11:19 -06:00
Nicolas Williams
3f1451a4c3 Remove get_default_username() 2018-12-25 22:11:19 -06:00
Nicolas Williams
95eb83c424 roken: Add roken_get_username() and friends
We add roken_get_{shell, username, appdatadir, homedir}() functions.  These use
a combination of secure_getenv(), getpwuid_r(), getlogin_r(), or various WIN32
functions to get this information.

Use roken_get_appdatadir() instead of roken_get_homedir() when looking for
dotfiles.
2018-12-25 22:11:19 -06:00
Nicolas Williams
073ffd0423 roken: Make sure we have MAX_PATH 2018-12-25 22:11:19 -06:00
Nicolas Williams
a152c4c808 Remove k_getpwnam() and k_getpwuid() 2018-12-25 22:11:19 -06:00
Nicolas Williams
784637709b Remove unix_verify_user() 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
Nicolas Williams
af9e938867 Fix infinite loop in print_units_table() 2018-12-25 22:11:19 -06:00
Nicolas Williams
7138a04690 Fix rk_mkdir() on WIN32 2018-12-25 22:11:19 -06:00
Luke Howard
6341132175 roken: fix build breakage, AT_HWCAP2 may be undefined (#446) 2018-12-23 06:44:50 +00:00
Luke Howard
2974a9841f roken: skip AT_HWCAP[2] in auxval test (#446)
AT_HWCAP and AT_HWCAP2 are handled specially by libc and cannot be parsed
directly out of /proc/self/auxv. Skip them in the auxval test.
2018-12-23 06:16:05 +00:00
Luke Howard
dd7eb8f665 roken: add rk_getpwuid_r()
TODO: implement non-POSIX getpwnam_r()/getpwuid_r() wrappers
2018-12-22 16:30:34 +11:00
Luke Howard
ec88576ace roken: Solaris auxval test fails (#441)
The Solaris auxval test fails, because Solaris uses different preprocessor
symbols (and numbers) for its UID and GID auxval types.

Note that issuid() could simply be an alias of issetugid() on Solaris, so
perhaps this is not necessary.
2018-12-19 09:51:12 +11:00
Rod Widdowson
136f8fb550 Windows: Avoid using deprecated function.
In VC15 GetVersionEx has been deprecated. In order to continue to
support Win2K use the undeprecated VerifyVersionInfoW API
(available since Win2K).

Inline helper functions used in latest Win10 SDK to simplify code.
2018-12-14 06:38:59 -05:00
Jeffrey Altman
1feff82129 roken: gettimeofday using GetSystemTimePreciseAsFileTime
GetSystemTimeAsFileTime() has 16ms precision.

GetSystemTimePreciseAsFileTime() has <1ns precision but is only available
on Windows 8 or later.

This change dynamically loads GetSystemTimePreciseAsFileTime() if it is
available.

Change-Id: Ib9c616c01948384e6b256ac9b6023f1e39673613
2018-09-19 00:30:42 -04:00
Daria Phoebe Brashear
7333c2c945 roken: parse_units returns void
despite the fact that the called function returns void,
returning a result here throws an error with solaris cc.

just call the function and don't return
2018-04-19 13:12:59 -04:00
Jeffrey Altman
dcc880cf7c roken: issuid always call rk_getauxval
Instead of calling getauxval(), always call rk_getauxval() to ensure consistent behavior within roken.
2018-04-04 12:54:13 -04:00
Daria Phoebe Brashear
6aece8ea06 getauxval: fall through to auxv gfter getauxval errno test
if when we need to determine if getauxval sets errno, we determine it doesn't
after getting a 0 return code, make sure we return a value, since we didn't
previously. fall through to code we'd otherwise have called in this case
above.
2018-04-04 12:54:13 -04:00
Jeffrey Altman
7ee3cc6855 Update parse_units.c 2018-04-04 11:27:23 -04:00
Harald Barth
7a2767e610 Make parse_units() handle trailing whitespace
Skipping any trailing whitespace characters
2018-04-04 11:27:23 -04:00
Viktor Dukhovni
b860b70ada Fix missing rk_ prefix 2017-10-17 03:11:55 -04:00
Nicolas Williams
496022fa37 Fix lib/roken parse_* warnings 2017-10-11 16:45:51 -05:00
David Mulder
2548b3b8aa Solaris 8 x86 uses ->d_fd not ->dd_fd or dirfd() 2017-09-25 18:26:35 -05:00
Roland C. Dowdeswell
8c18131c13 Have roken.h #include <util.h> to find emalloc on some platforms. 2017-09-25 18:01:19 -05:00
Viktor Dukhovni
aef3843b55 Add missing semicolons 2017-08-23 17:06:29 -04:00
Viktor Dukhovni
d73ec2510a Try to avoid parse_{time,units,flags} symbol conflicts
On Debian stretch systems PAM modules linked against Heimdal run into
symbol conflicts with parse_time() in systemd libraries.  We redefine
parse_time() and friends to rk_parse_time(), ... while keeping the old
names for ABI compatibility with existing clients.

The legacy names should eventually be droppped.
2017-08-23 15:09:11 -05:00
Nicolas Williams
2c913b4bf7 Fix typo in d999ac7 2017-05-29 00:49:58 -05:00
Nicolas Williams
d999ac7026 Quiet warning about rk_getprocauxval() 2017-05-28 16:58:38 -05:00
Viktor Dukhovni
2d968c5c88 Fix test-auxval typos hidden by platform dependence 2017-05-27 00:08:00 -05:00