From 9b5e3797b18ccf3efa167d4d8563ed54b5cffe84 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Tue, 25 Jun 2019 15:03:04 +0200 Subject: [PATCH] Fis status command to display only specific device types. Cryptsetup, veritysetup and integrity setup should ignore other device mappings in status command (it should display only basic type information). --- src/cryptsetup.c | 4 ++++ src/integritysetup.c | 1 + src/veritysetup.c | 11 ++++++----- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/cryptsetup.c b/src/cryptsetup.c index 0ce426ab..ce73e876 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -707,6 +707,10 @@ static int action_status(void) log_std(" type: %s\n", crypt_get_type(cd) ?: "n/a"); + /* Print only CRYPT type devices */ + if (!crypt_get_cipher(cd)) + goto out; + r = crypt_get_active_device(cd, action_argv[0], &cad); if (r < 0) goto out; diff --git a/src/integritysetup.c b/src/integritysetup.c index 27bf0970..f8722cfc 100644 --- a/src/integritysetup.c +++ b/src/integritysetup.c @@ -392,6 +392,7 @@ static int action_status(int arg) if (r < 0) goto out; + /* Print only INTEGRITY (and LUKS2 with integrity) info */ r = crypt_get_integrity_info(cd, &ip); if (r < 0) goto out; diff --git a/src/veritysetup.c b/src/veritysetup.c index 9a02c5b3..f23d8c17 100644 --- a/src/veritysetup.c +++ b/src/veritysetup.c @@ -257,22 +257,23 @@ static int action_status(int arg) ci == CRYPT_BUSY ? " and is in use" : ""); r = crypt_init_by_name_and_header(&cd, action_argv[0], NULL); - if (r < 0 || !crypt_get_type(cd)) + if (r < 0) goto out; - log_std(" type: %s\n", crypt_get_type(cd)); + log_std(" type: %s\n", crypt_get_type(cd) ?: "n/a"); r = crypt_get_active_device(cd, action_argv[0], &cad); if (r < 0) goto out; - log_std(" status: %s\n", - cad.flags & CRYPT_ACTIVATE_CORRUPTED ? "corrupted" : "verified"); - + /* Print only VERITY type devices */ r = crypt_get_verity_info(cd, &vp); if (r < 0) goto out; + log_std(" status: %s\n", + cad.flags & CRYPT_ACTIVATE_CORRUPTED ? "corrupted" : "verified"); + log_std(" hash type: %u\n", vp.hash_type); log_std(" data block: %u\n", vp.data_block_size); log_std(" hash block: %u\n", vp.hash_block_size);