Skip to content

Commit

Permalink
Fix tpm2_capabilities.py always return success while no tpm tool or…
Browse files Browse the repository at this point in the history
… chip installed (Bugfix) (#846)

* In the tpm2_capabilities.py there is no specific return value from raise SystemExit, this makes the test cases com.canonical.certification::clevis-encrypt-tpm2/detect-rsa-capabilities and com.canonical.certification::clevis-encrypt-tpm2/detect-ecc-capabilities passed with no tpm-tools installed or no TPM chip found.

* Fix meaning error

* Update providers/tpm2/bin/tpm2_capabilities.py

---------

Co-authored-by: kissiel <[email protected]>
  • Loading branch information
2 people authored and tang-mm committed Dec 6, 2023
1 parent e4f51f7 commit 4f2fe57
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions providers/tpm2/bin/tpm2_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@
try:
algs_caps = subprocess.check_output(['tpm2_getcap', 'algorithms'])
pcrs_caps = subprocess.check_output(['tpm2_getcap', 'pcrs'])
except subprocess.CalledProcessError:
raise SystemExit
except (subprocess.CalledProcessError, FileNotFoundError):
raise SystemExit(
"Please make sure you have installed tpm-tools and tpm chip."
)


algs_list = yaml.load(algs_caps, Loader=yaml.FullLoader)
pcrs_list = yaml.load(pcrs_caps, Loader=yaml.FullLoader)
Expand Down

0 comments on commit 4f2fe57

Please sign in to comment.