Skip to content
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

Prevent interactive prompts during git fetch #397

Merged
merged 1 commit into from
May 2, 2018

Conversation

mafredri
Copy link
Collaborator

@mafredri mafredri commented Apr 28, 2018

We set the shell into MONITOR mode to prevent password prompts from hijacking the TTY. If the command is suspended we know it's trying something not nice. So we kill it.

This seems a bit crazy, but at least it does not seem to affect performance (relatively). I also have found no other way to work around these issues.

Although we already set:

export GIT_SSH_COMMAND="${GIT_SSH_COMMAND:-"ssh"} -o BatchMode=yes"

It is not sufficient. For example, when a SSH configuration entry contains the ProxyJump option it will usually invoke a new instance of ssh which does not obey the BatchMode option we specified.

I tried both zsh 4.3.17 and 5.0.2 to be sure it doesn't break easily...

Fixes #373.

// ping @davidtwco

@davidtwco
Copy link

This does fix #373 as far as I can tell. However, it doesn't seem to solve #366.

@mafredri
Copy link
Collaborator Author

Thanks for the testing @davidtwco! Disappointed it does not help with pinentry, too bad I can't debug it :(.

We set the shell into MONITOR mode to prevent password prompts from
hijacking the TTY. If the command is suspended we know it's trying
something not nice. So we kill it.

This seems a bit crazy, but at least it does not seem to affect
performance (relatively). I also have found no other way to work around
these issues.

Although we already set:

```
export GIT_SSH_COMMAND="${GIT_SSH_COMMAND:-"ssh"} -o BatchMode=yes"
```

It is not sufficient. For example, when a SSH configuration entry
contains the ProxyJump option it will usually invoke a new instance of
ssh which does not obey the BatchMode option we specified.

I tried both zsh 4.3.17 and 5.0.2 to be sure it doesn't break easily...

Fixes sindresorhus#373.
@mafredri
Copy link
Collaborator Author

Rebased the PR to remove references to pinentry, since it was all a lie.

@mafredri mafredri merged commit a90b1bc into sindresorhus:master May 2, 2018
@mafredri mafredri deleted the prevent-password-prompt branch May 2, 2018 17:43
@davidtwco davidtwco mentioned this pull request May 8, 2018
2 tasks
kgrz added a commit to kgrz/pure that referenced this pull request Sep 19, 2018
* upstream/master: (21 commits)
  Avoid calling zle reset-prompt in precmd (sindresorhus#431)
  Simplify async tasks by not passing $PWD (sindresorhus#430)
  Abort git check if pwd has changed after invocation (sindresorhus#428)
  Update zsh-async to 1.7.0 (sindresorhus#429)
  1.8.0
  Advice against enabling incompatible Oh-My-Zsh plugins
  Show warning when Oh My Zsh themes are enabled (sindresorhus#426)
  Add support for VI-mode indicator (sindresorhus#405)
  Remove unused function for computing string length (sindresorhus#418)
  Update fpath-reference link (sindresorhus#417)
  Prevent IPv6 regexp from capturing the time (sindresorhus#413)
  Prevent hostname from showing up in local X sessions (sindresorhus#398)
  Make sure local HUP trap is unset during git fetch
  Improve the debug prompt (PS4) (sindresorhus#396)
  Show options as a table in readme (sindresorhus#407)
  Remove unfrequent FAQs from readme (sindresorhus#406)
  Prevent interactive prompts during git fetch (sindresorhus#397)
  Set title via atomic print statement (sindresorhus#399)
  Revert local prompt_opts, breaks promptinit
  Fix for setopt not taking effect when sourcing pure
  ...
filipekiss added a commit to filipekiss/pure that referenced this pull request Apr 26, 2019
* upstream/master:
  Add pure-pwsh to the ports section of the readme (sindresorhus#467)
  Skip grep fork, use native zsh matching (sindresorhus#459)
  Add pure-now to Ports section in the readme (sindresorhus#458)
  1.9.0
  Update to zsh-async 1.7.1 and recover from unexpected worker death (sindresorhus#454)
  Add conda environment name to precmd (sindresorhus#440)
  Add Mímir to Ports section in the readme (sindresorhus#438)
  Avoid calling zle reset-prompt in precmd (sindresorhus#431)
  Simplify async tasks by not passing $PWD (sindresorhus#430)
  Abort git check if pwd has changed after invocation (sindresorhus#428)
  Update zsh-async to 1.7.0 (sindresorhus#429)
  1.8.0
  Advice against enabling incompatible Oh-My-Zsh plugins
  Show warning when Oh My Zsh themes are enabled (sindresorhus#426)
  Add support for VI-mode indicator (sindresorhus#405)
  Remove unused function for computing string length (sindresorhus#418)
  Update fpath-reference link (sindresorhus#417)
  Prevent IPv6 regexp from capturing the time (sindresorhus#413)
  Prevent hostname from showing up in local X sessions (sindresorhus#398)
  Make sure local HUP trap is unset during git fetch
  Improve the debug prompt (PS4) (sindresorhus#396)
  Show options as a table in readme (sindresorhus#407)
  Remove unfrequent FAQs from readme (sindresorhus#406)
  Prevent interactive prompts during git fetch (sindresorhus#397)
  Set title via atomic print statement (sindresorhus#399)
  Revert local prompt_opts, breaks promptinit
  Fix for setopt not taking effect when sourcing pure
  Fix prompt_pure_state on older versions of zsh
  Fix wrong placement of localoptions during prompt init
  Fix line erasure when terminal output does not end in newline (sindresorhus#391)
  Try to detech SSH connection when SSH_CONNECTION is unset (sindresorhus#393)
  Always force BatchMode for the Git SSH command (sindresorhus#392)
  1.7.0
  Avoid setting title over serial console (sindresorhus#388)
  Hide virtualenv when explicitly disabled by the user (sindresorhus#381)
  Add install guide for Zplugin (sindresorhus#386)
  Update URL to Droid Sans Mono font (sindresorhus#387)
  Prevent multiple prompt resets in one execution cycle (sindresorhus#368)
  More thorough handling (hiding) of match results
  Avoid implicit creation of global var prompt_pure_git_arrows
  1.6.0
  Link to pure.zsh and async.zsh for better clarity (sindresorhus#358)
  Readme tweaks
  Link to a Pure-inspired prompt done in Rust
  Avoid implicit global var creation and cleanup (sindresorhus#347)
kutsan pushed a commit to kutsan/pure that referenced this pull request Jun 19, 2023
We set the shell into MONITOR mode to prevent password prompts from
hijacking the TTY. If the command is suspended we know it's trying
something not nice. So we kill it.

This seems a bit crazy, but at least it does not seem to affect
performance (relatively). I also have found no other way to work around
these issues.

Although we already set:

```
export GIT_SSH_COMMAND="${GIT_SSH_COMMAND:-"ssh"} -o BatchMode=yes"
```

It is not sufficient. For example, when a SSH configuration entry
contains the ProxyJump option it will usually invoke a new instance of
ssh which does not obey the BatchMode option we specified.

I tried both zsh 4.3.17 and 5.0.2 to be sure it doesn't break easily...

Fixes sindresorhus#373.
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.

3 participants