Make improvements

- Introduce path module to redbean
- Fix glitch with linenoise printing extra line on eof
- Introduce closefrom() and close_range() system calls
- Make file descriptor closing more secure in pledge.com
This commit is contained in:
Justine Tunney 2022-07-20 15:13:39 -07:00
parent 439ad21b12
commit 1837dc2e85
31 changed files with 806 additions and 75 deletions

View file

@ -1,2 +0,0 @@
.include "o/libc/sysv/macros.internal.inc"
.scall close_range,0xfffffffffffff1b4,globl

View file

@ -1,2 +0,0 @@
.include "o/libc/sysv/macros.internal.inc"
.scall closefrom,0xfff11f1fdfffffff,globl

View file

@ -0,0 +1,2 @@
.include "o/libc/sysv/macros.internal.inc"
.scall sys_close_range,0xffffff23fffff1b4,globl,hidden

View file

@ -0,0 +1,2 @@
.include "o/libc/sysv/macros.internal.inc"
.scall sys_closefrom,0xfff11f1fdfffffff,globl,hidden

View file

@ -586,6 +586,12 @@ syscon ss MINSIGSTKSZ 2048 32768 2048 12288 8192 2048 # overlayed
syscon ss SS_ONSTACK 1 1 1 1 1 1 # unix consensus
syscon ss SS_DISABLE 2 4 4 4 4 2 # bsd consensus
# close_range() values
#
# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary
syscon close CLOSE_RANGE_UNSHARE 2 -1 -1 -1 -1 -1 #
syscon close CLOSE_RANGE_CLOEXEC 4 -1 -1 -1 -1 -1 #
# clock_{gettime,settime} timers
#
# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary

16
libc/sysv/consts/close.h Normal file
View file

@ -0,0 +1,16 @@
#ifndef COSMOPOLITAN_LIBC_SYSV_CONSTS_CLOSE_H_
#define COSMOPOLITAN_LIBC_SYSV_CONSTS_CLOSE_H_
#include "libc/runtime/symbolic.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
extern const long CLOSE_RANGE_UNSHARE;
extern const long CLOSE_RANGE_CLOEXEC;
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#define CLOSE_RANGE_UNSHARE SYMBOLIC(CLOSE_RANGE_UNSHARE)
#define CLOSE_RANGE_CLOEXEC SYMBOLIC(CLOSE_RANGE_CLOEXEC)
#endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_CLOSE_H_ */

View file

@ -383,7 +383,7 @@ scall fsmount 0xfffffffffffff1b0 globl
scall fspick 0xfffffffffffff1b1 globl
scall pidfd_open 0xfffffffffffff1b2 globl
scall clone3 0xfffffffffffff1b3 globl
scall close_range 0xfffffffffffff1b4 globl
scall sys_close_range 0xffffff23fffff1b4 globl hidden # linux 5.9
scall sys_openat2 0xfffffffffffff1b5 globl hidden # Linux 5.6
scall pidfd_getfd 0xfffffffffffff1b6 globl
scall sys_faccessat2 0xfffffffffffff1b7 globl hidden
@ -463,7 +463,7 @@ scall chflagsat 0xfff06b21cfffffff globl
scall profil 0x02c02c02cfffffff globl
scall fhstatfs 0xfff04122efffffff globl
scall utrace 0x1320d114ffffffff globl
scall closefrom 0xfff11f1fdfffffff globl
scall sys_closefrom 0xfff11f1fdfffffff globl hidden
#───────────────────────────XNU──────────────────────────────
scall __pthread_markcancel 0xfffffffff214cfff globl
scall __pthread_kill 0xfffffffff2148fff globl