chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e0e1580
)
ask-password: properly handle multiple pending passwords when writing wall msg
author
Lennart Poettering
<lennart@poettering.net>
Tue, 26 Oct 2010 02:45:27 +0000
(
04:45
+0200)
committer
Lennart Poettering
<lennart@poettering.net>
Tue, 26 Oct 2010 02:45:27 +0000
(
04:45
+0200)
src/tty-ask-password-agent.c
patch
|
blob
|
history
diff --git
a/src/tty-ask-password-agent.c
b/src/tty-ask-password-agent.c
index 8a9330d4acbbc09d7929df14a09270d913328ffb..5b429398c091a008a6306ede14120c55f42ea8fb 100644
(file)
--- a/
src/tty-ask-password-agent.c
+++ b/
src/tty-ask-password-agent.c
@@
-200,7
+200,7
@@
finish:
return r;
}
return r;
}
-static int parse_password(const char *filename) {
+static int parse_password(const char *filename
, char **wall
) {
char *socket_name = NULL, *message = NULL, *packet = NULL;
uint64_t not_after = 0;
unsigned pid = 0;
char *socket_name = NULL, *message = NULL, *packet = NULL;
uint64_t not_after = 0;
unsigned pid = 0;
@@
-248,11
+248,13
@@
static int parse_password(const char *filename) {
if (arg_action == ACTION_LIST)
printf("'%s' (PID %u)\n", message, pid);
else if (arg_action == ACTION_WALL) {
if (arg_action == ACTION_LIST)
printf("'%s' (PID %u)\n", message, pid);
else if (arg_action == ACTION_WALL) {
- char *wall;
+ char *
_
wall;
- if (asprintf(&wall,
- "Password entry required for \'%s\' (PID %u).\r\n"
+ if (asprintf(&
_
wall,
+ "
%s%s
Password entry required for \'%s\' (PID %u).\r\n"
"Please enter password with the systemd-tty-password-agent tool!",
"Please enter password with the systemd-tty-password-agent tool!",
+ *wall ? *wall : "",
+ *wall ? "\r\n\r\n" : "",
message,
pid) < 0) {
log_error("Out of memory");
message,
pid) < 0) {
log_error("Out of memory");
@@
-260,8
+262,8
@@
static int parse_password(const char *filename) {
goto finish;
}
goto finish;
}
-
r = utmp_wall(
wall);
-
free(wall)
;
+
free(*
wall);
+
*wall = _wall
;
} else {
union {
struct sockaddr sa;
} else {
union {
struct sockaddr sa;
@@
-346,6
+348,7
@@
static int show_passwords(void) {
while ((de = readdir(d))) {
char *p;
int q;
while ((de = readdir(d))) {
char *p;
int q;
+ char *wall;
if (de->d_type != DT_REG)
continue;
if (de->d_type != DT_REG)
continue;
@@
-362,10
+365,16
@@
static int show_passwords(void) {
goto finish;
}
goto finish;
}
- if ((q = parse_password(p)) < 0)
+ wall = NULL;
+ if ((q = parse_password(p, &wall)) < 0)
r = q;
free(p);
r = q;
free(p);
+
+ if (wall) {
+ utmp_wall(wall);
+ free(wall);
+ }
}
finish:
}
finish: