summaryrefslogtreecommitdiffstats
path: root/src/cryptenroll/cryptenroll-password.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cryptenroll/cryptenroll-password.c')
-rw-r--r--src/cryptenroll/cryptenroll-password.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/src/cryptenroll/cryptenroll-password.c b/src/cryptenroll/cryptenroll-password.c
index c35b609..a9bd8a1 100644
--- a/src/cryptenroll/cryptenroll-password.c
+++ b/src/cryptenroll/cryptenroll-password.c
@@ -38,9 +38,8 @@ int load_volume_key_password(
return log_error_errno(r, "Password from environment variable $PASSWORD did not work: %m");
} else {
AskPasswordFlags ask_password_flags = ASK_PASSWORD_PUSH_CACHE|ASK_PASSWORD_ACCEPT_CACHED;
- _cleanup_free_ char *question = NULL, *disk_path = NULL;
+ _cleanup_free_ char *question = NULL, *id = NULL, *disk_path = NULL;
unsigned i = 5;
- const char *id;
question = strjoin("Please enter current passphrase for disk ", cd_node, ":");
if (!question)
@@ -50,7 +49,17 @@ int load_volume_key_password(
if (!disk_path)
return log_oom();
- id = strjoina("cryptsetup:", disk_path);
+ id = strjoin("cryptenroll:", disk_path);
+ if (!id)
+ return log_oom();
+
+ AskPasswordRequest req = {
+ .message = question,
+ .icon = "drive-harddisk",
+ .id = id,
+ .keyring = "cryptenroll",
+ .credential = "cryptenroll.passphrase",
+ };
for (;;) {
_cleanup_strv_free_erase_ char **passwords = NULL;
@@ -59,10 +68,7 @@ int load_volume_key_password(
return log_error_errno(SYNTHETIC_ERRNO(ENOKEY),
"Too many attempts, giving up.");
- r = ask_password_auto(
- question, "drive-harddisk", id, "cryptenroll", "cryptenroll.passphrase", USEC_INFINITY,
- ask_password_flags,
- &passwords);
+ r = ask_password_auto(&req, USEC_INFINITY, ask_password_flags, &passwords);
if (r < 0)
return log_error_errno(r, "Failed to query password: %m");
@@ -105,9 +111,8 @@ int enroll_password(
if (r < 0)
return log_error_errno(r, "Failed to acquire password from environment: %m");
if (r == 0) {
- _cleanup_free_ char *disk_path = NULL;
+ _cleanup_free_ char *disk_path = NULL, *id = NULL;
unsigned i = 5;
- const char *id;
assert_se(node = crypt_get_device_name(cd));
@@ -117,7 +122,16 @@ int enroll_password(
if (!disk_path)
return log_oom();
- id = strjoina("cryptsetup:", disk_path);
+ id = strjoin("cryptenroll-new:", disk_path);
+ if (!id)
+ return log_oom();
+
+ AskPasswordRequest req = {
+ .icon = "drive-harddisk",
+ .id = id,
+ .keyring = "cryptenroll",
+ .credential = "cryptenroll.new-passphrase",
+ };
for (;;) {
_cleanup_strv_free_erase_ char **passwords = NULL, **passwords2 = NULL;
@@ -131,7 +145,9 @@ int enroll_password(
if (!question)
return log_oom();
- r = ask_password_auto(question, "drive-harddisk", id, "cryptenroll", "cryptenroll.new-passphrase", USEC_INFINITY, 0, &passwords);
+ req.message = question;
+
+ r = ask_password_auto(&req, USEC_INFINITY, /* flags= */ 0, &passwords);
if (r < 0)
return log_error_errno(r, "Failed to query password: %m");
@@ -142,7 +158,9 @@ int enroll_password(
if (!question)
return log_oom();
- r = ask_password_auto(question, "drive-harddisk", id, "cryptenroll", "cryptenroll.new-passphrase", USEC_INFINITY, 0, &passwords2);
+ req.message = question;
+
+ r = ask_password_auto(&req, USEC_INFINITY, /* flags= */ 0, &passwords2);
if (r < 0)
return log_error_errno(r, "Failed to query password: %m");