File bnc#939278-gnome-packagekit-asks-for-reboot-password-too-early.patch of Package gnome-packagekit

Index: gnome-packagekit-3.21.4/src/systemd-proxy.c
===================================================================
--- gnome-packagekit-3.21.4.orig/src/systemd-proxy.c
+++ gnome-packagekit-3.21.4/src/systemd-proxy.c
@@ -63,10 +63,17 @@ systemd_proxy_can_restart (SystemdProxy
                            gboolean      *can_restart,
                            GError       **error)
 {
+        return TRUE;
+}
+
+gboolean
+systemd_proxy_restart (SystemdProxy  *proxy,
+                       GError       **error)
+{
         PolkitAuthorizationResult *res;
+        GDBusConnection *bus;
         GError *local_error = NULL;
 
-        *can_restart = FALSE;
         res = polkit_authority_check_authorization_sync (proxy->authority,
                                                          proxy->subject,
                                                          SYSTEMD_REBOOT_ACTION,
@@ -77,29 +84,18 @@ systemd_proxy_can_restart (SystemdProxy
         if (res == NULL) {
                 g_propagate_error (error, local_error);
                 return FALSE;
+        } else if (polkit_authorization_result_get_is_authorized (res) |
+                   polkit_authorization_result_get_is_challenge (res)) {
+                bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL);
+                g_dbus_connection_call_sync (bus,
+                                             SYSTEMD_DBUS_NAME,
+                                             SYSTEMD_DBUS_PATH,
+                                             SYSTEMD_DBUS_INTERFACE,
+                                             "Reboot",
+                                             g_variant_new ("(b)", TRUE),
+                                             NULL, 0, G_MAXINT, NULL, NULL);
+                g_object_unref (bus);
         }
 
-        *can_restart = polkit_authorization_result_get_is_authorized (res) ||
-                       polkit_authorization_result_get_is_challenge (res);
-
-        g_object_unref (res);
-
-        return TRUE;
-}
-
-gboolean
-systemd_proxy_restart (SystemdProxy  *proxy,
-                       GError       **error)
-{
-        g_autoptr(GDBusConnection) bus = NULL;
-
-        bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL);
-        g_dbus_connection_call_sync (bus,
-                                    SYSTEMD_DBUS_NAME,
-                                    SYSTEMD_DBUS_PATH,
-                                    SYSTEMD_DBUS_INTERFACE,
-                                    "Reboot",
-                                    g_variant_new ("(b)", TRUE),
-                                    NULL, 0, G_MAXINT, NULL, NULL);
         return TRUE;
 }
openSUSE Build Service is sponsored by