[gnome-remote-desktop] daemon: Exit, if all backends fail to initialize
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-remote-desktop] daemon: Exit, if all backends fail to initialize
- Date: Tue, 21 Sep 2021 09:26:46 +0000 (UTC)
commit 1ae050057ecb0b2e3ce6304fcdf0abfa40a2f76f
Author: Pascal Nowack <Pascal Nowack gmx de>
Date: Sun Sep 19 09:52:05 2021 +0200
daemon: Exit, if all backends fail to initialize
When gnome-remote-desktop is started, it attempts to initialize the RDP
and VNC backend, depending on with which backends gnome-remote-desktop
was built.
However, if all backends fail to initialize, gnome-remote-desktop will
still continue to run, despite not being usable.
This is especially problematic, as the systemd user service still runs
as if there would be no problem, making it hard to find the cause why a
connection to the server won't make it.
To get rid of this situation, also check the result of the backend
initialization.
If all backends fail, exit the daemon, as there is no reason to
continue running.
src/grd-daemon.c | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
---
diff --git a/src/grd-daemon.c b/src/grd-daemon.c
index 576cb4b..9bfc96c 100644
--- a/src/grd-daemon.c
+++ b/src/grd-daemon.c
@@ -68,18 +68,19 @@ is_daemon_ready (GrdDaemon *daemon)
}
#ifdef HAVE_RDP
-static void
+static gboolean
init_rdp_server (GrdDaemon *daemon)
{
GrdSettings *settings = grd_context_get_settings (daemon->context);
g_autoptr (GError) error = NULL;
+ gboolean result = FALSE;
daemon->rdp_server = NULL;
if (!g_access (grd_settings_get_rdp_server_cert (settings), F_OK) &&
!g_access (grd_settings_get_rdp_server_key (settings), F_OK))
{
daemon->rdp_server = grd_rdp_server_new (daemon->context);
- if (!grd_rdp_server_start (daemon->rdp_server, &error))
+ if (!(result = grd_rdp_server_start (daemon->rdp_server, &error)))
g_warning ("Failed to initialize RDP server: %s\n", error->message);
else
g_message ("Initialized RDP server");
@@ -88,36 +89,49 @@ init_rdp_server (GrdDaemon *daemon)
{
g_message ("Didn't initialize RDP server: not configured");
}
+
+ return result;
}
#endif /* HAVE_RDP */
#ifdef HAVE_VNC
-static void
+static gboolean
init_vnc_server (GrdDaemon *daemon)
{
g_autoptr (GError) error = NULL;
+ gboolean result;
daemon->vnc_server = grd_vnc_server_new (daemon->context);
- if (!grd_vnc_server_start (daemon->vnc_server, &error))
+ if (!(result = grd_vnc_server_start (daemon->vnc_server, &error)))
g_warning ("Failed to initialize VNC server: %s\n", error->message);
else
g_message ("Initialized VNC server");
+
+ return result;
}
#endif /* HAVE_VNC */
static void
maybe_enable_services (GrdDaemon *daemon)
{
+ gboolean has_one_backend = FALSE;
+
if (!is_daemon_ready (daemon))
return;
#ifdef HAVE_RDP
- init_rdp_server (daemon);
+ has_one_backend = init_rdp_server (daemon) || has_one_backend;
#endif
#ifdef HAVE_VNC
- init_vnc_server (daemon);
+ has_one_backend = init_vnc_server (daemon) || has_one_backend;
#endif
+
+ if (!has_one_backend)
+ {
+ g_warning ("No backend initialized successfully. Exiting");
+ g_application_release (G_APPLICATION (daemon));
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]