Strengthen the pledge() polyfill

This commit is contained in:
Justine Tunney 2022-06-27 13:01:58 -07:00
parent a6f65eea7c
commit 3c92adfd6e
79 changed files with 1457 additions and 357 deletions

View file

@ -37,6 +37,10 @@
#include "tool/decode/lib/flagger.h"
#include "tool/decode/lib/pollnames.h"
__attribute__((__constructor__)) static void init(void) {
pledge("stdio rpath proc inet", 0);
}
dontdiscard char *FormatPollFd(struct pollfd p[2]) {
return xasprintf("fd:%d revents:%s\n"
"fd:%d revents:%s\n",

View file

@ -23,6 +23,10 @@
#include "libc/testlib/testlib.h"
#include "libc/time/time.h"
__attribute__((__constructor__)) static void init(void) {
pledge("stdio rpath", 0);
}
// TEST(select, allZero) {
// // todo: figure out how to test block until signal w/ select
// EXPECT_SYS(0, 0, select(0, 0, 0, 0, 0));

View file

@ -27,6 +27,10 @@
#include "libc/sysv/consts/sol.h"
#include "libc/testlib/testlib.h"
__attribute__((__constructor__)) static void init(void) {
pledge("stdio rpath inet", 0);
}
TEST(setsockopt, SO_RCVTIMEO) {
char buf[32];
struct timeval tv = {0, 10000};

View file

@ -25,6 +25,10 @@
#include "libc/sysv/consts/sock.h"
#include "libc/testlib/testlib.h"
__attribute__((__constructor__)) static void init(void) {
pledge("stdio rpath tty", 0);
}
TEST(socketpair, testAfUnixStream) {
int fd[2];
const char ping[] = "ping";

View file

@ -31,6 +31,10 @@
#include "libc/testlib/testlib.h"
#include "libc/time/time.h"
__attribute__((__constructor__)) static void init(void) {
pledge("stdio rpath cpath proc unix", 0);
}
char testlib_enable_tmp_setup_teardown;
void DatagramServer(void) {