diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2022-02-08 13:04:33 +0400 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2022-07-15 16:26:18 +0100 |
commit | ed838d41693dc49ec6ea7875fb07139f3074c788 (patch) | |
tree | ee42ef4723eaf294e7a3380b85bc1fe0409a8c03 /dbus | |
parent | 655266f32e35c31c190ade3dbb3f93b3e9cafec3 (diff) | |
download | dbus-ed838d41693dc49ec6ea7875fb07139f3074c788.tar.gz |
dbus: handle unix transport in a new common function
Split out the Unix socket handling from open_platform_specific(),
enabling "unix:" connectable addresses on Windows in next patch.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Diffstat (limited to 'dbus')
-rw-r--r-- | dbus/dbus-transport-unix.c | 47 | ||||
-rw-r--r-- | dbus/dbus-transport-unix.h | 5 | ||||
-rw-r--r-- | dbus/dbus-transport.c | 3 |
3 files changed, 43 insertions, 12 deletions
diff --git a/dbus/dbus-transport-unix.c b/dbus/dbus-transport-unix.c index 574fd163..9931da51 100644 --- a/dbus/dbus-transport-unix.c +++ b/dbus/dbus-transport-unix.c @@ -210,20 +210,20 @@ _dbus_transport_new_for_exec (const char *path, } /** - * Opens platform specific transport types. - * - * @param entry the address entry to try opening + * Opens a UNIX socket transport. + * + * @param entry the address entry to try opening as a unix transport. * @param transport_p return location for the opened transport * @param error error to be set * @returns result of the attempt */ DBusTransportOpenResult -_dbus_transport_open_platform_specific (DBusAddressEntry *entry, - DBusTransport **transport_p, - DBusError *error) +_dbus_transport_open_unix_socket (DBusAddressEntry *entry, + DBusTransport **transport_p, + DBusError *error) { const char *method; - + method = dbus_address_entry_get_method (entry); _dbus_assert (method != NULL); @@ -232,14 +232,14 @@ _dbus_transport_open_platform_specific (DBusAddressEntry *entry, const char *path = dbus_address_entry_get_value (entry, "path"); const char *tmpdir = dbus_address_entry_get_value (entry, "tmpdir"); const char *abstract = dbus_address_entry_get_value (entry, "abstract"); - + if (tmpdir != NULL) { _dbus_set_bad_address (error, NULL, NULL, "cannot use the \"tmpdir\" option for an address to connect to, only in an address to listen on"); return DBUS_TRANSPORT_OPEN_BAD_ADDRESS; } - + if (path == NULL && abstract == NULL) { _dbus_set_bad_address (error, "unix", @@ -346,8 +346,33 @@ _dbus_transport_open_platform_specific (DBusAddressEntry *entry, return DBUS_TRANSPORT_OPEN_OK; } } + else + { + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + return DBUS_TRANSPORT_OPEN_NOT_HANDLED; + } +} + +/** + * Opens platform specific transport types. + * + * @param entry the address entry to try opening + * @param transport_p return location for the opened transport + * @param error error to be set + * @returns result of the attempt + */ +DBusTransportOpenResult +_dbus_transport_open_platform_specific (DBusAddressEntry *entry, + DBusTransport **transport_p, + DBusError *error) +{ #ifdef DBUS_ENABLE_LAUNCHD - else if (strcmp (method, "launchd") == 0) + const char *method; + + method = dbus_address_entry_get_method (entry); + _dbus_assert (method != NULL); + + if (strcmp (method, "launchd") == 0) { DBusError tmp_error = DBUS_ERROR_INIT; const char *launchd_env_var = dbus_address_entry_get_value (entry, "env"); @@ -398,8 +423,8 @@ _dbus_transport_open_platform_specific (DBusAddressEntry *entry, return DBUS_TRANSPORT_OPEN_OK; } } -#endif else +#endif /* DBUS_ENABLE_LAUNCHD */ { _DBUS_ASSERT_ERROR_IS_CLEAR (error); return DBUS_TRANSPORT_OPEN_NOT_HANDLED; diff --git a/dbus/dbus-transport-unix.h b/dbus/dbus-transport-unix.h index 5124e0b6..952fa0a4 100644 --- a/dbus/dbus-transport-unix.h +++ b/dbus/dbus-transport-unix.h @@ -23,7 +23,7 @@ #ifndef DBUS_TRANSPORT_UNIX_H #define DBUS_TRANSPORT_UNIX_H -#include <dbus/dbus-transport.h> +#include <dbus/dbus-transport-protected.h> DBUS_BEGIN_DECLS @@ -31,6 +31,9 @@ DBusTransport* _dbus_transport_new_for_domain_socket (const char *path, dbus_bool_t abstract, DBusError *error); +DBusTransportOpenResult _dbus_transport_open_unix_socket (DBusAddressEntry *entry, + DBusTransport **transport_p, + DBusError *error); DBUS_END_DECLS diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index 592abf9f..9e189f84 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -348,6 +348,9 @@ static const struct { DBusError *error); } open_funcs[] = { { _dbus_transport_open_socket }, +#ifndef _WIN32 /* FIXME: removed in next patch */ + { _dbus_transport_open_unix_socket }, +#endif { _dbus_transport_open_platform_specific }, { _dbus_transport_open_autolaunch } #ifdef DBUS_ENABLE_EMBEDDED_TESTS |