tpm2-util: allow to control if legend and/or footer shown by tpm2_list_devices()
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user