diff options
author | Xiang Fan <sfanxiang@gmail.com> | 2018-10-24 18:34:04 +0800 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-10-31 18:26:58 +0100 |
commit | c7b7d74e81bae65ffef38f46dd6abf0b8a9c3d4f (patch) | |
tree | 2e99111cfda17bbfcd6f213871cc3a33adfbd81d /src/test/test-ask-password-api.c | |
parent | 45313bd9211d456b8e27486ab9032572ce6743bd (diff) | |
download | systemd-c7b7d74e81bae65ffef38f46dd6abf0b8a9c3d4f.tar.gz |
ask-password: check keyring in ask_password_tty and ask_password_agent
A race condition happens when calling ask_password_auto() multiple times
to unlock several disks on boot and effectively no password caching is
utilized. This patch fixes it by polling the cache when waiting for
the password.
Diffstat (limited to 'src/test/test-ask-password-api.c')
-rw-r--r-- | src/test/test-ask-password-api.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/test/test-ask-password-api.c b/src/test/test-ask-password-api.c index ffd6da80fe..23b06be19b 100644 --- a/src/test/test-ask-password-api.c +++ b/src/test/test-ask-password-api.c @@ -3,15 +3,17 @@ #include "alloc-util.h" #include "ask-password-api.h" #include "log.h" +#include "strv.h" static void ask_password(void) { int r; - _cleanup_free_ char *ret; + _cleanup_strv_free_ char **ret = NULL; r = ask_password_tty(-1, "hello?", "da key", 0, 0, NULL, &ret); assert(r >= 0); + assert(strv_length(ret) == 1); - log_info("Got %s", ret); + log_info("Got %s", *ret); } int main(int argc, char **argv) { |