chiark / gitweb /
ratelimit: removed n_printed
[elogind.git] / src / ask-password-api.c
index cd663ae09ccc5712c7b019d0fafaa7f8676d5cd6..af1b611f2727e1f57561dd7eb3ba0049e0deacbb 100644 (file)
@@ -111,7 +111,7 @@ int ask_password_tty(
                         y = now(CLOCK_MONOTONIC);
 
                         if (y > until) {
-                                r = -ETIMEDOUT;
+                                r = -ETIME;
                                 goto finish;
                         }
 
@@ -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);
         }
@@ -373,7 +373,7 @@ int ask_password_agent(
                         goto finish;
                 }
 
-                if ((k = poll(pollfd, _FD_MAX, until-t/USEC_PER_MSEC)) < 0) {
+                if ((k = poll(pollfd, _FD_MAX, (until-t)/USEC_PER_MSEC)) < 0) {
 
                         if (errno == EINTR)
                                 continue;