From: Mark Andrews Date: Thu, 3 May 2012 06:10:24 +0000 (+1000) Subject: use -q when calling dig, quote the zone's name when calling dig and dnssec-dsfromkey X-Git-Tag: v9.10.0a1~1062^2~2 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=25e72ee350e423c81b1b48c7da6bce09cd4e678b;p=thirdparty%2Fbind9.git use -q when calling dig, quote the zone's name when calling dig and dnssec-dsfromkey --- diff --git a/bin/python/dnssec-checkds.py.in b/bin/python/dnssec-checkds.py.in index 0b29cb1d1f5..269f926ca20 100644 --- a/bin/python/dnssec-checkds.py.in +++ b/bin/python/dnssec-checkds.py.in @@ -19,6 +19,9 @@ import argparse import pprint import os +def shellquote(s): + return "'" + s.replace("'", "'\\''") + "'" + ############################################################################ # DSRR class: # Delegation Signer (DS) resource record @@ -143,7 +146,7 @@ class DLVRR: ############################################################################ def checkds(zone, masterfile = None): dslist=[] - fp=os.popen("%s +noall +answer -t ds %s" % (args.dig, zone)) + fp=os.popen("%s +noall +answer -t ds -q %s" % (args.dig, shellquote(zone))) for line in fp: dslist.append(DSRR(line)) dslist = sorted(dslist, key=lambda ds: (ds.keyid, ds.keyalg, ds.hashalg)) @@ -155,8 +158,9 @@ def checkds(zone, masterfile = None): fp = os.popen("%s -f %s %s " % (args.dsfromkey, masterfile, zone)) else: - fp = os.popen("%s +noall +answer -t dnskey %s | %s -f - %s" % - (args.dig, zone, args.dsfromkey, zone)) + fp = os.popen("%s +noall +answer -t dnskey -q %s | %s -f - %s" % + (args.dig, shellquote(zone), args.dsfromkey, + shellquote(zone))) for line in fp: dsklist.append(DSRR(line)) @@ -185,8 +189,8 @@ def checkds(zone, masterfile = None): ############################################################################ def checkdlv(zone, lookaside, masterfile = None): dlvlist=[] - fp=os.popen("%s +noall +answer -t dlv %s.%s" % - (args.dig, zone, lookaside)) + fp=os.popen("%s +noall +answer -t dlv -q %s" % + (args.dig, shellquote(zone + '.' + lookaside))) for line in fp: dlvlist.append(DLVRR(line, lookaside)) dlvlist = sorted(dlvlist, @@ -202,7 +206,8 @@ def checkdlv(zone, lookaside, masterfile = None): (args.dsfromkey, masterfile, lookaside, zone)) else: fp = os.popen("%s +noall +answer -t dnskey %s | %s -f - -l %s %s" - % (args.dig, zone, args.dsfromkey, lookaside, zone)) + % (args.dig, shellquote(zone), args.dsfromkey, + shellquote(lookaside), shellquote(zone))) for line in fp: dlvklist.append(DLVRR(line, lookaside))