Commit fd6b3a5d authored by Miloslav Trmač's avatar Miloslav Trmač Committed by Ray Strode

Simplify GVariant reference counting

For (non-public-API) *_to_gvariant, explicitly document that they return
a floating value, and rely on it in callers to avoid a
variable/sink/unref combo.

This should not change behavior.

https://bugs.freedesktop.org/show_bug.cgi?id=99741Signed-off-by: default avatarMiloslav Trmač <mitr@redhat.com>
parent 59d2fde3
...@@ -352,10 +352,10 @@ polkit_action_description_new_for_gvariant (GVariant *value) ...@@ -352,10 +352,10 @@ polkit_action_description_new_for_gvariant (GVariant *value)
return action_description; return action_description;
} }
/* Note that this returns a floating value. */
GVariant * GVariant *
polkit_action_description_to_gvariant (PolkitActionDescription *action_description) polkit_action_description_to_gvariant (PolkitActionDescription *action_description)
{ {
GVariant *value;
GVariantBuilder builder; GVariantBuilder builder;
GHashTableIter iter; GHashTableIter iter;
const gchar *a_key; const gchar *a_key;
...@@ -368,17 +368,15 @@ polkit_action_description_to_gvariant (PolkitActionDescription *action_descripti ...@@ -368,17 +368,15 @@ polkit_action_description_to_gvariant (PolkitActionDescription *action_descripti
g_variant_builder_add (&builder, "{ss}", a_key, a_value); g_variant_builder_add (&builder, "{ss}", a_key, a_value);
/* TODO: note 'foo ? : ""' is a gcc specific extension (it's a short-hand for 'foo ? foo : ""') */ /* TODO: note 'foo ? : ""' is a gcc specific extension (it's a short-hand for 'foo ? foo : ""') */
value = g_variant_new ("(ssssssuuua{ss})", return g_variant_new ("(ssssssuuua{ss})",
action_description->action_id ? : "", action_description->action_id ? : "",
action_description->description ? : "", action_description->description ? : "",
action_description->message ? : "", action_description->message ? : "",
action_description->vendor_name ? : "", action_description->vendor_name ? : "",
action_description->vendor_url ? : "", action_description->vendor_url ? : "",
action_description->icon_name ? : "", action_description->icon_name ? : "",
action_description->implicit_any, action_description->implicit_any,
action_description->implicit_inactive, action_description->implicit_inactive,
action_description->implicit_active, action_description->implicit_active,
&builder); &builder);
return value;
} }
...@@ -886,8 +886,6 @@ polkit_authority_check_authorization (PolkitAuthority *authority, ...@@ -886,8 +886,6 @@ polkit_authority_check_authorization (PolkitAuthority *authority,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GVariant *subject_value;
GVariant *details_value;
CheckAuthData *data; CheckAuthData *data;
g_return_if_fail (POLKIT_IS_AUTHORITY (authority)); g_return_if_fail (POLKIT_IS_AUTHORITY (authority));
...@@ -896,11 +894,6 @@ polkit_authority_check_authorization (PolkitAuthority *authority, ...@@ -896,11 +894,6 @@ polkit_authority_check_authorization (PolkitAuthority *authority,
g_return_if_fail (details == NULL || POLKIT_IS_DETAILS (details)); g_return_if_fail (details == NULL || POLKIT_IS_DETAILS (details));
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
subject_value = polkit_subject_to_gvariant (subject);
details_value = polkit_details_to_gvariant (details);
g_variant_ref_sink (subject_value);
g_variant_ref_sink (details_value);
data = g_new0 (CheckAuthData, 1); data = g_new0 (CheckAuthData, 1);
data->authority = g_object_ref (authority); data->authority = g_object_ref (authority);
data->simple = g_simple_async_result_new (G_OBJECT (authority), data->simple = g_simple_async_result_new (G_OBJECT (authority),
...@@ -915,9 +908,9 @@ polkit_authority_check_authorization (PolkitAuthority *authority, ...@@ -915,9 +908,9 @@ polkit_authority_check_authorization (PolkitAuthority *authority,
g_dbus_proxy_call (authority->proxy, g_dbus_proxy_call (authority->proxy,
"CheckAuthorization", "CheckAuthorization",
g_variant_new ("(@(sa{sv})s@a{ss}us)", g_variant_new ("(@(sa{sv})s@a{ss}us)",
subject_value, polkit_subject_to_gvariant (subject), /* A floating value */
action_id, action_id,
details_value, polkit_details_to_gvariant (details), /* A floating value */
flags, flags,
data->cancellation_id != NULL ? data->cancellation_id : ""), data->cancellation_id != NULL ? data->cancellation_id : ""),
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
...@@ -925,8 +918,6 @@ polkit_authority_check_authorization (PolkitAuthority *authority, ...@@ -925,8 +918,6 @@ polkit_authority_check_authorization (PolkitAuthority *authority,
cancellable, cancellable,
(GAsyncReadyCallback) check_authorization_cb, (GAsyncReadyCallback) check_authorization_cb,
data); data);
g_variant_unref (subject_value);
g_variant_unref (details_value);
} }
/** /**
...@@ -1058,20 +1049,16 @@ polkit_authority_register_authentication_agent (PolkitAuthority *authority, ...@@ -1058,20 +1049,16 @@ polkit_authority_register_authentication_agent (PolkitAuthority *authority,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GVariant *subject_value;
g_return_if_fail (POLKIT_IS_AUTHORITY (authority)); g_return_if_fail (POLKIT_IS_AUTHORITY (authority));
g_return_if_fail (POLKIT_IS_SUBJECT (subject)); g_return_if_fail (POLKIT_IS_SUBJECT (subject));
g_return_if_fail (locale != NULL); g_return_if_fail (locale != NULL);
g_return_if_fail (g_variant_is_object_path (object_path)); g_return_if_fail (g_variant_is_object_path (object_path));
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
subject_value = polkit_subject_to_gvariant (subject);
g_variant_ref_sink (subject_value);
g_dbus_proxy_call (authority->proxy, g_dbus_proxy_call (authority->proxy,
"RegisterAuthenticationAgent", "RegisterAuthenticationAgent",
g_variant_new ("(@(sa{sv})ss)", g_variant_new ("(@(sa{sv})ss)",
subject_value, polkit_subject_to_gvariant (subject), /* A floating value */
locale, locale,
object_path), object_path),
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
...@@ -1082,7 +1069,6 @@ polkit_authority_register_authentication_agent (PolkitAuthority *authority, ...@@ -1082,7 +1069,6 @@ polkit_authority_register_authentication_agent (PolkitAuthority *authority,
callback, callback,
user_data, user_data,
polkit_authority_register_authentication_agent)); polkit_authority_register_authentication_agent));
g_variant_unref (subject_value);
} }
/** /**
...@@ -1375,19 +1361,15 @@ polkit_authority_unregister_authentication_agent (PolkitAuthority *authorit ...@@ -1375,19 +1361,15 @@ polkit_authority_unregister_authentication_agent (PolkitAuthority *authorit
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GVariant *subject_value;
g_return_if_fail (POLKIT_IS_AUTHORITY (authority)); g_return_if_fail (POLKIT_IS_AUTHORITY (authority));
g_return_if_fail (POLKIT_IS_SUBJECT (subject)); g_return_if_fail (POLKIT_IS_SUBJECT (subject));
g_return_if_fail (g_variant_is_object_path (object_path)); g_return_if_fail (g_variant_is_object_path (object_path));
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
subject_value = polkit_subject_to_gvariant (subject);
g_variant_ref_sink (subject_value);
g_dbus_proxy_call (authority->proxy, g_dbus_proxy_call (authority->proxy,
"UnregisterAuthenticationAgent", "UnregisterAuthenticationAgent",
g_variant_new ("(@(sa{sv})s)", g_variant_new ("(@(sa{sv})s)",
subject_value, polkit_subject_to_gvariant (subject), /* A floating value */
object_path), object_path),
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
-1, -1,
...@@ -1397,7 +1379,6 @@ polkit_authority_unregister_authentication_agent (PolkitAuthority *authorit ...@@ -1397,7 +1379,6 @@ polkit_authority_unregister_authentication_agent (PolkitAuthority *authorit
callback, callback,
user_data, user_data,
polkit_authority_unregister_authentication_agent)); polkit_authority_unregister_authentication_agent));
g_variant_unref (subject_value);
} }
/** /**
...@@ -1511,7 +1492,6 @@ polkit_authority_authentication_agent_response (PolkitAuthority *authority, ...@@ -1511,7 +1492,6 @@ polkit_authority_authentication_agent_response (PolkitAuthority *authority,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GVariant *identity_value;
/* Note that in reality, this API is only accessible to root, and /* Note that in reality, this API is only accessible to root, and
* only called from the setuid helper `polkit-agent-helper-1`. * only called from the setuid helper `polkit-agent-helper-1`.
* *
...@@ -1526,14 +1506,12 @@ polkit_authority_authentication_agent_response (PolkitAuthority *authority, ...@@ -1526,14 +1506,12 @@ polkit_authority_authentication_agent_response (PolkitAuthority *authority,
g_return_if_fail (POLKIT_IS_IDENTITY (identity)); g_return_if_fail (POLKIT_IS_IDENTITY (identity));
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
identity_value = polkit_identity_to_gvariant (identity);
g_variant_ref_sink (identity_value);
g_dbus_proxy_call (authority->proxy, g_dbus_proxy_call (authority->proxy,
"AuthenticationAgentResponse2", "AuthenticationAgentResponse2",
g_variant_new ("(us@(sa{sv}))", g_variant_new ("(us@(sa{sv}))",
(guint32)uid, (guint32)uid,
cookie, cookie,
identity_value), polkit_identity_to_gvariant (identity)), /* A floating value */
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
-1, -1,
cancellable, cancellable,
...@@ -1542,7 +1520,6 @@ polkit_authority_authentication_agent_response (PolkitAuthority *authority, ...@@ -1542,7 +1520,6 @@ polkit_authority_authentication_agent_response (PolkitAuthority *authority,
callback, callback,
user_data, user_data,
polkit_authority_authentication_agent_response)); polkit_authority_authentication_agent_response));
g_variant_unref (identity_value);
} }
/** /**
...@@ -1653,18 +1630,14 @@ polkit_authority_enumerate_temporary_authorizations (PolkitAuthority *author ...@@ -1653,18 +1630,14 @@ polkit_authority_enumerate_temporary_authorizations (PolkitAuthority *author
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GVariant *subject_value;
g_return_if_fail (POLKIT_IS_AUTHORITY (authority)); g_return_if_fail (POLKIT_IS_AUTHORITY (authority));
g_return_if_fail (POLKIT_IS_SUBJECT (subject)); g_return_if_fail (POLKIT_IS_SUBJECT (subject));
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
subject_value = polkit_subject_to_gvariant (subject);
g_variant_ref_sink (subject_value);
g_dbus_proxy_call (authority->proxy, g_dbus_proxy_call (authority->proxy,
"EnumerateTemporaryAuthorizations", "EnumerateTemporaryAuthorizations",
g_variant_new ("(@(sa{sv}))", g_variant_new ("(@(sa{sv}))",
subject_value), polkit_subject_to_gvariant (subject)), /* A floating value */
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
-1, -1,
cancellable, cancellable,
...@@ -1673,7 +1646,6 @@ polkit_authority_enumerate_temporary_authorizations (PolkitAuthority *author ...@@ -1673,7 +1646,6 @@ polkit_authority_enumerate_temporary_authorizations (PolkitAuthority *author
callback, callback,
user_data, user_data,
polkit_authority_enumerate_temporary_authorizations)); polkit_authority_enumerate_temporary_authorizations));
g_variant_unref (subject_value);
} }
/** /**
...@@ -1805,18 +1777,14 @@ polkit_authority_revoke_temporary_authorizations (PolkitAuthority *authority ...@@ -1805,18 +1777,14 @@ polkit_authority_revoke_temporary_authorizations (PolkitAuthority *authority
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GVariant *subject_value;
g_return_if_fail (POLKIT_IS_AUTHORITY (authority)); g_return_if_fail (POLKIT_IS_AUTHORITY (authority));
g_return_if_fail (POLKIT_IS_SUBJECT (subject)); g_return_if_fail (POLKIT_IS_SUBJECT (subject));
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
subject_value = polkit_subject_to_gvariant (subject);
g_variant_ref_sink (subject_value);
g_dbus_proxy_call (authority->proxy, g_dbus_proxy_call (authority->proxy,
"RevokeTemporaryAuthorizations", "RevokeTemporaryAuthorizations",
g_variant_new ("(@(sa{sv}))", g_variant_new ("(@(sa{sv}))",
subject_value), polkit_subject_to_gvariant (subject)), /* A floating value */
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
-1, -1,
cancellable, cancellable,
...@@ -1825,7 +1793,6 @@ polkit_authority_revoke_temporary_authorizations (PolkitAuthority *authority ...@@ -1825,7 +1793,6 @@ polkit_authority_revoke_temporary_authorizations (PolkitAuthority *authority
callback, callback,
user_data, user_data,
polkit_authority_revoke_temporary_authorizations)); polkit_authority_revoke_temporary_authorizations));
g_variant_unref (subject_value);
} }
/** /**
......
...@@ -290,19 +290,15 @@ polkit_authorization_result_new_for_gvariant (GVariant *value) ...@@ -290,19 +290,15 @@ polkit_authorization_result_new_for_gvariant (GVariant *value)
return ret; return ret;
} }
/* Note that this returns a floating value. */
GVariant * GVariant *
polkit_authorization_result_to_gvariant (PolkitAuthorizationResult *authorization_result) polkit_authorization_result_to_gvariant (PolkitAuthorizationResult *authorization_result)
{ {
GVariant *ret; PolkitDetails *details;
GVariant *details_gvariant;
details_gvariant = polkit_details_to_gvariant (polkit_authorization_result_get_details (authorization_result));
g_variant_ref_sink (details_gvariant);
ret = g_variant_new ("(bb@a{ss})",
polkit_authorization_result_get_is_authorized (authorization_result),
polkit_authorization_result_get_is_challenge (authorization_result),
details_gvariant);
g_variant_unref (details_gvariant);
return ret; details = polkit_authorization_result_get_details (authorization_result);
return g_variant_new ("(bb@a{ss})",
polkit_authorization_result_get_is_authorized (authorization_result),
polkit_authorization_result_get_is_challenge (authorization_result),
polkit_details_to_gvariant (details)); /* A floating value */
} }
...@@ -195,10 +195,10 @@ polkit_details_get_keys (PolkitDetails *details) ...@@ -195,10 +195,10 @@ polkit_details_get_keys (PolkitDetails *details)
return ret; return ret;
} }
/* Note that this returns a floating value. */
GVariant * GVariant *
polkit_details_to_gvariant (PolkitDetails *details) polkit_details_to_gvariant (PolkitDetails *details)
{ {
GVariant *ret;
GVariantBuilder builder; GVariantBuilder builder;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{ss}")); g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{ss}"));
...@@ -212,8 +212,7 @@ polkit_details_to_gvariant (PolkitDetails *details) ...@@ -212,8 +212,7 @@ polkit_details_to_gvariant (PolkitDetails *details)
while (g_hash_table_iter_next (&hash_iter, (gpointer) &key, (gpointer) &value)) while (g_hash_table_iter_next (&hash_iter, (gpointer) &key, (gpointer) &value))
g_variant_builder_add (&builder, "{ss}", key, value); g_variant_builder_add (&builder, "{ss}", key, value);
} }
ret = g_variant_builder_end (&builder); return g_variant_builder_end (&builder);
return ret;
} }
PolkitDetails * PolkitDetails *
......
...@@ -198,12 +198,12 @@ polkit_identity_from_string (const gchar *str, ...@@ -198,12 +198,12 @@ polkit_identity_from_string (const gchar *str,
return identity; return identity;
} }
/* Note that this returns a floating value. */
GVariant * GVariant *
polkit_identity_to_gvariant (PolkitIdentity *identity) polkit_identity_to_gvariant (PolkitIdentity *identity)
{ {
GVariantBuilder builder; GVariantBuilder builder;
GVariant *dict; GVariant *dict;
GVariant *ret;
const gchar *kind; const gchar *kind;
kind = ""; kind = "";
...@@ -233,8 +233,7 @@ polkit_identity_to_gvariant (PolkitIdentity *identity) ...@@ -233,8 +233,7 @@ polkit_identity_to_gvariant (PolkitIdentity *identity)
} }
dict = g_variant_builder_end (&builder); dict = g_variant_builder_end (&builder);
ret = g_variant_new ("(s@a{sv})", kind, dict); return g_variant_new ("(s@a{sv})", kind, dict);
return ret;
} }
static GVariant * static GVariant *
......
...@@ -290,12 +290,12 @@ polkit_subject_from_string (const gchar *str, ...@@ -290,12 +290,12 @@ polkit_subject_from_string (const gchar *str,
return subject; return subject;
} }
/* Note that this returns a floating value. */
GVariant * GVariant *
polkit_subject_to_gvariant (PolkitSubject *subject) polkit_subject_to_gvariant (PolkitSubject *subject)
{ {
GVariantBuilder builder; GVariantBuilder builder;
GVariant *dict; GVariant *dict;
GVariant *ret;
const gchar *kind; const gchar *kind;
kind = ""; kind = "";
...@@ -329,8 +329,7 @@ polkit_subject_to_gvariant (PolkitSubject *subject) ...@@ -329,8 +329,7 @@ polkit_subject_to_gvariant (PolkitSubject *subject)
} }
dict = g_variant_builder_end (&builder); dict = g_variant_builder_end (&builder);
ret = g_variant_new ("(s@a{sv})", kind, dict); return g_variant_new ("(s@a{sv})", kind, dict);
return ret;
} }
static GVariant * static GVariant *
......
...@@ -212,22 +212,15 @@ polkit_temporary_authorization_new_for_gvariant (GVariant *value, ...@@ -212,22 +212,15 @@ polkit_temporary_authorization_new_for_gvariant (GVariant *value,
return authorization; return authorization;
} }
/* Note that this returns a floating value. */
GVariant * GVariant *
polkit_temporary_authorization_to_gvariant (PolkitTemporaryAuthorization *authorization) polkit_temporary_authorization_to_gvariant (PolkitTemporaryAuthorization *authorization)
{ {
GVariant *ret; return g_variant_new ("(ss@(sa{sv})tt)",
GVariant *subject_gvariant; authorization->id,
authorization->action_id,
subject_gvariant = polkit_subject_to_gvariant (authorization->subject); polkit_subject_to_gvariant (authorization->subject), /* A floating value */
g_variant_ref_sink (subject_gvariant); authorization->time_obtained,
ret = g_variant_new ("(ss@(sa{sv})tt)", authorization->time_expires);
authorization->id,
authorization->action_id,
subject_gvariant,
authorization->time_obtained,
authorization->time_expires);
g_variant_unref (subject_gvariant);
return ret;
} }
...@@ -645,11 +645,8 @@ server_handle_enumerate_actions (Server *server, ...@@ -645,11 +645,8 @@ server_handle_enumerate_actions (Server *server,
for (l = actions; l != NULL; l = l->next) for (l = actions; l != NULL; l = l->next)
{ {
PolkitActionDescription *ad = POLKIT_ACTION_DESCRIPTION (l->data); PolkitActionDescription *ad = POLKIT_ACTION_DESCRIPTION (l->data);
GVariant *value; g_variant_builder_add_value (&builder,
value = polkit_action_description_to_gvariant (ad); polkit_action_description_to_gvariant (ad)); /* A floating value */
g_variant_ref_sink (value);
g_variant_builder_add_value (&builder, value);
g_variant_unref (value);
} }
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(a(ssssssuuua{ss}))", &builder)); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(a(ssssssuuua{ss}))", &builder));
...@@ -709,11 +706,9 @@ check_auth_cb (GObject *source_object, ...@@ -709,11 +706,9 @@ check_auth_cb (GObject *source_object,
} }
else else
{ {
GVariant *value; g_dbus_method_invocation_return_value (data->invocation,
value = polkit_authorization_result_to_gvariant (result); g_variant_new ("(@(bba{ss}))",
g_variant_ref_sink (value); polkit_authorization_result_to_gvariant (result))); /* A floating value */
g_dbus_method_invocation_return_value (data->invocation, g_variant_new ("(@(bba{ss}))", value));
g_variant_unref (value);
g_object_unref (result); g_object_unref (result);
} }
...@@ -1158,11 +1153,8 @@ server_handle_enumerate_temporary_authorizations (Server *server ...@@ -1158,11 +1153,8 @@ server_handle_enumerate_temporary_authorizations (Server *server
for (l = authorizations; l != NULL; l = l->next) for (l = authorizations; l != NULL; l = l->next)
{ {
PolkitTemporaryAuthorization *a = POLKIT_TEMPORARY_AUTHORIZATION (l->data); PolkitTemporaryAuthorization *a = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
GVariant *value; g_variant_builder_add_value (&builder,
value = polkit_temporary_authorization_to_gvariant (a); polkit_temporary_authorization_to_gvariant (a)); /* A floating value */
g_variant_ref_sink (value);
g_variant_builder_add_value (&builder, value);
g_variant_unref (value);
} }
g_list_foreach (authorizations, (GFunc) g_object_unref, NULL); g_list_foreach (authorizations, (GFunc) g_object_unref, NULL);
g_list_free (authorizations); g_list_free (authorizations);
......
...@@ -2299,7 +2299,6 @@ authentication_agent_initiate_challenge (AuthenticationAgent *agent, ...@@ -2299,7 +2299,6 @@ authentication_agent_initiate_challenge (AuthenticationAgent *agent,
gchar *localized_message; gchar *localized_message;
gchar *localized_icon_name; gchar *localized_icon_name;
PolkitDetails *localized_details; PolkitDetails *localized_details;
GVariant *details_gvariant;
GList *user_identities = NULL; GList *user_identities = NULL;
GVariantBuilder identities_builder; GVariantBuilder identities_builder;
GVariant *parameters; GVariant *parameters;
...@@ -2397,28 +2396,21 @@ authentication_agent_initiate_challenge (AuthenticationAgent *agent, ...@@ -2397,28 +2396,21 @@ authentication_agent_initiate_challenge (AuthenticationAgent *agent,
add_pid (localized_details, caller, "polkit.caller-pid"); add_pid (localized_details, caller, "polkit.caller-pid");
add_pid (localized_details, subject, "polkit.subject-pid"); add_pid (localized_details, subject, "polkit.subject-pid");
details_gvariant = polkit_details_to_gvariant (localized_details);
g_variant_ref_sink (details_gvariant);
g_variant_builder_init (&identities_builder, G_VARIANT_TYPE ("a(sa{sv})")); g_variant_builder_init (&identities_builder, G_VARIANT_TYPE ("a(sa{sv})"));
for (l = user_identities; l != NULL; l = l->next) for (l = user_identities; l != NULL; l = l->next)
{ {
PolkitIdentity *identity = POLKIT_IDENTITY (l->data); PolkitIdentity *identity = POLKIT_IDENTITY (l->data);
GVariant *value; g_variant_builder_add_value (&identities_builder,
value = polkit_identity_to_gvariant (identity); polkit_identity_to_gvariant (identity)); /* A floating value */
g_variant_ref_sink (value);
g_variant_builder_add_value (&identities_builder, value);
g_variant_unref (value);
} }
parameters = g_variant_new ("(sss@a{ss}sa(sa{sv}))", parameters = g_variant_new ("(sss@a{ss}sa(sa{sv}))",
action_id, action_id,
localized_message, localized_message,
localized_icon_name, localized_icon_name,
details_gvariant, polkit_details_to_gvariant (localized_details), /* A floating value */
session->cookie, session->cookie,
&identities_builder); &identities_builder);
g_variant_unref (details_gvariant);
g_dbus_proxy_call (agent->proxy, g_dbus_proxy_call (agent->proxy,
"BeginAuthentication", "BeginAuthentication",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment