cosmopolitan/libc/fmt
Justine Tunney 98254a7c1f Make pledge() and unveil() work amazingly
This change reconciles our pledge() implementation with the OpenBSD
kernel source code. We now a polyfill that's much closer to OpenBSD's
behavior. For example, it was discovered that "stdio" permits threads.
There were a bunch of Linux system calls that needed to be added, like
sched_yield(). The exec / execnative category division is now dropped.
We're instead using OpenBSD's "prot_exec" promise for launching APE
binaries and dynamic shared objects. We also now filter clone() flags.

The pledge.com command has been greatly improved. It now does unveiling
by default when Landlock is available. It's now smart enough to unveil a
superset of paths that OpenBSD automatically unveils with pledge(), such
as /etc/localtime. pledge.com also now checks if the executable being
launched is a dynamic shared object, in which case it unveils libraries.

These changes now make it possible to pledge curl on ubuntu 20.04 glibc:

    pledge.com -p 'stdio rpath prot_exec inet dns tty sendfd recvfd' \
        curl -s https://justine.lol/hello.txt

Here's what pledging curl on Alpine 3.16 with Musl Libc looks like:

    pledge.com -p 'stdio rpath prot_exec dns inet' \
        curl -s https://justine.lol/hello.txt

Here's what pledging curl.com w/ ape loader looks like:

    pledge.com -p 'stdio rpath prot_exec dns inet' \
        o//examples/curl.com https://justine.lol/hello.txt

The most secure sandbox, is curl.com converted to static ELF:

    o//tool/build/assimilate.com o//examples/curl.com
    pledge.com -p 'stdio rpath dns inet' \
        o//examples/curl.com https://justine.lol/hello.txt

A weird corner case needed to be handled when resolving symbolic links
during the unveiling process, that's arguably a Landlock bug. It's not
surprising since Musl and Glibc are also inconsistent here too.
2022-07-19 21:33:49 -07:00
..
__xpg_strerror_r.c Add pthread tls api 2022-06-22 07:08:17 -07:00
abs.c Make improvements 2022-04-24 10:06:05 -07:00
atoi.c Implement new JSON parser for redbean 2022-07-09 11:44:19 -07:00
atol.c Add cpu / mem / fsz limits to build system 2021-08-13 23:40:53 -07:00
atoll.c Add cpu / mem / fsz limits to build system 2021-08-13 23:40:53 -07:00
basename.c Fix basename() and dirname() 2022-04-06 00:13:44 -07:00
bing.c Change license 2020-12-27 17:18:44 -08:00
bing.internal.h Enhance chibicc 2020-12-09 04:00:48 -08:00
conv.h Improve system calls 2022-07-08 06:42:03 -07:00
decodenf32.c Update experiment with tty audio 2022-07-15 23:07:32 -07:00
dirname.c Fix basename() and dirname() 2022-04-06 00:13:44 -07:00
div.c Change license 2020-12-27 17:18:44 -08:00
divmod10.internal.h Make improvements 2022-03-16 13:40:10 -07:00
encodenf32.c Update experiment with tty audio 2022-07-15 23:07:32 -07:00
fcvt.c Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
fmt.c Fix %c with nul character 2022-06-12 22:28:19 -07:00
fmt.h Make improvements 2022-04-24 10:06:05 -07:00
fmt.internal.h Make more fixes and improvements 2022-04-21 13:44:59 -07:00
fmt.mk Make fixes and improvements 2022-05-19 16:57:49 -07:00
formatbinary64.c Polish redbean serialization 2022-04-29 06:10:10 -07:00
formatflex64.c Improve Lua and JSON serialization 2022-07-12 23:35:11 -07:00
formathex64.c Improve Lua and JSON serialization 2022-07-12 23:35:11 -07:00
formatint64thousands.c Add torture test for zipos file descriptors 2022-06-15 16:29:49 -07:00
formatmemorysize.c Add torture test for zipos file descriptors 2022-06-15 16:29:49 -07:00
formatoctal32.c Do code cleanup use duff device linenoise i/o 2022-04-22 18:56:52 -07:00
formatoctal64.c Polish redbean serialization 2022-04-29 06:10:10 -07:00
i128abs.c Import C++ Standard Template Library 2022-03-22 06:41:54 -07:00
imaxabs.c Import C++ Standard Template Library 2022-03-22 06:41:54 -07:00
internal.h Support proper %g, %f, and %a float formatting 2021-03-05 10:31:16 -08:00
itoa.c Support proper %g, %f, and %a float formatting 2021-03-05 10:31:16 -08:00
itoa.h Add torture test for zipos file descriptors 2022-06-15 16:29:49 -07:00
itoa64.c Change noinline to dontinline (#312) 2021-11-12 15:12:18 -08:00
itoa64fixed16.greg.c Make numerous improvements 2021-09-28 01:52:34 -07:00
itoa64radix8.c Change noinline to dontinline (#312) 2021-11-12 15:12:18 -08:00
itoa64radix16.greg.c Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
itoa128radix10.greg.c Change noinline to dontinline (#312) 2021-11-12 15:12:18 -08:00
joinpaths.c Make pledge() and unveil() work amazingly 2022-07-19 21:33:49 -07:00
knfcimal.S Update experiment with tty audio 2022-07-15 23:07:32 -07:00
labs.c Make improvements 2022-04-24 10:06:05 -07:00
ldiv.c Change license 2020-12-27 17:18:44 -08:00
leb128.h Support Linux binfmt_misc and APE loading on Apple 2022-05-21 09:28:25 -07:00
lengthuint64.c Make some minor fixups to bug reporting, etc. 2022-07-11 05:58:24 -07:00
llabs.c Make improvements 2022-04-24 10:06:05 -07:00
lldiv.c Change license 2020-12-27 17:18:44 -08:00
magnumstrs.internal.h Make some quick fixes and cleanup 2022-06-26 02:58:36 -07:00
nf32.h Update experiment with tty audio 2022-07-15 23:07:32 -07:00
ntoa.c Make more fixes and improvements 2022-04-21 13:44:59 -07:00
pad.c Make more fixes and improvements 2022-04-21 13:44:59 -07:00
pflink.h Make more fixes and improvements 2022-04-21 13:44:59 -07:00
sizetol.c Add cpu / mem / fsz limits to build system 2021-08-13 23:40:53 -07:00
sleb64.c Productionize new APE loader and more 2021-10-02 08:27:03 -07:00
sleb128.c Productionize new APE loader and more 2021-10-02 08:27:03 -07:00
snprintf.c Support proper %g, %f, and %a float formatting 2021-03-05 10:31:16 -08:00
sprintf.c Support thread local storage 2022-05-16 13:20:08 -07:00
sscanf.c Change license 2020-12-27 17:18:44 -08:00
stoa.c Make build hermetic without shell scripts 2022-05-25 13:55:57 -07:00
strerror.c Make improvements 2022-04-24 10:06:05 -07:00
strerror_r.c Make fixes and improvements 2022-05-19 16:57:49 -07:00
stripext.c Make numerous improvements 2021-09-28 01:52:34 -07:00
stripexts.c Add SNI support to redbean and improve SSL perf 2021-07-23 13:56:13 -07:00
strtoi128.c Import C++ Standard Template Library 2022-03-22 06:41:54 -07:00
strtoimax.c Import C++ Standard Template Library 2022-03-22 06:41:54 -07:00
strtol.c Make numerous improvements 2021-09-28 01:52:34 -07:00
strtol.internal.h Make numerous improvements 2021-09-28 01:52:34 -07:00
strtoll.c Fix typo bug in strtoll (#245) 2021-08-15 12:07:33 -07:00
strtoll_l.c Import C++ Standard Template Library 2022-03-22 06:41:54 -07:00
strtonum.c Change license 2020-12-27 17:18:44 -08:00
strtou128.c Import C++ Standard Template Library 2022-03-22 06:41:54 -07:00
strtoul.c Make numerous improvements 2021-09-28 01:52:34 -07:00
strtoull.c Add cpu / mem / fsz limits to build system 2021-08-13 23:40:53 -07:00
strtoull_l.c Import C++ Standard Template Library 2022-03-22 06:41:54 -07:00
strtoumax.c Import C++ Standard Template Library 2022-03-22 06:41:54 -07:00
swprintf.c Import C++ Standard Template Library 2022-03-22 06:41:54 -07:00
uleb64.c Add Compress() and Uncompress() to redbean 2022-05-16 16:49:20 -07:00
uleb128.c Productionize new APE loader and more 2021-10-02 08:27:03 -07:00
unbing.c Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
unhexbuf.c Change license 2020-12-27 17:18:44 -08:00
unsleb128.c Change license 2020-12-27 17:18:44 -08:00
unuleb64.c Add Compress() and Uncompress() to redbean 2022-05-16 16:49:20 -07:00
unzleb64.c Productionize new APE loader and more 2021-10-02 08:27:03 -07:00
vcscanf.c Scan fixed-width integers in vcscanf (#424) 2022-06-26 21:27:07 -07:00
vsnprintf.c Make more fixes and improvements 2022-06-13 11:02:13 -07:00
vsprintf.c Support proper %g, %f, and %a float formatting 2021-03-05 10:31:16 -08:00
vsscanf.c Change license 2020-12-27 17:18:44 -08:00
wcstoi128.c Import C++ Standard Template Library 2022-03-22 06:41:54 -07:00
wcstoimax.c Import C++ Standard Template Library 2022-03-22 06:41:54 -07:00
wcstol.c Import C++ Standard Template Library 2022-03-22 06:41:54 -07:00
wcstoll.c Import C++ Standard Template Library 2022-03-22 06:41:54 -07:00
wcstoll_l.c Import C++ Standard Template Library 2022-03-22 06:41:54 -07:00
wcstou128.c Import C++ Standard Template Library 2022-03-22 06:41:54 -07:00
wcstoul.c Make numerous improvements 2021-09-28 01:52:34 -07:00
wcstoull.c Import C++ Standard Template Library 2022-03-22 06:41:54 -07:00
wcstoull_l.c Import C++ Standard Template Library 2022-03-22 06:41:54 -07:00
wcstoumax.c Import C++ Standard Template Library 2022-03-22 06:41:54 -07:00
zleb64.c Support Linux binfmt_misc and APE loading on Apple 2022-05-21 09:28:25 -07:00
zleb128.c Productionize new APE loader and more 2021-10-02 08:27:03 -07:00