1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +03:00
* elf/Makefile (tests): Add nodlopen.  Add rules to generate nodlopen.
	* include/dlfcn.h: Define __RTLD_DLOPEN.
	* elf/dl-load.c (_dl_map_object_from_fd): If DF_1_NOOPEN is set
	and this is a dlopen() call, do not load the binary.
	* dlfcn/dlopen.c: Add __RTLD_DLOPEN to mode passed down to _dl_open.
	* dlfcn/dlopenold.c: Likewise.
	* configure.in: Add test for -z nodelete option.
	* config.make.in: Define have-z-nodelete with libc_cv_z_nodelete.

2000-07-20  Mark Kettenis  <kettenis@gnu.org>

	Make Hesiod NSS module thread-safe.

	* hesiod/README.hesiod: Update.

	* hesiod/Versions [GLIBC_2.2]: Add _nss_hesiod_getservbyport_r,
	_nss_hesiod_setprotoent, _nss_hesiod_endprotoent,
	_nss_hesiod_getprotobyname_r, and _nss_hesiod_getprotobynumber_r.
	* hesiod/Makefile (libnss_hesiod-routines): Add hesiod-init and
	hesiod-proto.
	* hesiod/nss_hesiod/hesiod-init.c: New file.
	* hesiod/nss_hesiod/hesiod-pwd.c: Rewritten for thread-safeness.
	* hesiod/nss_hesiod/hesiod-grp.c: Likewise.
	* hesiod/nss_hesiod/nss_hesiod.h: New file.
	* hesiod/nss_hesiod/hesiod-service.c
	(_nss_hesiod_getservbyport_r): New function.  Provide support for
	looking up services by port number.
	* hesiod/nss_hesiod/hesiod-proto.c: New file.

	* hesiod/hesiod.c: Update from BIND 8.2.3-T5B.
	* hesiod/hesiod.h: Likewise.
	* hesiod/hesiod_p.h: Likewise.

2000-07-20  Mark Kettenis  <kettenis@gnu.org>

	Fix problems with `struct __res_state' getting too big.
	* resolv/resolv.h (struct __sockaddr_in): New definition.
	(struct __res_state): Use __sockaddr_in instead of sockaddr_in in
	the private parts of the structure to save some space.
	* resolv/res_send.c (res_nsend): Cast &EXT(statp).nsaddrs[ns] to
	(struct sockaddr_in *) in call to sock_eq.
	Use memcpy to copy statp->nsaddr_list[ns] to &EXT(statp).nsaddrs[ns].

2000-07-20  Ulrich Drepper  <drepper@redhat.com>

	* sysdeps/mach/hurd/dl-sysdep.c: Likewise.
This commit is contained in:
Ulrich Drepper
2000-07-21 04:12:25 +00:00
parent 89bc5366ba
commit 2f54c82dac
26 changed files with 954 additions and 710 deletions

View File

@ -1,3 +1,48 @@
2000-07-20 Ulrich Drepper <drepper@redhat.com>
* elf/Makefile (tests): Add nodlopen. Add rules to generate nodlopen.
* include/dlfcn.h: Define __RTLD_DLOPEN.
* elf/dl-load.c (_dl_map_object_from_fd): If DF_1_NOOPEN is set
and this is a dlopen() call, do not load the binary.
* dlfcn/dlopen.c: Add __RTLD_DLOPEN to mode passed down to _dl_open.
* dlfcn/dlopenold.c: Likewise.
* configure.in: Add test for -z nodelete option.
* config.make.in: Define have-z-nodelete with libc_cv_z_nodelete.
2000-07-20 Mark Kettenis <kettenis@gnu.org>
Make Hesiod NSS module thread-safe.
* hesiod/README.hesiod: Update.
* hesiod/Versions [GLIBC_2.2]: Add _nss_hesiod_getservbyport_r,
_nss_hesiod_setprotoent, _nss_hesiod_endprotoent,
_nss_hesiod_getprotobyname_r, and _nss_hesiod_getprotobynumber_r.
* hesiod/Makefile (libnss_hesiod-routines): Add hesiod-init and
hesiod-proto.
* hesiod/nss_hesiod/hesiod-init.c: New file.
* hesiod/nss_hesiod/hesiod-pwd.c: Rewritten for thread-safeness.
* hesiod/nss_hesiod/hesiod-grp.c: Likewise.
* hesiod/nss_hesiod/nss_hesiod.h: New file.
* hesiod/nss_hesiod/hesiod-service.c
(_nss_hesiod_getservbyport_r): New function. Provide support for
looking up services by port number.
* hesiod/nss_hesiod/hesiod-proto.c: New file.
* hesiod/hesiod.c: Update from BIND 8.2.3-T5B.
* hesiod/hesiod.h: Likewise.
* hesiod/hesiod_p.h: Likewise.
2000-07-20 Mark Kettenis <kettenis@gnu.org>
Fix problems with `struct __res_state' getting too big.
* resolv/resolv.h (struct __sockaddr_in): New definition.
(struct __res_state): Use __sockaddr_in instead of sockaddr_in in
the private parts of the structure to save some space.
* resolv/res_send.c (res_nsend): Cast &EXT(statp).nsaddrs[ns] to
(struct sockaddr_in *) in call to sock_eq.
Use memcpy to copy statp->nsaddr_list[ns] to &EXT(statp).nsaddrs[ns].
2000-07-20 Ulrich Drepper <drepper@redhat.com> 2000-07-20 Ulrich Drepper <drepper@redhat.com>
* elf/elf.h: Add various DF_1_*, DTF_1_*, and DF_P1_* entries. * elf/elf.h: Add various DF_1_*, DTF_1_*, and DF_P1_* entries.
@ -15,6 +60,7 @@
* sysdeps/generic/ldsodefs.h: Update prototype. * sysdeps/generic/ldsodefs.h: Update prototype.
* elf/dl-deps.c: Add new parameter to _dl_map_object calls. * elf/dl-deps.c: Add new parameter to _dl_map_object calls.
* elf/rtld.c: Likewise. * elf/rtld.c: Likewise.
* sysdeps/mach/hurd/dl-sysdep.c: Likewise.
* elf/Makefile (tests): Add noload. Add rules to generate noload. * elf/Makefile (tests): Add noload. Add rules to generate noload.
* elf/noload.c: New file. * elf/noload.c: New file.
* include/link.h (struct link_map): Add l_feature_1 and l_flags_1. * include/link.h (struct link_map): Add l_feature_1 and l_flags_1.

View File

@ -37,6 +37,7 @@ sysincludes = @SYSINCLUDES@
elf = @elf@ elf = @elf@
have-protected = @libc_cv_asm_protected_directive@ have-protected = @libc_cv_asm_protected_directive@
have-z-nodelete = @libc_cv_z_nodelete@ have-z-nodelete = @libc_cv_z_nodelete@
have-z-nodlopen = @libc_cv_z_nodlopen@
have-initfini = @libc_cv_have_initfini@ have-initfini = @libc_cv_have_initfini@
need-nopic-initfini = @nopic_initfini@ need-nopic-initfini = @nopic_initfini@
with-cvs = @with_cvs@ with-cvs = @with_cvs@

126
configure vendored
View File

@ -2639,16 +2639,56 @@ fi
echo "$ac_t""$libc_cv_asm_protected_directive" 1>&6 echo "$ac_t""$libc_cv_asm_protected_directive" 1>&6
echo $ac_n "checking for -z nodelete option""... $ac_c" 1>&6
echo "configure:2645: checking for -z nodelete option" >&5
if eval "test \"`echo '$''{'libc_cv_z_nodelete'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.c <<EOF
int _start (void) { return 42; }
EOF
if { ac_try='${CC-cc} -shared -o conftest.so conftest.c -Wl,--enable-new-dtags,-z,nodelete 1>&5'; { (eval echo configure:2652: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }
then
libc_cv_z_nodelete=yes
else
libc_cv_z_nodelete=no
fi
rm -f conftest*
fi
echo "$ac_t""$libc_cv_z_nodelete" 1>&6
echo $ac_n "checking for -z nodlopen option""... $ac_c" 1>&6
echo "configure:2665: checking for -z nodlopen option" >&5
if eval "test \"`echo '$''{'libc_cv_z_nodlopen'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.c <<EOF
int _start (void) { return 42; }
EOF
if { ac_try='${CC-cc} -shared -o conftest.so conftest.c -Wl,--enable-new-dtags,-z,nodlopen 1>&5'; { (eval echo configure:2672: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }
then
libc_cv_z_nodlopen=yes
else
libc_cv_z_nodlopen=no
fi
rm -f conftest*
fi
echo "$ac_t""$libc_cv_z_nodlopen" 1>&6
fi fi
if test $elf != yes; then if test $elf != yes; then
echo $ac_n "checking for .init and .fini sections""... $ac_c" 1>&6 echo $ac_n "checking for .init and .fini sections""... $ac_c" 1>&6
echo "configure:2647: checking for .init and .fini sections" >&5 echo "configure:2687: checking for .init and .fini sections" >&5
if eval "test \"`echo '$''{'libc_cv_have_initfini'+set}'`\" = set"; then if eval "test \"`echo '$''{'libc_cv_have_initfini'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2652 "configure" #line 2692 "configure"
#include "confdefs.h" #include "confdefs.h"
int main() { int main() {
@ -2657,7 +2697,7 @@ asm (".section .init");
asm ("${libc_cv_dot_text}"); asm ("${libc_cv_dot_text}");
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:2661: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then if { (eval echo configure:2701: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest* rm -rf conftest*
libc_cv_have_initfini=yes libc_cv_have_initfini=yes
else else
@ -2680,7 +2720,7 @@ fi
if test $elf = yes -a $gnu_ld = yes; then if test $elf = yes -a $gnu_ld = yes; then
echo $ac_n "checking whether cc puts quotes around section names""... $ac_c" 1>&6 echo $ac_n "checking whether cc puts quotes around section names""... $ac_c" 1>&6
echo "configure:2684: checking whether cc puts quotes around section names" >&5 echo "configure:2724: checking whether cc puts quotes around section names" >&5
if eval "test \"`echo '$''{'libc_cv_have_section_quotes'+set}'`\" = set"; then if eval "test \"`echo '$''{'libc_cv_have_section_quotes'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -2717,19 +2757,19 @@ if test $elf = yes; then
else else
if test $ac_cv_prog_cc_works = yes; then if test $ac_cv_prog_cc_works = yes; then
echo $ac_n "checking for _ prefix on C symbol names""... $ac_c" 1>&6 echo $ac_n "checking for _ prefix on C symbol names""... $ac_c" 1>&6
echo "configure:2721: checking for _ prefix on C symbol names" >&5 echo "configure:2761: checking for _ prefix on C symbol names" >&5
if eval "test \"`echo '$''{'libc_cv_asm_underscores'+set}'`\" = set"; then if eval "test \"`echo '$''{'libc_cv_asm_underscores'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2726 "configure" #line 2766 "configure"
#include "confdefs.h" #include "confdefs.h"
asm ("_glibc_foobar:"); asm ("_glibc_foobar:");
int main() { int main() {
glibc_foobar (); glibc_foobar ();
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:2733: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then if { (eval echo configure:2773: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest* rm -rf conftest*
libc_cv_asm_underscores=yes libc_cv_asm_underscores=yes
else else
@ -2744,17 +2784,17 @@ fi
echo "$ac_t""$libc_cv_asm_underscores" 1>&6 echo "$ac_t""$libc_cv_asm_underscores" 1>&6
else else
echo $ac_n "checking for _ prefix on C symbol names""... $ac_c" 1>&6 echo $ac_n "checking for _ prefix on C symbol names""... $ac_c" 1>&6
echo "configure:2748: checking for _ prefix on C symbol names" >&5 echo "configure:2788: checking for _ prefix on C symbol names" >&5
if eval "test \"`echo '$''{'libc_cv_asm_underscores'+set}'`\" = set"; then if eval "test \"`echo '$''{'libc_cv_asm_underscores'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2753 "configure" #line 2793 "configure"
#include "confdefs.h" #include "confdefs.h"
void underscore_test(void) { void underscore_test(void) {
return; } return; }
EOF EOF
if { (eval echo configure:2758: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then if { (eval echo configure:2798: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if grep _underscore_test conftest* >/dev/null; then if grep _underscore_test conftest* >/dev/null; then
rm -f conftest* rm -f conftest*
libc_cv_asm_underscores=yes libc_cv_asm_underscores=yes
@ -2786,7 +2826,7 @@ if test $elf = yes; then
fi fi
echo $ac_n "checking for assembler .weak directive""... $ac_c" 1>&6 echo $ac_n "checking for assembler .weak directive""... $ac_c" 1>&6
echo "configure:2790: checking for assembler .weak directive" >&5 echo "configure:2830: checking for assembler .weak directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_weak_directive'+set}'`\" = set"; then if eval "test \"`echo '$''{'libc_cv_asm_weak_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -2809,7 +2849,7 @@ echo "$ac_t""$libc_cv_asm_weak_directive" 1>&6
if test $libc_cv_asm_weak_directive = no; then if test $libc_cv_asm_weak_directive = no; then
echo $ac_n "checking for assembler .weakext directive""... $ac_c" 1>&6 echo $ac_n "checking for assembler .weakext directive""... $ac_c" 1>&6
echo "configure:2813: checking for assembler .weakext directive" >&5 echo "configure:2853: checking for assembler .weakext directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_weakext_directive'+set}'`\" = set"; then if eval "test \"`echo '$''{'libc_cv_asm_weakext_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -2847,7 +2887,7 @@ EOF
fi fi
echo $ac_n "checking for ld --no-whole-archive""... $ac_c" 1>&6 echo $ac_n "checking for ld --no-whole-archive""... $ac_c" 1>&6
echo "configure:2851: checking for ld --no-whole-archive" >&5 echo "configure:2891: checking for ld --no-whole-archive" >&5
if eval "test \"`echo '$''{'libc_cv_ld_no_whole_archive'+set}'`\" = set"; then if eval "test \"`echo '$''{'libc_cv_ld_no_whole_archive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -2858,7 +2898,7 @@ __throw () {}
EOF EOF
if { ac_try='${CC-cc} $CFLAGS if { ac_try='${CC-cc} $CFLAGS
-nostdlib -nostartfiles -Wl,--no-whole-archive -nostdlib -nostartfiles -Wl,--no-whole-archive
-o conftest conftest.c 1>&5'; { (eval echo configure:2862: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then -o conftest conftest.c 1>&5'; { (eval echo configure:2902: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_ld_no_whole_archive=yes libc_cv_ld_no_whole_archive=yes
else else
libc_cv_ld_no_whole_archive=no libc_cv_ld_no_whole_archive=no
@ -2872,7 +2912,7 @@ if test $libc_cv_ld_no_whole_archive = yes; then
fi fi
echo $ac_n "checking for gcc -fexceptions""... $ac_c" 1>&6 echo $ac_n "checking for gcc -fexceptions""... $ac_c" 1>&6
echo "configure:2876: checking for gcc -fexceptions" >&5 echo "configure:2916: checking for gcc -fexceptions" >&5
if eval "test \"`echo '$''{'libc_cv_gcc_exceptions'+set}'`\" = set"; then if eval "test \"`echo '$''{'libc_cv_gcc_exceptions'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -2883,7 +2923,7 @@ __throw () {}
EOF EOF
if { ac_try='${CC-cc} $CFLAGS if { ac_try='${CC-cc} $CFLAGS
-nostdlib -nostartfiles -fexceptions -nostdlib -nostartfiles -fexceptions
-o conftest conftest.c 1>&5'; { (eval echo configure:2887: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then -o conftest conftest.c 1>&5'; { (eval echo configure:2927: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_gcc_exceptions=yes libc_cv_gcc_exceptions=yes
else else
libc_cv_gcc_exceptions=no libc_cv_gcc_exceptions=no
@ -2898,14 +2938,14 @@ fi
if test "$base_machine" = alpha ; then if test "$base_machine" = alpha ; then
echo $ac_n "checking for function ..ng prefix""... $ac_c" 1>&6 echo $ac_n "checking for function ..ng prefix""... $ac_c" 1>&6
echo "configure:2902: checking for function ..ng prefix" >&5 echo "configure:2942: checking for function ..ng prefix" >&5
if eval "test \"`echo '$''{'libc_cv_gcc_alpha_ng_prefix'+set}'`\" = set"; then if eval "test \"`echo '$''{'libc_cv_gcc_alpha_ng_prefix'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.c <<\EOF cat > conftest.c <<\EOF
foo () { } foo () { }
EOF EOF
if { ac_try='${CC-cc} -S conftest.c -o - | fgrep "\$foo..ng" > /dev/null'; { (eval echo configure:2909: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; if { ac_try='${CC-cc} -S conftest.c -o - | fgrep "\$foo..ng" > /dev/null'; { (eval echo configure:2949: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; };
then then
libc_cv_gcc_alpha_ng_prefix=yes libc_cv_gcc_alpha_ng_prefix=yes
else else
@ -2932,19 +2972,19 @@ if test "$host_cpu" = powerpc ; then
# Check for a bug present in at least versions 2.8.x of GCC # Check for a bug present in at least versions 2.8.x of GCC
# and versions 1.0.x of EGCS. # and versions 1.0.x of EGCS.
echo $ac_n "checking whether clobbering cr0 causes problems""... $ac_c" 1>&6 echo $ac_n "checking whether clobbering cr0 causes problems""... $ac_c" 1>&6
echo "configure:2936: checking whether clobbering cr0 causes problems" >&5 echo "configure:2976: checking whether clobbering cr0 causes problems" >&5
if eval "test \"`echo '$''{'libc_cv_c_asmcr0_bug'+set}'`\" = set"; then if eval "test \"`echo '$''{'libc_cv_c_asmcr0_bug'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2941 "configure" #line 2981 "configure"
#include "confdefs.h" #include "confdefs.h"
int tester(int x) { asm ("" : : : "cc"); return x & 123; } int tester(int x) { asm ("" : : : "cc"); return x & 123; }
int main() { int main() {
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:2948: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then if { (eval echo configure:2988: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest* rm -rf conftest*
libc_cv_c_asmcr0_bug='no' libc_cv_c_asmcr0_bug='no'
else else
@ -2966,12 +3006,12 @@ fi
fi fi
echo $ac_n "checking for DWARF2 unwind info support""... $ac_c" 1>&6 echo $ac_n "checking for DWARF2 unwind info support""... $ac_c" 1>&6
echo "configure:2970: checking for DWARF2 unwind info support" >&5 echo "configure:3010: checking for DWARF2 unwind info support" >&5
if eval "test \"`echo '$''{'libc_cv_gcc_dwarf2_unwind_info'+set}'`\" = set"; then if eval "test \"`echo '$''{'libc_cv_gcc_dwarf2_unwind_info'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.c <<EOF cat > conftest.c <<EOF
#line 2975 "configure" #line 3015 "configure"
static char __EH_FRAME_BEGIN__; static char __EH_FRAME_BEGIN__;
_start () _start ()
{ {
@ -2998,7 +3038,7 @@ __bzero () {}
EOF EOF
if { ac_try='${CC-cc} $CFLAGS -DCHECK__register_frame_info if { ac_try='${CC-cc} $CFLAGS -DCHECK__register_frame_info
-nostdlib -nostartfiles -nostdlib -nostartfiles
-o conftest conftest.c -lgcc >&5'; { (eval echo configure:3002: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then -o conftest conftest.c -lgcc >&5'; { (eval echo configure:3042: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_gcc_dwarf2_unwind_info=static libc_cv_gcc_dwarf2_unwind_info=static
else else
libc_cv_gcc_dwarf2_unwind_info=no libc_cv_gcc_dwarf2_unwind_info=no
@ -3006,7 +3046,7 @@ fi
if test $libc_cv_gcc_dwarf2_unwind_info = no; then if test $libc_cv_gcc_dwarf2_unwind_info = no; then
if { ac_try='${CC-cc} $CFLAGS -DCHECK__register_frame if { ac_try='${CC-cc} $CFLAGS -DCHECK__register_frame
-nostdlib -nostartfiles -nostdlib -nostartfiles
-o conftest conftest.c -lgcc >&5'; { (eval echo configure:3010: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then -o conftest conftest.c -lgcc >&5'; { (eval echo configure:3050: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_gcc_dwarf2_unwind_info=yes libc_cv_gcc_dwarf2_unwind_info=yes
else else
libc_cv_gcc_dwarf2_unwind_info=no libc_cv_gcc_dwarf2_unwind_info=no
@ -3036,12 +3076,12 @@ EOF
esac esac
echo $ac_n "checking for __builtin_expect""... $ac_c" 1>&6 echo $ac_n "checking for __builtin_expect""... $ac_c" 1>&6
echo "configure:3040: checking for __builtin_expect" >&5 echo "configure:3080: checking for __builtin_expect" >&5
if eval "test \"`echo '$''{'libc_cv_gcc_builtin_expect'+set}'`\" = set"; then if eval "test \"`echo '$''{'libc_cv_gcc_builtin_expect'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.c <<EOF cat > conftest.c <<EOF
#line 3045 "configure" #line 3085 "configure"
int foo (int a) int foo (int a)
{ {
a = __builtin_expect (a, 10); a = __builtin_expect (a, 10);
@ -3049,7 +3089,7 @@ int foo (int a)
} }
EOF EOF
if { ac_try='${CC-cc} $CFLAGS -nostdlib -nostartfiles if { ac_try='${CC-cc} $CFLAGS -nostdlib -nostartfiles
-o conftest conftest.c -lgcc >&5'; { (eval echo configure:3053: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then -o conftest conftest.c -lgcc >&5'; { (eval echo configure:3093: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_gcc_builtin_expect=yes libc_cv_gcc_builtin_expect=yes
else else
libc_cv_gcc_builtin_expect=no libc_cv_gcc_builtin_expect=no
@ -3066,12 +3106,12 @@ EOF
fi fi
echo $ac_n "checking for local label subtraction""... $ac_c" 1>&6 echo $ac_n "checking for local label subtraction""... $ac_c" 1>&6
echo "configure:3070: checking for local label subtraction" >&5 echo "configure:3110: checking for local label subtraction" >&5
if eval "test \"`echo '$''{'libc_cv_gcc_subtract_local_labels'+set}'`\" = set"; then if eval "test \"`echo '$''{'libc_cv_gcc_subtract_local_labels'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.c <<EOF cat > conftest.c <<EOF
#line 3075 "configure" #line 3115 "configure"
int foo (int a) int foo (int a)
{ {
static const int ar[] = { &&l1 - &&l1, &&l2 - &&l1 }; static const int ar[] = { &&l1 - &&l1, &&l2 - &&l1 };
@ -3084,7 +3124,7 @@ int foo (int a)
} }
EOF EOF
if { ac_try='${CC-cc} $CFLAGS -nostdlib -nostartfiles if { ac_try='${CC-cc} $CFLAGS -nostdlib -nostartfiles
-o conftest conftest.c -lgcc >&5'; { (eval echo configure:3088: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then -o conftest conftest.c -lgcc >&5'; { (eval echo configure:3128: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_gcc_subtract_local_labels=yes libc_cv_gcc_subtract_local_labels=yes
else else
libc_cv_gcc_subtract_local_labels=no libc_cv_gcc_subtract_local_labels=no
@ -3101,7 +3141,7 @@ EOF
fi fi
echo $ac_n "checking for libgd""... $ac_c" 1>&6 echo $ac_n "checking for libgd""... $ac_c" 1>&6
echo "configure:3105: checking for libgd" >&5 echo "configure:3145: checking for libgd" >&5
old_CFLAGS="$CFLAGS" old_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $libgd_include" CFLAGS="$CFLAGS $libgd_include"
old_LDFLAGS="$LDFLAGS" old_LDFLAGS="$LDFLAGS"
@ -3109,14 +3149,14 @@ LDFLAGS="$LDFLAGS $libgd_ldflags"
old_LIBS="$LIBS" old_LIBS="$LIBS"
LIBS="$LIBS -lgd -lpng -lz" LIBS="$LIBS -lgd -lpng -lz"
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 3113 "configure" #line 3153 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <gd.h> #include <gd.h>
int main() { int main() {
gdImagePng (0, 0) gdImagePng (0, 0)
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:3120: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then if { (eval echo configure:3160: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest* rm -rf conftest*
LIBGD=yes LIBGD=yes
else else
@ -3133,7 +3173,7 @@ echo "$ac_t""$LIBGD" 1>&6
echo $ac_n "checking size of long double""... $ac_c" 1>&6 echo $ac_n "checking size of long double""... $ac_c" 1>&6
echo "configure:3137: checking size of long double" >&5 echo "configure:3177: checking size of long double" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_long_double'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_sizeof_long_double'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -3141,7 +3181,7 @@ else
ac_cv_sizeof_long_double=0 ac_cv_sizeof_long_double=0
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 3145 "configure" #line 3185 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <stdio.h> #include <stdio.h>
main() main()
@ -3152,7 +3192,7 @@ main()
exit(0); exit(0);
} }
EOF EOF
if { (eval echo configure:3156: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null if { (eval echo configure:3196: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then then
ac_cv_sizeof_long_double=`cat conftestval` ac_cv_sizeof_long_double=`cat conftestval`
else else
@ -3220,7 +3260,7 @@ if test "$uname" = "sysdeps/generic"; then
fi fi
echo $ac_n "checking OS release for uname""... $ac_c" 1>&6 echo $ac_n "checking OS release for uname""... $ac_c" 1>&6
echo "configure:3224: checking OS release for uname" >&5 echo "configure:3264: checking OS release for uname" >&5
if eval "test \"`echo '$''{'libc_cv_uname_release'+set}'`\" = set"; then if eval "test \"`echo '$''{'libc_cv_uname_release'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -3242,7 +3282,7 @@ echo "$ac_t""$libc_cv_uname_release" 1>&6
uname_release="$libc_cv_uname_release" uname_release="$libc_cv_uname_release"
echo $ac_n "checking OS version for uname""... $ac_c" 1>&6 echo $ac_n "checking OS version for uname""... $ac_c" 1>&6
echo "configure:3246: checking OS version for uname" >&5 echo "configure:3286: checking OS version for uname" >&5
if eval "test \"`echo '$''{'libc_cv_uname_version'+set}'`\" = set"; then if eval "test \"`echo '$''{'libc_cv_uname_version'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -3264,7 +3304,7 @@ else
fi fi
echo $ac_n "checking stdio selection""... $ac_c" 1>&6 echo $ac_n "checking stdio selection""... $ac_c" 1>&6
echo "configure:3268: checking stdio selection" >&5 echo "configure:3308: checking stdio selection" >&5
case $stdio in case $stdio in
libio) cat >> confdefs.h <<\EOF libio) cat >> confdefs.h <<\EOF
@ -3278,7 +3318,7 @@ echo "$ac_t""$stdio" 1>&6
# Test for old glibc 2.0.x headers so that they can be removed properly # Test for old glibc 2.0.x headers so that they can be removed properly
# Search only in includedir. # Search only in includedir.
echo $ac_n "checking for old glibc 2.0.x headers""... $ac_c" 1>&6 echo $ac_n "checking for old glibc 2.0.x headers""... $ac_c" 1>&6
echo "configure:3282: checking for old glibc 2.0.x headers" >&5 echo "configure:3322: checking for old glibc 2.0.x headers" >&5
if eval test -f "${includedir}/elfclass.h" -a -f "${includedir}/fcntlbits.h" if eval test -f "${includedir}/elfclass.h" -a -f "${includedir}/fcntlbits.h"
then then
old_glibc_headers=yes old_glibc_headers=yes
@ -3333,7 +3373,7 @@ if test $shared = default; then
fi fi
echo $ac_n "checking whether -fPIC is default""... $ac_c" 1>&6 echo $ac_n "checking whether -fPIC is default""... $ac_c" 1>&6
echo "configure:3337: checking whether -fPIC is default" >&5 echo "configure:3377: checking whether -fPIC is default" >&5
if eval "test \"`echo '$''{'pic_default'+set}'`\" = set"; then if eval "test \"`echo '$''{'pic_default'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -3557,6 +3597,8 @@ s%@INSTALL_INFO@%$INSTALL_INFO%g
s%@OLD_DEBIAN_INSTALL_INFO@%$OLD_DEBIAN_INSTALL_INFO%g s%@OLD_DEBIAN_INSTALL_INFO@%$OLD_DEBIAN_INSTALL_INFO%g
s%@VERSIONING@%$VERSIONING%g s%@VERSIONING@%$VERSIONING%g
s%@libc_cv_asm_protected_directive@%$libc_cv_asm_protected_directive%g s%@libc_cv_asm_protected_directive@%$libc_cv_asm_protected_directive%g
s%@libc_cv_z_nodelete@%$libc_cv_z_nodelete%g
s%@libc_cv_z_nodlopen@%$libc_cv_z_nodlopen%g
s%@libc_cv_have_initfini@%$libc_cv_have_initfini%g s%@libc_cv_have_initfini@%$libc_cv_have_initfini%g
s%@no_whole_archive@%$no_whole_archive%g s%@no_whole_archive@%$no_whole_archive%g
s%@exceptions@%$exceptions%g s%@exceptions@%$exceptions%g

View File

@ -914,6 +914,20 @@ EOF
fi fi
rm -f conftest*]) rm -f conftest*])
AC_SUBST(libc_cv_z_nodelete) AC_SUBST(libc_cv_z_nodelete)
AC_CACHE_CHECK(for -z nodlopen option,
libc_cv_z_nodlopen, [dnl
cat > conftest.c <<EOF
int _start (void) { return 42; }
EOF
if AC_TRY_COMMAND([${CC-cc} -shared -o conftest.so conftest.c -Wl,--enable-new-dtags,-z,nodlopen 1>&AC_FD_CC])
then
libc_cv_z_nodlopen=yes
else
libc_cv_z_nodlopen=no
fi
rm -f conftest*])
AC_SUBST(libc_cv_z_nodlopen)
fi fi
if test $elf != yes; then if test $elf != yes; then

View File

@ -36,7 +36,8 @@ dlopen_doit (void *a)
{ {
struct dlopen_args *args = (struct dlopen_args *) a; struct dlopen_args *args = (struct dlopen_args *) a;
args->new = _dl_open (args->file ?: "", args->mode, args->caller); args->new = _dl_open (args->file ?: "", args->mode | __RTLD_DLOPEN,
args->caller);
} }

View File

@ -42,7 +42,8 @@ dlopen_doit (void *a)
{ {
struct dlopen_args *args = (struct dlopen_args *) a; struct dlopen_args *args = (struct dlopen_args *) a;
args->new = _dl_open (args->file ?: "", args->mode, args->caller); args->new = _dl_open (args->file ?: "", args->mode | __RTLD_DLOPEN,
args->caller);
} }
void * void *

View File

@ -86,16 +86,20 @@ endif
ifeq (yes,$(build-shared)) ifeq (yes,$(build-shared))
tests = loadtest restest1 preloadtest loadfail multiload origtest resolvfail \ tests = loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
constload1 order $(tests-vis-$(have-protected)) noload \ constload1 order $(tests-vis-$(have-protected)) noload \
$(tests-nodelete-$(have-z-nodelete)) $(tests-nodelete-$(have-z-nodelete)) \
$(tests-nodlopen-$(have-z-nodlopen))
tests-vis-yes = vismain tests-vis-yes = vismain
tests-nodelete-yes = nodelete tests-nodelete-yes = nodelete
tests-nodlopen-yes = nodlopen
endif endif
modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
testobj1_1 failobj constload2 constload3 \ testobj1_1 failobj constload2 constload3 \
dep1 dep2 dep3 dep4 $(modules-vis-$(have-protected)) \ dep1 dep2 dep3 dep4 $(modules-vis-$(have-protected)) \
$(modules-nodelete-$(have-z-nodelete)) $(modules-nodelete-$(have-z-nodelete)) \
$(modules-nodlopen-$(have-z-nodlopen))
modules-vis-yes = vismod1 vismod2 vismod3 modules-vis-yes = vismod1 vismod2 vismod3
modules-nodelete-yes = nodelmod1 nodelmod2 modules-nodelete-yes = nodelmod1 nodelmod2
modules-nodlopen-yes = nodlopenmod
extra-objs += $(addsuffix .os,$(strip $(modules-names))) extra-objs += $(addsuffix .os,$(strip $(modules-names)))
include ../Rules include ../Rules
@ -302,3 +306,7 @@ $(objpfx)noload.out: $(objpfx)testobj5.so
LDFLAGS-nodelmod1.so = -Wl,--enable-new-dtags,-z,nodelete LDFLAGS-nodelmod1.so = -Wl,--enable-new-dtags,-z,nodelete
$(objpfx)nodelete: $(libdl) $(objpfx)nodelete: $(libdl)
$(objpfx)nodelete.out: $(objpfx)nodelmod1.so $(objpfx)nodelmod2.so $(objpfx)nodelete.out: $(objpfx)nodelmod1.so $(objpfx)nodelmod2.so
LDFLAGS-nodlopenmod.so = -Wl,--enable-new-dtags,-z,nodlopen
$(objpfx)nodlopen: $(libdl)
$(objpfx)nodlopen.out: $(objpfx)nodlopenmod.so

View File

@ -688,7 +688,7 @@ static
#endif #endif
struct link_map * struct link_map *
_dl_map_object_from_fd (const char *name, int fd, char *realname, _dl_map_object_from_fd (const char *name, int fd, char *realname,
struct link_map *loader, int l_type, int noload) struct link_map *loader, int l_type, int mode)
{ {
/* This is the expected ELF header. */ /* This is the expected ELF header. */
#define ELF32_CLASS ELFCLASS32 #define ELF32_CLASS ELFCLASS32
@ -752,7 +752,7 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname,
return l; return l;
} }
if (noload) if (mode & RTLD_NOLOAD)
/* We are not supposed to load the object unless it is already /* We are not supposed to load the object unless it is already
loaded. So return now. */ loaded. So return now. */
return NULL; return NULL;
@ -1097,6 +1097,35 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname,
} }
elf_get_dynamic_info (l); elf_get_dynamic_info (l);
/* Make sure we are dlopen()ing an object which has the DF_1_NOOPEN
flag set. */
if (__builtin_expect (l->l_flags_1 & DF_1_NOOPEN, 0)
&& (mode & __RTLD_DLOPEN))
{
/* Remove from the module list. */
assert (l->l_next == NULL);
#ifdef SHARED
if (l->l_prev == NULL)
/* No other module loaded. */
_dl_loaded = NULL;
else
#endif
l->l_prev->l_next = NULL;
/* We are not supposed to load this object. Free all resources. */
__munmap ((void *) l->l_map_start, l->l_map_end - l->l_map_start);
free (l->l_libname);
if (l->l_phdr_allocated)
free ((void *) l->l_phdr);
free (l);
_dl_signal_error (0, name, N_("shared object cannot be dlopen()ed"));
}
if (l->l_info[DT_HASH]) if (l->l_info[DT_HASH])
_dl_setup_hash (l); _dl_setup_hash (l);
@ -1306,7 +1335,7 @@ open_path (const char *name, size_t namelen, int preloaded,
struct link_map * struct link_map *
internal_function internal_function
_dl_map_object (struct link_map *loader, const char *name, int preloaded, _dl_map_object (struct link_map *loader, const char *name, int preloaded,
int type, int trace_mode, int noload) int type, int trace_mode, int mode)
{ {
int fd; int fd;
char *realname; char *realname;
@ -1506,5 +1535,5 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
_dl_signal_error (errno, name, N_("cannot open shared object file")); _dl_signal_error (errno, name, N_("cannot open shared object file"));
} }
return _dl_map_object_from_fd (name, fd, realname, loader, type, noload); return _dl_map_object_from_fd (name, fd, realname, loader, type, mode);
} }

View File

@ -145,7 +145,7 @@ dl_open_worker (void *a)
/* Load the named object. */ /* Load the named object. */
args->map = new = _dl_map_object (NULL, file, 0, lt_loaded, 0, args->map = new = _dl_map_object (NULL, file, 0, lt_loaded, 0,
mode & RTLD_NOLOAD); mode);
/* If the pointer returned is NULL this means the RTLD_NOLOAD flag is /* If the pointer returned is NULL this means the RTLD_NOLOAD flag is
set and the object is not already loaded. */ set and the object is not already loaded. */

View File

@ -1,4 +1,4 @@
# Copyright (C) 1997, 1998 Free Software Foundation, Inc. # Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc.
# This file is part of the GNU C Library. # This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or # The GNU C Library is free software; you can redistribute it and/or
@ -29,14 +29,13 @@ extra-libs-others = $(extra-libs)
subdir-dirs = nss_hesiod subdir-dirs = nss_hesiod
vpath %.c nss_hesiod vpath %.c nss_hesiod
libnss_hesiod-routines := hesiod hesiod-grp hesiod-pwd hesiod-service libnss_hesiod-routines := hesiod hesiod-grp hesiod-init hesiod-proto \
hesiod-pwd hesiod-service
# Build only shared library # Build only shared library
libnss_hesiod-inhibit-o = $(filter-out .os,$(object-suffixes)) libnss_hesiod-inhibit-o = $(filter-out .os,$(object-suffixes))
include ../Rules include ../Rules
CFLAGS-hesiod.c = -DSYSCONFDIR='"$(sysconfdir)"'
# Depend on libc.so so a DT_NEEDED is generated in the shared objects. # Depend on libc.so so a DT_NEEDED is generated in the shared objects.
# This ensures they will load libc.so for needed symbols if loaded by # This ensures they will load libc.so for needed symbols if loaded by
# a statically-linked program that hasn't already loaded it. # a statically-linked program that hasn't already loaded it.

View File

@ -65,18 +65,15 @@ Configuring Hesiod
Next, you will have to configure Hesiod. If you are already running Next, you will have to configure Hesiod. If you are already running
Hesiod in your network, you probably already have a file named Hesiod in your network, you probably already have a file named
`hesiod.conf' on your machines (probably as `/etc/hesiod.conf' or `hesiod.conf' on your machines (probably as `/etc/hesiod.conf' or
`/usr/local/etc/hesiod.conf'). The Hesiod NSS module expects this `/usr/local/etc/hesiod.conf'). The Hesiod NSS module looks for
file to be found in the sysconfdir (`/usr/local/etc/hesiod.conf' by `/etc/hesiod.conf' by default. If there is no configuration file you
default, see the installation notes on how to change this) or in the will want to create your own. It should look something like:
location specified by the environment variable `HESIOD_CONFIG'. If
there is no configuration file you will want to create your own. It
should look something like:
rhs=.your.domain rhs=.your.domain
lhs=.ns lhs=.ns
The value of rhs can be overridden by the environment variable The value of rhs can be overridden by the environment variable
HES_DOMAIN. `HES_DOMAIN'.
Configuring your name servers Configuring your name servers
----------------------------- -----------------------------
@ -115,8 +112,8 @@ file `named.hesiod' containing data that looks something like:
123.gid CNAME libc.group 123.gid CNAME libc.group
gnu.passwd TXT "gnu:*:4567:123:GNU:/home/gnu:/bin/bash" gnu.passwd TXT "gnu:*:4567:123:GNU:/home/gnu:/bin/bash"
456.uid CNAME mark.passwd 456.uid CNAME mark.passwd
nss.service TXT "nss;tcp;789;switch sw " nss.service TXT "nss tcp 789 switch sw "
nss.service TXT "nss;udp;789;switch sw" nss.service TXT "nss udp 789 switch sw"
where `libc' is an example of a group, `gnu' an example of an user, where `libc' is an example of a group, `gnu' an example of an user,
and `nss' an example of a service. Note that the format used to and `nss' an example of a service. Note that the format used to

View File

@ -9,5 +9,8 @@ libnss_hesiod {
} }
GLIBC_2.2 { GLIBC_2.2 {
_nss_hesiod_initgroups; _nss_hesiod_initgroups;
_nss_hesiod_getservbyport_r;
_nss_hesiod_setprotoent; _nss_hesiod_endprotoent;
_nss_hesiod_getprotobyname_r; _nss_hesiod_getprotobynumber_r;
} }
} }

View File

@ -1,4 +1,9 @@
/* Copyright (c) 1996 by Internet Software Consortium. #if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$BINDId: hesiod.c,v 1.21 2000/02/28 14:51:08 vixie Exp $";
#endif
/*
* Copyright (c) 1996,1999 by Internet Software Consortium.
* *
* Permission to use, copy, modify, and distribute this software for any * Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@ -14,469 +19,488 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* Copyright 1996 by the Massachusetts Institute of Technology. /*
* * This file is primarily maintained by <tytso@mit.edu> and <ghudson@mit.edu>.
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/ */
/* This file is part of the hesiod library. It implements the core /*
* portion of the hesiod resolver. * hesiod.c --- the core portion of the hesiod resolver.
* *
* This file is loosely based on an interim version of hesiod.c from * This file is derived from the hesiod library from Project Athena;
* the BIND IRS library, which was in turn based on an earlier version * It has been extensively rewritten by Theodore Ts'o to have a more
* of this file. Extensive changes have been made on each step of the * thread-safe interface.
* path.
*
* This implementation is not truly thread-safe at the moment because
* it uses res_send() and accesses _res.
*/ */
#if defined(LIBC_SCCS) && !defined(lint) /* Imports */
static const char rcsid[] = "$Id$";
#endif
#include <sys/types.h> #include <sys/types.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/nameser.h> #include <arpa/nameser.h>
#include <errno.h> #include <errno.h>
#include <netdb.h> #include <netdb.h>
#include <resolv.h> #include <resolv.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h>
#include "hesiod.h" #include "hesiod.h"
#include "hesiod_p.h" #include "hesiod_p.h"
#undef DEF_RHS
/* A few operating systems don't define these. */ #define _PATH_HESIOD_CONF "/etc/hesiod.conf"
#ifndef C_HS
# define C_HS 4
#endif
#ifndef T_TXT
# define T_TXT 16
#endif
static int read_config_file (struct hesiod_p *ctx, const char *filename); /* Forward */
static char **get_txt_records (struct hesiod_p *ctx, int class,
const char *name);
#ifdef _LIBC
# define cistrcmp(s1, s2) strcasecmp (s1, s2)
#else
static int cistrcmp (const char *s1, const char *s2);
#endif
/* This function is called to initialize a hesiod_p. */ int hesiod_init(void **context);
void hesiod_end(void *context);
char * hesiod_to_bind(void *context, const char *name,
const char *type);
char ** hesiod_resolve(void *context, const char *name,
const char *type);
void hesiod_free_list(void *context, char **list);
static int parse_config_file(struct hesiod_p *ctx, const char *filename);
static char ** get_txt_records(struct hesiod_p *ctx, int class,
const char *name);
static int init(struct hesiod_p *ctx);
/* Public */
/*
* This function is called to initialize a hesiod_p.
*/
int int
hesiod_init (void **context) hesiod_init(void **context) {
{ struct hesiod_p *ctx;
struct hesiod_p *ctx; const char *configname;
const char *p, *configname; char *cp;
ctx = malloc (sizeof (struct hesiod_p)); ctx = malloc(sizeof(struct hesiod_p));
if (ctx) if (ctx == 0) {
{ __set_errno(ENOMEM);
*context = ctx; return (-1);
configname = __secure_getenv ("HESIOD_CONFIG");
if (!configname)
configname = SYSCONFDIR "/hesiod.conf";
if (read_config_file (ctx, configname) >= 0)
{
/* The default rhs can be overridden by an environment variable. */
p = __secure_getenv ("HES_DOMAIN");
if (p)
{
if (ctx->rhs)
free (ctx->rhs);
ctx->rhs = malloc (strlen (p) + 2);
if (ctx->rhs)
{
*ctx->rhs = '.';
strcpy (ctx->rhs + 1, (*p == '.') ? p + 1 : p);
return 0;
}
else
__set_errno (ENOMEM);
}
else
return 0;
} }
}
else
__set_errno (ENOMEM);
if (ctx->lhs) ctx->LHS = NULL;
free (ctx->lhs); ctx->RHS = NULL;
if (ctx->rhs) ctx->res = NULL;
free (ctx->rhs);
if (ctx) configname = __secure_getenv("HESIOD_CONFIG");
free (ctx); if (!configname)
return -1; configname = _PATH_HESIOD_CONF;
if (parse_config_file(ctx, configname) < 0) {
#ifdef DEF_RHS
/*
* Use compiled in defaults.
*/
ctx->LHS = malloc(strlen(DEF_LHS)+1);
ctx->RHS = malloc(strlen(DEF_RHS)+1);
if (ctx->LHS == 0 || ctx->RHS == 0) {
__set_errno(ENOMEM);
goto cleanup;
}
strcpy(ctx->LHS, DEF_LHS);
strcpy(ctx->RHS, DEF_RHS);
#else
goto cleanup;
#endif
}
/*
* The default RHS can be overridden by an environment
* variable.
*/
if ((cp = __secure_getenv("HES_DOMAIN")) != NULL) {
if (ctx->RHS)
free(ctx->RHS);
ctx->RHS = malloc(strlen(cp)+2);
if (!ctx->RHS) {
__set_errno(ENOMEM);
goto cleanup;
}
if (cp[0] == '.')
strcpy(ctx->RHS, cp);
else {
strcpy(ctx->RHS, ".");
strcat(ctx->RHS, cp);
}
}
/*
* If there is no default hesiod realm set, we return an
* error.
*/
if (!ctx->RHS) {
__set_errno(ENOEXEC);
goto cleanup;
}
#if 0
if (res_ninit(ctx->res) < 0)
goto cleanup;
#endif
*context = ctx;
return (0);
cleanup:
hesiod_end(ctx);
return (-1);
} }
/* This function deallocates the hesiod_p. */ /*
* This function deallocates the hesiod_p
*/
void void
hesiod_end (void *context) hesiod_end(void *context) {
{ struct hesiod_p *ctx = (struct hesiod_p *) context;
struct hesiod_p *ctx = (struct hesiod_p *) context; int save_errno = errno;
free (ctx->rhs); if (ctx->res)
if (ctx->lhs) res_nclose(ctx->res);
free (ctx->lhs); if (ctx->RHS)
free (ctx); free(ctx->RHS);
if (ctx->LHS)
free(ctx->LHS);
if (ctx->res && ctx->free_res)
(*ctx->free_res)(ctx->res);
free(ctx);
__set_errno(save_errno);
} }
/* This function takes a hesiod (name, type) and returns a DNS /*
* This function takes a hesiod (name, type) and returns a DNS
* name which is to be resolved. * name which is to be resolved.
*/ */
char * char *
hesiod_to_bind (void *context, const char *name, const char *type) hesiod_to_bind(void *context, const char *name, const char *type) {
{ struct hesiod_p *ctx = (struct hesiod_p *) context;
struct hesiod_p *ctx = (struct hesiod_p *) context; char *bindname;
char bindname[MAXDNAME], *p, *endp, *ret, **rhs_list = NULL; char **rhs_list = NULL;
const char *rhs; const char *RHS, *cp;
size_t len;
endp = stpcpy (bindname, name); /* Decide what our RHS is, and set cp to the end of the actual name. */
if ((cp = strchr(name, '@')) != NULL) {
/* Find the right right hand side to use, possibly truncating bindname. */ if (strchr(cp + 1, '.'))
p = strchr (bindname, '@'); RHS = cp + 1;
if (p) else if ((rhs_list = hesiod_resolve(context, cp + 1,
{ "rhs-extension")) != NULL)
*p++ = 0; RHS = *rhs_list;
if (strchr (p, '.')) else {
rhs = name + (p - bindname); __set_errno(ENOENT);
else return (NULL);
{ }
rhs_list = hesiod_resolve (context, p, "rhs-extension"); } else {
if (rhs_list) RHS = ctx->RHS;
rhs = *rhs_list; cp = name + strlen(name);
else
{
__set_errno (ENOENT);
return NULL;
}
} }
}
else
rhs = ctx->rhs;
/* See if we have enough room. */ /*
len = (endp - bindname) + 1 + strlen (type); * Allocate the space we need, including up to three periods and
if (ctx->lhs) * the terminating NUL.
len += strlen (ctx->lhs) + ((ctx->lhs[0] != '.') ? 1 : 0); */
len += strlen (rhs) + ((rhs[0] != '.') ? 1 : 0); if ((bindname = malloc((cp - name) + strlen(type) + strlen(RHS) +
if (len > sizeof (bindname) - 1) (ctx->LHS ? strlen(ctx->LHS) : 0) + 4)) == NULL) {
{ __set_errno(ENOMEM);
if (rhs_list) if (rhs_list)
hesiod_free_list (context, rhs_list); hesiod_free_list(context, rhs_list);
__set_errno (EMSGSIZE); return NULL;
return NULL; }
}
/* Put together the rest of the domain. */ /* Now put together the DNS name. */
endp = stpcpy (stpcpy (endp, "."), type); memcpy(bindname, name, cp - name);
if (ctx->lhs) bindname[cp - name] = '\0';
{ strcat(bindname, ".");
if (ctx->lhs[0] != '.') strcat(bindname, type);
endp = stpcpy (endp, "."); if (ctx->LHS) {
endp = stpcpy (endp, ctx->lhs); if (ctx->LHS[0] != '.')
} strcat(bindname, ".");
if (rhs[0] != '.') strcat(bindname, ctx->LHS);
endp = stpcpy (endp, "."); }
endp = stpcpy (endp, rhs); if (RHS[0] != '.')
strcat(bindname, ".");
strcat(bindname, RHS);
/* rhs_list is no longer needed, since we're done with rhs. */ if (rhs_list)
if (rhs_list) hesiod_free_list(context, rhs_list);
hesiod_free_list (context, rhs_list);
/* Make a copy of the result and return it to the caller. */ return (bindname);
ret = malloc ((endp - bindname) + 1);
if (!ret)
{
__set_errno (ENOMEM);
return NULL;
}
return strcpy (ret, bindname);
} }
/* This is the core function. Given a hesiod name and type, it /*
* This is the core function. Given a hesiod (name, type), it
* returns an array of strings returned by the resolver. * returns an array of strings returned by the resolver.
*/ */
char ** char **
hesiod_resolve (void *context, const char *name, const char *type) hesiod_resolve(void *context, const char *name, const char *type) {
{ struct hesiod_p *ctx = (struct hesiod_p *) context;
struct hesiod_p *ctx = (struct hesiod_p *) context; char *bindname = hesiod_to_bind(context, name, type);
char *bindname, **retvec; char **retvec;
bindname = hesiod_to_bind (context, name, type); if (bindname == NULL)
if (bindname == NULL) return (NULL);
return NULL; if (init(ctx) == -1) {
free(bindname);
return (NULL);
}
retvec = get_txt_records(ctx, ctx->classes[0], bindname); if ((retvec = get_txt_records(ctx, C_IN, bindname))) {
if (retvec == NULL && errno == ENOENT && ctx->classes[1]) free(bindname);
retvec = get_txt_records (ctx, ctx->classes[1], bindname); return (retvec);
}
if (errno != ENOENT)
return (NULL);
free (bindname); retvec = get_txt_records(ctx, C_HS, bindname);
return retvec; free(bindname);
return (retvec);
} }
void void
hesiod_free_list (void *context, char **list) hesiod_free_list(void *context, char **list) {
{ char **p;
char **p;
for (p = list; *p; p++) for (p = list; *p; p++)
free (*p); free(*p);
free (list); free(list);
} }
/* This function parses the /etc/hesiod.conf file. Returns 0 on success, /*
* -1 on failure. On failure, it might leave values in ctx->lhs or * This function parses the /etc/hesiod.conf file
* ctx->rhs which need to be freed by the caller. */ */
static int static int
read_config_file (struct hesiod_p *ctx, const char *filename) parse_config_file(struct hesiod_p *ctx, const char *filename) {
{ char *key, *data, *cp, **cpp;
char *key, *data, *p, **which; char buf[MAXDNAME+7];
char buf[MAXDNAME + 7]; FILE *fp;
int n;
FILE *fp;
/* Set default query classes. */ /*
ctx->classes[0] = C_IN; * Clear the existing configuration variable, just in case
ctx->classes[1] = C_HS; * they're set.
*/
if (ctx->RHS)
free(ctx->RHS);
if (ctx->LHS)
free(ctx->LHS);
ctx->RHS = ctx->LHS = 0;
/* Try to open the configuration file. */ /*
fp = fopen (filename, "r"); * Now open and parse the file...
if (fp == NULL) */
{ if (!(fp = fopen(filename, "r")))
/* Use compiled in default domain names. */ return (-1);
ctx->lhs = malloc (strlen (DEF_LHS) + 1);
ctx->rhs = malloc (strlen (DEF_RHS) + 1); while (fgets(buf, sizeof(buf), fp) != NULL) {
if (ctx->lhs && ctx->rhs) cp = buf;
{ if (*cp == '#' || *cp == '\n' || *cp == '\r')
strcpy (ctx->lhs, DEF_LHS); continue;
strcpy (ctx->rhs, DEF_RHS); while(*cp == ' ' || *cp == '\t')
return 0; cp++;
key = cp;
while(*cp != ' ' && *cp != '\t' && *cp != '=')
cp++;
*cp++ = '\0';
while(*cp == ' ' || *cp == '\t' || *cp == '=')
cp++;
data = cp;
while(*cp != ' ' && *cp != '\n' && *cp != '\r')
cp++;
*cp++ = '\0';
if (strcmp(key, "lhs") == 0)
cpp = &ctx->LHS;
else if (strcmp(key, "rhs") == 0)
cpp = &ctx->RHS;
else
continue;
*cpp = malloc(strlen(data) + 1);
if (!*cpp) {
__set_errno(ENOMEM);
goto cleanup;
}
strcpy(*cpp, data);
} }
else fclose(fp);
{ return (0);
__set_errno (ENOMEM);
return -1; cleanup:
} fclose(fp);
} if (ctx->RHS)
free(ctx->RHS);
ctx->lhs = NULL; if (ctx->LHS)
ctx->rhs = NULL; free(ctx->LHS);
while (fgets (buf, sizeof (buf), fp) != NULL) ctx->RHS = ctx->LHS = 0;
{ return (-1);
p = buf;
if (*p == '#' || *p == '\n' || *p == '\r')
continue;
while (*p == ' ' || *p == '\t')
++p;
key = p;
while(*p != ' ' && *p != '\t' && *p != '=')
++p;
*p++ = 0;
while (isspace (*p) || *p == '=')
++p;
data = p;
while (!isspace (*p))
++p;
*p = 0;
if (cistrcmp (key, "lhs") == 0 || cistrcmp (key, "rhs") == 0)
{
which = (strcmp (key, "lhs") == 0) ? &ctx->lhs : &ctx->rhs;
*which = strdup (data);
if (!*which)
{
__set_errno (ENOMEM);
return -1;
}
}
else if (cistrcmp (key, "classes") == 0)
{
n = 0;
while (*data && n < 2)
{
p = data;
while (*p && *p != ',')
++p;
if (*p)
*p++ = 0;
if (cistrcmp (data, "IN") == 0)
ctx->classes[n++] = C_IN;
else if (cistrcmp (data, "HS") == 0)
ctx->classes[n++] = C_HS;
data = p;
}
while (n < 2)
ctx->classes[n++] = 0;
}
}
fclose (fp);
if (!ctx->rhs || ctx->classes[0] == 0 || ctx->classes[0] == ctx->classes[1])
{
__set_errno (ENOEXEC);
return -1;
}
return 0;
} }
/* Given a DNS class and a DNS name, do a lookup for TXT records, and /*
* Given a DNS class and a DNS name, do a lookup for TXT records, and
* return a list of them. * return a list of them.
*/ */
static char ** static char **
get_txt_records (struct hesiod_p *ctx, int qclass, const char *name) get_txt_records(struct hesiod_p *ctx, int class, const char *name) {
{ struct {
HEADER *hp; int type; /* RR type */
unsigned char qbuf[PACKETSZ], abuf[MAX_HESRESP], *p, *eom, *eor; int class; /* RR class */
char *dst, **list; int dlen; /* len of data section */
int ancount, qdcount, i, j, n, skip, type, class, len; u_char *data; /* pointer to data */
} rr;
HEADER *hp;
u_char qbuf[MAX_HESRESP], abuf[MAX_HESRESP];
u_char *cp, *erdata, *eom;
char *dst, *edst, **list;
int ancount, qdcount;
int i, j, n, skip;
/* Make sure the resolver is initialized. */ /*
if ((_res.options & RES_INIT) == 0 && res_init () == -1) * Construct the query and send it.
return NULL; */
n = res_nmkquery(ctx->res, QUERY, name, class, T_TXT, NULL, 0,
/* Construct the query. */ NULL, qbuf, MAX_HESRESP);
n = res_mkquery (QUERY, name, qclass, T_TXT, NULL, 0, if (n < 0) {
NULL, qbuf, PACKETSZ); __set_errno(EMSGSIZE);
if (n < 0) return (NULL);
return NULL;
/* Send the query. */
n = res_send (qbuf, n, abuf, MAX_HESRESP);
if (n < 0)
{
__set_errno (ECONNREFUSED);
return NULL;
}
/* Parse the header of the result. */
hp = (HEADER *) abuf;
ancount = ntohs (hp->ancount);
qdcount = ntohs (hp->qdcount);
p = abuf + sizeof (HEADER);
eom = abuf + n;
/* Skip questions, trying to get to the answer section which follows. */
for (i = 0; i < qdcount; ++i)
{
skip = dn_skipname (p, eom);
if (skip < 0 || p + skip + QFIXEDSZ > eom)
{
__set_errno (EMSGSIZE);
return NULL;
} }
p += skip + QFIXEDSZ; n = res_nsend(ctx->res, qbuf, n, abuf, MAX_HESRESP);
} if (n < 0) {
__set_errno(ECONNREFUSED);
/* Allocate space for the text record answers. */ return (NULL);
list = malloc ((ancount + 1) * sizeof(char *)); }
if (list == NULL) if (n < HFIXEDSZ) {
{ __set_errno(EMSGSIZE);
__set_errno (ENOMEM); return (NULL);
return NULL;
}
/* Parse the answers. */
j = 0;
for (i = 0; i < ancount; i++)
{
/* Parse the header of this answer. */
skip = dn_skipname (p, eom);
if (skip < 0 || p + skip + 10 > eom)
break;
type = p[skip + 0] << 8 | p[skip + 1];
class = p[skip + 2] << 8 | p[skip + 3];
len = p[skip + 8] << 8 | p[skip + 9];
p += skip + 10;
if (p + len > eom)
{
__set_errno (EMSGSIZE);
break;
} }
/* Skip entries of the wrong class and type. */ /*
if (class != qclass || type != T_TXT) * OK, parse the result.
{ */
p += len; hp = (HEADER *) abuf;
continue; ancount = ntohs(hp->ancount);
qdcount = ntohs(hp->qdcount);
cp = abuf + sizeof(HEADER);
eom = abuf + n;
/* Skip query, trying to get to the answer section which follows. */
for (i = 0; i < qdcount; i++) {
skip = dn_skipname(cp, eom);
if (skip < 0 || cp + skip + QFIXEDSZ > eom) {
__set_errno(EMSGSIZE);
return (NULL);
}
cp += skip + QFIXEDSZ;
} }
/* Allocate space for this answer. */ list = malloc((ancount + 1) * sizeof(char *));
list[j] = malloc (len); if (!list) {
if (!list[j]) __set_errno(ENOMEM);
{ return (NULL);
__set_errno (ENOMEM);
break;
} }
dst = list[j++]; j = 0;
for (i = 0; i < ancount; i++) {
/* Copy answer data into the allocated area. */ skip = dn_skipname(cp, eom);
eor = p + len; if (skip < 0) {
while (p < eor) __set_errno(EMSGSIZE);
{ goto cleanup;
n = (unsigned char) *p++; }
if (p + n > eor) cp += skip;
{ if (cp + 3 * INT16SZ + INT32SZ > eom) {
__set_errno (EMSGSIZE); __set_errno(EMSGSIZE);
break; goto cleanup;
} }
dst = mempcpy (dst, p, n); rr.type = ns_get16(cp);
p += n; cp += INT16SZ;
rr.class = ns_get16(cp);
cp += INT16SZ + INT32SZ; /* skip the ttl, too */
rr.dlen = ns_get16(cp);
cp += INT16SZ;
if (cp + rr.dlen > eom) {
__set_errno(EMSGSIZE);
goto cleanup;
}
rr.data = cp;
cp += rr.dlen;
if (rr.class != class || rr.type != T_TXT)
continue;
if (!(list[j] = malloc(rr.dlen)))
goto cleanup;
dst = list[j++];
edst = dst + rr.dlen;
erdata = rr.data + rr.dlen;
cp = rr.data;
while (cp < erdata) {
n = (unsigned char) *cp++;
if (cp + n > eom || dst + n > edst) {
__set_errno(EMSGSIZE);
goto cleanup;
}
memcpy(dst, cp, n);
cp += n;
dst += n;
}
if (cp != erdata) {
__set_errno(EMSGSIZE);
goto cleanup;
}
*dst = '\0';
} }
if (p < eor) list[j] = NULL;
{ if (j == 0) {
__set_errno (EMSGSIZE); __set_errno(ENOENT);
break; goto cleanup;
} }
*dst = 0; return (list);
}
/* If we didn't terminate the loop normally, something went wrong. */ cleanup:
if (i < ancount) for (i = 0; i < j; i++)
{ free(list[i]);
for (i = 0; i < j; i++) free(list);
free (list[i]); return (NULL);
free (list); }
return NULL;
} struct __res_state *
__hesiod_res_get(void *context) {
if (j == 0) struct hesiod_p *ctx = context;
{
__set_errno (ENOENT); if (!ctx->res) {
free (list); struct __res_state *res;
return NULL; res = (struct __res_state *)malloc(sizeof *res);
} if (res == NULL) {
__set_errno(ENOMEM);
list[j] = NULL; return (NULL);
return list; }
memset(res, 0, sizeof *res);
__hesiod_res_set(ctx, res, free);
}
return (ctx->res);
}
void
__hesiod_res_set(void *context, struct __res_state *res,
void (*free_res)(void *)) {
struct hesiod_p *ctx = context;
if (ctx->res && ctx->free_res) {
res_nclose(ctx->res);
(*ctx->free_res)(ctx->res);
}
ctx->res = res;
ctx->free_res = free_res;
} }
#ifndef _LIBC
static int static int
cistrcmp (const char *s1, const char *s2) init(struct hesiod_p *ctx) {
{
while (*s1 && tolower(*s1) == tolower(*s2)) if (!ctx->res && !__hesiod_res_get(ctx))
{ return (-1);
s1++;
s2++; if (((ctx->res->options & RES_INIT) == 0) &&
} (res_ninit(ctx->res) == -1))
return tolower(*s1) - tolower(*s2); return (-1);
return (0);
} }
#endif

View File

@ -1,7 +1,5 @@
/* $Id$ */
/* /*
* Copyright (c) 1996 by Internet Software Consortium. * Copyright (c) 1996,1999 by Internet Software Consortium.
* *
* Permission to use, copy, modify, and distribute this software for any * Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@ -17,57 +15,26 @@
* SOFTWARE. * SOFTWARE.
*/ */
#ifndef HESIOD__INCLUDED /*
#define HESIOD__INCLUDED * This file is primarily maintained by <tytso@mit.edu> and <ghudson@mit.edu>.
*/
#include <sys/types.h> /*
#include <pwd.h> * $BINDId: hesiod.h,v 1.7 1999/01/08 19:22:45 vixie Exp $
#include <netdb.h> */
/* Application-visible define to signal that we have the new interfaces. */ #ifndef _HESIOD_H_INCLUDED
#define HESIOD_INTERFACES #define _HESIOD_H_INCLUDED
struct hesiod_postoffice { int hesiod_init __P((void **context));
char *hesiod_po_type; void hesiod_end __P((void *context));
char *hesiod_po_host; char * hesiod_to_bind __P((void *context, const char *name,
char *hesiod_po_name; const char *type));
}; char ** hesiod_resolve __P((void *context, const char *name,
const char *type));
void hesiod_free_list __P((void *context, char **list));
struct __res_state * __hesiod_res_get __P((void *context));
void __hesiod_res_set __P((void *context, struct __res_state *,
void (*)(void *)));
int hesiod_init(void **context); #endif /*_HESIOD_H_INCLUDED*/
void hesiod_end(void *context);
char *hesiod_to_bind(void *context, const char *name, const char *type);
char **hesiod_resolve(void *context, const char *name, const char *type);
void hesiod_free_list(void *context, char **list);
struct passwd *hesiod_getpwnam(void *context, const char *name);
struct passwd *hesiod_getpwuid(void *context, uid_t uid);
void hesiod_free_passwd(void *context, struct passwd *pw);
struct servent *hesiod_getservbyname(void *context, const char *name,
const char *proto);
void hesiod_free_servent(void *context, struct servent *serv);
struct hesiod_postoffice *hesiod_getmailhost(void *context, const char *user);
void hesiod_free_postoffice(void *context, struct hesiod_postoffice *po);
/* Compatibility stuff. */
#define HES_ER_UNINIT -1 /* uninitialized */
#define HES_ER_OK 0 /* no error */
#define HES_ER_NOTFOUND 1 /* Hesiod name not found by server */
#define HES_ER_CONFIG 2 /* local problem (no config file?) */
#define HES_ER_NET 3 /* network problem */
struct hes_postoffice {
char *po_type;
char *po_host;
char *po_name;
};
int hes_init(void);
char *hes_to_bind(const char *name, const char *type);
char **hes_resolve(const char *name, const char *type);
int hes_error(void);
struct passwd *hes_getpwnam(const char *name);
struct passwd *hes_getpwuid(uid_t uid);
struct servent *hes_getservbyname(const char *name, const char *proto);
struct hes_postoffice *hes_getmailhost(const char *name);
#endif

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1996 by Internet Software Consortium. * Copyright (c) 1996,1999 by Internet Software Consortium.
* *
* Permission to use, copy, modify, and distribute this software for any * Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@ -16,26 +16,33 @@
*/ */
/* /*
* $Id$ * This file is primarily maintained by <tytso@mit.edu> and <ghudson@mit.edu>.
*/
/*
* $BINDId: hesiod_p.h,v 1.9 1999/01/08 19:24:39 vixie Exp $
*/ */
/* /*
* hesiod_p.h -- private definitions for the hesiod library * hesiod_p.h -- private definitions for the hesiod library
*/ */
#ifndef HESIOD_P_H_INCLUDED #ifndef _HESIOD_P_H_INCLUDED
#define HESIOD_P_H_INCLUDED #define _HESIOD_P_H_INCLUDED
/* Defaults if the configuration file is not present. */
#define DEF_RHS ".athena.mit.edu"
#define DEF_LHS ".ns"
#define DEF_RHS ".Athena.MIT.EDU" /* Defaults if HESIOD_CONF */
#define DEF_LHS ".ns" /* file is not */
/* present. */
struct hesiod_p { struct hesiod_p {
char *lhs; /* normally ".ns" */ char * LHS; /* normally ".ns" */
char *rhs; /* AKA the default hesiod domain */ char * RHS; /* AKA the default hesiod domain */
int classes[2]; /* The class search order. */ struct __res_state * res; /* resolver context */
void (*free_res)(void *);
void (*res_set)(struct hesiod_p *, struct __res_state *,
void (*)(void *));
struct __res_state * (*res_get)(struct hesiod_p *);
}; };
#define MAX_HESRESP 1024 #define MAX_HESRESP 1024
#endif /*HESIOD_P_H_INCLUDED*/ #endif /*_HESIOD_P_H_INCLUDED*/

View File

@ -21,11 +21,12 @@
#include <errno.h> #include <errno.h>
#include <grp.h> #include <grp.h>
#include <hesiod.h> #include <hesiod.h>
#include <nss.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <nss.h>
#include <bits/libc-lock.h> #include "nss_hesiod.h"
/* Get the declaration of the parser function. */ /* Get the declaration of the parser function. */
#define ENTNAME grent #define ENTNAME grent
@ -33,50 +34,15 @@
#define EXTERN_PARSER #define EXTERN_PARSER
#include <nss/nss_files/files-parse.c> #include <nss/nss_files/files-parse.c>
/* Locks the static variables in this file. */
__libc_lock_define_initialized (static, lock);
static void *context = NULL;
static enum nss_status
internal_setgrent (void)
{
if (!context)
{
if (hesiod_init (&context) == -1)
return NSS_STATUS_UNAVAIL;
}
return NSS_STATUS_SUCCESS;
}
enum nss_status enum nss_status
_nss_hesiod_setgrent (void) _nss_hesiod_setgrent (void)
{ {
enum nss_status status; return NSS_STATUS_SUCCESS;
__libc_lock_lock (lock);
status = internal_setgrent ();
__libc_lock_unlock (lock);
return status;
} }
enum nss_status enum nss_status
_nss_hesiod_endgrent (void) _nss_hesiod_endgrent (void)
{ {
__libc_lock_lock (lock);
if (context)
{
hesiod_end (context);
context = NULL;
}
__libc_lock_unlock (lock);
return NSS_STATUS_SUCCESS; return NSS_STATUS_SUCCESS;
} }
@ -84,32 +50,37 @@ static enum nss_status
lookup (const char *name, const char *type, struct group *grp, lookup (const char *name, const char *type, struct group *grp,
char *buffer, size_t buflen, int *errnop) char *buffer, size_t buflen, int *errnop)
{ {
enum nss_status status;
struct parser_data *data = (void *) buffer; struct parser_data *data = (void *) buffer;
size_t linebuflen; size_t linebuflen;
void *context;
char **list; char **list;
int parse_res; int parse_res;
size_t len; size_t len;
status = internal_setgrent (); context = _nss_hesiod_init ();
if (status != NSS_STATUS_SUCCESS) if (context == NULL)
return status; return NSS_STATUS_UNAVAIL;
list = hesiod_resolve (context, name, type); list = hesiod_resolve (context, name, type);
if (list == NULL) if (list == NULL)
return errno == ENOENT ? NSS_STATUS_NOTFOUND : NSS_STATUS_UNAVAIL; {
hesiod_end (context);
return errno == ENOENT ? NSS_STATUS_NOTFOUND : NSS_STATUS_UNAVAIL;
}
linebuflen = buffer + buflen - data->linebuffer; linebuflen = buffer + buflen - data->linebuffer;
len = strlen (*list) + 1; len = strlen (*list) + 1;
if (linebuflen < len) if (linebuflen < len)
{ {
hesiod_free_list (context, list); hesiod_free_list (context, list);
hesiod_end (context);
*errnop = ERANGE; *errnop = ERANGE;
return NSS_STATUS_TRYAGAIN; return NSS_STATUS_TRYAGAIN;
} }
memcpy (data->linebuffer, *list, len); memcpy (data->linebuffer, *list, len);
hesiod_free_list (context, list); hesiod_free_list (context, list);
hesiod_end (context);
parse_res = _nss_files_parse_grent (buffer, grp, data, buflen, errnop); parse_res = _nss_files_parse_grent (buffer, grp, data, buflen, errnop);
if (parse_res < 1) if (parse_res < 1)
@ -122,34 +93,19 @@ enum nss_status
_nss_hesiod_getgrnam_r (const char *name, struct group *grp, _nss_hesiod_getgrnam_r (const char *name, struct group *grp,
char *buffer, size_t buflen, int *errnop) char *buffer, size_t buflen, int *errnop)
{ {
enum nss_status status; return lookup (name, "group", grp, buffer, buflen, errnop);
__libc_lock_lock (lock);
status = lookup (name, "group", grp, buffer, buflen, errnop);
__libc_lock_unlock (lock);
return status;
} }
enum nss_status enum nss_status
_nss_hesiod_getgrgid_r (gid_t gid, struct group *grp, _nss_hesiod_getgrgid_r (gid_t gid, struct group *grp,
char *buffer, size_t buflen, int *errnop) char *buffer, size_t buflen, int *errnop)
{ {
enum nss_status status = NSS_STATUS_UNAVAIL;
char gidstr[21]; /* We will probably never have a gid_t with more char gidstr[21]; /* We will probably never have a gid_t with more
than 64 bits. */ than 64 bits. */
snprintf (gidstr, sizeof gidstr, "%d", gid); snprintf (gidstr, sizeof gidstr, "%d", gid);
__libc_lock_lock (lock); return lookup (gidstr, "gid", grp, buffer, buflen, errnop);
status = lookup (gidstr, "gid", grp, buffer, buflen, errnop);
__libc_lock_unlock (lock);
return status;
} }
static int static int
@ -217,7 +173,8 @@ _nss_hesiod_initgroups (const char *user, gid_t group, long int *start,
char *p; char *p;
void *context; void *context;
if (hesiod_init (&context) == -1) context = _nss_hesiod_init ();
if (context == NULL)
return NSS_STATUS_UNAVAIL; return NSS_STATUS_UNAVAIL;
list = hesiod_resolve (context, user, "grplist"); list = hesiod_resolve (context, user, "grplist");

View File

@ -0,0 +1,39 @@
/* Copyright (C) 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 2000.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sys/cdefs.h> /* Needs to come before <hesiod.h>. */
#include <hesiod.h>
#include <resolv.h>
#include <stddef.h>
#include "nss_hesiod.h"
void *
_nss_hesiod_init (void)
{
void *context;
if (hesiod_init (&context) == -1)
return NULL;
/* Use the default (per-thread) resolver state. */
__hesiod_res_set (context, &_res, NULL);
return context;
}

View File

@ -0,0 +1,137 @@
/* Copyright (C) 1997, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <errno.h>
#include <hesiod.h>
#include <netdb.h>
#include <netinet/in.h>
#include <nss.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "nss_hesiod.h"
/* Declare a parser for Hesiod protocol entries. Although the format
of the entries is identical to those in /etc/protocols, here is no
predefined parser for us to use. */
#define ENTNAME protoent
struct protoent_data {};
#define TRAILING_LIST_MEMBER p_aliases
#define TRAILING_LIST_SEPARATOR_P isspace
#include <nss/nss_files/files-parse.c>
LINE_PARSER
("#",
STRING_FIELD (result->p_name, isspace, 1);
INT_FIELD (result->p_proto, isspace, 1, 10,);
)
enum nss_status
_nss_hesiod_setprotoent (void)
{
return NSS_STATUS_SUCCESS;
}
enum nss_status
_nss_hesiod_endprotoent (void)
{
return NSS_STATUS_SUCCESS;
}
static enum nss_status
lookup (const char *name, const char *type, struct protoent *proto,
char *buffer, size_t buflen, int *errnop)
{
struct parser_data *data = (void *) buffer;
size_t linebuflen;
void *context;
char **list, **item;
int parse_res;
int found;
context = _nss_hesiod_init ();
if (context == NULL)
return NSS_STATUS_UNAVAIL;
list = hesiod_resolve (context, name, type);
if (list == NULL)
{
hesiod_end (context);
return errno == ENOENT ? NSS_STATUS_NOTFOUND : NSS_STATUS_UNAVAIL;
}
linebuflen = buffer + buflen - data->linebuffer;
item = list;
found = 0;
do
{
size_t len = strlen (*item) + 1;
if (linebuflen < len)
{
hesiod_free_list (context, list);
hesiod_end (context);
*errnop = ERANGE;
return NSS_STATUS_TRYAGAIN;
}
memcpy (data->linebuffer, *item, len);
parse_res = parse_line (buffer, proto, data, buflen, errnop);
if (parse_res == -1)
{
hesiod_free_list (context, list);
hesiod_end (context);
return NSS_STATUS_TRYAGAIN;
}
if (parse_res > 0)
found = 1;
++item;
}
while (*item != NULL && !found);
hesiod_free_list (context, list);
hesiod_end (context);
return found ? NSS_STATUS_SUCCESS : NSS_STATUS_NOTFOUND;
}
enum nss_status
_nss_hesiod_getprotobyname_r (const char *name, struct protoent *proto,
char *buffer, size_t buflen, int *errnop)
{
return lookup (name, "protocol", proto, buffer, buflen, errnop);
}
enum nss_status
_nss_hesiod_getprotobynumber_r (const int protocol, struct protoent *proto,
char *buffer, size_t buflen, int *errnop)
{
char protostr[21];
snprintf (protostr, sizeof protostr, "%d", protocol);
return lookup (protostr, "protonum", proto, buffer, buflen, errnop);
}

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1997 Free Software Foundation, Inc. /* Copyright (C) 1997, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997. Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997.
@ -17,65 +17,31 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <bits/libc-lock.h>
#include <errno.h> #include <errno.h>
#include <hesiod.h> #include <hesiod.h>
#include <nss.h>
#include <pwd.h> #include <pwd.h>
#include <nss.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "nss_hesiod.h"
/* Get the declaration of the parser function. */ /* Get the declaration of the parser function. */
#define ENTNAME pwent #define ENTNAME pwent
#define STRUCTURE passwd #define STRUCTURE passwd
#define EXTERN_PARSER #define EXTERN_PARSER
#include <nss/nss_files/files-parse.c> #include <nss/nss_files/files-parse.c>
/* Locks the static variables in this file. */
__libc_lock_define_initialized (static, lock);
static void *context = NULL;
static enum nss_status
internal_setpwent (void)
{
if (!context)
{
if (hesiod_init (&context) == -1)
return NSS_STATUS_UNAVAIL;
}
return NSS_STATUS_SUCCESS;
}
enum nss_status enum nss_status
_nss_hesiod_setpwent (void) _nss_hesiod_setpwent (void)
{ {
enum nss_status status; return NSS_STATUS_SUCCESS;
__libc_lock_lock (lock);
status = internal_setpwent ();
__libc_lock_unlock (lock);
return status;
} }
enum nss_status enum nss_status
_nss_hesiod_endpwent (void) _nss_hesiod_endpwent (void)
{ {
__libc_lock_lock (lock);
if (context)
{
hesiod_end (context);
context = NULL;
}
__libc_lock_unlock (lock);
return NSS_STATUS_SUCCESS; return NSS_STATUS_SUCCESS;
} }
@ -83,32 +49,37 @@ static enum nss_status
lookup (const char *name, const char *type, struct passwd *pwd, lookup (const char *name, const char *type, struct passwd *pwd,
char *buffer, size_t buflen, int *errnop) char *buffer, size_t buflen, int *errnop)
{ {
enum nss_status status;
struct parser_data *data = (void *) buffer; struct parser_data *data = (void *) buffer;
size_t linebuflen; size_t linebuflen;
void *context;
char **list; char **list;
int parse_res; int parse_res;
size_t len; size_t len;
status = internal_setpwent (); context = _nss_hesiod_init ();
if (status != NSS_STATUS_SUCCESS) if (context == NULL)
return status; return NSS_STATUS_UNAVAIL;
list = hesiod_resolve (context, name, type); list = hesiod_resolve (context, name, type);
if (list == NULL) if (list == NULL)
return errno == ENOENT ? NSS_STATUS_NOTFOUND : NSS_STATUS_UNAVAIL; {
hesiod_end (context);
return errno == ENOENT ? NSS_STATUS_NOTFOUND : NSS_STATUS_UNAVAIL;
}
linebuflen = buffer + buflen - data->linebuffer; linebuflen = buffer + buflen - data->linebuffer;
len = strlen (*list) + 1; len = strlen (*list) + 1;
if (linebuflen < len) if (linebuflen < len)
{ {
hesiod_free_list (context, list); hesiod_free_list (context, list);
hesiod_end (context);
*errnop = ERANGE; *errnop = ERANGE;
return NSS_STATUS_TRYAGAIN; return NSS_STATUS_TRYAGAIN;
} }
memcpy (data->linebuffer, *list, len); memcpy (data->linebuffer, *list, len);
hesiod_free_list (context, list); hesiod_free_list (context, list);
hesiod_end (context);
parse_res = _nss_files_parse_pwent (buffer, pwd, data, buflen, errnop); parse_res = _nss_files_parse_pwent (buffer, pwd, data, buflen, errnop);
if (parse_res < 1) if (parse_res < 1)
@ -121,32 +92,17 @@ enum nss_status
_nss_hesiod_getpwnam_r (const char *name, struct passwd *pwd, _nss_hesiod_getpwnam_r (const char *name, struct passwd *pwd,
char *buffer, size_t buflen, int *errnop) char *buffer, size_t buflen, int *errnop)
{ {
enum nss_status status; return lookup (name, "passwd", pwd, buffer, buflen, errnop);
__libc_lock_lock (lock);
status = lookup (name, "passwd", pwd, buffer, buflen, errnop);
__libc_lock_unlock (lock);
return status;
} }
enum nss_status enum nss_status
_nss_hesiod_getpwuid_r (uid_t uid, struct passwd *pwd, _nss_hesiod_getpwuid_r (uid_t uid, struct passwd *pwd,
char *buffer, size_t buflen, int *errnop) char *buffer, size_t buflen, int *errnop)
{ {
enum nss_status status = NSS_STATUS_UNAVAIL;
char uidstr[21]; /* We will probably never have a gid_t with more char uidstr[21]; /* We will probably never have a gid_t with more
than 64 bits. */ than 64 bits. */
snprintf (uidstr, sizeof uidstr, "%d", uid); snprintf (uidstr, sizeof uidstr, "%d", uid);
__libc_lock_lock (lock); return lookup (uidstr, "uid", pwd, buffer, buflen, errnop);
status = lookup (uidstr, "uid", pwd, buffer, buflen, errnop);
__libc_lock_unlock (lock);
return status;
} }

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1997 Free Software Foundation, Inc. /* Copyright (C) 1997, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997. Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997.
@ -17,102 +17,68 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <bits/libc-lock.h>
#include <errno.h> #include <errno.h>
#include <hesiod.h> #include <hesiod.h>
#include <netdb.h> #include <netdb.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <nss.h> #include <nss.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "nss_hesiod.h"
/* Hesiod uses a format for service entries that differs from the /* Hesiod uses a format for service entries that differs from the
traditional format. We therefore declare our own parser. */ traditional format. We therefore declare our own parser. */
#define ENTNAME servent #define ENTNAME servent
#define ENTDATA servent_data
struct servent_data {}; struct servent_data {};
#define TRAILING_LIST_MEMBER s_aliases #define TRAILING_LIST_MEMBER s_aliases
#define TRAILING_LIST_SEPARATOR_P isspace #define TRAILING_LIST_SEPARATOR_P isspace
#include <nss/nss_files/files-parse.c> #include <nss/nss_files/files-parse.c>
#define ISSEMICOLON(c) ((c) == ';') #define ISSC_OR_SPACE(c) ((c) == ';' || isspace (c))
LINE_PARSER LINE_PARSER
("", ("#",
(void) entdata; STRING_FIELD (result->s_name, ISSC_OR_SPACE, 1);
STRING_FIELD (result->s_name, ISSEMICOLON, 1); STRING_FIELD (result->s_proto, ISSC_OR_SPACE, 1);
STRING_FIELD (result->s_proto, ISSEMICOLON, 1); INT_FIELD (result->s_port, ISSC_OR_SPACE, 10, 0, htons);
INT_FIELD (result->s_port, ISSEMICOLON, 10, 0, htons);
) )
/* Locks the static variables in this file. */
__libc_lock_define_initialized (static, lock);
static void *context = NULL;
static enum nss_status
internal_setservent (void)
{
if (!context)
{
if (hesiod_init (&context) == -1)
return NSS_STATUS_UNAVAIL;
}
return NSS_STATUS_SUCCESS;
}
enum nss_status enum nss_status
_nss_hesiod_setservent (void) _nss_hesiod_setservent (void)
{ {
enum nss_status status; return NSS_STATUS_SUCCESS;
__libc_lock_lock (lock);
status = internal_setservent ();
__libc_lock_unlock (lock);
return status;
} }
enum nss_status enum nss_status
_nss_hesiod_endservent (void) _nss_hesiod_endservent (void)
{ {
__libc_lock_lock (lock);
if (context)
{
hesiod_end (context);
context = NULL;
}
__libc_lock_unlock (lock);
return NSS_STATUS_SUCCESS; return NSS_STATUS_SUCCESS;
} }
static enum nss_status static enum nss_status
lookup (const char *name, const char *protocol, struct servent *serv, lookup (const char *name, const char *type, const char *protocol,
char *buffer, size_t buflen, int *errnop) struct servent *serv, char *buffer, size_t buflen, int *errnop)
{ {
enum nss_status status;
struct parser_data *data = (void *) buffer; struct parser_data *data = (void *) buffer;
size_t linebuflen; size_t linebuflen;
void *context;
char **list, **item; char **list, **item;
int parse_res; int parse_res;
int found; int found;
status = internal_setservent (); context = _nss_hesiod_init ();
if (status != NSS_STATUS_SUCCESS) if (context == NULL)
return status; return NSS_STATUS_UNAVAIL;
list = hesiod_resolve (context, name, "service"); list = hesiod_resolve (context, name, type);
if (list == NULL) if (list == NULL)
return errno == ENOENT ? NSS_STATUS_NOTFOUND : NSS_STATUS_UNAVAIL; {
hesiod_end (context);
return errno == ENOENT ? NSS_STATUS_NOTFOUND : NSS_STATUS_UNAVAIL;
}
linebuflen = buffer + buflen - data->linebuffer; linebuflen = buffer + buflen - data->linebuffer;
@ -125,6 +91,7 @@ lookup (const char *name, const char *protocol, struct servent *serv,
if (linebuflen < len) if (linebuflen < len)
{ {
hesiod_free_list (context, list); hesiod_free_list (context, list);
hesiod_end (context);
*errnop = ERANGE; *errnop = ERANGE;
return NSS_STATUS_TRYAGAIN; return NSS_STATUS_TRYAGAIN;
} }
@ -135,17 +102,19 @@ lookup (const char *name, const char *protocol, struct servent *serv,
if (parse_res == -1) if (parse_res == -1)
{ {
hesiod_free_list (context, list); hesiod_free_list (context, list);
hesiod_end (context);
return NSS_STATUS_TRYAGAIN; return NSS_STATUS_TRYAGAIN;
} }
if (parse_res > 0) if (parse_res > 0)
found = protocol == NULL || strcmp (serv->s_proto, protocol) == 0; found = protocol == NULL || strcasecmp (serv->s_proto, protocol) == 0;
++item; ++item;
} }
while (*item != NULL && !found); while (*item != NULL && !found);
hesiod_free_list (context, list); hesiod_free_list (context, list);
hesiod_end (context);
return found ? NSS_STATUS_SUCCESS : NSS_STATUS_NOTFOUND; return found ? NSS_STATUS_SUCCESS : NSS_STATUS_NOTFOUND;
} }
@ -155,13 +124,17 @@ _nss_hesiod_getservbyname_r (const char *name, const char *protocol,
struct servent *serv, struct servent *serv,
char *buffer, size_t buflen, int *errnop) char *buffer, size_t buflen, int *errnop)
{ {
enum nss_status status; return lookup (name, "service", protocol, serv, buffer, buflen, errnop);
}
__libc_lock_lock (lock);
enum nss_status
status = lookup (name, protocol, serv, buffer, buflen, errnop); _nss_hesiod_getservbyport_r (const int port, const char *protocol,
struct servent *serv,
__libc_lock_unlock (lock); char *buffer, size_t buflen, int *errnop)
{
return status; char portstr[6]; /* Port numbers are restricted to 16 bits. */
snprintf (portstr, sizeof portstr, "%d", ntohs (port));
return lookup (portstr, "port", protocol, serv, buffer, buflen, errnop);
} }

View File

@ -0,0 +1,21 @@
/* Copyright (C) 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 2000.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* Initialize a Hesiod context. */
extern void *_nss_hesiod_init (void);

View File

@ -1,6 +1,9 @@
#ifndef _DLFCN_H #ifndef _DLFCN_H
#include <dlfcn/dlfcn.h> #include <dlfcn/dlfcn.h>
/* Internally used flag. */
#define __RTLD_DLOPEN 0x80000000
/* Now define the internal interfaces. */ /* Now define the internal interfaces. */
extern void *__dlvsym (void *__handle, __const char *__name, extern void *__dlvsym (void *__handle, __const char *__name,
__const char *__version); __const char *__version);

View File

@ -361,6 +361,9 @@ res_nsend(res_state statp,
else else
for (ns = 0; ns < statp->nscount; ns++) for (ns = 0; ns < statp->nscount; ns++)
if (!sock_eq(&statp->nsaddr_list[ns], if (!sock_eq(&statp->nsaddr_list[ns],
#ifdef _LIBC
(struct sockaddr_in *)
#endif
&EXT(statp).nsaddrs[ns])) { &EXT(statp).nsaddrs[ns])) {
needclose++; needclose++;
break; break;
@ -374,7 +377,13 @@ res_nsend(res_state statp,
*/ */
if (EXT(statp).nscount == 0) { if (EXT(statp).nscount == 0) {
for (ns = 0; ns < statp->nscount; ns++) { for (ns = 0; ns < statp->nscount; ns++) {
#ifdef _LIBC
memcpy(&EXT(statp).nsaddrs[ns],
&statp->nsaddr_list[ns],
sizeof (&EXT(statp).nsaddrs[0]));
#else
EXT(statp).nsaddrs[ns] = statp->nsaddr_list[ns]; EXT(statp).nsaddrs[ns] = statp->nsaddr_list[ns];
#endif
EXT(statp).nstimes[ns] = RES_MAXTIME; EXT(statp).nstimes[ns] = RES_MAXTIME;
EXT(statp).nssocks[ns] = -1; EXT(statp).nssocks[ns] = -1;
} }

View File

@ -123,6 +123,16 @@ struct res_sym {
#define RES_DFLRETRY 2 /* Default #/tries. */ #define RES_DFLRETRY 2 /* Default #/tries. */
#define RES_MAXTIME 65535 /* Infinity, in milliseconds. */ #define RES_MAXTIME 65535 /* Infinity, in milliseconds. */
/*
* Like "struct sockaddr_in", but without any padding (to avoid making
* "struct __rest_state" too large).
*/
struct __sockaddr_in {
__SOCKADDR_COMMON (sin_);
in_port_t sin_port;
struct in_addr sin_addr;
};
struct __res_state { struct __res_state {
int retrans; /* retransmition time interval */ int retrans; /* retransmition time interval */
int retry; /* number of times to retransmit */ int retry; /* number of times to retransmit */
@ -153,7 +163,7 @@ struct __res_state {
u_int16_t nscount; u_int16_t nscount;
u_int16_t nstimes[MAXNS]; /* ms. */ u_int16_t nstimes[MAXNS]; /* ms. */
int nssocks[MAXNS]; int nssocks[MAXNS];
struct sockaddr_in nsaddrs[MAXNS]; struct __sockaddr_in nsaddrs[MAXNS];
} _ext; } _ext;
} _u; } _u;
}; };

View File

@ -271,7 +271,7 @@ extern void _dl_receive_error (receiver_fct fct, void (*operate) (void *),
value to allow additional security checks. */ value to allow additional security checks. */
extern struct link_map *_dl_map_object (struct link_map *loader, extern struct link_map *_dl_map_object (struct link_map *loader,
const char *name, int preloaded, const char *name, int preloaded,
int type, int trace_mode, int noload) int type, int trace_mode, int mode)
internal_function; internal_function;
/* Call _dl_map_object on the dependencies of MAP, and set up /* Call _dl_map_object on the dependencies of MAP, and set up

View File

@ -170,7 +170,7 @@ unfmh(); /* XXX */
lastslash = strrchr (p, '/'); lastslash = strrchr (p, '/');
l = _dl_map_object_from_fd (lastslash ? lastslash + 1 : p, l = _dl_map_object_from_fd (lastslash ? lastslash + 1 : p,
memobj, strdup (p)); memobj, strdup (p), 0);
/* Squirrel away the memory object port where it /* Squirrel away the memory object port where it
can be retrieved by the program later. */ can be retrieved by the program later. */