Home | History | Annotate | Download | only in resolv
History log of /src/lib/libc/resolv/res_init.c
RevisionDateAuthorComments
 1.32  30-Sep-2021  christos kqueue(2) file descriptors are not inherited across fork(2). A
process that that calls getaddrinfo(3) will end up cacheing the
kqueue(2) file descriptor in its res_state structure. If that
process fork(2)s and calls getaddrinfo(3) again might end up closing
that cached file descriptor which can end up pointing to a different
file object than the kqueue(2) original one. To fix this, associate
the kqueue(2) file descriptor with the process id that created it,
and don't close(2) it if it is being closed from a different process.
An alternative fix would be to attach the resolver to a fork(2) hook
to cleanup the res_state, but handling it internally in the resolver
is less intrusive. This was discovered by Dima Veselov when using
the FreeRADIUS package.
 1.31  19-Apr-2017  christos branches: 1.31.14;
F_DUPFD* needs an argument (minfd) found by jmcneill
 1.30  24-Feb-2015  christos branches: 1.30.2; 1.30.4;
belated removal of the advertising clause.
 1.29  16-Sep-2014  christos Mark the dup of the resolv fd for close on exec.
 1.28  08-Jan-2014  christos provide a patchable __res_conf_name for testing purposes.
 1.27  09-Dec-2013  wiz Fix typo ("then" instead of "than")
 1.26  09-Sep-2012  christos branches: 1.26.2;
add a check-names option, now that the default is no-check-names
 1.25  20-Mar-2012  matt Use C89 Prototypes.
Remove use of __P
 1.24  13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.23  15-Oct-2011  christos branches: 1.23.2;
close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")
 1.22  24-Oct-2009  christos expose res_check.
 1.21  24-Oct-2009  christos Add a knote to keep track when resolv.conf gets changed and re-initialize.
While here fix a memory leak when calling res_vinit with an already inited
res_state.
 1.20  20-Apr-2009  christos Bring back binary compatibility with the previous version of the resolver.
There was no room to allocate 16 bytes for _rnd in the struct in the _LP64
case, so we dynamically allocate now. Also put the _rnd field last, so that
we are bitwise compatible too. Now of course we've run out of space, so
next time will need to perform more evil tricks to fit.
 1.19  16-Apr-2009  christos we are not guaranteed that the ext pointer is going to be null at this point
so don't attempt to free.
 1.18  12-Apr-2009  christos fix lint issues and actual bugs lint found (missing break statements)
 1.17  12-Apr-2009  christos merge libbind and bump.
 1.16  11-Jan-2009  christos branches: 1.16.2;
merge christos-time_t
 1.15  21-Jun-2008  christos branches: 1.15.4; 1.15.6; 1.15.8; 1.15.12;
- protect DEBUG again because we should be able to set it from the Makefile
- add a missing cast to pacify lint.
 1.14  21-Jun-2008  christos updates from bind-9-5-0
 1.13  30-Mar-2007  ghen branches: 1.13.12;
Resolve conflicts.
 1.12  09-Feb-2007  christos Only try free-ing a version of res if it is not supposed to be pre-inited
like before. Fixes issues with programs passing random uninitialized data
as res_state.
 1.11  28-Jan-2007  christos Don't check for ext being NULL to destroy the res_state. Instead check
the option bits like we did before.
 1.10  27-Jan-2007  christos Fix minor compilation issues.
 1.9  27-Jan-2007  christos merge in resolver portion of bind-9.4.0-rc2
 1.8  19-Mar-2006  christos branches: 1.8.4; 1.8.6;
Coverity CID 618: Comment out dead code.
 1.7  24-Jan-2006  christos don't re-define DEBUG
 1.6  15-Sep-2005  tsarna Rest of fix for PR#31184: getaddrinfo() now honors resolv.conf sortlist
directive for dns answers.

Also, unifdef the RESLVSORT (non-)option sillyness.

Reviewed by christos.
 1.5  21-May-2004  christos disable weak aliases for now; the resolver header file adds __ to all the
names.
 1.4  21-May-2004  christos namespace protection for resolver routines.
 1.3  20-May-2004  christos netbsd rcsid.
 1.2  20-May-2004  christos add casts to silence lint.
 1.1  20-May-2004  christos branches: 1.1.1;
Initial revision
 1.1.1.4  12-Apr-2009  christos libc portion of libbind from external/bsd/libbind
 1.1.1.3  30-Mar-2007  ghen Import bind 9.4.0.
 1.1.1.2  27-Jan-2007  christos import resolver portion of bind-9.4.0-rc2
 1.1.1.1  20-May-2004  christos Import libc portion of the resolver from bind9
 1.8.6.1  03-Jun-2007  wrstuden Catch up with now-somewhat-dated netbsd-4. These changes took longer
than expected for me to actually get around to merging.
 1.8.4.4  09-May-2011  bouyer Pull up following revision(s) (requested by taca in ticket #1429):
lib/libc/resolv/res_init.c: revisions 1.11, 1.12 via patch
Don't check for ext being NULL to destroy the res_state. Instead check
the option bits like we did before.
Only try free-ing a version of res if it is not supposed to be pre-inited
like before. Fixes issues with programs passing random uninitialized data
as res_state.
 1.8.4.3  23-Jan-2011  bouyer Apply patch, requested by spz in ticket 1413:
dist/bind/ patch
include/resolv.h patch
include/arpa/nameser.h: patch
lib/libc/include/isc/assertions.h: patch
lib/libc/include/isc/eventlib.h patch
lib/libc/isc/assertions.c: patch
lib/libc/nameser/ns_parse.c patch
lib/libc/resolv/herror.c: patch
lib/libc/resolv/res_init.c patch
lib/libc/resolv/res_mkquery.c: patch
lib/libc/resolv/res_query.c patch
lib/libc/resolv/res_send.c: patch
usr.sbin/bind/Makefile.inc patch
usr.sbin/bind/include/config.h: patch
usr.sbin/bind/include/dns/code.h: patch
usr.sbin/bind/include/dns/enumclass.h: patch
usr.sbin/bind/include/dns/enumtype.h: patch
usr.sbin/bind/include/dns/rdatastruct.h: patch
usr.sbin/bind/include/isc/platform.h: patch
usr.sbin/bind/include/lwres/netdb.h: patch
usr.sbin/bind/include/lwres/platform.h: patch
usr.sbin/bind/libisc/Makefile: patch
lib/libc/inet/inet_addr.c new file

Update bind to 9.4-ESV-R4, latest version of the 9.4 line.
 1.8.4.2  17-May-2007  jdc branches: 1.8.4.2.2;
Add missing BIND 9.4.x include file and library changes (requested by
tron in ticket #662).
 1.8.4.1  17-May-2007  jdc Update BIND to version 9.4.1 (requested by christos in ticket #602).
Thanks to tron for the patches, upgrade script and testing.
 1.8.4.2.2.1  23-Jan-2011  bouyer Apply patch, requested by spz in ticket 1413:
dist/bind/ patch
include/resolv.h patch
include/arpa/nameser.h: patch
lib/libc/include/isc/assertions.h: patch
lib/libc/include/isc/eventlib.h patch
lib/libc/isc/assertions.c: patch
lib/libc/nameser/ns_parse.c patch
lib/libc/resolv/herror.c: patch
lib/libc/resolv/res_init.c patch
lib/libc/resolv/res_mkquery.c: patch
lib/libc/resolv/res_query.c patch
lib/libc/resolv/res_send.c: patch
usr.sbin/bind/Makefile.inc patch
usr.sbin/bind/include/config.h: patch
usr.sbin/bind/include/dns/code.h: patch
usr.sbin/bind/include/dns/enumclass.h: patch
usr.sbin/bind/include/dns/enumtype.h: patch
usr.sbin/bind/include/dns/rdatastruct.h: patch
usr.sbin/bind/include/isc/platform.h: patch
usr.sbin/bind/include/lwres/netdb.h: patch
usr.sbin/bind/include/lwres/platform.h: patch
usr.sbin/bind/libisc/Makefile: patch
lib/libc/inet/inet_addr.c new file

Update bind to 9.4-ESV-R4, latest version of the 9.4 line.
 1.13.12.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.15.12.1  09-Jan-2011  riz Apply patches (requested by spz in ticket #1517):

Update bind to 9.7.2-P3.
 1.15.8.1  10-Jan-2011  riz Apply patches (requested by spz in ticket #1517):

Update bind to 9.7.2-P3.
 1.15.6.2  08-Nov-2008  christos time_t changes
 1.15.6.1  21-Jun-2008  christos file res_init.c was added on branch christos-time_t on 2008-11-08 21:45:38 +0000
 1.15.4.1  06-Jan-2011  riz Apply patches (requested by spz in ticket #1517):

Update bind to 9.7.2-P3.
 1.16.2.1  13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.23.2.3  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.23.2.2  30-Oct-2012  yamt sync with head
 1.23.2.1  17-Apr-2012  yamt sync with head
 1.26.2.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.30.4.1  21-Apr-2017  bouyer Sync with HEAD
 1.30.2.1  26-Apr-2017  pgoyette Sync with HEAD
 1.31.14.1  05-Oct-2021  martin Pull up following revision(s) (requested by christos in ticket #1356):

lib/libc/resolv/res_init.c: revision 1.32
lib/libc/resolv/res_private.h: revision 1.4

kqueue(2) file descriptors are not inherited across fork(2). A
process that that calls getaddrinfo(3) will end up cacheing the
kqueue(2) file descriptor in its res_state structure. If that
process fork(2)s and calls getaddrinfo(3) again might end up closing
that cached file descriptor which can end up pointing to a different
file object than the kqueue(2) original one. To fix this, associate
the kqueue(2) file descriptor with the process id that created it,
and don't close(2) it if it is being closed from a different process.

An alternative fix would be to attach the resolver to a fork(2) hook
to cleanup the res_state, but handling it internally in the resolver
is less intrusive. This was discovered by Dima Veselov when using
the FreeRADIUS package.

RSS XML Feed