summaryrefslogtreecommitdiff
path: root/src/cryptsetup/cryptsetup.c
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2014-03-25 11:05:23 +0100
committerLennart Poettering <lennart@poettering.net>2014-04-24 09:23:54 +0200
commit9fa1de965a0954dcb6d855ebe0513077515a0daa (patch)
tree7c6c8133d726a7d379361c4541fe15cb20bd7342 /src/cryptsetup/cryptsetup.c
parent0d522a7a0547982eae9ab1b5971e4bed9c2fbc7c (diff)
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 "<subsystem>:<target>" 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)
Diffstat (limited to 'src/cryptsetup/cryptsetup.c')
-rw-r--r--src/cryptsetup/cryptsetup.c14
1 files changed, 12 insertions, 2 deletions
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;