Subject: Strange behaviour of innetgr(3)
To: None <current-users@NetBSD.ORG,>
From: Olaf Seibert <>
List: current-users
Date: 06/06/1997 17:15:47
(This is with 1.2 but I expect that -current behaves the same)

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.


___ Olaf 'Rhialto' Seibert      D787B44DFC896063 4CBB95A5BD1DAA96 
\X/ It's not easy having a good time