[glib] GDBusProxy: Treat org.freedesktop.systemd1.Masked error as non-fatal



commit 3e706ef88b3b433f777e552c85339b901314deaa
Author: David Zeuthen <zeuthen gmail com>
Date:   Fri Jun 8 13:30:48 2012 -0400

    GDBusProxy: Treat org.freedesktop.systemd1.Masked error as non-fatal
    
    This is useful otherwise we'll fail if a systemd service is
    masked. See bug 677718 for details.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=677718
    
    Signed-off-by: David Zeuthen <zeuthen gmail com>

 gio/gdbusproxy.c |   34 ++++++++++++++++++++++++++--------
 1 files changed, 26 insertions(+), 8 deletions(-)
---
diff --git a/gio/gdbusproxy.c b/gio/gdbusproxy.c
index 5bab9bf..799c793 100644
--- a/gio/gdbusproxy.c
+++ b/gio/gdbusproxy.c
@@ -1609,21 +1609,39 @@ async_init_start_service_by_name_cb (GDBusConnection *connection,
        *   org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.Epiphany2
        *   was not provided by any .service files
        *
+       * or (see #677718)
+       *
+       *   org.freedesktop.systemd1.Masked: Unit polkit.service is masked.
+       *
        * This doesn't mean that the name doesn't have an owner, just
-       * that it's not provided by a .service file. So just proceed to
-       * invoke GetNameOwner() if dealing with that error.
+       * that it's not provided by a .service file or can't currently
+       * be started.
+       *
+       * In particular, in both cases, it could be that a service
+       * owner will actually appear later. So instead of erroring out,
+       * we just proceed to invoke GetNameOwner() if dealing with the
+       * kind of errors above.
        */
-      if (error->domain == G_DBUS_ERROR &&
-          error->code == G_DBUS_ERROR_SERVICE_UNKNOWN)
+      if (error->domain == G_DBUS_ERROR && error->code == G_DBUS_ERROR_SERVICE_UNKNOWN)
         {
           g_error_free (error);
         }
       else
         {
-          g_prefix_error (&error,
-                          _("Error calling StartServiceByName for %s: "),
-                          data->proxy->priv->name);
-          goto failed;
+          gchar *remote_error = g_dbus_error_get_remote_error (error);
+          if (g_strcmp0 (remote_error, "org.freedesktop.systemd1.Masked") == 0)
+            {
+              g_error_free (error);
+              g_free (remote_error);
+            }
+          else
+            {
+              g_prefix_error (&error,
+                              _("Error calling StartServiceByName for %s: "),
+                              data->proxy->priv->name);
+              g_free (remote_error);
+              goto failed;
+            }
         }
     }
   else



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]