rugged 0.27.10 → 0.27.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/AUTHORS +0 -1
- data/vendor/libgit2/CMakeLists.txt +54 -98
- data/vendor/libgit2/COPYING +0 -28
- data/vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake +1 -15
- data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +8 -9
- data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +2 -2
- data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +1 -1
- data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +2 -2
- data/vendor/libgit2/cmake/Modules/FindStatNsec.cmake +0 -6
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +0 -2
- data/vendor/libgit2/deps/http-parser/{COPYING → LICENSE-MIT} +0 -0
- data/vendor/libgit2/deps/http-parser/http_parser.c +6 -11
- data/vendor/libgit2/deps/regex/CMakeLists.txt +2 -0
- data/vendor/libgit2/deps/regex/config.h +7 -0
- data/vendor/libgit2/deps/regex/regcomp.c +3857 -0
- data/vendor/libgit2/deps/regex/regex.c +92 -0
- data/vendor/libgit2/deps/regex/regex.h +582 -0
- data/vendor/libgit2/deps/regex/regex_internal.c +1744 -0
- data/vendor/libgit2/deps/regex/regex_internal.h +819 -0
- data/vendor/libgit2/deps/regex/regexec.c +4369 -0
- data/vendor/libgit2/deps/zlib/CMakeLists.txt +0 -1
- data/vendor/libgit2/deps/zlib/adler32.c +7 -0
- data/vendor/libgit2/deps/zlib/crc32.c +7 -0
- data/vendor/libgit2/include/git2.h +0 -5
- data/vendor/libgit2/include/git2/annotated_commit.h +0 -9
- data/vendor/libgit2/include/git2/attr.h +20 -38
- data/vendor/libgit2/include/git2/blame.h +25 -42
- data/vendor/libgit2/include/git2/blob.h +13 -45
- data/vendor/libgit2/include/git2/branch.h +1 -1
- data/vendor/libgit2/include/git2/buffer.h +16 -22
- data/vendor/libgit2/include/git2/checkout.h +32 -65
- data/vendor/libgit2/include/git2/cherrypick.h +7 -9
- data/vendor/libgit2/include/git2/clone.h +10 -12
- data/vendor/libgit2/include/git2/commit.h +3 -53
- data/vendor/libgit2/include/git2/common.h +8 -60
- data/vendor/libgit2/include/git2/config.h +19 -30
- data/vendor/libgit2/include/git2/describe.h +9 -32
- data/vendor/libgit2/include/git2/diff.h +156 -208
- data/vendor/libgit2/include/git2/errors.h +46 -54
- data/vendor/libgit2/include/git2/filter.h +0 -8
- data/vendor/libgit2/include/git2/ignore.h +2 -2
- data/vendor/libgit2/include/git2/index.h +52 -74
- data/vendor/libgit2/include/git2/indexer.h +6 -76
- data/vendor/libgit2/include/git2/inttypes.h +309 -0
- data/vendor/libgit2/include/git2/merge.h +18 -35
- data/vendor/libgit2/include/git2/net.h +5 -0
- data/vendor/libgit2/include/git2/notes.h +1 -1
- data/vendor/libgit2/include/git2/object.h +29 -17
- data/vendor/libgit2/include/git2/odb.h +11 -12
- data/vendor/libgit2/include/git2/odb_backend.h +9 -10
- data/vendor/libgit2/include/git2/oid.h +2 -2
- data/vendor/libgit2/include/git2/pack.h +3 -14
- data/vendor/libgit2/include/git2/proxy.h +8 -14
- data/vendor/libgit2/include/git2/rebase.h +6 -53
- data/vendor/libgit2/include/git2/refs.h +15 -33
- data/vendor/libgit2/include/git2/refspec.h +0 -17
- data/vendor/libgit2/include/git2/remote.h +24 -123
- data/vendor/libgit2/include/git2/repository.h +39 -76
- data/vendor/libgit2/include/git2/revert.h +4 -6
- data/vendor/libgit2/include/git2/revwalk.h +7 -7
- data/vendor/libgit2/include/git2/signature.h +2 -2
- data/vendor/libgit2/include/git2/stash.h +12 -15
- data/vendor/libgit2/include/git2/status.h +20 -33
- data/vendor/libgit2/include/git2/submodule.h +12 -30
- data/vendor/libgit2/include/git2/sys/commit.h +1 -1
- data/vendor/libgit2/include/git2/sys/config.h +13 -13
- data/vendor/libgit2/include/git2/sys/filter.h +6 -6
- data/vendor/libgit2/include/git2/sys/index.h +0 -3
- data/vendor/libgit2/include/git2/sys/mempack.h +35 -35
- data/vendor/libgit2/include/git2/sys/merge.h +4 -9
- data/vendor/libgit2/include/git2/sys/odb_backend.h +22 -66
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +40 -76
- data/vendor/libgit2/include/git2/sys/repository.h +1 -5
- data/vendor/libgit2/include/git2/sys/stream.h +12 -92
- data/vendor/libgit2/include/git2/sys/time.h +31 -0
- data/vendor/libgit2/include/git2/sys/transport.h +83 -129
- data/vendor/libgit2/include/git2/tag.h +4 -13
- data/vendor/libgit2/include/git2/trace.h +2 -2
- data/vendor/libgit2/include/git2/transaction.h +0 -1
- data/vendor/libgit2/include/git2/transport.h +311 -11
- data/vendor/libgit2/include/git2/tree.h +4 -4
- data/vendor/libgit2/include/git2/types.h +111 -33
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +13 -48
- data/vendor/libgit2/libgit2.pc.in +13 -0
- data/vendor/libgit2/src/CMakeLists.txt +164 -96
- data/vendor/libgit2/src/annotated_commit.c +8 -15
- data/vendor/libgit2/src/apply.c +31 -537
- data/vendor/libgit2/src/apply.h +1 -3
- data/vendor/libgit2/src/array.h +2 -2
- data/vendor/libgit2/src/attr.c +75 -81
- data/vendor/libgit2/src/attr_file.c +121 -207
- data/vendor/libgit2/src/attr_file.h +9 -9
- data/vendor/libgit2/src/attrcache.c +53 -51
- data/vendor/libgit2/src/attrcache.h +1 -2
- data/vendor/libgit2/src/blame.c +20 -47
- data/vendor/libgit2/src/blame.h +1 -2
- data/vendor/libgit2/src/blame_git.c +20 -37
- data/vendor/libgit2/src/blob.c +42 -128
- data/vendor/libgit2/src/blob.h +2 -19
- data/vendor/libgit2/src/branch.c +43 -67
- data/vendor/libgit2/src/buf_text.c +6 -7
- data/vendor/libgit2/src/buffer.c +57 -69
- data/vendor/libgit2/src/buffer.h +1 -1
- data/vendor/libgit2/src/cache.c +45 -38
- data/vendor/libgit2/src/cache.h +3 -3
- data/vendor/libgit2/src/cc-compat.h +3 -20
- data/vendor/libgit2/src/checkout.c +90 -109
- data/vendor/libgit2/src/cherrypick.c +9 -15
- data/vendor/libgit2/src/clone.c +27 -49
- data/vendor/libgit2/src/clone.h +0 -4
- data/vendor/libgit2/src/commit.c +49 -117
- data/vendor/libgit2/src/commit.h +0 -7
- data/vendor/libgit2/src/commit_list.c +78 -30
- data/vendor/libgit2/src/commit_list.h +2 -2
- data/vendor/libgit2/src/common.h +91 -27
- data/vendor/libgit2/src/config.c +176 -194
- data/vendor/libgit2/src/config.h +20 -8
- data/vendor/libgit2/src/config_cache.c +35 -41
- data/vendor/libgit2/src/config_file.c +753 -439
- data/vendor/libgit2/src/config_file.h +73 -0
- data/vendor/libgit2/src/config_parse.c +63 -114
- data/vendor/libgit2/src/config_parse.h +16 -17
- data/vendor/libgit2/src/crlf.c +190 -219
- data/vendor/libgit2/src/delta.c +18 -25
- data/vendor/libgit2/src/describe.c +41 -42
- data/vendor/libgit2/src/diff.c +68 -53
- data/vendor/libgit2/src/diff.h +1 -2
- data/vendor/libgit2/src/diff_driver.c +49 -47
- data/vendor/libgit2/src/diff_file.c +17 -19
- data/vendor/libgit2/src/diff_file.h +1 -1
- data/vendor/libgit2/src/diff_generate.c +106 -162
- data/vendor/libgit2/src/diff_generate.h +3 -3
- data/vendor/libgit2/src/diff_parse.c +4 -4
- data/vendor/libgit2/src/diff_print.c +30 -42
- data/vendor/libgit2/src/diff_stats.c +7 -22
- data/vendor/libgit2/src/diff_tform.c +16 -16
- data/vendor/libgit2/src/diff_xdiff.c +3 -15
- data/vendor/libgit2/src/errors.c +39 -51
- data/vendor/libgit2/src/features.h.in +3 -11
- data/vendor/libgit2/src/fetch.c +5 -10
- data/vendor/libgit2/src/fetchhead.c +17 -17
- data/vendor/libgit2/src/filebuf.c +36 -32
- data/vendor/libgit2/src/filebuf.h +2 -2
- data/vendor/libgit2/src/{futils.c → fileops.c} +73 -80
- data/vendor/libgit2/src/{futils.h → fileops.h} +6 -6
- data/vendor/libgit2/src/filter.c +38 -46
- data/vendor/libgit2/src/filter.h +10 -0
- data/vendor/libgit2/src/fnmatch.c +248 -0
- data/vendor/libgit2/src/fnmatch.h +48 -0
- data/vendor/libgit2/src/global.c +63 -48
- data/vendor/libgit2/src/global.h +2 -0
- data/vendor/libgit2/src/hash.c +0 -61
- data/vendor/libgit2/src/hash.h +19 -20
- data/vendor/libgit2/src/hash/hash_collisiondetect.h +47 -0
- data/vendor/libgit2/src/hash/{sha1/common_crypto.c → hash_common_crypto.h} +17 -17
- data/vendor/libgit2/src/hash/{sha1/generic.c → hash_generic.c} +10 -22
- data/vendor/libgit2/src/hash/{sha1/generic.h → hash_generic.h} +10 -4
- data/vendor/libgit2/src/hash/hash_openssl.h +59 -0
- data/vendor/libgit2/src/hash/{sha1/win32.c → hash_win32.c} +37 -47
- data/vendor/libgit2/src/hash/{sha1/win32.h → hash_win32.h} +19 -6
- data/vendor/libgit2/src/hash/{sha1/sha1dc → sha1dc}/sha1.c +3 -14
- data/vendor/libgit2/src/hash/{sha1/sha1dc → sha1dc}/sha1.h +0 -0
- data/vendor/libgit2/src/hash/{sha1/sha1dc → sha1dc}/ubc_check.c +0 -0
- data/vendor/libgit2/src/hash/{sha1/sha1dc → sha1dc}/ubc_check.h +0 -0
- data/vendor/libgit2/src/hashsig.c +5 -5
- data/vendor/libgit2/src/idxmap.c +61 -107
- data/vendor/libgit2/src/idxmap.h +31 -153
- data/vendor/libgit2/src/ignore.c +47 -43
- data/vendor/libgit2/src/index.c +232 -337
- data/vendor/libgit2/src/index.h +1 -17
- data/vendor/libgit2/src/indexer.c +175 -346
- data/vendor/libgit2/src/integer.h +26 -71
- data/vendor/libgit2/src/iterator.c +70 -142
- data/vendor/libgit2/src/iterator.h +0 -15
- data/vendor/libgit2/src/khash.h +1 -3
- data/vendor/libgit2/src/map.h +1 -1
- data/vendor/libgit2/src/merge.c +100 -144
- data/vendor/libgit2/src/merge_driver.c +11 -11
- data/vendor/libgit2/src/merge_file.c +2 -2
- data/vendor/libgit2/src/mwindow.c +29 -24
- data/vendor/libgit2/src/mwindow.h +4 -4
- data/vendor/libgit2/src/netops.c +156 -55
- data/vendor/libgit2/src/netops.h +23 -3
- data/vendor/libgit2/src/notes.c +11 -16
- data/vendor/libgit2/src/object.c +69 -120
- data/vendor/libgit2/src/object.h +9 -22
- data/vendor/libgit2/src/object_api.c +8 -8
- data/vendor/libgit2/src/odb.c +93 -116
- data/vendor/libgit2/src/odb.h +7 -8
- data/vendor/libgit2/src/odb_loose.c +55 -62
- data/vendor/libgit2/src/odb_mempack.c +34 -21
- data/vendor/libgit2/src/odb_pack.c +14 -18
- data/vendor/libgit2/src/offmap.c +35 -53
- data/vendor/libgit2/src/offmap.h +21 -108
- data/vendor/libgit2/src/oid.c +7 -12
- data/vendor/libgit2/src/oidmap.c +47 -49
- data/vendor/libgit2/src/oidmap.h +24 -101
- data/vendor/libgit2/src/pack-objects.c +87 -88
- data/vendor/libgit2/src/pack-objects.h +8 -2
- data/vendor/libgit2/src/pack.c +101 -99
- data/vendor/libgit2/src/pack.h +19 -17
- data/vendor/libgit2/src/parse.c +0 -10
- data/vendor/libgit2/src/parse.h +3 -3
- data/vendor/libgit2/src/patch.c +4 -4
- data/vendor/libgit2/src/patch_generate.c +20 -20
- data/vendor/libgit2/src/patch_parse.c +63 -151
- data/vendor/libgit2/src/path.c +104 -117
- data/vendor/libgit2/src/path.h +71 -3
- data/vendor/libgit2/src/pathspec.c +19 -19
- data/vendor/libgit2/src/pool.c +22 -26
- data/vendor/libgit2/src/pool.h +7 -7
- data/vendor/libgit2/src/posix.c +10 -10
- data/vendor/libgit2/src/posix.h +1 -12
- data/vendor/libgit2/src/proxy.c +3 -8
- data/vendor/libgit2/src/push.c +31 -37
- data/vendor/libgit2/src/push.h +1 -2
- data/vendor/libgit2/src/rebase.c +59 -115
- data/vendor/libgit2/src/refdb.c +3 -15
- data/vendor/libgit2/src/refdb_fs.c +254 -381
- data/vendor/libgit2/src/reflog.c +15 -13
- data/vendor/libgit2/src/refs.c +88 -118
- data/vendor/libgit2/src/refs.h +3 -5
- data/vendor/libgit2/src/refspec.c +37 -56
- data/vendor/libgit2/src/refspec.h +1 -1
- data/vendor/libgit2/src/remote.c +215 -266
- data/vendor/libgit2/src/remote.h +2 -11
- data/vendor/libgit2/src/repository.c +225 -280
- data/vendor/libgit2/src/repository.h +40 -52
- data/vendor/libgit2/src/reset.c +8 -8
- data/vendor/libgit2/src/revert.c +9 -14
- data/vendor/libgit2/src/revparse.c +48 -47
- data/vendor/libgit2/src/revwalk.c +57 -120
- data/vendor/libgit2/src/revwalk.h +1 -22
- data/vendor/libgit2/src/settings.c +10 -47
- data/vendor/libgit2/src/signature.c +11 -11
- data/vendor/libgit2/src/sortedcache.c +36 -22
- data/vendor/libgit2/src/sortedcache.h +1 -1
- data/vendor/libgit2/src/stash.c +99 -125
- data/vendor/libgit2/src/status.c +22 -28
- data/vendor/libgit2/src/stream.h +2 -17
- data/vendor/libgit2/src/streams/curl.c +385 -0
- data/vendor/libgit2/src/{allocators/stdalloc.h → streams/curl.h} +5 -5
- data/vendor/libgit2/src/streams/openssl.c +114 -224
- data/vendor/libgit2/src/streams/openssl.h +108 -4
- data/vendor/libgit2/src/streams/socket.c +30 -55
- data/vendor/libgit2/src/streams/stransport.c +32 -57
- data/vendor/libgit2/src/streams/stransport.h +0 -5
- data/vendor/libgit2/src/streams/tls.c +19 -50
- data/vendor/libgit2/src/streams/tls.h +4 -12
- data/vendor/libgit2/src/strmap.c +74 -47
- data/vendor/libgit2/src/strmap.h +33 -108
- data/vendor/libgit2/src/submodule.c +216 -272
- data/vendor/libgit2/src/submodule.h +1 -1
- data/vendor/libgit2/src/sysdir.c +19 -29
- data/vendor/libgit2/src/tag.c +28 -41
- data/vendor/libgit2/src/tag.h +1 -2
- data/vendor/libgit2/src/trace.c +2 -2
- data/vendor/libgit2/src/trace.h +3 -3
- data/vendor/libgit2/src/trailer.c +38 -52
- data/vendor/libgit2/src/transaction.c +29 -30
- data/vendor/libgit2/src/transport.c +5 -5
- data/vendor/libgit2/src/transports/auth.c +11 -15
- data/vendor/libgit2/src/transports/auth.h +3 -10
- data/vendor/libgit2/src/transports/auth_negotiate.c +18 -33
- data/vendor/libgit2/src/transports/auth_negotiate.h +2 -2
- data/vendor/libgit2/src/transports/cred.c +24 -24
- data/vendor/libgit2/src/{allocators/win32_crtdbg.h → transports/cred.h} +4 -5
- data/vendor/libgit2/src/transports/git.c +31 -26
- data/vendor/libgit2/src/transports/http.c +348 -881
- data/vendor/libgit2/src/transports/http.h +0 -2
- data/vendor/libgit2/src/transports/local.c +35 -35
- data/vendor/libgit2/src/transports/smart.c +47 -70
- data/vendor/libgit2/src/transports/smart.h +4 -3
- data/vendor/libgit2/src/transports/smart_pkt.c +40 -43
- data/vendor/libgit2/src/transports/smart_protocol.c +116 -96
- data/vendor/libgit2/src/transports/ssh.c +66 -77
- data/vendor/libgit2/src/transports/winhttp.c +314 -318
- data/vendor/libgit2/src/tree-cache.c +12 -19
- data/vendor/libgit2/src/tree.c +142 -103
- data/vendor/libgit2/src/tree.h +12 -1
- data/vendor/libgit2/src/unix/map.c +3 -3
- data/vendor/libgit2/src/unix/posix.h +11 -1
- data/vendor/libgit2/src/userdiff.h +1 -3
- data/vendor/libgit2/src/util.c +56 -70
- data/vendor/libgit2/src/util.h +156 -28
- data/vendor/libgit2/src/vector.c +4 -4
- data/vendor/libgit2/src/win32/dir.c +3 -3
- data/vendor/libgit2/src/win32/findfile.c +3 -3
- data/vendor/libgit2/src/win32/map.c +11 -9
- data/vendor/libgit2/src/win32/msvc-compat.h +0 -6
- data/vendor/libgit2/src/win32/path_w32.c +9 -113
- data/vendor/libgit2/src/win32/path_w32.h +29 -18
- data/vendor/libgit2/src/win32/posix.h +4 -1
- data/vendor/libgit2/src/win32/posix_w32.c +45 -70
- data/vendor/libgit2/src/win32/precompiled.h +2 -0
- data/vendor/libgit2/src/win32/thread.c +10 -5
- data/vendor/libgit2/src/win32/w32_buffer.c +5 -9
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +2 -3
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +75 -26
- data/vendor/libgit2/src/win32/w32_stack.c +11 -6
- data/vendor/libgit2/src/win32/w32_stack.h +3 -3
- data/vendor/libgit2/src/win32/w32_util.c +64 -27
- data/vendor/libgit2/src/win32/w32_util.h +49 -5
- data/vendor/libgit2/src/worktree.c +60 -95
- data/vendor/libgit2/src/worktree.h +0 -2
- data/vendor/libgit2/src/xdiff/xdiffi.c +5 -7
- data/vendor/libgit2/src/xdiff/xhistogram.c +1 -1
- data/vendor/libgit2/src/xdiff/xmerge.c +15 -27
- data/vendor/libgit2/src/xdiff/xpatience.c +0 -3
- data/vendor/libgit2/src/zstream.c +4 -4
- metadata +33 -122
- data/vendor/libgit2/cmake/Modules/FindGSSFramework.cmake +0 -28
- data/vendor/libgit2/cmake/Modules/FindPCRE.cmake +0 -38
- data/vendor/libgit2/cmake/Modules/FindPCRE2.cmake +0 -37
- data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +0 -93
- data/vendor/libgit2/cmake/Modules/PkgBuildConfig.cmake +0 -110
- data/vendor/libgit2/cmake/Modules/SelectGSSAPI.cmake +0 -53
- data/vendor/libgit2/cmake/Modules/SelectHTTPSBackend.cmake +0 -124
- data/vendor/libgit2/cmake/Modules/SelectHashes.cmake +0 -66
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +0 -21
- data/vendor/libgit2/deps/ntlmclient/compat.h +0 -33
- data/vendor/libgit2/deps/ntlmclient/crypt.h +0 -64
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +0 -120
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +0 -18
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +0 -145
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +0 -18
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +0 -130
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +0 -21
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +0 -1420
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +0 -174
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +0 -320
- data/vendor/libgit2/deps/ntlmclient/unicode.h +0 -36
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +0 -445
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +0 -201
- data/vendor/libgit2/deps/ntlmclient/utf8.h +0 -1257
- data/vendor/libgit2/deps/ntlmclient/util.c +0 -21
- data/vendor/libgit2/deps/ntlmclient/util.h +0 -14
- data/vendor/libgit2/deps/pcre/CMakeLists.txt +0 -140
- data/vendor/libgit2/deps/pcre/COPYING +0 -5
- data/vendor/libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS +0 -22
- data/vendor/libgit2/deps/pcre/cmake/FindEditline.cmake +0 -17
- data/vendor/libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake +0 -58
- data/vendor/libgit2/deps/pcre/cmake/FindReadline.cmake +0 -29
- data/vendor/libgit2/deps/pcre/config.h.in +0 -57
- data/vendor/libgit2/deps/pcre/pcre.h +0 -641
- data/vendor/libgit2/deps/pcre/pcre_byte_order.c +0 -319
- data/vendor/libgit2/deps/pcre/pcre_chartables.c +0 -198
- data/vendor/libgit2/deps/pcre/pcre_compile.c +0 -9800
- data/vendor/libgit2/deps/pcre/pcre_config.c +0 -190
- data/vendor/libgit2/deps/pcre/pcre_dfa_exec.c +0 -3676
- data/vendor/libgit2/deps/pcre/pcre_exec.c +0 -7173
- data/vendor/libgit2/deps/pcre/pcre_fullinfo.c +0 -245
- data/vendor/libgit2/deps/pcre/pcre_get.c +0 -669
- data/vendor/libgit2/deps/pcre/pcre_globals.c +0 -86
- data/vendor/libgit2/deps/pcre/pcre_internal.h +0 -2787
- data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +0 -11913
- data/vendor/libgit2/deps/pcre/pcre_maketables.c +0 -156
- data/vendor/libgit2/deps/pcre/pcre_newline.c +0 -210
- data/vendor/libgit2/deps/pcre/pcre_ord2utf8.c +0 -94
- data/vendor/libgit2/deps/pcre/pcre_printint.c +0 -834
- data/vendor/libgit2/deps/pcre/pcre_refcount.c +0 -92
- data/vendor/libgit2/deps/pcre/pcre_string_utils.c +0 -211
- data/vendor/libgit2/deps/pcre/pcre_study.c +0 -1686
- data/vendor/libgit2/deps/pcre/pcre_tables.c +0 -727
- data/vendor/libgit2/deps/pcre/pcre_ucd.c +0 -3644
- data/vendor/libgit2/deps/pcre/pcre_valid_utf8.c +0 -301
- data/vendor/libgit2/deps/pcre/pcre_version.c +0 -98
- data/vendor/libgit2/deps/pcre/pcre_xclass.c +0 -268
- data/vendor/libgit2/deps/pcre/pcreposix.c +0 -421
- data/vendor/libgit2/deps/pcre/pcreposix.h +0 -117
- data/vendor/libgit2/deps/pcre/ucp.h +0 -224
- data/vendor/libgit2/deps/winhttp/COPYING.GPL +0 -993
- data/vendor/libgit2/deps/winhttp/COPYING.LGPL +0 -502
- data/vendor/libgit2/deps/zlib/COPYING +0 -27
- data/vendor/libgit2/include/git2/apply.h +0 -149
- data/vendor/libgit2/include/git2/cert.h +0 -135
- data/vendor/libgit2/include/git2/cred.h +0 -308
- data/vendor/libgit2/include/git2/deprecated.h +0 -493
- data/vendor/libgit2/include/git2/mailmap.h +0 -115
- data/vendor/libgit2/include/git2/sys/alloc.h +0 -101
- data/vendor/libgit2/include/git2/sys/cred.h +0 -90
- data/vendor/libgit2/include/git2/sys/path.h +0 -64
- data/vendor/libgit2/src/alloc.c +0 -43
- data/vendor/libgit2/src/alloc.h +0 -40
- data/vendor/libgit2/src/allocators/stdalloc.c +0 -119
- data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
- data/vendor/libgit2/src/config_backend.h +0 -96
- data/vendor/libgit2/src/config_entries.c +0 -229
- data/vendor/libgit2/src/config_entries.h +0 -24
- data/vendor/libgit2/src/config_mem.c +0 -220
- data/vendor/libgit2/src/config_snapshot.c +0 -206
- data/vendor/libgit2/src/errors.h +0 -81
- data/vendor/libgit2/src/hash/sha1.h +0 -38
- data/vendor/libgit2/src/hash/sha1/collisiondetect.c +0 -48
- data/vendor/libgit2/src/hash/sha1/collisiondetect.h +0 -19
- data/vendor/libgit2/src/hash/sha1/common_crypto.h +0 -19
- data/vendor/libgit2/src/hash/sha1/mbedtls.c +0 -46
- data/vendor/libgit2/src/hash/sha1/mbedtls.h +0 -19
- data/vendor/libgit2/src/hash/sha1/openssl.c +0 -59
- data/vendor/libgit2/src/hash/sha1/openssl.h +0 -19
- data/vendor/libgit2/src/mailmap.c +0 -485
- data/vendor/libgit2/src/mailmap.h +0 -35
- data/vendor/libgit2/src/net.c +0 -184
- data/vendor/libgit2/src/net.h +0 -36
- data/vendor/libgit2/src/reader.c +0 -265
- data/vendor/libgit2/src/reader.h +0 -107
- data/vendor/libgit2/src/regexp.c +0 -221
- data/vendor/libgit2/src/regexp.h +0 -97
- data/vendor/libgit2/src/streams/mbedtls.c +0 -483
- data/vendor/libgit2/src/streams/mbedtls.h +0 -23
- data/vendor/libgit2/src/streams/registry.c +0 -118
- data/vendor/libgit2/src/streams/registry.h +0 -19
- data/vendor/libgit2/src/transports/auth_ntlm.c +0 -223
- data/vendor/libgit2/src/transports/auth_ntlm.h +0 -35
- data/vendor/libgit2/src/wildmatch.c +0 -320
- data/vendor/libgit2/src/wildmatch.h +0 -23
- data/vendor/libgit2/src/win32/w32_common.h +0 -39
@@ -12,11 +12,11 @@
|
|
12
12
|
#include "git2.h"
|
13
13
|
#include "auth.h"
|
14
14
|
|
15
|
-
#
|
15
|
+
#ifdef GIT_GSSAPI
|
16
16
|
|
17
17
|
extern int git_http_auth_negotiate(
|
18
18
|
git_http_auth_context **out,
|
19
|
-
const
|
19
|
+
const gitno_connection_data *connection_data);
|
20
20
|
|
21
21
|
#else
|
22
22
|
|
@@ -5,10 +5,10 @@
|
|
5
5
|
* a Linking Exception. For full terms see the included COPYING file.
|
6
6
|
*/
|
7
7
|
|
8
|
-
#include "
|
8
|
+
#include "cred.h"
|
9
9
|
|
10
|
-
#include "git2
|
11
|
-
#include "
|
10
|
+
#include "git2.h"
|
11
|
+
#include "smart.h"
|
12
12
|
#include "git2/cred_helpers.h"
|
13
13
|
|
14
14
|
static int git_cred_ssh_key_type_new(
|
@@ -27,7 +27,7 @@ int git_cred_has_username(git_cred *cred)
|
|
27
27
|
return 1;
|
28
28
|
}
|
29
29
|
|
30
|
-
const char *
|
30
|
+
const char *git_cred__username(git_cred *cred)
|
31
31
|
{
|
32
32
|
switch (cred->credtype) {
|
33
33
|
case GIT_CREDTYPE_USERNAME:
|
@@ -88,7 +88,7 @@ int git_cred_userpass_plaintext_new(
|
|
88
88
|
assert(cred && username && password);
|
89
89
|
|
90
90
|
c = git__malloc(sizeof(git_cred_userpass_plaintext));
|
91
|
-
|
91
|
+
GITERR_CHECK_ALLOC(c);
|
92
92
|
|
93
93
|
c->parent.credtype = GIT_CREDTYPE_USERPASS_PLAINTEXT;
|
94
94
|
c->parent.free = plaintext_free;
|
@@ -217,7 +217,7 @@ int git_cred_ssh_key_memory_new(
|
|
217
217
|
GIT_UNUSED(privatekey);
|
218
218
|
GIT_UNUSED(passphrase);
|
219
219
|
|
220
|
-
|
220
|
+
giterr_set(GITERR_INVALID,
|
221
221
|
"this version of libgit2 was not built with ssh memory credentials.");
|
222
222
|
return -1;
|
223
223
|
#endif
|
@@ -236,25 +236,25 @@ static int git_cred_ssh_key_type_new(
|
|
236
236
|
assert(username && cred && privatekey);
|
237
237
|
|
238
238
|
c = git__calloc(1, sizeof(git_cred_ssh_key));
|
239
|
-
|
239
|
+
GITERR_CHECK_ALLOC(c);
|
240
240
|
|
241
241
|
c->parent.credtype = credtype;
|
242
242
|
c->parent.free = ssh_key_free;
|
243
243
|
|
244
244
|
c->username = git__strdup(username);
|
245
|
-
|
245
|
+
GITERR_CHECK_ALLOC(c->username);
|
246
246
|
|
247
247
|
c->privatekey = git__strdup(privatekey);
|
248
|
-
|
248
|
+
GITERR_CHECK_ALLOC(c->privatekey);
|
249
249
|
|
250
250
|
if (publickey) {
|
251
251
|
c->publickey = git__strdup(publickey);
|
252
|
-
|
252
|
+
GITERR_CHECK_ALLOC(c->publickey);
|
253
253
|
}
|
254
254
|
|
255
255
|
if (passphrase) {
|
256
256
|
c->passphrase = git__strdup(passphrase);
|
257
|
-
|
257
|
+
GITERR_CHECK_ALLOC(c->passphrase);
|
258
258
|
}
|
259
259
|
|
260
260
|
*cred = &c->parent;
|
@@ -264,7 +264,7 @@ static int git_cred_ssh_key_type_new(
|
|
264
264
|
int git_cred_ssh_interactive_new(
|
265
265
|
git_cred **out,
|
266
266
|
const char *username,
|
267
|
-
|
267
|
+
git_cred_ssh_interactive_callback prompt_callback,
|
268
268
|
void *payload)
|
269
269
|
{
|
270
270
|
git_cred_ssh_interactive *c;
|
@@ -272,13 +272,13 @@ int git_cred_ssh_interactive_new(
|
|
272
272
|
assert(out && username && prompt_callback);
|
273
273
|
|
274
274
|
c = git__calloc(1, sizeof(git_cred_ssh_interactive));
|
275
|
-
|
275
|
+
GITERR_CHECK_ALLOC(c);
|
276
276
|
|
277
277
|
c->parent.credtype = GIT_CREDTYPE_SSH_INTERACTIVE;
|
278
278
|
c->parent.free = ssh_interactive_free;
|
279
279
|
|
280
280
|
c->username = git__strdup(username);
|
281
|
-
|
281
|
+
GITERR_CHECK_ALLOC(c->username);
|
282
282
|
|
283
283
|
c->prompt_callback = prompt_callback;
|
284
284
|
c->payload = payload;
|
@@ -293,13 +293,13 @@ int git_cred_ssh_key_from_agent(git_cred **cred, const char *username) {
|
|
293
293
|
assert(username && cred);
|
294
294
|
|
295
295
|
c = git__calloc(1, sizeof(git_cred_ssh_key));
|
296
|
-
|
296
|
+
GITERR_CHECK_ALLOC(c);
|
297
297
|
|
298
298
|
c->parent.credtype = GIT_CREDTYPE_SSH_KEY;
|
299
299
|
c->parent.free = ssh_key_free;
|
300
300
|
|
301
301
|
c->username = git__strdup(username);
|
302
|
-
|
302
|
+
GITERR_CHECK_ALLOC(c->username);
|
303
303
|
|
304
304
|
c->privatekey = NULL;
|
305
305
|
|
@@ -312,7 +312,7 @@ int git_cred_ssh_custom_new(
|
|
312
312
|
const char *username,
|
313
313
|
const char *publickey,
|
314
314
|
size_t publickey_len,
|
315
|
-
|
315
|
+
git_cred_sign_callback sign_callback,
|
316
316
|
void *payload)
|
317
317
|
{
|
318
318
|
git_cred_ssh_custom *c;
|
@@ -320,17 +320,17 @@ int git_cred_ssh_custom_new(
|
|
320
320
|
assert(username && cred);
|
321
321
|
|
322
322
|
c = git__calloc(1, sizeof(git_cred_ssh_custom));
|
323
|
-
|
323
|
+
GITERR_CHECK_ALLOC(c);
|
324
324
|
|
325
325
|
c->parent.credtype = GIT_CREDTYPE_SSH_CUSTOM;
|
326
326
|
c->parent.free = ssh_custom_free;
|
327
327
|
|
328
328
|
c->username = git__strdup(username);
|
329
|
-
|
329
|
+
GITERR_CHECK_ALLOC(c->username);
|
330
330
|
|
331
331
|
if (publickey_len > 0) {
|
332
332
|
c->publickey = git__malloc(publickey_len);
|
333
|
-
|
333
|
+
GITERR_CHECK_ALLOC(c->publickey);
|
334
334
|
|
335
335
|
memcpy(c->publickey, publickey, publickey_len);
|
336
336
|
}
|
@@ -350,7 +350,7 @@ int git_cred_default_new(git_cred **cred)
|
|
350
350
|
assert(cred);
|
351
351
|
|
352
352
|
c = git__calloc(1, sizeof(git_cred_default));
|
353
|
-
|
353
|
+
GITERR_CHECK_ALLOC(c);
|
354
354
|
|
355
355
|
c->credtype = GIT_CREDTYPE_DEFAULT;
|
356
356
|
c->free = default_free;
|
@@ -368,10 +368,10 @@ int git_cred_username_new(git_cred **cred, const char *username)
|
|
368
368
|
|
369
369
|
len = strlen(username);
|
370
370
|
|
371
|
-
|
372
|
-
|
371
|
+
GITERR_CHECK_ALLOC_ADD(&allocsize, sizeof(git_cred_username), len);
|
372
|
+
GITERR_CHECK_ALLOC_ADD(&allocsize, allocsize, 1);
|
373
373
|
c = git__malloc(allocsize);
|
374
|
-
|
374
|
+
GITERR_CHECK_ALLOC(c);
|
375
375
|
|
376
376
|
c->parent.credtype = GIT_CREDTYPE_USERNAME;
|
377
377
|
c->parent.free = username_free;
|
@@ -4,14 +4,13 @@
|
|
4
4
|
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
5
|
* a Linking Exception. For full terms see the included COPYING file.
|
6
6
|
*/
|
7
|
-
|
8
|
-
#
|
9
|
-
#define INCLUDE_allocators_crtdbg_h
|
7
|
+
#ifndef INCLUDE_transports_cred_h__
|
8
|
+
#define INCLUDE_transports_cred_h__
|
10
9
|
|
11
10
|
#include "common.h"
|
12
11
|
|
13
|
-
#include "
|
12
|
+
#include "git2/transport.h"
|
14
13
|
|
15
|
-
|
14
|
+
const char *git_cred__username(git_cred *cred);
|
16
15
|
|
17
16
|
#endif
|
@@ -47,7 +47,7 @@ static int gen_proto(git_buf *request, const char *cmd, const char *url)
|
|
47
47
|
|
48
48
|
delim = strchr(url, '/');
|
49
49
|
if (delim == NULL) {
|
50
|
-
|
50
|
+
giterr_set(GITERR_NET, "malformed URL");
|
51
51
|
return -1;
|
52
52
|
}
|
53
53
|
|
@@ -75,19 +75,19 @@ static int gen_proto(git_buf *request, const char *cmd, const char *url)
|
|
75
75
|
|
76
76
|
static int send_command(git_proto_stream *s)
|
77
77
|
{
|
78
|
-
git_buf request = GIT_BUF_INIT;
|
79
78
|
int error;
|
79
|
+
git_buf request = GIT_BUF_INIT;
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
if ((error = git_stream__write_full(s->io, request.ptr, request.size, 0)) < 0)
|
81
|
+
error = gen_proto(&request, s->cmd, s->url);
|
82
|
+
if (error < 0)
|
85
83
|
goto cleanup;
|
86
84
|
|
87
|
-
s->
|
85
|
+
error = git_stream_write(s->io, request.ptr, request.size, 0);
|
86
|
+
if (error >= 0)
|
87
|
+
s->sent_command = 1;
|
88
88
|
|
89
89
|
cleanup:
|
90
|
-
|
90
|
+
git_buf_free(&request);
|
91
91
|
return error;
|
92
92
|
}
|
93
93
|
|
@@ -121,13 +121,13 @@ static int git_proto_stream_write(
|
|
121
121
|
const char *buffer,
|
122
122
|
size_t len)
|
123
123
|
{
|
124
|
-
git_proto_stream *s = (git_proto_stream *)stream;
|
125
124
|
int error;
|
125
|
+
git_proto_stream *s = (git_proto_stream *)stream;
|
126
126
|
|
127
127
|
if (!s->sent_command && (error = send_command(s)) < 0)
|
128
128
|
return error;
|
129
129
|
|
130
|
-
return
|
130
|
+
return git_stream_write(s->io, buffer, len, 0);
|
131
131
|
}
|
132
132
|
|
133
133
|
static void git_proto_stream_free(git_smart_subtransport_stream *stream)
|
@@ -163,7 +163,7 @@ static int git_proto_stream_alloc(
|
|
163
163
|
return -1;
|
164
164
|
|
165
165
|
s = git__calloc(1, sizeof(git_proto_stream));
|
166
|
-
|
166
|
+
GITERR_CHECK_ALLOC(s);
|
167
167
|
|
168
168
|
s->parent.subtransport = &t->parent;
|
169
169
|
s->parent.read = git_proto_stream_read;
|
@@ -181,7 +181,7 @@ static int git_proto_stream_alloc(
|
|
181
181
|
if ((git_socket_stream_new(&s->io, host, port)) < 0)
|
182
182
|
return -1;
|
183
183
|
|
184
|
-
|
184
|
+
GITERR_CHECK_VERSION(s->io, GIT_STREAM_VERSION, "git_stream");
|
185
185
|
|
186
186
|
*stream = &s->parent;
|
187
187
|
return 0;
|
@@ -192,9 +192,8 @@ static int _git_uploadpack_ls(
|
|
192
192
|
const char *url,
|
193
193
|
git_smart_subtransport_stream **stream)
|
194
194
|
{
|
195
|
-
|
195
|
+
char *host=NULL, *port=NULL, *path=NULL, *user=NULL, *pass=NULL;
|
196
196
|
const char *stream_url = url;
|
197
|
-
const char *host, *port;
|
198
197
|
git_proto_stream *s;
|
199
198
|
int error;
|
200
199
|
|
@@ -203,15 +202,17 @@ static int _git_uploadpack_ls(
|
|
203
202
|
if (!git__prefixcmp(url, prefix_git))
|
204
203
|
stream_url += strlen(prefix_git);
|
205
204
|
|
206
|
-
if ((error =
|
205
|
+
if ((error = gitno_extract_url_parts(&host, &port, &path, &user, &pass, url, GIT_DEFAULT_PORT)) < 0)
|
207
206
|
return error;
|
208
207
|
|
209
|
-
host = urldata.host;
|
210
|
-
port = urldata.port ? urldata.port : GIT_DEFAULT_PORT;
|
211
|
-
|
212
208
|
error = git_proto_stream_alloc(t, stream_url, cmd_uploadpack, host, port, stream);
|
213
209
|
|
214
|
-
|
210
|
+
git__free(host);
|
211
|
+
git__free(port);
|
212
|
+
git__free(path);
|
213
|
+
git__free(user);
|
214
|
+
git__free(pass);
|
215
|
+
|
215
216
|
|
216
217
|
if (error < 0) {
|
217
218
|
git_proto_stream_free(*stream);
|
@@ -241,7 +242,7 @@ static int _git_uploadpack(
|
|
241
242
|
return 0;
|
242
243
|
}
|
243
244
|
|
244
|
-
|
245
|
+
giterr_set(GITERR_NET, "must call UPLOADPACK_LS before UPLOADPACK");
|
245
246
|
return -1;
|
246
247
|
}
|
247
248
|
|
@@ -250,7 +251,7 @@ static int _git_receivepack_ls(
|
|
250
251
|
const char *url,
|
251
252
|
git_smart_subtransport_stream **stream)
|
252
253
|
{
|
253
|
-
|
254
|
+
char *host=NULL, *port=NULL, *path=NULL, *user=NULL, *pass=NULL;
|
254
255
|
const char *stream_url = url;
|
255
256
|
git_proto_stream *s;
|
256
257
|
int error;
|
@@ -259,12 +260,16 @@ static int _git_receivepack_ls(
|
|
259
260
|
if (!git__prefixcmp(url, prefix_git))
|
260
261
|
stream_url += strlen(prefix_git);
|
261
262
|
|
262
|
-
if ((error =
|
263
|
+
if ((error = gitno_extract_url_parts(&host, &port, &path, &user, &pass, url, GIT_DEFAULT_PORT)) < 0)
|
263
264
|
return error;
|
264
265
|
|
265
|
-
error = git_proto_stream_alloc(t, stream_url, cmd_receivepack,
|
266
|
+
error = git_proto_stream_alloc(t, stream_url, cmd_receivepack, host, port, stream);
|
266
267
|
|
267
|
-
|
268
|
+
git__free(host);
|
269
|
+
git__free(port);
|
270
|
+
git__free(path);
|
271
|
+
git__free(user);
|
272
|
+
git__free(pass);
|
268
273
|
|
269
274
|
if (error < 0) {
|
270
275
|
git_proto_stream_free(*stream);
|
@@ -293,7 +298,7 @@ static int _git_receivepack(
|
|
293
298
|
return 0;
|
294
299
|
}
|
295
300
|
|
296
|
-
|
301
|
+
giterr_set(GITERR_NET, "must call RECEIVEPACK_LS before RECEIVEPACK");
|
297
302
|
return -1;
|
298
303
|
}
|
299
304
|
|
@@ -353,7 +358,7 @@ int git_smart_subtransport_git(git_smart_subtransport **out, git_transport *owne
|
|
353
358
|
return -1;
|
354
359
|
|
355
360
|
t = git__calloc(1, sizeof(git_subtransport));
|
356
|
-
|
361
|
+
GITERR_CHECK_ALLOC(t);
|
357
362
|
|
358
363
|
t->owner = owner;
|
359
364
|
t->parent.action = _git_action;
|
@@ -12,22 +12,19 @@
|
|
12
12
|
#include "git2.h"
|
13
13
|
#include "http_parser.h"
|
14
14
|
#include "buffer.h"
|
15
|
-
#include "net.h"
|
16
15
|
#include "netops.h"
|
17
16
|
#include "global.h"
|
18
17
|
#include "remote.h"
|
19
|
-
#include "git2/sys/cred.h"
|
20
18
|
#include "smart.h"
|
21
19
|
#include "auth.h"
|
22
20
|
#include "http.h"
|
23
21
|
#include "auth_negotiate.h"
|
24
|
-
#include "auth_ntlm.h"
|
25
22
|
#include "streams/tls.h"
|
26
23
|
#include "streams/socket.h"
|
24
|
+
#include "streams/curl.h"
|
27
25
|
|
28
26
|
git_http_auth_scheme auth_schemes[] = {
|
29
27
|
{ GIT_AUTHTYPE_NEGOTIATE, "Negotiate", GIT_CREDTYPE_DEFAULT, git_http_auth_negotiate },
|
30
|
-
{ GIT_AUTHTYPE_NTLM, "NTLM", GIT_CREDTYPE_USERPASS_PLAINTEXT, git_http_auth_ntlm },
|
31
28
|
{ GIT_AUTHTYPE_BASIC, "Basic", GIT_CREDTYPE_USERPASS_PLAINTEXT, git_http_auth_basic },
|
32
29
|
};
|
33
30
|
|
@@ -40,12 +37,6 @@ static const char *receive_pack_service_url = "/git-receive-pack";
|
|
40
37
|
static const char *get_verb = "GET";
|
41
38
|
static const char *post_verb = "POST";
|
42
39
|
|
43
|
-
#define AUTH_HEADER_SERVER "Authorization"
|
44
|
-
#define AUTH_HEADER_PROXY "Proxy-Authorization"
|
45
|
-
|
46
|
-
#define SERVER_TYPE_REMOTE "remote"
|
47
|
-
#define SERVER_TYPE_PROXY "proxy"
|
48
|
-
|
49
40
|
#define OWNING_SUBTRANSPORT(s) ((http_subtransport *)(s)->parent.subtransport)
|
50
41
|
|
51
42
|
#define PARSE_ERROR_GENERIC -1
|
@@ -71,36 +62,17 @@ typedef struct {
|
|
71
62
|
unsigned chunk_buffer_len;
|
72
63
|
unsigned sent_request : 1,
|
73
64
|
received_response : 1,
|
74
|
-
chunked : 1
|
65
|
+
chunked : 1,
|
66
|
+
redirect_count : 3;
|
75
67
|
} http_stream;
|
76
68
|
|
77
|
-
typedef struct {
|
78
|
-
git_net_url url;
|
79
|
-
git_stream *stream;
|
80
|
-
|
81
|
-
git_http_authtype_t authtypes;
|
82
|
-
git_credtype_t credtypes;
|
83
|
-
|
84
|
-
git_cred *cred;
|
85
|
-
unsigned url_cred_presented : 1,
|
86
|
-
authenticated : 1;
|
87
|
-
|
88
|
-
git_vector auth_challenges;
|
89
|
-
git_http_auth_context *auth_context;
|
90
|
-
} http_server;
|
91
|
-
|
92
69
|
typedef struct {
|
93
70
|
git_smart_subtransport parent;
|
94
71
|
transport_smart *owner;
|
95
|
-
git_stream *
|
72
|
+
git_stream *io;
|
73
|
+
gitno_connection_data connection_data;
|
96
74
|
bool connected;
|
97
75
|
|
98
|
-
http_server server;
|
99
|
-
|
100
|
-
http_server proxy;
|
101
|
-
char *proxy_url;
|
102
|
-
git_proxy_options proxy_opts;
|
103
|
-
|
104
76
|
/* Parser structures */
|
105
77
|
http_parser parser;
|
106
78
|
http_parser_settings settings;
|
@@ -109,15 +81,17 @@ typedef struct {
|
|
109
81
|
git_buf parse_header_value;
|
110
82
|
char parse_buffer_data[NETIO_BUFSIZE];
|
111
83
|
char *content_type;
|
112
|
-
char *content_length;
|
113
84
|
char *location;
|
85
|
+
git_vector www_authenticate;
|
114
86
|
enum last_cb last_cb;
|
115
87
|
int parse_error;
|
116
88
|
int error;
|
117
|
-
unsigned
|
118
|
-
|
119
|
-
|
120
|
-
|
89
|
+
unsigned parse_finished : 1;
|
90
|
+
|
91
|
+
/* Authentication */
|
92
|
+
git_cred *cred;
|
93
|
+
git_cred *url_cred;
|
94
|
+
git_vector auth_contexts;
|
121
95
|
} http_subtransport;
|
122
96
|
|
123
97
|
typedef struct {
|
@@ -130,50 +104,94 @@ typedef struct {
|
|
130
104
|
size_t *bytes_read;
|
131
105
|
} parser_context;
|
132
106
|
|
133
|
-
static git_http_auth_scheme *
|
134
|
-
|
135
|
-
|
107
|
+
static bool credtype_match(git_http_auth_scheme *scheme, void *data)
|
108
|
+
{
|
109
|
+
unsigned int credtype = *(unsigned int *)data;
|
110
|
+
|
111
|
+
return !!(scheme->credtypes & credtype);
|
112
|
+
}
|
113
|
+
|
114
|
+
static bool challenge_match(git_http_auth_scheme *scheme, void *data)
|
115
|
+
{
|
116
|
+
const char *scheme_name = scheme->name;
|
117
|
+
const char *challenge = (const char *)data;
|
118
|
+
size_t scheme_len;
|
119
|
+
|
120
|
+
scheme_len = strlen(scheme_name);
|
121
|
+
return (strncasecmp(challenge, scheme_name, scheme_len) == 0 &&
|
122
|
+
(challenge[scheme_len] == '\0' || challenge[scheme_len] == ' '));
|
123
|
+
}
|
124
|
+
|
125
|
+
static int auth_context_match(
|
126
|
+
git_http_auth_context **out,
|
127
|
+
http_subtransport *t,
|
128
|
+
bool (*scheme_match)(git_http_auth_scheme *scheme, void *data),
|
129
|
+
void *data)
|
136
130
|
{
|
137
131
|
git_http_auth_scheme *scheme = NULL;
|
132
|
+
git_http_auth_context *context = NULL, *c;
|
138
133
|
size_t i;
|
139
134
|
|
135
|
+
*out = NULL;
|
136
|
+
|
140
137
|
for (i = 0; i < ARRAY_SIZE(auth_schemes); i++) {
|
141
|
-
|
142
|
-
|
143
|
-
|
138
|
+
if (scheme_match(&auth_schemes[i], data)) {
|
139
|
+
scheme = &auth_schemes[i];
|
140
|
+
break;
|
141
|
+
}
|
142
|
+
}
|
144
143
|
|
145
|
-
|
144
|
+
if (!scheme)
|
145
|
+
return 0;
|
146
146
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
147
|
+
/* See if authentication has already started for this scheme */
|
148
|
+
git_vector_foreach(&t->auth_contexts, i, c) {
|
149
|
+
if (c->type == scheme->type) {
|
150
|
+
context = c;
|
151
151
|
break;
|
152
152
|
}
|
153
153
|
}
|
154
154
|
|
155
|
-
|
155
|
+
if (!context) {
|
156
|
+
if (scheme->init_context(&context, &t->connection_data) < 0)
|
157
|
+
return -1;
|
158
|
+
else if (!context)
|
159
|
+
return 0;
|
160
|
+
else if (git_vector_insert(&t->auth_contexts, context) < 0)
|
161
|
+
return -1;
|
162
|
+
}
|
163
|
+
|
164
|
+
*out = context;
|
165
|
+
|
166
|
+
return 0;
|
156
167
|
}
|
157
168
|
|
158
|
-
static int apply_credentials(
|
159
|
-
git_buf *buf,
|
160
|
-
http_server *server,
|
161
|
-
const char *header_name)
|
169
|
+
static int apply_credentials(git_buf *buf, http_subtransport *t)
|
162
170
|
{
|
163
|
-
|
164
|
-
|
171
|
+
git_cred *cred = t->cred;
|
172
|
+
git_http_auth_context *context;
|
173
|
+
|
174
|
+
/* Apply the credentials given to us in the URL */
|
175
|
+
if (!cred && t->connection_data.user && t->connection_data.pass) {
|
176
|
+
if (!t->url_cred &&
|
177
|
+
git_cred_userpass_plaintext_new(&t->url_cred,
|
178
|
+
t->connection_data.user, t->connection_data.pass) < 0)
|
179
|
+
return -1;
|
180
|
+
|
181
|
+
cred = t->url_cred;
|
182
|
+
}
|
165
183
|
|
166
|
-
if (!
|
167
|
-
|
184
|
+
if (!cred)
|
185
|
+
return 0;
|
168
186
|
|
169
|
-
|
170
|
-
|
187
|
+
/* Get or create a context for the best scheme for this cred type */
|
188
|
+
if (auth_context_match(&context, t, credtype_match, &cred->credtype) < 0)
|
189
|
+
return -1;
|
171
190
|
|
172
|
-
|
191
|
+
if (!context)
|
192
|
+
return 0;
|
173
193
|
|
174
|
-
|
175
|
-
git_buf_dispose(&token);
|
176
|
-
return error;
|
194
|
+
return context->next_token(buf, context, cred);
|
177
195
|
}
|
178
196
|
|
179
197
|
static int gen_request(
|
@@ -182,29 +200,15 @@ static int gen_request(
|
|
182
200
|
size_t content_length)
|
183
201
|
{
|
184
202
|
http_subtransport *t = OWNING_SUBTRANSPORT(s);
|
185
|
-
const char *path = t->
|
203
|
+
const char *path = t->connection_data.path ? t->connection_data.path : "/";
|
186
204
|
size_t i;
|
187
205
|
|
188
|
-
|
189
|
-
git_buf_printf(buf, "%s %s://%s:%s%s%s HTTP/1.1\r\n",
|
190
|
-
s->verb,
|
191
|
-
t->server.url.scheme,
|
192
|
-
t->server.url.host,
|
193
|
-
t->server.url.port,
|
194
|
-
path, s->service_url);
|
195
|
-
else
|
196
|
-
git_buf_printf(buf, "%s %s%s HTTP/1.1\r\n",
|
197
|
-
s->verb, path, s->service_url);
|
206
|
+
git_buf_printf(buf, "%s %s%s HTTP/1.1\r\n", s->verb, path, s->service_url);
|
198
207
|
|
199
208
|
git_buf_puts(buf, "User-Agent: ");
|
200
209
|
git_http__user_agent(buf);
|
201
210
|
git_buf_puts(buf, "\r\n");
|
202
|
-
git_buf_printf(buf, "Host: %s", t->
|
203
|
-
|
204
|
-
if (!git_net_url_is_default_port(&t->server.url))
|
205
|
-
git_buf_printf(buf, ":%s", t->server.url.port);
|
206
|
-
|
207
|
-
git_buf_puts(buf, "\r\n");
|
211
|
+
git_buf_printf(buf, "Host: %s\r\n", t->connection_data.host);
|
208
212
|
|
209
213
|
if (s->chunked || content_length > 0) {
|
210
214
|
git_buf_printf(buf, "Accept: application/x-git-%s-result\r\n", s->service);
|
@@ -222,12 +226,8 @@ static int gen_request(
|
|
222
226
|
git_buf_printf(buf, "%s\r\n", t->owner->custom_headers.strings[i]);
|
223
227
|
}
|
224
228
|
|
225
|
-
/* Apply
|
226
|
-
if (t
|
227
|
-
apply_credentials(buf, &t->proxy, AUTH_HEADER_PROXY) < 0)
|
228
|
-
return -1;
|
229
|
-
|
230
|
-
if (apply_credentials(buf, &t->server, AUTH_HEADER_SERVER) < 0)
|
229
|
+
/* Apply credentials to the request */
|
230
|
+
if (apply_credentials(buf, t) < 0)
|
231
231
|
return -1;
|
232
232
|
|
233
233
|
git_buf_puts(buf, "\r\n");
|
@@ -238,86 +238,29 @@ static int gen_request(
|
|
238
238
|
return 0;
|
239
239
|
}
|
240
240
|
|
241
|
-
static int
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
if (git_vector_length(&server->auth_challenges) > 1) {
|
246
|
-
git_error_set(GIT_ERROR_NET, "received multiple authentication challenges");
|
247
|
-
return -1;
|
248
|
-
}
|
249
|
-
|
250
|
-
challenge = git_vector_get(&server->auth_challenges, 0);
|
251
|
-
|
252
|
-
if (server->auth_context->set_challenge)
|
253
|
-
return server->auth_context->set_challenge(server->auth_context, challenge);
|
254
|
-
else
|
255
|
-
return 0;
|
256
|
-
}
|
257
|
-
|
258
|
-
static int set_authentication_types(http_server *server)
|
241
|
+
static int parse_authenticate_response(
|
242
|
+
git_vector *www_authenticate,
|
243
|
+
http_subtransport *t,
|
244
|
+
int *allowed_types)
|
259
245
|
{
|
260
|
-
|
246
|
+
git_http_auth_context *context;
|
261
247
|
char *challenge;
|
262
248
|
size_t i;
|
263
249
|
|
264
|
-
git_vector_foreach(
|
265
|
-
if ((
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
}
|
270
|
-
|
271
|
-
return 0;
|
272
|
-
}
|
273
|
-
|
274
|
-
static bool auth_context_complete(http_server *server)
|
275
|
-
{
|
276
|
-
/* If there's no is_complete function, we're always complete */
|
277
|
-
if (!server->auth_context->is_complete)
|
278
|
-
return true;
|
279
|
-
|
280
|
-
if (server->auth_context->is_complete(server->auth_context))
|
281
|
-
return true;
|
282
|
-
|
283
|
-
return false;
|
284
|
-
}
|
285
|
-
|
286
|
-
static void free_auth_context(http_server *server)
|
287
|
-
{
|
288
|
-
if (!server->auth_context)
|
289
|
-
return;
|
290
|
-
|
291
|
-
if (server->auth_context->free)
|
292
|
-
server->auth_context->free(server->auth_context);
|
293
|
-
|
294
|
-
server->auth_context = NULL;
|
295
|
-
}
|
250
|
+
git_vector_foreach(www_authenticate, i, challenge) {
|
251
|
+
if (auth_context_match(&context, t, challenge_match, challenge) < 0)
|
252
|
+
return -1;
|
253
|
+
else if (!context)
|
254
|
+
continue;
|
296
255
|
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
* If we think that we've completed authentication (ie, we've either
|
301
|
-
* sent a basic credential or we've sent the NTLM/Negotiate response)
|
302
|
-
* but we've got an authentication request from the server then our
|
303
|
-
* last authentication did not succeed. Start over.
|
304
|
-
*/
|
305
|
-
if (server->auth_context && auth_context_complete(server)) {
|
306
|
-
free_auth_context(server);
|
256
|
+
if (context->set_challenge &&
|
257
|
+
context->set_challenge(context, challenge) < 0)
|
258
|
+
return -1;
|
307
259
|
|
308
|
-
|
260
|
+
*allowed_types |= context->credtypes;
|
309
261
|
}
|
310
262
|
|
311
|
-
|
312
|
-
* If we've begun authentication, give the challenge to the context.
|
313
|
-
* Otherwise, set up the types to prepare credentials.
|
314
|
-
*/
|
315
|
-
if (git_vector_length(&server->auth_challenges) == 0)
|
316
|
-
return 0;
|
317
|
-
else if (server->auth_context)
|
318
|
-
return set_authentication_challenge(server);
|
319
|
-
else
|
320
|
-
return set_authentication_types(server);
|
263
|
+
return 0;
|
321
264
|
}
|
322
265
|
|
323
266
|
static int on_header_ready(http_subtransport *t)
|
@@ -326,45 +269,22 @@ static int on_header_ready(http_subtransport *t)
|
|
326
269
|
git_buf *value = &t->parse_header_value;
|
327
270
|
|
328
271
|
if (!strcasecmp("Content-Type", git_buf_cstr(name))) {
|
329
|
-
if (t->content_type) {
|
330
|
-
|
331
|
-
|
332
|
-
}
|
333
|
-
|
334
|
-
t->content_type = git__strdup(git_buf_cstr(value));
|
335
|
-
GIT_ERROR_CHECK_ALLOC(t->content_type);
|
336
|
-
}
|
337
|
-
else if (!strcasecmp("Content-Length", git_buf_cstr(name))) {
|
338
|
-
if (t->content_length) {
|
339
|
-
git_error_set(GIT_ERROR_NET, "multiple Content-Length headers");
|
340
|
-
return -1;
|
272
|
+
if (!t->content_type) {
|
273
|
+
t->content_type = git__strdup(git_buf_cstr(value));
|
274
|
+
GITERR_CHECK_ALLOC(t->content_type);
|
341
275
|
}
|
342
|
-
|
343
|
-
t->content_length = git__strdup(git_buf_cstr(value));
|
344
|
-
GIT_ERROR_CHECK_ALLOC(t->content_length);
|
345
|
-
}
|
346
|
-
else if (!strcasecmp("Proxy-Authenticate", git_buf_cstr(name))) {
|
347
|
-
char *dup = git__strdup(git_buf_cstr(value));
|
348
|
-
GIT_ERROR_CHECK_ALLOC(dup);
|
349
|
-
|
350
|
-
if (git_vector_insert(&t->proxy.auth_challenges, dup) < 0)
|
351
|
-
return -1;
|
352
276
|
}
|
353
277
|
else if (!strcasecmp("WWW-Authenticate", git_buf_cstr(name))) {
|
354
278
|
char *dup = git__strdup(git_buf_cstr(value));
|
355
|
-
|
279
|
+
GITERR_CHECK_ALLOC(dup);
|
356
280
|
|
357
|
-
|
358
|
-
return -1;
|
281
|
+
git_vector_insert(&t->www_authenticate, dup);
|
359
282
|
}
|
360
283
|
else if (!strcasecmp("Location", git_buf_cstr(name))) {
|
361
|
-
if (t->location) {
|
362
|
-
|
363
|
-
|
284
|
+
if (!t->location) {
|
285
|
+
t->location = git__strdup(git_buf_cstr(value));
|
286
|
+
GITERR_CHECK_ALLOC(t->location);
|
364
287
|
}
|
365
|
-
|
366
|
-
t->location = git__strdup(git_buf_cstr(value));
|
367
|
-
GIT_ERROR_CHECK_ALLOC(t->location);
|
368
288
|
}
|
369
289
|
|
370
290
|
return 0;
|
@@ -408,204 +328,85 @@ static int on_header_value(http_parser *parser, const char *str, size_t len)
|
|
408
328
|
return 0;
|
409
329
|
}
|
410
330
|
|
411
|
-
GIT_INLINE(void) free_cred(git_cred **cred)
|
412
|
-
{
|
413
|
-
if (*cred) {
|
414
|
-
git_cred_free(*cred);
|
415
|
-
(*cred) = NULL;
|
416
|
-
}
|
417
|
-
}
|
418
|
-
|
419
|
-
static int apply_url_credentials(
|
420
|
-
git_cred **cred,
|
421
|
-
unsigned int allowed_types,
|
422
|
-
const char *username,
|
423
|
-
const char *password)
|
424
|
-
{
|
425
|
-
if (allowed_types & GIT_CREDTYPE_USERPASS_PLAINTEXT)
|
426
|
-
return git_cred_userpass_plaintext_new(cred, username, password);
|
427
|
-
|
428
|
-
if ((allowed_types & GIT_CREDTYPE_DEFAULT) && *username == '\0' && *password == '\0')
|
429
|
-
return git_cred_default_new(cred);
|
430
|
-
|
431
|
-
return GIT_PASSTHROUGH;
|
432
|
-
}
|
433
|
-
|
434
|
-
static int init_auth(http_server *server)
|
435
|
-
{
|
436
|
-
git_http_auth_scheme *s, *scheme = NULL;
|
437
|
-
char *c, *challenge = NULL;
|
438
|
-
size_t i;
|
439
|
-
int error;
|
440
|
-
|
441
|
-
git_vector_foreach(&server->auth_challenges, i, c) {
|
442
|
-
s = scheme_for_challenge(c, server->cred);
|
443
|
-
|
444
|
-
if (s && !!(s->credtypes & server->credtypes)) {
|
445
|
-
scheme = s;
|
446
|
-
challenge = c;
|
447
|
-
break;
|
448
|
-
}
|
449
|
-
}
|
450
|
-
|
451
|
-
if (!scheme) {
|
452
|
-
git_error_set(GIT_ERROR_NET, "no authentication mechanism could be negotiated");
|
453
|
-
return -1;
|
454
|
-
}
|
455
|
-
|
456
|
-
if ((error = scheme->init_context(&server->auth_context, &server->url)) == GIT_PASSTHROUGH)
|
457
|
-
return 0;
|
458
|
-
else if (error < 0)
|
459
|
-
return error;
|
460
|
-
|
461
|
-
if (server->auth_context->set_challenge &&
|
462
|
-
(error = server->auth_context->set_challenge(server->auth_context, challenge)) < 0)
|
463
|
-
return error;
|
464
|
-
|
465
|
-
return 0;
|
466
|
-
}
|
467
|
-
|
468
|
-
static int on_auth_required(
|
469
|
-
http_parser *parser,
|
470
|
-
http_server *server,
|
471
|
-
const char *url,
|
472
|
-
const char *type,
|
473
|
-
git_cred_acquire_cb callback,
|
474
|
-
void *callback_payload)
|
475
|
-
{
|
476
|
-
parser_context *ctx = (parser_context *) parser->data;
|
477
|
-
http_subtransport *t = ctx->t;
|
478
|
-
int error = 1;
|
479
|
-
|
480
|
-
if (parse_authenticate_response(server) < 0) {
|
481
|
-
t->parse_error = PARSE_ERROR_GENERIC;
|
482
|
-
return t->parse_error;
|
483
|
-
}
|
484
|
-
|
485
|
-
/* If we're in the middle of challenge/response auth, continue */
|
486
|
-
if (parser->status_code == 407 || parser->status_code == 401) {
|
487
|
-
if (server->auth_context && !auth_context_complete(server)) {
|
488
|
-
t->parse_error = PARSE_ERROR_REPLAY;
|
489
|
-
return 0;
|
490
|
-
}
|
491
|
-
}
|
492
|
-
|
493
|
-
/* Enforce a reasonable cap on the number of replays */
|
494
|
-
if (t->replay_count++ >= GIT_HTTP_REPLAY_MAX) {
|
495
|
-
git_error_set(GIT_ERROR_NET, "too many redirects or authentication replays");
|
496
|
-
return t->parse_error = PARSE_ERROR_GENERIC;
|
497
|
-
}
|
498
|
-
|
499
|
-
if (!server->credtypes) {
|
500
|
-
git_error_set(GIT_ERROR_NET, "%s requested authentication but did not negotiate mechanisms", type);
|
501
|
-
t->parse_error = PARSE_ERROR_GENERIC;
|
502
|
-
return t->parse_error;
|
503
|
-
}
|
504
|
-
|
505
|
-
free_auth_context(server);
|
506
|
-
free_cred(&server->cred);
|
507
|
-
|
508
|
-
/* Start with URL-specified credentials, if there were any. */
|
509
|
-
if (!server->url_cred_presented && server->url.username && server->url.password) {
|
510
|
-
error = apply_url_credentials(&server->cred, server->credtypes, server->url.username, server->url.password);
|
511
|
-
server->url_cred_presented = 1;
|
512
|
-
|
513
|
-
if (error == GIT_PASSTHROUGH) {
|
514
|
-
/* treat GIT_PASSTHROUGH as if callback isn't set */
|
515
|
-
error = 1;
|
516
|
-
}
|
517
|
-
}
|
518
|
-
|
519
|
-
if (error > 0 && callback) {
|
520
|
-
error = callback(&server->cred, url, server->url.username, server->credtypes, callback_payload);
|
521
|
-
|
522
|
-
if (error == GIT_PASSTHROUGH) {
|
523
|
-
/* treat GIT_PASSTHROUGH as if callback isn't set */
|
524
|
-
error = 1;
|
525
|
-
}
|
526
|
-
}
|
527
|
-
|
528
|
-
if (error > 0) {
|
529
|
-
git_error_set(GIT_ERROR_NET, "%s authentication required but no callback set",
|
530
|
-
type);
|
531
|
-
t->parse_error = PARSE_ERROR_GENERIC;
|
532
|
-
return t->parse_error;
|
533
|
-
} else if (error < 0) {
|
534
|
-
t->error = error;
|
535
|
-
t->parse_error = PARSE_ERROR_EXT;
|
536
|
-
return t->parse_error;
|
537
|
-
}
|
538
|
-
|
539
|
-
assert(server->cred);
|
540
|
-
|
541
|
-
if (!(server->cred->credtype & server->credtypes)) {
|
542
|
-
git_error_set(GIT_ERROR_NET, "%s credential provider returned an invalid cred type", type);
|
543
|
-
t->parse_error = PARSE_ERROR_GENERIC;
|
544
|
-
return t->parse_error;
|
545
|
-
}
|
546
|
-
|
547
|
-
/* Successfully acquired a credential. Start an auth context. */
|
548
|
-
if (init_auth(server) < 0) {
|
549
|
-
t->parse_error = PARSE_ERROR_GENERIC;
|
550
|
-
return t->parse_error;
|
551
|
-
}
|
552
|
-
|
553
|
-
t->parse_error = PARSE_ERROR_REPLAY;
|
554
|
-
return 0;
|
555
|
-
}
|
556
|
-
|
557
|
-
static void on_auth_success(http_server *server)
|
558
|
-
{
|
559
|
-
server->url_cred_presented = 0;
|
560
|
-
server->authenticated = 1;
|
561
|
-
}
|
562
|
-
|
563
331
|
static int on_headers_complete(http_parser *parser)
|
564
332
|
{
|
565
333
|
parser_context *ctx = (parser_context *) parser->data;
|
566
334
|
http_subtransport *t = ctx->t;
|
567
335
|
http_stream *s = ctx->s;
|
568
336
|
git_buf buf = GIT_BUF_INIT;
|
337
|
+
int error = 0, no_callback = 0, allowed_auth_types = 0;
|
569
338
|
|
570
339
|
/* Both parse_header_name and parse_header_value are populated
|
571
340
|
* and ready for consumption. */
|
572
|
-
if (
|
573
|
-
|
341
|
+
if (VALUE == t->last_cb)
|
342
|
+
if (on_header_ready(t) < 0)
|
343
|
+
return t->parse_error = PARSE_ERROR_GENERIC;
|
574
344
|
|
575
|
-
/*
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
t->proxy_opts.credentials,
|
583
|
-
t->proxy_opts.payload);
|
584
|
-
else
|
585
|
-
on_auth_success(&t->proxy);
|
345
|
+
/* Capture authentication headers which may be a 401 (authentication
|
346
|
+
* is not complete) or a 200 (simply informing us that auth *is*
|
347
|
+
* complete.)
|
348
|
+
*/
|
349
|
+
if (parse_authenticate_response(&t->www_authenticate, t,
|
350
|
+
&allowed_auth_types) < 0)
|
351
|
+
return t->parse_error = PARSE_ERROR_GENERIC;
|
586
352
|
|
587
353
|
/* Check for an authentication failure. */
|
588
|
-
if (parser->status_code == 401 && get_verb == s->verb)
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
354
|
+
if (parser->status_code == 401 && get_verb == s->verb) {
|
355
|
+
if (!t->owner->cred_acquire_cb) {
|
356
|
+
no_callback = 1;
|
357
|
+
} else {
|
358
|
+
if (allowed_auth_types) {
|
359
|
+
if (t->cred) {
|
360
|
+
t->cred->free(t->cred);
|
361
|
+
t->cred = NULL;
|
362
|
+
}
|
363
|
+
|
364
|
+
error = t->owner->cred_acquire_cb(&t->cred,
|
365
|
+
t->owner->url,
|
366
|
+
t->connection_data.user,
|
367
|
+
allowed_auth_types,
|
368
|
+
t->owner->cred_acquire_payload);
|
369
|
+
|
370
|
+
if (error == GIT_PASSTHROUGH) {
|
371
|
+
no_callback = 1;
|
372
|
+
} else if (error < 0) {
|
373
|
+
t->error = error;
|
374
|
+
return t->parse_error = PARSE_ERROR_EXT;
|
375
|
+
} else {
|
376
|
+
assert(t->cred);
|
377
|
+
|
378
|
+
if (!(t->cred->credtype & allowed_auth_types)) {
|
379
|
+
giterr_set(GITERR_NET, "credentials callback returned an invalid cred type");
|
380
|
+
return t->parse_error = PARSE_ERROR_GENERIC;
|
381
|
+
}
|
382
|
+
|
383
|
+
/* Successfully acquired a credential. */
|
384
|
+
t->parse_error = PARSE_ERROR_REPLAY;
|
385
|
+
return 0;
|
386
|
+
}
|
387
|
+
}
|
388
|
+
}
|
389
|
+
|
390
|
+
if (no_callback) {
|
391
|
+
giterr_set(GITERR_NET, "authentication required but no callback set");
|
392
|
+
return t->parse_error = PARSE_ERROR_GENERIC;
|
393
|
+
}
|
394
|
+
}
|
598
395
|
|
599
396
|
/* Check for a redirect.
|
600
397
|
* Right now we only permit a redirect to the same hostname. */
|
601
398
|
if ((parser->status_code == 301 ||
|
602
399
|
parser->status_code == 302 ||
|
603
400
|
(parser->status_code == 303 && get_verb == s->verb) ||
|
604
|
-
parser->status_code == 307
|
605
|
-
parser->status_code == 308) &&
|
401
|
+
parser->status_code == 307) &&
|
606
402
|
t->location) {
|
607
403
|
|
608
|
-
if (
|
404
|
+
if (s->redirect_count >= 7) {
|
405
|
+
giterr_set(GITERR_NET, "too many redirects");
|
406
|
+
return t->parse_error = PARSE_ERROR_GENERIC;
|
407
|
+
}
|
408
|
+
|
409
|
+
if (gitno_connection_data_from_url(&t->connection_data, t->location, s->service_url) < 0)
|
609
410
|
return t->parse_error = PARSE_ERROR_GENERIC;
|
610
411
|
|
611
412
|
/* Set the redirect URL on the stream. This is a transfer of
|
@@ -617,13 +418,15 @@ static int on_headers_complete(http_parser *parser)
|
|
617
418
|
t->location = NULL;
|
618
419
|
|
619
420
|
t->connected = 0;
|
421
|
+
s->redirect_count++;
|
422
|
+
|
620
423
|
t->parse_error = PARSE_ERROR_REPLAY;
|
621
424
|
return 0;
|
622
425
|
}
|
623
426
|
|
624
427
|
/* Check for a 200 HTTP status code. */
|
625
428
|
if (parser->status_code != 200) {
|
626
|
-
|
429
|
+
giterr_set(GITERR_NET,
|
627
430
|
"unexpected HTTP status code: %d",
|
628
431
|
parser->status_code);
|
629
432
|
return t->parse_error = PARSE_ERROR_GENERIC;
|
@@ -631,7 +434,7 @@ static int on_headers_complete(http_parser *parser)
|
|
631
434
|
|
632
435
|
/* The response must contain a Content-Type header. */
|
633
436
|
if (!t->content_type) {
|
634
|
-
|
437
|
+
giterr_set(GITERR_NET, "no Content-Type header in response");
|
635
438
|
return t->parse_error = PARSE_ERROR_GENERIC;
|
636
439
|
}
|
637
440
|
|
@@ -649,14 +452,14 @@ static int on_headers_complete(http_parser *parser)
|
|
649
452
|
return t->parse_error = PARSE_ERROR_GENERIC;
|
650
453
|
|
651
454
|
if (strcmp(t->content_type, git_buf_cstr(&buf))) {
|
652
|
-
|
653
|
-
|
455
|
+
git_buf_free(&buf);
|
456
|
+
giterr_set(GITERR_NET,
|
654
457
|
"invalid Content-Type: %s",
|
655
458
|
t->content_type);
|
656
459
|
return t->parse_error = PARSE_ERROR_GENERIC;
|
657
460
|
}
|
658
461
|
|
659
|
-
|
462
|
+
git_buf_free(&buf);
|
660
463
|
|
661
464
|
return 0;
|
662
465
|
}
|
@@ -667,7 +470,6 @@ static int on_message_complete(http_parser *parser)
|
|
667
470
|
http_subtransport *t = ctx->t;
|
668
471
|
|
669
472
|
t->parse_finished = 1;
|
670
|
-
t->keepalive = http_should_keep_alive(parser);
|
671
473
|
|
672
474
|
return 0;
|
673
475
|
}
|
@@ -677,19 +479,22 @@ static int on_body_fill_buffer(http_parser *parser, const char *str, size_t len)
|
|
677
479
|
parser_context *ctx = (parser_context *) parser->data;
|
678
480
|
http_subtransport *t = ctx->t;
|
679
481
|
|
680
|
-
/* If
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
482
|
+
/* If our goal is to replay the request (either an auth failure or
|
483
|
+
* a redirect) then don't bother buffering since we're ignoring the
|
484
|
+
* content anyway.
|
485
|
+
*/
|
486
|
+
if (t->parse_error == PARSE_ERROR_REPLAY)
|
487
|
+
return 0;
|
686
488
|
|
687
|
-
|
688
|
-
|
689
|
-
|
489
|
+
if (ctx->buf_size < len) {
|
490
|
+
giterr_set(GITERR_NET, "can't fit data in the buffer");
|
491
|
+
return t->parse_error = PARSE_ERROR_GENERIC;
|
690
492
|
}
|
691
493
|
|
494
|
+
memcpy(ctx->buffer, str, len);
|
692
495
|
*(ctx->bytes_read) += len;
|
496
|
+
ctx->buffer += len;
|
497
|
+
ctx->buf_size -= len;
|
693
498
|
|
694
499
|
return 0;
|
695
500
|
}
|
@@ -697,7 +502,7 @@ static int on_body_fill_buffer(http_parser *parser, const char *str, size_t len)
|
|
697
502
|
static void clear_parser_state(http_subtransport *t)
|
698
503
|
{
|
699
504
|
http_parser_init(&t->parser, HTTP_RESPONSE);
|
700
|
-
gitno_buffer_setup_fromstream(t->
|
505
|
+
gitno_buffer_setup_fromstream(t->io,
|
701
506
|
&t->parse_buffer,
|
702
507
|
t->parse_buffer_data,
|
703
508
|
sizeof(t->parse_buffer_data));
|
@@ -705,25 +510,20 @@ static void clear_parser_state(http_subtransport *t)
|
|
705
510
|
t->last_cb = NONE;
|
706
511
|
t->parse_error = 0;
|
707
512
|
t->parse_finished = 0;
|
708
|
-
t->keepalive = 0;
|
709
513
|
|
710
|
-
|
514
|
+
git_buf_free(&t->parse_header_name);
|
711
515
|
git_buf_init(&t->parse_header_name, 0);
|
712
516
|
|
713
|
-
|
517
|
+
git_buf_free(&t->parse_header_value);
|
714
518
|
git_buf_init(&t->parse_header_value, 0);
|
715
519
|
|
716
520
|
git__free(t->content_type);
|
717
521
|
t->content_type = NULL;
|
718
522
|
|
719
|
-
git__free(t->content_length);
|
720
|
-
t->content_length = NULL;
|
721
|
-
|
722
523
|
git__free(t->location);
|
723
524
|
t->location = NULL;
|
724
525
|
|
725
|
-
git_vector_free_deep(&t->
|
726
|
-
git_vector_free_deep(&t->server.auth_challenges);
|
526
|
+
git_vector_free_deep(&t->www_authenticate);
|
727
527
|
}
|
728
528
|
|
729
529
|
static int write_chunk(git_stream *io, const char *buffer, size_t len)
|
@@ -736,424 +536,117 @@ static int write_chunk(git_stream *io, const char *buffer, size_t len)
|
|
736
536
|
if (git_buf_oom(&buf))
|
737
537
|
return -1;
|
738
538
|
|
739
|
-
if (
|
740
|
-
|
539
|
+
if (git_stream_write(io, buf.ptr, buf.size, 0) < 0) {
|
540
|
+
git_buf_free(&buf);
|
741
541
|
return -1;
|
742
542
|
}
|
743
543
|
|
744
|
-
|
544
|
+
git_buf_free(&buf);
|
745
545
|
|
746
546
|
/* Chunk body */
|
747
|
-
if (len > 0 &&
|
547
|
+
if (len > 0 && git_stream_write(io, buffer, len, 0) < 0)
|
748
548
|
return -1;
|
749
549
|
|
750
550
|
/* Chunk footer */
|
751
|
-
if (
|
551
|
+
if (git_stream_write(io, "\r\n", 2, 0) < 0)
|
752
552
|
return -1;
|
753
553
|
|
754
554
|
return 0;
|
755
555
|
}
|
756
556
|
|
757
|
-
static int
|
557
|
+
static int apply_proxy_config(http_subtransport *t)
|
758
558
|
{
|
759
559
|
int error;
|
560
|
+
git_proxy_t proxy_type;
|
760
561
|
|
761
|
-
|
762
|
-
case GIT_PROXY_NONE:
|
562
|
+
if (!git_stream_supports_proxy(t->io))
|
763
563
|
return 0;
|
764
564
|
|
765
|
-
|
766
|
-
git__free(t->proxy_url);
|
767
|
-
t->proxy_url = NULL;
|
768
|
-
|
769
|
-
git_proxy_options_init(&t->proxy_opts, GIT_PROXY_OPTIONS_VERSION);
|
770
|
-
|
771
|
-
if ((error = git_remote__get_http_proxy(t->owner->owner,
|
772
|
-
!strcmp(t->server.url.scheme, "https"), &t->proxy_url)) < 0)
|
773
|
-
return error;
|
774
|
-
|
775
|
-
if (!t->proxy_url)
|
776
|
-
return 0;
|
777
|
-
|
778
|
-
t->proxy_opts.type = GIT_PROXY_SPECIFIED;
|
779
|
-
t->proxy_opts.url = t->proxy_url;
|
780
|
-
t->proxy_opts.credentials = t->owner->proxy.credentials;
|
781
|
-
t->proxy_opts.certificate_check = t->owner->proxy.certificate_check;
|
782
|
-
t->proxy_opts.payload = t->owner->proxy.payload;
|
783
|
-
break;
|
565
|
+
proxy_type = t->owner->proxy.type;
|
784
566
|
|
785
|
-
|
786
|
-
|
787
|
-
break;
|
788
|
-
|
789
|
-
default:
|
790
|
-
assert(0);
|
791
|
-
return -1;
|
792
|
-
}
|
793
|
-
|
794
|
-
git_net_url_dispose(&t->proxy.url);
|
795
|
-
|
796
|
-
return git_net_url_parse(&t->proxy.url, t->proxy_opts.url);
|
797
|
-
}
|
798
|
-
|
799
|
-
static int check_certificate(
|
800
|
-
git_stream *stream,
|
801
|
-
git_net_url *url,
|
802
|
-
int is_valid,
|
803
|
-
git_transport_certificate_check_cb cert_cb,
|
804
|
-
void *cert_cb_payload)
|
805
|
-
{
|
806
|
-
git_cert *cert;
|
807
|
-
git_error_state last_error = {0};
|
808
|
-
int error;
|
809
|
-
|
810
|
-
if ((error = git_stream_certificate(&cert, stream)) < 0)
|
811
|
-
return error;
|
812
|
-
|
813
|
-
git_error_state_capture(&last_error, GIT_ECERTIFICATE);
|
814
|
-
|
815
|
-
error = cert_cb(cert, is_valid, url->host, cert_cb_payload);
|
816
|
-
|
817
|
-
if (error == GIT_PASSTHROUGH && !is_valid)
|
818
|
-
return git_error_state_restore(&last_error);
|
819
|
-
else if (error == GIT_PASSTHROUGH)
|
820
|
-
error = 0;
|
821
|
-
else if (error && !git_error_last())
|
822
|
-
git_error_set(GIT_ERROR_NET, "user rejected certificate for %s", url->host);
|
823
|
-
|
824
|
-
git_error_state_free(&last_error);
|
825
|
-
return error;
|
826
|
-
}
|
567
|
+
if (proxy_type == GIT_PROXY_NONE)
|
568
|
+
return 0;
|
827
569
|
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
git_transport_certificate_check_cb cert_cb,
|
832
|
-
void *cb_payload)
|
833
|
-
{
|
834
|
-
int error;
|
570
|
+
if (proxy_type == GIT_PROXY_AUTO) {
|
571
|
+
char *url;
|
572
|
+
git_proxy_options opts = GIT_PROXY_OPTIONS_INIT;
|
835
573
|
|
836
|
-
|
574
|
+
if ((error = git_remote__get_http_proxy(t->owner->owner, !!t->connection_data.use_ssl, &url)) < 0)
|
575
|
+
return error;
|
837
576
|
|
838
|
-
|
577
|
+
opts.credentials = t->owner->proxy.credentials;
|
578
|
+
opts.certificate_check = t->owner->proxy.certificate_check;
|
579
|
+
opts.payload = t->owner->proxy.payload;
|
580
|
+
opts.type = GIT_PROXY_SPECIFIED;
|
581
|
+
opts.url = url;
|
582
|
+
error = git_stream_set_proxy(t->io, &opts);
|
583
|
+
git__free(url);
|
839
584
|
|
840
|
-
if (error && error != GIT_ECERTIFICATE)
|
841
585
|
return error;
|
842
|
-
|
843
|
-
if (git_stream_is_encrypted(stream) && cert_cb != NULL)
|
844
|
-
error = check_certificate(stream, url, !error, cert_cb, cb_payload);
|
845
|
-
|
846
|
-
return error;
|
847
|
-
}
|
848
|
-
|
849
|
-
static int gen_connect_req(git_buf *buf, http_subtransport *t)
|
850
|
-
{
|
851
|
-
git_buf_printf(buf, "CONNECT %s:%s HTTP/1.1\r\n",
|
852
|
-
t->server.url.host, t->server.url.port);
|
853
|
-
|
854
|
-
git_buf_puts(buf, "User-Agent: ");
|
855
|
-
git_http__user_agent(buf);
|
856
|
-
git_buf_puts(buf, "\r\n");
|
857
|
-
|
858
|
-
git_buf_printf(buf, "Host: %s\r\n", t->proxy.url.host);
|
859
|
-
|
860
|
-
if (apply_credentials(buf, &t->proxy, AUTH_HEADER_PROXY) < 0)
|
861
|
-
return -1;
|
862
|
-
|
863
|
-
git_buf_puts(buf, "\r\n");
|
864
|
-
|
865
|
-
return git_buf_oom(buf) ? -1 : 0;
|
866
|
-
}
|
867
|
-
|
868
|
-
static int proxy_headers_complete(http_parser *parser)
|
869
|
-
{
|
870
|
-
parser_context *ctx = (parser_context *) parser->data;
|
871
|
-
http_subtransport *t = ctx->t;
|
872
|
-
|
873
|
-
/* Both parse_header_name and parse_header_value are populated
|
874
|
-
* and ready for consumption. */
|
875
|
-
if (t->last_cb == VALUE && on_header_ready(t) < 0)
|
876
|
-
return t->parse_error = PARSE_ERROR_GENERIC;
|
877
|
-
|
878
|
-
/*
|
879
|
-
* Capture authentication headers for the proxy or final endpoint,
|
880
|
-
* these may be 407/401 (authentication is not complete) or a 200
|
881
|
-
* (informing us that auth has completed).
|
882
|
-
*/
|
883
|
-
if (parse_authenticate_response(&t->proxy) < 0)
|
884
|
-
return t->parse_error = PARSE_ERROR_GENERIC;
|
885
|
-
|
886
|
-
/* If we're in the middle of challenge/response auth, continue */
|
887
|
-
if (parser->status_code == 407) {
|
888
|
-
if (t->proxy.auth_context && !auth_context_complete(&t->proxy)) {
|
889
|
-
t->parse_error = PARSE_ERROR_REPLAY;
|
890
|
-
return 0;
|
891
|
-
}
|
892
|
-
}
|
893
|
-
|
894
|
-
/* Enforce a reasonable cap on the number of replays */
|
895
|
-
if (t->replay_count++ >= GIT_HTTP_REPLAY_MAX) {
|
896
|
-
git_error_set(GIT_ERROR_NET, "too many redirects or authentication replays");
|
897
|
-
return t->parse_error = PARSE_ERROR_GENERIC;
|
898
|
-
}
|
899
|
-
|
900
|
-
/* Check for a proxy authentication failure. */
|
901
|
-
if (parser->status_code == 407)
|
902
|
-
return on_auth_required(
|
903
|
-
parser,
|
904
|
-
&t->proxy,
|
905
|
-
t->proxy_opts.url,
|
906
|
-
SERVER_TYPE_PROXY,
|
907
|
-
t->proxy_opts.credentials,
|
908
|
-
t->proxy_opts.payload);
|
909
|
-
|
910
|
-
if (parser->status_code != 200) {
|
911
|
-
git_error_set(GIT_ERROR_NET, "unexpected status code from proxy: %d",
|
912
|
-
parser->status_code);
|
913
|
-
return t->parse_error = PARSE_ERROR_GENERIC;
|
914
586
|
}
|
915
587
|
|
916
|
-
|
917
|
-
t->parse_finished = 1;
|
918
|
-
|
919
|
-
return 0;
|
588
|
+
return git_stream_set_proxy(t->io, &t->owner->proxy);
|
920
589
|
}
|
921
590
|
|
922
|
-
static int
|
923
|
-
git_stream **out, git_stream *proxy_stream, http_subtransport *t)
|
591
|
+
static int http_connect(http_subtransport *t)
|
924
592
|
{
|
925
|
-
git_buf request = GIT_BUF_INIT;
|
926
|
-
static http_parser_settings proxy_parser_settings = {0};
|
927
|
-
size_t bytes_read = 0, bytes_parsed;
|
928
|
-
parser_context ctx;
|
929
|
-
bool auth_replay;
|
930
593
|
int error;
|
931
594
|
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
proxy_parser_settings.on_message_complete = on_message_complete;
|
937
|
-
|
938
|
-
replay:
|
939
|
-
clear_parser_state(t);
|
940
|
-
|
941
|
-
auth_replay = false;
|
942
|
-
|
943
|
-
gitno_buffer_setup_fromstream(proxy_stream,
|
944
|
-
&t->parse_buffer,
|
945
|
-
t->parse_buffer_data,
|
946
|
-
sizeof(t->parse_buffer_data));
|
947
|
-
|
948
|
-
if ((error = gen_connect_req(&request, t)) < 0)
|
949
|
-
goto done;
|
950
|
-
|
951
|
-
if ((error = git_stream__write_full(proxy_stream, request.ptr,
|
952
|
-
request.size, 0)) < 0)
|
953
|
-
goto done;
|
954
|
-
|
955
|
-
git_buf_dispose(&request);
|
956
|
-
|
957
|
-
while (!bytes_read && !t->parse_finished) {
|
958
|
-
t->parse_buffer.offset = 0;
|
959
|
-
|
960
|
-
if ((error = gitno_recv(&t->parse_buffer)) < 0) {
|
961
|
-
goto done;
|
962
|
-
} else if (error == 0 && t->request_count > 0) {
|
963
|
-
/* Server closed a keep-alive socket; reconnect. */
|
964
|
-
auth_replay = true;
|
965
|
-
goto done;
|
966
|
-
} else if (error == 0) {
|
967
|
-
git_error_set(GIT_ERROR_NET, "unexpected disconnection from server");
|
968
|
-
error = -1;
|
969
|
-
goto done;
|
970
|
-
}
|
971
|
-
|
972
|
-
/*
|
973
|
-
* This call to http_parser_execute will invoke the on_*
|
974
|
-
* callbacks. Since we don't care about the body of the response,
|
975
|
-
* we can set our buffer to NULL.
|
976
|
-
*/
|
977
|
-
ctx.t = t;
|
978
|
-
ctx.s = NULL;
|
979
|
-
ctx.buffer = NULL;
|
980
|
-
ctx.buf_size = 0;
|
981
|
-
ctx.bytes_read = &bytes_read;
|
982
|
-
|
983
|
-
/* Set the context, call the parser, then unset the context. */
|
984
|
-
t->parser.data = &ctx;
|
985
|
-
|
986
|
-
bytes_parsed = http_parser_execute(&t->parser,
|
987
|
-
&proxy_parser_settings, t->parse_buffer.data, t->parse_buffer.offset);
|
988
|
-
|
989
|
-
t->parser.data = NULL;
|
990
|
-
|
991
|
-
/* Ensure that we didn't get a redirect; unsupported. */
|
992
|
-
if (t->location) {
|
993
|
-
git_error_set(GIT_ERROR_NET, "proxy server sent unsupported redirect during CONNECT");
|
994
|
-
error = -1;
|
995
|
-
goto done;
|
996
|
-
}
|
997
|
-
|
998
|
-
/* Replay the request with authentication headers. */
|
999
|
-
if (PARSE_ERROR_REPLAY == t->parse_error) {
|
1000
|
-
auth_replay = true;
|
1001
|
-
} else if (t->parse_error < 0) {
|
1002
|
-
error = t->parse_error == PARSE_ERROR_EXT ? PARSE_ERROR_EXT : -1;
|
1003
|
-
goto done;
|
1004
|
-
}
|
1005
|
-
|
1006
|
-
if (bytes_parsed != t->parse_buffer.offset) {
|
1007
|
-
git_error_set(GIT_ERROR_NET,
|
1008
|
-
"HTTP parser error: %s",
|
1009
|
-
http_errno_description((enum http_errno)t->parser.http_errno));
|
1010
|
-
error = -1;
|
1011
|
-
goto done;
|
1012
|
-
}
|
1013
|
-
}
|
1014
|
-
|
1015
|
-
t->request_count++;
|
1016
|
-
|
1017
|
-
if (auth_replay) {
|
1018
|
-
if (t->keepalive && t->parse_finished)
|
1019
|
-
goto replay;
|
595
|
+
if (t->connected &&
|
596
|
+
http_should_keep_alive(&t->parser) &&
|
597
|
+
t->parse_finished)
|
598
|
+
return 0;
|
1020
599
|
|
1021
|
-
|
600
|
+
if (t->io) {
|
601
|
+
git_stream_close(t->io);
|
602
|
+
git_stream_free(t->io);
|
603
|
+
t->io = NULL;
|
604
|
+
t->connected = 0;
|
1022
605
|
}
|
1023
606
|
|
1024
|
-
if (
|
1025
|
-
error =
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
*/
|
1033
|
-
t->proxy_opts.type = GIT_PROXY_NONE;
|
1034
|
-
t->replay_count = 0;
|
1035
|
-
t->request_count = 0;
|
1036
|
-
|
1037
|
-
done:
|
1038
|
-
return error;
|
1039
|
-
}
|
1040
|
-
|
1041
|
-
static void reset_auth_connection(http_server *server)
|
1042
|
-
{
|
1043
|
-
/*
|
1044
|
-
* If we've authenticated and we're doing "normal"
|
1045
|
-
* authentication with a request affinity (Basic, Digest)
|
1046
|
-
* then we want to _keep_ our context, since authentication
|
1047
|
-
* survives even through non-keep-alive connections. If
|
1048
|
-
* we've authenticated and we're doing connection-based
|
1049
|
-
* authentication (NTLM, Negotiate) - indicated by the presence
|
1050
|
-
* of an `is_complete` callback - then we need to restart
|
1051
|
-
* authentication on a new connection.
|
1052
|
-
*/
|
1053
|
-
|
1054
|
-
if (server->authenticated &&
|
1055
|
-
server->auth_context &&
|
1056
|
-
server->auth_context->connection_affinity) {
|
1057
|
-
free_auth_context(server);
|
1058
|
-
|
1059
|
-
server->url_cred_presented = 0;
|
1060
|
-
server->authenticated = 0;
|
607
|
+
if (t->connection_data.use_ssl) {
|
608
|
+
error = git_tls_stream_new(&t->io, t->connection_data.host, t->connection_data.port);
|
609
|
+
} else {
|
610
|
+
#ifdef GIT_CURL
|
611
|
+
error = git_curl_stream_new(&t->io, t->connection_data.host, t->connection_data.port);
|
612
|
+
#else
|
613
|
+
error = git_socket_stream_new(&t->io, t->connection_data.host, t->connection_data.port);
|
614
|
+
#endif
|
1061
615
|
}
|
1062
|
-
}
|
1063
|
-
|
1064
|
-
static int http_connect(http_subtransport *t)
|
1065
|
-
{
|
1066
|
-
git_net_url *url;
|
1067
|
-
git_stream *proxy_stream = NULL, *stream = NULL;
|
1068
|
-
git_transport_certificate_check_cb cert_cb;
|
1069
|
-
void *cb_payload;
|
1070
|
-
int error;
|
1071
|
-
|
1072
|
-
auth_replay:
|
1073
|
-
if (t->connected && t->keepalive && t->parse_finished)
|
1074
|
-
return 0;
|
1075
616
|
|
1076
|
-
if (
|
617
|
+
if (error < 0)
|
1077
618
|
return error;
|
1078
619
|
|
1079
|
-
|
1080
|
-
git_stream_close(t->server.stream);
|
1081
|
-
git_stream_free(t->server.stream);
|
1082
|
-
t->server.stream = NULL;
|
1083
|
-
}
|
1084
|
-
|
1085
|
-
if (t->proxy.stream) {
|
1086
|
-
git_stream_close(t->proxy.stream);
|
1087
|
-
git_stream_free(t->proxy.stream);
|
1088
|
-
t->proxy.stream = NULL;
|
1089
|
-
}
|
620
|
+
GITERR_CHECK_VERSION(t->io, GIT_STREAM_VERSION, "git_stream");
|
1090
621
|
|
1091
|
-
|
1092
|
-
reset_auth_connection(&t->proxy);
|
622
|
+
apply_proxy_config(t);
|
1093
623
|
|
1094
|
-
|
1095
|
-
t->keepalive = 0;
|
1096
|
-
t->request_count = 0;
|
624
|
+
error = git_stream_connect(t->io);
|
1097
625
|
|
1098
|
-
if (
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
} else {
|
1103
|
-
url = &t->server.url;
|
1104
|
-
cert_cb = t->owner->certificate_check_cb;
|
1105
|
-
cb_payload = t->owner->message_cb_payload;
|
1106
|
-
}
|
626
|
+
if ((!error || error == GIT_ECERTIFICATE) && t->owner->certificate_check_cb != NULL &&
|
627
|
+
git_stream_is_encrypted(t->io)) {
|
628
|
+
git_cert *cert;
|
629
|
+
int is_valid = (error == GIT_OK);
|
1107
630
|
|
1108
|
-
|
1109
|
-
|
1110
|
-
else
|
1111
|
-
error = git_socket_stream_new(&stream, url->host, url->port);
|
631
|
+
if ((error = git_stream_certificate(&cert, t->io)) < 0)
|
632
|
+
return error;
|
1112
633
|
|
1113
|
-
|
1114
|
-
|
634
|
+
giterr_clear();
|
635
|
+
error = t->owner->certificate_check_cb(cert, is_valid, t->connection_data.host, t->owner->message_cb_payload);
|
1115
636
|
|
1116
|
-
|
1117
|
-
|
637
|
+
if (error < 0) {
|
638
|
+
if (!giterr_last())
|
639
|
+
giterr_set(GITERR_NET, "user cancelled certificate check");
|
1118
640
|
|
1119
|
-
|
1120
|
-
* At this point we have a connection to the remote server or to
|
1121
|
-
* a proxy. If it's a proxy and the remote server is actually
|
1122
|
-
* an HTTPS connection, then we need to build a CONNECT tunnel.
|
1123
|
-
*/
|
1124
|
-
if (t->proxy_opts.type == GIT_PROXY_SPECIFIED &&
|
1125
|
-
strcmp(t->server.url.scheme, "https") == 0) {
|
1126
|
-
proxy_stream = stream;
|
1127
|
-
stream = NULL;
|
1128
|
-
|
1129
|
-
error = proxy_connect(&stream, proxy_stream, t);
|
1130
|
-
|
1131
|
-
if (error == PARSE_ERROR_REPLAY) {
|
1132
|
-
git_stream_close(proxy_stream);
|
1133
|
-
git_stream_free(proxy_stream);
|
1134
|
-
goto auth_replay;
|
1135
|
-
} else if (error < 0) {
|
1136
|
-
goto on_error;
|
641
|
+
return error;
|
1137
642
|
}
|
1138
643
|
}
|
1139
644
|
|
1140
|
-
|
1141
|
-
|
645
|
+
if (error < 0)
|
646
|
+
return error;
|
647
|
+
|
1142
648
|
t->connected = 1;
|
1143
649
|
return 0;
|
1144
|
-
|
1145
|
-
on_error:
|
1146
|
-
if (stream) {
|
1147
|
-
git_stream_close(stream);
|
1148
|
-
git_stream_free(stream);
|
1149
|
-
}
|
1150
|
-
|
1151
|
-
if (proxy_stream) {
|
1152
|
-
git_stream_close(proxy_stream);
|
1153
|
-
git_stream_free(proxy_stream);
|
1154
|
-
}
|
1155
|
-
|
1156
|
-
return error;
|
1157
650
|
}
|
1158
651
|
|
1159
652
|
static int http_stream_read(
|
@@ -1166,23 +659,26 @@ static int http_stream_read(
|
|
1166
659
|
http_subtransport *t = OWNING_SUBTRANSPORT(s);
|
1167
660
|
parser_context ctx;
|
1168
661
|
size_t bytes_parsed;
|
1169
|
-
git_buf request = GIT_BUF_INIT;
|
1170
|
-
bool auth_replay;
|
1171
|
-
int error = 0;
|
1172
662
|
|
1173
663
|
replay:
|
1174
664
|
*bytes_read = 0;
|
1175
|
-
auth_replay = false;
|
1176
665
|
|
1177
666
|
assert(t->connected);
|
1178
667
|
|
1179
668
|
if (!s->sent_request) {
|
1180
|
-
|
669
|
+
git_buf request = GIT_BUF_INIT;
|
670
|
+
|
1181
671
|
clear_parser_state(t);
|
1182
672
|
|
1183
|
-
if (
|
1184
|
-
|
1185
|
-
|
673
|
+
if (gen_request(&request, s, 0) < 0)
|
674
|
+
return -1;
|
675
|
+
|
676
|
+
if (git_stream_write(t->io, request.ptr, request.size, 0) < 0) {
|
677
|
+
git_buf_free(&request);
|
678
|
+
return -1;
|
679
|
+
}
|
680
|
+
|
681
|
+
git_buf_free(&request);
|
1186
682
|
|
1187
683
|
s->sent_request = 1;
|
1188
684
|
}
|
@@ -1192,17 +688,15 @@ replay:
|
|
1192
688
|
assert(s->verb == post_verb);
|
1193
689
|
|
1194
690
|
/* Flush, if necessary */
|
1195
|
-
if (s->chunk_buffer_len > 0
|
1196
|
-
|
1197
|
-
|
691
|
+
if (s->chunk_buffer_len > 0 &&
|
692
|
+
write_chunk(t->io, s->chunk_buffer, s->chunk_buffer_len) < 0)
|
693
|
+
return -1;
|
1198
694
|
|
1199
|
-
|
1200
|
-
}
|
695
|
+
s->chunk_buffer_len = 0;
|
1201
696
|
|
1202
697
|
/* Write the final chunk. */
|
1203
|
-
if ((
|
1204
|
-
|
1205
|
-
goto done;
|
698
|
+
if (git_stream_write(t->io, "0\r\n\r\n", 5, 0) < 0)
|
699
|
+
return -1;
|
1206
700
|
}
|
1207
701
|
|
1208
702
|
s->received_response = 1;
|
@@ -1210,6 +704,7 @@ replay:
|
|
1210
704
|
|
1211
705
|
while (!*bytes_read && !t->parse_finished) {
|
1212
706
|
size_t data_offset;
|
707
|
+
int error;
|
1213
708
|
|
1214
709
|
/*
|
1215
710
|
* Make the parse_buffer think it's as full of data as
|
@@ -1219,37 +714,26 @@ replay:
|
|
1219
714
|
* data_offset is the actual data offset from which we
|
1220
715
|
* should tell the parser to start reading.
|
1221
716
|
*/
|
1222
|
-
if (buf_size >= t->parse_buffer.len)
|
717
|
+
if (buf_size >= t->parse_buffer.len) {
|
1223
718
|
t->parse_buffer.offset = 0;
|
1224
|
-
else
|
719
|
+
} else {
|
1225
720
|
t->parse_buffer.offset = t->parse_buffer.len - buf_size;
|
721
|
+
}
|
1226
722
|
|
1227
723
|
data_offset = t->parse_buffer.offset;
|
1228
724
|
|
1229
|
-
if (
|
1230
|
-
|
1231
|
-
} else if (error == 0 && t->request_count > 0) {
|
1232
|
-
/* Server closed a keep-alive socket; reconnect. */
|
1233
|
-
auth_replay = true;
|
1234
|
-
goto done;
|
1235
|
-
} else if (error == 0) {
|
1236
|
-
git_error_set(GIT_ERROR_NET, "unexpected disconnection from server");
|
1237
|
-
error = -1;
|
1238
|
-
goto done;
|
1239
|
-
}
|
725
|
+
if (gitno_recv(&t->parse_buffer) < 0)
|
726
|
+
return -1;
|
1240
727
|
|
1241
|
-
/*
|
1242
|
-
*
|
1243
|
-
*
|
1244
|
-
*
|
1245
|
-
*
|
1246
|
-
* that case we only care about the headers and don't need to
|
1247
|
-
* bother copying the body.
|
1248
|
-
*/
|
728
|
+
/* This call to http_parser_execute will result in invocations of the
|
729
|
+
* on_* family of callbacks. The most interesting of these is
|
730
|
+
* on_body_fill_buffer, which is called when data is ready to be copied
|
731
|
+
* into the target buffer. We need to marshal the buffer, buf_size, and
|
732
|
+
* bytes_read parameters to this callback. */
|
1249
733
|
ctx.t = t;
|
1250
734
|
ctx.s = s;
|
1251
|
-
ctx.buffer =
|
1252
|
-
ctx.buf_size =
|
735
|
+
ctx.buffer = buffer;
|
736
|
+
ctx.buf_size = buf_size;
|
1253
737
|
ctx.bytes_read = bytes_read;
|
1254
738
|
|
1255
739
|
/* Set the context, call the parser, then unset the context. */
|
@@ -1262,40 +746,33 @@ replay:
|
|
1262
746
|
|
1263
747
|
t->parser.data = NULL;
|
1264
748
|
|
1265
|
-
/*
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
goto
|
749
|
+
/* If there was a handled authentication failure, then parse_error
|
750
|
+
* will have signaled us that we should replay the request. */
|
751
|
+
if (PARSE_ERROR_REPLAY == t->parse_error) {
|
752
|
+
s->sent_request = 0;
|
753
|
+
|
754
|
+
if ((error = http_connect(t)) < 0)
|
755
|
+
return error;
|
756
|
+
|
757
|
+
goto replay;
|
758
|
+
}
|
759
|
+
|
760
|
+
if (t->parse_error == PARSE_ERROR_EXT) {
|
761
|
+
return t->error;
|
1274
762
|
}
|
1275
763
|
|
764
|
+
if (t->parse_error < 0)
|
765
|
+
return -1;
|
766
|
+
|
1276
767
|
if (bytes_parsed != t->parse_buffer.offset - data_offset) {
|
1277
|
-
|
768
|
+
giterr_set(GITERR_NET,
|
1278
769
|
"HTTP parser error: %s",
|
1279
770
|
http_errno_description((enum http_errno)t->parser.http_errno));
|
1280
|
-
|
1281
|
-
goto done;
|
771
|
+
return -1;
|
1282
772
|
}
|
1283
773
|
}
|
1284
774
|
|
1285
|
-
|
1286
|
-
|
1287
|
-
if (auth_replay) {
|
1288
|
-
s->sent_request = 0;
|
1289
|
-
|
1290
|
-
if ((error = http_connect(t)) < 0)
|
1291
|
-
return error;
|
1292
|
-
|
1293
|
-
goto replay;
|
1294
|
-
}
|
1295
|
-
|
1296
|
-
done:
|
1297
|
-
git_buf_dispose(&request);
|
1298
|
-
return error;
|
775
|
+
return 0;
|
1299
776
|
}
|
1300
777
|
|
1301
778
|
static int http_stream_write_chunked(
|
@@ -1303,7 +780,7 @@ static int http_stream_write_chunked(
|
|
1303
780
|
const char *buffer,
|
1304
781
|
size_t len)
|
1305
782
|
{
|
1306
|
-
http_stream *s =
|
783
|
+
http_stream *s = (http_stream *)stream;
|
1307
784
|
http_subtransport *t = OWNING_SUBTRANSPORT(s);
|
1308
785
|
|
1309
786
|
assert(t->connected);
|
@@ -1317,13 +794,12 @@ static int http_stream_write_chunked(
|
|
1317
794
|
if (gen_request(&request, s, 0) < 0)
|
1318
795
|
return -1;
|
1319
796
|
|
1320
|
-
if (
|
1321
|
-
|
1322
|
-
git_buf_dispose(&request);
|
797
|
+
if (git_stream_write(t->io, request.ptr, request.size, 0) < 0) {
|
798
|
+
git_buf_free(&request);
|
1323
799
|
return -1;
|
1324
800
|
}
|
1325
801
|
|
1326
|
-
|
802
|
+
git_buf_free(&request);
|
1327
803
|
|
1328
804
|
s->sent_request = 1;
|
1329
805
|
}
|
@@ -1331,25 +807,22 @@ static int http_stream_write_chunked(
|
|
1331
807
|
if (len > CHUNK_SIZE) {
|
1332
808
|
/* Flush, if necessary */
|
1333
809
|
if (s->chunk_buffer_len > 0) {
|
1334
|
-
if (write_chunk(t->
|
1335
|
-
s->chunk_buffer, s->chunk_buffer_len) < 0)
|
810
|
+
if (write_chunk(t->io, s->chunk_buffer, s->chunk_buffer_len) < 0)
|
1336
811
|
return -1;
|
1337
812
|
|
1338
813
|
s->chunk_buffer_len = 0;
|
1339
814
|
}
|
1340
815
|
|
1341
816
|
/* Write chunk directly */
|
1342
|
-
if (write_chunk(t->
|
817
|
+
if (write_chunk(t->io, buffer, len) < 0)
|
1343
818
|
return -1;
|
1344
819
|
}
|
1345
820
|
else {
|
1346
821
|
/* Append as much to the buffer as we can */
|
1347
822
|
int count = min(CHUNK_SIZE - s->chunk_buffer_len, len);
|
1348
823
|
|
1349
|
-
if (!s->chunk_buffer)
|
824
|
+
if (!s->chunk_buffer)
|
1350
825
|
s->chunk_buffer = git__malloc(CHUNK_SIZE);
|
1351
|
-
GIT_ERROR_CHECK_ALLOC(s->chunk_buffer);
|
1352
|
-
}
|
1353
826
|
|
1354
827
|
memcpy(s->chunk_buffer + s->chunk_buffer_len, buffer, count);
|
1355
828
|
s->chunk_buffer_len += count;
|
@@ -1358,8 +831,7 @@ static int http_stream_write_chunked(
|
|
1358
831
|
|
1359
832
|
/* Is the buffer full? If so, then flush */
|
1360
833
|
if (CHUNK_SIZE == s->chunk_buffer_len) {
|
1361
|
-
if (write_chunk(t->
|
1362
|
-
s->chunk_buffer, s->chunk_buffer_len) < 0)
|
834
|
+
if (write_chunk(t->io, s->chunk_buffer, s->chunk_buffer_len) < 0)
|
1363
835
|
return -1;
|
1364
836
|
|
1365
837
|
s->chunk_buffer_len = 0;
|
@@ -1379,14 +851,14 @@ static int http_stream_write_single(
|
|
1379
851
|
const char *buffer,
|
1380
852
|
size_t len)
|
1381
853
|
{
|
1382
|
-
http_stream *s =
|
854
|
+
http_stream *s = (http_stream *)stream;
|
1383
855
|
http_subtransport *t = OWNING_SUBTRANSPORT(s);
|
1384
856
|
git_buf request = GIT_BUF_INIT;
|
1385
857
|
|
1386
858
|
assert(t->connected);
|
1387
859
|
|
1388
860
|
if (s->sent_request) {
|
1389
|
-
|
861
|
+
giterr_set(GITERR_NET, "subtransport configured for only one write");
|
1390
862
|
return -1;
|
1391
863
|
}
|
1392
864
|
|
@@ -1395,25 +867,25 @@ static int http_stream_write_single(
|
|
1395
867
|
if (gen_request(&request, s, len) < 0)
|
1396
868
|
return -1;
|
1397
869
|
|
1398
|
-
if (
|
870
|
+
if (git_stream_write(t->io, request.ptr, request.size, 0) < 0)
|
1399
871
|
goto on_error;
|
1400
872
|
|
1401
|
-
if (len &&
|
873
|
+
if (len && git_stream_write(t->io, buffer, len, 0) < 0)
|
1402
874
|
goto on_error;
|
1403
875
|
|
1404
|
-
|
876
|
+
git_buf_free(&request);
|
1405
877
|
s->sent_request = 1;
|
1406
878
|
|
1407
879
|
return 0;
|
1408
880
|
|
1409
881
|
on_error:
|
1410
|
-
|
882
|
+
git_buf_free(&request);
|
1411
883
|
return -1;
|
1412
884
|
}
|
1413
885
|
|
1414
886
|
static void http_stream_free(git_smart_subtransport_stream *stream)
|
1415
887
|
{
|
1416
|
-
http_stream *s =
|
888
|
+
http_stream *s = (http_stream *)stream;
|
1417
889
|
|
1418
890
|
if (s->chunk_buffer)
|
1419
891
|
git__free(s->chunk_buffer);
|
@@ -1433,7 +905,7 @@ static int http_stream_alloc(http_subtransport *t,
|
|
1433
905
|
return -1;
|
1434
906
|
|
1435
907
|
s = git__calloc(sizeof(http_stream), 1);
|
1436
|
-
|
908
|
+
GITERR_CHECK_ALLOC(s);
|
1437
909
|
|
1438
910
|
s->parent.subtransport = &t->parent;
|
1439
911
|
s->parent.read = http_stream_read;
|
@@ -1526,24 +998,16 @@ static int http_action(
|
|
1526
998
|
const char *url,
|
1527
999
|
git_smart_service_t action)
|
1528
1000
|
{
|
1529
|
-
http_subtransport *t =
|
1001
|
+
http_subtransport *t = (http_subtransport *)subtransport;
|
1530
1002
|
int ret;
|
1531
1003
|
|
1532
|
-
|
1004
|
+
if (!stream)
|
1005
|
+
return -1;
|
1533
1006
|
|
1534
|
-
|
1535
|
-
|
1536
|
-
* been given. This is important to continue authorization against
|
1537
|
-
* the redirect target, not the user-given source; the endpoint may
|
1538
|
-
* have redirected us from HTTP->HTTPS and is using an auth mechanism
|
1539
|
-
* that would be insecure in plaintext (eg, HTTP Basic).
|
1540
|
-
*/
|
1541
|
-
if ((!t->server.url.host || !t->server.url.port || !t->server.url.path) &&
|
1542
|
-
(ret = git_net_url_parse(&t->server.url, url)) < 0)
|
1007
|
+
if ((!t->connection_data.host || !t->connection_data.port || !t->connection_data.path) &&
|
1008
|
+
(ret = gitno_connection_data_from_url(&t->connection_data, url, NULL)) < 0)
|
1543
1009
|
return ret;
|
1544
1010
|
|
1545
|
-
assert(t->server.url.host && t->server.url.port && t->server.url.path);
|
1546
|
-
|
1547
1011
|
if ((ret = http_connect(t)) < 0)
|
1548
1012
|
return ret;
|
1549
1013
|
|
@@ -1567,47 +1031,50 @@ static int http_action(
|
|
1567
1031
|
|
1568
1032
|
static int http_close(git_smart_subtransport *subtransport)
|
1569
1033
|
{
|
1570
|
-
http_subtransport *t =
|
1034
|
+
http_subtransport *t = (http_subtransport *) subtransport;
|
1035
|
+
git_http_auth_context *context;
|
1036
|
+
size_t i;
|
1571
1037
|
|
1572
1038
|
clear_parser_state(t);
|
1573
1039
|
|
1574
1040
|
t->connected = 0;
|
1575
1041
|
|
1576
|
-
if (t->
|
1577
|
-
git_stream_close(t->
|
1578
|
-
git_stream_free(t->
|
1579
|
-
t->
|
1042
|
+
if (t->io) {
|
1043
|
+
git_stream_close(t->io);
|
1044
|
+
git_stream_free(t->io);
|
1045
|
+
t->io = NULL;
|
1580
1046
|
}
|
1581
1047
|
|
1582
|
-
if (t->
|
1583
|
-
|
1584
|
-
|
1585
|
-
t->proxy.stream = NULL;
|
1048
|
+
if (t->cred) {
|
1049
|
+
t->cred->free(t->cred);
|
1050
|
+
t->cred = NULL;
|
1586
1051
|
}
|
1587
1052
|
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
free_auth_context(&t->proxy);
|
1053
|
+
if (t->url_cred) {
|
1054
|
+
t->url_cred->free(t->url_cred);
|
1055
|
+
t->url_cred = NULL;
|
1056
|
+
}
|
1593
1057
|
|
1594
|
-
t->
|
1595
|
-
|
1058
|
+
git_vector_foreach(&t->auth_contexts, i, context) {
|
1059
|
+
if (context->free)
|
1060
|
+
context->free(context);
|
1061
|
+
}
|
1596
1062
|
|
1597
|
-
|
1598
|
-
git_net_url_dispose(&t->proxy.url);
|
1063
|
+
git_vector_clear(&t->auth_contexts);
|
1599
1064
|
|
1600
|
-
|
1601
|
-
t->
|
1065
|
+
gitno_connection_data_free_ptrs(&t->connection_data);
|
1066
|
+
memset(&t->connection_data, 0x0, sizeof(gitno_connection_data));
|
1602
1067
|
|
1603
1068
|
return 0;
|
1604
1069
|
}
|
1605
1070
|
|
1606
1071
|
static void http_free(git_smart_subtransport *subtransport)
|
1607
1072
|
{
|
1608
|
-
http_subtransport *t =
|
1073
|
+
http_subtransport *t = (http_subtransport *) subtransport;
|
1609
1074
|
|
1610
1075
|
http_close(subtransport);
|
1076
|
+
|
1077
|
+
git_vector_free(&t->auth_contexts);
|
1611
1078
|
git__free(t);
|
1612
1079
|
}
|
1613
1080
|
|
@@ -1621,7 +1088,7 @@ int git_smart_subtransport_http(git_smart_subtransport **out, git_transport *own
|
|
1621
1088
|
return -1;
|
1622
1089
|
|
1623
1090
|
t = git__calloc(sizeof(http_subtransport), 1);
|
1624
|
-
|
1091
|
+
GITERR_CHECK_ALLOC(t);
|
1625
1092
|
|
1626
1093
|
t->owner = (transport_smart *)owner;
|
1627
1094
|
t->parent.action = http_action;
|