chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
unit: consider all cgroups in the name=systemd hierarchy, even when the user has...
[elogind.git]
/
src
/
tty-ask-password-agent.c
diff --git
a/src/tty-ask-password-agent.c
b/src/tty-ask-password-agent.c
index dcf4b332b3beed1c87a1ef51d37e20d99d5c8a92..b620aa6ee3e5dece2d3ef4dd684f959272287f6d 100644
(file)
--- a/
src/tty-ask-password-agent.c
+++ b/
src/tty-ask-password-agent.c
@@
-261,7
+261,6
@@
static int parse_password(const char *filename, char **wall) {
FILE *f;
int r;
FILE *f;
int r;
- usec_t n;
assert(filename);
assert(filename);
@@
-279,14
+278,22
@@
static int parse_password(const char *filename, char **wall) {
goto finish;
}
goto finish;
}
- if (!socket_name
|| not_after <= 0
) {
+ if (!socket_name) {
log_error("Invalid password file %s", filename);
r = -EBADMSG;
goto finish;
}
log_error("Invalid password file %s", filename);
r = -EBADMSG;
goto finish;
}
- n = now(CLOCK_MONOTONIC);
- if (n > not_after) {
+ if (not_after > 0) {
+ if (now(CLOCK_MONOTONIC) > not_after) {
+ r = 0;
+ goto finish;
+ }
+ }
+
+ if (pid > 0 &&
+ kill(pid, 0) < 0 &&
+ errno == ESRCH) {
r = 0;
goto finish;
}
r = 0;
goto finish;
}
@@
-369,10
+376,15
@@
static int parse_password(const char *filename, char **wall) {
release_terminal();
}
release_terminal();
}
- asprintf(&packet, "+%s", password);
- free(password);
+ packet_length = 1+strlen(password)+1;
+ if (!(packet = new(char, packet_length)))
+ r = -ENOMEM;
+ else {
+ packet[0] = '+';
+ strcpy(packet+1, password);
+ }
-
packet_length = strlen(packet
);
+
free(password
);
}
if (r == -ETIME || r == -ENOENT) {
}
if (r == -ETIME || r == -ENOENT) {
@@
-382,17
+394,10
@@
static int parse_password(const char *filename, char **wall) {
}
if (r < 0) {
}
if (r < 0) {
-
log_error("Failed to query password: %s", strerror(-r));
goto finish;
}
log_error("Failed to query password: %s", strerror(-r));
goto finish;
}
- if (!packet) {
- log_error("Out of memory");
- r = -ENOMEM;
- goto finish;
- }
-
if ((socket_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) {
log_error("socket(): %m");
r = -errno;
if ((socket_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) {
log_error("socket(): %m");
r = -errno;
@@
-428,7
+433,8
@@
static int wall_tty_block(void) {
int fd, r;
dev_t devnr;
int fd, r;
dev_t devnr;
- if ((r = get_ctty_devnr(&devnr)) < 0)
+ r = get_ctty_devnr(0, &devnr);
+ if (r < 0)
return -r;
if (asprintf(&p, "/run/systemd/ask-password-block/%u:%u", major(devnr), minor(devnr)) < 0)
return -r;
if (asprintf(&p, "/run/systemd/ask-password-block/%u:%u", major(devnr), minor(devnr)) < 0)