[Libguestfs] [nbdkit PATCH 4/8] Revert "RHEL 5: Define O_CLOEXEC and SOCK_CLOEXEC."

Eric Blake eblake at redhat.com
Wed Jul 31 21:31:32 UTC 2019


This reverts commit 25206df20275aeff346d9b86adf5e9be99cc9e43.

An upcoming patch wants to ensure no leaked fds from the server to a
child process.  POSIX has required O_CLOEXEC since 2008, and although
current POSIX doesn't yet specify full atomic interfaces everywhere
such as SOCK_CLOEXEC, it does have an open bug since 2014 [1]
recommending the full set of interfaces that will be mandatory in the
next revision of POSIX.  Most modern OS have caught up to that (RHEL 6
and FreeBSD 10 support SOCK_CLOEXEC, for example), and we're doing
ourselves a disservice by using silent fallback instead of actively
detecting with compile failure on systems that are still behind.

[1] http://austingroupbugs.net/view.php?id=411

Conflicts:
 filters/xz/xzfile.c - The fallback moved from plugins/xz/xzfile.c (and
in fact has been dead code since commit c879d310 made it a filter)
 plugins/file/file.c - context changes in the meantime
 src/internal.h - Moved to server/internal.h
---
 server/internal.h             | 8 --------
 filters/xz/xzfile.c           | 4 ----
 plugins/example2/example2.c   | 4 ----
 plugins/file/file.c           | 4 ----
 plugins/streaming/streaming.c | 4 ----
 5 files changed, 24 deletions(-)

diff --git a/server/internal.h b/server/internal.h
index 80ab879c..6207f0cf 100644
--- a/server/internal.h
+++ b/server/internal.h
@@ -50,14 +50,6 @@
 #define UNIX_PATH_MAX 108
 #endif

-#ifndef O_CLOEXEC
-#define O_CLOEXEC 0
-#endif
-
-#ifndef SOCK_CLOEXEC
-#define SOCK_CLOEXEC 0
-#endif
-
 #if HAVE_VALGRIND
 # include <valgrind.h>
 /* http://valgrind.org/docs/manual/faq.html#faq.unhelpful */
diff --git a/filters/xz/xzfile.c b/filters/xz/xzfile.c
index ebe7f29c..ee4af713 100644
--- a/filters/xz/xzfile.c
+++ b/filters/xz/xzfile.c
@@ -52,10 +52,6 @@

 #include "xzfile.h"

-#ifndef O_CLOEXEC
-#define O_CLOEXEC 0
-#endif
-
 #define XZ_HEADER_MAGIC     "\xfd" "7zXZ\0"
 #define XZ_HEADER_MAGIC_LEN 6
 #define XZ_FOOTER_MAGIC     "YZ"
diff --git a/plugins/example2/example2.c b/plugins/example2/example2.c
index d0bce155..6adc100a 100644
--- a/plugins/example2/example2.c
+++ b/plugins/example2/example2.c
@@ -48,10 +48,6 @@

 #include <nbdkit-plugin.h>

-#ifndef O_CLOEXEC
-#define O_CLOEXEC 0
-#endif
-
 static char *filename = NULL;

 /* A debug flag which can be set on the command line using
diff --git a/plugins/file/file.c b/plugins/file/file.c
index 52d330f7..9df5001d 100644
--- a/plugins/file/file.c
+++ b/plugins/file/file.c
@@ -61,10 +61,6 @@
 #include "cleanup.h"
 #include "isaligned.h"

-#ifndef O_CLOEXEC
-#define O_CLOEXEC 0
-#endif
-
 #ifndef HAVE_FDATASYNC
 #define fdatasync fsync
 #endif
diff --git a/plugins/streaming/streaming.c b/plugins/streaming/streaming.c
index 4ca3e765..4ab73b8b 100644
--- a/plugins/streaming/streaming.c
+++ b/plugins/streaming/streaming.c
@@ -43,10 +43,6 @@

 #include <nbdkit-plugin.h>

-#ifndef O_CLOEXEC
-#define O_CLOEXEC 0
-#endif
-
 static char *filename = NULL;
 static int fd = -1;

-- 
2.20.1




More information about the Libguestfs mailing list