diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 15:51:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 15:51:13 +0000 |
commit | 0b1bec3993aefdd84011471101b612683047b75a (patch) | |
tree | 6d81ecbfbb1e360bd5c5831e70953b7796c88051 /parse-root-anchors.sh | |
parent | Initial commit. (diff) | |
download | dns-root-data-0b1bec3993aefdd84011471101b612683047b75a.tar.xz dns-root-data-0b1bec3993aefdd84011471101b612683047b75a.zip |
Adding upstream version 2023010101.upstream/2023010101
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'parse-root-anchors.sh')
-rwxr-xr-x | parse-root-anchors.sh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/parse-root-anchors.sh b/parse-root-anchors.sh new file mode 100755 index 0000000..eb1696b --- /dev/null +++ b/parse-root-anchors.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +unset ZONE KTAG ALGO DTYPE DIGEST EXPIRES BEGINS + +export IFS="=" +xml2 | while read -r KEY VAL; do + case "$KEY" in + "/TrustAnchor/Zone") ZONE="$VAL";; + "/TrustAnchor/KeyDigest/KeyTag") KTAG="$VAL";; + "/TrustAnchor/KeyDigest/Algorithm") ALGO="$VAL";; + "/TrustAnchor/KeyDigest/DigestType") DTYPE="$VAL";; + "/TrustAnchor/KeyDigest/@validUntil") EXPIRES="$VAL";; + "/TrustAnchor/KeyDigest/@validFrom") BEGINS="$VAL";; + "/TrustAnchor/KeyDigest/Digest") + DIGEST="$(echo "$VAL" | tr "[:upper:]" "[:lower:]")" + if [ -z "$ZONE" ] || [ -z "$KTAG" ] || [ -z "$ALGO" ] || [ -z "$DTYPE" ]; then + echo "Missing some KeyDigest parameter" + exit 1 + fi + if [ -n "$EXPIRES" ] && [ "$(date +%s -d "$EXPIRES")" -lt "$(date +%s)" ]; then + printf 'Digest %s expired on %s\n' "$DIGEST" "$EXPIRES" >&2 + elif [ -n "$BEGINS" ] && [ "$(date +%s -d "$BEGINS")" -gt "$(date +%s)" ]; then + printf 'Digest %s will not be valid until %s\n' "$DIGEST" "$BEGINS" >&2 + else + printf "%s IN DS %s %s %s %s\n" "$ZONE" "$KTAG" "$ALGO" "$DTYPE" "$DIGEST" + fi + unset KTAG ALGO DTYPE DIGEST EXPIRES BEGINS + ;; + esac +done +exit 0 |