#! /bin/sh # # Run sresolv_test using our own name server # # -------------------------------------------------------------------- # # This file is part of the Sofia-SIP package # # Copyright (C) 2005 Nokia Corporation. # # Contact: Pekka Pessi # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License # as published by the Free Software Foundation; either version 2.1 of # the License, or (at your option) any later version. # # This 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 # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA # # -------------------------------------------------------------------- # # Author(s): Pekka Pessi . # s=`dirname $0` test x$s = x. && s=`pwd` PATH=/usr/sbin:/usr/local/sbin:/sbin:$PATH export PATH # Test for support for IPv6 on Linux. This probably fails on everything else. ipv6='sysctl net.ipv6.conf.default.mtu >/dev/null 2>&1' # Bind not working with IPv6 on RHEL 4: # client.c:1325: unexpected error: failed to get request's destination: failure #ipv6=false port=`expr $$ % \( 65536 - 1024 \) + 1024` # Try to find a free port if netstat --ip >/dev/null 2>&1 ; then while netstat --ip -n -a | fgrep ":$port " > /dev/null do port=`expr $port + 1` if test $port = 65536 ; then port=1024 fi done fi # No BIND 9, no fun { type named >/dev/null && named -v | grep BIND.*9 > /dev/null } || { echo test_sresolv: there is no BIND 9 named in you path, skipping exit 77 } if eval $ipv6 then # Figure out nice IPv6 address for us ns=`ip addr ls | awk ' /^[0-9]:/ { up = ($3 ~ /UP/) && ($3 !~ /LOOPBACK/); } /inet6 fe80::/ { next; } # no link-local up && $1 ~ /inet6/ { sub(/\/.*$/, "", $2); print $2; exit 0; }'` # Nothing found, use localnode ::1 if test -z "$ns"; then ns=::1 ; fi listen6="listen-on-v6 port $port { any; };" else ns="127.0.0.1" listen4="listen-on port $port { 127.0.0.1; };" fi # # Set up configuration. First, nice tmpdir # t=${TMPDIR:-/tmp}/sofia-sip-sresolv-$USER-$$ mkdir $t || exit 77 # Main resolv.conf (with primary nameserver not answering) cat > $t/resolv.conf < $t/error.conf < $t/named.conf <&2 ; if fgrep -i -e SELINUX=enforcing /etc/selinux/config >/dev/null 2>&1 ; then echo $0: perhaps you have to disable SELinux protection for named elif test -d /etc/apparmor.d ; then echo $0: perhaps you have to disable apparmor protection for named else echo $0: perhaps you have to disable apparmor or SELinux fi exit 77 } kill_named () { kill `cat $t/named.pid` rm $t/named.conf $t/resolv.conf $t/error.conf $t/named.pid 2>/dev/null rmdir $t } trap kill_named EXIT # export SOFIA_DEBUG=9 $VALGRIND ./test_sresolv "$@" - $t/resolv.conf $t/error.conf || exit 1 exit 0