summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/getpwent.c
Commit message (Collapse)AuthorAgeFilesLines
* - Extend the nsswitch to support Services, Protocols and Rpcume2006-04-281-0/+277
| | | | | | | | databases. - Make nsswitch support caching. Submitted by: Michael Bushkov <bushman__at__rsu.ru> Sponsored by: Google Summer of Code 2005
* POSIX prohibits any library function from setting errno to 0.kientzle2004-05-171-1/+1
| | | | | | | | 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@)
* If getpwent/getpwuid/getpwnam return NULL, they must also set errno.kientzle2004-05-171-0/+3
|
* Fix a bug that could result in getpw*() incorrectly returning NULL when NISjon2004-04-211-0/+1
| | | | | | | 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.
* Make NULL a (void*)0 whereever possible, and fix the warnings(-Werror)markm2004-03-051-1/+1
| | | | | | | | | | | | | | | 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
* Kill whitespace at end of lines.nectar2004-01-121-9/+9
|
* Fix a bug that could result in a null pointer dereference innectar2004-01-121-1/+1
| | | | | | | | | | | 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>
* Revert to using yp_order() to probe for master.paswd.by* maps andwpaul2003-07-181-7/+14
| | | | | | | | | | | | | | | 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.
* fix NIS+ YP compat modejwd2003-06-271-3/+4
| | | | | PR: bin/52792 Submitted by: TOMITA Yoshinori <yoshint@flab.fujitsu.co.jp>
* Back out the `hiding' of strlcpy and strlcat. Several peoplenectar2003-05-011-5/+5
| | | | vocally objected to this safety belt.
* `Hide' strlcpy and strlcat (using the namespace.h / __weak_referencenectar2003-04-291-5/+5
| | | | | | | 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
* When using `compat' mode, be sure to re-dispatch setpwent, endpwent,nectar2003-04-251-0/+29
| | | | | | | | | | 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
* In compat mode, we `redispatch' the lookup. It is probably a goodnectar2003-04-241-0/+1
| | | | | | | | 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
* Don't try to access the NIS `master' maps unless we have superusernectar2003-04-211-7/+9
| | | | | | | | 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
* Follow-up to revision 1.74: Using the result buffer to store our emptynectar2003-04-181-22/+16
| | | | | | | 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
* Follow-up to revision 1.73: set _PWF_FILES when `compat' source is usednectar2003-04-181-4/+13
| | | | | | | but user is found in local file. Reported by: Shizuka Kudo <shizukakudo_99@yahoo.com> Sponsored by: DARPA, Network Associates Laboratories
* Don't use `memset' to initialize a struct passwd. A modulenectar2003-04-181-6/+31
| | | | | | | | | | | | | | | | 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
* Correctly set _PWF_FILES in pw_fields when appropriate.nectar2003-04-181-2/+6
| | | | | | | (_PWF_NIS and _PWF_HESIOD were already being set.) Reported by: Shizuka Kudo <shizukakudo_99@yahoo.com> Sponsored by: DARPA, Network Associates Laboratories
* Revert the definitions of _PW_KEY* to their previous values. There isnectar2003-04-181-2/+2
| | | | | | | | | | 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
* The default if nsswitch.conf(5) is not present is supposed to be thenectar2003-04-181-1/+1
| | | | | | | hated `compat' source, not `files'. Reported by: Philip Paeps <philip@paeps.cx> Sponsored by: DARPA, Network Associates Laboratories
* = Implement thread-safe versions of the getpwent(3) and getgrent(3)nectar2003-04-171-971/+1446
| | | | | | | | | | | | | | | | | | | | | | 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
* Eliminate 19 warnings in libc (at level WARNS=2) of thenectar2003-02-271-0/+1
| | | | `implicit declaration of function' variety.
* Eliminate 61 warnings emitted at WARNS=2 (leaving 53 to go).nectar2003-02-161-4/+1
| | | | | | | 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
* Fix bug that causes passwd and friends to fail when the user has a '+' indes2002-05-071-0/+3
| | | | | | their passwd file for NIS because _PWF_SOURCE is not set. Submitted by: amigus (perforce change 10969)
* Missed a spot in previous commit.des2002-04-151-1/+3
| | | | Sponsored by: DARPA, NAI Labs
* (ab)use unused bits in the pw_fields member of struct passwd to recorddes2002-04-141-2/+12
| | | | | | the source of the data contained in the structure. Sponsored by: DARPA, NAI Labs
* * Remove __P and convert to ANSI prototypes.obrien2002-02-011-23/+19
| | | | | * Remove 'register'. (some functions had 7+ register functions...) * Fix SCM ID's.
* Fixed world breakage due to missing include of <sys/cdefs.h> in previousbde2002-01-311-0/+4
| | | | | | | | | | | | 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'
* Fix FreeBSD IDs.obrien2002-01-301-3/+2
|
* Explicitly use int32_t for on-disk records for pw_change and pw_expire,peter2001-10-271-2/+5
| | | | | | 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.
* If the username we are trying to look up in the db files won't fit intodwmalone2001-06-181-1/+3
| | | | | | | | the buffer then act like it doesn't exist. The buffer is always big enough for any valid username. PR: 27860 Reviewed by: nectar
* Remove _THREAD_SAFE and make libc thread-safe by default bydeischen2001-01-241-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix bug introduced in previous commit: users obtained via compat modenectar2000-11-131-3/+8
| | | | | | had uid, gid set to 0 if not otherwise specified! Submitted by: eivind
* Fix passwd entry `prototypes' in compat mode. I broke this in revisionnectar2000-11-101-34/+16
| | | | | | 1.55 when importing nsswitch from NetBSD. Reported by: Naoki Kobayashi <shibata@geo.titech.ac.jp>
* Explicitly initialize _pw_passwd.nectar2000-10-271-1/+1
|
* Add nsswitch support. By creating an /etc/nsswitch.conf file, you cannectar2000-09-061-675/+990
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* sprintf -> snprintf paranoiakris2000-08-041-3/+3
|
* YP/NIS code: remove unnecessary endgrent() calls which can cause fail onache1999-10-161-5/+3
| | | | | | 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).
* Fix longstanding bug "unused stayopen" introduced in rev1.11ache1999-10-161-2/+6
| | | | PR: 14201
* Don't forget to reset _pw_stepping_yp to 0 before returning. Fixes a bugdes1999-09-061-0/+1
| | | | | | | | where getpwent() would ignore wildcard entries that followed a netgroup entry. PR: misc/12999 Submitted by: David Hedley <david@inty.net>
* Apply patch for PR #12008: remember to reset _yp_enabled flag inwpaul1999-06-041-0/+2
| | | | | | | endpwent() so we don't trip over a NULL db pointer later. PR: 12008 Submitted by: Valentin Netchayev <netch@lucky.net>
* Partial fix for the forking problem: if we can't access the master maps,des1999-03-271-4/+11
| | | | | | try again with the unrestricted map. PR: bin/10821
* Restore old semantics (broken in rev 1.47's buffer overflow fix).eivind1998-12-171-1/+3
|
* Prevent buffer overflow in getpwnam()msmith1998-10-291-2/+2
| | | | | PR: bin/8176 Submitted by: Archie Cobbs <archie@whistle.com>
* Replace memory leaking instances of realloc with non-leaking reallocf.imp1998-09-161-1/+1
| | | | | | | | | | | 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...
* Don't initialize NIS until it is really necessary. Now, in case of networkdt1998-09-151-55/+71
| | | | | | or NIS server problems, local user can login without a pause. Also, -Wsomething cleanup.
* XOpen says the void setpwent(void) is correct. Also call setpassent(0)steve1998-02-011-7/+2
| | | | | | instead of duplicating code, albeit trivial (inspired by NetBSD). PR: 5524
* Many places in the code NULL is used in integer context, wherephk1997-09-181-2/+2
| | | | | | | | | 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>
* Fix yet a minor stylistic nit from Bruce.wosch1997-09-151-4/+4
| | | | (`cvs diff -ib' print one new char ;-).
* Potential bufferflow in getpwent(), getpwnam() and getpwuid()wosch1997-09-141-2/+7
| | | | | PR: bin/4134 Submitted by: nick@foobar.org
OpenPOWER on IntegriCloud