History log of /freebsd-current/lib/libc/net/gethostbynis.c
Revision Date Author Comments
# 559a218c 01-Nov-2023 Warner Losh <imp@FreeBSD.org>

libc: Purge unneeded cdefs.h

These sys/cdefs.h are not needed. Purge them. They are mostly left-over
from the $FreeBSD$ removal. A few in libc are still required for macros
that cdefs.h defines. Keep those.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D42385


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 6b462d27 12-Aug-2019 Konstantin Belousov <kib@FreeBSD.org>

Increase YPMAXRECORD to 16M to be compatible with Linux.

Since YP protocol definition uses the constant to declare
variable-size opaque byte strings, the change should be binary
compatible with existing installations which do not expose keys or
values larger than 1024 bytes.

All uses of local variables with YPMAXRECORD sizes were removed to
avoid insane stack use. On the other hand, variables with static
lifetime should be fine and only result in increased VA use.

Glibc made same change, increasing the allowed length for keys and
values in YP to 16M, in 2013.

Reviewed by: markj
Discussed with: ian
Sponsored by: Mellanox Technologies
MFC after: 3 weeks
Differential revision: https://reviews.freebsd.org/D20900


# d915a14e 25-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

libc: further adoption of SPDX licensing ID tags.

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.


# 831f2b39 25-Dec-2015 Hajimu UMEMOTO <ume@FreeBSD.org>

Remove _gethostbynisname() and _gethostbynisaddr(). These functions
used to be called from getipnodebyname().

MFC after: 1 week


# b3608ae1 03-Jan-2012 Ed Schouten <ed@FreeBSD.org>

Replace index() and rindex() calls with strchr() and strrchr().

The index() and rindex() functions were marked LEGACY in the 2001
revision of POSIX and were subsequently removed from the 2008 revision.
The strchr() and strrchr() functions are part of the C standard.

This makes the source code a lot more consistent, as most of these C
files also call into other str*() routines. In fact, about a dozen
already perform strchr() calls.


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 225edeac 13-Aug-2010 Hajimu UMEMOTO <ume@FreeBSD.org>

- When there is no room for returning the result, nss backend
have to return ERANGE and terminate with NS_RETURN.
- When gethostbyname_r(3) and the friends end with an error,
set errno to the value nss backend returns, and return errno
value.

PR: kern/131623
MFC after: 2 weeks


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 3da59cd0 12-May-2006 Hajimu UMEMOTO <ume@FreeBSD.org>

Fix gethostbyaddr() prototype to conform to IEEE Std 1003.1:

http://www.opengroup.org/onlinepubs/009695399/functions/gethostbyaddr.html

gethostbyaddr_r() is changed as well.
It breaks ABI backward compatibility on 64 bit arch. So, we fix it
on 32 bit arch only for now.

Reported by: Rostislav Krasny <rosti.bsd@gmail.com>


# d3ac2b30 15-Apr-2006 Hajimu UMEMOTO <ume@FreeBSD.org>

- make reentrant version of netdb functions glibc style API, and
expose them to outside of libc.
- make netdb functions NSS friendly.

Reviewed by: arch@ and current@ (no objection)


# 5342d17f 21-Mar-2006 Hajimu UMEMOTO <ume@FreeBSD.org>

Update the resolver in libc to BIND9's one.

Since, res_sendsigned(3) and the friends use MD5 functions, it is
hard to include them without having MD5 functions in libc. So,
res_sendsigned(3) is not merged into libc.

Since, res_update(3) in BIND9 is not binary compatible with our
res_update(3), res_update(3) is leaved as is, except some
necessary modifications.
The res_update(3) and the friends are not essential part of the
resolver. They are not defined in resolv.h but defined in
res_update.h separately in BIND9. Further, they are not called from
our tree. So, I hide them from our resolv.h, but leave them only
for binary backward compatibility (perhaps, no one calls them).

Since, struct __res_state_ext is not exposed in BIND9, I hide it
from our resolv.h. And, global variable _res_ext is removed. It
breaks binary backward compatibility. But, since it is not used from
outside of our libc, I think it is safe.

Reviewed by: arch@ (no objection)


# 8592d23a 01-May-2005 Hajimu UMEMOTO <ume@FreeBSD.org>

don't see RES_USE_INET6 when called from getipnodeby*().


# e84892eb 30-Apr-2005 Hajimu UMEMOTO <ume@FreeBSD.org>

oops, gethostbyaddr(3) must return h_addr as an IPv4-mapped
IPv6 address when RES_USE_INET6 was set, according to RFC 2133
section 6.2.


# 6964622d 30-Apr-2005 Hajimu UMEMOTO <ume@FreeBSD.org>

handling RES_USE_INET6 better.


# e692b618 30-Apr-2005 Hajimu UMEMOTO <ume@FreeBSD.org>

_gethostbynisname() didn't support RES_USE_INET6.


# 86726f32 29-Apr-2005 Hajimu UMEMOTO <ume@FreeBSD.org>

NETDB_INTERNAL is not fit, here. return NO_RECOVERY for h_errno.


# 0d389e72 28-Apr-2005 Hajimu UMEMOTO <ume@FreeBSD.org>

we cannot use inet_ntoa(3), here. so, use inet_ntop(3), instead.


# aa2f4ec7 28-Apr-2005 Hajimu UMEMOTO <ume@FreeBSD.org>

make gethostby*() thread-safe.


# 72572cc6 26-Apr-2005 Hajimu UMEMOTO <ume@FreeBSD.org>

add IPv6 awareness for NIS query of gethostby*().

Inspired by: NetBSD


# 33dee819 25-Feb-2004 Brian Feldman <green@FreeBSD.org>

Make the resolver(3) and many associated interfaces much more reentrant.
The getaddrinfo(3), getipnodebyname(3) and resolver(3) can coincide now
with what should be totally reentrant, and h_errno values will now
be preserved correctly, but this does not affect interfaces such as
gethostbyname(3) which are still mostly non-reentrant.

In all of these relevant functions, the thread-safety has been pushed
down as far as it seems possible right now. This means that operations
that are selected via nsdispatch(3) (i.e. files, yp, dns) are protected
still under global locks that getaddrinfo(3) defines, but where possible
the locking is greatly reduced. The most noticeable improvement is
that multiple DNS lookups can now be run at the same time, and this
shows major improvement in performance of DNS-lookup threaded programs,
and solves the "Mozilla tab serialization" problem.

No single-threaded applications need to be recompiled. Multi-threaded
applications that reference "_res" to change resolver(3) options will
need to be recompiled, and ones which reference "h_errno" will also
if they desire the correct h_errno values. If the applications already
understood that _res and h_errno were not thread-safe and had their own
locking, they will see no performance improvement but will not
actually break in any way.

Please note that when NSS modules are used, or when nsdispatch(3)
defaults to adding any lookups of its own to the individual libc
_nsdispatch() calls, those MUST be reentrant as well.


# a6497df5 05-Jan-2003 Bill Fenner <fenner@FreeBSD.org>

Use in_addr_t for the right size of an IPv4 address, and copy into
an unaligned destination using bcopy instead of an assignment.

Submitted by: Hartmut Brandt <brandt@fokus.gmd.de>
PR: sparc64/46729


# 333fc21e 22-Mar-2002 David E. O'Brien <obrien@FreeBSD.org>

Fix the style of the SCM ID's.
I believe have made all of libc .c's as consistent as possible.


# 8fb3f3f6 21-Mar-2002 David E. O'Brien <obrien@FreeBSD.org>

Remove 'register' keyword.


# 8af1452c 13-Aug-2001 Ruslan Ermilov <ru@FreeBSD.org>

Removed duplicate VCS ID tags, as per style(9).


# 6737f02e 10-Sep-2000 Jacques Vidrine <nectar@FreeBSD.org>

Set h_errno when an error is encountered.

PR: bin/21092
Submitted by: Alexander Kabaev <ak03@gte.com>


# 248aee62 06-Sep-2000 Jacques Vidrine <nectar@FreeBSD.org>

Add nsswitch support. By creating an /etc/nsswitch.conf file, you can
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


# 7f3dea24 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# f0f3d5af 24-Jan-1999 Andrew Gallatin <gallatin@FreeBSD.org>

gethostbyname2() was broken for lookups via NIS on FreeBSD/alpha
due to _gethostbynis() setting h.h_length to sizeof(u_long), which
works out to 8 on alphas. And 8!= NS_INADDRSZ.


# 7e546392 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Revert $FreeBSD$ to $Id$


# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

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.


# 3951b8e3 27-Dec-1996 Bill Paul <wpaul@FreeBSD.org>

Small yet significant tweaks/cleanups:

- getservent:
o put _yp_check() proto under #ifdef YP where it belongs
o local YP buffers should be YPMAXRECORD + 2 bytes long and should
be NUL terminated after copying

- gethostbynis:
o local YP buffer should be YPMAXRECORD + 2 bytes long

- getnetbynis:
o local YP buffer should be YPMAXRECORD + 2 bytes long and should
be NUL terminated after copying

- ether_addr:
o local YP buffers should be YPMAXRECORD + 2 bytes long and should
be NUL terminated after copying (in this case it's BUFSIZ + 2 bytes,
but it happens that BUFSIZ == YPMAXRECORD.

- gethostbydns:
o nuke stray 'return(NULL)' in __dns_getanswer() (harmless but looks silly)

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.


# f360d1ef 24-Dec-1996 Bill Paul <wpaul@FreeBSD.org>

Another one-liner: remember to NUL terminate local copy of NIS host
lookup results. Without this, doing multiple host/addr lookups in a
single process yeilds strange results (the buffer is static, and
garbage may be left behind from previous lookups).

I just noticed this in 2.2-BETA. Unless somebody threatens to chop my
hands off with an axe, I'm going to move this to the 2.2-RELENG branch
shortly.


# 5ce1c533 29-Aug-1996 Peter Wemm <peter@FreeBSD.org>

Merge in bind-4.9.4-P1 resolver...


# 51295a4d 12-Jul-1996 Jordan K. Hubbard <jkh@FreeBSD.org>

General -Wall warning cleanup, part I.
Submitted-By: Kent Vander Velden <graphix@iastate.edu>


# 6daf1720 16-Mar-1996 Bill Paul <wpaul@FreeBSD.org>

gethostbynis.c:

- Fix problem described in PR #1079: _gethostbynisaddr() doesn't
work. Make it accept the same arguments as all the other
gethostby*addr() functions and properly convert the supplied IP
address into a text string so that yp_match() can find it in the
hosts.byaddr map.

- Also fix potential memory leak: copy the results of yp_match() to
a static buffer and free the result (yp_match() returns dynamically
allocated memory).

ether_addr.c:

- Since I was in the neighborhood, fix ether_ntohost() and
ether_hostton() so that they don't bogusly for a free(result)
when yp_match() fails.


# 1363f04c 24-Sep-1994 Paul Traina <pst@FreeBSD.org>

get* rework and new bind code