+ if (tmpdir != NULL)
+ {
+ DBusString full_path;
+ DBusString filename;
+
+ if (!_dbus_string_init (&full_path))
+ {
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ goto out;
+ }
+
+ if (!_dbus_string_init (&filename))
+ {
+ _dbus_string_free (&full_path);
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ goto out;
+ }
+
+ if (!_dbus_string_append (&filename,
+ "dbus-") ||
+ !_dbus_generate_random_ascii (&filename, 10) ||
+ !_dbus_string_append (&full_path, tmpdir) ||
+ !_dbus_concat_dir_and_file (&full_path, &filename))
+ {
+ _dbus_string_free (&full_path);
+ _dbus_string_free (&filename);
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ goto out;
+ }
+
+ /* FIXME - we will unconditionally unlink() the path.
+ * unlink() does not follow symlinks, but would like
+ * independent confirmation this is safe enough. See
+ * also _dbus_listen_unix_socket() and comments therein.
+ */
+
+ server =
+ _dbus_server_new_for_domain_socket (_dbus_string_get_const_data (&full_path),
+ error);
+
+ _dbus_string_free (&full_path);
+ _dbus_string_free (&filename);
+ }
+ else
+ {
+ server = _dbus_server_new_for_domain_socket (path, error);
+ }