Showing with 15 additions and 9 deletions.
  1. +11 −8 lib/tpm2_options.c
  2. +1 −1 tools/aux/tpm2_rc_decode.c
  3. +3 −0 tools/tpm2_tool.c
19 changes: 11 additions & 8 deletions lib/tpm2_options.c
Expand Up @@ -327,16 +327,19 @@ tpm2_option_code tpm2_handle_options (int argc, char **argv, char **envp,
}
}

tcti_opts = tcti_get_opts(optarg);
/* Only init a TCTI if the tool needs it */
if (!tool_opts || !(tool_opts->flags & TPM2_OPTIONS_NO_SAPI)) {
tcti_opts = tcti_get_opts(optarg);

*tcti = tpm2_tcti_ldr_load(tcti_name, tcti_opts);
if (!*tcti) {
LOG_ERR("Unknown tcti, got: \"%s\"", tcti_name);
goto out;
}
*tcti = tpm2_tcti_ldr_load(tcti_name, tcti_opts);
if (!*tcti) {
LOG_ERR("Unknown tcti, got: \"%s\"", tcti_name);
goto out;
}

if (!flags->enable_errata) {
flags->enable_errata = !!getenv (TPM2TOOLS_ENV_ENABLE_ERRATA);
if (!flags->enable_errata) {
flags->enable_errata = !!getenv (TPM2TOOLS_ENV_ENABLE_ERRATA);
}
}

rc = tpm2_option_code_continue;
Expand Down
2 changes: 1 addition & 1 deletion tools/aux/tpm2_rc_decode.c
Expand Up @@ -74,7 +74,7 @@ static bool on_arg(int argc, char **argv) {
bool tpm2_tool_onstart(tpm2_options **opts) {

*opts = tpm2_options_new(NULL, 0, NULL, NULL, on_arg,
TPM2_OPTIONS_SHOW_USAGE);
TPM2_OPTIONS_SHOW_USAGE|TPM2_OPTIONS_NO_SAPI);

return *opts != NULL;
}
Expand Down
3 changes: 3 additions & 0 deletions tools/tpm2_tool.c
Expand Up @@ -146,6 +146,9 @@ int main(int argc, char *argv[], char *envp[]) {
TSS2_SYS_CONTEXT *sapi_context = NULL;
if (tcti) {
sapi_context = sapi_ctx_init(tcti);
if (!sapi_context) {
goto free_opts;
}
}

if (flags.enable_errata) {
Expand Down