diff -uNr dbus-1.6.0/dbus/dbus-server-unix.c dbus-1.6.0-2/dbus/dbus-server-unix.c --- dbus-1.6.0/dbus/dbus-server-unix.c 2012-03-28 19:43:32.000000000 +0200 +++ dbus-1.6.0-2/dbus/dbus-server-unix.c 2012-06-11 21:08:18.377050743 +0200 @@ -149,7 +149,7 @@ } else if (strcmp (method, "systemd") == 0) { - int n, *fds; + int i, n, *fds; DBusString address; n = _dbus_listen_systemd_sockets (&fds, error); @@ -159,13 +159,19 @@ return DBUS_SERVER_LISTEN_DID_NOT_CONNECT; } - _dbus_string_init_const (&address, "systemd:"); + _dbus_string_init(&address); + for (i = 0; i < n; i++) + { + if ( i > 0) + { + _dbus_string_append (&address, ";"); + } + _dbus_append_address_from_socket (fds[i], &address); + } *server_p = _dbus_server_new_for_socket (fds, n, &address, NULL); if (*server_p == NULL) { - int i; - for (i = 0; i < n; i++) { _dbus_close_socket (fds[i], NULL); diff -uNr dbus-1.6.0/dbus/dbus-sysdeps-unix.c dbus-1.6.0-2/dbus/dbus-sysdeps-unix.c --- dbus-1.6.0/dbus/dbus-sysdeps-unix.c 2012-06-05 13:17:45.000000000 +0200 +++ dbus-1.6.0-2/dbus/dbus-sysdeps-unix.c 2012-06-11 21:09:24.144228538 +0200 @@ -4086,4 +4086,60 @@ close (i); } +int _dbus_append_address_from_socket (int fd, DBusString *address) +{ + struct sockaddr_storage socket; + struct sockaddr_in *inet_addr = (struct sockaddr_in*)&socket; + struct sockaddr_in6 *inet6_addr = (struct sockaddr_in6*)&socket; + struct sockaddr_un *unix_addr = (struct sockaddr_un*)&socket; + char host[50]; + int size = sizeof(struct sockaddr_storage); + + getsockname(fd, (struct sockaddr*)&socket, &size); + + switch(socket.ss_family) + { + case AF_UNIX: + if (unix_addr->sun_path[0]=='\0') + { + _dbus_string_append (address, "unix:abstract="); + _dbus_string_append (address, &(unix_addr->sun_path[1])); + } + else + { + _dbus_string_append (address, "unix:path="); + _dbus_string_append (address, unix_addr->sun_path); + } + break; + case AF_INET: + _dbus_string_append (address, "tcp:family=ipv4,host="); + snprintf(host, 26, "%hu.%hu.%hu.%hu,port=%hu", + (inet_addr->sin_addr.s_addr & 0xFF000000)>>24, + (inet_addr->sin_addr.s_addr & 0x00FF0000)>>16, + (inet_addr->sin_addr.s_addr & 0x0000FF00)>>8, + (inet_addr->sin_addr.s_addr & 0x000000FF), + inet_addr->sin_port); + _dbus_string_append (address, host); + break; + case AF_INET6: + _dbus_string_append (address, "tcp:family=ipv6,host="); + snprintf(host, 50, "%.2hhx%.2hhx:%.2hhx%.2hhx:%.2hhx%.2hhx:%.2hhx%.2hhx:" + "%.2hhx%.2hhx:%.2hhx%.2hhx:%.2hhx%.2hhx:%.2hhx%.2hhx,port=%hu", + inet6_addr->sin6_addr.s6_addr[0], inet6_addr->sin6_addr.s6_addr[1], + inet6_addr->sin6_addr.s6_addr[2], inet6_addr->sin6_addr.s6_addr[3], + inet6_addr->sin6_addr.s6_addr[4], inet6_addr->sin6_addr.s6_addr[5], + inet6_addr->sin6_addr.s6_addr[6], inet6_addr->sin6_addr.s6_addr[7], + inet6_addr->sin6_addr.s6_addr[8], inet6_addr->sin6_addr.s6_addr[9], + inet6_addr->sin6_addr.s6_addr[10], inet6_addr->sin6_addr.s6_addr[11], + inet6_addr->sin6_addr.s6_addr[12], inet6_addr->sin6_addr.s6_addr[13], + inet6_addr->sin6_addr.s6_addr[14], inet6_addr->sin6_addr.s6_addr[15], + inet6_addr->sin6_port); + _dbus_string_append (address, host); + break; + default: + return -1; + } + return 0; +} + /* tests in dbus-sysdeps-util.c */ diff -uNr dbus-1.6.0/dbus/dbus-sysdeps-unix.h dbus-1.6.0-2/dbus/dbus-sysdeps-unix.h --- dbus-1.6.0/dbus/dbus-sysdeps-unix.h 2012-06-05 13:17:45.000000000 +0200 +++ dbus-1.6.0-2/dbus/dbus-sysdeps-unix.h 2012-06-11 21:05:45.459962468 +0200 @@ -138,6 +138,7 @@ void _dbus_close_all (void); +int _dbus_append_address_from_socket (int fd, DBusString *address); /** @} */ DBUS_END_DECLS