Skip to content

Option 1: Workaround for broken stdin logic#288

Closed
holmanb wants to merge 1 commit intoNetworkConfiguration:masterfrom
holmanb:holmanb/force-stdin-when-no-interface
Closed

Option 1: Workaround for broken stdin logic#288
holmanb wants to merge 1 commit intoNetworkConfiguration:masterfrom
holmanb:holmanb/force-stdin-when-no-interface

Conversation

@holmanb
Copy link
Contributor

@holmanb holmanb commented Jan 20, 2024

This is my original proposal to fix #285. It just checks if there was an interface passed and then forces stdin parsing if no interface was passed.

After I implemented it, I read the docs and realized that when no interface was passed, and no stdin is piped that in theory this means that all interfaces should be dumped:

-U, --dumplease [interface]
         Dumps the current lease for the interface to stdout.  If no interface is given then all
        interfaces are dumped.

Since this approach breaks the intended user interface, I originally assumed you didn't want it. However, after I implemented the second option I realized that this documented behavior that option 2 designs around is also broken.

Continued discusion of the options for #285 in the second PR.

Previous code used the non-existance of data in the input buffer to
determine whether to attempt parsing from stdin. This is racy, so
`dhcpcd -U < /path/to/lease` will sometimes fail:

  # dhcpcd --dumplease --ipv4only < /var/lib/dhcpcd/<iface>.lease
  dhcpcd is not running

 The fix uses the (non-)existance of an interface argument to indicate
 that dhcpcd should wait for data to arrive on stdin.

Fixes NetworkConfiguration#285
@rsmarples
Copy link
Member

Yes, we don't want this change of behavior. Your other approach is better even though it will break existing scripts that use it.

@rsmarples rsmarples closed this Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dhcpcd -U intermittently fails if stdin is connected to a pipe

2 participants