+2006-08-10 John (J5) Palmieri <johnp@redhat.com>
+
+ * dbus/dbus-sysdeps.c:
+ * dbus/dbus-address.c:
+ * bus/activation.c:
+ * test/shell-test.c:
+ don't hardcode tmp directory (patch from Dave Meikle
+ <dmk at davemeikle dot co dot uk>)
+
2006-08-09 John (J5) Palmieri <johnp@redhat.com>
* dbus/dbus-dataslot.c (_dbus_data_slot_allocator_alloc):
#include <dbus/dbus-shell.h>
#include <dbus/dbus-spawn.h>
#include <dbus/dbus-timeout.h>
+#include <dbus/dbus-sysdeps.h>
#include <dirent.h>
#include <errno.h>
if (!_dbus_string_init (&directory))
return FALSE;
-
- if (!_dbus_string_append (&directory, "/tmp/dbus-reload-test-") ||
+
+ if (!_dbus_string_append (&directory, _dbus_get_tmpdir()))
+ return FALSE;
+
+ if (!_dbus_string_append (&directory, "/dbus-reload-test-") ||
!_dbus_generate_random_ascii (&directory, 6))
{
return FALSE;
&entries, &len, &error))
_dbus_assert_not_reached ("could not parse address");
_dbus_assert (len == 2);
- _dbus_assert (strcmp (dbus_address_entry_get_value (entries[0], "path"), "/tmp/foo") == 0);
+ _dbus_assert (strcmp (dbus_address_entry_get_value (entries[0], "path"), strcat(_dbus_get_tmpdir(),"/foo") == 0));
_dbus_assert (strcmp (dbus_address_entry_get_value (entries[1], "name"), "test") == 0);
_dbus_assert (strcmp (dbus_address_entry_get_value (entries[1], "sliff"), "sloff") == 0);
+/**
+ * Gets the temporary files directory by inspecting the environment variables
+ * TMPDIR, TMP, and TEMP in that order. If none of those are set "/tmp" is returned
+ *
+ * @returns char* - location of temp directory
+ */
+char*
+_dbus_get_tmpdir()
+{
+ char* tmpdir;
+
+ tmpdir = getenv("TMPDIR");
+ if (tmpdir) {
+ return tmpdir;
+ }
+
+ tmpdir = getenv("TMP");
+ if (tmpdir) {
+ return tmpdir;
+ }
+
+ tmpdir = getenv("TEMP");
+ if (tmpdir) {
+ return tmpdir;
+ }
+
+ return "/tmp";
+}
+
/** @} end of sysdeps */
/* tests in dbus-sysdeps-util.c */
dbus_bool_t _dbus_file_exists (const char *file);
dbus_bool_t _dbus_user_at_console (const char *username,
DBusError *error);
+char* _dbus_get_tmpdir();
/* Define DBUS_VA_COPY() to do the right thing for copying va_list variables.
* config.h may have already defined DBUS_VA_COPY as va_copy or __va_copy.
#include <dbus/dbus-memory.h>
#include <dbus/dbus-shell.h>
#include <dbus/dbus-string.h>
+#include <dbus/dbus-sysdeps.h>
static dbus_bool_t
test_command_line (const char *arg1, ...)
|| !test_command_line ("/opt/gnome/bin/service-start", NULL)
|| !test_command_line ("grep", "-l", "-r", "-i", "'whatever'", "files*.c", NULL)
|| !test_command_line ("/home/boston/johnp/devel-local/dbus/test/test-segfault", NULL)
- || !test_command_line ("ls", "-l", "-a", "--colors", "/tmp", NULL)
+ || !test_command_line ("ls", "-l", "-a", "--colors", _dbus_get_tmpdir(), NULL)
|| !test_command_line ("rsync-to-server", NULL)
|| !test_command_line ("test-segfault", "--no-segfault", NULL)
|| !test_command_line ("evolution", "mailto:pepe@cuco.com", NULL)