diff options
author | Franck Bui <fbui@suse.com> | 2019-09-19 15:18:18 +0200 |
---|---|---|
committer | Franck Bui <fbui@suse.com> | 2019-10-05 08:08:24 +0200 |
commit | d325f2443eceb423a02b26852065a25ed21a992c (patch) | |
tree | 0f3044a0cfd9a3dac082979093ee5b3ff175b710 /src/tty-ask-password-agent | |
parent | 1503bcb12ec9ae775a0b3435c9f2dfdd5204e09e (diff) | |
download | systemd-d325f2443eceb423a02b26852065a25ed21a992c.tar.gz |
tty-ask-pwd-agent: give the possiblity to skip a password prompt
If multiple passwords are waiting the agent will prompt for each of them. Give
the possiblity to the user to skip some of them by pressing 'C-d'.
Diffstat (limited to 'src/tty-ask-password-agent')
-rw-r--r-- | src/tty-ask-password-agent/tty-ask-password-agent.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c index 72b04e6f0e..504ba9162d 100644 --- a/src/tty-ask-password-agent/tty-ask-password-agent.c +++ b/src/tty-ask-password-agent/tty-ask-password-agent.c @@ -417,6 +417,9 @@ static int process_one_password_file(const char *filename) { if (r < 0) return log_error_errno(r, "Failed to query password: %m"); + if (strv_isempty(passwords)) + return -ECANCELED; + r = send_passwords(socket_name, passwords); if (r < 0) return log_error_errno(r, "Failed to send: %m"); @@ -525,11 +528,20 @@ static int process_and_watch_password_files(void) { pollfd[FD_SIGNAL].events = POLLIN; for (;;) { + int timeout = -1; + r = process_password_files(); - if (r < 0) - log_error_errno(r, "Failed to process password: %m"); + if (r < 0) { + if (r == -ECANCELED) + /* Disable poll() timeout since at least one password has + * been skipped and therefore one file remains and is + * unlikely to trigger any events. */ + timeout = 0; + else + log_error_errno(r, "Failed to process password: %m"); + } - if (poll(pollfd, _FD_MAX, -1) < 0) { + if (poll(pollfd, _FD_MAX, timeout) < 0) { if (errno == EINTR) continue; |