#include <string.h>
#include <sys/types.h>
+#include <glib/gstdio.h>
+
#if defined(HAVE_APPARMOR_2_10) && defined(DBUS_TEST_APPARMOR_ACTIVATION)
#include <sys/apparmor.h>
#endif
const char *activated_name;
DBusMessage *activated_message;
dbus_bool_t activated_filter_added;
+
+ gchar *tmp_runtime_dir;
} Fixture;
typedef struct
setup (Fixture *f,
gconstpointer context G_GNUC_UNUSED)
{
+#if defined(DBUS_TEST_APPARMOR_ACTIVATION) && defined(HAVE_APPARMOR_2_10)
+ aa_features *features;
+#endif
+
+ f->ge = NULL;
+ dbus_error_init (&f->e);
+
+ f->tmp_runtime_dir = g_dir_make_tmp ("dbus-daemon-test.XXXXXX", &f->ge);
+ g_assert_no_error (f->ge);
+
#if defined(DBUS_TEST_APPARMOR_ACTIVATION) && !defined(HAVE_APPARMOR_2_10)
g_test_skip ("AppArmor support not compiled or AppArmor 2.10 unavailable");
#else
#if defined(DBUS_TEST_APPARMOR_ACTIVATION)
- aa_features *features;
-
if (!aa_is_enabled ())
{
g_test_message ("aa_is_enabled() -> %s", g_strerror (errno));
f->ctx = test_main_context_get ();
- f->ge = NULL;
- dbus_error_init (&f->e);
-
f->address = test_get_dbus_daemon (
"valid-config-files/systemd-activation.conf",
- TEST_USER_ME, NULL, &f->daemon_pid);
+ TEST_USER_ME, f->tmp_runtime_dir, &f->daemon_pid);
if (f->address == NULL)
return;
test_main_context_unref (f->ctx);
g_free (f->address);
+
+ if (f->tmp_runtime_dir != NULL)
+ {
+ test_rmdir_if_exists (f->tmp_runtime_dir);
+
+ g_free (f->tmp_runtime_dir);
+ }
}
static const Config deny_send_tests[] =
g_strerror (saved_errno));
}
}
+
+/*
+ * Delete empty directory @path, with a retry loop if the system call is
+ * interrupted by an async signal. If @path does not exist, ignore.
+ */
+void
+test_rmdir_if_exists (const gchar *path)
+{
+ while (g_remove (path) != 0)
+ {
+ int saved_errno = errno;
+
+ if (saved_errno == ENOENT)
+ return;
+
+#ifdef G_OS_UNIX
+ if (saved_errno == EINTR)
+ continue;
+#endif
+
+ g_error ("Unable to remove directory \"%s\": %s", path,
+ g_strerror (saved_errno));
+ }
+}