shm, xwayland: prefer atomic close-on-exec without O_TMPFILE
Signed-off-by: Jan Beich <jbeich@FreeBSD.org> Reviewed-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
parent
3e3b8a40fe
commit
1e23f03dd5
|
@ -1195,7 +1195,6 @@ shm_tmpfile(void)
|
|||
{
|
||||
#ifdef SHMDIR
|
||||
int fd;
|
||||
int flags;
|
||||
char template[] = SHMDIR "/shmfd-XXXXXX";
|
||||
#ifdef O_TMPFILE
|
||||
fd = open(SHMDIR, O_TMPFILE|O_RDWR|O_CLOEXEC|O_EXCL, 0666);
|
||||
|
@ -1205,15 +1204,21 @@ shm_tmpfile(void)
|
|||
}
|
||||
ErrorF ("Not using O_TMPFILE\n");
|
||||
#endif
|
||||
#ifdef HAVE_MKOSTEMP
|
||||
fd = mkostemp(template, O_CLOEXEC);
|
||||
#else
|
||||
fd = mkstemp(template);
|
||||
#endif
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
unlink(template);
|
||||
flags = fcntl(fd, F_GETFD);
|
||||
#ifndef HAVE_MKOSTEMP
|
||||
int flags = fcntl(fd, F_GETFD);
|
||||
if (flags != -1) {
|
||||
flags |= FD_CLOEXEC;
|
||||
(void) fcntl(fd, F_SETFD, &flags);
|
||||
}
|
||||
#endif
|
||||
return fd;
|
||||
#else
|
||||
return -1;
|
||||
|
|
|
@ -157,7 +157,7 @@ dnl Checks for library functions.
|
|||
AC_CHECK_FUNCS([backtrace geteuid getuid issetugid getresuid \
|
||||
getdtablesize getifaddrs getpeereid getpeerucred getprogname getzoneid \
|
||||
mmap posix_fallocate seteuid shmctl64 strncasecmp vasprintf vsnprintf \
|
||||
walkcontext setitimer poll epoll_create1])
|
||||
walkcontext setitimer poll epoll_create1 mkostemp])
|
||||
AC_CONFIG_LIBOBJ_DIR([os])
|
||||
AC_REPLACE_FUNCS([reallocarray strcasecmp strcasestr strlcat strlcpy strndup\
|
||||
timingsafe_memcmp])
|
||||
|
|
|
@ -134,6 +134,9 @@
|
|||
/* Define to 1 if you have the <linux/fb.h> header file. */
|
||||
#undef HAVE_LINUX_FB_H
|
||||
|
||||
/* Define to 1 if you have the `mkostemp' function. */
|
||||
#undef HAVE_MKOSTEMP
|
||||
|
||||
/* Define to 1 if you have the `mmap' function. */
|
||||
#undef HAVE_MMAP
|
||||
|
||||
|
|
|
@ -119,6 +119,7 @@ conf_data.set('HAVE_GETPEEREID', cc.has_function('getpeereid'))
|
|||
conf_data.set('HAVE_GETPEERUCRED', cc.has_function('getpeerucred'))
|
||||
conf_data.set('HAVE_GETPROGNAME', cc.has_function('getprogname'))
|
||||
conf_data.set('HAVE_GETZONEID', cc.has_function('getzoneid'))
|
||||
conf_data.set('HAVE_MKOSTEMP', cc.has_function('mkostemp'))
|
||||
conf_data.set('HAVE_MMAP', cc.has_function('mmap'))
|
||||
conf_data.set('HAVE_POLL', cc.has_function('poll'))
|
||||
conf_data.set('HAVE_POLLSET_CREATE', cc.has_function('pollset_create'))
|
||||
|
|
Loading…
Reference in New Issue
Block a user