mirror of
https://github.com/brl/mutter.git
synced 2024-11-28 02:50:41 -05:00
f894f5cc13
Allowing code from inside mutter to create a child process and delegate on it some of its tasks is something very useful. This can be done easily with the g_subprocess and g_subprocess_launcher classes already available in GLib and GObject. Unfortunately, although the child process can be a graphical program, currently it is not possible for the inner code to identify the windows created by the child in a secure manner (this is: being able to ensure that a malicious program won't be able to trick the inner code into thinking it is a child process launched by it). Under X11 this is not a problem because any program has full control over their windows, but under Wayland it is a different story: a program can't neither force their window to be kept at the top (like a docker program does) or at the bottom (like a program for desktop icons does), nor hide it from the list of windows. This means that it is not possible for a "classic", non-priviledged program, to fulfill these tasks, and it can be done only from code inside mutter (like a gnome-shell extension). This is a non desirable situation, because an extension runs in the same main loop than the whole desktop itself, which means that a complex extension can need to do too much work inside the main loop, and freeze the whole desktop for too much time. Also, it is important to note that javascript doesn't have access to fork(), or threads, which means that, at most, all the parallel computing that can do is those available in the _async calls in GLib/GObject. Also, having to create an extension for any priviledged graphical element is an stopper for a lot of programmers who already know GTK+ but doesn't know Clutter. This patch wants to offer a solution to this problem, by offering a new class that allows to launch a trusted child process from inside mutter, and make it to use an specific UNIX socket to communicate with the compositor. It also allows to check whether an specific MetaWindow was created by one of this trusted child processes or not. This allows to create extensions that launch a child process, and when that process creates a window, the extension can confirm in a secure way that the window really belongs to that process launched by it, so it can give to that window "superpowers" like being kept at the bottom of the desktop, not being listed in the list of windows or shown in the Activities panel... Also, in future versions, it could easily implement protocol extensions that only could be used by these trusted child processes. Several examples of the usefulness of this are that, with it, it is possible to write programs that implements: - desktop icons - a dock - a top or bottom bar ... all in a secure manner, avoiding insecure programs to do the same. In fact, even if the same code is launched manually, it won't have those privileges, only the specific process launched from inside mutter. Since this is only needed under Wayland, it won't work under X11. Fixes https://gitlab.gnome.org/GNOME/mutter/issues/741
68 lines
2.4 KiB
C
68 lines
2.4 KiB
C
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
/*
|
|
* Copyright 2019 Sergio Costas (rastersoft@gmail.com)
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
* License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
* 02111-1307, USA.
|
|
*/
|
|
|
|
#ifndef META_WAYLAND_CLIENT_H
|
|
#define META_WAYLAND_CLIENT_H
|
|
|
|
#include <glib-object.h>
|
|
#include <gio/gio.h>
|
|
|
|
#include "meta/display.h"
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
#define META_TYPE_WAYLAND_CLIENT (meta_wayland_client_get_type ())
|
|
META_EXPORT
|
|
G_DECLARE_FINAL_TYPE (MetaWaylandClient, meta_wayland_client, META, WAYLAND_CLIENT, GObject)
|
|
|
|
META_EXPORT
|
|
MetaWaylandClient *meta_wayland_client_new (GSubprocessLauncher *launcher,
|
|
GError **error);
|
|
|
|
META_EXPORT
|
|
GSubprocess *meta_wayland_client_spawn (MetaWaylandClient *client,
|
|
MetaDisplay *display,
|
|
GError **error,
|
|
const char *argv0,
|
|
...) G_GNUC_NULL_TERMINATED;
|
|
|
|
META_EXPORT
|
|
GSubprocess *meta_wayland_client_spawnv (MetaWaylandClient *client,
|
|
MetaDisplay *display,
|
|
const char * const *argv,
|
|
GError **error);
|
|
|
|
META_EXPORT
|
|
gboolean meta_wayland_client_owns_window (MetaWaylandClient *client,
|
|
MetaWindow *window);
|
|
|
|
META_EXPORT
|
|
void meta_wayland_client_hide_from_window_list (MetaWaylandClient *client,
|
|
MetaWindow *window);
|
|
|
|
META_EXPORT
|
|
void meta_wayland_client_show_in_window_list (MetaWaylandClient *client,
|
|
MetaWindow *window);
|
|
|
|
G_END_DECLS
|
|
|
|
#endif /* META_WAYLAND_CLIENT_H */
|