aboutsummaryrefslogtreecommitdiffstats
path: root/tools/validate-diameter-xml.sh
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2018-10-17 12:22:17 +0200
committerJeff Morriss <jeff.morriss.ws@gmail.com>2018-10-17 15:02:42 +0000
commitca50195f1148b855c9fd788725dba77aa4b08315 (patch)
tree23b0337dda61f617bb24cd4f7ed3dbdad7f505fc /tools/validate-diameter-xml.sh
parent3d6bf1fe00a0eff48ddd83af3e3c0c18b65d6afd (diff)
validate-diameter-xml.sh: do not hard-code temporary directory
In the event that validation fails, the hard-coded temporary directory would remain present. Use of a fixed hard-coded directory also prevents concurrent runs. Change-Id: I29f09dc004b1ab3578b4a9c51ea7e1a5b526159f Reviewed-on: https://code.wireshark.org/review/30231 Reviewed-by: Jeff Morriss <jeff.morriss.ws@gmail.com>
Diffstat (limited to 'tools/validate-diameter-xml.sh')
-rwxr-xr-xtools/validate-diameter-xml.sh15
1 files changed, 9 insertions, 6 deletions
diff --git a/tools/validate-diameter-xml.sh b/tools/validate-diameter-xml.sh
index 3fad9c8632..36b6fb2976 100755
--- a/tools/validate-diameter-xml.sh
+++ b/tools/validate-diameter-xml.sh
@@ -37,24 +37,27 @@ then
exit 1
fi
+if ! tmpdir=$(mktemp -d); then
+ echo "Could not create temporary directory" >&2
+ exit 1
+fi
+trap 'rm -rf "$tmpdir"' EXIT
+
# First edit all the AVP names that start with "3GPP" to indicate "TGPP".
# XML doesn't allow ID's to start with a digit but:
# 1) We don't *really* care if it's valid XML
# 2) (but) we do want to use xmllint to find problems
# 3) (and) users see the AVP names. Showing them "TGPP" instead of "3GPP"
# is annoying enough to warrant this extra work.
-mkdir /tmp/diameter || exit 1
-cp diameter/dictionary.dtd /tmp/diameter || exit 1
+cp diameter/dictionary.dtd "$tmpdir" || exit 1
for f in diameter/*.xml
do
- sed 's/name="3GPP/name="TGPP/g' $f > /tmp/$f || exit 1
+ sed 's/name="3GPP/name="TGPP/g' "$f" > "$tmpdir/${f##*/}" || exit 1
done
-xmllint --noout --noent --postvalid /tmp/diameter/dictionary.xml &&
+xmllint --noout --noent --postvalid "$tmpdir/dictionary.xml" &&
echo "Diameter dictionary is (mostly) valid XML."
-rm -rf /tmp/diameter
-
#
# Editor modelines - https://www.wireshark.org/tools/modelines.html
#