From: noer AT cygnus DOT com (Geoffrey Noer) Subject: getgrnam fix? 11 Feb 1998 16:33:16 -0800 Message-ID: <199802120012.QAA00464.cygnus.cygwin32.developers@rtl.cygnus.com> Reply-To: cygwin32-developers AT cygnus DOT com Content-Type: text To: cygwin32-developers AT cygnus DOT com Cc: noer AT cygnus DOT com (Geoffrey Noer) Hello, Some people have complained about the fact that getgrnam does not return NULL when there is an /etc/group that doesn't contain the right group ID. The patch that follows adds the default group line into the group file in memory when /etc/group isn't found. getgrnam will then return NULL if the group file in memory doesn't contain the requested group. Will this cause problems I'm not thinking of? I don't think so but... Geoff ------------------------------ snip ------------------------------- Index: ChangeLog =================================================================== RCS file: /cvs/cvsfiles/devo/winsup/ChangeLog,v retrieving revision 1.380.2.3.4.86 diff -c -p -r1.380.2.3.4.86 ChangeLog *** ChangeLog 1998/02/11 23:59:48 1.380.2.3.4.86 --- ChangeLog 1998/02/12 00:07:07 *************** *** 1,5 **** --- 1,12 ---- Wed Feb 11 15:59:10 1998 Geoffrey Noer + * grp.cc (read_etc_group): add a default /etc/group in memory + if /etc/group isn't found + (getgrnam): return NULL if requested group isn't found instead + of returning a default group + + Wed Feb 11 15:59:10 1998 Geoffrey Noer + patch from sos AT prospect DOT com DOT ru (Sergey Okhapkin): * strace.cc (strace_open): do not close u->strace_file if it points to stderr. Index: grp.cc =================================================================== RCS file: /cvs/cvsfiles/devo/winsup/grp.cc,v retrieving revision 1.9.2.1.4.5 diff -c -p -r1.9.2.1.4.5 grp.cc *** grp.cc 1998/02/11 02:16:02 1.9.2.1.4.5 --- grp.cc 1998/02/12 00:07:07 *************** read_etc_group () *** 81,86 **** --- 81,92 ---- fclose (f); } + else /* /etc/group doesn't exist -- create default one in memory */ + { + const char *default_line = "everyone::500:\n"; + add_grp_line (default_line); + } + group_in_memory_p = 1; } *************** getgrnam (const char *name) *** 156,168 **** } } } ! ! grp.gr_gid = def_group_id; ! grp.gr_name = def_group; ! namearray[0] = grp.gr_name; ! namearray[1] = NULL; ! grp.gr_mem = namearray; ! return (&grp); } extern "C" --- 162,170 ---- } } } ! ! /* Didn't find requested group */ ! return NULL; } extern "C"