-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option 2: Fix stdin parsing #289
Option 2: Fix stdin parsing #289
Conversation
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 NetworkConfiguration#285
@@ -2243,8 +2242,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 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why checking i > 0? I used to contain the number of bytes in STDIN, now it is undefined as you removed the ioctl which set it.
You'll need to change dhcpcd.8.in as well to document the new requirement for dumping leases needing the |
Thanks for the review @rsmarples. I'm busy now, but will try to get back to this PR in the next few weeks if possible. Otherwise I plan circle back to this after the next Ubuntu release. |
@holmanb Has this made any progress? |
This is my second fix #285. It checks if there was a single "interface" argument passed and if that argument value is
-
. If such an argument exists, then dhcpcd forcibly waits on stdin. This also removes the unreliable "check if the stdin buffer is full" semantics, which I don't think should break other use cases. Runningdhcpcd -U <interface>
will work just like it did before, by contacting the network manager[1]. I assume you prefer this fix over the first one I wrote, because that one breaks the "no interface means dump all interfaces" expectation, but I still offered both fixes for you to decide because that documented expectation also appears broken.[1] this requirement also seems like a bug when the lease file has already been acquired with a
--oneshot
call, but as long as we have some stable way across releases to parse a lease without the daemon running I guess I don't care strongly if that one of these gets fixed