Fix replacement getpass. If we ^C at the prompt echo was left off.
authorJeremy Allison <jra@samba.org>
Fri, 9 May 2008 21:51:45 +0000 (14:51 -0700)
committerStefan Metzmacher <metze@samba.org>
Sun, 14 Sep 2008 16:19:59 +0000 (18:19 +0200)
Jeremy.
(cherry picked from commit e54c71954ae484fe4a4e195db33440490e78e256)

source/lib/replace/getpass.c

index 73333b902199b92d6627f2c1794124ebf7922ce8..0be618fc916cf21d6d7e6122d0ac847759ae6002 100644 (file)
@@ -187,10 +187,6 @@ char *rep_getpass(const char *prompt)
                in_fd = fileno(in);
                if (fgets(buf, bufsize, in) == NULL) {
                        buf[0] = 0;
-                       if (in && in != stdin) {
-                               fclose(in);
-                       }
-                       return buf;
                }
        }
        nread = strlen(buf);
@@ -201,8 +197,9 @@ char *rep_getpass(const char *prompt)
 
        /* Restore echoing.  */
        if (echo_off) {
-               if (gotintr && in_fd == -1)
+               if (gotintr && in_fd == -1) {
                        in = fopen ("/dev/tty", "w+");
+               }
                if (in != NULL)
                        tcsetattr (fileno (in), TCSANOW, &t);
        }