Subject: lib/3746: innetgr(3) fails to return 1 in certain cases
To: None <gnats-bugs@gnats.netbsd.org, rhialto@polder.ubc.kun.nl>
From: Olaf Seibert <rhialto@polder.ubc.kun.nl>
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
>Last-Modified:
>Originator: Olaf Seibert
>Organization:
___ Olaf 'Rhialto' Seibert D787B44DFC896063 4CBB95A5BD1DAA96
\X/ It's not easy having a good time rhialto@polder.ubc.kun.nl
>Release: 1.2
>Environment:
System: NetBSD polder.ubc.kun.nl 1.2.1 NetBSD 1.2.1 (POLDER) #5: Wed Jun 4 15:53:30 MET DST 1997 rhialto@polder.ubc.kun.nl:/home/src/sys/arch/i386/compile/POLDER i386
>Description:
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).
#ifdef REPLACE_INNETGR
/*
* 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)));
setnetgrent(group);
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))) {
endnetgrent();
return (1);
}
endnetgrent();
return (0);
}
#endif
My debugging logs show cases where this version returns 1,
where innetgr() returns 0:
InNetGr: group: polders, host: wiering.ubc.kun.nl, user: (null), dom: ubc.kun.nl
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 (polder.ubc.kun.nl,,) ixpolders polpcs
ixpolders (purmer.ubc.kun.nl,,) \
(schermer.ubc.kun.nl,,)
polpcs (wormer.ubc.kun.nl,,) \
(wiering.ubc.kun.nl,,) \
(haarlem.ubc.kun.nl,,)
nfspolders (wormer.ubc.kun.nl,,)
The only way to get NetBSD 1.2's innetgr() to return 1 for these parameters,
is to add (wiering.ubc.kun.nl,,ubc.kun.nl) directly to the ixpolders line.
Anything less won't do.
>How-To-Repeat:
see above
>Fix:
workaround: replace innetgr() with code cited above.
>Audit-Trail:
>Unformatted: