From: Michał Kępień Date: Wed, 13 Jun 2018 05:47:12 +0000 (+0200) Subject: Add helper functions for converting keyfile data into configuration sections X-Git-Tag: v9.13.2~41^2~2 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=2392b8bc7d706307cff6f59fa2b93b39d5749c11;p=thirdparty%2Fbind9.git Add helper functions for converting keyfile data into configuration sections Add a set of helper functions for system test scripts which enable converting key data from a set of keyfiles to either a "trusted-keys" section or a "managed-keys" section suitable for including in a resolver's configuration file. --- diff --git a/bin/tests/system/conf.sh.in b/bin/tests/system/conf.sh.in index 1e4f97d1069..4271f67c30c 100644 --- a/bin/tests/system/conf.sh.in +++ b/bin/tests/system/conf.sh.in @@ -254,6 +254,41 @@ digcomp() { # Useful functions in test scripts # +# keyfile_to_keys_section: helper function for keyfile_to_*_keys() which +# converts keyfile data into a configuration section using the supplied +# parameters +keyfile_to_keys_section() { + section_name=$1 + key_prefix=$2 + shift + shift + echo "$section_name {" + for keyname in $*; do + awk '!/^; /{ + printf "\t\""$1"\" " + printf "'"$key_prefix"'" + printf $4 " " $5 " " $6 " \"" + for (i=7; i<=NF; i++) printf $i + printf "\";\n" + }' $keyname.key + done + echo "};" +} + +# keyfile_to_trusted_keys: convert key data contained in the keyfile(s) +# provided to a "trusted-keys" section suitable for including in a +# resolver's configuration file +keyfile_to_trusted_keys() { + keyfile_to_keys_section "trusted-keys" "" $* +} + +# keyfile_to_managed_keys: convert key data contained in the keyfile(s) +# provided to a "managed-keys" section suitable for including in a +# resolver's configuration file +keyfile_to_managed_keys() { + keyfile_to_keys_section "managed-keys" "initial-key " $* +} + # nextpart: read everything that's been appended to a file since the # last time 'nextpart' was called. nextpart () { diff --git a/bin/tests/system/conf.sh.win32 b/bin/tests/system/conf.sh.win32 index 1e9c02d697a..07abc52d5aa 100644 --- a/bin/tests/system/conf.sh.win32 +++ b/bin/tests/system/conf.sh.win32 @@ -231,6 +231,41 @@ digcomp() { # Useful functions in test scripts # +# keyfile_to_keys_section: helper function for keyfile_to_*_keys() which +# converts keyfile data into a configuration section using the supplied +# parameters +keyfile_to_keys_section() { + section_name=$1 + key_prefix=$2 + shift + shift + echo "$section_name {" + for keyname in $*; do + awk '!/^; /{ + printf "\t\""$1"\" " + printf "'"$key_prefix"'" + printf $4 " " $5 " " $6 " \"" + for (i=7; i<=NF; i++) printf $i + printf "\";\n" + }' $keyname.key + done + echo "};" +} + +# keyfile_to_trusted_keys: convert key data contained in the keyfile(s) +# provided to a "trusted-keys" section suitable for including in a +# resolver's configuration file +keyfile_to_trusted_keys() { + keyfile_to_keys_section "trusted-keys" "" $* +} + +# keyfile_to_managed_keys: convert key data contained in the keyfile(s) +# provided to a "managed-keys" section suitable for including in a +# resolver's configuration file +keyfile_to_managed_keys() { + keyfile_to_keys_section "managed-keys" "initial-key " $* +} + # nextpart: read everything that's been appended to a file since the # last time 'nextpart' was called. nextpart () {