[gnome-session/benzea/systemd-new-session-config: 12/12] util, main: Reset all failed states on startup
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-session/benzea/systemd-new-session-config: 12/12] util, main: Reset all failed states on startup
- Date: Thu, 13 Feb 2020 14:56:11 +0000 (UTC)
commit c1f0ebf72272242bc0716b12cd4d7610611cf67b
Author: Benjamin Berg <bberg redhat com>
Date: Mon Feb 3 13:45:51 2020 +0100
util, main: Reset all failed states on startup
In the event that the user logs back in after a session failure, it is
likely that some failed units cannot start. Reset all failed states to
ensure that systemd at least tries to start all previously failed units
on every login.
gnome-session/gsm-util.c | 30 ++++++++++++++++++++++++++++++
gnome-session/gsm-util.h | 2 ++
gnome-session/main.c | 10 ++++++++++
3 files changed, 42 insertions(+)
---
diff --git a/gnome-session/gsm-util.c b/gnome-session/gsm-util.c
index 02bc4a57..29f04fd0 100644
--- a/gnome-session/gsm-util.c
+++ b/gnome-session/gsm-util.c
@@ -768,6 +768,36 @@ gsm_util_start_systemd_unit (const char *unit,
return TRUE;
}
+
+gboolean
+gsm_util_systemd_reset_failed (GError **error)
+{
+ g_autoptr(GDBusConnection) connection = NULL;
+ g_autoptr(GVariant) reply = NULL;
+ GError *bus_error = NULL;
+
+ connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, error);
+
+ if (connection == NULL)
+ return FALSE;
+
+ reply = g_dbus_connection_call_sync (connection,
+ "org.freedesktop.systemd1",
+ "/org/freedesktop/systemd1",
+ "org.freedesktop.systemd1.Manager",
+ "ResetFailed",
+ NULL,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL, &bus_error);
+
+ if (bus_error != NULL) {
+ g_propagate_error (error, bus_error);
+ return FALSE;
+ }
+
+ return TRUE;
+}
#endif
void
diff --git a/gnome-session/gsm-util.h b/gnome-session/gsm-util.h
index bd7b6986..bc26a21e 100644
--- a/gnome-session/gsm-util.h
+++ b/gnome-session/gsm-util.h
@@ -58,6 +58,8 @@ gboolean gsm_util_export_user_environment (GError **error);
gboolean gsm_util_start_systemd_unit (const char *unit,
const char *mode,
GError **error);
+gboolean gsm_util_systemd_reset_failed (GError **error);
+
#endif
void gsm_quit (void);
diff --git a/gnome-session/main.c b/gnome-session/main.c
index 01f56667..83c5b108 100644
--- a/gnome-session/main.c
+++ b/gnome-session/main.c
@@ -551,6 +551,16 @@ main (int argc, char **argv)
session_name = _gsm_manager_get_default_session (NULL);
}
+ /* Reset all failed units; we are going to start a lof ot things and
+ * really do not want to run into errors because units have failed
+ * in a previous session
+ */
+ gsm_util_systemd_reset_failed (&error);
+ if (error) {
+ g_warning ("Failed to reset failed state of units: %s", error->message);
+ g_clear_error (&error);
+ }
+
/* We don't escape the name (i.e. we leave any '-' intact). */
gnome_session_target = g_strdup_printf ("gnome-session-%s@%s.target", session_type,
session_name);
if (gsm_util_start_systemd_unit (gnome_session_target, "fail", &error)) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]