public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/dhcpcd] f45: Fix daemonising broken by RLIMIT_NOFILE of 0 on Linux (rhbz#2547780)
@ 2026-10-30 7:19 Martin Osvald
0 siblings, 0 replies; only message in thread
From: Martin Osvald @ 2026-10-30 7:19 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/dhcpcd
Branch : f45
Commit : 051387c2a373f65cabd86cafbb38e6140ac70f50
Author : Martin Osvald <mosvald@redhat.com>
Date : 2026-10-08T07:35:20+02:00
Stats : +42/-0 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/dhcpcd/c/051387c2a373f65cabd86cafbb38e6140ac70f50?branch=f45
Log:
Fix daemonising broken by RLIMIT_NOFILE of 0 on Linux (rhbz#2547780)
---
diff --git a/dhcpcd-fix-RLIMIT_NOFILE.patch b/dhcpcd-fix-RLIMIT_NOFILE.patch
new file mode 100644
index 0000000..98c30dc
--- /dev/null
+++ b/dhcpcd-fix-RLIMIT_NOFILE.patch
@@ -0,0 +1,37 @@
+From 3f44ca223a810815c425accc64949b25261cc96d Mon Sep 17 00:00:00 2001
+From: Jorik Cronenberg <jorik.cronenberg@suse.com>
+Date: Mon, 14 Sep 2026 13:23:07 +0200
+Subject: [PATCH] privsep: Fix daemonising broken by RLIMIT_NOFILE of 0
+
+RLIMIT_NOFILE of 0 makes dup2(2) fail EBADF on linux, so daemonising
+could no longer redirect stdout/stderr to /dev/null and readers of a
+piped stdio never saw EOF. Cap at STDERR_FILENO + 1; as 0-2 are always
+open, no new fd can be allocated.
+---
+ src/privsep.c | 10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+diff --git a/src/privsep.c b/src/privsep.c
+index f35502e0..1cab3ce9 100644
+--- a/src/privsep.c
++++ b/src/privsep.c
+@@ -159,10 +159,18 @@ ps_dropprivs(struct dhcpcd_ctx *ctx)
+ struct rlimit rzero = { .rlim_cur = 0, .rlim_max = 0 };
+
+ #ifndef __sun /* RLIMIT_NOFILE and ppoll don't mix */
++#ifdef __linux__
++ /* Linux dup2(2) fails EBADF if RLIMIT_NOFILE is 0 */
++ struct rlimit rnofile = { .rlim_cur = STDERR_FILENO + 1,
++ .rlim_max = STDERR_FILENO + 1 };
++#else
++ struct rlimit rnofile = { .rlim_cur = 0, .rlim_max = 0 };
++#endif
++
+ /* Prohibit new files, sockets, etc
+ * The control proxy *does* need to create new fd's via accept(2). */
+ if (ctx->ps_ctl == NULL || ctx->ps_ctl->psp_pid != getpid()) {
+- if (setrlimit(RLIMIT_NOFILE, &rzero) == -1)
++ if (setrlimit(RLIMIT_NOFILE, &rnofile) == -1)
+ logerr("setrlimit RLIMIT_NOFILE");
+ }
+ #endif
diff --git a/dhcpcd.spec b/dhcpcd.spec
index 4e3d950..5b803d4 100644
--- a/dhcpcd.spec
+++ b/dhcpcd.spec
@@ -17,6 +17,11 @@ Source5: systemd-sysusers.conf
Source6: systemd-tmpfiles.conf
Source7: 99-prefixlen
+# https://bugzilla.redhat.com/show_bug.cgi?id=2547780
+# Fix daemonising broken by RLIMIT_NOFILE of 0 on Linux
+# https://github.com/NetworkConfiguration/dhcpcd/pull/733
+Patch0: dhcpcd-fix-RLIMIT_NOFILE.patch
+
BuildRequires: gcc
BuildRequires: systemd-rpm-macros
BuildRequires: chrony
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-30 7:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-30 7:19 [rpms/dhcpcd] f45: Fix daemonising broken by RLIMIT_NOFILE of 0 on Linux (rhbz#2547780) Martin Osvald
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox