Commit 3b37bd27 authored by Benjamin Berg's avatar Benjamin Berg

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.
parent 08e19e0e
...@@ -769,6 +769,36 @@ gsm_util_start_systemd_unit (const char *unit, ...@@ -769,6 +769,36 @@ gsm_util_start_systemd_unit (const char *unit,
return TRUE; return TRUE;
} }
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,
-1, NULL, &bus_error);
if (bus_error != NULL) {
g_propagate_error (error, bus_error);
return FALSE;
return TRUE;
#endif #endif
void void
...@@ -58,6 +58,8 @@ gboolean gsm_util_export_user_environment (GError **error); ...@@ -58,6 +58,8 @@ gboolean gsm_util_export_user_environment (GError **error);
gboolean gsm_util_start_systemd_unit (const char *unit, gboolean gsm_util_start_systemd_unit (const char *unit,
const char *mode, const char *mode,
GError **error); GError **error);
gboolean gsm_util_systemd_reset_failed (GError **error);
#endif #endif
void gsm_quit (void); void gsm_quit (void);
...@@ -551,6 +551,16 @@ main (int argc, char **argv) ...@@ -551,6 +551,16 @@ main (int argc, char **argv)
session_name = _gsm_manager_get_default_session (NULL); 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). */ /* We don't escape the name (i.e. we leave any '-' intact). */
gnome_session_target = g_strdup_printf ("", session_type, session_name); gnome_session_target = g_strdup_printf ("", session_type, session_name);
if (gsm_util_start_systemd_unit (gnome_session_target, "fail", &error)) { if (gsm_util_start_systemd_unit (gnome_session_target, "fail", &error)) {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment