chiark / gitweb /
systemctl: shutdown agent explicitly so that it can reset the tty properly
[elogind.git] / src / ask-password-api.c
index cd663ae09ccc5712c7b019d0fafaa7f8676d5cd6..dd54fb6abf22a0680f0849b67fd31f138a5a180a 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;
                 }
 
@@ -180,7 +180,6 @@ int ask_password_tty(
         }
 
         if (ttyfd >= 0)
-                loop_write(ttyfd, "\n", 1, false);
 
         passphrase[p] = 0;
 
@@ -196,8 +195,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 +375,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;