tpm2-util: allow to control if legend and/or footer shown by tpm2_list_devices()

This commit is contained in:
Yu Watanabe
2024-12-12 15:21:16 +09:00
parent 9d8cb69e7f
commit 66d2c693ac
8 changed files with 11 additions and 9 deletions
+4 -2
View File
@@ -6165,7 +6165,7 @@ int tpm2_unseal_data(
}
#endif /* HAVE_TPM2 */
int tpm2_list_devices(void) {
int tpm2_list_devices(bool legend, bool quiet) {
#if HAVE_TPM2
_cleanup_(table_unrefp) Table *t = NULL;
_cleanup_closedir_ DIR *d = NULL;
@@ -6179,6 +6179,8 @@ int tpm2_list_devices(void) {
if (!t)
return log_oom();
(void) table_set_header(t, legend);
d = opendir("/sys/class/tpmrm");
if (!d) {
log_full_errno(errno == ENOENT ? LOG_DEBUG : LOG_ERR, errno, "Failed to open /sys/class/tpmrm: %m");
@@ -6224,7 +6226,7 @@ int tpm2_list_devices(void) {
}
}
if (table_isempty(t)) {
if (table_isempty(t) && !quiet) {
log_info("No suitable TPM2 devices found.");
return 0;
}
+1 -1
View File
@@ -385,7 +385,7 @@ static inline int tpm2_pcrlock_search_file(const char *path, FILE **ret_file, ch
#endif /* HAVE_TPM2 */
int tpm2_list_devices(void);
int tpm2_list_devices(bool legend, bool quiet);
int tpm2_find_device_auto(char **ret);
int tpm2_make_pcr_json_array(uint32_t pcr_mask, sd_json_variant **ret);