ndhc/nk
Nicholas J. Kain ba8f674e15 nk/exec: Simplify and remove double null termination.
The current code pads with an extra character that is then rewritten
into a null character.  This isn't necessary with post-C99
implementations of standardized snprintf, so get rid of it.

Also add a note warning that nk_generate_env() and nk_execute()
are not async signal safe and are thus unsuitable for use in
multithreaded processes.

nk_execute() could be rewritten to be async signal safe without much
trouble, as the only problem point is snprintf() which is not guaranteed
to be async signal safe by POSIX.

However, nk_generate_env() performs chroot() if a chroot_path is
specified, and chroot() is not async signal safe in POSIX.
Additionally, malloc() can be called in rare cases where user
information fields are very long, and malloc() is obviously not async
signal safe.  Finally, snprintf() is used here, too, but it could be
replaced.

Converting to posix_spawn() is a no-go because posix_spawn() has no
facility for changing rlimits or chroot on the spawned process.

In summary, I don't think the gains are worth it.  Multithreaded
processes should just not fork().
2022-02-25 04:53:02 -05:00
..
copy_cmdarg.h Relicense as MIT. 2022-02-06 20:05:29 -05:00
exec.c nk/exec: Simplify and remove double null termination. 2022-02-25 04:53:02 -05:00
exec.h Support running an executable file when a new lease is acquired. 2022-02-24 03:58:37 -05:00
hwrng.c Relicense as MIT. 2022-02-06 20:05:29 -05:00
hwrng.h Relicense as MIT. 2022-02-06 20:05:29 -05:00
io.c Relicense as MIT. 2022-02-06 20:05:29 -05:00
io.h Relicense as MIT. 2022-02-06 20:05:29 -05:00
log.h Relicense as MIT. 2022-02-06 20:05:29 -05:00
net_checksum16.h Relicense as MIT. 2022-02-06 20:05:29 -05:00
privs.c Relicense as MIT. 2022-02-06 20:05:29 -05:00
privs.h Relicense as MIT. 2022-02-06 20:05:29 -05:00
random.c Relicense as MIT. 2022-02-06 20:05:29 -05:00
random.h Relicense as MIT. 2022-02-06 20:05:29 -05:00