* dbus/dbus-sysdeps.c:
authorJohn (J5) Palmieri <johnp@redhat.com>
Thu, 10 Aug 2006 20:09:43 +0000 (20:09 +0000)
committerJohn (J5) Palmieri <johnp@redhat.com>
Thu, 10 Aug 2006 20:09:43 +0000 (20:09 +0000)
* 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>)

ChangeLog
bus/activation.c
dbus/dbus-address.c
dbus/dbus-sysdeps.c
dbus/dbus-sysdeps.h
test/shell-test.c

index fe0ddbc..3719248 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+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):
index 3d16901..7b7afe8 100644 (file)
@@ -33,6 +33,7 @@
 #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>
 
@@ -1918,8 +1919,11 @@ bus_activation_service_reload_test (const DBusString *test_data_dir)
 
   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;
index 7dc33e3..ae9acfe 100644 (file)
@@ -715,7 +715,7 @@ _dbus_address_test (void)
                           &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);
   
index 9a2c1fd..43bfcd8 100644 (file)
@@ -2998,6 +2998,35 @@ int _dbus_printf_string_upper_bound (const char *format,
 
 
 
+/**
+ * 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 */
index ed5b48e..8e7c501 100644 (file)
@@ -323,6 +323,7 @@ void _dbus_set_signal_handler (int               sig,
 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. 
index 46a387d..4115f19 100644 (file)
@@ -6,6 +6,7 @@
 #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, ...)
@@ -95,7 +96,7 @@ main (int argc, char **argv)
       || !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)