Commit Graph

7 Commits

Author SHA1 Message Date
Érico Rolim 8a6dadd57e Split platform compatibility code into compat.c.
Also use getentropy() in entropy.c, since it should be available in all
platforms.

This also cleaned up the error checking in general.
2020-11-28 15:27:03 -03:00
Érico Rolim 8435f3b695 Use opendir and readdir instead of scandir.
Slightly better portability, makes scandirat unnecessary.

Also fix small resource leakage with config_fd.
2020-10-18 03:17:54 -03:00
Érico Rolim 7cd4a58ab1 Add scandirat verification to configure script.
Tested on glibc, correctly detects the function. Added for a future use
case, if such appears.
2020-10-16 01:16:59 -03:00
Érico Rolim a8ded0e76f Build system fixes.
- Use CFLAGS and LDFLAGS from the environment in configure.
- Install meowd correctly.
2020-10-15 20:48:24 -03:00
Érico Rolim 7da7454a7d Improve file descriptor handling.
- Add close-on-exec flags where applicable, either with arguments when
opening the file or with fcntl calls. The possibility of applying the
flags atomically, when opening the file, is tested by the configure
script.
- Close the duplicated socket_write fd if fdopen in comm.c fails.
2020-10-15 20:45:05 -03:00
Érico Rolim 0b7243174c Add comment to FTMs, use less varied ones.
The feature test macro for POSIX.2001 is used in other source files
already, we should just use it when appropriate.

strdup() declaration is obtained by defining _XOPEN_SOURCE=500. Need (?)
to find out if there libcs that define it for POSIX.2008 but not for
X/Open.5.
2020-10-01 16:41:12 -03:00
Érico Rolim a99b5380a1 Add configure script to make it work on BSD.
We could use `extern const char *__progname` to work on musl/glibc and
BSDs, but it's not a recommended interface, and they prefer
getprogname(). In the interest of proper platform usage, use
getprogname() on BSD and program_invocation_short_name on musl/glibc.

Supporting arc4random_buf and getrandom is pretty simple.

Hasn't been tested on an actual BSD platform.
2020-09-14 10:20:48 -03:00