Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Prompt for GPG passphrase and then silent failure to commit #737

Closed

Description

@bwestover

Description

Yesterday I started seeing a new prompt for my GPG passphrase when I attempted a commit in Atom with the atom/github package. I type the passphrase, and it fails silently. The changes that were staged are still staged.

Steps to Reproduce

  1. Make a change
  2. Stage the change
  3. Type a commit message and click Commit
  4. Prompt for GPG passphrase appears:
    image
  5. Type in passphrase and click Sign in
  6. Prompt disappears, but commit is not made and change is still staged.

Developer Console shows this:
image

Expected behavior:

I am using a gpg-agent (the configuration that comes with gpgtools) and I don't get a prompt on the command-line. I expected no prompt at all. If I get a prompt, I would expect that typing in the correct passphrase would succeed in creating the commit, and an incorrect passphrase would fail with an error.

Actual behavior:

I get a prompt, and typing in the correct passphrase fails silently.

Reproduces how often:

Happens 100% of the time

Versions

$ atom --version
Atom    : 1.16.0
Electron: 1.3.13
Chrome  : 52.0.2743.82
Node    : 6.5.0

$ apm --version
apm  1.16.1
npm  3.10.5
node 6.9.5 x64
python 2.7.10
git 2.12.0

GitHub package version:
image

Additional Information

I have git configured to sign every commit:

$ git config --global --get commit.gpgsign
true

And my git version:

$ git --version
git version 2.12.0

edit: I added a better screenshot of the developer console with the output of stderr expanded 😊

Activity

  1. added this to the Public Release milestone on May 4, 2017
  2. self-assigned this
    on May 8, 2017
  3. bwestover commented on May 9, 2017

    @bwestover
    Author

    @smashwilson - Thanks for fixing the silent failure problem. I can confirm that a commit failure will now surface as an error, rather than silence (with a log to the console). 🎉 ❇️

    However, this was only part of my issue. When I try to commit a change I initially get a prompt for a GPG passphrase, which I enter (correctly, from a password manager). It was followed by silence and an error being logged to the console. It is now followed by this error:

    image

    Same error only prettier 😉

    I can make the commit, with gpg signature, on the command-line without interaction:

    $ git commit -m "Add a reusable for choosing a branch"
    
    You need a passphrase to unlock the secret key for
    user: "Brett Westover <[email protected]>"
    4096-bit RSA key, ID 6D34F71F, created 2016-03-24
    
    [desktop-contributing-2 4c0e759f9d] Add a reusable for choosing a branch
     1 file changed, 4 insertions(+)
    $  
    

    I'm using a gpg-agent, so I don't get prompted for my passphrase. Since I get prompted in Atom, I would suspect its not talking to that agent. However, since even a correct password doesn't work, I suspect it isn't able to shell out to gpg at all.

    I was able to make commits with the atom/github package with this configuration up until recently. It's been about 5-6 days now. (And I miss it!! 💙 😧 )

    Let me know if you need anything further from me to help reproduce. Should this issue be re-opened, or shall I create another?

  4. smashwilson commented on May 9, 2017

    @smashwilson
    Contributor

    @bwestover Whoops! My mistake, I was too eager on the close button there 🙈 😆

    I'm using a gpg-agent, so I don't get prompted for my passphrase. Since I get prompted in Atom, I would suspect its not talking to that agent. However, since even a correct password doesn't work, I suspect it isn't able to shell out to gpg at all.

    Quite possible. I'm also wondering if our wrapper script is discovering or invoking your gpg binary incorrectly. Can you share the output of:

    1. gpg --version
    2. git config gpg.program

    Something else that may help: if you open the github package settings in the settings view and enable "Git Diagnostics," it'll execute git commands with GIT_TRACE=1 and log all of the output to the dev console. Expand the console groups labelled with git:git -c gpg.program=... commit -m... to see the commit traces - there should be two of them.

    I may need to add in a bit more debugging output to the GPG wrapper to get to the bottom of this, though.

    I was able to make commits with the atom/github package with this configuration up until recently. It's been about 5-6 days now. (And I miss it!! 💙 😧 )

    💭 Regressing that recently suggests that this may have something to do with the way that we handle git errors? Commands that may require the use of a GPG key (commit, merge, pull) are executed first without the prompt-through-Atom helper then re-executed with it on failure.

  5. bwestover commented on May 9, 2017

    @bwestover
    Author

    gpg version

    $ gpg --version
    gpg (GnuPG/MacGPG2) 2.0.30
    libgcrypt 1.7.0
    Copyright (C) 2015 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    
    Home: ~/.gnupg
    Supported algorithms:
    Pubkey: RSA, RSA, RSA, ELG, DSA
    Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
            CAMELLIA128, CAMELLIA192, CAMELLIA256
    Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
    Compression: Uncompressed, ZIP, ZLIB, BZIP2
    

    gpg.program

    $ git config gpg.program
    

    No output. Yikes, is there supposed to be? It looks like you fall back to just gpg if this isn't set so probably ok?

    gpg-no-tty.sh#L7:

    GPG_PROGRAM=$(git config gpg.program || echo 'gpg')

    Console output after enabling "Git Diagnostics"

    image

    ...and again in text, in case thats easier to read ☺️

    git:git -c gpg.program=/Users/bwestover/.atom/packages/github/bin/gpg-no-tty.sh commit -m Test commit in /Users/bwestover/github/help-docs
    git-shell-out-strategy.js:192 exit status 128
    git-shell-out-strategy.js:193 stdout
    git-shell-out-strategy.js:194 
    git-shell-out-strategy.js:195 stderr
    git-shell-out-strategy.js:196 08:39:49.694394 git.c:371               trace: built-in: git 'commit' '-m' 'Test commit'
    08:39:49.774759 run-command.c:369       trace: run_command: '/Users/bwestover/.atom/packages/github/bin/gpg-no-tty.sh' '--status-fd=2' '-bsau' '6D34F71F'
    error: gpg failed to sign the data
    fatal: failed to write commit object
    
    git-shell-out-strategy.js:191 git:git -c gpg.program=/Users/bwestover/.atom/packages/github/bin/gpg-no-tty.sh commit -m Test commit in /Users/bwestover/github/help-docs
    git-shell-out-strategy.js:192 exit status 128
    git-shell-out-strategy.js:193 stdout
    git-shell-out-strategy.js:194 
    git-shell-out-strategy.js:195 stderr
    git-shell-out-strategy.js:196 08:39:49.863913 git.c:371               trace: built-in: git 'commit' '-m' 'Test commit'
    08:39:49.940084 run-command.c:369       trace: run_command: '/Users/bwestover/.atom/packages/github/bin/gpg-no-tty.sh' '--status-fd=2' '-bsau' '6D34F71F'
    error: gpg failed to sign the data
    fatal: failed to write commit object
    

    A crazy test you didn't ask for (feel free to ignore)

    I thought I'd see what happened if I tried to run the wrapper script on my terminal directly.

    $ /Users/bwestover/.atom/packages/github/bin/gpg-no-tty.sh --status-fd=2 -bsau 6D34F71F
    [GNUPG:] USERID_HINT 41644F7A6D34F71F Brett Westover <[email protected]>
    [GNUPG:] NEED_PASSPHRASE 41644F7A6D34F71F 41644F7A6D34F71F 1 0
    [GNUPG:] GOOD_PASSPHRASE
    [GNUPG:] BEGIN_SIGNING H10
    
    # It just hung here until I interrupted it
    
    ^C
    gpg: signal Interrupt caught ... exiting
    
  6. smashwilson commented on May 9, 2017

    @smashwilson
    Contributor

    Phew, thanks for the data! I was hoping that git would report something more informative for the run_command failures (like the stderr of our wrapper script's output for example) but it looks like it does not. Inconvenient.

    No output. Yikes, is there supposed to be? It looks like you fall back to just gpg if this isn't set so probably ok?

    Yep, that's fine - I mainly wanted to see if you'd set it to gpg2 or something, since it'd override the ${PATH} lookup 😄

    A crazy test you didn't ask for

    Haha, yeah, it's trying to write a query to a socket that connects back to the Atom process to show that prompt dialog, so when you run it on its own it'll just wait forever.

    I'm wondering if this is a PATH issue like #764, in which case #765 might take care of this. Care to apm upgrade github and try again?

  7. bwestover commented on May 9, 2017

    @bwestover
    Author

    😻 - That did it 🎉

    Did a commit with no prompt, just flew through!

    Console had this output:

    git:git -c gpg.program=/Users/bwestover/.atom/packages/github/bin/gpg-no-tty.sh commit -m Test commit in /Users/bwestover/github/help-docs
    git-shell-out-strategy.js:193 exit status 0
    git-shell-out-strategy.js:194 stdout
    git-shell-out-strategy.js:195 [desktop-contributing-2 10e1879405] Test commit
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    git-shell-out-strategy.js:196 stderr
    git-shell-out-strategy.js:197 09:43:10.149797 git.c:371               trace: built-in: git 'commit' '-m' 'Test commit'
    09:43:10.262653 run-command.c:369       trace: run_command: '/Users/bwestover/.atom/packages/github/bin/gpg-no-tty.sh' '--status-fd=2' '-bsau' '6D34F71F'
    

    Thank you so much 👍

  8. smashwilson commented on May 9, 2017

    @smashwilson
    Contributor

    Woo, excellent! Thank you for all the info 😁

  9. ahuffman commented on Apr 28, 2020

    @ahuffman

    I have this issue on MacOS with Atom v1.45.0 and gnupg installed via homebrew. The gpg password prompt comes up and I enter the password, but always fails. The same password works in the bash shell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions