Subject: lib/3746: innetgr(3) fails to return 1 in certain cases
To: None <,>
From: Olaf Seibert <>
List: netbsd-bugs
Date: 06/13/1997 18:36:35
>Number:         3746
>Category:       lib
>Synopsis:       innetgr(3) fails to return 1 in certain cases
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people (Library Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 13 09:50:01 1997
>Originator:     Olaf Seibert
___ Olaf 'Rhialto' Seibert      D787B44DFC896063 4CBB95A5BD1DAA96 
\X/ It's not easy having a good time
>Release:        1.2
System: NetBSD 1.2.1 NetBSD 1.2.1 (POLDER) #5: Wed Jun 4 15:53:30 MET DST 1997 i386

It seems that innetgr() behaves different than I expect. I wonder
if I misunderstand things, or if this is actually a bug.

The following re-implementation of innetgr is part of Samba.
Note that it looks suspiciously like the implementation that NetBSD
used in 1.0 (except that it doesn't crash with NULL pointers).

 * Search for a match in a netgroup. This replaces it on broken systems.
int InNetGr(char *group,char *host,char *user,char *dom)
  char *hst, *usr, *dm;
  DEBUG(3, ("InNetGr: group: %s, host: %s, user: %s, dom: %s\n",
	              group    , host    , user    , dom));
#undef innetgr
  DEBUG(3, ("InNetGr: innetgr would return %d\n",
	  innetgr(group, host, user, dom)));

  while (getnetgrent(&hst, &usr, &dm))
    if (((host == 0) || (hst == 0) || !strcmp(host, hst)) &&
	((user == 0) || (usr == 0) || !strcmp(user, usr)) &&
	((dom == 0) || (dm == 0) || !strcmp(dom, dm))) {
      return (1);
  return (0);

My debugging logs show cases where this version returns 1,
where innetgr() returns 0:

InNetGr: group: polders, host:, user: (null), dom:
InNetGr: innetgr would return 0

This is (part of) the netgroup file:

# Polderland netgroups file
# Don't forget to run netgroup_mkdb after editing this...
polders	(,,) ixpolders polpcs 
ixpolders (,,) \
polpcs	(,,) \
	(,,) \
nfspolders	(,,)

The only way to get NetBSD 1.2's innetgr() to return 1 for these parameters,
is to add (,, directly to the ixpolders line.
Anything less won't do.

	see above
	workaround: replace innetgr() with code cited above.