1#!/bin/sh 2# 3# Copyright (C) 2011, 2012 Internet Systems Consortium, Inc. ("ISC") 4# 5# Permission to use, copy, modify, and/or distribute this software for any 6# purpose with or without fee is hereby granted, provided that the above 7# copyright notice and this permission notice appear in all copies. 8# 9# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 10# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 11# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 12# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 13# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 14# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15# PERFORMANCE OF THIS SOFTWARE. 16 17# $Id$ 18 19SYSTEMTESTTOP=.. 20. $SYSTEMTESTTOP/conf.sh 21THISDIR=`pwd` 22CONFDIR="ns1" 23PLAINCONF="${THISDIR}/${CONFDIR}/named.plain" 24DIRCONF="${THISDIR}/${CONFDIR}/named.dirconf" 25PIPECONF="${THISDIR}/${CONFDIR}/named.pipeconf" 26SYMCONF="${THISDIR}/${CONFDIR}/named.symconf" 27PLAINFILE="named_log" 28DIRFILE="named_dir" 29PIPEFILE="named_pipe" 30SYMFILE="named_sym" 31PIDFILE="${THISDIR}/${CONFDIR}/named.pid" 32myRNDC="$RNDC -c ${THISDIR}/${CONFDIR}/rndc.conf" 33myNAMED="$NAMED -c ${THISDIR}/${CONFDIR}/named.conf -m record,size,mctx -T clienttest -d 99" 34 35# Stop the server and run through a series of tests with various config 36# files while controlling the stop/start of the server. 37# Have to stop the stock server because it uses "-g" 38# 39$PERL ../stop.pl . ns1 40 41cd $CONFDIR 42 43$myNAMED > /dev/null 2>&1 44 45if [ $? -ne 0 ] 46then 47 echo "I:failed to start $myNAMED" 48 echo "I:exit status: $status" 49 exit $status 50fi 51 52status=0 53 54echo "I:testing log file validity (only plain files allowed)" 55 56# First run with a known good config. 57echo > $PLAINFILE 58cp $PLAINCONF named.conf 59$myRNDC reconfig 60grep "reloading configuration failed" named.run > /dev/null 2>&1 61if [ $? -ne 0 ] 62then 63 echo "I: testing plain file succeeded" 64else 65 echo "I: testing plain file failed (unexpected)" 66 echo "I:exit status: 1" 67 exit 1 68fi 69 70# Now try directory, expect failure 71echo "I: testing directory as log file" 72echo > named.run 73mkdir -p $DIRFILE >/dev/null 2>&1 74if [ $? -eq 0 ] 75then 76 cp $DIRCONF named.conf 77 echo > named.run 78 $myRNDC reconfig 79 grep "invalid file" named.run > /dev/null 2>&1 80 if [ $? -ne 0 ] 81 then 82 echo "I: testing directory as file succeeded (UNEXPECTED)" 83 echo "I:exit status: 1" 84 exit 1 85 else 86 echo "I: testing directory as log file failed (expected)" 87 fi 88else 89 echo "I: skipping directory test (unable to create directory)" 90fi 91 92# Now try pipe file, expect failure 93echo "I: testing pipe file as log file" 94echo > named.run 95mkfifo $PIPEFILE >/dev/null 2>&1 96if [ $? -eq 0 ] 97then 98 cp $PIPECONF named.conf 99 echo > named.run 100 $myRNDC reconfig 101 grep "invalid file" named.run > /dev/null 2>&1 102 if [ $? -ne 0 ] 103 then 104 echo "I: testing pipe file as log file succeeded (UNEXPECTED)" 105 echo "I:exit status: 1" 106 exit 1 107 else 108 echo "I: testing pipe file as log file failed (expected)" 109 fi 110else 111 echo "I: skipping pipe test (unable to create pipe)" 112fi 113 114# Now try symlink file to plain file, expect success 115echo "I: testing symlink to plain file as log file" 116# Assume success 117status=0 118echo > named.run 119echo > $PLAINFILE 120ln -s $PLAINFILE $SYMFILE >/dev/null 2>&1 121if [ $? -eq 0 ] 122then 123 cp $SYMCONF named.conf 124 $myRNDC reconfig 125 echo > named.run 126 grep "reloading configuration failed" named.run > /dev/null 2>&1 127 if [ $? -ne 0 ] 128 then 129 echo "I: testing symlink to plain file succeeded" 130 else 131 echo "I: testing symlink to plain file failed (unexpected)" 132 echo "I:exit status: 1" 133 exit 1 134 fi 135else 136 echo "I: skipping symlink test (unable to create symlink)" 137fi 138 139echo "I:exit status: $status" 140exit $status 141