Skip to content

Commit 859d775

Browse files
blucajrybar-rh
authored andcommitted
CheckAuthorization: return 'polkit.result' in the details dict
Let callers know how the user was authorized. This is useful for example to be able to distinguish between an auth_self and an auth_admin, as the latter means the subject is more privileged than the former.
1 parent 081b4c1 commit 859d775

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

data/org.freedesktop.PolicyKit1.Authority.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
</annotation>
161161

162162
<annotation name="org.gtk.EggDBus.Struct.Member" value="Dict<String,String>:details">
163-
<annotation name="org.gtk.EggDBus.DocString" value="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)) and <literal>polkit.lockdown</literal> (set to a non-empty string if the action is locked down)."/>
163+
<annotation name="org.gtk.EggDBus.DocString" value="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.lockdown</literal> (set to a non-empty string if the action is locked down), <literal>polkit.result</literal> (Set to the string value of the polkit.Result enum, e.g.: <literal>auth_admin</literal>)."/>
164164
</annotation>
165165
</annotation>
166166

docs/polkit/docbook-interface-org.freedesktop.PolicyKit1.Authority.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ TRUE if the given <link linkend="eggdbus-struct-Subject">Subject</link> could be
479479
<term><literal>Dict&lt;String,String&gt; <structfield>details</structfield></literal></term>
480480
<listitem>
481481
<para>
482-
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).
482+
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), <literal>polkit.result</literal> (Set to the string value of the polkit.Result enum, e.g.: <literal>auth_admin</literal>).
483483
</para>
484484
</listitem>
485485
</varlistentry>

src/polkitbackend/polkitbackendduktapeauthority.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,8 @@ polkit_backend_common_js_authority_check_authorization_sync (PolkitBackendIntera
10511051
goto out;
10521052
}
10531053

1054+
polkit_details_insert (details, "polkit.result", ret_str);
1055+
10541056
good = TRUE;
10551057

10561058
out:

src/polkitbackend/polkitbackendinteractiveauthority.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,8 @@ check_authorization_sync (PolkitBackendAuthority *authority,
12701270
polkit_details_insert (details, "polkit.retains_authorization_after_challenge", "1");
12711271
}
12721272

1273+
polkit_details_insert (details, "polkit.result", polkit_implicit_authorization_to_string (implicit_authorization));
1274+
12731275
result = polkit_authorization_result_new (FALSE, TRUE, details);
12741276

12751277
/* return implicit_authorization so the caller can use an authentication agent if applicable */

0 commit comments

Comments
 (0)