]> granicus.if.org Git - sudo/commitdiff
remove bogus flush of stderr
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 6 Feb 1998 19:05:19 +0000 (19:05 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 6 Feb 1998 19:05:19 +0000 (19:05 +0000)
spew prompt before turning off echo.  Seems to fix a weird problem where
if sudo complained about a bogus stamp file the user would sometimes
not have a chance to enter a password

tgetpass.c

index f8c950485a53a7cabd1ca12ed6e2d4817e161ab1..cc17b9cf38a73d2291a88ecf4c7b2411feb8ab5d 100644 (file)
@@ -137,37 +137,13 @@ char * tgetpass(prompt, timeout, user, host)
     if ((input = fopen(_PATH_TTY, "r+")) == NULL) {
        input = stdin;
        output = stderr;
-       (void) fflush(output);
     } else {
        output = input;
     }
 
     /*
-     * turn off echo
+     * print the prompt
      */
-#ifdef HAVE_TERMIOS_H
-    (void) tcgetattr(fileno(input), &term);
-    if ((echo = (term.c_lflag & ECHO))) {
-       term.c_lflag &= ~ECHO;
-       (void) tcsetattr(fileno(input), TCSAFLUSH|TCSASOFT, &term);
-    }
-#else
-#ifdef HAVE_TERMIO_H
-    (void) ioctl(fileno(input), TCGETA, &term);
-    if ((echo = (term.c_lflag & ECHO))) {
-       term.c_lflag &= ~ECHO;
-       (void) ioctl(fileno(input), TCSETA, &term);
-    }
-#else
-    (void) ioctl(fileno(input), TIOCGETP, &ttyb);
-    if ((echo = (ttyb.sg_flags & ECHO))) {
-       ttyb.sg_flags &= ~ECHO;
-       (void) ioctl(fileno(input), TIOCSETP, &ttyb);
-    }
-#endif /* HAVE_TERMIO_H */
-#endif /* HAVE_TERMIOS_H */
-
-    /* print the prompt */
     if (prompt) {
        p = (char *) prompt;
        do {
@@ -194,6 +170,31 @@ char * tgetpass(prompt, timeout, user, host)
        (void) rewind(output);
     }
 
+    /*
+     * turn off echo
+     */
+#ifdef HAVE_TERMIOS_H
+    (void) tcgetattr(fileno(input), &term);
+    if ((echo = (term.c_lflag & ECHO))) {
+       term.c_lflag &= ~ECHO;
+       (void) tcsetattr(fileno(input), TCSAFLUSH|TCSASOFT, &term);
+    }
+#else
+#ifdef HAVE_TERMIO_H
+    (void) ioctl(fileno(input), TCGETA, &term);
+    if ((echo = (term.c_lflag & ECHO))) {
+       term.c_lflag &= ~ECHO;
+       (void) ioctl(fileno(input), TCSETA, &term);
+    }
+#else
+    (void) ioctl(fileno(input), TIOCGETP, &ttyb);
+    if ((echo = (ttyb.sg_flags & ECHO))) {
+       ttyb.sg_flags &= ~ECHO;
+       (void) ioctl(fileno(input), TIOCSETP, &ttyb);
+    }
+#endif /* HAVE_TERMIO_H */
+#endif /* HAVE_TERMIOS_H */
+
     /*
      * Timeout of <= 0 means no timeout
      */