Skip to content

Commit

Permalink
remote-desktop: Accept ConnectToEIS only with started sessions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ofourdan authored and whot committed Dec 12, 2022
1 parent 28d4e11 commit 2622dd4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion data/org.freedesktop.portal.RemoteDesktop.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 7 additions & 2 deletions src/remote-desktop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2622dd4

Please sign in to comment.