10

このファイルを使用して_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=1GIT_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 を使用してみましたが、結果は同じでした。

だからここに私の質問があります:

  1. これは msysgit の制限ですか?
  2. _netrcこの制限を (ファイルと対話型プロンプトの両方で) 増やすことはできますか?
  3. 回避策はありますか?

そして、なぜそんなに長いユーザー名が必要なのかと聞かれれば、それは私の目標がカスタム GIT サーバーの OAuth トークンを送信することだからです。


アップデート:

さらに調査すると、問題はcURLGITが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

これから良い結果が得られるという楽観主義を失い始めています。

4

1 に答える 1

9

はい、カールの限界のようです。あなたが参照しているコードは最新のものではありません:これはであり、同じ値を持っていると思います。

Windows の場合、git の cygwin バージョンは、パス サイズの制限など、msysgit が持ついくつかの制限を修正します。ただし、これはmsysgitではなくcurlの制限であるため、できることはあまりなく、実際にテストしたところ、同じ動作がありました.

ただし、これは .netrc ファイルの使用の制限であると思われることに注意してください。HTTP 仕様またはcurl プログラム インターフェイスにはその制限がないためです。実際、URLで指定するだけでうまくいくようです:

C:\REMenu>git remote add origin https://1234567890123456789012345678901234567890123456789012345678901234567890@github.com/romaonthego/REMenu.git

C:\REMenu>git push origin master
...
* Server auth using Basic with user '1234567890123456789012345678901234567890123456789012345678901234567890'
..
Password for 'https://1234567890123456789012345678901234567890123456789012345678
901234567890@github.com':

_netrc を使用する必要がある場合、curl を自分でコンパイルして動作させるしかないと思います。

必要がない場合は、他のオプションがあります。

  • ユーザー/パスを指定するローカルプロキシを実行し、接続時にそのプロキシを使用し、gitまたはcurlのユーザー/パスを指定しない
  • URLでユーザー名を使用する
  • ssh ベースの URL を使用する

編集:要約すると、これまでに見た制限:

  • _netrc: 64 (curl .netrc 制限)
  • インタラクティブ: 256
  • credential.helper wincred: 512 (Windows 資格情報ストアの制限)
  • credential.helper プレーン: 4000+
  • URL: 4000+
  • プロキシ: 無制限 (HTTP およびプロキシ ソフトウェアによってのみ制限されます)
于 2013-02-21T15:17:14.540 に答える