From 9fa1de965a0954dcb6d855ebe0513077515a0daa Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Tue, 25 Mar 2014 11:05:23 +0100 Subject: Add more password agent information Add an (optional) "Id" key in the password agent .ask files. The Id is supposed to be a simple string in ":" form which is used to provide more information on what the requested passphrase is to be used for (which e.g. allows an agent to only react to cryptsetup requests). (v2: rebased, fixed indentation, escape name, use strappenda) --- src/cryptsetup/cryptsetup.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/cryptsetup') diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c index 9b9074c52a..a647a94e6e 100644 --- a/src/cryptsetup/cryptsetup.c +++ b/src/cryptsetup/cryptsetup.c @@ -257,6 +257,8 @@ static int get_password(const char *name, usec_t until, bool accept_cached, char int r; char **p; _cleanup_free_ char *text = NULL; + _cleanup_free_ char *escaped_name = NULL; + char *id; assert(name); assert(passwords); @@ -264,7 +266,13 @@ static int get_password(const char *name, usec_t until, bool accept_cached, char if (asprintf(&text, "Please enter passphrase for disk %s!", name) < 0) return log_oom(); - r = ask_password_auto(text, "drive-harddisk", until, accept_cached, passwords); + escaped_name = cescape(name); + if (!escaped_name) + return log_oom(); + + id = strappenda("cryptsetup:", escaped_name); + + r = ask_password_auto(text, "drive-harddisk", id, until, accept_cached, passwords); if (r < 0) { log_error("Failed to query password: %s", strerror(-r)); return r; @@ -278,7 +286,9 @@ static int get_password(const char *name, usec_t until, bool accept_cached, char if (asprintf(&text, "Please enter passphrase for disk %s! (verification)", name) < 0) return log_oom(); - r = ask_password_auto(text, "drive-harddisk", until, false, &passwords2); + id = strappenda("cryptsetup-verification:", escaped_name); + + r = ask_password_auto(text, "drive-harddisk", id, until, false, &passwords2); if (r < 0) { log_error("Failed to query verification password: %s", strerror(-r)); return r; -- cgit v1.2.3-54-g00ecf