Commit Graph

48 Commits

Author SHA1 Message Date
Nicolas Williams
8b6926f4c0 roken: Add rk_undumptext() and support ttys and such
Add rk_undumptext(), which NUL-terminates the contents it reads.

rk_undumptext(), and now also rk_undumpdata(), can read from regular and
non-regular files (e.g., ttys, pipes, devices, but -on Windows- not
sockets).

This means that `asn1_print` can now read from `/dev/stdin`, which can
be a pipe.

There's a way to set a limit on how much to read from non-regular files,
and that limit defaults to 10MB.

At any rate, the rk_dumpdata(), rk_undumpdata(), and rk_undumptext() functions
really do not belong in lib/roken but in lib/base.  There are other utility
functions in lib/roken that don't belong there too.  A rationalization of the
split between lib/roken and lib/base is overdue.  And while we're at it -lest I
forget- it'd be nice to move all the krb5_storage functions out of lib/krb5 and
into lib/base, as those could come in handy for, e.g., implementing OpenSSH
style certificates and other things outside the krb5 universe.
2022-12-21 22:06:15 -06:00
Nicolas Williams
d5a87e5906 roken: Add easprintf() and evasprintf() utils
Like emalloc() and ecalloc(): errx on ENOMEM.
2022-12-08 20:49:28 -06:00
Nicolas Williams
1193bd5e74 roken: Add time_add()/time_sub() with overflow prot. 2022-02-15 20:11:37 -06:00
Nicolas Williams
94bb267a8b roken: Delete getcap/cgetent/cgetstr() 2022-01-14 12:01:33 -06:00
Luke Howard
b3bb3ac49d roken: add rk_clzll() helper function 2021-12-22 10:36:26 +11:00
Nicolas Williams
d336730534 roken: Add (re)allocating strvis functions
These are a Heimdal innovation.
2021-01-13 20:17:58 -06:00
Jeffrey Altman
51912c0215 roken: introduce rk_socket_set_keepalive
Change-Id: I3086a10cd3d23bef00336f5db7db3a35ca02d568
2020-07-24 01:32:34 -04:00
Luke Howard
1c74afb01a roken: add mergesort_r()
Add mergesort_r() as a stable sort function that can be used by other
components of Heimdal. Note that there is no standardized prototype for this
function, however it appears that both FreeBSD and glibc would adopt the glibc
convention (where the private data argument appears last). See:

    https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214248
2020-04-12 13:25:09 -05:00
Nicolas Williams
a7359d6898 roken: Add mkdtemp() 2020-03-02 17:48:04 -06:00
Nicolas Williams
77619f245d roken: Add base32 2020-03-02 17:48:04 -06:00
Nicolas Williams
96d1e80bda roken: add mkostemp() 2019-10-03 13:09:18 -05:00
Nicolas Williams
f31cdc30b2 roken: add rk_memmem() 2019-10-03 13:09:18 -05:00
Nicolas Williams
141289f14b roken: add roken_get_loginname() 2019-09-25 23:09:20 -05:00
Nicolas Williams
99188ea797 Bump roken SONAME version (fix #279) 2019-01-04 12:49:58 -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
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
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
123f702001 lib/roken: add fseeko()/ftello() 2017-05-26 23:24:30 -04:00
Nicolas Williams
cf4efe8de6 Add secure_getenv.c 2017-04-17 18:02:30 -04:00
Nicolas Williams
650ffdc964 Revamp lib/roken/getauxval.c 2017-04-17 18:02:30 -04:00
Nicolas Williams
707b2372d2 Further improvements to issuid() 2017-03-31 18:56:04 -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
Nicolas Williams
0271b171e5 Add bswap64() 2016-02-16 20:49:33 -06: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
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
37afa01be3 rename roken base64, fixes #107 2014-08-22 20:57:24 -07: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
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
Roland C. Dowdeswell
183b15c11b lib/roken must export rk_socket_set_nonblocking. 2013-02-13 16:50:09 +08:00
Nicolas Williams
6dd66df594 Make master build on Windows
Add strtoll()/strtoull() to lib/roken
    Add stdint.h to lib/roken (Windows only)
    Add logic to detect whether to use lib/roken's stdint.h based on
        Visual Studio version
    Add include of stdint.h in generated ASN.1 code
    Export missing symbols for 64-bit integers in lib/asn1
    Export missing symbols for FAST
    Add missing sources to kdc/NTMakefile
    Fix issue in kuserok
    Fix bsearch issues
2012-01-17 12:10:14 -06:00
Love Hornquist Astrand
81a03fafd2 is rk, not rx 2011-04-14 13:08:16 -07:00
Derrick Brashear
2a32bf67f0 Add tsearch and friends, and a test program
tsearch is missing from windows. use the netbsd version as it's
license-compatible.
2011-04-08 15:15:36 +01:00
Love Hornquist Astrand
a2b45360c2 add random_init 2010-11-29 09:31:07 -08:00
Love Hornquist Astrand
cf1b11f8a0 export more 2010-03-11 23:35:26 -08:00
Love Hornquist Astrand
908ece3604 Adapt for Linux with SOCK_CLOEXEC, patch from Harald Barth 2010-01-26 10:46:51 -08:00
Asanka Herath
68cfbb7e19 Add rk_cloexec_dir() to lib/roken 2009-12-22 14:03:39 -05:00
Love Hornquist Astrand
599a7e2e50 add ct_memcmp as an exported symbol 2009-08-20 04:34:26 -07:00
Love Hornquist Astrand
21ff5b84a5 Fix symbols renaming for flock 2009-08-14 05:17:51 +02:00
Love Hörnquist Åstrand
b8fb6b35ae dns_ symbols are no more.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24884 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-03-22 17:17:12 +00:00
Love Hörnquist Åstrand
5ba6d352b7 glob/globfree is no longer used, prefixed with rk_
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24768 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-22 23:23:26 +00:00
Love Hörnquist Åstrand
efed5633ca prefix symbols with rk_, patch from Martin von Gagern
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24759 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-17 02:49:55 +00:00
Love Hörnquist Åstrand
081f5bc0ad prefix warnerr with rk_
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24733 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-16 18:37:46 +00:00
Love Hörnquist Åstrand
f7e54baefc More symbols, from Martin von Gagern.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24620 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-04 22:11:11 +00:00
Love Hörnquist Åstrand
ec24bb4386 add more bits
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24607 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-04 22:09:01 +00:00
Love Hörnquist Åstrand
cb57cd57f8 add version-script.map
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24606 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-04 22:08:51 +00:00