Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RemoteDesktop: Pass the creator's pid when creating a session #913

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions data/org.freedesktop.impl.portal.RemoteDesktop.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@
org.freedesktop.portal.ScreenCast), but may only be started and stopped
with this interface.

The following results get passed via the options argument:
<variablelist>
<varlistentry>
<term>pid t</term>
<listitem><para>
The process id of the process that is creating the session.
</para></listitem>
</varlistentry>
</variablelist>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this couldn't instead be something that could be put on the org.freedesktop.portal.Session API instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would make sense too, as long as it's xdp setting it. It doesn't need to be part of the client's API as they already know their pid

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Erm, yes, I meant org.freedesktop.impl.portal.Session.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, If you all agree that this is the way to go, I'll implement this instead


The following results get returned via the #org.freedesktop.portal.Request::Response signal:
<variablelist>
<varlistentry>
Expand Down
2 changes: 2 additions & 0 deletions src/remote-desktop.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ handle_create_session (XdpDbusRemoteDesktop *object,
}

g_variant_builder_init (&options_builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add (&options_builder, "{sv}",
"pid", g_variant_new ("t", xdp_app_info_get_pid (request->app_info)));
options = g_variant_builder_end (&options_builder);

g_object_set_qdata_full (G_OBJECT (request),
Expand Down
18 changes: 14 additions & 4 deletions src/xdp-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ xdp_mkstempat (int dir_fd,
struct _XdpAppInfo {
volatile gint ref_count;
char *id;
pid_t pid;
XdpAppInfoKind kind;

union
Expand All @@ -141,11 +142,12 @@ struct _XdpAppInfo {
};

static XdpAppInfo *
xdp_app_info_new (XdpAppInfoKind kind)
xdp_app_info_new (XdpAppInfoKind kind, pid_t pid)
{
XdpAppInfo *app_info = g_new0 (XdpAppInfo, 1);
app_info->ref_count = 1;
app_info->kind = kind;
app_info->pid = pid;
return app_info;
}

Expand Down Expand Up @@ -224,7 +226,7 @@ set_appid_from_pid (XdpAppInfo *app_info, pid_t pid)
static XdpAppInfo *
xdp_app_info_new_host (pid_t pid)
{
XdpAppInfo *app_info = xdp_app_info_new (XDP_APP_INFO_KIND_HOST);
XdpAppInfo *app_info = xdp_app_info_new (XDP_APP_INFO_KIND_HOST, pid);
set_appid_from_pid (app_info, pid);
return app_info;
}
Expand Down Expand Up @@ -278,6 +280,14 @@ xdp_app_info_get_id (XdpAppInfo *app_info)
return app_info->id;
}

pid_t
xdp_app_info_get_pid (XdpAppInfo *app_info)
{
g_return_val_if_fail (app_info != NULL, NULL);

return app_info->pid;
}

XdpAppInfoKind
xdp_app_info_get_kind (XdpAppInfo *app_info)
{
Expand Down Expand Up @@ -673,7 +683,7 @@ parse_app_info_from_flatpak_info (int pid, GError **error)

close (info_fd);

app_info = xdp_app_info_new (XDP_APP_INFO_KIND_FLATPAK);
app_info = xdp_app_info_new (XDP_APP_INFO_KIND_FLATPAK, pid);
app_info->id = g_steal_pointer (&id);
app_info->u.flatpak.keyfile = g_steal_pointer (&metadata);

Expand Down Expand Up @@ -801,7 +811,7 @@ parse_app_info_from_snap (pid_t pid, GError **error)
return NULL;
}

app_info = xdp_app_info_new (XDP_APP_INFO_KIND_SNAP);
app_info = xdp_app_info_new (XDP_APP_INFO_KIND_SNAP, pid);
app_info->id = g_strconcat ("snap.", snap_name, NULL);
app_info->u.snap.keyfile = g_steal_pointer (&metadata);

Expand Down
1 change: 1 addition & 0 deletions src/xdp-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ G_DEFINE_AUTO_CLEANUP_FREE_FUNC(XdpFd, close, -1)
XdpAppInfo *xdp_app_info_ref (XdpAppInfo *app_info);
void xdp_app_info_unref (XdpAppInfo *app_info);
const char *xdp_app_info_get_id (XdpAppInfo *app_info);
pid_t xdp_app_info_get_pid (XdpAppInfo *app_info);
char * xdp_app_info_get_instance (XdpAppInfo *app_info);
gboolean xdp_app_info_is_host (XdpAppInfo *app_info);
XdpAppInfoKind xdp_app_info_get_kind (XdpAppInfo *app_info);
Expand Down