]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
dbus-sysdeps-unix: Handle empty supplementary group list
authorcptpcrd <cptpcrd.git@gmail.com>
Sun, 30 Jul 2023 22:38:22 +0000 (18:38 -0400)
committerSimon McVittie <smcv@collabora.com>
Tue, 1 Aug 2023 18:09:26 +0000 (18:09 +0000)
It is valid for getsockopt(SO_PEERGROUPS) to return len=0; that
indicates the process has no supplementary groups. Rather than failing,
simply use the returned empty list (and add the primary GID to it).

Without this change, calling GetConnectionCredentials on a bus name
owned by a process with no supplementary groups does not return the
UnixGroupIDs field, even though it is easy to determine that the process
only has one GID (the primary GID).

dbus/dbus-sysdeps-unix.c

index c1c9f182ed6262b5b7d9cef40558e87e414cca2b..486c4e21941af3b7bb621e628ee6447f7aa7bebd 100644 (file)
@@ -2001,13 +2001,6 @@ add_groups_to_credentials (int              client_fd,
       _dbus_verbose ("will try again with %lu\n", (unsigned long) len);
     }
 
-  if (len <= 0)
-    {
-      _dbus_verbose ("getsockopt(SO_PEERGROUPS) yielded <= 0 bytes: %ld\n",
-                     (long) len);
-      goto out;
-    }
-
   if (len > n_gids * sizeof (gid_t))
     {
       _dbus_verbose ("%lu > %zu", (unsigned long) len, n_gids * sizeof (gid_t));