From 8e02d1640d956183f8cad8f9d295d6bac6229ab6 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Thu, 19 Oct 2006 15:34:49 +0000 Subject: [PATCH] Suppress encryption key in 'dmsetup table' output unless --showkeys supplied. --- WHATS_NEW | 1 + dmsetup/dmsetup.c | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 7acc169..e5996a4 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 1.02.13 - ============================= + Suppress encryption key in 'dmsetup table' output unless --showkeys supplied. Version 1.02.12 - 13 Oct 2006 ============================= diff --git a/dmsetup/dmsetup.c b/dmsetup/dmsetup.c index e6d7941..c0eb863 100644 --- a/dmsetup/dmsetup.c +++ b/dmsetup/dmsetup.c @@ -114,6 +114,7 @@ enum { NOOPENCOUNT_ARG, NOTABLE_ARG, OPTIONS_ARG, + SHOWKEYS_ARG, TABLE_ARG, TARGET_ARG, TREE_ARG, @@ -211,7 +212,11 @@ static int _parse_file(struct dm_task *dmt, const char *file) r = 1; out: +#ifndef HAVE_GETLINE dm_free(buffer); +#else + free(buffer); +#endif if (file) fclose(fp); return r; @@ -915,7 +920,7 @@ static int _status(int argc, char **argv, void *data) void *next = NULL; uint64_t start, length; char *target_type = NULL; - char *params; + char *params, *c; int cmd; struct dm_names *names = (struct dm_names *) data; const char *name = NULL; @@ -978,6 +983,17 @@ static int _status(int argc, char **argv, void *data) if (data && !_switches[VERBOSE_ARG]) printf("%s: ", name); if (target_type) { + + /* Suppress encryption key */ + if (!_switches[SHOWKEYS_ARG] && + !strcmp(target_type, "crypt")) { + c = params; + while (*c && *c != ' ') + c++; + c++; + while (*c && *c != ' ') + *c++ = '0'; + } printf("%" PRIu64 " %" PRIu64 " %s %s", start, length, target_type, params); } @@ -1522,7 +1538,7 @@ static struct command _commands[] = { {"info", "[]", 0, 1, _info}, {"deps", "[]", 0, 1, _deps}, {"status", "[] [--target ]", 0, 1, _status}, - {"table", "[] [--target ]", 0, 1, _status}, + {"table", "[] [--target ] [--showkeys]", 0, 1, _status}, {"wait", " []", 0, 2, _wait}, {"mknodes", "[]", 0, 1, _mknodes}, {"targets", "", 0, 0, _targets}, @@ -1868,6 +1884,7 @@ static int _process_switches(int *argc, char ***argv) {"noopencount", 0, &ind, NOOPENCOUNT_ARG}, {"notable", 0, &ind, NOTABLE_ARG}, {"options", 1, &ind, OPTIONS_ARG}, + {"showkeys", 0, &ind, SHOWKEYS_ARG}, {"table", 1, &ind, TABLE_ARG}, {"target", 1, &ind, TARGET_ARG}, {"tree", 0, &ind, TREE_ARG}, @@ -1988,6 +2005,8 @@ static int _process_switches(int *argc, char ***argv) _switches[NOLOCKFS_ARG]++; if ((ind == NOOPENCOUNT_ARG)) _switches[NOOPENCOUNT_ARG]++; + if ((ind == SHOWKEYS_ARG)) + _switches[SHOWKEYS_ARG]++; if ((ind == TABLE_ARG)) { _switches[TABLE_ARG]++; _table = optarg; -- 2.43.5