This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Problem with gid



Hi,

Bernhard Rosenkraenzer <bero@microsoft.sucks.eu.org> brought a problem
up on bug-glibc with gids in glibc 2.0.7pre5 and (verified myself) in
glibc 2.1.  The problem is as follows:

<bits/types.h> has typedef __u_int __gid_t;

grp/fgetgrent_r.c reads the grpid from /etc/groups with:
       INT_FIELD_MAYBE_NULL (result->gr_gid, ISCOLON, 0, 10, , 0)
where INTFIELD_MAYBE_NULL is defined in nss/nss_files/files-parse.c
and uses:
  variable = convert (strtol (line, &endp, base));

Therefore gid is declared as unsigned int but (out of compatibility
reasons?) read as signed int.

A line like the following in /etc/groups:
nogroup:x:4294967294:root
leads to what seems to be an endless loop (endlessly reading
/etc/groups) with e.g.:
chown 14999.14999 some-file
where 14999 is an unknown group.

/etc/nsswitch.conf has:
group:     files

So, what's the correct solution:
- tell Bernhard to use:
nogroup:x:-2:root
- use strtoul instead of strtol - but this might lead to the same
  problems, just the other way round.
- fix the reading of gid

Andreas
-- 
 Andreas Jaeger   aj@arthur.rhein-neckar.de    jaeger@informatik.uni-kl.de
  for pgp-key finger ajaeger@alma.student.uni-kl.de


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]