chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
def: centralize definition of default timeout in one place
[elogind.git]
/
src
/
ask-password-api.c
diff --git
a/src/ask-password-api.c
b/src/ask-password-api.c
index f43075e60194e5a563d345f217109198479fb97c..9c3dad965e03099bd509ef9b3e379fc84ed6db82 100644
(file)
--- a/
src/ask-password-api.c
+++ b/
src/ask-password-api.c
@@
-179,9
+179,6
@@
int ask_password_tty(
}
}
}
}
- if (ttyfd >= 0)
- loop_write(ttyfd, "\n", 1, false);
-
passphrase[p] = 0;
if (!(*_passphrase = strdup(passphrase))) {
passphrase[p] = 0;
if (!(*_passphrase = strdup(passphrase))) {
@@
-196,8
+193,11
@@
finish:
close_nointr_nofail(notify);
if (ttyfd >= 0) {
close_nointr_nofail(notify);
if (ttyfd >= 0) {
- if (reset_tty)
+
+ if (reset_tty) {
+ loop_write(ttyfd, "\n", 1, false);
tcsetattr(ttyfd, TCSADRAIN, &old_termios);
tcsetattr(ttyfd, TCSADRAIN, &old_termios);
+ }
close_nointr_nofail(ttyfd);
}
close_nointr_nofail(ttyfd);
}
@@
-223,7
+223,7
@@
static int create_socket(char **name) {
zero(sa);
sa.un.sun_family = AF_UNIX;
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;
if (bind(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path)) < 0) {
r = -errno;
@@
-265,18
+265,22
@@
int ask_password_agent(
_FD_MAX
};
_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;
char *socket_name = NULL;
int socket_fd = -1, signal_fd = -1;
char final[sizeof(temp)] = "";
int fd = -1, r;
FILE *f = NULL;
char *socket_name = NULL;
int socket_fd = -1, signal_fd = -1;
- sigset_t mask;
+ sigset_t mask
, oldmask
;
struct pollfd pollfd[_FD_MAX];
assert(_passphrases);
struct pollfd pollfd[_FD_MAX];
assert(_passphrases);
- mkdir_p("/dev/.systemd/ask-password", 0755);
+ assert_se(sigemptyset(&mask) == 0);
+ sigset_add_many(&mask, SIGINT, SIGTERM, -1);
+ assert_se(sigprocmask(SIG_BLOCK, &mask, &oldmask) == 0);
+
+ 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");
if ((fd = mkostemp(temp, O_CLOEXEC|O_CREAT|O_WRONLY)) < 0) {
log_error("Failed to create password file: %m");
@@
-294,10
+298,6
@@
int ask_password_agent(
fd = -1;
fd = -1;
- assert_se(sigemptyset(&mask) == 0);
- sigset_add_many(&mask, SIGINT, SIGTERM, -1);
- assert_se(sigprocmask(SIG_SETMASK, &mask, NULL) == 0);
-
if ((signal_fd = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC)) < 0) {
log_error("signalfd(): %m");
r = -errno;
if ((signal_fd = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC)) < 0) {
log_error("signalfd(): %m");
r = -errno;
@@
-493,6
+493,8
@@
finish:
if (final[0])
unlink(final);
if (final[0])
unlink(final);
+ assert_se(sigprocmask(SIG_SETMASK, &oldmask, NULL) == 0);
+
return r;
}
return r;
}