diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-04-01 12:19:43 +0100 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-04-01 12:30:55 +0100 |
| commit | 44004191cbc1a2a4fc2a60aca215560b5d989b7c (patch) | |
| tree | 6e1baaf6fc5a90e6aea4f3987486d74b6df06b24 /util/libreboot-utils/lib | |
| parent | 2c40ad78166c4cdb667caf4238080a4708c43326 (diff) | |
lbutils: don't set USE_OPENAT and USE_URANDOM
these can be set explicitly in the compiler flags,
e.g.
make CC="cc -DUSE_OPENAT=1 -DUSE_URANDOM=1"
these options, if set to 1, will cause you to use
the code as if it were running on non-linux systems
such as openbsd. of course, some differences will
still exist, but this is useful for portability
testing when compiling on linux.
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/libreboot-utils/lib')
| -rw-r--r-- | util/libreboot-utils/lib/file.c | 6 | ||||
| -rw-r--r-- | util/libreboot-utils/lib/mkhtemp.c | 9 | ||||
| -rw-r--r-- | util/libreboot-utils/lib/rand.c | 6 |
3 files changed, 13 insertions, 8 deletions
diff --git a/util/libreboot-utils/lib/file.c b/util/libreboot-utils/lib/file.c index 3f15aabf..1df5cfb3 100644 --- a/util/libreboot-utils/lib/file.c +++ b/util/libreboot-utils/lib/file.c @@ -22,12 +22,15 @@ long max = pathconf("/", _PC_PATH_MAX); /* for openat2: */ #ifdef __linux__ +#if !defined(USE_OPENAT) || \ + ((USE_OPENAT) < 1) /* if 1: use openat, not openat2 */ #ifndef _GNU_SOURCE #define _GNU_SOURCE 1 #endif #include <linux/openat2.h> #include <sys/syscall.h> #endif +#endif #include <sys/types.h> #include <sys/stat.h> @@ -612,7 +615,8 @@ open_file_on_eintr(const char *path, } -#ifdef __linux__ /* we use openat2 on linux */ +#if defined(__linux__) && \ + ((USE_OPENAT) < 1) /* we use openat2 on linux */ int openat_on_eintr(int dirfd, const char *path, int flags, mode_t mode) diff --git a/util/libreboot-utils/lib/mkhtemp.c b/util/libreboot-utils/lib/mkhtemp.c index 11a5bdb9..4e7f6013 100644 --- a/util/libreboot-utils/lib/mkhtemp.c +++ b/util/libreboot-utils/lib/mkhtemp.c @@ -10,6 +10,8 @@ /* for openat2 / fast path: */ #ifdef __linux__ +#if !defined(USE_OPENAT) || \ + ((USE_OPENAT) < 1) /* if 1: use openat, not openat2 */ #ifndef _GNU_SOURCE #define _GNU_SOURCE 1 #endif @@ -22,6 +24,7 @@ #define AT_EMPTY_PATH 0x1000 #endif #endif +#endif #include <sys/types.h> #include <sys/stat.h> @@ -543,7 +546,8 @@ mkhtemp_try_create(int dirfd, goto err; if (type == MKHTEMP_FILE) { -#ifdef __linux__ +#if defined(__linux__) && \ + (!defined(USE_OPENAT) || ((USE_OPENAT) < 1)) /* try O_TMPFILE fast path */ if (mkhtemp_tmpfile_linux(dirfd, st_dir_first, fname_copy, @@ -652,7 +656,8 @@ err: we still use openat() on bsd, which is still ok with our other mitigations */ -#ifdef __linux__ +#if defined(__linux__) && \ + (!defined(USE_OPENAT) || ((USE_OPENAT) < 1)) int mkhtemp_tmpfile_linux(int dirfd, struct stat *st_dir_first, diff --git a/util/libreboot-utils/lib/rand.c b/util/libreboot-utils/lib/rand.c index 726d5cd2..8e50e110 100644 --- a/util/libreboot-utils/lib/rand.c +++ b/util/libreboot-utils/lib/rand.c @@ -154,7 +154,7 @@ retry_rand: { while (rw_retry(saved_errno, rc = read_on_eintr(fd, - (unsigned char *)buf + off, n - off, 0))); + (unsigned char *)buf + off, n - off))); #elif defined(__linux__) long rc; while (sys_retry(saved_errno, @@ -183,10 +183,6 @@ retry_rand: { reset_caller_errno(0); return; err: -#if defined(USE_URANDOM) && \ - ((USE_URANDOM) > 0) - close_on_eintr(&fd); -#endif (void) with_fallback_errno(ECANCELED); exitf("Randomisierungsfehler"); exit(EXIT_FAILURE); |
