X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fask-password-api.c;h=0b2e9ad84810749553c46a3556c615f0de88ee07;hp=cd663ae09ccc5712c7b019d0fafaa7f8676d5cd6;hb=a8f11321c209830a35edd0357e8def5d4437d854;hpb=21bc923aa35d455cdef1607eb7022608c705c9f3 diff --git a/src/ask-password-api.c b/src/ask-password-api.c index cd663ae09..0b2e9ad84 100644 --- a/src/ask-password-api.c +++ b/src/ask-password-api.c @@ -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); } @@ -223,7 +223,7 @@ static int create_socket(char **name) { zero(sa); sa.un.sun_family = AF_UNIX; - snprintf(sa.un.sun_path, sizeof(sa.un.sun_path)-1, "/dev/.systemd/ask-password/sck.%llu", random_ull()); + snprintf(sa.un.sun_path, sizeof(sa.un.sun_path)-1, "/dev/.run/systemd/ask-password/sck.%llu", random_ull()); if (bind(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path)) < 0) { r = -errno; @@ -265,7 +265,7 @@ int ask_password_agent( _FD_MAX }; - char temp[] = "/dev/.systemd/ask-password/tmp.XXXXXX"; + char temp[] = "/dev/.run/systemd/ask-password/tmp.XXXXXX"; char final[sizeof(temp)] = ""; int fd = -1, r; FILE *f = NULL; @@ -276,7 +276,7 @@ int ask_password_agent( assert(_passphrases); - mkdir_p("/dev/.systemd/ask-password", 0755); + mkdir_p("/dev/.run/systemd/ask-password", 0755); if ((fd = mkostemp(temp, O_CLOEXEC|O_CREAT|O_WRONLY)) < 0) { log_error("Failed to create password file: %m"); @@ -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;