freebsd-nq/lib/libc
Bill Paul dbf973c0c7 Fixes for PR #508 and #509 ('botched 'Bad netgroup' error message' and
'cycle in netgroup check too greedy').

PR #508 is apparently due to an inconsistency in the way the 4.4BSD
netgroup code deals with bad netgroups. When 4.4BSD code encounters
a badly formed netgroup entry (e.g. (somehost,-somedomain), which,
because of the missing comma between the '-' and 'somedomain,' has
only 2 fields instead of 3), it generates an error message and
then bails out without doing any more processing on the netgroup
containing the bad entry. Conversely, every other *NIX in the world
that usees netgroups just tries to parse the entry as best it can
and then silently continues on its way.

The result is that two bad things happen: 1) we ignore other valid entries
within the netgroup containing the bogus entry, which prevents
us from interoperating with other systems that don't behave this way,
and 2) by printing an error to stderr from inside libc, we hose certain
programs, in this case rlogind. In the problem report, Bill Fenner
noted that the 'B' from 'Bad' was missing, and that rlogind exited
immediately after generating the error. The missing 'B' is apparently
not caused by any problem in getnetgrent.c; more likely it's getting
swallowed up by rlogind somehow, and the error message itself causes
rlogind to become confused. I was able to duplicate this problem and
discovered that running a simple test program on my FreeBSD system
resulted in a properly formatted (if confusing) error, whereas triggering
the error by trying to rlogin to the machine yielded the missing 'B'
problem.

Anyway, the fixes for this are as follows:

- The error message has been reformatted so that it prints out more useful
  information (e.g. Bad entry (somehost,-somedomain) in netgroup "foo").
  We check for NULL entries so that we don't print '(null)' anymore too. :)

- Rearranged things in parse_netgrp()  so that we make a best guess at
  what bad entries are supposed to look like and then continue processing
  instead of bailing out.

- Even though the error message has been cleaned up, it's wrapped inside
  a #ifdef DEBUG. This way we match the behavior of other systems. Since we
  now handle the error condition better anyway, this error message becomes
  less important.

PR #507 is another case of inconsistency. The code that handles
duplicate/circular netgroup entries isn't really 'too greedy; -- it's
just too noisy. If you have a netgroup containing duplicate entries,
the code actually does the right thing, but it also generates an error
message. As with the 'Bad netgroup' message, spewing this out from
inside libc can also hose certain programs (like rlogind). Again, no
other system generates an error message in this case.

The only change here is to hide the error message inside an #ifdef DEBUG.
Like the other message, it's largely superfluous since the code handles
the condition correctly.

Note that PR #510 (+@netgroup host matching in /etc/hosts.equiv) is still
being investigated. I haven't been able to duplicate it myself, and I
strongly suspect it to be a configuration problem of some kind. However,
I'm leaving all three PRs open until I get 510 resolved just for the
sake of paranoia.
1995-06-23 14:47:54 +00:00
..
amd64 First round of changes to clean up the RCSID mess in libc: 1995-01-23 01:30:24 +00:00
compat-43 Remove setre*id*. 1995-04-25 10:00:04 +00:00
db Remove trailing whitespace. 1995-05-30 05:51:47 +00:00
gen Fixes for PR #508 and #509 ('botched 'Bad netgroup' error message' and 1995-06-23 14:47:54 +00:00
gmon Remove trailing whitespace. 1995-05-30 05:51:47 +00:00
i386 Remove trailing whitespace. 1995-05-30 05:51:47 +00:00
locale Remove trailing whitespace. 1995-05-30 05:51:47 +00:00
net Remove trailing whitespace. 1995-05-30 05:51:47 +00:00
nls Add /usr/local/share/nls to default search path 1995-06-17 03:02:21 +00:00
quad Remove trailing whitespace. 1995-05-30 05:51:47 +00:00
regex Remove trailing whitespace. 1995-05-30 05:51:47 +00:00
rpc Remove trailing whitespace. 1995-05-30 05:51:47 +00:00
stdio Remove trailing whitespace. 1995-05-30 05:51:47 +00:00
stdlib Remove trailing whitespace. 1995-05-30 05:51:47 +00:00
stdtime Remove trailing whitespace. 1995-05-30 05:51:47 +00:00
string Remove trailing whitespace. 1995-05-30 05:51:47 +00:00
sys Add a missing link from the setpgid manpage to the setpgrp manpage. 1995-05-27 04:17:04 +00:00
xdr Remove trailing whitespace. 1995-05-30 05:51:47 +00:00
yp Remove trailing whitespace. 1995-05-30 05:51:47 +00:00
Makefile Add nls include to Makefile. 1995-03-30 12:46:36 +00:00