From: Klearchos Chaloulos Date: Tue, 1 Dec 2015 17:29:59 +0000 (+0200) Subject: journal-remote: split-mode=host, remove port from journal filename X-Git-Tag: v229.1~1^2~93 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=6506aaf23c48fbc14720073bfeb3e477c37ffd97;p=elogind.git journal-remote: split-mode=host, remove port from journal filename When constructing the journal filename to store logs from a remote host, remove the port of the tcp connection, as the port will change with every reboot/connection loss between sender/reveiver machines. Having the port in the filename will cause a new journal file to be created for every reboot or connection loss. For the implementation, a new argument "bool include_port" is added to the getpeername_pretty() function. This is passed to the sockaddr_pretty() function. The value of the include_port argument is set to true in all calls of getpeername_pretty(), except for 2 calls in journal-remote.c, where it is set to false. --- diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c index 091789851..b2aee3894 100644 --- a/src/basic/socket-util.c +++ b/src/basic/socket-util.c @@ -611,7 +611,7 @@ int sockaddr_pretty(const struct sockaddr *_sa, socklen_t salen, bool translate_ return 0; } -int getpeername_pretty(int fd, char **ret) { +int getpeername_pretty(int fd, bool include_port, char **ret) { union sockaddr_union sa; socklen_t salen = sizeof(sa); int r; @@ -641,7 +641,7 @@ int getpeername_pretty(int fd, char **ret) { /* For remote sockets we translate IPv6 addresses back to IPv4 * if applicable, since that's nicer. */ - return sockaddr_pretty(&sa.sa, salen, true, true, ret); + return sockaddr_pretty(&sa.sa, salen, true, include_port, ret); } int getsockname_pretty(int fd, char **ret) {