このファイルを使用して_netrc
基本認証用のクライアント資格情報を保存していますが、msysgit は常にユーザー名を 63 文字目で切り捨てることに気付きました。
これが私の%HOME%\_netrc
見た目です:
# username for local repos
machine localhost
login 12345678901234567890123456789012345678901234567890123456789012345
password secret
65 文字のユーザー名を定義しました。
そして、リポジトリのクローンを作成しようとしました:
C:\work>git clone https://localhost:44305/git myrepo
そしてここに出力があります(GIT_CURL_VERBOSE=1
とGIT_SSL_NO_VERIFY=true
):
Cloning into 'myrepo'...
* About to connect() to localhost port 44305 (#0)
* Trying 127.0.0.1... * connected
* Connected to localhost (127.0.0.1) port 44305 (#0)
* successfully set certificate verify locations:
* CAfile: C:\Program Files (x86)\Git/bin/curl-ca-bundle.crt CApath: none
* 0x214a410 is at send pipe head!
* Expire cleared
* SSL connection using AES128-SHA
* Server certificate:
* subject: CN=localhost
* start date: 2012-10-23 06:41:25 GMT
* expire date: 2022-10-23 00:00:00 GMT
* issuer: CN=localhost
* SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
> GET /git/info/refs?service=git-upload-pack HTTP/1.1
User-Agent: git/1.7.11.msysgit.1
Host: localhost:44305
Accept: */*
Pragma: no-cache
< HTTP/1.1 401 Unauthorized
< Cache-Control: private
< Content-Type: text/html; charset=utf-8
< Server: Microsoft-IIS/8.0
< WWW-Authenticate: Basic Realm="MyRealm"
< X-AspNet-Version: 4.0.30319
< X-SourceFiles: =?UTF-8?B?Yzpcd29ya1xUb0REXFdlYkFwcGxpY2F0aW9uMVxXZWJBcHBsaWNhdGlvbjFcZ2l0XGluZm9ccmVmcw==?=
< X-Powered-By: ASP.NET
< Date: Thu, 21 Feb 2013 13:05:56 GMT
< Content-Length: 4975
<
* Ignoring the response-body
* Connection #0 to host localhost left intact
* Issue another request to this URL: 'https://localhost:44305/git/info/refs?service=git-upload-pack'
* Re-using existing connection! (#0) with host localhost
* Connected to localhost (127.0.0.1) port 44305 (#0)
* 0x214a410 is at send pipe head!
* Server auth using Basic with user '123456789012345678901234567890123456789012345678901234567890123☻'
> GET /git/info/refs?service=git-upload-pack HTTP/1.1
Authorization: Basic MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzAjpzZWNyZXQ=
User-Agent: git/1.7.11.msysgit.1
Host: localhost:44305
Accept: */*
Pragma: no-cache
< HTTP/1.1 200 OK
< Cache-Control: private
< Content-Type: text/plain; charset=utf-8
< Server: Microsoft-IIS/8.0
< X-AspNet-Version: 4.0.30319
< X-SourceFiles: =?UTF-8?B?Yzpcd29ya1xUb0REXFdlYkFwcGxpY2F0aW9uMVxXZWJBcHBsaWNhdGlvbjFcZ2l0XGluZm9ccmVmcw==?=
< X-Powered-By: ASP.NET
< Date: Thu, 21 Feb 2013 13:05:56 GMT
< Content-Length: 2
<
* Expire cleared
* Connection #0 to host localhost left intact
* Re-using existing connection! (#0) with host localhost
* Connected to localhost (127.0.0.1) port 44305 (#0)
* 0x214a410 is at send pipe head!
* Server auth using Basic with user '123456789012345678901234567890123456789012345678901234567890123☻'
> GET /git/HEAD HTTP/1.1
Authorization: Basic MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzAjpzZWNyZXQ=
User-Agent: git/1.7.11.msysgit.1
Host: localhost:44305
Accept: */*
Pragma: no-cache
< HTTP/1.1 200 OK
< Cache-Control: private
< Content-Type: text/plain; charset=utf-8
< Server: Microsoft-IIS/8.0
< X-AspNet-Version: 4.0.30319
< X-SourceFiles: =?UTF-8?B?Yzpcd29ya1xUb0REXFdlYkFwcGxpY2F0aW9uMVxXZWJBcHBsaWNhdGlvbjFcZ2l0XEhFQUQ=?=
< X-Powered-By: ASP.NET
< Date: Thu, 21 Feb 2013 13:05:56 GMT
< Content-Length: 2
<
* Expire cleared
* Connection #0 to host localhost left intact
warning: You appear to have cloned an empty repository.
msysgit が 63 番目の文字でユーザー名を切り捨てた方法に注意してください。
123456789012345678901234567890123456789012345678901234567890123☻
次に、_netrc
ファイルを無効にして、ユーザー名とパスワードを対話的に入力しようとしましたが、今回は 256 文字を入力してみました。
C:\work>git clone https://localhost:44305/git myrepo
インタラクティブなセッションは次のとおりです。
Cloning into 'myrepo'...
* Couldn't find host localhost in the _netrc file; using defaults
* About to connect() to localhost port 44305 (#0)
* Trying 127.0.0.1... * connected
* Connected to localhost (127.0.0.1) port 44305 (#0)
* successfully set certificate verify locations:
* CAfile: C:\Program Files (x86)\Git/bin/curl-ca-bundle.crt CApath: none
* 0x22ea410 is at send pipe head!
* Expire cleared
* SSL connection using AES128-SHA
* Server certificate:
* subject: CN=localhost
* start date: 2012-10-23 06:41:25 GMT
* expire date: 2022-10-23 00:00:00 GMT
* issuer: CN=localhost
* SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
> GET /git/info/refs?service=git-upload-pack HTTP/1.1
User-Agent: git/1.7.11.msysgit.1
Host: localhost:44305
Accept: */*
Pragma: no-cache
* The requested URL returned error: 401
* Closing connection #0
Username for 'https://localhost:44305': 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456
Password for 'https://1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456@localhost:44305':
* Couldn't find host localhost in the _netrc file; using defaults
* About to connect() to localhost port 44305 (#0)
* Trying 127.0.0.1... * connected
* Connected to localhost (127.0.0.1) port 44305 (#0)
* successfully set certificate verify locations:
* CAfile: C:\Program Files (x86)\Git/bin/curl-ca-bundle.crt CApath: none
* SSL re-using session ID
* 0x22ea410 is at send pipe head!
* Expire cleared
* SSL connection using AES128-SHA
* Server certificate:
* subject: CN=localhost
* start date: 2012-10-23 06:41:25 GMT
* expire date: 2022-10-23 00:00:00 GMT
* issuer: CN=localhost
* SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
> GET /git/info/refs?service=git-upload-pack HTTP/1.1
User-Agent: git/1.7.11.msysgit.1
Host: localhost:44305
Accept: */*
Pragma: no-cache
< HTTP/1.1 401 Unauthorized
< Cache-Control: private
< Content-Type: text/html; charset=utf-8
< Server: Microsoft-IIS/8.0
< WWW-Authenticate: Basic Realm="GitApi"
< X-AspNet-Version: 4.0.30319
< X-SourceFiles: =?UTF-8?B?Yzpcd29ya1xUb0REXFdlYkFwcGxpY2F0aW9uMVxXZWJBcHBsaWNhdGlvbjFcZ2l0XGluZm9ccmVmcw==?=
< X-Powered-By: ASP.NET
< Date: Thu, 21 Feb 2013 13:16:35 GMT
< Content-Length: 4975
<
* Ignoring the response-body
* Connection #0 to host localhost left intact
* Issue another request to this URL: 'https://localhost:44305/git/info/refs?service=git-upload-pack'
* Couldn't find host localhost in the _netrc file; using defaults
* Re-using existing connection! (#0) with host localhost
* Connected to localhost (127.0.0.1) port 44305 (#0)
* 0x22ea410 is at send pipe head!
* Server auth using Basic with user '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345'
> GET /git/info/refs?service=git-upload-pack HTTP/1.1
Authorization: Basic MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1OnNlY3JldA==
User-Agent: git/1.7.11.msysgit.1
Host: localhost:44305
Accept: */*
Pragma: no-cache
< HTTP/1.1 200 OK
< Cache-Control: private
< Content-Type: text/plain; charset=utf-8
< Server: Microsoft-IIS/8.0
< X-AspNet-Version: 4.0.30319
< X-SourceFiles: =?UTF-8?B?Yzpcd29ya1xUb0REXFdlYkFwcGxpY2F0aW9uMVxXZWJBcHBsaWNhdGlvbjFcZ2l0XGluZm9ccmVmcw==?=
< X-Powered-By: ASP.NET
< Date: Thu, 21 Feb 2013 13:16:35 GMT
< Content-Length: 2
<
* Expire cleared
* Connection #0 to host localhost left intact
* Couldn't find host localhost in the _netrc file; using defaults
* Re-using existing connection! (#0) with host localhost
* Connected to localhost (127.0.0.1) port 44305 (#0)
* 0x22ea410 is at send pipe head!
* Server auth using Basic with user '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345'
> GET /git/HEAD HTTP/1.1
Authorization: Basic MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1OnNlY3JldA==
User-Agent: git/1.7.11.msysgit.1
Host: localhost:44305
Accept: */*
Pragma: no-cache
< HTTP/1.1 200 OK
< Cache-Control: private
< Content-Type: text/plain; charset=utf-8
< Server: Microsoft-IIS/8.0
< X-AspNet-Version: 4.0.30319
< X-SourceFiles: =?UTF-8?B?Yzpcd29ya1xUb0REXFdlYkFwcGxpY2F0aW9uMVxXZWJBcHBsaWNhdGlvbjFcZ2l0XEhFQUQ=?=
< X-Powered-By: ASP.NET
< Date: Thu, 21 Feb 2013 13:16:35 GMT
< Content-Length: 2
<
* Expire cleared
* Connection #0 to host localhost left intact
warning: You appear to have cloned an empty repository.
今回は、ユーザー名が 255 文字目で切り捨てられました。
標準の MS-DOS プロンプト、PowerShell プロンプト、Git Bash プロンプトで msysgit を使用してみましたが、結果は同じでした。
だからここに私の質問があります:
- これは msysgit の制限ですか?
_netrc
この制限を (ファイルと対話型プロンプトの両方で) 増やすことはできますか?- 回避策はありますか?
そして、なぜそんなに長いユーザー名が必要なのかと聞かれれば、それは私の目標がカスタム GIT サーバーの OAuth トークンを送信することだからです。
アップデート:
さらに調査すると、問題はcURL
GITがHTTPクライアントに使用するものにあるようです。次のコマンドを使用して、まったく同じ動作を再現できます。
curl --netrc -kv https://localhost:44305/git
そのため、質問をリターゲティングしています。
更新 2:
でさらに調査netrc.c
:
/* make sure we have room for at least this size: */
#define LOGINSIZE 64
#define PASSWORDSIZE 64
これから良い結果が得られるという楽観主義を失い始めています。