summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* http: introduce GIT_ERROR_HTTPethomson/gssapiEdward Thomson2020-01-243-56/+56
| | | | | Disambiguate between general network problems and HTTP problems in error codes.
* httpclient: use defines for status codesEdward Thomson2020-01-243-14/+25
|
* trace: compare against an int valueEdward Thomson2020-01-241-1/+1
| | | | | When tracing is disabled, don't let `git_trace__level` return a void, since that can't be compared against.
* http: send probe packetsEdward Thomson2020-01-242-2/+70
| | | | | | | | | | | | | | | | | | | | | | When we're authenticating with a connection-based authentication scheme (NTLM, Negotiate), we need to make sure that we're still connected between the initial GET where we did the authentication and the POST that we're about to send. Our keep-alive session may have not kept alive, but more likely, some servers do not authenticate the entire keep-alive connection and may have "forgotten" that we were authenticated, namely Apache and nginx. Send a "probe" packet, that is an HTTP POST request to the upload-pack or receive-pack endpoint, that consists of an empty git pkt ("0000"). If we're authenticated, we'll get a 200 back. If we're not, we'll get a 401 back, and then we'll resend that probe packet with the first step of our authentication (asking to start authentication with the given scheme). We expect _yet another_ 401 back, with the authentication challenge. Finally, we will send our authentication response with the actual POST data. This will allow us to authenticate without draining the POST data in the initial request that gets us a 401.
* http: use the new httpclientEdward Thomson2020-01-242-1374/+407
| | | | | Untangle the notion of the http transport from the actual http implementation. The http transport now uses the httpclient.
* httpclient: support expect/continueEdward Thomson2020-01-246-9/+61
| | | | | | | | | | | | | Allow users to opt-in to expect/continue handling when sending a POST and we're authenticated with a "connection-based" authentication mechanism like NTLM or Negotiate. If the response is a 100, return to the caller (to allow them to post their body). If the response is *not* a 100, buffer the response for the caller. HTTP expect/continue is generally safe, but some legacy servers have not implemented it correctly. Require it to be opt-in.
* httpclient: support CONNECT proxiesEdward Thomson2020-01-242-76/+251
| | | | | Fully support HTTP proxies, in particular CONNECT proxies, that allow us to speak TLS through a proxy.
* httpclient: handle chunked responsesEdward Thomson2020-01-242-7/+15
| | | | | Detect responses that are sent with Transfer-Encoding: chunked, and record that information so that we can consume the entire message body.
* httpclient: support authenticationEdward Thomson2020-01-242-8/+373
| | | | | | | | | | | | Store the last-seen credential challenges (eg, all the 'WWW-Authenticate' headers in a response message). Given some credentials, find the best (first) challenge whose mechanism supports these credentials. (eg, 'Basic' supports username/password credentials, 'Negotiate' supports default credentials). Set up an authentication context for this mechanism and these credentials. Continue exchanging challenge/responses until we're authenticated.
* net: free the url's query componentEdward Thomson2020-01-241-0/+1
|
* net: introduce path formatting functionEdward Thomson2020-01-242-0/+15
| | | | | Introduce a function to format the path and query string for a URL, suitable for creating an HTTP request.
* httpclient: consume final chunk messageEdward Thomson2020-01-241-111/+153
| | | | | | | | | | | | | | | When sending a new request, ensure that we got the entirety of the response body. Our caller may have decided that they were done reading. If we were not at the end of the message, this means that we need to tear down the connection and cannot do keep-alive. However, if the caller read all of the message, but we still have a final end-of-response chunk signifier (ie, "0\r\n\r\n") on the socket, then we should consider that the response was successfully copmleted. If we're asked to send a new request, try to read from the socket, just to clear out that end-of-chunk message, marking ourselves as disconnected on any errors.
* httpclient: add chunk support to POSTEdward Thomson2020-01-241-11/+44
| | | | Teach httpclient how to support chunking when POSTing request bodies.
* httpclient: introduce a simple http implementationEdward Thomson2020-01-242-0/+1045
| | | | | | | | | | | | | | Introduce a new http client implementation that can GET and POST to remote URLs. Consumers can use `git_http_client_init` to create a new client, `git_http_client_send_request` to send a request to the remote server and `git_http_client_read_response` to read the response. The http client implementation will perform the I/O with the remote server (http or https) but does not understand the git smart transfer protocol. This allows us to split the concerns of the http subtransport from the actual http implementation.
* net: introduce url formatting functionEdward Thomson2020-01-242-0/+36
|
* buf: add consume_bytesEdward Thomson2020-01-242-0/+6
| | | | | Allow users to consume a buffer by the number of bytes, not just to an ending pointer.
* net: introduce git_net_url_joinpathEdward Thomson2020-01-242-0/+76
| | | | | | Provide a mechanism to add a path and query string to an existing url so that we can easily append `/info/refs?...` type url segments to a url given to us by a user.
* net: refactor gitno redirect handlingEdward Thomson2020-01-246-122/+114
| | | | Move the redirect handling into `git_net_url` for consistency.
* net: add an isvalid functionEdward Thomson2020-01-242-4/+12
| | | | (Also, mark all the declarations as extern.)
* winhttp: refactor request sendingEdward Thomson2020-01-241-8/+8
| | | | | Clarify what it means to not send a length; this allows us to refactor requests further.
* smart protocol: correct case in error messagesEdward Thomson2020-01-241-4/+4
|
* gssapi: validate that we were requested NegotiateEdward Thomson2020-01-241-3/+5
|
* gssapi: dispose after completion for retryEdward Thomson2020-01-241-13/+19
| | | | | | Disposal pattern; dispose on completion, allowing us to retry authentication, which may happen on web servers that close connection-based authenticated sessions (NTLM/SPNEGO) unexpectedly.
* gssapi: delete half-built security context so auth can continueJonathan Turcotte2020-01-241-3/+3
|
* gssapi: correct incorrect case in error messageEdward Thomson2020-01-241-1/+1
|
* gssapi: protect GSS_ERROR macroEdward Thomson2020-01-241-4/+7
| | | | | | | | | | | The GSS_ERROR(x) macro may expand to `(x & value)` on some implementations, instead of `((x) & value)`. This is the case on macOS, which means that if we attempt to wrap an expression in that macro, like `a = b`, then that would expand to `(a = b & value)`. Since `&` has a higher precedence, this is not at all what we want, and will set our result code to an incorrect value. Evaluate the expression then test it with `GSS_ERROR` independently to avoid this.
* gssapi: protect against empty messagesEdward Thomson2020-01-241-0/+6
|
* auth: update enum type name for consistencyethomson/typetEdward Thomson2020-01-185-13/+13
| | | | | libgit2 does not use `type_t` suffixes as it's redundant; thus, rename `git_http_authtype_t` to `git_http_auth_t` for consistency.
* iterator: update enum type name for consistencyEdward Thomson2020-01-189-50/+50
| | | | | libgit2 does not use `type_t` suffixes as it's redundant; thus, rename `git_iterator_type_t` to `git_iterator_t` for consistency.
* rebase: update enum type name for consistencyEdward Thomson2020-01-181-21/+21
| | | | | libgit2 does not use `type_t` suffixes as it's redundant; thus, rename `git_rebase_type_t` to `git_rebase_t` for consistency.
* merge: update enum type name for consistencyEdward Thomson2020-01-181-2/+2
| | | | | libgit2 does not use `type_t` suffixes as it's redundant; thus, rename `git_merge_diff_type_t` to `git_merge_diff_t` for consistency.
* Merge pull request #5358 from lrm29/git_merge_driver_source_repo_non_constPatrick Steinhardt2020-01-171-1/+1
|\ | | | | merge: Return non-const git_repository from accessor method
| * merge: Return non-const git_repository from git_merge_driver_source_repo ↵Laurence McGlashan2020-01-151-1/+1
| | | | | | | | accessor.
* | Merge pull request #5361 from csware/no-return-freed_objectPatrick Steinhardt2020-01-171-2/+1
|\ \ | | | | | | Do not return free'd git_repository object on error
| * | Do not return free'd git_repository object on errorSven Strickroth2020-01-161-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | Regression introduced in commit dde6d9c706bf1ecab545da55ab874a016587af1f. This issue causes lots of crashes in TortoiseGit. Signed-off-by: Sven Strickroth <email@cs-ware.de>
* | | Merge pull request #5360 from josharian/fix-5357Patrick Steinhardt2020-01-171-0/+5
|\ \ \ | | | | | | | | refs: refuse to delete HEAD
| * | | refs: refuse to delete HEADJosh Bleecher Snyder2020-01-151-0/+5
| |/ / | | | | | | | | | | | | | | | | | | This requires adding a new symbolic ref to the testrepo fixture. Some of the existing tests attempt to delete HEAD, expecting a different failure. Introduce and use a non-HEAD symbolic ref instead. Adjust a few other tests as needed. Fixes #5357
* | | Merge pull request #5351 from pks-t/pks/index-map-macrosEdward Thomson2020-01-161-60/+48
|\ \ \ | |/ / |/| | index: replace map macros with inline functions
| * | index: fix resizing index map twice on case-insensitive systemsPatrick Steinhardt2020-01-141-17/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Depending on whether the index map is case-sensitive or insensitive, we need to call either `git_idxmap_icase_resize` or `git_idxmap_resize`. There are multiple locations where we thus use the following pattern: if (index->ignore_case && git_idxmap_icase_resize(map, length) < 0) return -1; else if (git_idxmap_resize(map, length) < 0) return -1; The funny thing is: on case-insensitive systems, we will try to resize the map twice in case where `git_idxmap_icase_resize()` doesn't error. While this will still use the correct hashing function as both map types use the same, this bug will at least cause us to resize the map twice in a row. Fix the issue by introducing a new function `index_map_resize` that handles case-sensitivity, similar to how `index_map_set` and `index_map_delete`. Convert all call sites where we were previously resizing the map to use that new function.
| * | index: replace map macros with inline functionsPatrick Steinhardt2020-01-141-43/+34
| |/ | | | | | | | | | | | | | | | | | | | | Traditionally, our maps were mostly implemented via macros that had weird call semantics. This shows in our index code, where we have macros that insert into an index map case-sensitively or insensitively, as they still return error codes via an error parameter. This is unwieldy and, most importantly, not necessary anymore, due to the introduction of our high-level map API and removal of macros. Replace them with inlined functions to make code easier to read.
* | Make type mismatch errors consistentTobias Nießen2020-01-152-2/+2
|/
* Merge pull request #5355 from pks-t/pks/win32-relative-symlink-across-dirsEdward Thomson2020-01-121-1/+9
|\ | | | | win32: fix relative symlinks pointing into dirs
| * win32: fix relative symlinks pointing into dirsPatrick Steinhardt2020-01-101-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Windows platforms, we need some logic to emulate symlink(3P) defined by POSIX. As unprivileged symlinks on Windows are a rather new feature, our current implementation is comparatively new and still has some rough edges in special cases. One such case is relative symlinks. While relative symlinks to files in the same directory work as expected, libgit2 currently fails to create reltaive symlinks pointing into other directories. This is due to the fact that we forgot to translate the Unix-style target path to Windows-style. Most importantly, we are currently not converting directory separators from "/" to "\". Fix the issue by calling `git_win32_path_canonicalize` on the target. Add a test that verifies our ability to create such relative links across directories.
* | Merge pull request #5305 from kas-luthor/bugfix/multiple-authPatrick Steinhardt2020-01-101-0/+8
|\ \ | |/ |/| Adds support for multiple SSH auth mechanisms being used sequentially
| * Fixes code stylingkas2019-12-131-5/+3
| |
| * Adds support for multiple SSH auth mechanisms being used sequentiallykas2019-11-161-0/+10
| |
* | netops: handle intact query parameters in service_suffix removalJosh Bleecher Snyder2020-01-091-8/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | Some servers leave the query parameters intact in the Location header when responding with a redirect. The service_suffix removal check as written assumed that the server removed them. Handle both cases. Along with PR #5325, this fixes #5321. There are two new tests. The first already passed; the second previously failed.
* | pack: refactor streams to use `git_zstream`Patrick Steinhardt2020-01-092-47/+19
| | | | | | | | | | | | While we do have a `git_zstream` abstraction that encapsulates all the calls to zlib as well as its error handling, we do not use it in our pack file code. Refactor it to make the code a lot easier to understand.
* | pack: refactor unpacking of raw objects to use `git_zstream`Patrick Steinhardt2020-01-093-41/+44
| | | | | | | | | | | | While we do have a zstream abstraction that encapsulates all the calls to zlib as well as its error handling, we do not use it in our pack file code. Refactor it to make the code a lot easier to understand.
* | Merge pull request #5322 from kdj0c/fix_sub_syncEdward Thomson2020-01-081-56/+49
|\ \ | | | | | | Fix git_submodule_sync with relative url