From: Remi Gacogne Date: Mon, 21 Jun 2021 16:30:14 +0000 (+0200) Subject: Credentials: Apply comments from code review X-Git-Tag: dnsdist-1.7.0-alpha1~12^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d78e47e35db6676530cee6ee9a3ce1d42e65f0e6;p=thirdparty%2Fpdns.git Credentials: Apply comments from code review --- diff --git a/pdns/credentials.cc b/pdns/credentials.cc index 8ece8743eb..2b1854d603 100644 --- a/pdns/credentials.cc +++ b/pdns/credentials.cc @@ -392,10 +392,6 @@ SensitiveData CredentialsHolder::readFromTerminal() { struct termios term; struct termios oterm; - memset(&term, 0, sizeof(term)); - term.c_lflag |= ECHO; - memset(&oterm, 0, sizeof(oterm)); - oterm.c_lflag |= ECHO; bool restoreTermSettings = false; int termAction = TCSAFLUSH; #ifdef TCSASOFT @@ -413,7 +409,9 @@ SensitiveData CredentialsHolder::readFromTerminal() } else { input = FDWrapper(dup(STDIN_FILENO)); + restoreTermSettings = false; } + FDWrapper output(open("/dev/tty", O_WRONLY)); if (int(output) == -1) { output = FDWrapper(dup(STDERR_FILENO)); @@ -450,12 +448,6 @@ SensitiveData CredentialsHolder::readFromTerminal() } } - if (!(term.c_lflag & ECHO)) { - if (write(output, "\n", 1) != 1) { - /* the compiler _really_ wants the result of write() to be checked.. */ - } - } - if (restoreTermSettings) { tcsetattr(input, termAction, &oterm); }