tty-ask-password-agent: don't open terminal multiple times

We already have the terminal open, hence pass the fd we got to
ask_password_tty(), so that it doesn't have to reopen it a second time.

This is mostly an optimization, but it has the nice benefit of making us
independent from RLIMIT_NOFILE issues and so on, as we don't need to
allocate another fd needlessly.
This commit is contained in:
Lennart Poettering
2018-02-14 00:11:16 +01:00
parent 088dcd8e41
commit daa557208d
5 changed files with 12 additions and 9 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ static void ask_password(void) {
int r;
_cleanup_free_ char *ret;
r = ask_password_tty("hello?", "da key", 0, 0, NULL, &ret);
r = ask_password_tty(-1, "hello?", "da key", 0, 0, NULL, &ret);
assert(r >= 0);
log_info("Got %s", ret);