]> mj.ucw.cz Git - nsc-5.git/blobdiff - bin/genzone
Names of key files should also have their /'s translated to @
[nsc-5.git] / bin / genzone
index 6c7bffc3e9d1da4672dae41db845999f2186ca43..432ad43e8e8cd6503d6b6b5f37c50300141f6360 100755 (executable)
@@ -15,8 +15,8 @@ shift
 CURRENT_HASH=$($M4 -DHASHING m4/nsc.m4 "$@" | md5sum | cut -d " " -f1)
 if [ -f khash/$Z ] ; then
        CURRENT_HASH=$CURRENT_HASH:$(cat khash/$Z)
-       if [ -f khash/resign-stamp ] ; then
-               CURRENT_HASH=$CURRENT_HASH:$(stat -c '%Y' khash/resign-stamp)
+       if [ -f keys/resign-stamp ] ; then
+               CURRENT_HASH=$CURRENT_HASH:$(stat -c '%Y' keys/resign-stamp)
        fi
 fi
 
@@ -28,13 +28,25 @@ else
        $M4 -DVERS=ver/$Z m4/nsc.m4 "$@" >zone/$Z.new
        NEWVER="$(sed -e "s/^;;; VERSION: //; t; d" zone/$Z.new)"
        if [ -f khash/$Z ] ; then
-               if ! dnssec-signzone -a -d dss -g -K keys/$Z $SIGNZONE_OPTIONS -f zone/$Z.signed -o $Z -S -3 - zone/$Z.new &>zone/$Z.tmp ; then
+               ORIGIN=$(grep '\$ORIGIN' zone/$Z.new | cut -d' ' -f2)
+               if [ -z "$ORIGIN" ] ; then
+                       echo >&2 "FATAL: Cannot establish zone origin for $Z"
+                       exit 1
+               fi
+               NSEC="-3 -"
+               if [ -f bin/dnssec-hacks ] ; then
+                       # Undocumented hook for hacks
+                       . bin/dnssec-hacks
+               fi
+               if ! dnssec-signzone -a -d tmp -K keys/$Z $SIGNZONE_OPTIONS -f zone/$Z.signed -o $ORIGIN -S $NSEC zone/$Z.new &>zone/$Z.tmp ; then
                        cat zone/$Z.tmp
-                       echo >&2 "FATAL: Signing failed"
+                       echo >&2 "FATAL: Cannot sign $Z"
                        exit 1
                fi
                rm -f zone/$Z.tmp
+               rm -f tmp/dsset-*
                mv zone/$Z.signed zone/$Z
+               rm -f zone/$Z.new
                SIGNED=" (signed)"
        else
                mv zone/$Z.new zone/$Z