summaryrefslogtreecommitdiff
path: root/lib/libc
Commit message (Collapse)AuthorAgeFilesLines
* Make _yp_dobind() a litle smarter:Bill Paul1996-06-011-2/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that we preserve RPC handles instead of rebuilding them each time a ypcln function is called, we have to be careful about keeping our sockets in a sane state. It's possible that the caller may call a ypclnt function, and then decide to close all its file descriptors. This would also close the socket descriptor held by the yplib code. Worse, it could re-open the same descriptor number for its own use. If it then calls another ypclnt function, the subsequent RPC will fail because the socket will either be gone or replaced with Something Completely Different. The yplib code will recover by rebinding, but it doing so it may wreck the descriptor which now belongs to the caller. To fix this, _yp_dobind() needs to label the descriptor somehow so that it can test it later to make sure it hasn't been altered between ypclnt calls. It does this by binding the socket, thus associating a port number with it. It then saves this port number in the dom_local_port member of the dom_binding structure for the given domain. When _yp_dobind() is called again (which it is at the start of each ypclnt function), it checks to see if the domain is already bound, and if it is, it does a getsockname() on the socket and compares the port number to the one it saved. If the getsockname() fails, or the port number doesn't match, it abandons the socket and sets up a new client handle. This still incurs some syscall overhead, which is what I was trying to avoid, but it's still not as bad as before. Notes: svn path=/head/; revision=16051
* Improve NIS performace of getservbyname() and getservbyport(). Both theseBill Paul1996-06-013-7/+123
| | | | | | | | | | | | | | | | | | | | | | | | | functions are implimented as wrappers around getservent(), which means it's up to getservent() to do all the work. The NIS support in getservent() only allows it to scan through the services.byname map one entry at a time until it finds the requested service name/port. This can be painfully slow due to the overhead involved (lots and lots of successive RPCs). To fix this, we allow getservbyname() and getservbyport() to signal getservent() that if NIS is turned on (there's a '+' in /etc/services), the usual yp_first()/yp_next() linear search should be abandoned and yp_match() used instead. This causes getservent() to immediately locate the requested entry instead of wasting time groping through the whole map. The downside is that this trick is accomplished by exporting a couple of pointers from getservent.c which getservbyname.c and getservbyport.c can preset in order to tell getservent() what to do. If all three functions were in the same source module, then the extra cruft could be delcared static to avoid poluting the global symbol space. Maybe they should be combined anyway. For now I've settled on prepending lots of underscores. Notes: svn path=/head/; revision=16050
* Use the setsockopt for IP_PORTRANGE to cause rresvport() to allocate aPeter Wemm1996-05-311-12/+24
| | | | | | | | | | | | privileged port within a single bind(), rather than looping through attempts to bind over and over again over progressively lower ports. This should speed up rlogin/rsh etc, and will probably cure some of the strange rlogin hangs that have been reported in the past where rresvport() managed to bind() to a port address that it shouldn't have. Notes: svn path=/head/; revision=16034
* Fix bogus MLINKS line from vasprintf change.Jordan K. Hubbard1996-05-291-2/+2
| | | | Notes: svn path=/head/; revision=15976
* add manpage linksWolfram Schneider1996-05-291-1/+2
| | | | | | | | asprintf.3 -> printf.3 vasprintf -> printf.3 Notes: svn path=/head/; revision=15970
* add manpage links:Wolfram Schneider1996-05-291-3/+6
| | | | | | | | | | | des_setkey.3 -> crypt.3 des_cipher.3 -> crypt.3 err_set_exit.3 -> err.3 err_set_file.3 -> err.3 strunvis.3 -> unvis.3 Notes: svn path=/head/; revision=15968
* Use ld -O insted of ld -o + mv.Poul-Henning Kamp1996-05-281-9/+5
| | | | Notes: svn path=/head/; revision=15960
* Add an implementation of the gnu-ish asprintf() and vasprintf(). They arePeter Wemm1996-05-274-38/+219
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | not based on gpl'ed code, just prototype and usage. I'm not 100% certain they behave the same while the system is in trouble (eg: malloc() failing) but in those circumstances all bets would be off anyway. These routines work like sprintf() and vsprintf(), except that instead of using a fixed buffer, they allocate memory and return it to the user and it's the user's responsibility to free() it. They have allocate as much memory as they need (and can get), so the size of strings it can deal with is limited only by the amount of memory it can malloc() on your behalf. There are a few gpl'ed programs starting to use this interface, and it's becoming more common with the scares about security risks with sprintf(). I dont like the look of the code that the various programs (including cvs, gdb, libg++, etc) provide if configure can't find it on the system. It should be possible to modify the stdio core code to provide this interface more efficiently, I was more worried about having something that worked and was secure. :-) (I noticed that there was once intended to be a smprintf() routine when our stdio was written for 4.4BSD, but it looks pretty stillborn, and it's intended interface is not clear). Since Linux and gnu libc have this interface, it seemed silly to bring yet another one onto the scene. Notes: svn path=/head/; revision=15931
* Removed false copyrights...Marc G. Fournier1996-05-276-173/+1
| | | | Notes: svn path=/head/; revision=15927
* Added in appropriate Berkeley copyright and RCS Id: stringMarc G. Fournier1996-05-276-1/+182
| | | | | | | Closes PR#doc/536 Notes: svn path=/head/; revision=15923
* Document that the superuser cannot override link() and unlink() onPeter Wemm1996-05-242-5/+17
| | | | | | | directories, and mention that it was historical practice. Notes: svn path=/head/; revision=15898
* Fixed various problems: typos, grammer, missing include filesMike Pritchard1996-05-2319-29/+36
| | | | | | | | wrong function type declarations, and wrong argument type declarations. Notes: svn path=/head/; revision=15874
* - Fix _listmatch() to close PR #1207.Bill Paul1996-05-211-8/+8
| | | | | | | | | | Fix submitted by: Alan Cox <alc@cs.rice.edu> - Nuke yet another free(result) that isn't needed. (This one I found without phkmalloc's help. :) Notes: svn path=/head/; revision=15839
* Fix for vfsload(3):Garrett Wollman1996-05-171-7/+7
| | | | | | | | | - Don't allow non-root users to specify LKMDIR. - Don't allow any users to specify TMPDIR. - Call /sbin/modload using execl() rather than execlp(). Notes: svn path=/head/; revision=15804
* - Patch around amd core dump problem: don't allow yp_unbind() or _yp_unbind()Bill Paul1996-05-161-29/+36
| | | | | | | | | | | | | to call clnt_destroy() on a potentially NULL RPC handle. Somebody should bang on this a bit to make sure the problem is really gone; I seem to have difficulty reproducing it. Patch provided by Peter Wemm and slightly tweaked by me. - Don't call _yp_unbind() in individual ypclnt functions unless we encounter an RPC error while making a clnt_call(). Notes: svn path=/head/; revision=15793
* Fix a bug caused by the collision of a local assembler label with anotherJohn Polstra1996-05-112-16/+16
| | | | | | | | use of the same label in a recently-introduced PIC_PROLOGUE. This should solve the recent core dumps from pdksh. Notes: svn path=/head/; revision=15731
* Fix a bogon in the pic + threadsafe version of cerror, it was missingPeter Wemm1996-05-102-6/+10
| | | | | | | | | a PIC_EPILOGUE (leaving an extra long on the stack). Submitted by: John Polstra <jdp@polstra.com> Notes: svn path=/head/; revision=15719
* Clarify the description of the FNM_PERIOD flag.John Polstra1996-05-101-1/+6
| | | | Notes: svn path=/head/; revision=15706
* Make rules reentrant.Poul-Henning Kamp1996-05-091-9/+9
| | | | Notes: svn path=/head/; revision=15696
* ``mv'' -> ``mv -f''Wolfram Schneider1996-05-072-14/+16
| | | | | | | | ``rm'' -> ``rm -f'' so mv/rm may not ask for confirmation if you are not root Notes: svn path=/head/; revision=15679
* Grrrr... yet another variation on Murphy's Law: the best way to findBill Paul1996-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 Notes: svn path=/head/; revision=15668
* Add support to enable libc to be compiled in ELF format. (#ifdef __ELF__)Peter Wemm1996-05-0533-281/+340
| | | | | | | | | | | | | | In a nutshell, this macroizes the local/global symbol scoping rules that are different in a.out and ELF. It also makes the i386 assembler stubs conform to i386 PIC calling conventions - the a.out ld.so didn't object, but the ELF one needs it as it implements PIC jumps via PLT's as well as calls. The a.out rtld only worked because it was accidently snooping the grandparent calling function's return address off the stack.. This also affects the libc_r code a little, because of cpp macro nesting. Notes: svn path=/head/; revision=15634
* NIS client-side performance tweak:Bill Paul1996-05-021-79/+108
| | | | | | | | | | | | | | | | | | | | | Each of the ypclnt functions does a _yp_dobind() when it starts and then a _yp_unbind() when it finishes. This is not strictly necessary and it wastes cycles: it means we do a new clnt_create() and clnt_destroy() for each yp_whatever() call. In fact, you can do multiple clnt_call()s using a single RPC client handle returned by clnt_create(). Ideally we only have to create a handle to ypserv once (the first time we call a ypclnt function) and then destroy it and rebind only if a call to ypserv fails. - Modify _yp_dobind() so that it only creates a new RPC client handle when establishing a new binding or when one of the ypclnt calls invalidates an existing binding and calls _yp_dobind() to establish a new one. - Modify the various ypclnt functions to only call _yp_unbind() if a call to ypserv fails. Notes: svn path=/head/; revision=15547
* Use PAGE_SIZE instead of NBPGPoul-Henning Kamp1996-05-021-2/+2
| | | | Notes: svn path=/head/; revision=15529
* Cache the result of getpagesize() so we only make one syscall.Poul-Henning Kamp1996-05-022-16/+19
| | | | | | | Use getpagesize instead of CLBYTES. Notes: svn path=/head/; revision=15528
* Convert the time2posix man page to mdoc format. This stillMike Pritchard1996-05-011-49/+45
| | | | | | | needs some other cleanup, but it is good enough for now. Notes: svn path=/head/; revision=15522
* Fix a typo.Mike Pritchard1996-05-011-1/+1
| | | | Notes: svn path=/head/; revision=15521
* Remove a redundant description of the EMFILE error, and fix a typo.Mike Pritchard1996-05-011-7/+1
| | | | | | | Submitted by: James Raynard <jraynard@dial.pipex.com> Notes: svn path=/head/; revision=15518
* Fixed incomplete or wrong lists of prerequisite #includes related toBruce Evans1996-05-012-2/+4
| | | | | | | <sys/types.h>. Notes: svn path=/head/; revision=15489
* Fixed incomplete or wrong lists of prerequisite #includes related toBruce Evans1996-05-012-2/+4
| | | | | | | <sys/types.h>. Notes: svn path=/head/; revision=15488
* Fixed a wrong prerequisite #include and a missing function-arg type.Bruce Evans1996-05-011-3/+3
| | | | Notes: svn path=/head/; revision=15487
* Fixed misformatted #include (.Ft -> .Fd).Bruce Evans1996-05-011-1/+1
| | | | Notes: svn path=/head/; revision=15486
* Fixed longstanding namespace convolution involving rune_t vs wchar_t.Bruce Evans1996-05-013-9/+5
| | | | | | | | | | | | | | If _ANSI_SOURCE or _POSIX_SOURCE is defined, then <ctype.h> had to be included before <stddef.h> or <stdlib.h> to get rune_t declared. Now rune_t is declared perfectly bogusly in all cases when <ctype.h> is included. This change breaks similar (but more convoluted) convolutions in the stddef.h in gcc distributions. Ports of gcc should avoid using the gcc headers. Notes: svn path=/head/; revision=15483
* Very minor tweak:Bill Paul1996-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 Notes: svn path=/head/; revision=15446
* Removed bogus includes of <sys/types.h> from synopses.Bruce Evans1996-04-195-6/+1
| | | | | | | | | This commit covers the man pages for most of the ANSI library functions. A few others such as strtol.3 have to mention <sys/types.h> because they mix ANSI interfaces with less well designed extensions. Notes: svn path=/head/; revision=15313
* Don't include <sys/types.h> when it isn't used.Bruce Evans1996-04-194-7/+2
| | | | | | | | This commit covers most of the ANSI library functions. Many others only need <sys/types.h> because they use u_xxx. Notes: svn path=/head/; revision=15312
* Added `const' to types of sys_siglist and sys_signame.Bruce Evans1996-04-191-2/+2
| | | | Notes: svn path=/head/; revision=15308
* Added `const' to types of sys_errlist and sys_nerr.Bruce Evans1996-04-191-5/+10
| | | | | | | | | | Use .Va instead of .Fa to describe these variables. Say a little about inconsistent declarations of sys_errlist in the BUGS section. Notes: svn path=/head/; revision=15307
* Fix the man page to reflect the recent addition of RFNOWAIT and the removal ofSujal Patel1996-04-181-4/+5
| | | | | | | Plan9 specific flags. Notes: svn path=/head/; revision=15303
* Fix error in wcstombs: byte count not countedAndrey A. Chernov1996-04-181-3/+4
| | | | | | | | Remove unneded casts in sgetrune/sputrune Submitted by: wcstombs fix by Mihoko Tanaka <m_tonaka@pa.yokogawa.co.jp> Notes: svn path=/head/; revision=15286
* Document the possible EPERM return.Joerg Wunsch1996-04-171-0/+2
| | | | | | | Submitted by: imp@village.org (Warner Losh) Notes: svn path=/head/; revision=15278
* NIS cleanups and fixes, the next generation.Bill Paul1996-04-162-260/+260
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=15267
* Fix a few NIS-related bogons:Bill Paul1996-04-151-11/+14
| | | | | | | | | | | | | | | - Clear the _yp_innetgr flag immediately after calling setnetgrent() from innetgr(). We only need the flag set to temporarily alter setnetgrent()'s behavior. Previously, it was being cleared too late. - When in NIS-only mode, innetgr() was wasting time doing unecessary extra processing after it had already found a match. - Remember to free memory allocated by the NIS functions during innetgr() searches. Notes: svn path=/head/; revision=15264
* Update the description of strncat to accurately describe how manyMike Pritchard1996-04-091-1/+4
| | | | | | | | | bytes are copied to the destination string. Closes PR#1000. Submitted by: Dave Glowacki <dglo@ssec.wisc.edu> Notes: svn path=/head/; revision=15165
* Correct a minor typo. Fixes part of PR#1000.Mike Pritchard1996-04-091-1/+1
| | | | | | | Submitted by: Dave Glowacki <dglo@ssec.wisc.edu> Notes: svn path=/head/; revision=15164
* Do not install the now unsupported netns and netisoMike Pritchard1996-04-082-4/+7
| | | | | | | | related man pages. Comment out cross references to those man pages from other man pages. Notes: svn path=/head/; revision=15136
* Correct some man page xrefs, and some other minor changes to bring someMike Pritchard1996-04-083-5/+5
| | | | | | | | | man pages up to mdoc guidelines and fix some minor formatting glitches. Also fixed a number of man pages to not abuse the .Xr macro to display functions and path names and a lot of other junk. Notes: svn path=/head/; revision=15135
* Correct some man page cross references and file location references.Mike Pritchard1996-04-072-3/+3
| | | | Notes: svn path=/head/; revision=15082
* Mention other possible errors that could be caused by the F_[GS]ETOWNJoerg Wunsch1996-04-061-1/+19
| | | | | | | commands. Notes: svn path=/head/; revision=15074
* Xref clocks(7).Joerg Wunsch1996-04-057-6/+13
| | | | Notes: svn path=/head/; revision=15049