]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journald: use the "driver" transport for logging a refused connection
authorEvgeny Vereshchagin <evvers@ya.ru>
Sun, 21 Oct 2018 03:21:36 +0000 (03:21 +0000)
committerLennart Poettering <lennart@poettering.net>
Tue, 23 Oct 2018 17:36:52 +0000 (19:36 +0200)
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.

src/journal/journald-stream.c

index 502bd6f51bb9e8cf58da7699924ae18f733a5281..9ddcbb9d9d7b694607e39b0f7adabe61ca7809bf 100644 (file)
@@ -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;
         }