summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-transport-unix.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-03-31 08:19:50 +0000
committerHavoc Pennington <hp@redhat.com>2003-03-31 08:19:50 +0000
commit29c71168cd17b11eed65023c97aff401d5305b01 (patch)
tree431a05106d857cf38abbdea74a375326f395485e /dbus/dbus-transport-unix.c
parentbc86794f23fa538a405813fb61b531c2eacc9ae1 (diff)
2003-03-31 Havoc Pennington <hp@pobox.com>
* dbus/dbus-transport-unix.c (_dbus_transport_new_for_domain_socket) (_dbus_transport_new_for_tcp_socket): these didn't need the "server" argument since they are always client side * dbus/dbus-server.c (dbus_server_get_address): new function * bus/main.c (main): take the configuration file as an argument. * test/data/valid-config-files/debug-allow-all.conf: new file to use with dispatch.c tests for example * bus/test-main.c (main): require test data dir * bus/bus.c (bus_context_new): change this to take a configuration file name as argument * doc/config-file.txt (Elements): add <servicedir> * bus/system.conf, bus/session.conf: new files * dbus/dbus-bus.c (dbus_bus_get): look for system bus on well-known socket if none set * configure.in: create system.conf and session.conf
Diffstat (limited to 'dbus/dbus-transport-unix.c')
-rw-r--r--dbus/dbus-transport-unix.c64
1 files changed, 51 insertions, 13 deletions
diff --git a/dbus/dbus-transport-unix.c b/dbus/dbus-transport-unix.c
index d34565eb..81672de5 100644
--- a/dbus/dbus-transport-unix.c
+++ b/dbus/dbus-transport-unix.c
@@ -963,11 +963,13 @@ static DBusTransportVTable unix_vtable = {
*
* @param fd the file descriptor.
* @param server #TRUE if this transport is on the server side of a connection
+ * @param address the transport's address
* @returns the new transport, or #NULL if no memory.
*/
DBusTransport*
-_dbus_transport_new_for_fd (int fd,
- dbus_bool_t server)
+_dbus_transport_new_for_fd (int fd,
+ dbus_bool_t server,
+ const DBusString *address)
{
DBusTransportUnix *unix_transport;
@@ -997,7 +999,7 @@ _dbus_transport_new_for_fd (int fd,
if (!_dbus_transport_init_base (&unix_transport->base,
&unix_vtable,
- server))
+ server, address))
goto failed_4;
unix_transport->fd = fd;
@@ -1024,27 +1026,41 @@ _dbus_transport_new_for_fd (int fd,
/**
* Creates a new transport for the given Unix domain socket
- * path.
+ * path. This creates a client-side of a transport.
*
* @param path the path to the domain socket.
- * @param server #TRUE if this transport is on the server side of a connection
* @param error address where an error can be returned.
* @returns a new transport, or #NULL on failure.
*/
DBusTransport*
_dbus_transport_new_for_domain_socket (const char *path,
- dbus_bool_t server,
DBusError *error)
{
int fd;
DBusTransport *transport;
-
+ DBusString address;
+
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
+
+ if (!_dbus_string_init (&address, _DBUS_INT_MAX))
+ {
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ return NULL;
+ }
+
+ if (!_dbus_string_append (&address, "unix:path=") ||
+ !_dbus_string_append (&address, path))
+ {
+ _dbus_string_free (&address);
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ return NULL;
+ }
fd = _dbus_connect_unix_socket (path, error);
if (fd < 0)
{
_DBUS_ASSERT_ERROR_IS_SET (error);
+ _dbus_string_free (&address);
return NULL;
}
@@ -1052,14 +1068,17 @@ _dbus_transport_new_for_domain_socket (const char *path,
_dbus_verbose ("Successfully connected to unix socket %s\n",
path);
-
- transport = _dbus_transport_new_for_fd (fd, server);
+
+ transport = _dbus_transport_new_for_fd (fd, FALSE, &address);
if (transport == NULL)
{
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ _dbus_string_free (&address);
_dbus_close (fd, NULL);
fd = -1;
}
+
+ _dbus_string_free (&address);
return transport;
}
@@ -1069,25 +1088,41 @@ _dbus_transport_new_for_domain_socket (const char *path,
*
* @param host the host to connect to
* @param port the port to connect to
- * @param server #TRUE if this transport is on the server side of a connection
* @param error location to store reason for failure.
* @returns a new transport, or #NULL on failure.
*/
DBusTransport*
_dbus_transport_new_for_tcp_socket (const char *host,
dbus_int32_t port,
- dbus_bool_t server,
DBusError *error)
{
int fd;
DBusTransport *transport;
-
+ DBusString address;
+
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
+
+ if (!_dbus_string_init (&address, _DBUS_INT_MAX))
+ {
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ return NULL;
+ }
+
+ if (!_dbus_string_append (&address, "tcp:host=") ||
+ !_dbus_string_append (&address, host) ||
+ !_dbus_string_append (&address, ",port=") ||
+ !_dbus_string_append_int (&address, port))
+ {
+ _dbus_string_free (&address);
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ return NULL;
+ }
fd = _dbus_connect_tcp_socket (host, port, error);
if (fd < 0)
{
_DBUS_ASSERT_ERROR_IS_SET (error);
+ _dbus_string_free (&address);
return NULL;
}
@@ -1096,14 +1131,17 @@ _dbus_transport_new_for_tcp_socket (const char *host,
_dbus_verbose ("Successfully connected to tcp socket %s:%d\n",
host, port);
- transport = _dbus_transport_new_for_fd (fd, server);
+ transport = _dbus_transport_new_for_fd (fd, FALSE, &address);
if (transport == NULL)
{
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
_dbus_close (fd, NULL);
+ _dbus_string_free (&address);
fd = -1;
}
+ _dbus_string_free (&address);
+
return transport;
}