PolicyKit: Branch 'master' - 2 commits
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Jun 6 08:56:48 UTC 2022
src/polkitbackend/polkitbackendinteractiveauthority.c | 76 ++++++++----------
1 file changed, 34 insertions(+), 42 deletions(-)
New commits:
commit 5be583d026ea87d120ec1c3056d334bbf079990d
Author: Vincent Mihalkovic <vmihalko at redhat.com>
Date: Fri May 13 18:04:52 2022 +0200
fixup! backend: Dedup some code for temporary auth subjects
See https://bugs.freedesktop.org/show_bug.cgi?id=23867
which turned up from `git annotate` here.
I was reading this code and noticed it was duplicated.
diff --git a/src/polkitbackend/polkitbackendinteractiveauthority.c b/src/polkitbackend/polkitbackendinteractiveauthority.c
index 976d3d5..d935a7a 100644
--- a/src/polkitbackend/polkitbackendinteractiveauthority.c
+++ b/src/polkitbackend/polkitbackendinteractiveauthority.c
@@ -3068,7 +3068,9 @@ convert_temporary_authorization_subject (PolkitSubject *subject)
return g_object_ref (subject);
}
else
- return ret;
+ {
+ return ret;
+ }
}
else
{
commit 0eda3c370d4a2c7c080a8ea4a6560c0a8a06e9f3
Author: Colin Walters <walters at verbum.org>
Date: Fri Jan 4 20:10:05 2019 +0000
backend: Dedup some code for temporary auth subjects
See https://bugs.freedesktop.org/show_bug.cgi?id=23867
which turned up from `git annotate` here.
I was reading this code and noticed it was duplicated.
diff --git a/src/polkitbackend/polkitbackendinteractiveauthority.c b/src/polkitbackend/polkitbackendinteractiveauthority.c
index 21500f9..976d3d5 100644
--- a/src/polkitbackend/polkitbackendinteractiveauthority.c
+++ b/src/polkitbackend/polkitbackendinteractiveauthority.c
@@ -3046,6 +3046,36 @@ temporary_authorization_store_free (TemporaryAuthorizationStore *store)
g_free (store);
}
+/* XXX: for now, prefer to store the process; see
+ * https://bugs.freedesktop.org/show_bug.cgi?id=23867
+ */
+static PolkitSubject *
+convert_temporary_authorization_subject (PolkitSubject *subject)
+{
+ PolkitSubject *ret;
+ if (POLKIT_IS_SYSTEM_BUS_NAME (subject))
+ {
+ GError *error = NULL;
+ ret = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (subject),
+ NULL,
+ &error);
+ if (ret == NULL)
+ {
+ g_printerr ("Error getting process for system bus name `%s': %s\n",
+ polkit_system_bus_name_get_name (POLKIT_SYSTEM_BUS_NAME (subject)),
+ error->message);
+ g_error_free (error);
+ return g_object_ref (subject);
+ }
+ else
+ return ret;
+ }
+ else
+ {
+ return g_object_ref (subject);
+ }
+}
+
/* See the comment at the top of polkitunixprocess.c */
static gboolean
subject_equal_for_authz (PolkitSubject *a,
@@ -3095,27 +3125,7 @@ temporary_authorization_store_has_authorization (TemporaryAuthorizationStore *st
g_return_val_if_fail (POLKIT_IS_SUBJECT (subject), FALSE);
g_return_val_if_fail (action_id != NULL, FALSE);
- /* XXX: for now, prefer to store the process */
- if (POLKIT_IS_SYSTEM_BUS_NAME (subject))
- {
- GError *error;
- error = NULL;
- subject_to_use = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (subject),
- NULL,
- &error);
- if (subject_to_use == NULL)
- {
- g_printerr ("Error getting process for system bus name `%s': %s\n",
- polkit_system_bus_name_get_name (POLKIT_SYSTEM_BUS_NAME (subject)),
- error->message);
- g_error_free (error);
- subject_to_use = g_object_ref (subject);
- }
- }
- else
- {
- subject_to_use = g_object_ref (subject);
- }
+ subject_to_use = convert_temporary_authorization_subject (subject);
ret = FALSE;
@@ -3256,27 +3266,7 @@ temporary_authorization_store_add_authorization (TemporaryAuthorizationStore *st
g_return_val_if_fail (action_id != NULL, NULL);
g_return_val_if_fail (!temporary_authorization_store_has_authorization (store, subject, action_id, NULL), NULL);
- /* XXX: for now, prefer to store the process */
- if (POLKIT_IS_SYSTEM_BUS_NAME (subject))
- {
- GError *error;
- error = NULL;
- subject_to_use = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (subject),
- NULL,
- &error);
- if (subject_to_use == NULL)
- {
- g_printerr ("Error getting process for system bus name `%s': %s\n",
- polkit_system_bus_name_get_name (POLKIT_SYSTEM_BUS_NAME (subject)),
- error->message);
- g_error_free (error);
- subject_to_use = g_object_ref (subject);
- }
- }
- else
- {
- subject_to_use = g_object_ref (subject);
- }
+ subject_to_use = convert_temporary_authorization_subject (subject);
/* TODO: right now the time the temporary authorization is kept is hard-coded - we
* could make it a propery on the PolkitBackendInteractiveAuthority class (so
More information about the hal-commit
mailing list