summaryrefslogtreecommitdiff
path: root/src/shared
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/shared
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/shared')
-rw-r--r--src/shared/ask-password-api.c9
-rw-r--r--src/shared/ask-password-api.h6
2 files changed, 11 insertions, 4 deletions
diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c
index eb40995010..c3c78b69fb 100644
--- a/src/shared/ask-password-api.c
+++ b/src/shared/ask-password-api.c
@@ -298,6 +298,7 @@ fail:
int ask_password_agent(
const char *message,
const char *icon,
+ const char *id,
usec_t until,
bool accept_cached,
char ***_passphrases) {
@@ -373,6 +374,9 @@ int ask_password_agent(
if (icon)
fprintf(f, "Icon=%s\n", icon);
+ if (id)
+ fprintf(f, "Id=%s\n", id);
+
fflush(f);
if (ferror(f)) {
@@ -537,7 +541,8 @@ finish:
return r;
}
-int ask_password_auto(const char *message, const char *icon, usec_t until, bool accept_cached, char ***_passphrases) {
+int ask_password_auto(const char *message, const char *icon, const char *id,
+ usec_t until, bool accept_cached, char ***_passphrases) {
assert(message);
assert(_passphrases);
@@ -556,5 +561,5 @@ int ask_password_auto(const char *message, const char *icon, usec_t until, bool
*_passphrases = l;
return r;
} else
- return ask_password_agent(message, icon, until, accept_cached, _passphrases);
+ return ask_password_agent(message, icon, id, until, accept_cached, _passphrases);
}
diff --git a/src/shared/ask-password-api.h b/src/shared/ask-password-api.h
index 288a0f48cf..3839a2df0f 100644
--- a/src/shared/ask-password-api.h
+++ b/src/shared/ask-password-api.h
@@ -25,6 +25,8 @@
int ask_password_tty(const char *message, usec_t until, const char *flag_file, char **_passphrase);
-int ask_password_agent(const char *message, const char *icon, usec_t until, bool accept_cached, char ***_passphrases);
+int ask_password_agent(const char *message, const char *icon, const char *id,
+ usec_t until, bool accept_cached, char ***_passphrases);
-int ask_password_auto(const char *message, const char *icon, usec_t until, bool accept_cached, char ***_passphrases);
+int ask_password_auto(const char *message, const char *icon, const char *id,
+ usec_t until, bool accept_cached, char ***_passphrases);