commit 1a40f64be11bce6bf143b76f4af0aa03f3c57845
parent b733f9d6ace63c710bc4b567627500cfbeb1592d
Author: Simon South <simon@simonsouth.net>
Date: Mon, 6 Sep 2021 09:13:40 -0400
sandbox: Assume "openat" syscall is used where "open" is unavailable
On architectures where Linux does not provide the legacy "open" syscall glibc
necessarily uses "openat" instead. Omit the unnecessary glibc-version check on
these systems.
Diffstat:
1 file changed, 8 insertions(+), 0 deletions(-)
diff --git a/src/lib/sandbox/sandbox.c b/src/lib/sandbox/sandbox.c
@@ -505,7 +505,11 @@ is_libc_at_least(int major, int minor)
static int
libc_uses_openat_for_open(void)
{
+#ifdef __NR_open
return is_libc_at_least(2, 26);
+#else
+ return 1;
+#endif /* defined(__NR_open) */
}
/* Return true if we think we're running with a libc that uses openat for the
@@ -513,9 +517,13 @@ libc_uses_openat_for_open(void)
static int
libc_uses_openat_for_opendir(void)
{
+#ifdef __NR_open
// libc 2.27 and above or between 2.15 (inclusive) and 2.22 (exclusive)
return is_libc_at_least(2, 27) ||
(is_libc_at_least(2, 15) && !is_libc_at_least(2, 22));
+#else
+ return 1;
+#endif /* defined(__NR_open) */
}
/** Allow a single file to be opened. If <b>use_openat</b> is true,