From: Marc-André Lureau Date: Tue, 8 Feb 2022 13:55:49 +0000 (+0400) Subject: dbus: handle unix server in a new function X-Git-Tag: dbus-1.15.0~26^2~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee7c08afafe4574c54e9555fe5ca6669f174bf5d;p=thirdparty%2Fdbus.git dbus: handle unix server in a new function Split _dbus_server_listen_platform_specific() to handle unix listenable address independently, allowing Windows support in following commit. Signed-off-by: Marc-André Lureau --- diff --git a/dbus/dbus-server-protected.h b/dbus/dbus-server-protected.h index 650963f12..d9254f47d 100644 --- a/dbus/dbus-server-protected.h +++ b/dbus/dbus-server-protected.h @@ -126,6 +126,10 @@ typedef enum DBUS_SERVER_LISTEN_ADDRESS_ALREADY_USED /**< address is already used */ } DBusServerListenResult; +DBusServerListenResult _dbus_server_listen_unix_socket (DBusAddressEntry *entry, + DBusServer **server_p, + DBusError *error); + DBusServerListenResult _dbus_server_listen_platform_specific (DBusAddressEntry *entry, DBusServer **server_p, DBusError *error); diff --git a/dbus/dbus-server-unix.c b/dbus/dbus-server-unix.c index 80da348bc..fbb87dcb1 100644 --- a/dbus/dbus-server-unix.c +++ b/dbus/dbus-server-unix.c @@ -40,8 +40,9 @@ */ /** - * Tries to interpret the address entry in a platform-specific - * way, creating a platform-specific server type if appropriate. + * Tries to interpret the address entry for UNIX socket + * addresses. + * * Sets error if the result is not OK. * * @param entry an address entry @@ -51,9 +52,9 @@ * */ DBusServerListenResult -_dbus_server_listen_platform_specific (DBusAddressEntry *entry, - DBusServer **server_p, - DBusError *error) +_dbus_server_listen_unix_socket (DBusAddressEntry *entry, + DBusServer **server_p, + DBusError *error) { const char *method; @@ -217,7 +218,38 @@ _dbus_server_listen_platform_specific (DBusAddressEntry *entry, return DBUS_SERVER_LISTEN_DID_NOT_CONNECT; } } - else if (strcmp (method, "systemd") == 0) + else + { + /* If we don't handle the method, we return NULL with the + * error unset + */ + _DBUS_ASSERT_ERROR_IS_CLEAR(error); + return DBUS_SERVER_LISTEN_NOT_HANDLED; + } +} + +/** + * Tries to interpret the address entry in a platform-specific + * way, creating a platform-specific server type if appropriate. + * Sets error if the result is not OK. + * + * @param entry an address entry + * @param server_p location to store a new DBusServer, or #NULL on failure. + * @param error location to store rationale for failure on bad address + * @returns the outcome + * + */ +DBusServerListenResult +_dbus_server_listen_platform_specific (DBusAddressEntry *entry, + DBusServer **server_p, + DBusError *error) +{ + const char *method; + + *server_p = NULL; + + method = dbus_address_entry_get_method (entry); + if (strcmp (method, "systemd") == 0) { int i, n; DBusSocket *fds; diff --git a/dbus/dbus-server.c b/dbus/dbus-server.c index cde3c986d..7051c467c 100644 --- a/dbus/dbus-server.c +++ b/dbus/dbus-server.c @@ -527,6 +527,9 @@ static const struct { DBusError *error); } listen_funcs[] = { { _dbus_server_listen_socket } +#ifndef _WIN32 /* FIXME: remove in next commit */ + , { _dbus_server_listen_unix_socket } +#endif , { _dbus_server_listen_platform_specific } #ifdef DBUS_ENABLE_EMBEDDED_TESTS , { _dbus_server_listen_debug_pipe }