Option 2: Fix stdin parsing#289
Merged
rsmarples merged 1 commit intoNetworkConfiguration:masterfrom Jun 17, 2024
Merged
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
Contributor
Author
This was referenced Jan 20, 2024
rsmarples
reviewed
Feb 16, 2024
| if (ctx.options & DHCPCD_DUMPLEASE && | ||
| ioctl(fileno(stdin), FIONREAD, &i, sizeof(i)) == 0 && | ||
| i > 0) | ||
| i > 0 && |
Member
There was a problem hiding this comment.
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.
Member
|
You'll need to change dhcpcd.8.in as well to document the new requirement for dumping leases needing the |
Contributor
Author
|
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. |
Contributor
|
@holmanb Has this made any progress? |
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
--oneshotcall, 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