cursor: Use memfd_create() when available

This (so-far) Linux-only API lets users create file descriptors purely
in memory, without any backing file on the filesystem and the race
condition which could ensue when unlink()ing it.

It also allows seals to be placed on the file, ensuring to every other
process that we won’t be allowed to shrink the contents, potentially
causing a SIGBUS when they try reading it.

This patch is best viewed with the -w option of git log -p.

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Reviewed-by: Simon Ser <contact@emersion.fr>
This commit is contained in:
Emmanuel Gil Peyrot 2019-02-16 16:06:52 +01:00 committed by Simon Ser
parent 9d63c9ff84
commit 6908c8c85a
2 changed files with 46 additions and 20 deletions

View file

@ -63,7 +63,7 @@ fi
AC_SUBST(GCC_CFLAGS)
AC_CHECK_HEADERS([sys/prctl.h])
AC_CHECK_FUNCS([accept4 mkostemp posix_fallocate prctl])
AC_CHECK_FUNCS([accept4 mkostemp posix_fallocate prctl memfd_create])
# *BSD don't have libdl, but they have its functions in libc
WESTON_SEARCH_LIBS([DL], [dl], [dlsym])