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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user