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
static const char dhcpcd_copyright[] = "Copyright (c) 2006-2023 Roy Marples";
#include <sys/file.h>
-#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#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