PolicyKit: Branch 'master'

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Oct 3 16:30:10 UTC 2023


 src/polkitbackend/polkitbackendduktapeauthority.c |   21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

New commits:
commit 89b7a37b91210ac054645c617d150a0d4906a84e
Author: Jan Rybar <jrybar at redhat.com>
Date:   Tue Oct 3 16:30:07 2023 +0000

    user_of_subject is NULL if DBus provides groups

diff --git a/src/polkitbackend/polkitbackendduktapeauthority.c b/src/polkitbackend/polkitbackendduktapeauthority.c
index b5eea39..c40b907 100644
--- a/src/polkitbackend/polkitbackendduktapeauthority.c
+++ b/src/polkitbackend/polkitbackendduktapeauthority.c
@@ -420,6 +420,17 @@ push_subject (duk_context               *cx,
   groups = g_ptr_array_new_with_free_func (g_free);
   gids_from_dbus = polkit_unix_process_get_gids (POLKIT_UNIX_PROCESS (process));
 
+passwd = getpwuid (uid);
+if (passwd == NULL)
+  {
+    user_name = g_strdup_printf ("%d", (gint) uid);
+    g_warning ("Error looking up info for uid %d: %m", (gint) uid);
+  }
+else
+  {
+    user_name = g_strdup (passwd->pw_name);
+  }
+
   /* D-Bus will give us supplementary groups too, so prefer that to looking up
    * the group from the uid. */
   if (gids_from_dbus && gids_from_dbus->len > 0)
@@ -441,19 +452,11 @@ push_subject (duk_context               *cx,
     }
   else
     {
-      passwd = getpwuid (uid);
-      if (passwd == NULL)
-        {
-          user_name = g_strdup_printf ("%d", (gint) uid);
-          g_warning ("Error looking up info for uid %d: %m", (gint) uid);
-        }
-      else
+      if (passwd != NULL)
         {
           gid_t gids[512];
           int num_gids = 512;
 
-          user_name = g_strdup (passwd->pw_name);
-
           if (getgrouplist (passwd->pw_name,
                             passwd->pw_gid,
                             gids,


More information about the hal-commit mailing list