chiark / gitweb /
s/seperate/separate/
[elogind.git] / src / ask-password-api.c
index 845517a6905d12004bf120ce85657f2bad60822b..af1b611f2727e1f57561dd7eb3ba0049e0deacbb 100644 (file)
@@ -132,7 +132,7 @@ int ask_password_tty(
                         r = -errno;
                         goto finish;
                 } else if (k == 0) {
-                        r = -ETIMEDOUT;
+                        r = -ETIME;
                         goto finish;
                 }
 
@@ -179,9 +179,6 @@ int ask_password_tty(
                 }
         }
 
-        if (ttyfd >= 0)
-                loop_write(ttyfd, "\n", 1, false);
-
         passphrase[p] = 0;
 
         if (!(*_passphrase = strdup(passphrase))) {
@@ -196,8 +193,11 @@ finish:
                 close_nointr_nofail(notify);
 
         if (ttyfd >= 0) {
-                if (reset_tty)
+
+                if (reset_tty) {
+                        loop_write(ttyfd, "\n", 1, false);
                         tcsetattr(ttyfd, TCSADRAIN, &old_termios);
+                }
 
                 close_nointr_nofail(ttyfd);
         }