mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 22:02:27 +00:00
Improve ZIP filesystem and change its prefix
The ZIP filesystem has a breaking change. You now need to use /zip/ to open() / opendir() / etc. assets within the ZIP structure of your APE binary, instead of the previous convention of using zip: or zip! URIs. This is needed because Python likes to use absolute paths, and having ZIP paths encoded like URIs simply broke too many things. Many more system calls have been updated to be able to operate on ZIP files and file descriptors. In particular fcntl() and ioctl() since Python would do things like ask if a ZIP file is a terminal and get confused when the old implementation mistakenly said yes, because the fastest way to guarantee native file descriptors is to dup(2). This change also improves the async signal safety of zipos and ensures it doesn't maintain any open file descriptors beyond that which the user has opened. This change makes a lot of progress towards adding magic numbers that are specific to platforms other than Linux. The philosophy here is that, if you use an operating system like FreeBSD, then you should be able to take advantage of FreeBSD exclusive features, even if we don't polyfill them on other platforms. For example, you can now open() a file with the O_VERIFY flag. If your program runs on other platforms, then Cosmo will automatically set O_VERIFY to zero. This lets you safely use it without the need for #ifdef or ifstatements which detract from readability. One of the blindspots of the ASAN memory hardening we use to offer Rust like assurances has always been that memory passed to the kernel via system calls (e.g. writev) can't be checked automatically since the kernel wasn't built with MODE=asan. This change makes more progress ensuring that each system call will verify the soundness of memory before it's passed to the kernel. The code for doing these checks is fast, particularly for buffers, where it can verify 64 bytes a cycle. - Correct O_LOOP definition on NT - Introduce program_executable_name - Add ASAN guards to more system calls - Improve termios compatibility with BSDs - Fix bug in Windows auxiliary value encoding - Add BSD and XNU specific errnos and open flags - Add check to ensure build doesn't talk to internet
This commit is contained in:
parent
2730c66f4a
commit
00611e9b06
319 changed files with 4418 additions and 2599 deletions
220
third_party/python/Modules/signalmodule.c
vendored
220
third_party/python/Modules/signalmodule.c
vendored
|
@ -27,6 +27,7 @@
|
|||
#include "third_party/python/Include/pymacro.h"
|
||||
#include "third_party/python/Include/tupleobject.h"
|
||||
#include "third_party/python/Modules/posixmodule.h"
|
||||
#include "third_party/python/pyconfig.h"
|
||||
/* clang-format off */
|
||||
|
||||
/* Signal module -- many thanks to Lance Ellinghaus */
|
||||
|
@ -1230,18 +1231,9 @@ PyInit__signal(void)
|
|||
goto finally;
|
||||
Py_DECREF(x);
|
||||
|
||||
#ifdef SIG_BLOCK
|
||||
if (PyModule_AddIntMacro(m, SIG_BLOCK))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIG_UNBLOCK
|
||||
if (PyModule_AddIntMacro(m, SIG_UNBLOCK))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIG_SETMASK
|
||||
if (PyModule_AddIntMacro(m, SIG_SETMASK))
|
||||
goto finally;
|
||||
#endif
|
||||
if (PyModule_AddIntMacro(m, SIG_BLOCK)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIG_UNBLOCK)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIG_SETMASK)) goto finally;
|
||||
|
||||
x = IntHandler = PyDict_GetItemString(d, "default_int_handler");
|
||||
if (!x)
|
||||
|
@ -1268,173 +1260,47 @@ PyInit__signal(void)
|
|||
PyOS_setsig(SIGINT, signal_handler);
|
||||
}
|
||||
|
||||
#ifdef SIGHUP
|
||||
if (PyModule_AddIntMacro(m, SIGHUP))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGINT
|
||||
if (PyModule_AddIntMacro(m, SIGINT))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGBREAK
|
||||
if (PyModule_AddIntMacro(m, SIGBREAK))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGQUIT
|
||||
if (PyModule_AddIntMacro(m, SIGQUIT))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGILL
|
||||
if (PyModule_AddIntMacro(m, SIGILL))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGTRAP
|
||||
if (PyModule_AddIntMacro(m, SIGTRAP))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGIOT
|
||||
if (PyModule_AddIntMacro(m, SIGIOT))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGABRT
|
||||
if (PyModule_AddIntMacro(m, SIGABRT))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGEMT
|
||||
if (PyModule_AddIntMacro(m, SIGEMT))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGFPE
|
||||
if (PyModule_AddIntMacro(m, SIGFPE))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGKILL
|
||||
if (PyModule_AddIntMacro(m, SIGKILL))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGBUS
|
||||
if (PyModule_AddIntMacro(m, SIGBUS))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGSEGV
|
||||
if (PyModule_AddIntMacro(m, SIGSEGV))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGSYS
|
||||
if (PyModule_AddIntMacro(m, SIGSYS))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGPIPE
|
||||
if (PyModule_AddIntMacro(m, SIGPIPE))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGALRM
|
||||
if (PyModule_AddIntMacro(m, SIGALRM))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGTERM
|
||||
if (PyModule_AddIntMacro(m, SIGTERM))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGUSR1
|
||||
if (PyModule_AddIntMacro(m, SIGUSR1))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGUSR2
|
||||
if (PyModule_AddIntMacro(m, SIGUSR2))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGCLD
|
||||
if (PyModule_AddIntMacro(m, SIGCLD))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGCHLD
|
||||
if (PyModule_AddIntMacro(m, SIGCHLD))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGPWR
|
||||
if (PyModule_AddIntMacro(m, SIGPWR))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGIO
|
||||
if (PyModule_AddIntMacro(m, SIGIO))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGURG
|
||||
if (PyModule_AddIntMacro(m, SIGURG))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGWINCH
|
||||
if (PyModule_AddIntMacro(m, SIGWINCH))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGPOLL
|
||||
if (PyModule_AddIntMacro(m, SIGPOLL))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGSTOP
|
||||
if (PyModule_AddIntMacro(m, SIGSTOP))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGTSTP
|
||||
if (PyModule_AddIntMacro(m, SIGTSTP))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGCONT
|
||||
if (PyModule_AddIntMacro(m, SIGCONT))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGTTIN
|
||||
if (PyModule_AddIntMacro(m, SIGTTIN))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGTTOU
|
||||
if (PyModule_AddIntMacro(m, SIGTTOU))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGVTALRM
|
||||
if (PyModule_AddIntMacro(m, SIGVTALRM))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGPROF
|
||||
if (PyModule_AddIntMacro(m, SIGPROF))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGXCPU
|
||||
if (PyModule_AddIntMacro(m, SIGXCPU))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGXFSZ
|
||||
if (PyModule_AddIntMacro(m, SIGXFSZ))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGRTMIN
|
||||
if (PyModule_AddIntMacro(m, SIGRTMIN))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGRTMAX
|
||||
if (PyModule_AddIntMacro(m, SIGRTMAX))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef SIGINFO
|
||||
if (PyModule_AddIntMacro(m, SIGINFO))
|
||||
goto finally;
|
||||
#endif
|
||||
|
||||
#ifdef ITIMER_REAL
|
||||
if (PyModule_AddIntMacro(m, ITIMER_REAL))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef ITIMER_VIRTUAL
|
||||
if (PyModule_AddIntMacro(m, ITIMER_VIRTUAL))
|
||||
goto finally;
|
||||
#endif
|
||||
#ifdef ITIMER_PROF
|
||||
if (PyModule_AddIntMacro(m, ITIMER_PROF))
|
||||
goto finally;
|
||||
#endif
|
||||
if (PyModule_AddIntMacro(m, SIGHUP)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGINT)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGQUIT)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGILL)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGTRAP)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGIOT)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGABRT)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGFPE)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGKILL)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGBUS)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGSEGV)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGSYS)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGPIPE)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGALRM)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGTERM)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGUSR1)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGUSR2)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGCHLD)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGPWR)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGIO)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGURG)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGWINCH)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGPOLL)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGSTOP)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGTSTP)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGCONT)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGTTIN)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGTTOU)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGVTALRM)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGPROF)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGXCPU)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, SIGXFSZ)) goto finally;
|
||||
if (SIGEMT && PyModule_AddIntMacro(m, SIGEMT)) goto finally;
|
||||
if (SIGINFO && PyModule_AddIntMacro(m, SIGINFO)) goto finally;
|
||||
if (SIGRTMIN && PyModule_AddIntMacro(m, SIGRTMIN)) goto finally;
|
||||
if (SIGRTMAX && PyModule_AddIntMacro(m, SIGRTMAX)) goto finally;
|
||||
|
||||
#if defined (HAVE_SETITIMER) || defined (HAVE_GETITIMER)
|
||||
if (PyModule_AddIntMacro(m, ITIMER_REAL)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, ITIMER_VIRTUAL)) goto finally;
|
||||
if (PyModule_AddIntMacro(m, ITIMER_PROF)) goto finally;
|
||||
ItimerError = PyErr_NewException("signal.ItimerError",
|
||||
PyExc_IOError, NULL);
|
||||
if (ItimerError != NULL)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue