Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl2/xcvs/dist/src When checking for membership in ...



details:   https://anonhg.NetBSD.org/src/rev/058ad28acd43
branches:  trunk
changeset: 786767:058ad28acd43
user:      christos <christos%NetBSD.org@localhost>
date:      Thu May 09 15:25:44 2013 +0000

description:
When checking for membership in the system group file don't forget to check
the primary group of the user.

diffstat:

 external/gpl2/xcvs/dist/src/acl.c |  23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diffs (44 lines):

diff -r d26c011f0477 -r 058ad28acd43 external/gpl2/xcvs/dist/src/acl.c
--- a/external/gpl2/xcvs/dist/src/acl.c Thu May 09 15:03:40 2013 +0000
+++ b/external/gpl2/xcvs/dist/src/acl.c Thu May 09 15:25:44 2013 +0000
@@ -30,6 +30,7 @@
  */
 #include "cvs.h"
 #include "getline.h"
+#include <pwd.h>
 #include <grp.h>
 
 static int acl_fileproc (void *callerdat, struct file_info *finfo);
@@ -556,18 +557,24 @@
        if (debug) fprintf (stderr, "usesystemgroups=%d\n", use_system_groups);
        if (use_system_groups) {
            struct group *griter;
+           struct passwd *pwd;
+           gid_t gid = (pwd = getpwnam(username)) != NULL ? pwd->pw_gid : -1;
            setgrent ();
            while (griter = getgrent ())
            {
-               char **users=griter->gr_mem;
-               int index = 0;
-               char *userchk = users [index++];
-               while(userchk != NULL) {
-                   if(strcmp (userchk, username) == 0)
-                       break;
-                   userchk = users[index++];
+               char *userchk;
+               if (gid == griter->gr_gid) {
+                   userchk = username;
+               } else  {
+                   char **users = griter->gr_mem;
+                   int index = 0;
+                   userchk = users [index++];
+                   while(userchk != NULL) {
+                       if(strcmp (userchk, username) == 0)
+                           break;
+                       userchk = users[index++];
+                   }
                }
-               if (debug) fprintf (stderr, "usercheck=%s\n", userchk);
                if (userchk != NULL) {
                    char *grp;
                    if ((grp = findusername (part_perms, griter->gr_name)))



Home | Main Index | Thread Index | Old Index