:
# NAME:
#	chkorigin - check there are no $ORIGIN RRs
#
# DESCRIPTION:
#	
# AUTHOR:
#	Simon J. Gerraty <sjg@crufty.net>

# RCSid:
#	$Id: chkorigin,v 1.8 2022/10/10 00:44:51 sjg Exp $
#
#	@(#) Copyright (c) 1997-2022 Simon J. Gerraty.
#
#	This file is provided in the hope that it will
#	be of use.  There is absolutely NO WARRANTY.
#	Permission to copy, redistribute or otherwise
#	use this file is hereby granted provided that 
#	the above copyright notice and this notice are
#	left intact. 
#      
#	Please send copies of changes and bug-fixes to:
#	sjg@crufty.net
#

Myname=chkorigin

. debug.sh

DebugOn

(
ests=0
for f in $*
do
	test -f $f || continue
	case "$f" in
	*.db|*.rev)
		# its sjg's new layout, there should be 0 $ORIGIN RRs
		n=`grep -ci '\$ORIGIN' $f`
		if test $n -gt 0; then
			grep -ni '\$ORIGIN' $f /dev/null 
			ests=1
		fi
		;;
	esac
done
if test $ests != 0; then
	echo "Multiple \$ORIGIN RRs can lead to data being hidden by subsequent zone loads."
	# never tell people not to do something, 
	# without suggesting a better way...
	echo "\$INCLUDE <file> <origin>"
	echo "Is a much safer way of temporarily changing the origin."
fi
exit $ests
) >&2
