mirror of
https://github.com/systemd/systemd.git
synced 2025-02-07 05:57:46 +03:00
tpm2-util: allow to control if legend and/or footer shown by tpm2_list_devices()
This commit is contained in:
parent
9d8cb69e7f
commit
66d2c693ac
@ -911,7 +911,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
|
||||
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;
|
||||
|
@ -493,7 +493,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
_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),
|
||||
|
@ -295,7 +295,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
_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);
|
||||
|
@ -131,7 +131,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
_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);
|
||||
|
@ -8160,7 +8160,7 @@ static int parse_argv(int argc, char *argv[], X509 **ret_certificate, EVP_PKEY *
|
||||
_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);
|
||||
|
@ -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);
|
||||
|
@ -91,7 +91,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
|
||||
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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user