mirror of
https://github.com/stefanberger/swtpm.git
synced 2026-02-04 21:19:14 +00:00
swtpm: Move TPMLIB_ChooseTPMVersion into capabilities_print_json
All callers to capabilities_print_json() call TPMLIB_ChooseTPMVersion right before. Move it into the function now and check the return code. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
f67607db26
commit
bf3f517539
@ -114,7 +114,7 @@ oom:
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
int capabilities_print_json(bool cusetpm)
|
||||
int capabilities_print_json(bool cusetpm, TPMLIB_TPMVersion tpmversion)
|
||||
{
|
||||
char *string = NULL;
|
||||
int ret = -1;
|
||||
@ -130,6 +130,11 @@ int capabilities_print_json(bool cusetpm)
|
||||
const char *nvram_backend_dir = "\"nvram-backend-dir\", ";
|
||||
const char *nvram_backend_file = "\"nvram-backend-file\"";
|
||||
|
||||
if (TPMLIB_ChooseTPMVersion(tpmversion) != TPM_SUCCESS) {
|
||||
logprintf(STDERR_FILENO, "Could not choose TPM version.\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = get_rsa_keysize_caps(&keysizecaps);
|
||||
if (ret < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -40,6 +40,8 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
int capabilities_print_json(bool cusetpm);
|
||||
#include <libtpms/tpm_library.h>
|
||||
|
||||
int capabilities_print_json(bool cusetpm, TPMLIB_TPMVersion tpmversion);
|
||||
|
||||
#endif /* SWTPM_CAPABILITIES_H */
|
||||
|
||||
@ -1616,8 +1616,7 @@ int swtpm_cuse_main(int argc, char **argv, const char *prgname, const char *ifac
|
||||
* Choose the TPM version so that getting/setting buffer size works.
|
||||
* Ignore failure, for backward compatibility when TPM 1.2 is disabled.
|
||||
*/
|
||||
TPMLIB_ChooseTPMVersion(tpmversion);
|
||||
ret = capabilities_print_json(true) ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
ret = capabilities_print_json(true, tpmversion) ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
||||
@ -432,8 +432,7 @@ int swtpm_main(int argc, char **argv, const char *prgname, const char *iface)
|
||||
* Choose the TPM version so that getting/setting buffer size works.
|
||||
* Ignore failure, for backward compatibility when TPM 1.2 is disabled.
|
||||
*/
|
||||
TPMLIB_ChooseTPMVersion(mlp.tpmversion);
|
||||
ret = capabilities_print_json(false);
|
||||
ret = capabilities_print_json(false, mlp.tpmversion);
|
||||
exit(ret ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@ -486,8 +486,7 @@ int swtpm_chardev_main(int argc, char **argv, const char *prgname, const char *i
|
||||
* Choose the TPM version so that getting/setting buffer size works.
|
||||
* Ignore failure, for backward compatibility when TPM 1.2 is disabled.
|
||||
*/
|
||||
TPMLIB_ChooseTPMVersion(mlp.tpmversion);
|
||||
ret = capabilities_print_json(false);
|
||||
ret = capabilities_print_json(false, mlp.tpmversion);
|
||||
exit(ret ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user