summaryrefslogtreecommitdiff
path: root/src/journal/journald-stream.c
diff options
context:
space:
mode:
authorEvgeny Vereshchagin <evvers@ya.ru>2018-10-21 03:21:36 +0000
committerLennart Poettering <lennart@poettering.net>2018-10-23 19:36:52 +0200
commitc8758e726c58babdfd654c622c5524e029232787 (patch)
tree9f4cd488b316bc66644e3ff7f34c4d14d41f35b5 /src/journal/journald-stream.c
parent9e8b1ec08e8eb0b4611b7caf6adb8828feb32312 (diff)
downloadsystemd-c8758e726c58babdfd654c622c5524e029232787.tar.gz
journald: use the "driver" transport for logging a refused connection
Otherwise, these messages can end up in `/dev/null` when journald is run in containers as was shown in https://github.com/systemd/systemd/pull/10444#issuecomment-430927793.
Diffstat (limited to 'src/journal/journald-stream.c')
-rw-r--r--src/journal/journald-stream.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c
index 502bd6f51b..9ddcbb9d9d 100644
--- a/src/journal/journald-stream.c
+++ b/src/journal/journald-stream.c
@@ -610,7 +610,17 @@ static int stdout_stream_new(sd_event_source *es, int listen_fd, uint32_t revent
}
if (s->n_stdout_streams >= STDOUT_STREAMS_MAX) {
- log_warning("Too many stdout streams, refusing connection.");
+ struct ucred u;
+
+ r = getpeercred(fd, &u);
+
+ /* By closing fd here we make sure that the client won't wait too long for journald to
+ * gather all the data it adds to the error message to find out that the connection has
+ * just been refused.
+ */
+ fd = safe_close(fd);
+
+ server_driver_message(s, r < 0 ? 0 : u.pid, NULL, LOG_MESSAGE("Too many stdout streams, refusing connection."), NULL);
return 0;
}