tpm2-util: introduce tpm2_is_fully_supported()
This commit is contained in:
@@ -96,7 +96,7 @@ int verb_pcrs(int argc, char *argv[], void *userdata) {
|
||||
const char *alg = NULL;
|
||||
int r;
|
||||
|
||||
if (tpm2_support() != TPM2_SUPPORT_FULL)
|
||||
if (!tpm2_is_fully_supported())
|
||||
log_notice("System lacks full TPM2 support, not showing PCR state.");
|
||||
else {
|
||||
r = get_pcr_alg(&alg);
|
||||
|
||||
+1
-1
@@ -1005,7 +1005,7 @@ static int validate_stub(void) {
|
||||
bool found = false;
|
||||
int r;
|
||||
|
||||
if (tpm2_support() != TPM2_SUPPORT_FULL)
|
||||
if (!tpm2_is_fully_supported())
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "Sorry, system lacks full TPM2 support.");
|
||||
|
||||
r = efi_stub_get_features(&features);
|
||||
|
||||
@@ -369,7 +369,7 @@ static int run(int argc, char *argv[]) {
|
||||
event = TPM2_EVENT_PHASE;
|
||||
}
|
||||
|
||||
if (arg_graceful && tpm2_support() != TPM2_SUPPORT_FULL) {
|
||||
if (arg_graceful && !tpm2_is_fully_supported()) {
|
||||
log_notice("No complete TPM2 support detected, exiting gracefully.");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -886,7 +886,7 @@ int encrypt_credential_and_warn(
|
||||
* container tpm2_support will detect this, and will return a different flag combination of
|
||||
* TPM2_SUPPORT_FULL, effectively skipping the use of TPM2 when inside one. */
|
||||
|
||||
try_tpm2 = tpm2_support() == TPM2_SUPPORT_FULL;
|
||||
try_tpm2 = tpm2_is_fully_supported();
|
||||
if (!try_tpm2)
|
||||
log_debug("System lacks TPM2 support or running in a container, not attempting to use TPM2.");
|
||||
} else
|
||||
|
||||
@@ -462,6 +462,9 @@ typedef enum Tpm2Support {
|
||||
} Tpm2Support;
|
||||
|
||||
Tpm2Support tpm2_support(void);
|
||||
static inline bool tpm2_is_fully_supported(void) {
|
||||
return tpm2_support() == TPM2_SUPPORT_FULL;
|
||||
}
|
||||
|
||||
int verb_has_tpm2_generic(bool quiet);
|
||||
|
||||
|
||||
@@ -259,7 +259,7 @@ static int run(int argc, char *argv[]) {
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
if (arg_graceful && tpm2_support() != TPM2_SUPPORT_FULL) {
|
||||
if (arg_graceful && !tpm2_is_fully_supported()) {
|
||||
log_notice("No complete TPM2 support detected, exiting gracefully.");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user