From: Brett Holman Date: Sat, 20 Jan 2024 01:43:26 +0000 (-0700) Subject: Force dumplease to parse stdin X-Git-Tag: v10.0.9~24 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=25806878c9975dd769e2e193eae22f470ef4c71a;p=thirdparty%2Fdhcpcd.git Force dumplease to parse stdin Checking if data exists in the stdin buffer via an ioctl is unreliable. Allow a user to pass '-' to force stdin parsing. This provides a fix that will allow "no interfaces" to still mean "dump all interfaces". Fixes #285 --- diff --git a/src/dhcpcd.c b/src/dhcpcd.c index a94dbdac..84b4d8f1 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -29,7 +29,6 @@ static const char dhcpcd_copyright[] = "Copyright (c) 2006-2023 Roy Marples"; #include -#include #include #include #include @@ -2278,8 +2277,10 @@ printpidfile: #ifndef SMALL if (ctx.options & DHCPCD_DUMPLEASE && - ioctl(fileno(stdin), FIONREAD, &i, sizeof(i)) == 0 && - i > 0) + i > 0 && + ctx.ifc == 1 && + strlen(ctx.ifv[0]) == 1 && + ctx.ifv[0][0] == '-') { ctx.options |= DHCPCD_FORKED; /* pretend child process */ #ifdef PRIVSEP