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
fix: retain and restore terminal mode on Windows #4369
Conversation
Thanks, looks reasonable. Just need someone affected to confirm it fixes it. |
@@ -50,6 +50,9 @@ func init() { | |||
// Main implements the main function of the caddy command. | |||
// Call this if Caddy is to be the main() of your program. | |||
func Main() { | |||
if err := resetTerminalState(); err != nil { |
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.
Doesn't this disable the terminal change altogether? Wouldn't that break the dependency -- if it's being used? I assume it was enabled for a reason.
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.
My understanding of their code is they're using it because they have interactive TUI. Running go mod why
against the offending dependency shows:
2021-10-04 22:57:09 ~/projects/caddyserver/caddy git:(fix-4251) ✗ $ go mod why go.step.sm/cli-utils/ui
# go.step.sm/cli-utils/ui
github.com/caddyserver/caddy/v2/modules/caddypki
github.com/smallstep/certificates/authority
github.com/smallstep/certificates/kms
github.com/smallstep/certificates/kms/softkms
go.step.sm/cli-utils/ui
softkms
uses the go.step.sm/cli-utils/ui
package to prompt for password. The only password prompt Caddy has is on run of caddy trust
which uses github.com/FiloSottile/mkcert
which doesn't use go.step.sm/cli-utils/ui
for the prompt.
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.
Ok, just making sure.
Thanks for the patch; as discussed in Slack, we're going to wait on this until we can determine if upstream can fix it first. |
Great, looks like this was fixed upstream (thank you @maraino!) so I will close this PR. Thank you very much for making it Mohammed! |
Given this is caused by a dependency, not possible to remove the dependency, and not easy to excise the code from the dependency due to their needs, I'm attempting to retain the original terminal mode bits and to be set before exit. Bitwise OR operations aren't reversible, so retaining the original state is the other option.
Fixes #4251