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

Index: gnome-packagekit-3.10.1/src/systemd-proxy.c
===================================================================
--- gnome-packagekit-3.10.1.orig/src/systemd-proxy.c
+++ gnome-packagekit-3.10.1/src/systemd-proxy.c
@@ -63,27 +63,6 @@ systemd_proxy_can_restart (SystemdProxy
                            gboolean      *can_restart,
                            GError       **error)
 {
-        PolkitAuthorizationResult *res;
-        GError *local_error = NULL;
-
-        *can_restart = FALSE;
-        res = polkit_authority_check_authorization_sync (proxy->authority,
-                                                         proxy->subject,
-                                                         SYSTEMD_REBOOT_ACTION,
-                                                         NULL,
-                                                         POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
-                                                         NULL,
-                                                         &local_error);
-        if (res == NULL) {
-                g_propagate_error (error, local_error);
-                return FALSE;
-        }
-
-        *can_restart = polkit_authorization_result_get_is_authorized (res) ||
-                       polkit_authorization_result_get_is_challenge (res);
-
-        g_object_unref (res);
-
         return TRUE;
 }
 
@@ -91,17 +70,32 @@ gboolean
 systemd_proxy_restart (SystemdProxy  *proxy,
                        GError       **error)
 {
-        GDBusConnection *bus;
-
-        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);
-
-        return TRUE;
+         PolkitAuthorizationResult *res;
+         GDBusConnection *bus;
+         GError *local_error = NULL;
+
+         res = polkit_authority_check_authorization_sync (proxy->authority,
+                                                          proxy->subject,
+                                                          SYSTEMD_REBOOT_ACTION,
+                                                          NULL,
+                                                          POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
+                                                          NULL,
+                                                          &local_error);
+         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);
+         }
+         
+         return TRUE;
 }
openSUSE Build Service is sponsored by