1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-22 08:58:47 +00:00

sysutils/rsyslog8: patch for forking issue due to close_range() call

Add patch from upstream:

599b5c7524

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
This commit is contained in:
Nathan Huff 2023-10-24 22:04:00 +01:00 committed by Matthew Seaman
parent 14dfdd5087
commit 959521fd0d
2 changed files with 37 additions and 3 deletions

View File

@ -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

View File

@ -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();