Skip to content

Commit

Permalink
Merge pull request containers#1299 from alvistack/1.9-FSOPEN_CLOEXEC
Browse files Browse the repository at this point in the history
Fix CentOS 7 Build by Checking if FSOPEN_CLOEXEC exists
  • Loading branch information
giuseppe authored Sep 8, 2023
2 parents e748e8b + 8645d1a commit c0a40fa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ AC_CHECK_HEADERS([error.h linux/openat2.h stdatomic.h linux/ioprio.h])
AC_CHECK_TYPES([atomic_int], [], [], [[#include <stdatomic.h>]])
AC_CHECK_TYPES([atomic_bool], [], [], [[#include <stdatomic.h>]])

AC_CHECK_FUNCS(copy_file_range fgetxattr statx fgetpwent_r issetugid)
AC_CHECK_FUNCS(copy_file_range fgetxattr statx fgetpwent_r issetugid memfd_create)

AC_ARG_ENABLE(crun,
AS_HELP_STRING([--enable-crun], [Include crun executable in installation (default: yes)]),
Expand Down
12 changes: 12 additions & 0 deletions src/libcrun/linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@
# define MOVE_MOUNT_T_EMPTY_PATH 0x00000040
#endif

#ifndef FSOPEN_CLOEXEC
# define FSOPEN_CLOEXEC 0x00000001
#endif

#ifndef FSMOUNT_CLOEXEC
# define FSMOUNT_CLOEXEC 0x00000001
#endif

#ifndef FSCONFIG_CMD_CREATE
# define FSCONFIG_CMD_CREATE 6
#endif

struct remount_s
{
struct remount_s *next;
Expand Down
4 changes: 4 additions & 0 deletions src/libcrun/seccomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,13 @@ libcrun_apply_seccomp (int infd, int listener_receiver_fd, const char *receiver_
return crun_make_error (err, 0, "the `SECCOMP_FILTER_FLAG_NEW_LISTENER` flag is not supported");
# endif

# ifdef HAVE_MEMFD_CREATE
memfd = memfd_create ("seccomp-helper-memfd", O_RDWR);
if (UNLIKELY (memfd < 0))
return crun_make_error (err, errno, "memfd_create");
# else
return crun_make_error (err, ENOSYS, "memfd_create non supported");
# endif

ret = ftruncate (memfd, sizeof (atomic_int));
if (UNLIKELY (ret < 0))
Expand Down

0 comments on commit c0a40fa

Please sign in to comment.