1
0
mirror of https://github.com/Zygo/bees.git synced 2025-06-15 17:26:15 +02:00

openat2: create a weak syscall wrapper for it

openat2 allows closing more TOCTOU holes, but we can only use it when
the kernel supports it.

This should disappear seamlessly when libc implements the function.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
Zygo Blaxell
2025-01-09 01:16:02 -05:00
parent 613ddc3c71
commit a9b07d7684
3 changed files with 31 additions and 0 deletions

View File

@ -14,6 +14,7 @@ CRUCIBLE_OBJS = \
fs.o \
multilock.o \
ntoa.o \
openat2.o \
path.o \
process.o \
string.o \

13
lib/openat2.cc Normal file
View File

@ -0,0 +1,13 @@
#include "crucible/openat2.h"
extern "C" {
int
__attribute__((weak))
openat2(int const dirfd, const char *const pathname, struct open_how *const how, size_t const size)
throw()
{
return syscall(SYS_openat2, dirfd, pathname, how, size);
}
};