summaryrefslogtreecommitdiff
path: root/lib/libc/net/nsdispatch.c
Commit message (Collapse)AuthorAgeFilesLines
* Don't call stat(2) on nsswitch.conf(5) every time nsdispatch(3)Edward Tomasz Napierala2018-11-101-0/+11
| | | | | | | | | | | | | | | | | | | and dependent functions (eg getpwname(3)) get called. This can improve performance of binaries that perform a lot of name lookups, such as gssd(8). It also matches documented behaviour of Linux and Solaris. The old code is left in place, should anyone need it, guarded by #ifdef NS_REREAD_CONF. Reviewed by: imp, bcr MFC after: 2 weeks Relnotes: yes Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D17934 Notes: svn path=/head/; revision=340339
* Don't call dlopen(3) for built-in NSS types - "cache", "compat",Edward Tomasz Napierala2018-10-151-2/+12
| | | | | | | | | | | | | | "dns", "files", "db", and "nis". It saves some path lookups during binary startup. Reviewed by: markj Approved by: re (gjb, kib) MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D17557 Notes: svn path=/head/; revision=339363
* libc: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-251-0/+2
| | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=326193
* Don't dlclose NSS modules from nss_atexit().Mark Johnston2017-07-111-6/+3
| | | | | | | | | | | | | As hinted in the commit log message for r259042, this is unnecessary. Moreover, as a result of that change we may invoke a DSO's atexit handler after it has been unmapped. Reviewed by: bdrewery, cem MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=320895
* libc: provide some bounds-checking through reallocarray(3).Pedro F. Giffuni2017-03-121-1/+1
| | | | | | | | | | | | reallocarray(3) is a non portable extension that originated in OpenBSD. Given that it is already in FreeBSD's libc it is useful for the cases where reallocation involves a multiplication. MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D9955 Notes: svn path=/head/; revision=315162
* Fix indentation in nss_configure().Mark Johnston2017-02-141-13/+13
| | | | | | | | MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=313749
* Register nss_atexit() before parsing nsswitch.conf for the first time.Mark Johnston2017-02-141-2/+2
| | | | | | | | | | | | | NSS modules are loaded when nsswitch.conf is parsed and may register their own atexit handlers with libc. nss_atexit() unloads any dynamically loaded NSS modules, so it should run only after the modules' atexit handlers have been invoked. MFC after: 2 weeks Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=313748
* The fallback flag in nsdispatch prevents the fallback implementation ofDag-Erling Smørgrav2014-11-251-9/+16
| | | | | | | | | | | | | | | | | getgroupmembership() from invoking the correct backend in the compat case. Replace it with a nesting depth counter so it only blocks one level (the first is the group -> group_compat translation, the second is the actual backend). This is one of two bugs that break getgrouplist() in the compat case, the second being that the backend's own getgroupmembership() method is ignored. Unfortunately, that is not easily fixable without a redesign of our nss implementation (which is also needed to implement the +@group syntax in /etc/passwd). PR: 190055 MFC after: 1 week Notes: svn path=/head/; revision=275020
* Eliminate conf_lock and instead rely on the NSS write lock to protectMark Johnston2014-10-241-8/+5
| | | | | | | | | | | | | | | | | | NSS configuration state. As a side effect, this fixes a race condition which can occur if multiple threads call nsdispatch(3) concurrently before nsswitch.conf has been parsed. Previously, the thread holding conf_lock could cause other threads to return from nss_configure() before nsswitch.conf had been parsed, forcing them to fall back to the default sources for their NSS methods. Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D994 MFC after: 1 month Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=273605
* libc: Make various internal file descriptors from fopen() close-on-exec.Jilles Tjoelker2013-08-231-1/+1
| | | | Notes: svn path=/head/; revision=254700
* Remove clause 3 and 4 from TNF licensesEd Maste2013-05-291-7/+0
| | | | | | | | | | Per the NetBSD Foundation statement Third parties are encouraged to change the license on any files which have a 4-clause license contributed to the NetBSD Foundation to a 2-clause license. Notes: svn path=/head/; revision=251091
* Fix a problem whereby a corrupt DNS record can cause named to crash. [11:06]Colin Percival2011-12-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | Add an API for alerting internal libc routines to the presence of "unsafe" paths post-chroot, and use it in ftpd. [11:07] Fix a buffer overflow in telnetd. [11:08] Make pam_ssh ignore unpassphrased keys unless the "nullok" option is specified. [11:09] Add sanity checking of service names in pam_start. [11:10] Approved by: so (cperciva) Approved by: re (bz) Security: FreeBSD-SA-11:06.bind Security: FreeBSD-SA-11:07.chroot Security: FreeBSD-SA-11:08.telnetd Security: FreeBSD-SA-11:09.pam_ssh Security: FreeBSD-SA-11:10.pam Notes: svn path=/head/; revision=228843
* Clear errno for each method dispatch.Hajimu UMEMOTO2010-10-041-0/+2
| | | | | | | | Spotted by: Kostik Belousov <kostikbel__at__gmail.com> MFC after: 2 weeks Notes: svn path=/head/; revision=213403
* Fix an issue when nss fallback routines are used in a multithreaded application.Zachary Loafman2009-05-271-4/+23
| | | | | | | | Reviewed by: bushman Approved by: dfr (mentor) Notes: svn path=/head/; revision=192911
* Include libc_private.h for the declaration of __isthreaded instead ofJohn Baldwin2008-05-021-0/+1
| | | | | | | | | relying on namespace pollution in stdio.h. MFC after: 3 days Notes: svn path=/head/; revision=178720
* Moved logging out of the nss_method_lookup() in order not toMichael Bushkov2007-12-171-9/+13
| | | | | | | flood logs with failed fallback method lookup attempts. Notes: svn path=/head/; revision=174716
* Implementing 'fallback' nsswitch source. 'fallback' source is usedMichael Bushkov2007-12-121-3/+26
| | | | | | | | | | | | | | | when particular function can't be found in nsswitch-module. For example, getgrouplist(3) will use module-supplied 'getgroupmembership' function (which can work in an optimal way for such source as LDAP) and will fall back to the stanard iterate-through-all-groups implementation otherwise. PR: ports/114655 Submitted by: Michael Hanselmann <freebsd AT hansmi DOT ch> Reviewed by: brooks (mentor) Notes: svn path=/head/; revision=174547
* fix memory leak from reading nsswitch.confJonathan Chen2007-05-171-0/+2
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=169644
* - Extend the nsswitch to support Services, Protocols and RpcHajimu UMEMOTO2006-04-281-4/+91
| | | | | | | | | | | databases. - Make nsswitch support caching. Submitted by: Michael Bushkov <bushman__at__rsu.ru> Sponsored by: Google Summer of Code 2005 Notes: svn path=/head/; revision=158115
* The previous commit changed the behavior of nsdispatch() in theJacques Vidrine2004-04-011-3/+1
| | | | | | | | | | | | | | | | | case where an /etc/nsswitch.conf file was present, but could not be opened (e.g. due to permissions). Previously, the open failure condition was suppressed, and the built-in defaults were used. In revision 1.11, however, propagated the open failure causing all nsdispatch() invocations to return NS_UNAVAIL, and thus many APIs including getpwnam and gethostbyname unconditionally failed. This commit restores the previous behavior. Pointy hat: nectar (+1 for obstinance; ache had to use clue bat) Reported by: ache Notes: svn path=/head/; revision=127727
* When a dynamic NSS module is built and linked against a threadJacques Vidrine2004-03-301-20/+39
| | | | | | | | | | | | | | | | library, it may pull in that thread library at run time. If the process started out single-threaded, this could cause attempts to release locks that do not exist. Guard against this possibility by checking __isthreaded before invoking thread primitives. A similar problem remains if the process is linked against one thread library, but the NSS module is linked against another. This can only be avoided by careful design of the NSS module. Submitted by: Sean McNeil <sean@mcneil.com> (mostly; bugs are mine) Notes: svn path=/head/; revision=127625
* Make this compile with -O2. A proper fix would use a struct to representDag-Erling Smørgrav2004-03-151-22/+22
| | | | | | | | vectors, instead of requiring the caller to keep track of element size and count and pass them in by reference. Notes: svn path=/head/; revision=127012
* Whitespace nits.Dag-Erling Smørgrav2004-03-151-4/+4
| | | | Notes: svn path=/head/; revision=127011
* Don't complain about missing NSS methods when built statically. It isJacques Vidrine2003-04-241-1/+3
| | | | | | | | | annoying and not very useful. Sponsored by: DARPA, Network Associates Laboratories Notes: svn path=/head/; revision=113983
* = Implement name service switch modules (NSS modules). NSS modulesJacques Vidrine2003-04-171-115/+469
| | | | | | | | | | | | | | | | | | | | | | | | may be built into libc (`static NSS modules') or dynamically loaded via dlopen (`dynamic NSS modules'). Modules are loaded/initialized at configuration time (i.e. when nsdispatch is called and nsswitch.conf is read or re-read). = Make the nsdispatch(3) core thread-safe. = New status code for nsdispatch(3) `NS_RETURN', currently used to signal ERANGE-type issues. = syslog(3) problems, don't warn/err/abort. = Try harder to avoid namespace pollution. = Implement some shims to assist in porting NSS modules written for the GNU C Library nsswitch interface. Sponsored by: DARPA, Network Associates Laboratories Notes: svn path=/head/; revision=113595
* Eliminate 19 warnings in libc (at level WARNS=2) of theJacques Vidrine2003-02-271-0/+2
| | | | | | | `implicit declaration of function' variety. Notes: svn path=/head/; revision=111618
* Assume __STDC__, remove non-__STDC__ code.Alfred Perlstein2002-05-281-14/+0
| | | | | | | Submitted by: keramida Notes: svn path=/head/; revision=97407
* Fix the style of the SCM ID's.David E. O'Brien2002-03-221-4/+1
| | | | | | | I believe have made all of libc .c's as consistent as possible. Notes: svn path=/head/; revision=92986
* Remove __P() usage.David E. O'Brien2002-03-211-2/+2
| | | | Notes: svn path=/head/; revision=92905
* Fixed namespace pollution related to `err' in libc in the same way as forBruce Evans2001-11-111-2/+2
| | | | | | | | | | | `warn'. Now a whole 2 members of the err() family don't cause pollution. This fixes world breakage in awk for NOSHARED worlds. contrib/awk/msg.c has had its own version of err() for a long time, but this somehow didn't cause problems until the update to awk-3.1.0. Notes: svn path=/head/; revision=86250
* Add nsswitch support. By creating an /etc/nsswitch.conf file, you canJacques Vidrine2000-09-061-0/+270
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 Notes: svn path=/head/; revision=65532