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
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
This commit is contained in:
Simon McVittie 2014-10-24 13:41:13 +01:00 committed by Ralf Habacker
parent 8fd6e561df
commit 3d363220ad
2 changed files with 18 additions and 0 deletions

View file

@ -31,6 +31,10 @@
#include <dbus/dbus-message-internal.h>
#include "selinux.h"
#ifdef DBUS_UNIX
# include <dbus/dbus-sysdeps-unix.h>
#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");

View file

@ -31,6 +31,10 @@
#include <locale.h>
#endif
#ifdef DBUS_UNIX
# include <dbus/dbus-sysdeps-unix.h>
#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