improve handling of trailing dots in dnssec-keymgr and dnssec-coverage

- mishandling of trailing dots caused bad behavior with the
  root zone or names like "example.com."
- fixing this exposed an error in dnssec-coverage caused the
  wrong return value if there were KSK errors but no ZSK errors
- incidentally silenced the dnssec-keygen output in the coverage
  system test

(cherry picked from commit 1ccf4e6c16)
This commit is contained in:
Evan Hunt
2019-01-21 13:12:26 -08:00
parent 0c2ba7d303
commit 4f06d65e38
7 changed files with 69 additions and 45 deletions

View File

@@ -188,6 +188,9 @@ def parse_args():
if args.filename and len(args.zone) > 1:
fatal("ERROR: -f can only be used with one zone.")
# strip trailing dots
args.zone = [x[:-1] for x in args.zone if len(x) > 1 and x[-1] == '.']
# convert from time arguments to seconds
try:
if args.maxttl:
@@ -251,7 +254,7 @@ def main():
print("PHASE 1--Loading keys to check for internal timing problems")
try:
kd = keydict(path=args.path, zone=args.zone, keyttl=args.keyttl)
kd = keydict(path=args.path, zones=args.zone, keyttl=args.keyttl)
except Exception as e:
fatal('ERROR: Unable to build key dictionary: ' + str(e))

View File

@@ -73,7 +73,7 @@ class eventlist:
kok = self.checkzone(z, "KSK", until, output)
if not no_zsk and z in self._Z.keys():
found = True
kok = self.checkzone(z, "ZSK", until, output)
zok = self.checkzone(z, "ZSK", until, output)
if not found:
output("ERROR: No key events found")

View File

@@ -49,15 +49,18 @@ class keydict:
self._keydict[key.name][key.alg][key.keyid] = key
def readone(self, path, zone):
match='K' + zone + '.+*.private'
if not zone.endswith('.'):
zone += '.'
match='K' + zone + '+*.private'
files = glob.glob(os.path.join(path, match))
found = False
for infile in files:
key = dnskey(infile, path, self._defttl)
if key.name != zone: # shouldn't ever happen
if key.fullname != zone: # shouldn't ever happen
continue
self._keydict[key.name][key.alg][key.keyid] = key
keyname=key.name if zone != '.' else '.'
self._keydict[keyname][key.alg][key.keyid] = key
found = True
return found