From ec281e5d512e7236a985dec613bcec87496f7a4c Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Mon, 16 Feb 2009 00:53:58 +0000 Subject: [PATCH] 2503. [port] linux: improve compatibility with Linux Standard Base. [RT #18793] --- CHANGES | 3 +++ acconfig.h | 8 +------- bin/named/unix/os.c | 6 +++++- configure.in | 33 +++++++++++++------------------ lib/dns/dst_api.c | 4 +++- lib/isc/Makefile.in | 6 +++--- lib/isc/include/isc/platform.h.in | 7 +------ lib/isc/unix/dir.c | 6 +++++- lib/isc/unix/entropy.c | 13 +++++++++++- lib/isc/unix/ifiter_ioctl.c | 6 +++--- lib/isc/unix/include/isc/net.h | 4 +--- 11 files changed, 51 insertions(+), 45 deletions(-) diff --git a/CHANGES b/CHANGES index 2d0579dfd2..c8a6573353 100644 --- a/CHANGES +++ b/CHANGES @@ -90,6 +90,9 @@ 2505. [port] Treat amd64 similarly to x86_64 when determining atomic operation support. [RT #19031] +2503. [port] linux: improve compatibility with Linux Standard + Base. [RT #18793] + 2502. [cleanup] isc_radix: Improve compliance with coding style, document function in . [RT #18534] diff --git a/acconfig.h b/acconfig.h index a806e58ebd..595bf4db5f 100644 --- a/acconfig.h +++ b/acconfig.h @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: acconfig.h,v 1.51 2007/06/19 23:46:59 tbox Exp $ */ +/* $Id: acconfig.h,v 1.51.130.1 2009/02/16 00:53:58 marka Exp $ */ /*! \file */ @@ -25,9 +25,6 @@ ***/ @TOP@ -/** define to `int' if doesn't define. */ -#undef ssize_t - /** define on DEC OSF to enable 4.4BSD style sa_len support */ #undef _SOCKADDR_LEN @@ -61,9 +58,6 @@ /** define if you have the NET_RT_IFLIST sysctl variable and sys/sysctl.h */ #undef HAVE_IFLIST_SYSCTL -/** define if chroot() is available */ -#undef HAVE_CHROOT - /** define if tzset() is available */ #undef HAVE_TZSET diff --git a/bin/named/unix/os.c b/bin/named/unix/os.c index 3e487c4562..b18e594566 100644 --- a/bin/named/unix/os.c +++ b/bin/named/unix/os.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: os.c,v 1.79.128.9 2008/11/14 05:11:42 marka Exp $ */ +/* $Id: os.c,v 1.79.128.10 2009/02/16 00:53:58 marka Exp $ */ /*! \file */ @@ -505,10 +505,14 @@ ns_os_chroot(const char *root) { ns_smf_chroot = 0; #endif if (root != NULL) { +#ifdef HAVE_CHROOT if (chroot(root) < 0) { isc__strerror(errno, strbuf, sizeof(strbuf)); ns_main_earlyfatal("chroot(): %s", strbuf); } +#else + ns_main_earlyfatal("chroot(): disabled"); +#endif if (chdir("/") < 0) { isc__strerror(errno, strbuf, sizeof(strbuf)); ns_main_earlyfatal("chdir(/): %s", strbuf); diff --git a/configure.in b/configure.in index c39c73507d..f6d0632555 100644 --- a/configure.in +++ b/configure.in @@ -18,7 +18,7 @@ AC_DIVERT_PUSH(1)dnl esyscmd([sed "s/^/# /" COPYRIGHT])dnl AC_DIVERT_POP()dnl -AC_REVISION($Revision: 1.432.60.29 $) +AC_REVISION($Revision: 1.432.60.30 $) AC_INIT(lib/dns/name.c) AC_PREREQ(2.59) @@ -1125,7 +1125,6 @@ AC_CHECK_FUNC(catgets, AC_DEFINE(HAVE_CATGETS),) # # AC_CHECK_LIB(xnet, socket, , # AC_CHECK_LIB(socket, socket) -# AC_CHECK_LIB(nsl, inet_ntoa) # ) # # Use this for now, instead: @@ -1135,7 +1134,6 @@ case "$host" in ;; *) AC_CHECK_LIB(socket, socket) - AC_CHECK_LIB(nsl, inet_ntoa) ;; esac @@ -1589,23 +1587,8 @@ main() { char a[16]; return (inet_pton(AF_INET, "1.2.3", a) == 1 ? 1 : [AC_MSG_RESULT(assuming target platform has working inet_pton) ISC_PLATFORM_NEEDPTON="#undef ISC_PLATFORM_NEEDPTON"]) -AC_MSG_CHECKING([for inet_aton]) -AC_TRY_LINK([ -#include -#include -#include ], - [struct in_addr in; inet_aton(0, &in); return (0);], - [AC_MSG_RESULT(yes) - ISC_PLATFORM_NEEDATON="#undef ISC_PLATFORM_NEEDATON"], - - [AC_MSG_RESULT(no) - ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_aton.$O" - ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS inet_aton.c" - ISC_PLATFORM_NEEDATON="#define ISC_PLATFORM_NEEDATON 1"]) - AC_SUBST(ISC_PLATFORM_NEEDNTOP) AC_SUBST(ISC_PLATFORM_NEEDPTON) -AC_SUBST(ISC_PLATFORM_NEEDATON) # # Look for a 4.4BSD-style sa_len member in struct sockaddr. @@ -1975,7 +1958,17 @@ AC_SUBST(LWRES_PLATFORM_QUADFORMAT) # # Security Stuff # -AC_CHECK_FUNC(chroot, AC_DEFINE(HAVE_CHROOT)) +# Note it is very recommended to *not* disable chroot(), +# this is only because chroot() was made obsolete by Posix. +AC_ARG_ENABLE(chroot, + [ --disable-chroot disable chroot]) +case "$enable_chroot" in + yes|'') + AC_CHECK_FUNCS(chroot) + ;; + no) + ;; +esac AC_ARG_ENABLE(linux-caps, [ --disable-linux-caps disable linux capabilities]) case "$enable_linux_caps" in @@ -2210,6 +2203,8 @@ yes) esac AC_SUBST(ISC_PLATFORM_HAVEIFNAMETOINDEX) +AC_CHECK_FUNCS(nanosleep) + # # Machine architecture dependent features # diff --git a/lib/dns/dst_api.c b/lib/dns/dst_api.c index 8f92a8f557..7e358c0cc6 100644 --- a/lib/dns/dst_api.c +++ b/lib/dns/dst_api.c @@ -31,7 +31,7 @@ /* * Principal Author: Brian Wellington - * $Id: dst_api.c,v 1.11.92.3 2008/11/14 22:57:29 marka Exp $ + * $Id: dst_api.c,v 1.11.92.4 2009/02/16 00:53:58 marka Exp $ */ /*! \file */ @@ -125,6 +125,7 @@ static isc_result_t addsuffix(char *filename, unsigned int len, return (_r); \ } while (0); \ +#ifdef OPENSSL static void * default_memalloc(void *arg, size_t size) { UNUSED(arg); @@ -138,6 +139,7 @@ default_memfree(void *arg, void *ptr) { UNUSED(arg); free(ptr); } +#endif isc_result_t dst_lib_init(isc_mem_t *mctx, isc_entropy_t *ectx, unsigned int eflags) { diff --git a/lib/isc/Makefile.in b/lib/isc/Makefile.in index 2668593c3f..7980af8c8a 100644 --- a/lib/isc/Makefile.in +++ b/lib/isc/Makefile.in @@ -13,7 +13,7 @@ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -# $Id: Makefile.in,v 1.93.58.4 2009/01/29 23:47:13 tbox Exp $ +# $Id: Makefile.in,v 1.93.58.5 2009/02/16 00:53:58 marka Exp $ srcdir = @srcdir@ VPATH = @srcdir@ @@ -54,7 +54,7 @@ OBJS = @ISC_EXTRA_OBJS@ \ assertions.@O@ base64.@O@ bitstring.@O@ buffer.@O@ \ bufferlist.@O@ commandline.@O@ error.@O@ event.@O@ \ hash.@O@ heap.@O@ hex.@O@ hmacmd5.@O@ hmacsha.@O@ \ - httpd.@O@ \ + httpd.@O@ inet_aton.@O@ \ lex.@O@ lfsr.@O@ lib.@O@ log.@O@ \ md5.@O@ mem.@O@ mutexblock.@O@ \ netaddr.@O@ netscope.@O@ ondestroy.@O@ \ @@ -69,7 +69,7 @@ SRCS = @ISC_EXTRA_SRCS@ \ assertions.c base64.c bitstring.c buffer.c \ bufferlist.c commandline.c error.c event.c \ heap.c hex.c hmacmd5.c hmacsha.c \ - httpd.c \ + httpd.c inet_aton.c \ lex.c lfsr.c lib.c log.c \ md5.c mem.c mutexblock.c \ netaddr.c netscope.c ondestroy.c \ diff --git a/lib/isc/include/isc/platform.h.in b/lib/isc/include/isc/platform.h.in index 21796b9292..a6c4673d5b 100644 --- a/lib/isc/include/isc/platform.h.in +++ b/lib/isc/include/isc/platform.h.in @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: platform.h.in,v 1.45.60.3 2008/06/24 00:09:12 jinmei Exp $ */ +/* $Id: platform.h.in,v 1.45.60.4 2009/02/16 00:53:58 marka Exp $ */ #ifndef ISC_PLATFORM_H #define ISC_PLATFORM_H 1 @@ -93,11 +93,6 @@ */ @ISC_PLATFORM_NEEDPTON@ -/*! \brief - * If this system needs inet_aton(), ISC_PLATFORM_NEEDATON will be defined. - */ -@ISC_PLATFORM_NEEDATON@ - /*! \brief * If this system needs in_port_t, ISC_PLATFORM_NEEDPORTT will be defined. */ diff --git a/lib/isc/unix/dir.c b/lib/isc/unix/dir.c index 8ab0cddfe0..9d71fd0dd9 100644 --- a/lib/isc/unix/dir.c +++ b/lib/isc/unix/dir.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dir.c,v 1.25 2007/06/19 23:47:18 tbox Exp $ */ +/* $Id: dir.c,v 1.25.128.1 2009/02/16 00:53:58 marka Exp $ */ /*! \file * \author Principal Authors: DCL */ @@ -171,10 +171,14 @@ isc_dir_chroot(const char *dirname) { REQUIRE(dirname != NULL); +#ifdef HAVE_CHROOT if (chroot(dirname) < 0) return (isc__errno2result(errno)); return (ISC_R_SUCCESS); +#else + return (ISC_R_NOTIMPLEMENTED); +#endif } isc_result_t diff --git a/lib/isc/unix/entropy.c b/lib/isc/unix/entropy.c index 4e3ee614db..48141dd19d 100644 --- a/lib/isc/unix/entropy.c +++ b/lib/isc/unix/entropy.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: entropy.c,v 1.80 2007/06/19 23:47:18 tbox Exp $ */ +/* $Id: entropy.c,v 1.80.128.1 2009/02/16 00:53:58 marka Exp $ */ /* \file unix/entropy.c * \brief @@ -31,6 +31,9 @@ #include #include +#ifdef HAVE_NANOSLEEP +#include +#endif #include #include @@ -174,7 +177,15 @@ get_from_usocketsource(isc_entropysource_t *source, isc_uint32_t desired) { * just "break", then the "desired" * amount gets borked. */ +#ifdef HAVE_NANOSLEEP + struct timespec ts; + + ts.tv_sec = 0; + ts.tv_nsec = 1000000; + nanosleep(&ts, NULL); +#else usleep(1000); +#endif goto eagain_loop; } if (errno == EWOULDBLOCK || errno == EINTR) diff --git a/lib/isc/unix/ifiter_ioctl.c b/lib/isc/unix/ifiter_ioctl.c index 73f2e700c4..1096e3e82b 100644 --- a/lib/isc/unix/ifiter_ioctl.c +++ b/lib/isc/unix/ifiter_ioctl.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ifiter_ioctl.c,v 1.58.90.2 2009/01/19 23:47:03 tbox Exp $ */ +/* $Id: ifiter_ioctl.c,v 1.58.90.3 2009/02/16 00:53:58 marka Exp $ */ /*! \file * \brief @@ -479,8 +479,8 @@ linux_if_inet6_current(isc_interfaceiter_t *iter) { for (i = 0; i < 16; i++) { unsigned char byte; static const char hex[] = "0123456789abcdef"; - byte = ((index(hex, address[i * 2]) - hex) << 4) | - (index(hex, address[i * 2 + 1]) - hex); + byte = ((strchr(hex, address[i * 2]) - hex) << 4) | + (strchr(hex, address[i * 2 + 1]) - hex); addr6.s6_addr[i] = byte; } iter->current.af = AF_INET6; diff --git a/lib/isc/unix/include/isc/net.h b/lib/isc/unix/include/isc/net.h index 82d46d33c4..2f1b7b2ad4 100644 --- a/lib/isc/unix/include/isc/net.h +++ b/lib/isc/unix/include/isc/net.h @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: net.h,v 1.46.128.2 2008/06/24 23:46:27 tbox Exp $ */ +/* $Id: net.h,v 1.46.128.3 2009/02/16 00:53:58 marka Exp $ */ #ifndef ISC_NET_H #define ISC_NET_H 1 @@ -354,11 +354,9 @@ isc_net_pton(int af, const char *src, void *dst); #define inet_pton isc_net_pton #endif -#ifdef ISC_PLATFORM_NEEDATON int isc_net_aton(const char *cp, struct in_addr *addr); #define inet_aton isc_net_aton -#endif ISC_LANG_ENDDECLS