Only exit with 0 if we actually verified it

This commit is contained in:
Juhani Krekelä 2018-09-01 23:43:10 +03:00
parent c027f5fe53
commit 5d71ff9d73
1 changed files with 10 additions and 0 deletions

View File

@ -75,6 +75,7 @@ def main():
infiles = args.infiles
# Check
any_verified = True
for path in infiles:
# Remove the directory and the extension from the file
name = os.path.basename(path)
@ -86,6 +87,9 @@ def main():
success, fail, same_fingerprint = check_fingerprint.check(entries, args.host, port, fingerprint)
if len(success) > 0:
any_verified = True
for match_host, match_port, match_comment in success:
# Use for display the same normalzed format as internally
# We do .decode() here, as it produces bytes
@ -104,6 +108,12 @@ def main():
for _, _, same_fingerprint_comment in same_fingerprint:
print('[same fingerprint] %s: (unknown host): %s' % (name, same_fingerprint_comment))
# Exit with 0 only if it was verified
if any_verified:
sys.exit(0)
else:
sys.exit(2)
if __name__ == '__main__':
try:
main()