diff options
author | Nathan Huff <nhuff@acm.org> | 2023-10-24 21:04:00 +0000 |
---|---|---|
committer | Matthew Seaman <matthew@FreeBSD.org> | 2023-10-24 21:08:41 +0000 |
commit | 959521fd0d960b4bf9938a2229f29959ee2f8fa3 (patch) | |
tree | 0e3e5cc343205740da8c5b0d909ec22427cd2ba8 | |
parent | 14dfdd508748cab7dfd27526ddd3e7bea2877e75 (diff) | |
download | ports-959521fd0d960b4bf9938a2229f29959ee2f8fa3.tar.gz ports-959521fd0d960b4bf9938a2229f29959ee2f8fa3.zip |
sysutils/rsyslog8: patch for forking issue due to close_range() call
Add patch from upstream:
https://github.com/rsyslog/rsyslog/commit/599b5c7524b76cfc73245206fcce1e2b4d955f21
After fork if the child process uses close_range to close open file
descriptors it has no way to exempt the parentPipeFD causing a failure
to signal successful startup to the parent process. This causes
failures on all systems that aren't Linux that implement close_range.
1. Loop through file descriptors between beginClose and
MAX(parentPipeFD,dbgGetDbglogFd()) making sure not to close those two
file descriptors.
2. Potentially use close_range to close all file descriptors above
MAX(parentPipeFD,dbgGetDbglogFd())
PR: 274509
Reported by: Helmut Ritter
Obtained from: https://github.com/rsyslog/rsyslog/pull/5254
-rw-r--r-- | sysutils/rsyslog8/Makefile | 4 | ||||
-rw-r--r-- | sysutils/rsyslog8/files/patch-tools_rsyslogd.c | 36 |
2 files changed, 37 insertions, 3 deletions
diff --git a/sysutils/rsyslog8/Makefile b/sysutils/rsyslog8/Makefile index 8df79aa1a249..a81c1ce7fae3 100644 --- a/sysutils/rsyslog8/Makefile +++ b/sysutils/rsyslog8/Makefile @@ -1,6 +1,6 @@ PORTNAME= rsyslog PORTVERSION= 8.2310.0 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= sysutils MASTER_SITES= http://www.rsyslog.com/files/download/rsyslog/ @@ -8,8 +8,6 @@ MAINTAINER= matthew@FreeBSD.org COMMENT= Syslogd supporting SQL, TCP, and TLS WWW= https://www.rsyslog.com/ -BROKEN= "Socket operation on non-socket" See PR 274509 - LICENSE= GPLv3 LGPL3 APACHE20 LICENSE_COMB= multi diff --git a/sysutils/rsyslog8/files/patch-tools_rsyslogd.c b/sysutils/rsyslog8/files/patch-tools_rsyslogd.c new file mode 100644 index 000000000000..a4fdaf7a965c --- /dev/null +++ b/sysutils/rsyslog8/files/patch-tools_rsyslogd.c @@ -0,0 +1,36 @@ +--- tools/rsyslogd.c.orig 2023-10-09 07:12:48 UTC ++++ tools/rsyslogd.c +@@ -460,19 +460,24 @@ prepareBackground(const int parentPipeFD) + /* try MacOS, FreeBSD */ + if(close_unneeded_open_files("/proc/fd", beginClose, parentPipeFD) != 0) { + /* did not work out, so let's close everything... */ +- const int endClose = getdtablesize(); +-# if defined(HAVE_CLOSE_RANGE) +- if(close_range(beginClose, endClose, 0) != 0) { ++ int endClose = (parentPipeFD > dbgGetDbglogFd()) ? parentPipeFD : dbgGetDbglogFd(); ++ for(int i = beginClose ; i <= endClose ; ++i) { ++ if((i != dbgGetDbglogFd()) && (i != parentPipeFD)) { ++ aix_close_it(i); /* AIXPORT */ ++ } ++ } ++ beginClose = endClose + 1; ++ endClose = getdtablesize(); ++#if defined(HAVE_CLOSE_RANGE) ++ if(close_range(beginClose, endClose, 0) !=0) { + dbgprintf("errno %d after close_range(), fallback to loop\n", errno); +-# endif ++#endif + for(int i = beginClose ; i <= endClose ; ++i) { +- if((i != dbgGetDbglogFd()) && (i != parentPipeFD)) { +- aix_close_it(i); /* AIXPORT */ +- } ++ aix_close_it(i); /* AIXPORT */ + } +-# if defined(HAVE_CLOSE_RANGE) ++#if defined(HAVE_CLOSE_RANGE) + } +-# endif ++#endif + } + } + seedRandomNumberForChild(); |