Merge commit 'origin/v3-2-test' into v3-2-stable
[ira/wip.git] / source3 / lib / replace / getpass.c
index 1d134615738e34a97b1910302d85e94d94769354..57e28eb981577594c2d8b6a0511fe2a21157f9ec 100644 (file)
@@ -21,6 +21,7 @@ not, see <http://www.gnu.org/licenses/>.  */
 #include "system/filesys.h"
 #include "system/wait.h"
 #include "system/terminal.h"
+#include "system/passwd.h"
 
 /*
  * Define additional missing types
@@ -184,7 +185,10 @@ char *rep_getpass(const char *prompt)
        buf[0] = 0;
        if (!gotintr) {
                in_fd = fileno(in);
-               fgets(buf, bufsize, in);
+               if (fgets(buf, bufsize, in) == NULL) {
+                       buf[0] = 0;
+                       return buf;
+               }
        }
        nread = strlen(buf);
        if (nread) {