Currently we check for openat2 RESOLVE_IN_ROOT support using
AC_LINK_IFELSE.  HAVE_OPENAT2_RESOLVE_IN_ROOT is defined when
AC_LINK_IFELSE succeeds.

It is possible for openat2 and RESOLVE_IN_ROOT to be
present in headers but the kernel does not implement it.  In this case
AC_LINK_IFELSE succeeds and HAVE_OPENAT2_RESOLVE_IN_ROOT is defined,
but openat2 calls using RESOLVE_IN_ROOT always fail with ENOSYS for
instance.

Fix this by using AC_RUN_IFELSE instead of AC_LINK_IFELSE when
determining whether to define HAVE_OPENAT2_RESOLVE_IN_ROOT.

Suggested-by: Arnout Engelen <[email protected]>
Signed-off-by: Aaron Merey <[email protected]>
---
 configure.ac | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 58e58af2..eefe081b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -282,7 +282,7 @@ esac
 AC_CACHE_CHECK(
   [for openat2 with RESOLVE_IN_ROOT support],
   [eu_cv_openat2_RESOLVE_IN_ROOT],
-  [AC_LINK_IFELSE(
+  [AC_RUN_IFELSE(
     [AC_LANG_PROGRAM(
       [[#define _GNU_SOURCE
         #include <fcntl.h>
@@ -298,6 +298,7 @@ AC_CACHE_CHECK(
       ]]
     )],
     [eu_cv_openat2_RESOLVE_IN_ROOT=yes],
+    [eu_cv_openat2_RESOLVE_IN_ROOT=no],
     [eu_cv_openat2_RESOLVE_IN_ROOT=no]
   )]
 )
-- 
2.52.0

Reply via email to