Skip to content

Commit

Permalink
Force dumplease to parse stdin
Browse files Browse the repository at this point in the history
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
  • Loading branch information
holmanb authored and rsmarples committed Jun 17, 2024
1 parent 127c0b7 commit 2580687
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/dhcpcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
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>
Expand Down Expand Up @@ -2278,8 +2277,10 @@ main(int argc, char **argv, char **envp)

#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
Expand Down

0 comments on commit 2580687

Please sign in to comment.