From 25e72ee350e423c81b1b48c7da6bce09cd4e678b Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 3 May 2012 16:10:24 +1000 Subject: [PATCH] use -q when calling dig, quote the zone's name when calling dig and dnssec-dsfromkey --- bin/python/dnssec-checkds.py.in | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/bin/python/dnssec-checkds.py.in b/bin/python/dnssec-checkds.py.in index 0b29cb1d1f..269f926ca2 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))