From 8cf86745c21a6052d86c46009a4841c0c345e19e Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Thu, 13 May 2010 13:31:30 +0000 Subject: [PATCH] Do not print encryption key in message debug output. --- WHATS_NEW_DM | 1 + libdm/ioctl/libdm-iface.c | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index b93dee908..c40b8b73d 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.48 - ================================= + Do not print encryption key in message debug output (cryptsetup luksResume). Version 1.02.47 - 30th April 2010 ================================= diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c index f34892cc2..68cd74d42 100644 --- a/libdm/ioctl/libdm-iface.c +++ b/libdm/ioctl/libdm-iface.c @@ -1102,7 +1102,7 @@ int dm_task_set_newname(struct dm_task *dmt, const char *newname) int dm_task_set_message(struct dm_task *dmt, const char *message) { if (!(dmt->message = dm_strdup(message))) { - log_error("dm_task_set_message: strdup(%s) failed", message); + log_error("dm_task_set_message: strdup failed"); return 0; } @@ -1724,6 +1724,18 @@ no_match: return r; } +static const char *_sanitise_message(char *message) +{ + const char *sanitised_message = message ?: ""; + + /* FIXME: Check for whitespace variations. */ + /* This traps what cryptsetup sends us. */ + if (message && !strncasecmp(message, "key set", 7)) + sanitised_message = "key set"; + + return sanitised_message; +} + static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command, unsigned repeat_count) { @@ -1805,7 +1817,7 @@ static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command, dmt->no_flush ? 'N' : 'F', dmt->skip_lockfs ? "S " : "", dmt->query_inactive_table ? "I " : "", - dmt->sector, dmt->message ? dmt->message : "", + dmt->sector, _sanitise_message(dmt->message), dmi->data_size); #ifdef DM_IOCTLS if (ioctl(_control_fd, command, dmi) < 0) {