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

@ -18,6 +18,7 @@
*/
#include "libc/bits/safemacros.internal.h"
#include "libc/fmt/fmt.h"
#include "libc/macros.internal.h"
#include "libc/runtime/runtime.h"
#include "net/https/sslcache.h"
@ -26,10 +27,10 @@
* @return pointer to static memory
*/
char *GetSslCacheFile(void) {
static char sslcachefile[PATH_MAX + 1];
static char sslcachefile[PATH_MAX];
if (snprintf(sslcachefile, sizeof(sslcachefile), "%s/%s.sslcache",
firstnonnull(getenv("TMPDIR"), "/tmp"),
getenv("USER")) <= PATH_MAX) {
getenv("USER")) < ARRAYLEN(sslcachefile)) {
return sslcachefile;
} else {
return 0;

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);