case ARG_TPM2_DEVICE:
if (streq(optarg, "list"))
- return tpm2_list_devices();
+ return tpm2_list_devices(arg_legend, arg_quiet);
arg_tpm2_device = streq(optarg, "auto") ? NULL : optarg;
break;
_cleanup_free_ char *device = NULL;
if (streq(optarg, "list"))
- return tpm2_list_devices();
+ return tpm2_list_devices(/* legend = */ true, /* quiet = */ false);
if (arg_enroll_type >= 0 || arg_tpm2_device)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
_cleanup_free_ char *device = NULL;
if (streq(optarg, "list"))
- return tpm2_list_devices();
+ return tpm2_list_devices(/* legend = */ true, /* quiet = */ false);
if (!streq(optarg, "auto")) {
device = strdup(optarg);
_cleanup_free_ char *device = NULL;
if (streq(optarg, "list"))
- return tpm2_list_devices();
+ return tpm2_list_devices(/* legend = */ true, /* quiet = */ false);
if (!streq(optarg, "auto")) {
device = strdup(optarg);
_cleanup_free_ char *device = NULL;
if (streq(optarg, "list"))
- return tpm2_list_devices();
+ return tpm2_list_devices(/* legend = */ true, /* quiet = */ false);
if (!streq(optarg, "auto")) {
device = strdup(optarg);
}
#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;
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");
}
}
- if (table_isempty(t)) {
+ if (table_isempty(t) && !quiet) {
log_info("No suitable TPM2 devices found.");
return 0;
}
#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);
case ARG_TPM2_DEVICE:
if (streq(optarg, "list"))
- return tpm2_list_devices();
+ return tpm2_list_devices(/* legend = */ true, /* quiet = */ false);
if (free_and_strdup(&arg_tpm2_device, streq(optarg, "auto") ? NULL : optarg) < 0)
return log_oom();