diff options
author | Simon South <simon@simonsouth.net> | 2021-09-06 09:13:40 -0400 |
---|---|---|
committer | Simon South <simon@simonsouth.net> | 2022-06-13 09:09:54 -0400 |
commit | 1a40f64be11bce6bf143b76f4af0aa03f3c57845 (patch) | |
tree | f2bce7d48733bea6950af70631731e9e0287b518 /src/lib/sandbox | |
parent | b733f9d6ace63c710bc4b567627500cfbeb1592d (diff) | |
download | tor-1a40f64be11bce6bf143b76f4af0aa03f3c57845.tar.gz tor-1a40f64be11bce6bf143b76f4af0aa03f3c57845.zip |
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 (limited to 'src/lib/sandbox')
-rw-r--r-- | src/lib/sandbox/sandbox.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/lib/sandbox/sandbox.c b/src/lib/sandbox/sandbox.c index 7c024d7e37..728092c591 100644 --- 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, |