From 2622dd47d2889e45c5f497c3ef114c364c039ab8 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Mon, 21 Nov 2022 15:16:48 +0100 Subject: [PATCH] remote-desktop: Accept ConnectToEIS only with started sessions The ConnectToEIS() method allows the client to communicate directly with EIS via a socket. But we need to allow for this only with a fully started session, otherwise ConnecToEIS() would allow to bypass the permission and the user dialog entirely. --- data/org.freedesktop.portal.RemoteDesktop.xml | 2 +- src/remote-desktop.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/data/org.freedesktop.portal.RemoteDesktop.xml b/data/org.freedesktop.portal.RemoteDesktop.xml index 46dab3a16..ab7679056 100644 --- a/data/org.freedesktop.portal.RemoteDesktop.xml +++ b/data/org.freedesktop.portal.RemoteDesktop.xml @@ -400,7 +400,7 @@ This method may only be called once per session, where the EIS implementation disconnects the session should be closed. - This method must be called before #org.freedesktop.portal.RemoteDesktop.Start() + This method must be called after #org.freedesktop.portal.RemoteDesktop.Start() Once an EIS connection is established, input events must be sent exclusively via the EIS connection. Any events submitted via NotifyPointerMotion, diff --git a/src/remote-desktop.c b/src/remote-desktop.c index 1ed0457c3..c06205f1c 100644 --- a/src/remote-desktop.c +++ b/src/remote-desktop.c @@ -1407,13 +1407,18 @@ handle_connect_to_eis (XdpDbusRemoteDesktop *object, switch (remote_desktop_session->state) { + case REMOTE_DESKTOP_SESSION_STATE_STARTED: + break; case REMOTE_DESKTOP_SESSION_STATE_INIT: case REMOTE_DESKTOP_SESSION_STATE_DEVICES_SELECTED: case REMOTE_DESKTOP_SESSION_STATE_SELECTING_DEVICES: case REMOTE_DESKTOP_SESSION_STATE_SOURCES_SELECTED: case REMOTE_DESKTOP_SESSION_STATE_SELECTING_SOURCES: - break; - case REMOTE_DESKTOP_SESSION_STATE_STARTED: + g_dbus_method_invocation_return_error (invocation, + G_DBUS_ERROR, + G_DBUS_ERROR_FAILED, + "Session is not ready"); + return G_DBUS_METHOD_INVOCATION_HANDLED; case REMOTE_DESKTOP_SESSION_STATE_STARTING: g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,