freebsd-src/lib
Bill Paul a393cc06f5 Fixed a rather serious bug that presents itself when FreeBSD is configured
as an NIS client. The pw_breakout_yp routines that are used to populate the
_pw_passwd structire only do anything if the bits in the pw_fields member
_pw_passwd are cleared. Unfortunately, we can get into a state where
pw_fields has garbage in it right before the YP lookup functions are
called, which causes the breakout functions to screw up in a big way.
Here's how to duplicate the problem:

- Configure FreeBSD as an NIS client
- Log in as a user who's password database records reside only in
  the NIS passwd maps.
- Type ps -aux

Result: your processes appear to be owned by 'root' or 'deamon.'
/bin/ls can exhibit the same problem.

The reason this happens:

- When ps(1) needs to match a username to a UID, it calls getpwuid().

- root is in the local password file, so getpwuid() calls  __hashpw()
  and __hashpw() populates the _pw_passwd struct, including the pw_fields
  member. This happens before NIS lookups take place because, by coincidence,
  ps(1) tends to display processes owned by root before it happens upon
  a proccess owned by you.

- When your UID comes up, __hashpw() fails to find your entry in the
  local password database, so it bails out, BUT THE BITS IN THE pw_fields
  STRUCTURE OF _pw_passwd ARE NEVER CLEARED AND STILL CONTAIN INFORMATION
  FROM THE PREVIOUS CALL TO __hash_pw()!!

- If we have NIS enabled, the NIS lookup functions are called.

- The pw_breakout_yp routines see that the pw_fields bits are set and
  decline to place the data retrieved from the NIS passwd maps into the
  _pw_passwd structure.

- getpwuid() returns the results of the last __hashpw() lookup instead
  of the valid NIS data.

- Hijinxs ensue when user_from_uid() caches this bogus information and
  starts handing out the wrong usernames.

AAAARRRRRRRRRGGGGGGHHHHHHHHHH!!!

*Please* don't tell me I'm the only person to have noticed this.

Fixed by having __hashpw() check the state of pw_fields just before
bailing out on a failed lookup and clearing away any leftover garbage.
What a fun way to spend an afternoon.
1995-02-03 01:09:35 +00:00
..
csu/i386 Call reduced (8-bit only) startup_setlocale() 1994-09-24 16:01:30 +00:00
libc Fixed a rather serious bug that presents itself when FreeBSD is configured 1995-02-03 01:09:35 +00:00
libcom_err Don't call _doprnt, which doesn't exist; use vfprintf. 1995-01-23 22:53:12 +00:00
libcompat Add sanity check for "no previous regular expression" state, 1994-09-14 22:25:15 +00:00
libcrypt Install shared libraries in ${DESTDIR}${SHLIBDIR} instead of in 1994-11-14 06:44:45 +00:00
libcurses tputs: (char) -> (int) 1994-12-10 23:02:33 +00:00
libedit Add LDADD+= -ltermcap 1994-10-12 02:06:02 +00:00
libf2c Remove z_abs. It is already in libm.a 1994-11-11 12:58:12 +00:00
libF77 Library for f2c (part 2 of 2) 1994-10-26 18:17:41 +00:00
libforms Implemented height field for text fields so they can now be more than 1995-02-01 04:06:37 +00:00
libI77 Library for f2c. (part 1 of 2) 1994-10-26 18:15:35 +00:00
libkvm A semicolon was lost. 1994-11-07 19:54:55 +00:00
libm Declare huge and tiny as volatile so that gcc doesn't evaluate huge*huge 1994-09-08 11:19:43 +00:00
libmd Eliminate a bogus tab. 1995-01-24 00:13:56 +00:00
libmytinfo Prototypes... 1994-12-10 22:56:53 +00:00
libncurses Back out bkgd changes, now acts per braindamaged sysv standard 1995-01-16 17:33:33 +00:00
libpam/modules In the non-PARANOID case, make sure to set `notickets' to 0 sothat login.c 1995-01-20 23:07:10 +00:00
libpcap Add the Packet Capture Library from Michael Reifenberger. 1995-01-20 04:13:07 +00:00
libresolv BSD 4.4 Lite Lib Sources 1994-05-27 05:00:24 +00:00
librpc Make up for the fact that rpc headers are now installed from include. 1994-08-05 01:59:40 +00:00
librpcsvc Use ${ECHO} instead of echo' so that make -s' is fairly quiet. 1994-08-28 17:48:43 +00:00
libscsi Clean up handling of unspecified names. Clarify man page. 1995-01-26 23:48:41 +00:00
libskey Remove extra newline. 1994-10-27 18:15:42 +00:00
libss Make Jordan happy: 1995-01-23 18:56:40 +00:00
libtelnet The big crypt removal - make libtelnet exportable. 1994-08-12 22:41:29 +00:00
libterm Correct the man page extent. 1994-08-08 19:26:23 +00:00
libtermcap tputs: (char) -> (int) 1994-12-10 22:01:25 +00:00
libutil Added $Id$ 1994-09-24 02:59:15 +00:00
liby BSD 4.4 Lite Lib Sources 1994-05-27 05:00:24 +00:00
msun Add missing z_abs. In BSD tradition this is in libm.a. 1994-11-11 12:56:27 +00:00
ncurses/ncurses termcap.h now belongs to system 1994-12-04 02:43:41 +00:00
rpcsvc Makefile to build librpcsvc. (All sources automatically generated.) 1994-08-07 23:21:08 +00:00
Makefile added libscsi 1995-01-24 12:10:42 +00:00
Makefile.inc From 1.1.5: define default shared library versions. For 2.0, use version 1994-08-04 22:44:00 +00:00