/[base]/head/lib/libc/gen/getpwent.c
ViewVC logotype

Log of /head/lib/libc/gen/getpwent.c

Parent Directory Parent Directory | Revision Log Revision Log


Links to HEAD: (view) (download) (annotate)
Sticky Revision:


Revision 365910 - (view) (download) (annotate) - [select for diffs]
Modified Sat Sep 19 19:08:27 2020 UTC (3 years, 9 months ago) by asomers
File length: 45714 byte(s)
Diff to previous 359978
fix integer underflow in getgrnam_r and getpwnam_r

Sometimes nscd(8) will return a 1-byte buffer for a nonexistent entry. This
triggered an integer underflow in grp_unmarshal_func, causing getgrnam_r to
return ERANGE instead of 0.

Fix the user's buffer size check, and add a correct check for a too-small
nscd buffer.

PR:		248932
Event:		September 2020 Bugathon
Reviewed by:	markj
MFC after:	2 weeks
Sponsored by:	Axcient
Differential Revision: https://reviews.freebsd.org/D26204


Revision 359978 - (view) (download) (annotate) - [select for diffs]
Modified Wed Apr 15 18:15:58 2020 UTC (4 years, 2 months ago) by brooks
File length: 45518 byte(s)
Diff to previous 336746
Fix -Wvoid-pointer-to-enum-cast warnings.

This pattern is used in callbacks with void * data arguments and seems
both relatively uncommon and relatively harmless.  Silence the warning
by casting through uintptr_t.

This warning is on by default in Clang 11.

Reviewed by:	arichardson
Obtained from:	CheriBSD (partial)
MFC after:	1 week
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24425


Revision 336746 - (view) (download) (annotate) - [select for diffs]
Modified Thu Jul 26 18:34:38 2018 UTC (5 years, 11 months ago) by ian
File length: 45430 byte(s)
Diff to previous 326193
Make pw_scan(3) more compatible with getpwent(3) et. al. when processing
data from /etc/passwd rather than /etc/master.passwd.

The libc getpwent(3) and related functions automatically read master.passwd
when run by root, or passwd when run by a non-root user.  When run by non-
root, getpwent() copes with the missing data by setting the corresponding
fields in the passwd struct to known values (zeroes for numbers, or a
pointer to an empty string for literals).  When libutil's pw_scan(3) was
used to parse a line without the root-accessible data, it was leaving
garbage in the corresponding fields.

These changes rename the static pw_init() function used by getpwent() and
friends to __pw_initpwd(), and move it into pw_scan.c so that common init
code can be shared between libc and libutil.  pw_scan(3) now calls
__pw_initpwd() before __pw_scan(), just like the getpwent() family does, so
that reading an arbitrary passwd file in either format and parsing it with
pw_scan(3) returns the same results as getpwent(3) would.

This also adds a new pw_initpwd(3) function to libutil, so that code which
creates passwd structs from scratch in some manner that doesn't involve
pw_scan() can initialize the struct to the values expected by lots of
existing code, which doesn't expect to encounter NULL pointers or garbage
values in some fields.


Revision 326193 - (view) (download) (annotate) - [select for diffs]
Modified Sat Nov 25 17:12:48 2017 UTC (6 years, 7 months ago) by pfg
File length: 45825 byte(s)
Diff to previous 298120
libc: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using mis-identified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.


Revision 298120 - (view) (download) (annotate) - [select for diffs]
Modified Sat Apr 16 17:52:00 2016 UTC (8 years, 2 months ago) by pfg
File length: 45773 byte(s)
Diff to previous 289925
libc: make some more use of the nitems() macro.

We have an nitems() macro in the <sys/param.h> header that is
convenient to re-use as it makes things easier to read.
Given that it is available already without adding additional
headers and other parts of libc already use it, extend a bit
more its use.


Revision 289925 - (view) (download) (annotate) - [select for diffs]
Modified Sun Oct 25 07:42:56 2015 UTC (8 years, 8 months ago) by ngie
File length: 45798 byte(s)
Diff to previous 287797
Fix compiling with gcc [4.2.1] after r287797 when MK_HESOID == no and
MK_NIS == no by converting `i` back to an int, and instead cast the loop
comparison to `int`

The loop comparison is iterating the len(ns_dtab)-1, because
the last element is the sentinel tuple { NULL, NULL, NULL, }, so when
both HESOID and NIS are off, len(ns_dtab)-1 == 1 - 1 == 0, and the loop
is skipped because the expression is tautologically false

While here, convert `(sizeof(x) / sizeof(x[0]))` to `nitems(x)`

Tested with: clang 3.7.0, gcc 4.2.1, and gcc 4.9.4 [*] with MK_NIS={no,yes}
             and by running bash -lc 'id -u && id -g && id'

* gcc 4.9.4 needs another patch in order for the compile to succeed
  with -Werror with lib/libc/gen/getgrent.c

Reported by: jhibbits


Revision 287797 - (view) (download) (annotate) - [select for diffs]
Modified Mon Sep 14 18:59:01 2015 UTC (8 years, 9 months ago) by rodrigc
File length: 45847 byte(s)
Diff to previous 279712
Use unsigned variables in a few places.

Eliminates gcc 4.9 warnings.


Revision 279712 - (view) (download) (annotate) - [select for diffs]
Modified Fri Mar 6 22:22:57 2015 UTC (9 years, 3 months ago) by pfg
File length: 45824 byte(s)
Diff to previous 279035
compat_passwd(): yet another uninitialized access to stayopen.

CID:	1018731


Revision 279035 - (view) (download) (annotate) - [select for diffs]
Modified Fri Feb 20 01:02:32 2015 UTC (9 years, 4 months ago) by pfg
File length: 45824 byte(s)
Diff to previous 278804
Fix small memleaks in nis_passwd() and nis_group().

These only occur upon error.

Code Review:	https://reviews.freebsd.org/D1849
Reviewed by:	delphij

CID:	1016715
CID:	1016717


Revision 278804 - (view) (download) (annotate) - [select for diffs]
Modified Sun Feb 15 16:50:21 2015 UTC (9 years, 4 months ago) by pfg
File length: 45801 byte(s)
Diff to previous 278363
More tidy-ups on uninitialized scalar variable

As a followup to r278363, there is one more case where
stayopen can be accessed uninitialized, but even after
swapping arguments, access is possible in some other
cases so prevent it completely by initializing stayopen.

CID:	1018729
CID:	1018732


Revision 278363 - (view) (download) (annotate) - [select for diffs]
Modified Sat Feb 7 19:51:34 2015 UTC (9 years, 4 months ago) by pfg
File length: 45797 byte(s)
Diff to previous 158115
Protect uninitialized scalar variable from being accessed

In a couple of cases a variable "stayopen" can be checked
unitialized. This is of no danger as the complementary
condition is false but prevent the access by switching
the checks.

CID:	1018729
CID:	1018732


Revision 158115 - (view) (download) (annotate) - [select for diffs]
Modified Fri Apr 28 12:03:38 2006 UTC (18 years, 2 months ago) by ume
File length: 45797 byte(s)
Diff to previous 129349
- Extend the nsswitch to support Services, Protocols and Rpc
  databases.
- Make nsswitch support caching.

Submitted by:	Michael Bushkov <bushman__at__rsu.ru>
Sponsored by:	Google Summer of Code 2005


Revision 129349 - (view) (download) (annotate) - [select for diffs]
Modified Mon May 17 18:27:05 2004 UTC (20 years, 1 month ago) by kientzle
File length: 39267 byte(s)
Diff to previous 129319
POSIX prohibits any library function from setting errno to 0.
Correct my previous commit and add a comment to the manpage
indicating that the user must set errno to 0 if they wish to
distinguish "no such user" from "error".

Pointed out by: Jacques Vidrine (nectar@)


Revision 129319 - (view) (download) (annotate) - [select for diffs]
Modified Mon May 17 06:17:59 2004 UTC (20 years, 1 month ago) by kientzle
File length: 39271 byte(s)
Diff to previous 128537
If getpwent/getpwuid/getpwnam return NULL, they must also set errno.


Revision 128537 - (view) (download) (annotate) - [select for diffs]
Modified Wed Apr 21 21:15:08 2004 UTC (20 years, 2 months ago) by jon
File length: 39219 byte(s)
Diff to previous 126643
Fix a bug that could result in getpw*() incorrectly returning NULL when NIS
adjunct maps are used.  One symtom of this bug is sshd saying:
	login_get_lastlog: Cannot find account for uid X
when logging in.  The problem here is caused by an incorrect reuse of the rv
variable when previous values are needed later.


Revision 126643 - (view) (download) (annotate) - [select for diffs]
Modified Fri Mar 5 08:10:19 2004 UTC (20 years, 4 months ago) by markm
File length: 39200 byte(s)
Diff to previous 124432
Make NULL a (void*)0 whereever possible, and fix the warnings(-Werror)
that this provokes. "Wherever possible" means "In the kernel OR NOT
C++" (implying C).

There are places where (void *) pointers are not valid, such as for
function pointers, but in the special case of (void *)0, agreement
settles on it being OK.

Most of the fixes were NULL where an integer zero was needed; many
of the fixes were NULL where ascii <nul> ('\0') was needed, and a
few were just "other".

Tested on: i386 sparc64


Revision 124432 - (view) (download) (annotate) - [select for diffs]
Modified Mon Jan 12 13:33:24 2004 UTC (20 years, 5 months ago) by nectar
File length: 39203 byte(s)
Diff to previous 124431
Kill whitespace at end of lines.


Revision 124431 - (view) (download) (annotate) - [select for diffs]
Modified Mon Jan 12 13:29:54 2004 UTC (20 years, 5 months ago) by nectar
File length: 39214 byte(s)
Diff to previous 117750
Fix a bug that could result in a null pointer dereference in
getpwent(3) or getpwuid(3) when using NIS adjunct maps.  The bug was
present in the internal `nis_passwd' function.  The lookup in the
adjunct map used the name passed into `nis_passwd', however no name
was of course supplied by getpwent or getpwuid.  Correctly use the
name from the `struct pwd' that was found instead.

PR:		bin/59962
Submitted by:	Gabriel Gomez <ggomez@fing.edu.uy>


Revision 117750 - (view) (download) (annotate) - [select for diffs]
Modified Fri Jul 18 23:51:15 2003 UTC (20 years, 11 months ago) by wpaul
File length: 39206 byte(s)
Diff to previous 116901
Revert to using yp_order() to probe for master.paswd.by* maps and
don't probe the server at all for passwd.by* maps. This fixes
interoperability with the Services For UNIX NIS server (which is
really a front end to Captive^WActiveDirectory). This server
incorrectly returns success for all YPPROC_MASTER requests,
even for maps that don't exist, which makes it impossible to
(ab)use it to probe for the existence of the master.passwd.by*
maps.

This is a little kludgey, but basically restores the original
behavior of getpwent.c as it is in -stable, and works around both
the lack of YPPROC_ORDER on NIS+ servers as well as the broken
YPPROC_MASTER on Services For UNIX servers.


Revision 116901 - (view) (download) (annotate) - [select for diffs]
Modified Fri Jun 27 03:37:44 2003 UTC (21 years ago) by jwd
File length: 38818 byte(s)
Diff to previous 114443
fix NIS+ YP compat mode

PR:		bin/52792
Submitted by:	TOMITA Yoshinori <yoshint@flab.fujitsu.co.jp>


Revision 114443 - (view) (download) (annotate) - [select for diffs]
Modified Thu May 1 19:03:14 2003 UTC (21 years, 2 months ago) by nectar
File length: 38803 byte(s)
Diff to previous 114256
Back out the `hiding' of strlcpy and strlcat.  Several people
vocally objected to this safety belt.


Revision 114256 - (view) (download) (annotate) - [select for diffs]
Modified Tue Apr 29 21:13:50 2003 UTC (21 years, 2 months ago) by nectar
File length: 38808 byte(s)
Diff to previous 114021
`Hide' strlcpy and strlcat (using the namespace.h / __weak_reference
technique) so that we don't wind up calling into an application's
version if the application defines them.

Inspired by:	qpopper's interfering and buggy version of strlcpy


Revision 114021 - (view) (download) (annotate) - [select for diffs]
Modified Fri Apr 25 18:25:19 2003 UTC (21 years, 2 months ago) by nectar
File length: 38803 byte(s)
Diff to previous 113992
When using `compat' mode, be sure to re-dispatch setpwent, endpwent,
setgrent, and endgrent also.  (The previous NSS implementation used to
simply twiddle the internal data of the various modules directly.)

A symptom (group list set incorrectly in sshd) was
Reported by:	Glenn Johnson <gjohnson@srrc.ars.usda.gov>

Sponsored by:	DARPA, Network Associates Laboratories


Revision 113992 - (view) (download) (annotate) - [select for diffs]
Modified Thu Apr 24 23:56:58 2003 UTC (21 years, 2 months ago) by nectar
File length: 38140 byte(s)
Diff to previous 113794
In compat mode, we `redispatch' the lookup.  It is probably a good
idea to re-initialize `struct passwd', because e.g. pw_class might
get set by one module, but not by another.  Add another call to the
internal pwd_init function to accomplish this.

Sponsored by:	DARPA, Network Associates Laboratories


Revision 113794 - (view) (download) (annotate) - [select for diffs]
Modified Mon Apr 21 13:57:58 2003 UTC (21 years, 2 months ago) by nectar
File length: 38124 byte(s)
Diff to previous 113694
Don't try to access the NIS `master' maps unless we have superuser
privileges.  To do so may cause the NIS server to log spurious and
annoying `access denied' messages.

Reported by:	Philip Paeps <philip@paeps.cx>
Sponsored by:	DARPA, Network Associates Laboratories


Revision 113694 - (view) (download) (annotate) - [select for diffs]
Modified Fri Apr 18 22:07:30 2003 UTC (21 years, 2 months ago) by nectar
File length: 38090 byte(s)
Diff to previous 113691
Follow-up to revision 1.74: Using the result buffer to store our empty
string was an incredibly dumb idea (of course it will be changed by an
NSS module on success!).  Use a static empty string instead.

Sponsored by:	DARPA, Network Associates Laboratories


Revision 113691 - (view) (download) (annotate) - [select for diffs]
Modified Fri Apr 18 21:13:35 2003 UTC (21 years, 2 months ago) by nectar
File length: 38364 byte(s)
Diff to previous 113672
Follow-up to revision 1.73: set _PWF_FILES when `compat' source is used
but user is found in local file.

Reported by:	Shizuka Kudo <shizukakudo_99@yahoo.com>
Sponsored by:	DARPA, Network Associates Laboratories


Revision 113672 - (view) (download) (annotate) - [select for diffs]
Modified Fri Apr 18 17:27:05 2003 UTC (21 years, 2 months ago) by nectar
File length: 38204 byte(s)
Diff to previous 113670
Don't use `memset' to initialize a struct passwd.  A module
may not fill in all fields, and in the case of string fields, this could
cause trouble for applications.  (The only likely example is `pw_class',
because this field is not used by all modules in all cases.)

Move initialization of struct passwd from module-specific code to the
dispatch code.

The problem of a NULL pw_class was
Noticed by:	Philip Paeps <philip@paeps.cx>
                    and the c^Htrusty ssh(1) command.
Déjà vu by:	getpwent.c revision 1.56

Sponsored by:	DARPA, Network Associates Laboratories


Revision 113670 - (view) (download) (annotate) - [select for diffs]
Modified Fri Apr 18 16:24:25 2003 UTC (21 years, 2 months ago) by nectar
File length: 37564 byte(s)
Diff to previous 113666
Correctly set _PWF_FILES in pw_fields when appropriate.
(_PWF_NIS and _PWF_HESIOD were already being set.)

Reported by:	Shizuka Kudo <shizukakudo_99@yahoo.com>
Sponsored by:	DARPA, Network Associates Laboratories


Revision 113666 - (view) (download) (annotate) - [select for diffs]
Modified Fri Apr 18 14:11:17 2003 UTC (21 years, 2 months ago) by nectar
File length: 37488 byte(s)
Diff to previous 113643
Revert the definitions of _PW_KEY* to their previous values.  There is
at least one consumer outside of libc and pwd_mkdb.
Adjust the versioning in libc and pwd_mkdb accordingly.

named was the application affected, and that fact was first
Reported by:	Zherdev Anatoly <tolyar@mx.ru>

Sponsored by:	DARPA, Network Associates Laboratories


Revision 113643 - (view) (download) (annotate) - [select for diffs]
Modified Fri Apr 18 01:00:37 2003 UTC (21 years, 2 months ago) by nectar
File length: 37475 byte(s)
Diff to previous 113596
The default if nsswitch.conf(5) is not present is supposed to be the
hated `compat' source, not `files'.

Reported by:	Philip Paeps <philip@paeps.cx>
Sponsored by:	DARPA, Network Associates Laboratories


Revision 113596 - (view) (download) (annotate) - [select for diffs]
Modified Thu Apr 17 14:15:26 2003 UTC (21 years, 2 months ago) by nectar
File length: 37474 byte(s)
Diff to previous 111618
= Implement thread-safe versions of the getpwent(3) and getgrent(3)
  family of functions using the new nsdispatch(3) core.  Remove
  arbitrary size limits when using the thread-safe versions.

= Re-implement the traditional getpwent(3)/getgrent(3) functions on
  top of the thread-safe versions.

= Update the on-disk format of the hashed version of the passwd(5)
  databases to allow for versioned entries.  The legacy version is
  `3'.  (Don't ask.)

= Add support for version `4' entries in the passwd(5) database.
  Entries in this format are identical to version 3 entries except
  that all integers are stored as 32-bit integers in network byte
  order (big endian).

= pwd_mkdb is updated to generate both version 3 and version 4
  entries.

Sponsored by:	DARPA, Network Associates Laboratories


Revision 111618 - (view) (download) (annotate) - [select for diffs]
Modified Thu Feb 27 13:40:01 2003 UTC (21 years, 4 months ago) by nectar
File length: 26595 byte(s)
Diff to previous 111010
Eliminate 19 warnings in libc (at level WARNS=2) of the
`implicit declaration of function' variety.


Revision 111010 - (view) (download) (annotate) - [select for diffs]
Modified Sun Feb 16 17:29:11 2003 UTC (21 years, 4 months ago) by nectar
File length: 26569 byte(s)
Diff to previous 96186
Eliminate 61 warnings emitted at WARNS=2 (leaving 53 to go).
Only warnings that could be fixed without changing the generated object
code and without restructuring the source code have been handled.

Reviewed by:	/sbin/md5


Revision 96186 - (view) (download) (annotate) - [select for diffs]
Modified Tue May 7 23:26:00 2002 UTC (22 years, 2 months ago) by des
File length: 26711 byte(s)
Diff to previous 94700
Fix bug that causes passwd and friends to fail when the user has a '+' in
their passwd file for NIS because _PWF_SOURCE is not set.

Submitted by:	amigus (perforce change 10969)


Revision 94700 - (view) (download) (annotate) - [select for diffs]
Modified Mon Apr 15 00:21:25 2002 UTC (22 years, 2 months ago) by des
File length: 26620 byte(s)
Diff to previous 94688
Missed a spot in previous commit.

Sponsored by:	DARPA, NAI Labs


Revision 94688 - (view) (download) (annotate) - [select for diffs]
Modified Sun Apr 14 22:24:55 2002 UTC (22 years, 2 months ago) by des
File length: 26535 byte(s)
Diff to previous 90045
(ab)use unused bits in the pw_fields member of struct passwd to record
the source of the data contained in the structure.

Sponsored by:	DARPA, NAI Labs


Revision 90045 - (view) (download) (annotate) - [select for diffs]
Modified Fri Feb 1 01:32:19 2002 UTC (22 years, 5 months ago) by obrien
File length: 26268 byte(s)
Diff to previous 90016
* Remove __P and convert to ANSI prototypes.
* Remove 'register'.  (some functions had 7+ register functions...)
* Fix SCM ID's.


Revision 90016 - (view) (download) (annotate) - [select for diffs]
Modified Thu Jan 31 12:58:36 2002 UTC (22 years, 5 months ago) by bde
File length: 26391 byte(s)
Diff to previous 89999
Fixed world breakage due to missing include of <sys/cdefs.h> in previous
commit.

Fixed related style bugs:
basename.c: misplaced '#if 0'
dirname.c: misplaced '#if 0'
getgrent.c: missing '#if 0', and tab lossage in vendor id (the previous
            commit fixed the complete corruption of the vendor id but
	    lost a tab)
getpwent.c: missing '#if 0'


Revision 89999 - (view) (download) (annotate) - [select for diffs]
Modified Wed Jan 30 21:36:57 2002 UTC (22 years, 5 months ago) by obrien
File length: 26354 byte(s)
Diff to previous 85572
Fix FreeBSD IDs.


Revision 85572 - (view) (download) (annotate) - [select for diffs]
Modified Sat Oct 27 02:13:41 2001 UTC (22 years, 8 months ago) by peter
File length: 26334 byte(s)
Diff to previous 78418
Explicitly use int32_t for on-disk records for pw_change and pw_expire,
since that is what we use now and this insulates us from any time_t
tweaks here.  We can define a record format that uses 64 bit times if/when
we need to.


Revision 78418 - (view) (download) (annotate) - [select for diffs]
Modified Mon Jun 18 16:09:24 2001 UTC (23 years ago) by dwmalone
File length: 26255 byte(s)
Diff to previous 71579
If the username we are trying to look up in the db files won't fit into
the buffer then act like it doesn't exist. The buffer is always big enough
for any valid username.

PR:		27860
Reviewed by:	nectar


Revision 71579 - (view) (download) (annotate) - [select for diffs]
Modified Wed Jan 24 13:01:12 2001 UTC (23 years, 5 months ago) by deischen
File length: 26229 byte(s)
Diff to previous 68691
Remove _THREAD_SAFE and make libc thread-safe by default by
adding (weak definitions to) stubs for some of the pthread
functions.  If the threads library is linked in, the real
pthread functions will pulled in.

Use the following convention for system calls wrapped by the
threads library:
	__sys_foo - actual system call
	_foo - weak definition to __sys_foo
	foo - weak definition to __sys_foo

Change all libc uses of system calls wrapped by the threads
library from foo to _foo.  In order to define the prototypes
for _foo(), we introduce namespace.h and un-namespace.h
(suggested by bde).  All files that need to reference these
system calls, should include namespace.h before any standard
includes, then include un-namespace.h after the standard
includes and before any local includes.  <db.h> is an exception
and shouldn't be included in between namespace.h and
un-namespace.h  namespace.h will define foo to _foo, and
un-namespace.h will undefine foo.

Try to eliminate some of the recursive calls to MT-safe
functions in libc/stdio in preparation for adding a mutex
to FILE.  We have recursive mutexes, but would like to avoid
using them if possible.

Remove uneeded includes of <errno.h> from a few files.

Add $FreeBSD$ to a few files in order to pass commitprep.

Approved by:	-arch


Revision 68691 - (view) (download) (annotate) - [select for diffs]
Modified Mon Nov 13 21:22:50 2000 UTC (23 years, 7 months ago) by nectar
File length: 26177 byte(s)
Diff to previous 68577
Fix bug introduced in previous commit: users obtained via compat mode
had uid, gid set to 0 if not otherwise specified!

Submitted by:	eivind


Revision 68577 - (view) (download) (annotate) - [select for diffs]
Modified Fri Nov 10 19:11:14 2000 UTC (23 years, 7 months ago) by nectar
File length: 26082 byte(s)
Diff to previous 67725
Fix passwd entry `prototypes' in compat mode.  I broke this in revision
1.55 when importing nsswitch from NetBSD.

Reported by:	Naoki Kobayashi <shibata@geo.titech.ac.jp>


Revision 67725 - (view) (download) (annotate) - [select for diffs]
Modified Fri Oct 27 18:27:07 2000 UTC (23 years, 8 months ago) by nectar
File length: 26421 byte(s)
Diff to previous 65532
Explicitly initialize _pw_passwd.


Revision 65532 - (view) (download) (annotate) - [select for diffs]
Modified Wed Sep 6 18:16:48 2000 UTC (23 years, 10 months ago) by nectar
File length: 26402 byte(s)
Diff to previous 64236
Add nsswitch support.  By creating an /etc/nsswitch.conf file, you can
configure FreeBSD so that various databases such as passwd and group can be
looked up using flat files, NIS, or Hesiod.

= Hesiod has been added to libc (see hesiod(3)).

= A library routine for parsing nsswitch.conf and invoking callback
  functions as specified has been added to libc (see nsdispatch(3)).

= The following C library functions have been modified to use nsdispatch:
    . getgrent, getgrnam, getgrgid
    . getpwent, getpwnam, getpwuid
    . getusershell
    . getaddrinfo
    . gethostbyname, gethostbyname2, gethostbyaddr
    . getnetbyname, getnetbyaddr
    . getipnodebyname, getipnodebyaddr, getnodebyname, getnodebyaddr

= host.conf has been removed from src/etc.  rc.network has been modified
  to warn that host.conf is no longer used at boot time.  In addition, if
  there is a host.conf but no nsswitch.conf, the latter is created at boot
  time from the former.

Obtained from:	NetBSD


Revision 64236 - (view) (download) (annotate) - [select for diffs]
Modified Fri Aug 4 10:23:42 2000 UTC (23 years, 11 months ago) by kris
File length: 19843 byte(s)
Diff to previous 52310
sprintf -> snprintf paranoia


Revision 52310 - (view) (download) (annotate) - [select for diffs]
Modified Sat Oct 16 12:31:49 1999 UTC (24 years, 8 months ago) by ache
File length: 19778 byte(s)
Diff to previous 52306
YP/NIS code: remove unnecessary endgrent() calls which can cause fail on
next try over chroot (descriptor closed). getgrnam() used already handles
endgrent() properly and honors _gr_stayopen. Automatically call
setgroupent(1) when _pw_stayopen is set (for YP/NIS code).


Revision 52306 - (view) (download) (annotate) - [select for diffs]
Modified Sat Oct 16 11:50:37 1999 UTC (24 years, 8 months ago) by ache
File length: 19796 byte(s)
Diff to previous 51003
Fix longstanding bug "unused stayopen" introduced in rev1.11

PR:		14201


Revision 51003 - (view) (download) (annotate) - [select for diffs]
Modified Mon Sep 6 08:04:43 1999 UTC (24 years, 10 months ago) by des
File length: 19737 byte(s)
Diff to previous 47721
Don't forget to reset _pw_stepping_yp to 0 before returning. Fixes a bug
where getpwent() would ignore wildcard entries that followed a netgroup
entry.

PR:		misc/12999
Submitted by:	David Hedley <david@inty.net>


Revision 47721 - (view) (download) (annotate) - [select for diffs]
Modified Fri Jun 4 02:27:35 1999 UTC (25 years, 1 month ago) by wpaul
File length: 19711 byte(s)
Diff to previous 45066
Apply patch for PR #12008: remember to reset _yp_enabled flag in
endpwent() so we don't trip over a NULL db pointer later.

PR: 12008
Submitted by: Valentin Netchayev <netch@lucky.net>


Revision 45066 - (view) (download) (annotate) - [select for diffs]
Modified Sat Mar 27 21:51:33 1999 UTC (25 years, 3 months ago) by des
File length: 19667 byte(s)
Diff to previous 41898
Partial fix for the forking problem: if we can't access the master maps,
try again with the unrestricted map.

PR:		bin/10821


Revision 41898 - (view) (download) (annotate) - [select for diffs]
Modified Thu Dec 17 16:31:02 1998 UTC (25 years, 6 months ago) by eivind
File length: 19446 byte(s)
Diff to previous 40742
Restore old semantics (broken in rev 1.47's buffer overflow fix).


Revision 40742 - (view) (download) (annotate) - [select for diffs]
Modified Thu Oct 29 23:16:24 1998 UTC (25 years, 8 months ago) by msmith
File length: 19424 byte(s)
Diff to previous 39327
Prevent buffer overflow in getpwnam()

PR:		bin/8176
Submitted by:	Archie Cobbs <archie@whistle.com>


Revision 39327 - (view) (download) (annotate) - [select for diffs]
Modified Wed Sep 16 04:17:47 1998 UTC (25 years, 9 months ago) by imp
File length: 19424 byte(s)
Diff to previous 39283
Replace memory leaking instances of realloc with non-leaking reallocf.
In some cases replace if (a == null) a = malloc(x); else a =
realloc(a, x); with simple reallocf(a, x).  Per ANSI-C, this is
guaranteed to be the same thing.

I've been running these on my system here w/o ill effects for some
time.  However, the CTM-express is at part 6 of 34 for the CAM
changes, so I've not been able to do a build world with the CAM in the
tree with these changes.  Shouldn't impact anything, but...


Revision 39283 - (view) (download) (annotate) - [select for diffs]
Modified Tue Sep 15 16:22:30 1998 UTC (25 years, 9 months ago) by dt
File length: 19423 byte(s)
Diff to previous 32962
Don't initialize NIS until it is really necessary. Now, in case of network
or NIS server problems, local user can login without a pause.

Also, -Wsomething cleanup.


Revision 32962 - (view) (download) (annotate) - [select for diffs]
Modified Sun Feb 1 06:16:08 1998 UTC (26 years, 5 months ago) by steve
File length: 19094 byte(s)
Diff to previous 29574
XOpen says the void setpwent(void) is correct.  Also call setpassent(0)
instead of duplicating code, albeit trivial (inspired by NetBSD).

PR:		5524


Revision 29574 - (view) (download) (annotate) - [select for diffs]
Modified Thu Sep 18 14:08:40 1997 UTC (26 years, 9 months ago) by phk
File length: 19158 byte(s)
Diff to previous 29479
Many places in the code NULL is used in integer context, where
plain 0 should be used.  This happens to work because we #define
NULL to 0, but is stylistically wrong and can cause problems
for people trying to port bits of code to other environments.

PR:		2752
Submitted by:	Arne Henrik Juul <arnej@imf.unit.no>


Revision 29479 - (view) (download) (annotate) - [select for diffs]
Modified Mon Sep 15 19:37:23 1997 UTC (26 years, 9 months ago) by wosch
File length: 19164 byte(s)
Diff to previous 29396
Fix yet a minor stylistic nit from Bruce.
(`cvs diff -ib' print one new char ;-).


Revision 29396 - (view) (download) (annotate) - [select for diffs]
Modified Sun Sep 14 18:16:11 1997 UTC (26 years, 9 months ago) by wosch
File length: 19205 byte(s)
Diff to previous 24288
Potential bufferflow in getpwent(), getpwnam() and getpwuid()

PR: bin/4134
Submitted by:	nick@foobar.org


Revision 24288 - (view) (download) (annotate) - [select for diffs]
Modified Wed Mar 26 15:42:09 1997 UTC (27 years, 3 months ago) by davidn
File length: 19078 byte(s)
Diff to previous 23668
Remove minor warning (for -Wall -Wshadow); clarifies code.


Revision 23668 - (view) (download) (annotate) - [select for diffs]
Modified Tue Mar 11 11:52:33 1997 UTC (27 years, 3 months ago) by peter
File length: 19087 byte(s)
Diff to previous 23608
Merge from Lite2:
  filesystem include updates, duplicate group suppression, cleanups,
  filesystem whiteout support (unionfs), bidir popen().


Revision 23608 - (view) (download) (annotate) - [select for diffs]
Modified Mon Mar 10 16:47:19 1997 UTC (27 years, 4 months ago) by wpaul
File length: 19099 byte(s)
Diff to previous 20957
Fix brain-o in SunOS passwd.adjunct stuff: !strstr(s, "##") is a) bad
style and b) the wrong logic. Should be strstr(s, "##") != NULL. (Note
that the passwd.adjunct stuff has not been merged into 2.2 so this bug
is not in that branch.)


Revision 20957 - (view) (download) (annotate) - [select for diffs]
Modified Fri Dec 27 19:28:46 1996 UTC (27 years, 6 months ago) by wpaul
File length: 19092 byte(s)
Diff to previous 20119
Small yet significant tweaks/cleanups:

- getpwent:
  o adjunctbuf should be NUL terminated after copying
  o _pw_breakout_yp() needs to know the length of the buffer returned
    from YP so it can properly NUL terminate its local buffer.

- getgrent:
  o YP buffers should be YPMAXRECORD + 2 bytes long and NUL terminated.
    (Previously they were hardcoded to 1024 bytes.)

- getnetgrent:
  o YP data should be copied with snprintf(), not sprintf()

These are 2.2 candidates. I will wait a few days to make sure these don't
break anything and then, if there are no objections, move them to the 2.2
branch.


Revision 20119 - (view) (download) (annotate) - [select for diffs]
Modified Tue Dec 3 17:55:49 1996 UTC (27 years, 7 months ago) by wpaul
File length: 19010 byte(s)
Diff to previous 17141
Add support for detecting and hopefully using the passwd.adjunct.byname
NIS map which is present on SunOS NIS servers with the SunOS C2 security
hack^Woption installed. I'm convinced that the C2 security option restricts
access to the passwd.adjunct.byname map in the same way that I restrict
access to the master.passwd.{byname,buid} maps (checking for reserved ports),
which means that we should be able to handle passwd.adjunct.byname map
correctly.

If _havemaster() doesn't find a master.passwd.byname map, it will now
test for a passwd.adjunct.byname map before defaulting back to the
standard non-shadowed passwd.{byname,byuid} maps. If _pw_breakout_yp()
sees that the adjunct map was found and the password from the standard
maps starts with ##, it will try to grab the correct password field
from the adjunct map. As with the master.passwd maps, this only happens
if the caller is root, so the shadowing feature is preserved; non-root
users just get back ##username as the encrypted password.

Note that all we do is grab the second field from the passwd.adjunct.byname
entry, which is designated to be the real encrypted password. There are
other auditing fields in the entry but they aren't of much use to us.

Also switched back to using yp_order() to probe for the maps (instead
of yp_first()). The original problem with yp_order() was that it barfed
with NIS+ servers in YP compat mode since they don't support the
YPPROC_ORDER procedure. This condition is handled a bit more gracefully
in yplib now: we can detect the error and just punt on the probing.


Revision 17141 - (view) (download) (annotate) - [select for diffs]
Modified Fri Jul 12 18:57:58 1996 UTC (27 years, 11 months ago) by jkh
File length: 17737 byte(s)
Diff to previous 15668
General -Wall warning cleanup, part I.
Submitted-By: Kent Vander Velden <graphix@iastate.edu>


Revision 15668 - (view) (download) (annotate) - [select for diffs]
Modified Tue May 7 20:51:52 1996 UTC (28 years, 2 months ago) by wpaul
File length: 17540 byte(s)
Diff to previous 15446
Grrrr... yet another variation on Murphy's Law: the best way to find
bugs in your code is to put it in the -stable branch. (Corollary: the
day you discover the bug is the day the Internet decides to route your
telnet session to the repository box via Zimbabwe.)

Remove one bogus free(result) (from _havemaster()) that slipped by me.

Flagged by: phkmalloc
Pointed out to me by: Stefan Esser


Revision 15446 - (view) (download) (annotate) - [select for diffs]
Modified Mon Apr 29 14:48:47 1996 UTC (28 years, 2 months ago) by wpaul
File length: 17556 byte(s)
Diff to previous 15267
Very minor tweak:

In __initdb(), a failure to open the local password database is supposed
to result in a warning message being syslog()ed. This warning is only
supposed to be generated as long as the 'warned' flag hasn't been yet;
once the warning is generated, the flag should be set so that the message
is only syslog()ed once. However, while the state of the flag is checked
properly, the flag's state is never changed, so you always get multiple
warnings instead of just one.

Pointed out by: Peter Wemm


Revision 15267 - (view) (download) (annotate) - [select for diffs]
Modified Tue Apr 16 00:22:41 1996 UTC (28 years, 2 months ago) by wpaul
File length: 17554 byte(s)
Diff to previous 13717
NIS cleanups and fixes, the next generation.

getnetgrent.c:

- Catch one bogon that snuck by: in _listmatch(), check for '\0'
  rather than '\n'; strings returned from yp_match() are terminated
  with a nul, not a newline.

getpwent.c:

- Rip out all of the +inclusion/-exclusion stuff from before and
  replace it with something a little less grotty. The main problem
  with the old mechanism was that it wasted many cycles processing
  NIS entries even after it already knew they were to be exlcuded
  (or not included, depending on your pointof view). The highlights
  of these changes include:

  o Uses an in-memory hash database table to keep track of all the
    -@netgroup, -user, and -@group exclusions.

  o Tries harder to duplicate the behavior normally obtained when using
    NIS inclusions/exclusions on a flat /etc/passwd file (meaning things
    come out in much the same order).

  o Uses seperate methods for handling getpwent() and getpwnam()/getpwuid()
    operations instead of trying to do everything with one general
    function, which didn't work as well as I thought it would.

  o Uses both getnetgrent() and innetgr() to try to save time where
    possible.

  o Use only one special token in the local password database
    (_PW_KEYYPBYNUM) instead of seperate tokens to mark + and -
    entries (and stop using the counter tokens too). If this new
    token doesn't exist, the code will make due with the standard
    _PW_KEYBYNUM token in order to support older databases that
    won't have the new token in them.

  All this is an attempt to make this stuff work better in environments
  with large NIS passwd databases.


Revision 13717 - (view) (download) (annotate) - [select for diffs]
Modified Mon Jan 29 20:16:30 1996 UTC (28 years, 5 months ago) by mpp
File length: 19727 byte(s)
Diff to previous 11659
Getpwent() and getservent() can wind up calling free() with
an invalid pointer if a call to yp_first() fails.  Closes PR # 964,
and possibly # 952.


Revision 11659 - (view) (download) (annotate) - [select for diffs]
Modified Sun Oct 22 14:37:11 1995 UTC (28 years, 8 months ago) by phk
File length: 19743 byte(s)
Diff to previous 11436
Minor cleanup, mostly unused vars and missing #includes.


Revision 11436 - (view) (download) (annotate) - [select for diffs]
Modified Wed Oct 11 21:35:08 1995 UTC (28 years, 8 months ago) by wpaul
File length: 19747 byte(s)
Diff to previous 10565
Another tweak/speedup pass:

- Fix buffer overflow problem once and for all: do away with the buffer
  copies to 'user' prior to calling _scancaches() and just pass a pointer
  to the buffer returned by yp_match()/yp_first()/yp_next()/whatever.
  (We turn the first ':' to a NUL first so strcmp() works, then change it
  back later. Submitted by Bill Fenner <fenner@parc.xerox.com> and
  tweaked slightly by me.

- Give _pw_breakout_yp() the 'more elegant solution' I promised way back when.
  Eliminate several copies to static buffers and replace them with just
  one copy. (The buffer returned by the NIS functions is at most
  YPMAXRECORD bytes long, so we should only need one static buffer of
  the same length (plus 2 for paranoia's sake).)

- Also in _pw_breakout_yp(): always set pw.pw_passwd to the username
  obtained via NIS regardless of what pw_fields says: usernames cannot
  be overridden so we have no choice but to use the name returned by
  NIS.

- _Again_ in _pw_breakout_yp(): before doing anything else, check that
  the first character of the NIS-returned buffer is not a '+' or '-'.
  If it is, drop the entry. (#define EXTRA_PARANOIA 1 :)

- Probe for the master.passwd.* maps once during __initdb() instead
  of doing it each time _getyppass() or _nextyppass() is called.

- Don't copy the NIS data buffers to static memory in _getyppass()
  and _nextyppass(): this is done in _pw_breakout_yp() now.

- Test against phkmalloc and phkmalloc/2 (TNG!) to make sure we're
  free()ing the yp buffers sanely.

- Put _havemaster(), _getyppass() and nextyppass() prototypes under
  #ifdef YP. (Somehow they ended up on the wrong side of the #endif.)

- Remove unused variable ___yp_only.


Revision 10565 - (view) (download) (annotate) - [select for diffs]
Modified Tue Sep 5 19:52:59 1995 UTC (28 years, 10 months ago) by wpaul
File length: 19610 byte(s)
Diff to previous 10521
getgrent.c: adjust _nextypgroup() slightly so that it continues processing
the group map after encountering a badly formatted entry.

getpwent.c: same as above for _nextyppass(), and also turn a couple of
sprintf()s into snprintf()s to avoid potential buffer overruns. (The
other day I nearly went mad because of a username in my NIS database
that's actually 9 characters long instead of 8. Stuffing a 9-character
username into an 8-character buffer can do some strange things.)

(This reminds me: I hope somebody's planning to fix the buffer overrun
security hole in syslog(3) before 2.1 ships.)


Revision 10521 - (view) (download) (annotate) - [select for diffs]
Modified Sat Sep 2 04:08:55 1995 UTC (28 years, 10 months ago) by wpaul
File length: 19545 byte(s)
Diff to previous 9332
getpwent.c: turn the code that checks the override caches into a
seperate function to avoid duplication. Also fix getpwent() a
small bit to properly handle the case where the magic NIS '+'
entry appears before the end of the password file.

getgrent.c: be a little more SunOS-ish. Make it look like the NIS
group map is 'inserted' at the the point(s) where the magic NIS '+'
entry/entries appear.

getgrent: fix a file descriptor leak: remember to close the netgroup
file after we determine that we're using NIS-only innetgr() lookups.


Revision 9332 - (view) (download) (annotate) - [select for diffs]
Modified Mon Jun 26 16:04:57 1995 UTC (29 years ago) by wpaul
File length: 19669 byte(s)
Diff to previous 9250
Do the same sanity checking in _pw_breakout_yp() that we do in
_gr_breakout_yp(): if we encounter a NULL pointer generated as the
result of a badly formatted NIS passwd entry (e.g. missing fields),
we punt and return an error code, thereby silently skipping the
bad entry.


Revision 9250 - (view) (download) (annotate) - [select for diffs]
Modified Sat Jun 17 04:00:02 1995 UTC (29 years ago) by wpaul
File length: 19302 byte(s)
Diff to previous 9202
Make _havemaster() use yp_first() (again) instead of yp_order() to
ward off possible NIS+ evil. (I might be overly paranoid with this,
but it doesn't hurt, so...)


Revision 9202 - (view) (download) (annotate) - [select for diffs]
Modified Sun Jun 11 19:33:05 1995 UTC (29 years ago) by rgrimes
File length: 19215 byte(s)
Diff to previous 8870
Merge RELENG_2_0_5 into HEAD


Revision 8870 - (view) (download) (annotate) - [select for diffs]
Modified Tue May 30 05:51:47 1995 UTC (29 years, 1 month ago) by rgrimes
File length: 18724 byte(s)
Diff to previous 8002
Remove trailing whitespace.


Revision 8002 - (view) (download) (annotate) - [select for diffs]
Modified Sat Apr 22 17:28:04 1995 UTC (29 years, 2 months ago) by wpaul
File length: 18729 byte(s)
Diff to previous 7834
in _freecaches(): strdup() allocates us memory -- remember to free it.


Revision 7834 - (view) (download) (annotate) - [select for diffs]
Modified Sat Apr 15 03:11:55 1995 UTC (29 years, 2 months ago) by wpaul
File length: 18440 byte(s)
Diff to previous 7815
Head off potential core dump in _havemaster() (we don't need to free any
memory here: the underlying YP routines handle this one for us).


Revision 7815 - (view) (download) (annotate) - [select for diffs]
Modified Fri Apr 14 14:56:28 1995 UTC (29 years, 2 months ago) by wpaul
File length: 18471 byte(s)
Diff to previous 7615
Better conformance to SunOS behavior: if we can't match a user to one
of the plus or minus lists at all, reject him. This lets you create
a +@netgroup list of users that you want to admit and reject everybody
else. If you end your +@netgroup list with the wildcard line
(+:::::::::) then you'll have a +@netgroup list that remaps the
specified people but leaves people not in any netgroup unaffected.


Revision 7615 - (view) (download) (annotate) - [select for diffs]
Modified Tue Apr 4 05:36:16 1995 UTC (29 years, 3 months ago) by wpaul
File length: 18222 byte(s)
Diff to previous 7422
getpwent.c: fix problem with emacs dumping core when NIS is enabled. Also
add #includes for YP headers when compiling with -DYP to avoid some implicit
declarations.

getgrent.c & getnetgrent.c: add some #includes to avoid implicit declarations
of YP functions.


Revision 7422 - (view) (download) (annotate) - [select for diffs]
Modified Mon Mar 27 20:46:40 1995 UTC (29 years, 3 months ago) by wpaul
File length: 18026 byte(s)
Diff to previous 7340
Use yp_order() instead of yp_first()  in _havemaster() to check for the
presence of the master.passwd.byname map, and remember to free the
returned order value before exiting.


Revision 7340 - (view) (download) (annotate) - [select for diffs]
Modified Sat Mar 25 00:30:35 1995 UTC (29 years, 3 months ago) by wpaul
File length: 18072 byte(s)
Diff to previous 7322
Add calls to endgrent() and endnetgrent() to the end of _createcaches().


Revision 7322 - (view) (download) (annotate) - [select for diffs]
Modified Fri Mar 24 08:01:01 1995 UTC (29 years, 3 months ago) by wpaul
File length: 18043 byte(s)
Diff to previous 7319
Yikes! Fix stupid mistake I made in last commit that made getpwent() ignore
local password entries when YP was enabled. (How the heck did that
get by me!?)


Revision 7319 - (view) (download) (annotate) - [select for diffs]
Modified Fri Mar 24 05:46:47 1995 UTC (29 years, 3 months ago) by wpaul
File length: 17833 byte(s)
Diff to previous 7288
As per Justin T. Gibbs's request, agument the +@netgroup/-@netgroup
remapping mechanism in the following manner: if given an entry +@foo
and there is no netgroup named 'foo,' try searching for a regular
user group called 'foo' and build the cache using the members of
group 'foo' instead. If both a netgroup 'foo' and a user group 'foo'
exist, the 'foo' netgroup takes precedence, since we're primarily
interested in netgroup matching anyway.

This allows access control schemes based on ordinary user groups
(which are also available via NIS) rather than netgroups, since
netgroups on some systems are limited in really brain-damaged ways.


Revision 7288 - (view) (download) (annotate) - [select for diffs]
Modified Thu Mar 23 22:18:00 1995 UTC (29 years, 3 months ago) by wpaul
File length: 16651 byte(s)
Diff to previous 7278
Very important sanity checks: today I clobbered all four NIS servers on
my network because setnetgrent() was trying to do a lookup on group "".
It seems that an attempt to do a yp_match() (and possible yp_next())
on a null or empty key causes Sun's ypserv in SunOS 4.1.3 to exit
suddenly (and without warning). Our ypserv behaves badly in this
situation too, thoush it doesn't appear to crash. In any event, getpwent,
getnetgrent and yp_match() and yp_next() are now extra careful not to
accidentally pass on null or empty arguments.

Also made a small change to getpwent.c to allow +::::::::: wildcarding,
which I had disabled previously.


Revision 7278 - (view) (download) (annotate) - [select for diffs]
Modified Thu Mar 23 17:33:19 1995 UTC (29 years, 3 months ago) by wpaul
File length: 16507 byte(s)
Diff to previous 7262
Lots of fixes/improvements in the +user substitution handling:

- Have the +@netgroup/-@netgroup caches handle the +user/-user cases too.
- Clean up getpwent() to take advantage of the improved +user/-user handling.


Revision 7262 - (view) (download) (annotate) - [select for diffs]
Modified Thu Mar 23 04:04:01 1995 UTC (29 years, 3 months ago) by wpaul
File length: 16652 byte(s)
Diff to previous 7258
Small cleanups:
- Prepend a '_' to a couple of things
- Make sure YP is enabled in _createcaches()
- Remove a couple of unused/uneeded variables from _createcaches()


Revision 7258 - (view) (download) (annotate) - [select for diffs]
Modified Thu Mar 23 00:59:15 1995 UTC (29 years, 3 months ago) by wpaul
File length: 16546 byte(s)
Diff to previous 6190
Phew! Done at last: getpwent now understands +@netgroup/-@netgroup directives
in addition to the existing NIS substitutions. I may tweak this a bit in
the future, but the important stuff is all here.


Revision 6190 - (view) (download) (annotate) - [select for diffs]
Modified Sun Feb 5 02:12:49 1995 UTC (29 years, 5 months ago) by wpaul
File length: 11451 byte(s)
Diff to previous 6145
Collapsed _masterpw_breakout_yp() and _pw_breakout_yp() into a
single function.


Revision 6145 - (view) (download) (annotate) - [select for diffs]
Modified Fri Feb 3 01:09:35 1995 UTC (29 years, 5 months ago) by wpaul
File length: 12527 byte(s)
Diff to previous 6096
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.


Revision 6096 - (view) (download) (annotate) - [select for diffs]
Modified Wed Feb 1 20:09:00 1995 UTC (29 years, 5 months ago) by wpaul
File length: 12019 byte(s)
Diff to previous 6095
Fix for that last fix... pass the hat. :)


Revision 6095 - (view) (download) (annotate) - [select for diffs]
Modified Wed Feb 1 20:06:33 1995 UTC (29 years, 5 months ago) by wpaul
File length: 12067 byte(s)
Diff to previous 6076
Small fix to _getyppass(): sometimes we can construct the wrong mapname
when looking for master.passwd.whatever.


Revision 6076 - (view) (download) (annotate) - [select for diffs]
Modified Tue Jan 31 10:04:18 1995 UTC (29 years, 5 months ago) by wpaul
File length: 12025 byte(s)
Diff to previous 5714
Some changes for YP password map handling:

- FreeBSD's NIS server can supply a master.passwd map, which has
  more fields in it than a standard passwd map, so we need a
  _master_pw_breakout() fuction.

- When doing passwd map lookups, look for master.passwd.* by attempting
  a _yp_first() on master.passwd.byname. If it exists, we're being served
  by a FreeBSD NIS server and we should use this map.

- If we aren't the superuser, retrieve only the standard passwd maps.
  If we're being served by a FreeBSD system, then the passwd map has
  no passwords in it, and it won't serve us the master.passwd map unless
  we're superuser anyway.

There's a small speed hit for the superuser inherent in the check for
the master.passwd map, but this lets us dynamically decide what to do
rather than rely on a non-standard config file somewhere. Since all
of this is bypassed for normal users, they shouldn't notice the
difference.


Revision 5714 - (view) (download) (annotate) - [select for diffs]
Modified Thu Jan 19 19:01:50 1995 UTC (29 years, 5 months ago) by wollman
File length: 9731 byte(s)
Diff to previous 5703
Fix unbalanced #endif introduced by yesterday's change.


Revision 5703 - (view) (download) (annotate) - [select for diffs]
Modified Tue Jan 17 23:17:38 1995 UTC (29 years, 5 months ago) by wollman
File length: 9737 byte(s)
Diff to previous 2935
Prevent sites from shooting themselves in the foot while enabling/disabling
YP by disallowing `+' entries as logins in all cases.  (This handles the
case of a `+' entry in the password file but YP not running, which should
never happen but is easy enough to check for so we'll apply some
prophylaxis.)


Revision 2935 - (view) (download) (annotate) - [select for diffs]
Modified Tue Sep 20 21:42:12 1994 UTC (29 years, 9 months ago) by wollman
File length: 9736 byte(s)
Diff to previous 2917
Second half of YP security hole fix.  Needs updated password
database in order to operate.


Revision 2917 - (view) (download) (annotate) - [select for diffs]
Added Tue Sep 20 01:23:45 1994 UTC (29 years, 9 months ago) by wollman
File length: 9541 byte(s)
Diff to previous 1574
Re-implement YP password file support from scratch.  This implementation
correctly handles +user entries and + entries with local overrides.



This form allows you to request diffs between any two revisions of this file. For each of the two "sides" of the diff, enter a numeric revision.

  Diffs between and
  Type of Diff should be a

  ViewVC Help
Powered by ViewVC 1.1.27