rugged 0.28.3.1 → 0.28.4
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 +1 -0
- data/vendor/libgit2/CMakeLists.txt +36 -16
- data/vendor/libgit2/COPYING +28 -0
- data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +5 -1
- data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +2 -2
- data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +1 -1
- data/vendor/libgit2/cmake/Modules/FindGSSFramework.cmake +28 -0
- data/vendor/libgit2/cmake/Modules/FindPCRE.cmake +38 -0
- data/vendor/libgit2/cmake/Modules/FindPCRE2.cmake +37 -0
- data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +2 -2
- data/vendor/libgit2/cmake/Modules/FindStatNsec.cmake +6 -0
- data/vendor/libgit2/cmake/Modules/PkgBuildConfig.cmake +110 -0
- data/vendor/libgit2/cmake/Modules/SelectGSSAPI.cmake +53 -0
- data/vendor/libgit2/cmake/Modules/SelectHTTPSBackend.cmake +124 -0
- data/vendor/libgit2/cmake/Modules/SelectHashes.cmake +66 -0
- data/vendor/libgit2/deps/http-parser/http_parser.c +11 -6
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +21 -0
- data/vendor/libgit2/deps/ntlmclient/compat.h +33 -0
- data/vendor/libgit2/deps/ntlmclient/crypt.h +64 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +120 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +18 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +145 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +18 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +130 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +21 -0
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +1420 -0
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +174 -0
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +320 -0
- data/vendor/libgit2/deps/ntlmclient/unicode.h +36 -0
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +445 -0
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +201 -0
- data/vendor/libgit2/deps/ntlmclient/utf8.h +1257 -0
- data/vendor/libgit2/deps/ntlmclient/util.c +21 -0
- data/vendor/libgit2/deps/ntlmclient/util.h +14 -0
- data/vendor/libgit2/deps/pcre/CMakeLists.txt +140 -0
- data/vendor/libgit2/deps/pcre/COPYING +5 -0
- data/vendor/libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS +22 -0
- data/vendor/libgit2/deps/pcre/cmake/FindEditline.cmake +17 -0
- data/vendor/libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake +58 -0
- data/vendor/libgit2/deps/pcre/cmake/FindReadline.cmake +29 -0
- data/vendor/libgit2/deps/pcre/config.h.in +57 -0
- data/vendor/libgit2/deps/pcre/pcre.h +641 -0
- data/vendor/libgit2/deps/pcre/pcre_byte_order.c +319 -0
- data/vendor/libgit2/deps/pcre/pcre_chartables.c +198 -0
- data/vendor/libgit2/deps/pcre/pcre_compile.c +9800 -0
- data/vendor/libgit2/deps/pcre/pcre_config.c +190 -0
- data/vendor/libgit2/deps/pcre/pcre_dfa_exec.c +3676 -0
- data/vendor/libgit2/deps/pcre/pcre_exec.c +7173 -0
- data/vendor/libgit2/deps/pcre/pcre_fullinfo.c +245 -0
- data/vendor/libgit2/deps/pcre/pcre_get.c +669 -0
- data/vendor/libgit2/deps/pcre/pcre_globals.c +86 -0
- data/vendor/libgit2/deps/pcre/pcre_internal.h +2787 -0
- data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +11913 -0
- data/vendor/libgit2/deps/pcre/pcre_maketables.c +156 -0
- data/vendor/libgit2/deps/pcre/pcre_newline.c +210 -0
- data/vendor/libgit2/deps/pcre/pcre_ord2utf8.c +94 -0
- data/vendor/libgit2/deps/pcre/pcre_printint.c +834 -0
- data/vendor/libgit2/deps/pcre/pcre_refcount.c +92 -0
- data/vendor/libgit2/deps/pcre/pcre_string_utils.c +211 -0
- data/vendor/libgit2/deps/pcre/pcre_study.c +1686 -0
- data/vendor/libgit2/deps/pcre/pcre_tables.c +727 -0
- data/vendor/libgit2/deps/pcre/pcre_ucd.c +3644 -0
- data/vendor/libgit2/deps/pcre/pcre_valid_utf8.c +301 -0
- data/vendor/libgit2/deps/pcre/pcre_version.c +98 -0
- data/vendor/libgit2/deps/pcre/pcre_xclass.c +268 -0
- data/vendor/libgit2/deps/pcre/pcreposix.c +421 -0
- data/vendor/libgit2/deps/pcre/pcreposix.h +117 -0
- data/vendor/libgit2/deps/pcre/ucp.h +224 -0
- data/vendor/libgit2/deps/zlib/adler32.c +0 -7
- data/vendor/libgit2/deps/zlib/crc32.c +0 -7
- data/vendor/libgit2/include/git2.h +2 -0
- data/vendor/libgit2/include/git2/apply.h +22 -2
- data/vendor/libgit2/include/git2/attr.h +19 -12
- data/vendor/libgit2/include/git2/blame.h +2 -2
- data/vendor/libgit2/include/git2/blob.h +44 -12
- data/vendor/libgit2/include/git2/buffer.h +20 -14
- data/vendor/libgit2/include/git2/cert.h +135 -0
- data/vendor/libgit2/include/git2/checkout.h +46 -14
- data/vendor/libgit2/include/git2/cherrypick.h +3 -3
- data/vendor/libgit2/include/git2/clone.h +2 -2
- data/vendor/libgit2/include/git2/commit.h +23 -1
- data/vendor/libgit2/include/git2/common.h +7 -5
- data/vendor/libgit2/include/git2/config.h +12 -12
- data/vendor/libgit2/include/git2/cred.h +308 -0
- data/vendor/libgit2/include/git2/deprecated.h +243 -3
- data/vendor/libgit2/include/git2/describe.h +4 -4
- data/vendor/libgit2/include/git2/diff.h +16 -14
- data/vendor/libgit2/include/git2/filter.h +8 -0
- data/vendor/libgit2/include/git2/index.h +2 -1
- data/vendor/libgit2/include/git2/indexer.h +48 -4
- data/vendor/libgit2/include/git2/merge.h +6 -10
- data/vendor/libgit2/include/git2/net.h +0 -5
- data/vendor/libgit2/include/git2/object.h +2 -14
- data/vendor/libgit2/include/git2/odb.h +3 -2
- data/vendor/libgit2/include/git2/odb_backend.h +5 -4
- data/vendor/libgit2/include/git2/oid.h +1 -1
- data/vendor/libgit2/include/git2/pack.h +12 -1
- data/vendor/libgit2/include/git2/proxy.h +5 -3
- data/vendor/libgit2/include/git2/rebase.h +46 -2
- data/vendor/libgit2/include/git2/refs.h +19 -0
- data/vendor/libgit2/include/git2/remote.h +35 -12
- data/vendor/libgit2/include/git2/repository.h +24 -2
- data/vendor/libgit2/include/git2/revert.h +1 -1
- data/vendor/libgit2/include/git2/stash.h +3 -3
- data/vendor/libgit2/include/git2/status.h +25 -16
- data/vendor/libgit2/include/git2/submodule.h +20 -3
- data/vendor/libgit2/include/git2/sys/alloc.h +9 -9
- data/vendor/libgit2/include/git2/sys/cred.h +90 -0
- data/vendor/libgit2/include/git2/sys/odb_backend.h +48 -4
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +57 -21
- data/vendor/libgit2/include/git2/sys/repository.h +5 -1
- data/vendor/libgit2/include/git2/sys/transport.h +2 -2
- data/vendor/libgit2/include/git2/tag.h +11 -2
- data/vendor/libgit2/include/git2/trace.h +2 -2
- data/vendor/libgit2/include/git2/transport.h +11 -340
- data/vendor/libgit2/include/git2/tree.h +1 -1
- data/vendor/libgit2/include/git2/types.h +4 -89
- data/vendor/libgit2/include/git2/version.h +2 -2
- data/vendor/libgit2/include/git2/worktree.h +5 -5
- data/vendor/libgit2/src/CMakeLists.txt +88 -222
- data/vendor/libgit2/src/alloc.c +2 -14
- data/vendor/libgit2/src/{stdalloc.c → allocators/stdalloc.c} +3 -4
- data/vendor/libgit2/src/{stdalloc.h → allocators/stdalloc.h} +4 -4
- data/vendor/libgit2/src/allocators/win32_crtdbg.c +118 -0
- data/vendor/libgit2/src/{transports/cred.h → allocators/win32_crtdbg.h} +5 -4
- data/vendor/libgit2/src/apply.c +60 -30
- data/vendor/libgit2/src/attr.c +70 -64
- data/vendor/libgit2/src/attr_file.c +189 -96
- data/vendor/libgit2/src/attr_file.h +9 -9
- data/vendor/libgit2/src/attrcache.c +44 -46
- data/vendor/libgit2/src/attrcache.h +2 -1
- data/vendor/libgit2/src/blame.c +17 -5
- data/vendor/libgit2/src/blame.h +1 -1
- data/vendor/libgit2/src/blame_git.c +21 -7
- data/vendor/libgit2/src/blob.c +81 -17
- data/vendor/libgit2/src/blob.h +2 -2
- data/vendor/libgit2/src/branch.c +29 -5
- data/vendor/libgit2/src/buffer.c +14 -7
- data/vendor/libgit2/src/cache.c +26 -33
- data/vendor/libgit2/src/cache.h +1 -1
- data/vendor/libgit2/src/cc-compat.h +5 -0
- data/vendor/libgit2/src/checkout.c +26 -16
- data/vendor/libgit2/src/cherrypick.c +9 -3
- data/vendor/libgit2/src/clone.c +29 -7
- data/vendor/libgit2/src/clone.h +4 -0
- data/vendor/libgit2/src/commit.c +69 -21
- data/vendor/libgit2/src/commit.h +6 -0
- data/vendor/libgit2/src/commit_list.c +28 -76
- data/vendor/libgit2/src/commit_list.h +2 -2
- data/vendor/libgit2/src/common.h +3 -75
- data/vendor/libgit2/src/config.c +31 -40
- data/vendor/libgit2/src/config.h +7 -6
- data/vendor/libgit2/src/config_backend.h +12 -0
- data/vendor/libgit2/src/config_cache.c +39 -39
- data/vendor/libgit2/src/config_entries.c +69 -99
- data/vendor/libgit2/src/config_entries.h +1 -0
- data/vendor/libgit2/src/config_file.c +337 -380
- data/vendor/libgit2/src/config_mem.c +12 -16
- data/vendor/libgit2/src/config_parse.c +49 -29
- data/vendor/libgit2/src/config_parse.h +13 -12
- data/vendor/libgit2/src/config_snapshot.c +206 -0
- data/vendor/libgit2/src/crlf.c +14 -14
- data/vendor/libgit2/src/describe.c +21 -20
- data/vendor/libgit2/src/diff.c +43 -58
- data/vendor/libgit2/src/diff.h +2 -1
- data/vendor/libgit2/src/diff_driver.c +37 -38
- data/vendor/libgit2/src/diff_file.c +9 -7
- data/vendor/libgit2/src/diff_file.h +1 -1
- data/vendor/libgit2/src/diff_generate.c +135 -85
- data/vendor/libgit2/src/diff_generate.h +2 -2
- data/vendor/libgit2/src/diff_parse.c +1 -1
- data/vendor/libgit2/src/diff_print.c +25 -13
- data/vendor/libgit2/src/diff_stats.c +1 -1
- data/vendor/libgit2/src/diff_tform.c +4 -4
- data/vendor/libgit2/src/errors.c +12 -22
- data/vendor/libgit2/src/errors.h +81 -0
- data/vendor/libgit2/src/features.h.in +9 -2
- data/vendor/libgit2/src/fetch.c +7 -2
- data/vendor/libgit2/src/fetchhead.c +1 -1
- data/vendor/libgit2/src/filebuf.c +6 -10
- data/vendor/libgit2/src/filebuf.h +2 -2
- data/vendor/libgit2/src/filter.c +16 -8
- data/vendor/libgit2/src/{fileops.c → futils.c} +21 -17
- data/vendor/libgit2/src/{fileops.h → futils.h} +5 -5
- data/vendor/libgit2/src/global.c +12 -40
- data/vendor/libgit2/src/global.h +0 -2
- data/vendor/libgit2/src/hash.c +61 -0
- data/vendor/libgit2/src/hash.h +19 -21
- data/vendor/libgit2/src/hash/sha1.h +38 -0
- data/vendor/libgit2/src/hash/{hash_collisiondetect.h → sha1/collisiondetect.c} +14 -17
- data/vendor/libgit2/src/hash/sha1/collisiondetect.h +19 -0
- data/vendor/libgit2/src/hash/{hash_common_crypto.h → sha1/common_crypto.c} +15 -19
- data/vendor/libgit2/src/hash/sha1/common_crypto.h +19 -0
- data/vendor/libgit2/src/hash/{hash_generic.c → sha1/generic.c} +22 -10
- data/vendor/libgit2/src/hash/{hash_generic.h → sha1/generic.h} +4 -14
- data/vendor/libgit2/src/hash/{hash_mbedtls.c → sha1/mbedtls.c} +15 -7
- data/vendor/libgit2/src/hash/{hash_mbedtls.h → sha1/mbedtls.h} +6 -11
- data/vendor/libgit2/src/hash/{hash_openssl.h → sha1/openssl.c} +14 -18
- data/vendor/libgit2/src/hash/sha1/openssl.h +19 -0
- data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.c +14 -3
- data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.h +0 -0
- data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.c +0 -0
- data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.h +0 -0
- data/vendor/libgit2/src/hash/{hash_win32.c → sha1/win32.c} +34 -24
- data/vendor/libgit2/src/hash/{hash_win32.h → sha1/win32.h} +6 -19
- data/vendor/libgit2/src/hashsig.c +1 -1
- data/vendor/libgit2/src/idxmap.c +91 -65
- data/vendor/libgit2/src/idxmap.h +151 -15
- data/vendor/libgit2/src/ignore.c +32 -38
- data/vendor/libgit2/src/index.c +66 -43
- data/vendor/libgit2/src/index.h +1 -1
- data/vendor/libgit2/src/indexer.c +69 -70
- data/vendor/libgit2/src/integer.h +39 -4
- data/vendor/libgit2/src/iterator.c +27 -22
- data/vendor/libgit2/src/map.h +1 -1
- data/vendor/libgit2/src/merge.c +58 -44
- data/vendor/libgit2/src/merge_driver.c +4 -4
- data/vendor/libgit2/src/merge_file.c +1 -1
- data/vendor/libgit2/src/mwindow.c +18 -23
- data/vendor/libgit2/src/mwindow.h +4 -4
- data/vendor/libgit2/src/net.c +184 -0
- data/vendor/libgit2/src/net.h +36 -0
- data/vendor/libgit2/src/netops.c +55 -165
- data/vendor/libgit2/src/netops.h +3 -25
- data/vendor/libgit2/src/notes.c +2 -2
- data/vendor/libgit2/src/object.c +2 -2
- data/vendor/libgit2/src/object.h +2 -0
- data/vendor/libgit2/src/odb.c +41 -23
- data/vendor/libgit2/src/odb.h +3 -2
- data/vendor/libgit2/src/odb_loose.c +17 -10
- data/vendor/libgit2/src/odb_mempack.c +10 -23
- data/vendor/libgit2/src/odb_pack.c +4 -4
- data/vendor/libgit2/src/offmap.c +43 -55
- data/vendor/libgit2/src/offmap.h +102 -24
- data/vendor/libgit2/src/oid.c +6 -1
- data/vendor/libgit2/src/oidmap.c +39 -57
- data/vendor/libgit2/src/oidmap.h +99 -19
- data/vendor/libgit2/src/pack-objects.c +25 -32
- data/vendor/libgit2/src/pack-objects.h +1 -1
- data/vendor/libgit2/src/pack.c +45 -47
- data/vendor/libgit2/src/pack.h +12 -14
- data/vendor/libgit2/src/parse.c +10 -0
- data/vendor/libgit2/src/parse.h +3 -3
- data/vendor/libgit2/src/patch.c +1 -1
- data/vendor/libgit2/src/patch_generate.c +2 -2
- data/vendor/libgit2/src/patch_parse.c +124 -31
- data/vendor/libgit2/src/path.c +95 -27
- data/vendor/libgit2/src/path.h +2 -0
- data/vendor/libgit2/src/pathspec.c +13 -13
- data/vendor/libgit2/src/pool.c +26 -22
- data/vendor/libgit2/src/pool.h +7 -7
- data/vendor/libgit2/src/posix.c +7 -7
- data/vendor/libgit2/src/posix.h +12 -1
- data/vendor/libgit2/src/proxy.c +7 -2
- data/vendor/libgit2/src/push.c +10 -5
- data/vendor/libgit2/src/reader.c +2 -2
- data/vendor/libgit2/src/rebase.c +66 -7
- data/vendor/libgit2/src/refdb.c +12 -0
- data/vendor/libgit2/src/refdb_fs.c +214 -165
- data/vendor/libgit2/src/reflog.c +11 -13
- data/vendor/libgit2/src/refs.c +24 -18
- data/vendor/libgit2/src/refspec.c +9 -16
- data/vendor/libgit2/src/regexp.c +221 -0
- data/vendor/libgit2/src/regexp.h +97 -0
- data/vendor/libgit2/src/remote.c +50 -52
- data/vendor/libgit2/src/remote.h +2 -2
- data/vendor/libgit2/src/repository.c +115 -100
- data/vendor/libgit2/src/repository.h +49 -40
- data/vendor/libgit2/src/revert.c +8 -3
- data/vendor/libgit2/src/revparse.c +18 -19
- data/vendor/libgit2/src/revwalk.c +63 -30
- data/vendor/libgit2/src/revwalk.h +20 -0
- data/vendor/libgit2/src/settings.c +5 -0
- data/vendor/libgit2/src/sortedcache.c +12 -26
- data/vendor/libgit2/src/sortedcache.h +1 -1
- data/vendor/libgit2/src/stash.c +45 -65
- data/vendor/libgit2/src/status.c +15 -9
- data/vendor/libgit2/src/streams/openssl.c +20 -0
- data/vendor/libgit2/src/streams/socket.c +2 -2
- data/vendor/libgit2/src/strmap.c +37 -84
- data/vendor/libgit2/src/strmap.h +105 -33
- data/vendor/libgit2/src/submodule.c +102 -70
- data/vendor/libgit2/src/submodule.h +1 -1
- data/vendor/libgit2/src/sysdir.c +11 -1
- data/vendor/libgit2/src/tag.c +10 -2
- data/vendor/libgit2/src/trace.c +1 -1
- data/vendor/libgit2/src/trace.h +2 -2
- data/vendor/libgit2/src/trailer.c +46 -32
- data/vendor/libgit2/src/transaction.c +10 -9
- data/vendor/libgit2/src/transports/auth.c +10 -9
- data/vendor/libgit2/src/transports/auth.h +11 -4
- data/vendor/libgit2/src/transports/auth_negotiate.c +23 -9
- data/vendor/libgit2/src/transports/auth_negotiate.h +2 -2
- data/vendor/libgit2/src/transports/auth_ntlm.c +223 -0
- data/vendor/libgit2/src/transports/auth_ntlm.h +35 -0
- data/vendor/libgit2/src/transports/cred.c +6 -6
- data/vendor/libgit2/src/transports/git.c +11 -16
- data/vendor/libgit2/src/transports/http.c +419 -276
- data/vendor/libgit2/src/transports/http.h +1 -1
- data/vendor/libgit2/src/transports/local.c +9 -9
- data/vendor/libgit2/src/transports/smart.c +17 -17
- data/vendor/libgit2/src/transports/smart.h +2 -2
- data/vendor/libgit2/src/transports/smart_protocol.c +36 -60
- data/vendor/libgit2/src/transports/ssh.c +46 -36
- data/vendor/libgit2/src/transports/winhttp.c +231 -207
- data/vendor/libgit2/src/tree-cache.c +14 -7
- data/vendor/libgit2/src/tree.c +10 -24
- data/vendor/libgit2/src/unix/map.c +1 -1
- data/vendor/libgit2/src/unix/posix.h +1 -11
- data/vendor/libgit2/src/userdiff.h +3 -1
- data/vendor/libgit2/src/util.c +51 -53
- data/vendor/libgit2/src/util.h +16 -21
- data/vendor/libgit2/src/wildmatch.c +320 -0
- data/vendor/libgit2/src/wildmatch.h +23 -0
- data/vendor/libgit2/src/win32/map.c +3 -5
- data/vendor/libgit2/src/win32/path_w32.c +12 -2
- data/vendor/libgit2/src/win32/path_w32.h +0 -29
- data/vendor/libgit2/src/win32/posix.h +1 -4
- data/vendor/libgit2/src/win32/posix_w32.c +40 -5
- data/vendor/libgit2/src/win32/precompiled.h +0 -2
- data/vendor/libgit2/src/win32/thread.c +5 -10
- data/vendor/libgit2/src/win32/w32_buffer.c +7 -3
- data/vendor/libgit2/src/win32/w32_common.h +39 -0
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +0 -93
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -2
- data/vendor/libgit2/src/win32/w32_stack.c +4 -9
- data/vendor/libgit2/src/win32/w32_stack.h +3 -3
- data/vendor/libgit2/src/win32/w32_util.c +31 -0
- data/vendor/libgit2/src/win32/w32_util.h +6 -32
- data/vendor/libgit2/src/worktree.c +36 -22
- data/vendor/libgit2/src/xdiff/xdiffi.c +1 -1
- data/vendor/libgit2/src/xdiff/xmerge.c +12 -0
- data/vendor/libgit2/src/xdiff/xpatience.c +3 -0
- metadata +98 -34
- data/vendor/libgit2/deps/regex/CMakeLists.txt +0 -2
- data/vendor/libgit2/deps/regex/COPYING +0 -502
- data/vendor/libgit2/deps/regex/config.h +0 -7
- data/vendor/libgit2/deps/regex/regcomp.c +0 -3857
- data/vendor/libgit2/deps/regex/regex.c +0 -92
- data/vendor/libgit2/deps/regex/regex.h +0 -582
- data/vendor/libgit2/deps/regex/regex_internal.c +0 -1744
- data/vendor/libgit2/deps/regex/regex_internal.h +0 -819
- data/vendor/libgit2/deps/regex/regexec.c +0 -4369
- data/vendor/libgit2/include/git2/inttypes.h +0 -309
- data/vendor/libgit2/include/git2/sys/time.h +0 -31
- data/vendor/libgit2/libgit2.pc.in +0 -13
- data/vendor/libgit2/src/fnmatch.c +0 -248
- data/vendor/libgit2/src/fnmatch.h +0 -48
@@ -12,11 +12,11 @@
|
|
12
12
|
#include "git2.h"
|
13
13
|
#include "auth.h"
|
14
14
|
|
15
|
-
#
|
15
|
+
#if defined(GIT_GSSAPI) || defined(GIT_GSSFRAMEWORK)
|
16
16
|
|
17
17
|
extern int git_http_auth_negotiate(
|
18
18
|
git_http_auth_context **out,
|
19
|
-
const
|
19
|
+
const git_net_url *url);
|
20
20
|
|
21
21
|
#else
|
22
22
|
|
@@ -0,0 +1,223 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) the libgit2 contributors. All rights reserved.
|
3
|
+
*
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include "git2.h"
|
9
|
+
#include "common.h"
|
10
|
+
#include "buffer.h"
|
11
|
+
#include "auth.h"
|
12
|
+
#include "auth_ntlm.h"
|
13
|
+
#include "git2/sys/cred.h"
|
14
|
+
|
15
|
+
#ifdef GIT_NTLM
|
16
|
+
|
17
|
+
#include "ntlm.h"
|
18
|
+
|
19
|
+
typedef struct {
|
20
|
+
git_http_auth_context parent;
|
21
|
+
ntlm_client *ntlm;
|
22
|
+
char *challenge;
|
23
|
+
bool complete;
|
24
|
+
} http_auth_ntlm_context;
|
25
|
+
|
26
|
+
static int ntlm_set_challenge(
|
27
|
+
git_http_auth_context *c,
|
28
|
+
const char *challenge)
|
29
|
+
{
|
30
|
+
http_auth_ntlm_context *ctx = (http_auth_ntlm_context *)c;
|
31
|
+
|
32
|
+
assert(ctx && challenge);
|
33
|
+
|
34
|
+
git__free(ctx->challenge);
|
35
|
+
|
36
|
+
ctx->challenge = git__strdup(challenge);
|
37
|
+
GIT_ERROR_CHECK_ALLOC(ctx->challenge);
|
38
|
+
|
39
|
+
return 0;
|
40
|
+
}
|
41
|
+
|
42
|
+
static int ntlm_set_credentials(http_auth_ntlm_context *ctx, git_cred *_cred)
|
43
|
+
{
|
44
|
+
git_cred_userpass_plaintext *cred;
|
45
|
+
const char *sep, *username;
|
46
|
+
char *domain = NULL, *domainuser = NULL;
|
47
|
+
int error = 0;
|
48
|
+
|
49
|
+
assert(_cred->credtype == GIT_CREDTYPE_USERPASS_PLAINTEXT);
|
50
|
+
cred = (git_cred_userpass_plaintext *)_cred;
|
51
|
+
|
52
|
+
if ((sep = strchr(cred->username, '\\')) != NULL) {
|
53
|
+
domain = strndup(cred->username, (sep - cred->username));
|
54
|
+
GIT_ERROR_CHECK_ALLOC(domain);
|
55
|
+
|
56
|
+
domainuser = strdup(sep + 1);
|
57
|
+
GIT_ERROR_CHECK_ALLOC(domainuser);
|
58
|
+
|
59
|
+
username = domainuser;
|
60
|
+
} else {
|
61
|
+
username = cred->username;
|
62
|
+
}
|
63
|
+
|
64
|
+
if (ntlm_client_set_credentials(ctx->ntlm,
|
65
|
+
username, domain, cred->password) < 0) {
|
66
|
+
git_error_set(GIT_ERROR_NET, "could not set credentials: %s",
|
67
|
+
ntlm_client_errmsg(ctx->ntlm));
|
68
|
+
error = -1;
|
69
|
+
goto done;
|
70
|
+
}
|
71
|
+
|
72
|
+
done:
|
73
|
+
git__free(domain);
|
74
|
+
git__free(domainuser);
|
75
|
+
return error;
|
76
|
+
}
|
77
|
+
|
78
|
+
static int ntlm_next_token(
|
79
|
+
git_buf *buf,
|
80
|
+
git_http_auth_context *c,
|
81
|
+
git_cred *cred)
|
82
|
+
{
|
83
|
+
http_auth_ntlm_context *ctx = (http_auth_ntlm_context *)c;
|
84
|
+
git_buf input_buf = GIT_BUF_INIT;
|
85
|
+
const unsigned char *msg;
|
86
|
+
size_t challenge_len, msg_len;
|
87
|
+
int error = -1;
|
88
|
+
|
89
|
+
assert(buf && ctx && ctx->ntlm);
|
90
|
+
|
91
|
+
challenge_len = ctx->challenge ? strlen(ctx->challenge) : 0;
|
92
|
+
|
93
|
+
if (ctx->complete)
|
94
|
+
ntlm_client_reset(ctx->ntlm);
|
95
|
+
|
96
|
+
/*
|
97
|
+
* Set us complete now since it's the default case; the one
|
98
|
+
* incomplete case (successfully created a client request)
|
99
|
+
* will explicitly set that it requires a second step.
|
100
|
+
*/
|
101
|
+
ctx->complete = true;
|
102
|
+
|
103
|
+
if (cred && ntlm_set_credentials(ctx, cred) != 0)
|
104
|
+
goto done;
|
105
|
+
|
106
|
+
if (challenge_len < 4) {
|
107
|
+
git_error_set(GIT_ERROR_NET, "no ntlm challenge sent from server");
|
108
|
+
goto done;
|
109
|
+
} else if (challenge_len == 4) {
|
110
|
+
if (memcmp(ctx->challenge, "NTLM", 4) != 0) {
|
111
|
+
git_error_set(GIT_ERROR_NET, "server did not request NTLM");
|
112
|
+
goto done;
|
113
|
+
}
|
114
|
+
|
115
|
+
if (ntlm_client_negotiate(&msg, &msg_len, ctx->ntlm) != 0) {
|
116
|
+
git_error_set(GIT_ERROR_NET, "ntlm authentication failed: %s",
|
117
|
+
ntlm_client_errmsg(ctx->ntlm));
|
118
|
+
goto done;
|
119
|
+
}
|
120
|
+
|
121
|
+
ctx->complete = false;
|
122
|
+
} else {
|
123
|
+
if (memcmp(ctx->challenge, "NTLM ", 5) != 0) {
|
124
|
+
git_error_set(GIT_ERROR_NET, "challenge from server was not NTLM");
|
125
|
+
goto done;
|
126
|
+
}
|
127
|
+
|
128
|
+
if (git_buf_decode_base64(&input_buf,
|
129
|
+
ctx->challenge + 5, challenge_len - 5) < 0) {
|
130
|
+
git_error_set(GIT_ERROR_NET, "invalid NTLM challenge from server");
|
131
|
+
goto done;
|
132
|
+
}
|
133
|
+
|
134
|
+
if (ntlm_client_set_challenge(ctx->ntlm,
|
135
|
+
(const unsigned char *)input_buf.ptr, input_buf.size) != 0) {
|
136
|
+
git_error_set(GIT_ERROR_NET, "ntlm challenge failed: %s",
|
137
|
+
ntlm_client_errmsg(ctx->ntlm));
|
138
|
+
goto done;
|
139
|
+
}
|
140
|
+
|
141
|
+
if (ntlm_client_response(&msg, &msg_len, ctx->ntlm) != 0) {
|
142
|
+
git_error_set(GIT_ERROR_NET, "ntlm authentication failed: %s",
|
143
|
+
ntlm_client_errmsg(ctx->ntlm));
|
144
|
+
goto done;
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
git_buf_puts(buf, "NTLM ");
|
149
|
+
git_buf_encode_base64(buf, (const char *)msg, msg_len);
|
150
|
+
|
151
|
+
if (git_buf_oom(buf))
|
152
|
+
goto done;
|
153
|
+
|
154
|
+
error = 0;
|
155
|
+
|
156
|
+
done:
|
157
|
+
git_buf_dispose(&input_buf);
|
158
|
+
return error;
|
159
|
+
}
|
160
|
+
|
161
|
+
static int ntlm_is_complete(git_http_auth_context *c)
|
162
|
+
{
|
163
|
+
http_auth_ntlm_context *ctx = (http_auth_ntlm_context *)c;
|
164
|
+
|
165
|
+
assert(ctx);
|
166
|
+
return (ctx->complete == true);
|
167
|
+
}
|
168
|
+
|
169
|
+
static void ntlm_context_free(git_http_auth_context *c)
|
170
|
+
{
|
171
|
+
http_auth_ntlm_context *ctx = (http_auth_ntlm_context *)c;
|
172
|
+
|
173
|
+
ntlm_client_free(ctx->ntlm);
|
174
|
+
git__free(ctx->challenge);
|
175
|
+
git__free(ctx);
|
176
|
+
}
|
177
|
+
|
178
|
+
static int ntlm_init_context(
|
179
|
+
http_auth_ntlm_context *ctx,
|
180
|
+
const git_net_url *url)
|
181
|
+
{
|
182
|
+
GIT_UNUSED(url);
|
183
|
+
|
184
|
+
if ((ctx->ntlm = ntlm_client_init(NTLM_CLIENT_DEFAULTS)) == NULL) {
|
185
|
+
git_error_set_oom();
|
186
|
+
return -1;
|
187
|
+
}
|
188
|
+
|
189
|
+
return 0;
|
190
|
+
}
|
191
|
+
|
192
|
+
int git_http_auth_ntlm(
|
193
|
+
git_http_auth_context **out,
|
194
|
+
const git_net_url *url)
|
195
|
+
{
|
196
|
+
http_auth_ntlm_context *ctx;
|
197
|
+
|
198
|
+
GIT_UNUSED(url);
|
199
|
+
|
200
|
+
*out = NULL;
|
201
|
+
|
202
|
+
ctx = git__calloc(1, sizeof(http_auth_ntlm_context));
|
203
|
+
GIT_ERROR_CHECK_ALLOC(ctx);
|
204
|
+
|
205
|
+
if (ntlm_init_context(ctx, url) < 0) {
|
206
|
+
git__free(ctx);
|
207
|
+
return -1;
|
208
|
+
}
|
209
|
+
|
210
|
+
ctx->parent.type = GIT_AUTHTYPE_NTLM;
|
211
|
+
ctx->parent.credtypes = GIT_CREDTYPE_USERPASS_PLAINTEXT;
|
212
|
+
ctx->parent.connection_affinity = 1;
|
213
|
+
ctx->parent.set_challenge = ntlm_set_challenge;
|
214
|
+
ctx->parent.next_token = ntlm_next_token;
|
215
|
+
ctx->parent.is_complete = ntlm_is_complete;
|
216
|
+
ctx->parent.free = ntlm_context_free;
|
217
|
+
|
218
|
+
*out = (git_http_auth_context *)ctx;
|
219
|
+
|
220
|
+
return 0;
|
221
|
+
}
|
222
|
+
|
223
|
+
#endif /* GIT_NTLM */
|
@@ -0,0 +1,35 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) the libgit2 contributors. All rights reserved.
|
3
|
+
*
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
+
*/
|
7
|
+
|
8
|
+
#ifndef INCLUDE_transports_auth_ntlm_h__
|
9
|
+
#define INCLUDE_transports_auth_ntlm_h__
|
10
|
+
|
11
|
+
#include "git2.h"
|
12
|
+
#include "auth.h"
|
13
|
+
|
14
|
+
#ifdef GIT_NTLM
|
15
|
+
|
16
|
+
#if defined(GIT_OPENSSL)
|
17
|
+
# define CRYPT_OPENSSL
|
18
|
+
#elif defined(GIT_MBEDTLS)
|
19
|
+
# define CRYPT_MBEDTLS
|
20
|
+
#elif defined(GIT_SECURE_TRANSPORT)
|
21
|
+
# define CRYPT_COMMONCRYPTO
|
22
|
+
#endif
|
23
|
+
|
24
|
+
extern int git_http_auth_ntlm(
|
25
|
+
git_http_auth_context **out,
|
26
|
+
const git_net_url *url);
|
27
|
+
|
28
|
+
#else
|
29
|
+
|
30
|
+
#define git_http_auth_ntlm git_http_auth_dummy
|
31
|
+
|
32
|
+
#endif /* GIT_NTLM */
|
33
|
+
|
34
|
+
#endif
|
35
|
+
|
@@ -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 "common.h"
|
9
9
|
|
10
|
-
#include "git2.h"
|
11
|
-
#include "
|
10
|
+
#include "git2/cred.h"
|
11
|
+
#include "git2/sys/cred.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_get_username(git_cred *cred)
|
31
31
|
{
|
32
32
|
switch (cred->credtype) {
|
33
33
|
case GIT_CREDTYPE_USERNAME:
|
@@ -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_cb prompt_callback,
|
268
268
|
void *payload)
|
269
269
|
{
|
270
270
|
git_cred_ssh_interactive *c;
|
@@ -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_cb sign_callback,
|
316
316
|
void *payload)
|
317
317
|
{
|
318
318
|
git_cred_ssh_custom *c;
|
@@ -192,8 +192,9 @@ static int _git_uploadpack_ls(
|
|
192
192
|
const char *url,
|
193
193
|
git_smart_subtransport_stream **stream)
|
194
194
|
{
|
195
|
-
|
195
|
+
git_net_url urldata = GIT_NET_URL_INIT;
|
196
196
|
const char *stream_url = url;
|
197
|
+
const char *host, *port;
|
197
198
|
git_proto_stream *s;
|
198
199
|
int error;
|
199
200
|
|
@@ -202,17 +203,15 @@ static int _git_uploadpack_ls(
|
|
202
203
|
if (!git__prefixcmp(url, prefix_git))
|
203
204
|
stream_url += strlen(prefix_git);
|
204
205
|
|
205
|
-
if ((error =
|
206
|
+
if ((error = git_net_url_parse(&urldata, url)) < 0)
|
206
207
|
return error;
|
207
208
|
|
208
|
-
|
209
|
+
host = urldata.host;
|
210
|
+
port = urldata.port ? urldata.port : GIT_DEFAULT_PORT;
|
209
211
|
|
210
|
-
|
211
|
-
git__free(port);
|
212
|
-
git__free(path);
|
213
|
-
git__free(user);
|
214
|
-
git__free(pass);
|
212
|
+
error = git_proto_stream_alloc(t, stream_url, cmd_uploadpack, host, port, stream);
|
215
213
|
|
214
|
+
git_net_url_dispose(&urldata);
|
216
215
|
|
217
216
|
if (error < 0) {
|
218
217
|
git_proto_stream_free(*stream);
|
@@ -251,7 +250,7 @@ static int _git_receivepack_ls(
|
|
251
250
|
const char *url,
|
252
251
|
git_smart_subtransport_stream **stream)
|
253
252
|
{
|
254
|
-
|
253
|
+
git_net_url urldata = GIT_NET_URL_INIT;
|
255
254
|
const char *stream_url = url;
|
256
255
|
git_proto_stream *s;
|
257
256
|
int error;
|
@@ -260,16 +259,12 @@ static int _git_receivepack_ls(
|
|
260
259
|
if (!git__prefixcmp(url, prefix_git))
|
261
260
|
stream_url += strlen(prefix_git);
|
262
261
|
|
263
|
-
if ((error =
|
262
|
+
if ((error = git_net_url_parse(&urldata, url)) < 0)
|
264
263
|
return error;
|
265
264
|
|
266
|
-
error = git_proto_stream_alloc(t, stream_url, cmd_receivepack, host, port, stream);
|
265
|
+
error = git_proto_stream_alloc(t, stream_url, cmd_receivepack, urldata.host, urldata.port, stream);
|
267
266
|
|
268
|
-
|
269
|
-
git__free(port);
|
270
|
-
git__free(path);
|
271
|
-
git__free(user);
|
272
|
-
git__free(pass);
|
267
|
+
git_net_url_dispose(&urldata);
|
273
268
|
|
274
269
|
if (error < 0) {
|
275
270
|
git_proto_stream_free(*stream);
|
@@ -12,18 +12,22 @@
|
|
12
12
|
#include "git2.h"
|
13
13
|
#include "http_parser.h"
|
14
14
|
#include "buffer.h"
|
15
|
+
#include "net.h"
|
15
16
|
#include "netops.h"
|
16
17
|
#include "global.h"
|
17
18
|
#include "remote.h"
|
19
|
+
#include "git2/sys/cred.h"
|
18
20
|
#include "smart.h"
|
19
21
|
#include "auth.h"
|
20
22
|
#include "http.h"
|
21
23
|
#include "auth_negotiate.h"
|
24
|
+
#include "auth_ntlm.h"
|
22
25
|
#include "streams/tls.h"
|
23
26
|
#include "streams/socket.h"
|
24
27
|
|
25
28
|
git_http_auth_scheme auth_schemes[] = {
|
26
29
|
{ GIT_AUTHTYPE_NEGOTIATE, "Negotiate", GIT_CREDTYPE_DEFAULT, git_http_auth_negotiate },
|
30
|
+
{ GIT_AUTHTYPE_NTLM, "NTLM", GIT_CREDTYPE_USERPASS_PLAINTEXT, git_http_auth_ntlm },
|
27
31
|
{ GIT_AUTHTYPE_BASIC, "Basic", GIT_CREDTYPE_USERPASS_PLAINTEXT, git_http_auth_basic },
|
28
32
|
};
|
29
33
|
|
@@ -71,14 +75,18 @@ typedef struct {
|
|
71
75
|
} http_stream;
|
72
76
|
|
73
77
|
typedef struct {
|
74
|
-
|
78
|
+
git_net_url url;
|
75
79
|
git_stream *stream;
|
76
80
|
|
81
|
+
git_http_authtype_t authtypes;
|
82
|
+
git_credtype_t credtypes;
|
83
|
+
|
77
84
|
git_cred *cred;
|
78
|
-
|
85
|
+
unsigned url_cred_presented : 1,
|
86
|
+
authenticated : 1;
|
79
87
|
|
80
88
|
git_vector auth_challenges;
|
81
|
-
|
89
|
+
git_http_auth_context *auth_context;
|
82
90
|
} http_server;
|
83
91
|
|
84
92
|
typedef struct {
|
@@ -106,8 +114,10 @@ typedef struct {
|
|
106
114
|
enum last_cb last_cb;
|
107
115
|
int parse_error;
|
108
116
|
int error;
|
117
|
+
unsigned request_count;
|
109
118
|
unsigned parse_finished : 1,
|
110
|
-
|
119
|
+
keepalive : 1,
|
120
|
+
replay_count : 4;
|
111
121
|
} http_subtransport;
|
112
122
|
|
113
123
|
typedef struct {
|
@@ -120,66 +130,29 @@ typedef struct {
|
|
120
130
|
size_t *bytes_read;
|
121
131
|
} parser_context;
|
122
132
|
|
123
|
-
static
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
return !!(scheme->credtypes & credtype);
|
128
|
-
}
|
129
|
-
|
130
|
-
static bool challenge_match(git_http_auth_scheme *scheme, void *data)
|
131
|
-
{
|
132
|
-
const char *scheme_name = scheme->name;
|
133
|
-
const char *challenge = (const char *)data;
|
134
|
-
size_t scheme_len;
|
135
|
-
|
136
|
-
scheme_len = strlen(scheme_name);
|
137
|
-
return (strncasecmp(challenge, scheme_name, scheme_len) == 0 &&
|
138
|
-
(challenge[scheme_len] == '\0' || challenge[scheme_len] == ' '));
|
139
|
-
}
|
140
|
-
|
141
|
-
static int auth_context_match(
|
142
|
-
git_http_auth_context **out,
|
143
|
-
http_server *server,
|
144
|
-
bool (*scheme_match)(git_http_auth_scheme *scheme, void *data),
|
145
|
-
void *data)
|
133
|
+
static git_http_auth_scheme *scheme_for_challenge(
|
134
|
+
const char *challenge,
|
135
|
+
git_cred *cred)
|
146
136
|
{
|
147
137
|
git_http_auth_scheme *scheme = NULL;
|
148
|
-
git_http_auth_context *context = NULL, *c;
|
149
138
|
size_t i;
|
150
139
|
|
151
|
-
*out = NULL;
|
152
|
-
|
153
140
|
for (i = 0; i < ARRAY_SIZE(auth_schemes); i++) {
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
}
|
158
|
-
}
|
141
|
+
const char *scheme_name = auth_schemes[i].name;
|
142
|
+
const git_credtype_t scheme_types = auth_schemes[i].credtypes;
|
143
|
+
size_t scheme_len;
|
159
144
|
|
160
|
-
|
161
|
-
return 0;
|
145
|
+
scheme_len = strlen(scheme_name);
|
162
146
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
147
|
+
if ((!cred || (cred->credtype & scheme_types)) &&
|
148
|
+
strncasecmp(challenge, scheme_name, scheme_len) == 0 &&
|
149
|
+
(challenge[scheme_len] == '\0' || challenge[scheme_len] == ' ')) {
|
150
|
+
scheme = &auth_schemes[i];
|
167
151
|
break;
|
168
152
|
}
|
169
153
|
}
|
170
154
|
|
171
|
-
|
172
|
-
if (scheme->init_context(&context, &server->url) < 0)
|
173
|
-
return -1;
|
174
|
-
else if (!context)
|
175
|
-
return 0;
|
176
|
-
else if (git_vector_insert(&server->auth_contexts, context) < 0)
|
177
|
-
return -1;
|
178
|
-
}
|
179
|
-
|
180
|
-
*out = context;
|
181
|
-
|
182
|
-
return 0;
|
155
|
+
return scheme;
|
183
156
|
}
|
184
157
|
|
185
158
|
static int apply_credentials(
|
@@ -187,31 +160,20 @@ static int apply_credentials(
|
|
187
160
|
http_server *server,
|
188
161
|
const char *header_name)
|
189
162
|
{
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
/* Apply the credentials given to us in the URL */
|
194
|
-
if (!cred && server->url.user && server->url.pass) {
|
195
|
-
if (!server->url_cred &&
|
196
|
-
git_cred_userpass_plaintext_new(&server->url_cred,
|
197
|
-
server->url.user, server->url.pass) < 0)
|
198
|
-
return -1;
|
199
|
-
|
200
|
-
cred = server->url_cred;
|
201
|
-
}
|
163
|
+
git_buf token = GIT_BUF_INIT;
|
164
|
+
int error = 0;
|
202
165
|
|
203
|
-
if (!
|
204
|
-
|
166
|
+
if (!server->auth_context)
|
167
|
+
goto done;
|
205
168
|
|
206
|
-
|
207
|
-
|
208
|
-
credtype_match, &cred->credtype) < 0)
|
209
|
-
return -1;
|
169
|
+
if ((error = server->auth_context->next_token(&token, server->auth_context, server->cred)) < 0)
|
170
|
+
goto done;
|
210
171
|
|
211
|
-
|
212
|
-
return 0;
|
172
|
+
error = git_buf_printf(buf, "%s: %s\r\n", header_name, token.ptr);
|
213
173
|
|
214
|
-
|
174
|
+
done:
|
175
|
+
git_buf_dispose(&token);
|
176
|
+
return error;
|
215
177
|
}
|
216
178
|
|
217
179
|
static int gen_request(
|
@@ -226,7 +188,7 @@ static int gen_request(
|
|
226
188
|
if (t->proxy_opts.type == GIT_PROXY_SPECIFIED)
|
227
189
|
git_buf_printf(buf, "%s %s://%s:%s%s%s HTTP/1.1\r\n",
|
228
190
|
s->verb,
|
229
|
-
t->server.url.
|
191
|
+
t->server.url.scheme,
|
230
192
|
t->server.url.host,
|
231
193
|
t->server.url.port,
|
232
194
|
path, s->service_url);
|
@@ -238,9 +200,10 @@ static int gen_request(
|
|
238
200
|
git_http__user_agent(buf);
|
239
201
|
git_buf_puts(buf, "\r\n");
|
240
202
|
git_buf_printf(buf, "Host: %s", t->server.url.host);
|
241
|
-
|
203
|
+
|
204
|
+
if (!git_net_url_is_default_port(&t->server.url))
|
242
205
|
git_buf_printf(buf, ":%s", t->server.url.port);
|
243
|
-
|
206
|
+
|
244
207
|
git_buf_puts(buf, "\r\n");
|
245
208
|
|
246
209
|
if (s->chunked || content_length > 0) {
|
@@ -275,29 +238,86 @@ static int gen_request(
|
|
275
238
|
return 0;
|
276
239
|
}
|
277
240
|
|
278
|
-
static int
|
279
|
-
http_server *server,
|
280
|
-
int *allowed_types)
|
241
|
+
static int set_authentication_challenge(http_server *server)
|
281
242
|
{
|
282
|
-
|
243
|
+
const char *challenge;
|
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)
|
259
|
+
{
|
260
|
+
git_http_auth_scheme *scheme;
|
283
261
|
char *challenge;
|
284
262
|
size_t i;
|
285
263
|
|
286
264
|
git_vector_foreach(&server->auth_challenges, i, challenge) {
|
287
|
-
if (
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
265
|
+
if ((scheme = scheme_for_challenge(challenge, NULL)) != NULL) {
|
266
|
+
server->authtypes |= scheme->type;
|
267
|
+
server->credtypes |= scheme->credtypes;
|
268
|
+
}
|
269
|
+
}
|
292
270
|
|
293
|
-
|
294
|
-
|
295
|
-
|
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;
|
296
290
|
|
297
|
-
|
291
|
+
if (server->auth_context->free)
|
292
|
+
server->auth_context->free(server->auth_context);
|
293
|
+
|
294
|
+
server->auth_context = NULL;
|
295
|
+
}
|
296
|
+
|
297
|
+
static int parse_authenticate_response(http_server *server)
|
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);
|
307
|
+
|
308
|
+
server->authenticated = 0;
|
298
309
|
}
|
299
310
|
|
300
|
-
|
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);
|
301
321
|
}
|
302
322
|
|
303
323
|
static int on_header_ready(http_subtransport *t)
|
@@ -396,55 +416,148 @@ GIT_INLINE(void) free_cred(git_cred **cred)
|
|
396
416
|
}
|
397
417
|
}
|
398
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
|
+
|
399
468
|
static int on_auth_required(
|
400
|
-
git_cred **creds,
|
401
469
|
http_parser *parser,
|
470
|
+
http_server *server,
|
402
471
|
const char *url,
|
403
472
|
const char *type,
|
404
473
|
git_cred_acquire_cb callback,
|
405
|
-
void *callback_payload
|
406
|
-
const char *username,
|
407
|
-
int allowed_types)
|
474
|
+
void *callback_payload)
|
408
475
|
{
|
409
476
|
parser_context *ctx = (parser_context *) parser->data;
|
410
477
|
http_subtransport *t = ctx->t;
|
411
|
-
int
|
478
|
+
int error = 1;
|
412
479
|
|
413
|
-
if (
|
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) {
|
414
500
|
git_error_set(GIT_ERROR_NET, "%s requested authentication but did not negotiate mechanisms", type);
|
415
501
|
t->parse_error = PARSE_ERROR_GENERIC;
|
416
502
|
return t->parse_error;
|
417
503
|
}
|
418
504
|
|
419
|
-
|
420
|
-
|
421
|
-
ret = callback(creds, url, username, allowed_types, callback_payload);
|
505
|
+
free_auth_context(server);
|
506
|
+
free_cred(&server->cred);
|
422
507
|
|
423
|
-
|
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) {
|
424
514
|
/* treat GIT_PASSTHROUGH as if callback isn't set */
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
return t->parse_error;
|
429
|
-
} else {
|
430
|
-
assert(*creds);
|
431
|
-
|
432
|
-
if (!((*creds)->credtype & allowed_types)) {
|
433
|
-
git_error_set(GIT_ERROR_NET, "%s credential provider returned an invalid cred type", type);
|
434
|
-
t->parse_error = PARSE_ERROR_GENERIC;
|
435
|
-
return t->parse_error;
|
436
|
-
}
|
515
|
+
error = 1;
|
516
|
+
}
|
517
|
+
}
|
437
518
|
|
438
|
-
|
439
|
-
|
440
|
-
|
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;
|
441
525
|
}
|
442
526
|
}
|
443
527
|
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
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;
|
448
561
|
}
|
449
562
|
|
450
563
|
static int on_headers_complete(http_parser *parser)
|
@@ -453,50 +566,35 @@ static int on_headers_complete(http_parser *parser)
|
|
453
566
|
http_subtransport *t = ctx->t;
|
454
567
|
http_stream *s = ctx->s;
|
455
568
|
git_buf buf = GIT_BUF_INIT;
|
456
|
-
int proxy_auth_types = 0, server_auth_types = 0;
|
457
|
-
|
458
|
-
/* Enforce a reasonable cap on the number of replays */
|
459
|
-
if (t->replay_count++ >= GIT_HTTP_REPLAY_MAX) {
|
460
|
-
git_error_set(GIT_ERROR_NET, "too many redirects or authentication replays");
|
461
|
-
return t->parse_error = PARSE_ERROR_GENERIC;
|
462
|
-
}
|
463
569
|
|
464
570
|
/* Both parse_header_name and parse_header_value are populated
|
465
571
|
* and ready for consumption. */
|
466
|
-
if (
|
467
|
-
if (on_header_ready(t) < 0)
|
468
|
-
return t->parse_error = PARSE_ERROR_GENERIC;
|
469
|
-
|
470
|
-
/*
|
471
|
-
* Capture authentication headers for the proxy or final endpoint,
|
472
|
-
* these may be 407/401 (authentication is not complete) or a 200
|
473
|
-
* (informing us that auth has completed).
|
474
|
-
*/
|
475
|
-
if (parse_authenticate_response(&t->proxy, &proxy_auth_types) < 0 ||
|
476
|
-
parse_authenticate_response(&t->server, &server_auth_types) < 0)
|
572
|
+
if (t->last_cb == VALUE && on_header_ready(t) < 0)
|
477
573
|
return t->parse_error = PARSE_ERROR_GENERIC;
|
478
574
|
|
479
575
|
/* Check for a proxy authentication failure. */
|
480
576
|
if (parser->status_code == 407 && get_verb == s->verb)
|
481
|
-
return on_auth_required(
|
577
|
+
return on_auth_required(
|
482
578
|
parser,
|
579
|
+
&t->proxy,
|
483
580
|
t->proxy_opts.url,
|
484
581
|
SERVER_TYPE_PROXY,
|
485
582
|
t->proxy_opts.credentials,
|
486
|
-
t->proxy_opts.payload
|
487
|
-
|
488
|
-
|
583
|
+
t->proxy_opts.payload);
|
584
|
+
else
|
585
|
+
on_auth_success(&t->proxy);
|
489
586
|
|
490
587
|
/* Check for an authentication failure. */
|
491
588
|
if (parser->status_code == 401 && get_verb == s->verb)
|
492
|
-
return on_auth_required(
|
589
|
+
return on_auth_required(
|
493
590
|
parser,
|
591
|
+
&t->server,
|
494
592
|
t->owner->url,
|
495
593
|
SERVER_TYPE_REMOTE,
|
496
594
|
t->owner->cred_acquire_cb,
|
497
|
-
t->owner->cred_acquire_payload
|
498
|
-
|
499
|
-
|
595
|
+
t->owner->cred_acquire_payload);
|
596
|
+
else
|
597
|
+
on_auth_success(&t->server);
|
500
598
|
|
501
599
|
/* Check for a redirect.
|
502
600
|
* Right now we only permit a redirect to the same hostname. */
|
@@ -507,7 +605,7 @@ static int on_headers_complete(http_parser *parser)
|
|
507
605
|
parser->status_code == 308) &&
|
508
606
|
t->location) {
|
509
607
|
|
510
|
-
if (
|
608
|
+
if (gitno_connection_data_handle_redirect(&t->server.url, t->location, s->service_url) < 0)
|
511
609
|
return t->parse_error = PARSE_ERROR_GENERIC;
|
512
610
|
|
513
611
|
/* Set the redirect URL on the stream. This is a transfer of
|
@@ -569,6 +667,7 @@ static int on_message_complete(http_parser *parser)
|
|
569
667
|
http_subtransport *t = ctx->t;
|
570
668
|
|
571
669
|
t->parse_finished = 1;
|
670
|
+
t->keepalive = http_should_keep_alive(parser);
|
572
671
|
|
573
672
|
return 0;
|
574
673
|
}
|
@@ -578,13 +677,6 @@ static int on_body_fill_buffer(http_parser *parser, const char *str, size_t len)
|
|
578
677
|
parser_context *ctx = (parser_context *) parser->data;
|
579
678
|
http_subtransport *t = ctx->t;
|
580
679
|
|
581
|
-
/* If our goal is to replay the request (either an auth failure or
|
582
|
-
* a redirect) then don't bother buffering since we're ignoring the
|
583
|
-
* content anyway.
|
584
|
-
*/
|
585
|
-
if (t->parse_error == PARSE_ERROR_REPLAY)
|
586
|
-
return 0;
|
587
|
-
|
588
680
|
/* If there's no buffer set, we're explicitly ignoring the body. */
|
589
681
|
if (ctx->buffer) {
|
590
682
|
if (ctx->buf_size < len) {
|
@@ -613,6 +705,7 @@ static void clear_parser_state(http_subtransport *t)
|
|
613
705
|
t->last_cb = NONE;
|
614
706
|
t->parse_error = 0;
|
615
707
|
t->parse_finished = 0;
|
708
|
+
t->keepalive = 0;
|
616
709
|
|
617
710
|
git_buf_dispose(&t->parse_header_name);
|
618
711
|
git_buf_init(&t->parse_header_name, 0);
|
@@ -673,10 +766,10 @@ static int load_proxy_config(http_subtransport *t)
|
|
673
766
|
git__free(t->proxy_url);
|
674
767
|
t->proxy_url = NULL;
|
675
768
|
|
676
|
-
|
769
|
+
git_proxy_options_init(&t->proxy_opts, GIT_PROXY_OPTIONS_VERSION);
|
677
770
|
|
678
771
|
if ((error = git_remote__get_http_proxy(t->owner->owner,
|
679
|
-
|
772
|
+
!strcmp(t->server.url.scheme, "https"), &t->proxy_url)) < 0)
|
680
773
|
return error;
|
681
774
|
|
682
775
|
if (!t->proxy_url)
|
@@ -698,20 +791,14 @@ static int load_proxy_config(http_subtransport *t)
|
|
698
791
|
return -1;
|
699
792
|
}
|
700
793
|
|
701
|
-
|
702
|
-
return error;
|
794
|
+
git_net_url_dispose(&t->proxy.url);
|
703
795
|
|
704
|
-
|
705
|
-
git_error_set(GIT_ERROR_NET, "SSL connections to proxy are not supported");
|
706
|
-
return -1;
|
707
|
-
}
|
708
|
-
|
709
|
-
return error;
|
796
|
+
return git_net_url_parse(&t->proxy.url, t->proxy_opts.url);
|
710
797
|
}
|
711
798
|
|
712
799
|
static int check_certificate(
|
713
800
|
git_stream *stream,
|
714
|
-
|
801
|
+
git_net_url *url,
|
715
802
|
int is_valid,
|
716
803
|
git_transport_certificate_check_cb cert_cb,
|
717
804
|
void *cert_cb_payload)
|
@@ -740,7 +827,7 @@ static int check_certificate(
|
|
740
827
|
|
741
828
|
static int stream_connect(
|
742
829
|
git_stream *stream,
|
743
|
-
|
830
|
+
git_net_url *url,
|
744
831
|
git_transport_certificate_check_cb cert_cb,
|
745
832
|
void *cb_payload)
|
746
833
|
{
|
@@ -782,18 +869,10 @@ static int proxy_headers_complete(http_parser *parser)
|
|
782
869
|
{
|
783
870
|
parser_context *ctx = (parser_context *) parser->data;
|
784
871
|
http_subtransport *t = ctx->t;
|
785
|
-
int proxy_auth_types = 0;
|
786
|
-
|
787
|
-
/* Enforce a reasonable cap on the number of replays */
|
788
|
-
if (t->replay_count++ >= GIT_HTTP_REPLAY_MAX) {
|
789
|
-
git_error_set(GIT_ERROR_NET, "too many redirects or authentication replays");
|
790
|
-
return t->parse_error = PARSE_ERROR_GENERIC;
|
791
|
-
}
|
792
872
|
|
793
873
|
/* Both parse_header_name and parse_header_value are populated
|
794
874
|
* and ready for consumption. */
|
795
|
-
if (
|
796
|
-
if (on_header_ready(t) < 0)
|
875
|
+
if (t->last_cb == VALUE && on_header_ready(t) < 0)
|
797
876
|
return t->parse_error = PARSE_ERROR_GENERIC;
|
798
877
|
|
799
878
|
/*
|
@@ -801,19 +880,32 @@ static int proxy_headers_complete(http_parser *parser)
|
|
801
880
|
* these may be 407/401 (authentication is not complete) or a 200
|
802
881
|
* (informing us that auth has completed).
|
803
882
|
*/
|
804
|
-
if (parse_authenticate_response(&t->proxy
|
883
|
+
if (parse_authenticate_response(&t->proxy) < 0)
|
805
884
|
return t->parse_error = PARSE_ERROR_GENERIC;
|
806
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
|
+
|
807
900
|
/* Check for a proxy authentication failure. */
|
808
901
|
if (parser->status_code == 407)
|
809
|
-
return on_auth_required(
|
902
|
+
return on_auth_required(
|
810
903
|
parser,
|
904
|
+
&t->proxy,
|
811
905
|
t->proxy_opts.url,
|
812
906
|
SERVER_TYPE_PROXY,
|
813
907
|
t->proxy_opts.credentials,
|
814
|
-
t->proxy_opts.payload
|
815
|
-
t->proxy.url.user,
|
816
|
-
proxy_auth_types);
|
908
|
+
t->proxy_opts.payload);
|
817
909
|
|
818
910
|
if (parser->status_code != 200) {
|
819
911
|
git_error_set(GIT_ERROR_NET, "unexpected status code from proxy: %d",
|
@@ -834,6 +926,7 @@ static int proxy_connect(
|
|
834
926
|
static http_parser_settings proxy_parser_settings = {0};
|
835
927
|
size_t bytes_read = 0, bytes_parsed;
|
836
928
|
parser_context ctx;
|
929
|
+
bool auth_replay;
|
837
930
|
int error;
|
838
931
|
|
839
932
|
/* Use the parser settings only to parser headers. */
|
@@ -845,6 +938,8 @@ static int proxy_connect(
|
|
845
938
|
replay:
|
846
939
|
clear_parser_state(t);
|
847
940
|
|
941
|
+
auth_replay = false;
|
942
|
+
|
848
943
|
gitno_buffer_setup_fromstream(proxy_stream,
|
849
944
|
&t->parse_buffer,
|
850
945
|
t->parse_buffer_data,
|
@@ -862,8 +957,17 @@ replay:
|
|
862
957
|
while (!bytes_read && !t->parse_finished) {
|
863
958
|
t->parse_buffer.offset = 0;
|
864
959
|
|
865
|
-
if ((error = gitno_recv(&t->parse_buffer)) < 0)
|
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;
|
866
969
|
goto done;
|
970
|
+
}
|
867
971
|
|
868
972
|
/*
|
869
973
|
* This call to http_parser_execute will invoke the on_*
|
@@ -892,10 +996,9 @@ replay:
|
|
892
996
|
}
|
893
997
|
|
894
998
|
/* Replay the request with authentication headers. */
|
895
|
-
if (PARSE_ERROR_REPLAY == t->parse_error)
|
896
|
-
|
897
|
-
|
898
|
-
if (t->parse_error < 0) {
|
999
|
+
if (PARSE_ERROR_REPLAY == t->parse_error) {
|
1000
|
+
auth_replay = true;
|
1001
|
+
} else if (t->parse_error < 0) {
|
899
1002
|
error = t->parse_error == PARSE_ERROR_EXT ? PARSE_ERROR_EXT : -1;
|
900
1003
|
goto done;
|
901
1004
|
}
|
@@ -909,6 +1012,15 @@ replay:
|
|
909
1012
|
}
|
910
1013
|
}
|
911
1014
|
|
1015
|
+
t->request_count++;
|
1016
|
+
|
1017
|
+
if (auth_replay) {
|
1018
|
+
if (t->keepalive && t->parse_finished)
|
1019
|
+
goto replay;
|
1020
|
+
|
1021
|
+
return PARSE_ERROR_REPLAY;
|
1022
|
+
}
|
1023
|
+
|
912
1024
|
if ((error = git_tls_stream_wrap(out, proxy_stream, t->server.url.host)) == 0)
|
913
1025
|
error = stream_connect(*out, &t->server.url,
|
914
1026
|
t->owner->certificate_check_cb,
|
@@ -920,22 +1032,45 @@ replay:
|
|
920
1032
|
*/
|
921
1033
|
t->proxy_opts.type = GIT_PROXY_NONE;
|
922
1034
|
t->replay_count = 0;
|
1035
|
+
t->request_count = 0;
|
923
1036
|
|
924
1037
|
done:
|
925
1038
|
return error;
|
926
1039
|
}
|
927
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;
|
1061
|
+
}
|
1062
|
+
}
|
1063
|
+
|
928
1064
|
static int http_connect(http_subtransport *t)
|
929
1065
|
{
|
930
|
-
|
1066
|
+
git_net_url *url;
|
931
1067
|
git_stream *proxy_stream = NULL, *stream = NULL;
|
932
1068
|
git_transport_certificate_check_cb cert_cb;
|
933
1069
|
void *cb_payload;
|
934
1070
|
int error;
|
935
1071
|
|
936
|
-
|
937
|
-
|
938
|
-
t->parse_finished)
|
1072
|
+
auth_replay:
|
1073
|
+
if (t->connected && t->keepalive && t->parse_finished)
|
939
1074
|
return 0;
|
940
1075
|
|
941
1076
|
if ((error = load_proxy_config(t)) < 0)
|
@@ -953,7 +1088,12 @@ static int http_connect(http_subtransport *t)
|
|
953
1088
|
t->proxy.stream = NULL;
|
954
1089
|
}
|
955
1090
|
|
1091
|
+
reset_auth_connection(&t->server);
|
1092
|
+
reset_auth_connection(&t->proxy);
|
1093
|
+
|
956
1094
|
t->connected = 0;
|
1095
|
+
t->keepalive = 0;
|
1096
|
+
t->request_count = 0;
|
957
1097
|
|
958
1098
|
if (t->proxy_opts.type == GIT_PROXY_SPECIFIED) {
|
959
1099
|
url = &t->proxy.url;
|
@@ -965,7 +1105,7 @@ static int http_connect(http_subtransport *t)
|
|
965
1105
|
cb_payload = t->owner->message_cb_payload;
|
966
1106
|
}
|
967
1107
|
|
968
|
-
if (url->
|
1108
|
+
if (strcmp(url->scheme, "https") == 0)
|
969
1109
|
error = git_tls_stream_new(&stream, url->host, url->port);
|
970
1110
|
else
|
971
1111
|
error = git_socket_stream_new(&stream, url->host, url->port);
|
@@ -982,18 +1122,24 @@ static int http_connect(http_subtransport *t)
|
|
982
1122
|
* an HTTPS connection, then we need to build a CONNECT tunnel.
|
983
1123
|
*/
|
984
1124
|
if (t->proxy_opts.type == GIT_PROXY_SPECIFIED &&
|
985
|
-
|
1125
|
+
strcmp(t->server.url.scheme, "https") == 0) {
|
986
1126
|
proxy_stream = stream;
|
987
1127
|
stream = NULL;
|
988
1128
|
|
989
|
-
|
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) {
|
990
1136
|
goto on_error;
|
1137
|
+
}
|
991
1138
|
}
|
992
1139
|
|
993
1140
|
t->proxy.stream = proxy_stream;
|
994
1141
|
t->server.stream = stream;
|
995
1142
|
t->connected = 1;
|
996
|
-
t->replay_count = 0;
|
997
1143
|
return 0;
|
998
1144
|
|
999
1145
|
on_error:
|
@@ -1020,27 +1166,23 @@ static int http_stream_read(
|
|
1020
1166
|
http_subtransport *t = OWNING_SUBTRANSPORT(s);
|
1021
1167
|
parser_context ctx;
|
1022
1168
|
size_t bytes_parsed;
|
1169
|
+
git_buf request = GIT_BUF_INIT;
|
1170
|
+
bool auth_replay;
|
1171
|
+
int error = 0;
|
1023
1172
|
|
1024
1173
|
replay:
|
1025
1174
|
*bytes_read = 0;
|
1175
|
+
auth_replay = false;
|
1026
1176
|
|
1027
1177
|
assert(t->connected);
|
1028
1178
|
|
1029
1179
|
if (!s->sent_request) {
|
1030
|
-
|
1031
|
-
|
1180
|
+
git_buf_clear(&request);
|
1032
1181
|
clear_parser_state(t);
|
1033
1182
|
|
1034
|
-
if (gen_request(&request, s, 0) < 0
|
1035
|
-
|
1036
|
-
|
1037
|
-
if (git_stream__write_full(t->server.stream, request.ptr,
|
1038
|
-
request.size, 0) < 0) {
|
1039
|
-
git_buf_dispose(&request);
|
1040
|
-
return -1;
|
1041
|
-
}
|
1042
|
-
|
1043
|
-
git_buf_dispose(&request);
|
1183
|
+
if ((error = gen_request(&request, s, 0)) < 0 ||
|
1184
|
+
(error = git_stream__write_full(t->server.stream, request.ptr, request.size, 0)) < 0)
|
1185
|
+
goto done;
|
1044
1186
|
|
1045
1187
|
s->sent_request = 1;
|
1046
1188
|
}
|
@@ -1050,17 +1192,17 @@ replay:
|
|
1050
1192
|
assert(s->verb == post_verb);
|
1051
1193
|
|
1052
1194
|
/* Flush, if necessary */
|
1053
|
-
if (s->chunk_buffer_len > 0
|
1054
|
-
write_chunk(t->server.stream,
|
1055
|
-
|
1056
|
-
return -1;
|
1195
|
+
if (s->chunk_buffer_len > 0) {
|
1196
|
+
if ((error = write_chunk(t->server.stream, s->chunk_buffer, s->chunk_buffer_len)) < 0)
|
1197
|
+
goto done;
|
1057
1198
|
|
1058
|
-
|
1199
|
+
s->chunk_buffer_len = 0;
|
1200
|
+
}
|
1059
1201
|
|
1060
1202
|
/* Write the final chunk. */
|
1061
|
-
if (git_stream__write_full(t->server.stream,
|
1062
|
-
"0\r\n\r\n", 5, 0) < 0)
|
1063
|
-
|
1203
|
+
if ((error = git_stream__write_full(t->server.stream,
|
1204
|
+
"0\r\n\r\n", 5, 0)) < 0)
|
1205
|
+
goto done;
|
1064
1206
|
}
|
1065
1207
|
|
1066
1208
|
s->received_response = 1;
|
@@ -1068,7 +1210,6 @@ replay:
|
|
1068
1210
|
|
1069
1211
|
while (!*bytes_read && !t->parse_finished) {
|
1070
1212
|
size_t data_offset;
|
1071
|
-
int error;
|
1072
1213
|
|
1073
1214
|
/*
|
1074
1215
|
* Make the parse_buffer think it's as full of data as
|
@@ -1078,26 +1219,37 @@ replay:
|
|
1078
1219
|
* data_offset is the actual data offset from which we
|
1079
1220
|
* should tell the parser to start reading.
|
1080
1221
|
*/
|
1081
|
-
if (buf_size >= t->parse_buffer.len)
|
1222
|
+
if (buf_size >= t->parse_buffer.len)
|
1082
1223
|
t->parse_buffer.offset = 0;
|
1083
|
-
|
1224
|
+
else
|
1084
1225
|
t->parse_buffer.offset = t->parse_buffer.len - buf_size;
|
1085
|
-
}
|
1086
1226
|
|
1087
1227
|
data_offset = t->parse_buffer.offset;
|
1088
1228
|
|
1089
|
-
if (gitno_recv(&t->parse_buffer) < 0)
|
1090
|
-
|
1229
|
+
if ((error = gitno_recv(&t->parse_buffer)) < 0) {
|
1230
|
+
goto done;
|
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
|
+
}
|
1091
1240
|
|
1092
|
-
/*
|
1093
|
-
*
|
1094
|
-
*
|
1095
|
-
* into the target buffer.
|
1096
|
-
*
|
1241
|
+
/*
|
1242
|
+
* This call to http_parser_execute will result in invocations
|
1243
|
+
* of the on_* family of callbacks, including on_body_fill_buffer
|
1244
|
+
* which will write into the target buffer. Set up the buffer
|
1245
|
+
* for it to write into _unless_ we got an auth failure; in
|
1246
|
+
* that case we only care about the headers and don't need to
|
1247
|
+
* bother copying the body.
|
1248
|
+
*/
|
1097
1249
|
ctx.t = t;
|
1098
1250
|
ctx.s = s;
|
1099
|
-
ctx.buffer = buffer;
|
1100
|
-
ctx.buf_size = buf_size;
|
1251
|
+
ctx.buffer = auth_replay ? NULL : buffer;
|
1252
|
+
ctx.buf_size = auth_replay ? 0 : buf_size;
|
1101
1253
|
ctx.bytes_read = bytes_read;
|
1102
1254
|
|
1103
1255
|
/* Set the context, call the parser, then unset the context. */
|
@@ -1110,33 +1262,40 @@ replay:
|
|
1110
1262
|
|
1111
1263
|
t->parser.data = NULL;
|
1112
1264
|
|
1113
|
-
/*
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
goto
|
1122
|
-
}
|
1123
|
-
|
1124
|
-
if (t->parse_error == PARSE_ERROR_EXT) {
|
1125
|
-
return t->error;
|
1265
|
+
/* On a 401, read the rest of the response then retry. */
|
1266
|
+
if (t->parse_error == PARSE_ERROR_REPLAY) {
|
1267
|
+
auth_replay = true;
|
1268
|
+
} else if (t->parse_error == PARSE_ERROR_EXT) {
|
1269
|
+
error = t->error;
|
1270
|
+
goto done;
|
1271
|
+
} else if (t->parse_error < 0) {
|
1272
|
+
error = -1;
|
1273
|
+
goto done;
|
1126
1274
|
}
|
1127
1275
|
|
1128
|
-
if (t->parse_error < 0)
|
1129
|
-
return -1;
|
1130
|
-
|
1131
1276
|
if (bytes_parsed != t->parse_buffer.offset - data_offset) {
|
1132
1277
|
git_error_set(GIT_ERROR_NET,
|
1133
1278
|
"HTTP parser error: %s",
|
1134
1279
|
http_errno_description((enum http_errno)t->parser.http_errno));
|
1135
|
-
|
1280
|
+
error = -1;
|
1281
|
+
goto done;
|
1136
1282
|
}
|
1137
1283
|
}
|
1138
1284
|
|
1139
|
-
|
1285
|
+
t->request_count++;
|
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;
|
1140
1299
|
}
|
1141
1300
|
|
1142
1301
|
static int http_stream_write_chunked(
|
@@ -1144,7 +1303,7 @@ static int http_stream_write_chunked(
|
|
1144
1303
|
const char *buffer,
|
1145
1304
|
size_t len)
|
1146
1305
|
{
|
1147
|
-
http_stream *s = (http_stream
|
1306
|
+
http_stream *s = GIT_CONTAINER_OF(stream, http_stream, parent);
|
1148
1307
|
http_subtransport *t = OWNING_SUBTRANSPORT(s);
|
1149
1308
|
|
1150
1309
|
assert(t->connected);
|
@@ -1187,8 +1346,10 @@ static int http_stream_write_chunked(
|
|
1187
1346
|
/* Append as much to the buffer as we can */
|
1188
1347
|
int count = min(CHUNK_SIZE - s->chunk_buffer_len, len);
|
1189
1348
|
|
1190
|
-
if (!s->chunk_buffer)
|
1349
|
+
if (!s->chunk_buffer) {
|
1191
1350
|
s->chunk_buffer = git__malloc(CHUNK_SIZE);
|
1351
|
+
GIT_ERROR_CHECK_ALLOC(s->chunk_buffer);
|
1352
|
+
}
|
1192
1353
|
|
1193
1354
|
memcpy(s->chunk_buffer + s->chunk_buffer_len, buffer, count);
|
1194
1355
|
s->chunk_buffer_len += count;
|
@@ -1218,7 +1379,7 @@ static int http_stream_write_single(
|
|
1218
1379
|
const char *buffer,
|
1219
1380
|
size_t len)
|
1220
1381
|
{
|
1221
|
-
http_stream *s = (http_stream
|
1382
|
+
http_stream *s = GIT_CONTAINER_OF(stream, http_stream, parent);
|
1222
1383
|
http_subtransport *t = OWNING_SUBTRANSPORT(s);
|
1223
1384
|
git_buf request = GIT_BUF_INIT;
|
1224
1385
|
|
@@ -1252,7 +1413,7 @@ on_error:
|
|
1252
1413
|
|
1253
1414
|
static void http_stream_free(git_smart_subtransport_stream *stream)
|
1254
1415
|
{
|
1255
|
-
http_stream *s = (http_stream
|
1416
|
+
http_stream *s = GIT_CONTAINER_OF(stream, http_stream, parent);
|
1256
1417
|
|
1257
1418
|
if (s->chunk_buffer)
|
1258
1419
|
git__free(s->chunk_buffer);
|
@@ -1365,7 +1526,7 @@ static int http_action(
|
|
1365
1526
|
const char *url,
|
1366
1527
|
git_smart_service_t action)
|
1367
1528
|
{
|
1368
|
-
http_subtransport *t = (http_subtransport
|
1529
|
+
http_subtransport *t = GIT_CONTAINER_OF(subtransport, http_subtransport, parent);
|
1369
1530
|
int ret;
|
1370
1531
|
|
1371
1532
|
assert(stream);
|
@@ -1378,7 +1539,7 @@ static int http_action(
|
|
1378
1539
|
* that would be insecure in plaintext (eg, HTTP Basic).
|
1379
1540
|
*/
|
1380
1541
|
if ((!t->server.url.host || !t->server.url.port || !t->server.url.path) &&
|
1381
|
-
(ret =
|
1542
|
+
(ret = git_net_url_parse(&t->server.url, url)) < 0)
|
1382
1543
|
return ret;
|
1383
1544
|
|
1384
1545
|
assert(t->server.url.host && t->server.url.port && t->server.url.path);
|
@@ -1404,22 +1565,9 @@ static int http_action(
|
|
1404
1565
|
return -1;
|
1405
1566
|
}
|
1406
1567
|
|
1407
|
-
static void free_auth_contexts(git_vector *contexts)
|
1408
|
-
{
|
1409
|
-
git_http_auth_context *context;
|
1410
|
-
size_t i;
|
1411
|
-
|
1412
|
-
git_vector_foreach(contexts, i, context) {
|
1413
|
-
if (context->free)
|
1414
|
-
context->free(context);
|
1415
|
-
}
|
1416
|
-
|
1417
|
-
git_vector_clear(contexts);
|
1418
|
-
}
|
1419
|
-
|
1420
1568
|
static int http_close(git_smart_subtransport *subtransport)
|
1421
1569
|
{
|
1422
|
-
http_subtransport *t = (http_subtransport
|
1570
|
+
http_subtransport *t = GIT_CONTAINER_OF(subtransport, http_subtransport, parent);
|
1423
1571
|
|
1424
1572
|
clear_parser_state(t);
|
1425
1573
|
|
@@ -1438,18 +1586,16 @@ static int http_close(git_smart_subtransport *subtransport)
|
|
1438
1586
|
}
|
1439
1587
|
|
1440
1588
|
free_cred(&t->server.cred);
|
1441
|
-
free_cred(&t->server.url_cred);
|
1442
1589
|
free_cred(&t->proxy.cred);
|
1443
|
-
free_cred(&t->proxy.url_cred);
|
1444
1590
|
|
1445
|
-
|
1446
|
-
|
1591
|
+
free_auth_context(&t->server);
|
1592
|
+
free_auth_context(&t->proxy);
|
1447
1593
|
|
1448
|
-
|
1449
|
-
|
1594
|
+
t->server.url_cred_presented = false;
|
1595
|
+
t->proxy.url_cred_presented = false;
|
1450
1596
|
|
1451
|
-
|
1452
|
-
|
1597
|
+
git_net_url_dispose(&t->server.url);
|
1598
|
+
git_net_url_dispose(&t->proxy.url);
|
1453
1599
|
|
1454
1600
|
git__free(t->proxy_url);
|
1455
1601
|
t->proxy_url = NULL;
|
@@ -1459,12 +1605,9 @@ static int http_close(git_smart_subtransport *subtransport)
|
|
1459
1605
|
|
1460
1606
|
static void http_free(git_smart_subtransport *subtransport)
|
1461
1607
|
{
|
1462
|
-
http_subtransport *t = (http_subtransport
|
1608
|
+
http_subtransport *t = GIT_CONTAINER_OF(subtransport, http_subtransport, parent);
|
1463
1609
|
|
1464
1610
|
http_close(subtransport);
|
1465
|
-
|
1466
|
-
git_vector_free(&t->server.auth_contexts);
|
1467
|
-
git_vector_free(&t->proxy.auth_contexts);
|
1468
1611
|
git__free(t);
|
1469
1612
|
}
|
1470
1613
|
|