From 735f1b90972e1424e3037b9480a81b373990be4d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 24 Oct 2014 13:41:13 +0100 Subject: [PATCH 3/4] test-bus, test-dbus: close any inherited fds from caller It is probably a bug for them to pass us any fds without close-on-exec; but apparently CMake has this bug, and so does at least some NetBSD GUI environment. Cope. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=73689 Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83899 --- bus/test-main.c | 9 +++++++++ dbus/dbus-test-main.c | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/bus/test-main.c b/bus/test-main.c index 01d2287..788574f 100644 --- a/bus/test-main.c +++ b/bus/test-main.c @@ -31,6 +31,10 @@ #include #include "selinux.h" +#ifdef DBUS_UNIX +# include +#endif + #ifdef DBUS_ENABLE_EMBEDDED_TESTS static void die (const char *failure) @@ -109,6 +113,11 @@ main (int argc, char **argv) _dbus_string_init_const (&test_data_dir, dir); +#ifdef DBUS_UNIX + /* close any inherited fds so dbus-spawn's check for close-on-exec works */ + _dbus_close_all (); +#endif + if (!_dbus_threads_init_debug ()) die ("initializing debug threads"); diff --git a/dbus/dbus-test-main.c b/dbus/dbus-test-main.c index f6ef782..9a80f85 100644 --- a/dbus/dbus-test-main.c +++ b/dbus/dbus-test-main.c @@ -31,6 +31,10 @@ #include #endif +#ifdef DBUS_UNIX +# include +#endif + int main (int argc, char **argv) @@ -38,6 +42,11 @@ main (int argc, const char *test_data_dir; const char *specific_test; +#ifdef DBUS_UNIX + /* close any inherited fds so dbus-spawn's check for close-on-exec works */ + _dbus_close_all (); +#endif + #if HAVE_SETLOCALE setlocale(LC_ALL, ""); #endif -- 2.1.1