Hi,

Here is a patch to add check for all user's groups instead of only the
real group.
--- lsx.c.bak   2006-10-12 17:12:51.000000000 +0200
+++ lsx.c       2006-10-12 17:39:12.000000000 +0200
@@ -8,6 +8,16 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <stdlib.h>
+#include <string.h>
+
+int
+ingroups(struct stat* s, int size, gid_t list[]) {
+       int i;
+       for(i = 0; i < size; i++)
+               if(s->st_gid == list[i])
+                       return 1;
+       return 0;
+}
 
 int
 main(int argc, char *argv[]) {
@@ -17,6 +27,10 @@
        struct stat s;
        uid_t uid = getuid();
        DIR *dir;
+       long ngroups_max;
+       ngroups_max = sysconf(_SC_NGROUPS_MAX);
+       gid_t gid_l[ngroups_max];
+       int ngroups = getgroups(ngroups_max, gid_l);
 
        if((argc > 1) && !strncmp(argv[1], "-v", 3)) {
                fputs("lsx-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", 
stdout);
@@ -30,7 +44,7 @@
                                        && (stat(dp->d_name, &s) != -1)
                                        && S_ISREG (s.st_mode)
                                        && ((s.st_uid == uid && s.st_mode & 
S_IXUSR) ||
-                                               (s.st_gid == gid && s.st_mode & 
S_IXGRP) ||
+                                               ((s.st_gid == gid || 
ingroups(&s, ngroups, gid_l)) &&s.st_mode & S_IXGRP) ||
                                                (s.st_mode & S_IXOTH)))
                                        puts(dp->d_name);
                        while(dp);

Attachment: pgp4C1SD2oYhJ.pgp
Description: PGP signature



Reply via email to