Make improvements

- Add rusage to redbean Lua API
- Add more redbean documentation
- Add pledge() to redbean Lua API
- Polyfill OpenBSD pledge() for Linux
- Increase PATH_MAX limit to 1024 characters
- Untrack sibling processes after fork() on Windows
This commit is contained in:
Justine Tunney 2022-04-28 09:42:36 -07:00
parent 9a6bd304a5
commit 47b3274665
212 changed files with 2251 additions and 834 deletions

View file

@ -47,15 +47,15 @@ mbedtls_x509_crt *GetSslRoots(void) {
size_t n, m;
struct dirent *e;
static bool once;
char path[PATH_MAX];
static mbedtls_x509_crt *c;
char path[PATH_MAX + 1];
if (!once) {
if ((c = calloc(1, sizeof(*c)))) {
m = stpcpy(path, "/zip/usr/share/ssl/root/") - path;
if ((d = opendir(path))) {
while ((e = readdir(d))) {
if (e->d_type != DT_REG) continue;
if (m + (n = strlen(e->d_name)) > PATH_MAX) continue;
if (m + (n = strlen(e->d_name)) >= ARRAYLEN(path)) continue;
memcpy(path + m, e->d_name, n + 1);
CHECK((p = xslurp(path, &n)));
CHECK_GE(mbedtls_x509_crt_parse(c, p, n + 1), 0, "%s", path);