commit b29f4884e9a7637e09f93f8d53973c83a69670d9
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Sun Feb 11 21:32:24 2024 +0100

    Fix testing belonging to the audio group
    
    cuserid() is limited to L_cuserid characters, which is 9.  This means that
    users with a longer login were never seen as belonging to the group.
    
    Let us just replace with using getgroups, which allows
    - to actually check the current allowed groups,
    - to compare gids, which don't pose length limitations.
    
    Fixes #4

diff --git a/src/common.c b/src/common.c
index a580153..6658c40 100644
--- a/src/common.c
+++ b/src/common.c
@@ -911,17 +911,18 @@ void get_list_of_sound_devices (misc_t *misc, audio_info_t *sound_devices)
    char *str, *orig_language;
    struct group *grp;
    FILE *p;
+   int ngroups;
+
+   ngroups = getgroups (0, NULL);
+   gid_t groups[ngroups];
+   getgroups (ngroups, groups);
 
    grp = getgrnam ("audio");
-   found = 0;
-   for (g = 0; grp->gr_mem[g]; g++)
-   {
-      if (strcmp (grp->gr_mem[g], cuserid (NULL)) == 0)
-      {
-         found = 1;
-         break;
-      } // if
-   } // for
+   found = getegid () == grp->gr_gid;
+
+   for (g = 0; !found && g < ngroups; g++)
+      found = groups[g] == grp->gr_gid;
+
    if (found == 0)
    {
       beep ();
