Merge pull request #982 from tiborvass/fix-stdin-blocking

session: add lock to fix hang
docker-19.03
Tõnis Tiigi 2019-05-07 19:39:11 -07:00 committed by GitHub
commit 97b4b9a6db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package authprovider
import (
"context"
"io/ioutil"
"sync"
"github.com/docker/cli/cli/config"
"github.com/docker/cli/cli/config/configfile"
@ -19,6 +20,12 @@ func NewDockerAuthProvider() session.Attachable {
type authProvider struct {
config *configfile.ConfigFile
// The need for this mutex is not well understood.
// Without it, the docker cli on OS X hangs when
// reading credentials from docker-credential-osxkeychain.
// See issue https://github.com/docker/cli/issues/1862
mu sync.Mutex
}
func (ap *authProvider) Register(server *grpc.Server) {
@ -26,6 +33,8 @@ func (ap *authProvider) Register(server *grpc.Server) {
}
func (ap *authProvider) Credentials(ctx context.Context, req *auth.CredentialsRequest) (*auth.CredentialsResponse, error) {
ap.mu.Lock()
defer ap.mu.Unlock()
if req.Host == "registry-1.docker.io" {
req.Host = "https://index.docker.io/v1/"
}