summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/getpwent.c
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Remove minor warning (for -Wall -Wshadow); clarifies code.davidn1997-03-261-3/+3
|
* Merge from Lite2:peter1997-03-111-14/+13
| | | | | filesystem include updates, duplicate group suppression, cleanups, filesystem whiteout support (unionfs), bidir popen().
* Fix brain-o in SunOS passwd.adjunct stuff: !strstr(s, "##") is a) badwpaul1997-03-101-1/+1
| | | | | | 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.)
* Small yet significant tweaks/cleanups:wpaul1996-12-271-5/+7
| | | | | | | | | | | | | | | | | | - 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.
* Add support for detecting and hopefully using the passwd.adjunct.bynamewpaul1996-12-031-13/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* General -Wall warning cleanup, part I.jkh1996-07-121-3/+7
| | | | Submitted-By: Kent Vander Velden <graphix@iastate.edu>
* Grrrr... yet another variation on Murphy's Law: the best way to findwpaul1996-05-071-1/+0
| | | | | | | | | | | 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
* Very minor tweak:wpaul1996-04-291-1/+1
| | | | | | | | | | | | 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
* NIS cleanups and fixes, the next generation.wpaul1996-04-161-259/+259
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Getpwent() and getservent() can wind up calling free() withmpp1996-01-291-1/+0
| | | | | an invalid pointer if a call to yp_first() fails. Closes PR # 964, and possibly # 952.
* Minor cleanup, mostly unused vars and missing #includes.phk1995-10-221-1/+1
|
* Another tweak/speedup pass:wpaul1995-10-111-62/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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.
* getgrent.c: adjust _nextypgroup() slightly so that it continues processingwpaul1995-09-051-3/+6
| | | | | | | | | | | | | 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.)
* getpwent.c: turn the code that checks the override caches into awpaul1995-09-021-70/+65
| | | | | | | | | | | | | 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.
* Do the same sanity checking in _pw_breakout_yp() that we do inwpaul1995-06-261-16/+19
| | | | | | | _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.
* Make _havemaster() use yp_first() (again) instead of yp_order() towpaul1995-06-171-2/+6
| | | | | ward off possible NIS+ evil. (I might be overly paranoid with this, but it doesn't hurt, so...)
* Merge RELENG_2_0_5 into HEADrgrimes1995-06-111-0/+9
|
* Remove trailing whitespace.rgrimes1995-05-301-4/+4
|
* in _freecaches(): strdup() allocates us memory -- remember to free it.wpaul1995-04-221-10/+18
|
* Head off potential core dump in _havemaster() (we don't need to free anywpaul1995-04-151-4/+1
| | | | memory here: the underlying YP routines handle this one for us).
* Better conformance to SunOS behavior: if we can't match a user to onewpaul1995-04-141-2/+8
| | | | | | | | 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.
* getpwent.c: fix problem with emacs dumping core when NIS is enabled. Alsowpaul1995-04-041-16/+20
| | | | | | | | 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.
OpenPOWER on IntegriCloud