]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Credentials: Apply comments from code review
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 21 Jun 2021 16:30:14 +0000 (18:30 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 16 Sep 2021 12:12:28 +0000 (14:12 +0200)
pdns/credentials.cc

index 8ece8743eb2ac2d0ebefc6672a5b6dac9c9465ef..2b1854d603c7bd79f1e51ce1456af7994286c24c 100644 (file)
@@ -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);
   }