diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2019-09-21 14:01:30 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2019-09-21 14:20:42 +0200 |
commit | 1b24dd3dda3409ec4b186398316e9a4f47f78330 (patch) | |
tree | 84299b42034a1304218e659630e798ae185dc879 | |
parent | 54903a86e84df3b9f3d0bec2d3e95d3ef380cb5e (diff) |
libmbim-glib,proxy: always use realpath in the MbimDevice
We don't want to create different MbimDevices for the same cdc-wdm
port when it's accessed through different symlinks.
Fixes https://gitlab.freedesktop.org/mobile-broadband/libmbim/issues/6
(cherry picked from commit 40640217fb40921c787cf309d6b988f04f1af84c)
-rw-r--r-- | src/libmbim-glib/mbim-proxy.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/libmbim-glib/mbim-proxy.c b/src/libmbim-glib/mbim-proxy.c index 508e935..bc63d84 100644 --- a/src/libmbim-glib/mbim-proxy.c +++ b/src/libmbim-glib/mbim-proxy.c @@ -744,10 +744,12 @@ process_internal_proxy_config (MbimProxy *self, Client *client, MbimMessage *message) { - Request *request; + Request *request; MbimDevice *device; - gchar *path; - GFile *file; + gchar *incoming_path; + gchar *path; + GFile *file; + GError *error = NULL; /* create request holder */ request = request_new (self, client, message); @@ -767,8 +769,20 @@ process_internal_proxy_config (MbimProxy *self, } /* Retrieve path from request */ - path = _mbim_message_read_string (message, 0, 0); + incoming_path = _mbim_message_read_string (message, 0, 0); + if (!incoming_path) { + request->response = build_proxy_control_command_done (message, MBIM_STATUS_ERROR_INVALID_PARAMETERS); + request_complete_and_free (request); + return TRUE; + } + + /* The incoming path may be a symlink. In the proxy, we always use the real path of the + * device, so that clients using different symlinks for the same file don't collide with + * each other. */ + path = __mbim_utils_get_devpath (incoming_path, &error); if (!path) { + g_warning ("Error looking up real device path: %s", error->message); + g_error_free (error); request->response = build_proxy_control_command_done (message, MBIM_STATUS_ERROR_INVALID_PARAMETERS); request_complete_and_free (request); return TRUE; |