Skip to content

When using the Secret Service credential store, if the keyring is locked at the time when I run a Git operation then GCM deletes the credential from the keyring and fails to authenticate with the remote #694

@gaazkam

Description

@gaazkam

Which version of GCM are you using?

Git Credential Manager version 2.0.696+4365b917da (Ubuntu 20.04.4 LTS on VirtualBox, almost fresh installation)

As per your instructions https://github.com/GitCredentialManager/git-credential-manager/blob/main/docs/credstores.md I instructed GCM to use the freedesktop.org Secret Service API as its credential store.

This is how I set up GCM to test the issue described here:

sudo dpkg -i Downloads/gcmcore-linux_amd64.2.0.696.deb
git-credential-manager-core configure
git config --global user.name gaazkam
git config --global user.email "[email protected]"
git config --global credential.credentialStore secretservice
git clone https://github.com/gaazkam/mon.git
cd mon
git push

After the last command, as expected, I had to log in into Github and a keyring was created holding the credentials to my Github account.

Problems described below start when the keyring gets locked (eg because I reboot the system; note that the login keyring does not get unlocked on login if the system is set to automatic login, without having to enter the password).

Which Git host provider are you trying to connect to?

  • Azure DevOps
  • Azure DevOps Server (TFS/on-prem)
  • GitHub
  • GitHub Enterprise
  • Bitbucket
  • Other - please describe

Can you access the remote repository directly in the browser using the remote URL?

  • Yes
  • No, I get a permission error
  • No, for a different reason - please describe

[Azure DevOps only] What format is your remote URL?

[Azure DevOps only] If the account picker shows more than one identity as you authenticate, check that you selected the same one that has access on the web.

  • Not applicable
  • I only see one identity
  • I checked each identity and none worked

Expected behavior

If the keyring that holds the credentials to my Github account is locked at the time when GCM needs to access it then a popup shows asking me to enter the password to unlock this keyring. When I enter the correct password I am authenticated and my Git operation completes succesfully. The credential is not deleted.

Actual behavior

If the keyring that holds the credentials to my Github account is locked at the time when GCM needs to access it then a popup shows asking me to enter the password to unlock this keyring. When I enter the correct password the keyring gets unlocked, however, the credential is immediately deleted from this keyring and my Git operation fails with the following error:

remote: No anonymous write access.
fatal: Authentication failed for 'https://github.com/gaazkam/mon.git/'

That the credential is deleted from the keyring can be confirmed by launching the Passwords and Keys tool in ubuntu and keeping it open next to the terminal emulator. If git push is then run in the terminal emulator and the correct password is entered into the popup then this is what happens in the Passwords and Keys window: the keyring is unlocked, the credential to my Github account is shown very briefly but then soon removed and the message 'It looks like this collection is empty' is shown.

Subsequent attempts to run the Git operation launch the browser and ask me to log into my Github account; when this is done the credential is saved to the keyring and everything works fine until the next time when the keyring is locked when GCM needs to access it.

If, at the time when GCM needs to access the keyring it is not locked then the problem described above does not happen. Instead, at that situation, as expected, I am authenticated, my Git operation completes succesfully and no credentials are deleted from the keyring.

Logs

m@m-VirtualBox:~$ export GCM_TRACE=1
m@m-VirtualBox:~$ export GIT_TRACE=1
m@m-VirtualBox:~$ cd mon
m@m-VirtualBox:~/mon$ git push
10:27:02.657020 git.c:439               trace: built-in: git push
10:27:02.661387 run-command.c:663       trace: run_command: GIT_DIR=.git git-remote-https origin https://github.com/gaazkam/mon.git
10:27:03.241135 run-command.c:663       trace: run_command: '/usr/local/share/gcm-core/git-credential-manager-core get'
10:27:03.868554 ...re/Application.cs:95 trace: [RunInternalAsync] Version: 2.0.696.25923
10:27:03.872331 ...re/Application.cs:96 trace: [RunInternalAsync] Runtime: .NET 6.0.3
10:27:03.872536 ...re/Application.cs:97 trace: [RunInternalAsync] Platform: Linux (x86-64)
10:27:03.872591 ...re/Application.cs:98 trace: [RunInternalAsync] OSVersion: Linux m-VirtualBox 5.13.0-41-generic #46~20.04.1-Ubuntu SMP Wed Apr 20 13:16:21 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
10:27:03.873047 ...re/Application.cs:99 trace: [RunInternalAsync] AppPath: /usr/local/share/gcm-core/git-credential-manager-core
10:27:03.873135 ...e/Application.cs:100 trace: [RunInternalAsync] Arguments: get
10:27:04.073771 ...GitCommandBase.cs:33 trace: [ExecuteAsync] Start 'get' command...
10:27:04.096547 ...GitCommandBase.cs:47 trace: [ExecuteAsync] Detecting host provider for input:
10:27:04.099318 ...GitCommandBase.cs:48 trace: [ExecuteAsync] 	protocol=https
10:27:04.099456 ...GitCommandBase.cs:48 trace: [ExecuteAsync] 	host=github.com
10:27:04.194879 ...viderRegistry.cs:149 trace: [GetProviderAsync] Performing auto-detection of host provider.
10:27:04.202265 ...viderRegistry.cs:158 trace: [GetProviderAsync] Auto-detect probe timeout is 2 ms.
10:27:04.208775 ...viderRegistry.cs:166 trace: [GetProviderAsync] Checking against 4 host providers registered with priority 'Normal'.
10:27:04.213750 ...GitCommandBase.cs:50 trace: [ExecuteAsync] Host provider 'GitHub' was selected.
10:27:04.222221 .../HostProvider.cs:126 trace: [GetCredentialAsync] Looking for existing credential in store with service=https://github.com account=...
10:27:11.296076 .../HostProvider.cs:140 trace: [GetCredentialAsync] Existing credential found.
10:27:11.298580 ...GitCommandBase.cs:54 trace: [ExecuteAsync] End 'get' command...
10:27:11.531683 run-command.c:663       trace: run_command: '/usr/local/share/gcm-core/git-credential-manager-core erase'
10:27:11.837155 ...re/Application.cs:95 trace: [RunInternalAsync] Version: 2.0.696.25923
10:27:11.840275 ...re/Application.cs:96 trace: [RunInternalAsync] Runtime: .NET 6.0.3
10:27:11.840370 ...re/Application.cs:97 trace: [RunInternalAsync] Platform: Linux (x86-64)
10:27:11.840392 ...re/Application.cs:98 trace: [RunInternalAsync] OSVersion: Linux m-VirtualBox 5.13.0-41-generic #46~20.04.1-Ubuntu SMP Wed Apr 20 13:16:21 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
10:27:11.840565 ...re/Application.cs:99 trace: [RunInternalAsync] AppPath: /usr/local/share/gcm-core/git-credential-manager-core
10:27:11.840636 ...e/Application.cs:100 trace: [RunInternalAsync] Arguments: erase
10:27:11.989844 ...GitCommandBase.cs:33 trace: [ExecuteAsync] Start 'erase' command...
10:27:12.011502 ...GitCommandBase.cs:47 trace: [ExecuteAsync] Detecting host provider for input:
10:27:12.014696 ...GitCommandBase.cs:48 trace: [ExecuteAsync] 	protocol=https
10:27:12.014811 ...GitCommandBase.cs:48 trace: [ExecuteAsync] 	host=github.com
10:27:12.014864 ...GitCommandBase.cs:48 trace: [ExecuteAsync] 	username=
10:27:12.014880 ...GitCommandBase.cs:48 trace: [ExecuteAsync] 	password=********
10:27:12.074374 ...viderRegistry.cs:149 trace: [GetProviderAsync] Performing auto-detection of host provider.
10:27:12.080330 ...viderRegistry.cs:158 trace: [GetProviderAsync] Auto-detect probe timeout is 2 ms.
10:27:12.084111 ...viderRegistry.cs:166 trace: [GetProviderAsync] Checking against 4 host providers registered with priority 'Normal'.
10:27:12.086713 ...GitCommandBase.cs:50 trace: [ExecuteAsync] Host provider 'GitHub' was selected.
10:27:12.088833 .../HostProvider.cs:173 trace: [EraseCredentialAsync] Erasing stored credential in store with service=https://github.com account=...
10:27:12.168989 .../HostProvider.cs:176 trace: [EraseCredentialAsync] Credential was successfully erased.
10:27:12.169133 ...GitCommandBase.cs:54 trace: [ExecuteAsync] End 'erase' command...
remote: No anonymous write access.
fatal: Authentication failed for 'https://github.com/gaazkam/mon.git/'

Metadata

Metadata

Assignees

Labels

auth-issueAn issue authenticating to a hostbugA bug in Git Credential Manager

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions