summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn (J5) Palmieri <johnp@redhat.com>2006-08-10 20:09:43 +0000
committerJohn (J5) Palmieri <johnp@redhat.com>2006-08-10 20:09:43 +0000
commit2974c82428b5d9d3e1f504ba4052aec47fc2b415 (patch)
tree66973e6b07b52fcd01add8cdfb4c6e1bdac5fae0
parent5628ef82de9e853381ab61bab8c3cd3b1b622290 (diff)
downloaddbus-2974c82428b5d9d3e1f504ba4052aec47fc2b415.tar.gz
* 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>)
-rw-r--r--ChangeLog9
-rw-r--r--bus/activation.c8
-rw-r--r--dbus/dbus-address.c2
-rw-r--r--dbus/dbus-sysdeps.c29
-rw-r--r--dbus/dbus-sysdeps.h1
-rw-r--r--test/shell-test.c3
6 files changed, 48 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index fe0ddbc0..37192484 100644
--- 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):
diff --git a/bus/activation.c b/bus/activation.c
index 3d169017..7b7afe8a 100644
--- a/bus/activation.c
+++ b/bus/activation.c
@@ -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;
diff --git a/dbus/dbus-address.c b/dbus/dbus-address.c
index 7dc33e3e..ae9acfee 100644
--- a/dbus/dbus-address.c
+++ b/dbus/dbus-address.c
@@ -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);
diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c
index 9a2c1fde..43bfcd8c 100644
--- a/dbus/dbus-sysdeps.c
+++ b/dbus/dbus-sysdeps.c
@@ -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 */
diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h
index ed5b48e9..8e7c5019 100644
--- a/dbus/dbus-sysdeps.h
+++ b/dbus/dbus-sysdeps.h
@@ -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.
diff --git a/test/shell-test.c b/test/shell-test.c
index 46a387d7..4115f191 100644
--- a/test/shell-test.c
+++ b/test/shell-test.c
@@ -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)