app-containers/crun: fix build w/ glibc 2.36

Closes: https://bugs.gentoo.org/863437
Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Sam James
2022-08-03 19:12:24 +01:00
parent 28b59e4aa3
commit 28853d92c3
2 changed files with 91 additions and 1 deletions

View File

@@ -5,7 +5,8 @@ EAPI=8
PYTHON_COMPAT=( python3_{8..10} )
inherit python-any-r1
# Can drop autotools/eautoreconf after next release & glibc patch gone
inherit autotools python-any-r1
DESCRIPTION="A fast and low-memory footprint OCI Container Runtime fully written in C"
HOMEPAGE="https://github.com/containers/crun"
@@ -36,6 +37,16 @@ BDEPEND="
# required to create linux "containers".
RESTRICT="test"
PATCHES=(
"${FILESDIR}"/${PN}-1.4.5-glibc-2.36.patch
)
src_prepare() {
default
eautoreconf
}
src_configure() {
local myeconfargs=(
$(use_enable bpf)

View File

@@ -0,0 +1,79 @@
https://bugs.gentoo.org/863437
https://github.com/containers/crun/commit/3df14584b84414df77b2079c1b8b48d44d0ceb61
From 3df14584b84414df77b2079c1b8b48d44d0ceb61 Mon Sep 17 00:00:00 2001
From: Giuseppe Scrivano <gscrivan@redhat.com>
Date: Tue, 26 Jul 2022 15:17:16 +0200
Subject: [PATCH] linux: fix build with glibc 2.36
glibc 2.36 has the new mount API in the <sys/mount.h> file. These
definitions conflict with the definitions in the <linux/mount.h>
file.
Add a check and include <linux/mount.h> only if it doesn't conflict
with <sys/mount.h>.
Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2110738
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
--- a/configure.ac
+++ b/configure.ac
@@ -174,11 +174,21 @@ LIBS=""
AC_MSG_CHECKING([for new mount API (fsconfig)])
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE([[
+ #include <sys/mount.h>
+ int cmd = FSCONFIG_CMD_CREATE;
+ ]])],
+ [AC_MSG_RESULT(yes)
+ AC_DEFINE([HAVE_FSCONFIG_CMD_CREATE_SYS_MOUNT_H], 1, [Define if FSCONFIG_CMD_CREATE is available in sys/mount.h])],
+ [AC_MSG_RESULT(no)])
+AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([[
+ /* also make sure it doesn't conflict with <sys/mount.h> since it is always used. */
+ #include <sys/mount.h>
#include <linux/mount.h>
int cmd = FSCONFIG_CMD_CREATE;
]])],
[AC_MSG_RESULT(yes)
- AC_DEFINE([HAVE_FSCONFIG_CMD_CREATE], 1, [Define if FSCONFIG_CMD_CREATE is available])],
+ AC_DEFINE([HAVE_FSCONFIG_CMD_CREATE_LINUX_MOUNT_H], 1, [Define if FSCONFIG_CMD_CREATE is available in linux/mount.h])],
[AC_MSG_RESULT(no)])
AC_MSG_CHECKING([for seccomp notify API])
--- a/src/libcrun/linux.c
+++ b/src/libcrun/linux.c
@@ -26,9 +26,13 @@
#include <fcntl.h>
#include <unistd.h>
#include <sys/mount.h>
-#ifdef HAVE_FSCONFIG_CMD_CREATE
+#ifdef HAVE_FSCONFIG_CMD_CREATE_LINUX_MOUNT_H
# include <linux/mount.h>
#endif
+#if defined HAVE_FSCONFIG_CMD_CREATE_LINUX_MOUNT_H || defined HAVE_FSCONFIG_CMD_CREATE_SYS_MOUNT_H
+# define HAVE_NEW_MOUNT_API
+#endif
+
#include <sys/syscall.h>
#include <sys/prctl.h>
#ifdef HAVE_CAP
@@ -990,7 +994,7 @@ open_mount_target (libcrun_container_t *container, const char *target_rel, libcr
static int
fsopen_mount (runtime_spec_schema_defs_mount *mount)
{
-#ifdef HAVE_FSCONFIG_CMD_CREATE
+#ifdef HAVE_NEW_MOUNT_API
cleanup_close int fsfd = -1;
int ret;
@@ -1016,7 +1020,7 @@ fsopen_mount (runtime_spec_schema_defs_mount *mount)
static int
fs_move_mount_to (int fd, int dirfd, const char *name)
{
-#ifdef HAVE_FSCONFIG_CMD_CREATE
+#ifdef HAVE_NEW_MOUNT_API
if (name)
return syscall_move_mount (fd, "", dirfd, name, MOVE_MOUNT_F_EMPTY_PATH);