Signed-off-by: Jan Beich <[email protected]>
---
 Xext/shm.c              | 9 +++++++--
 configure.ac            | 2 +-
 include/dix-config.h.in | 3 +++
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/Xext/shm.c b/Xext/shm.c
index 91ea90b14..6edeba6fb 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -1199,7 +1199,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);
@@ -1209,15 +1208,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;
diff --git a/configure.ac b/configure.ac
index e202770c1..a795ecf1e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -157,7 +157,7 @@ dnl Checks for library functions.
 AC_CHECK_FUNCS([backtrace ffs 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])
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index ad1ab20a6..367d75c27 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -140,6 +140,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
 
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to