Bug 32334 – Always set polkit.retains_authorization_after_challenge
authorDavid Zeuthen <davidz@redhat.com>
Wed, 23 Feb 2011 14:56:17 +0000 (09:56 -0500)
committerDavid Zeuthen <davidz@redhat.com>
Wed, 23 Feb 2011 15:01:58 +0000 (10:01 -0500)
Otherwise it's impossible to implement lock buttons.

https://bugs.freedesktop.org/show_bug.cgi?id=32334

Signed-off-by: David Zeuthen <davidz@redhat.com>
docs/polkit/docbook-interface-org.freedesktop.PolicyKit1.Authority.xml
src/polkitbackend/polkitbackendinteractiveauthority.c

index 93f8cfa68350bc4be201ae0ae5c314dc810a8ccf..515ccf74a2544b8ba0e70ae904602ab16d65622c 100644 (file)
@@ -461,7 +461,7 @@ TRUE if the given <link linkend="eggdbus-struct-Subject">Subject</link> could be
     <term><literal>Dict&lt;String,String&gt; <structfield>details</structfield></literal></term>
     <listitem>
       <para>
-Details for the result or empty if not authorized. Known key/value-pairs include <literal>polkit.temporary_authorization_id</literal> (if the authorization is temporary, this is set to the opaque temporary authorization id), <literal>polkit.retains_authorization_after_challenge</literal> (Set to a non-empty string if the authorization will be retained after authentication (if is_challenge is TRUE)), <literal>polkit.dismissed</literal> (Set to a non-empty string if the authentication dialog was dismissed by the user).
+Details for the result. Known key/value-pairs include <literal>polkit.temporary_authorization_id</literal> (if the authorization is temporary, this is set to the opaque temporary authorization id), <literal>polkit.retains_authorization_after_challenge</literal> (Set to a non-empty string if the authorization will be retained after authentication (if is_challenge is TRUE)), <literal>polkit.dismissed</literal> (Set to a non-empty string if the authentication dialog was dismissed by the user).
       </para>
     </listitem>
   </varlistentry>
index 4107e2d3a48694ebfbaaf237884a22cdb8f79408..567cdb51b1abaf4662e4e595ef6be258c6f92ff1 100644 (file)
@@ -600,6 +600,7 @@ check_authorization_challenge_cb (AuthenticationAgent         *agent,
   gchar *authenticated_identity_str;
   gchar *subject_cmdline;
   gboolean is_temp;
+  PolkitDetails *details;
 
   priv = POLKIT_BACKEND_INTERACTIVE_AUTHORITY_GET_PRIVATE (authority);
 
@@ -626,13 +627,14 @@ check_authorization_challenge_cb (AuthenticationAgent         *agent,
            was_dismissed,
            authentication_success);
 
+  details = polkit_details_new ();
+  if (implicit_authorization == POLKIT_IMPLICIT_AUTHORIZATION_AUTHENTICATION_REQUIRED_RETAINED ||
+      implicit_authorization == POLKIT_IMPLICIT_AUTHORIZATION_ADMINISTRATOR_AUTHENTICATION_REQUIRED_RETAINED)
+    polkit_details_insert (details, "polkit.retains_authorization_after_challenge", "true");
+
   is_temp = FALSE;
   if (authentication_success)
     {
-      PolkitDetails *details;
-
-      details = polkit_details_new ();
-
       /* store temporary authorization depending on value of implicit_authorization */
       if (implicit_authorization == POLKIT_IMPLICIT_AUTHORIZATION_AUTHENTICATION_REQUIRED_RETAINED ||
           implicit_authorization == POLKIT_IMPLICIT_AUTHORIZATION_ADMINISTRATOR_AUTHENTICATION_REQUIRED_RETAINED)
@@ -651,21 +653,14 @@ check_authorization_challenge_cb (AuthenticationAgent         *agent,
           /* we've added a temporary authorization, let the user know */
           g_signal_emit_by_name (authority, "changed");
         }
-
       result = polkit_authorization_result_new (TRUE, FALSE, details);
-      g_object_unref (details);
     }
   else
     {
-      PolkitDetails *details;
-
       /* TODO: maybe return set is_challenge? */
-
-      details = polkit_details_new ();
       if (was_dismissed)
         polkit_details_insert (details, "polkit.dismissed", "true");
       result = polkit_authorization_result_new (FALSE, FALSE, details);
-      g_object_unref (details);
     }
 
   /* Log the event */
@@ -710,6 +705,7 @@ check_authorization_challenge_cb (AuthenticationAgent         *agent,
 
   /* log_result (authority, action_id, subject, caller, result); */
 
+  g_object_unref (details);
   g_simple_async_result_set_op_res_gpointer (simple,
                                              result,
                                              g_object_unref);