summaryrefslogtreecommitdiff
path: root/dbus
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2022-02-08 17:55:49 +0400
committerSimon McVittie <smcv@collabora.com>2022-07-15 16:26:18 +0100
commitee7c08afafe4574c54e9555fe5ca6669f174bf5d (patch)
tree13484bf2dc9d18296d16c7b1e40f9524885b07a5 /dbus
parenta508ab583de138c22934e4622e6884057e824c22 (diff)
downloaddbus-ee7c08afafe4574c54e9555fe5ca6669f174bf5d.tar.gz
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 <marcandre.lureau@redhat.com>
Diffstat (limited to 'dbus')
-rw-r--r--dbus/dbus-server-protected.h4
-rw-r--r--dbus/dbus-server-unix.c44
-rw-r--r--dbus/dbus-server.c3
3 files changed, 45 insertions, 6 deletions
diff --git a/dbus/dbus-server-protected.h b/dbus/dbus-server-protected.h
index 650963f1..d9254f47 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 80da348b..fbb87dcb 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 cde3c986..7051c467 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 }