summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ypserv/yp_dblookup.c
Commit message (Collapse)AuthorAgeFilesLines
* Use __FBSDID over rcsid[]. Protect copyright[] where needed.obrien2003-05-031-4/+2
|
* Fix a boatload of format errors and constness violations.des2002-05-081-5/+8
| | | | Sponsored by: DARPA, NAI Labs
* Spell void * as void * rather than caddr_t. This is complicated by thedes2002-04-281-12/+12
| | | | | | fact that caddr_t is often misspelled as char *. Sponsored by: DARPA, NAI Labs
* ANSIfy and remove some dead code.des2002-02-061-61/+40
| | | | Sponsored by: DARPA, NAI Labs
* Apply the following mechanical transformations in preparation fordes2002-02-061-6/+6
| | | | | | | | | | | | | | | | | ansification and constification: s{\s+__P\((\(.*?\))\)}{$1}g; s{\(\s+}{\(}g; s{\s+\)}{\)}g; s{\s+,}{,}g; s{(\s+)(for|if|switch|while)\(}{$1$2 \(}g; s{return ([^\(].*?);}{return ($1);}g; s{([\w\)])([!=+/\*-]?=)([\w\(+-])}{$1 $2 $3}g; s{\s+$}{\n};g Also add $FreeBSD$ where needed. MFC after: 1 week
* Convert from CIRCLEQ to TAILQ.phk2000-12-291-35/+33
|
* Back out the previous change to the queue(3) interface.jake2000-05-261-2/+2
| | | | | | It was not discussed and should probably not happen. Requested by: msmith and others
* Change the way that the queue(3) structures are declared; don't assume thatjake2000-05-231-2/+2
| | | | | | | | the type argument to *_HEAD and *_ENTRY is a struct. Suggested by: phk Reviewed by: phk Approved by: mdodd
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Close PR #11122: check key length before calling strncmp()wpaul1999-04-141-3/+4
| | | | in yp_next_record().
* Fix a bug in the database handle caching. This has to do with the way thewpaul1998-02-111-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | underlying database code works. When dealing with first/next queries, you have the notion of a database 'cursor,' which is essentially a file pointer for the database. To select the first entry, you do a fetch with the R_FIRST flag set, then you can use the R_NEXT flag to enumerate the other entries in the database. Unfortunately, doing a direct fetch with no flag does _not_ set the 'cursor,' so you can't do a direct fetch and then enumerate the table from there. The bug is that cached handles generated as the result of a YPPROC_MATCH were being treated as though they were the same as handles generated by a YPPROC_FIRST, which is not the case. The manifestation is that if you do a 'ypmatch first-key-in-map map' followed by a yp_first()/yp_next() pair, the yp_first() and yp_next() both return the first key in the table, which makes the entry appear to be duplicated. A couple smaller things since I'm here: - yp_main.c and yp_error.c both have a global 'int debug' in them. For some reason, our cc/ld doesn't flag this as a multiply defined symbol even though it should. Removed the declaration from yp_main.c; we want the one in yp_error.c. - The Makefile wasn't installing ypinit in the right place.
* Typos in man page. Cosmetics in error strings.charnier1997-10-291-22/+19
|
* Revert $FreeBSD$ to $Id$peter1997-02-221-2/+2
|
* Fix bug that slipped through last big round of changes: sometimeswpaul1997-01-201-1/+6
| | | | | | | | | yp_next_record() is called without a key (from xdr_my_ypresp_all()), in which case it returns the first key in the map. When doing this, it also needs to update the key index in the map queue entry. Without this, ypproc_all_2_svc() (and hence ypcat) don't work correctly. Noticed by: Michael L. Hench <hench@watt.cae.uwm.edu>
* Make the long-awaited change from $Id$ to $FreeBSD$jkh1997-01-141-2/+2
| | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise.
* Big round o changes:wpaul1996-12-221-10/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - yp_dblookup.c: Create non-DB specific database access functions. Using these allows access to the underlying database functions without needing explicit knowledge of Berkeley DB. (These are used only when DB_CACHE is #defined. Other programs that use the non-caching functions (yp_mkdb, ypxfr, yppush, rpc.yppasswdd) shouldn't notice the difference.) - yp_dnslookup: Implement async DNS lookups. We send our own DNS requests using UDP and put the request in a queue. When the response arrives, we use the ID in the header to find the corresponsing queue entry and then send the response to the client. We can go about our business and handle other YP requests in the meantime. This way, we can deal with time consuming DNS requests without blocking and without forking. - yp_server.c: Convert to using new non-DB-specific database access functions. This simplifies the code a bit and removes the need for this module to know anything about Berkeley DB. Also convert the ypproc_match_2_svc() function to use the async DNS lookup routines. - yp_main.c: tweak yp_svc_run() to add the resolver socket to the set of descriptors monitored in the select() loop. Also add a timeout to select(); we may get stale DNS requests stuck in the queue which we want to invalidate after a while. If the timeout hits, we decrement the ttl on all pending DNS requests and nuke those requests that aren't handled before ttl hits zero. - yp_extern.h: Add prototypes for new stuff. - yp_svc_udp.c (new file): The async resolver code needs to be able to rummage around inside the RPC UDP transport handle in order to work correcty. There's basically one transport handle, and each time a request comes in, the transaction ID in the handle is changed. This means that if we queue a DNS request, then we handle some other unrelated requests, we will be unable to send the DNS response because the transaction ID and remote address of the client that made the DNS request will have been lost. What we need to do is save the client address and transaction ID in the queue entry for the DNS request, then put the transaction ID and address back in the transport handle when we're ready to reply. (And then we have to undo the change so as not to confuse any other part of the server.) The trouble is that the transaction ID is hidden in an opaque part of the transport handle, and only the code in the svc_udp module in the RPC library knows how to handle it. This file contains a couple of functions that let us read and set the transaction ID in spite of this. This is really a dirty trick and I should be taken out and shot for even thinking about it, but there's no other way to get this stuff to work. - Makefile: add yp_svc_udp.c to SRCS.
* Add support for handling the YP_SECURE and YP_INTERDOMAIN keys fromwpaul1996-10-241-2/+64
| | | | | | | | | | | | any maps that may have them. If the YP_SECURE key is present, ypserv will only allow access to the map from clients on reserved ports. If the YP_INTERDOMAIN key is present, the server will do DNS lookups for hostnames that it can't find in hosts.byname or hosts.byaddr. This is the same as the -d flag (which is retained for backwards compatibility) but it can be set on a per-map/per-domain basis. Also modified /var/yp/Makefile to add YP_INTERDOMAIN to the hosts.* maps and YP_SECURE to master.passwd.* maps by default.
* Re-implement the DB handle cache using a circular queue and managewpaul1996-07-071-89/+180
| | | | | | | | | | | | | | | | it with the CIRCLEQ macros. This simplifies the code a little, makes it somewhat easier to read, and may be a little faster. (Actually I think the performace is about the same.) Also, in the non DB_CACHE case, save copies of data returned from the database library in a static buffer, just in case we decide to use it after the database has been closed. Technically, the memory that the data pointers refer to belongs to the DB package and we can't count on it being there after the database has been closed -- the DB package frees its buffers. (With DB_CACHE #defined the databases are held open so the buffers remain valid.) I don't think any of the utilities that use the dblookup module have had any problems with this yet, but there's no sense in taking any chances.
* Makefile.yp:wpaul1996-06-051-15/+23
| | | | | | | | | | | | | | | | | | | | | | | - Add a 'pushpw' target that only yppushes the various passwd maps and sends a YPPROC_CLEAR to the local ypserv. This will be used by rpc.yppasswdd once I merge in the in-place update changes. yp_access.c: - Make the yp_access() function print RPC program and procedure numbers that it doesn't know about in literal form. This will allow it to work with other prgrams that it doesn't know about, like rpc.ypxfrd I'm going to import shortly. yp_dblookup.c: - Take out the __inline keywords. They weren't really helping me anyway. - Somehow I broke yp_next() when DB_CACHE wasn't #defined. Fix it. - Also fix potential case where yp_next() might loop forever; make sure it checks the return values of all the (dbp->seq)()/R_NEXT calls that it does as well as comparing keys.
* Small touch-ups -- no functional changes.wpaul1996-05-311-16/+17
| | | | | | | | | | | | | | | Fix some comments to reflect reality (in some cases I made changes to code but not to the comments). Change some instances of 'inline' to '__inline' to pacify gcc -ansi -pedantic. Use rcsid strings more consistently. Make 'oldaddr' static in yp_access(). Use strcpy()/strcat() in yp_open_db_cache() instead of snprintf(). (Seems to be a little faster this way.)
* Performance enhancements (I hope) and new stuff:wpaul1996-04-281-31/+292
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | yp_dblookup.c: - Implement database handle caching. What this means is that instead of opening and closing map databases for each request, we open a database and save the handle (and, if requested, the key index) in an array. This saves a bit of overhead on things like repeated YPPROC_NEXT calls, such as you'd get from getpwent(). Normally, each YPPROC_NEXT would require open()ing the database, seeking to the location supplied by the caller (which is time consuming with hash databases as the R_CURSOR flag doesn't work), reading the data, close()ing the database and then shipping the data off to the caller. The system call overhead is prohibitive, especially with very large maps. By caching the handle to an open database, we elimitate at least the open()/close() system calls, as well as the associated DB setup and tear-down operations, for a large percentage of the time. This improves performance substantially at the cost of consuming a little more memory than before. Note that all the caching support is surrounded by #ifdef DB_CACHE so that this same source module can still be used by other programs that don't need it. - Make yp_open_db() call yp_validdomain(). Doing it here saves cycles when caching is enabled since a hit on the map cache list by definition means that the domain being referenced is valid. - Also make yp_open_db() check for exhaustion of file descriptors, just in case. yp_server.c: - Reorganize things a little to take advantage of the database handle caching. Add a call to yp_flush_all() in ypproc_clear_2_svc(). - Remove calls to yp_validdomain() from some of the service procedures. yp_validdomain() is called inside yp_open_db() now, so procedures that call into the database package don't need to use yp_validdomain() themselves. - Fix a bogosity in ypproc_maplist_2_svc(): don't summarily initiallize the result.maps pointer to NULL. This causes yp_maplist_free() to fail and leaks memory. - Make ypproc_master_2_svc() copy the string it gets from the database package into a private static buffer before trying to NUL terminate it. This is necessary with the DB handle caching: stuffing a NUL into the data returned by DB package will goof it up internally. yp_main.c: - Stuff for DB handle caching: call yp_init_dbs() to clear the handle array and add call to yp_flush_all() to the SIGHUP signal handler. Makefile.yp: - Reorganize to deal with database caching. yp_mkdb(8) can now be used to send a YPPROC_CLEAR signal to ypserv(8). Call it after each map is created to refresh ypserv's cache. - Add support for mail.alias map. Contributed by Mike Murphy (mrm@sceard.com). - Make default location for the netgroups source file be /var/yp/netgroup instead of /etc/netgroup. mkaliases: - New file: script to generate mail.alias map. Contributed by Mike Murphy (mrm@sceard.com). Makefile: - Install Makefile.yp as /var/yp/Makefile.dist and link it to /var/yp/Makefile only if /var/yp/Makefile doesn't already exist. Suggested by Peter Wemm. - Install new mkaliases script in /usr/libexec along with mknetid. - Use somewhat saner approach to generating rpcgen-dependent files as suggested by Garrett Wollman.
* Fix for memory leak: specify NULL as openinfo parameter when callingwpaul1996-04-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | dbopen() to open an NIS map. Testing with very large maps (e.g. a sample password database with 31,000+ entries) has shown that ypserv will leak memory (ps shows RSS and VSZ growing to 4000 pages or more) when performing repeated yp_next()s or a yp_all(). The problem with yp_all() is not immediately obvious since the ypproc_all service is handled in a child process which exits once the transfer is finished, but with repeated yp_next()s (like what you get when you use getpwent() to scroll through the password database), the parent ypserv grows to enormous size and never shrinks again. It seems this is related to the HASHINFO parameters I used in yp_dblookup.c, which I actually stole from pwd_mkdb. Calling dbopen() with the default parameters (specifying openinfo as NULL) fixes the problem. I still need to see how this impacts the other NIS tools. I'm also considering changing from hash to btree databases: the hash database method doesn't support R_CURSOR, which means yp_next_record() has to do a lot of ugly work in order to reach an arbitrary location in the database.
* Makefile.yp:wpaul1996-02-041-9/+28
| | | | | | | | - Improve support for multiple domains. (In preparation for new rpc.yppasswdd.) yp_dblookup.c: - Improve error reporting: be more selective as to what error code we return when a (dbp->get) fails.
* A few small tweaks related to ypxfr:wpaul1995-12-231-8/+8
| | | | | | | | | | | | | | | | - Add a ypxfr_callback() function that we can use to signal failure to yppush(8) in the event that we can't fork()/exec() ypxfr(8). yppush only checks the return status from YPPROC_XFR enough to determine that the RPC succeded: it relies on its callback service to figure out whether or not the transfer actually worked. - Give yp_dblookup.c its own debug variable (ypdb_debug) so that DB access debugging messages can be turned on or off independent of the program's global debug messages. - Have the Makefile rpcgen the ypushresp_xfr_1() client stub for us and nuke the unneeded rule for yp_xdr.c that I left in by mistake (the XDR filters live in libc now).
* This commit was generated by cvs2svn to compensate for changes in r12891,wpaul1995-12-161-0/+217
which included commits to RCS files with non-trunk default branches.
OpenPOWER on IntegriCloud