KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kigit_transport.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.TXT for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#include "kigit_transport.h"
21
22#include "git_repo_mixin.h"
23#include "kicad_git_common.h"
24#include "kigit_failure.h"
25#include "kigit_ssh_keys.h"
26
28#include <trace_helpers.h>
29
30#include <wx/log.h>
31#include <wx/translation.h>
32
33#include <cstring>
34
35
36namespace KIGIT
37{
38
40{
42 unsigned tested = 0;
43 bool agentTried = false;
45
46 KIGIT_COMMON* Common() const { return handler->GetCommon(); }
47
49 void Begin()
50 {
51 tested = 0;
52 agentTried = false;
54 handler->ResetTransferState();
55 }
56
57 int Fail( int aCode )
58 {
60 return aCode;
61 }
62};
63
64
65namespace
66{
68
69
70 int refuseAuthentication( STATE& aState )
71 {
72 // Answered as a refusal rather than "no callback set", so the caller prompts and retries
73 git_error_clear();
74 git_error_set_str( GIT_ERROR_NET, _( "Unable to authenticate" ).mbc_str() );
75 aState.handler->SetAuthFailure();
76 return GIT_EAUTH;
77 }
78
79
80 // The server accepted the key's public half. Refusing to sign ends the request before any login is tried.
81 // Recorded here because the server may disconnect before libgit2 asks for another credential
82 extern "C" int probeSignCb( LIBSSH2_SESSION*, unsigned char**, size_t*, const unsigned char*, size_t,
83 void** aAbstract )
84 {
85 if( !aAbstract || !*aAbstract )
86 return -1;
87
88 KIGIT_AUTH_ATTEMPT* attempt = static_cast<KIGIT_AUTH_ATTEMPT*>( *aAbstract );
89 attempt->lastKeyRefused = false;
90
91 if( attempt->acceptedKey.IsEmpty() )
92 {
93 attempt->acceptedKey = attempt->probing;
94 attempt->passphraseGiven = false;
95 }
96
97 return -1;
98 }
99
100
102 int offerSSHKey( STATE& aState, git_credential** aOut, const wxString& aUsername )
103 {
104 KIGIT_AUTH_ATTEMPT& attempt = aState.handler->AuthAttempt();
105 KIGIT_COMMON* common = aState.Common();
106
107 if( !aState.agentTried )
108 {
109 aState.agentTried = true;
110
111 if( git_credential_ssh_key_from_agent( aOut, aUsername.mbc_str() ) == GIT_OK )
112 {
113 attempt.agentTried = true;
114 return GIT_OK;
115 }
116
117 wxLogTrace( traceGit, "Failed to create SSH agent credential: %s", KIGIT_COMMON::GetLastGitError() );
118 }
119
120 if( !attempt.probing.IsEmpty() )
121 {
122 wxLogTrace( traceGit, attempt.lastKeyRefused ? "Server refuses %s" : "Server accepts %s", attempt.probing );
123 attempt.probing.clear();
124 }
125
126 wxString password = common->GetPassword();
127 wxString sshKey = common->GetNextPublicKey();
128
129 if( sshKey.IsEmpty() )
130 {
131 wxLogTrace( traceGit, "Finished testing all possible ssh keys" );
132 aState.tested |= GIT_CREDENTIAL_SSH_KEY;
133 return GIT_PASSTHROUGH;
134 }
135
136 // Without a passphrase no encrypted key can sign, so asking the server first is the only way to learn which
137 // one it takes. With one, the probe's extra round would cost a counted attempt for nothing
138 if( password.IsEmpty() && IsPrivateKeyFileEncrypted( sshKey ) )
139 {
140 const std::string blob = PublicKeyBlob( sshKey );
141
142 if( !blob.empty()
143 && git_credential_ssh_custom_new( aOut, aUsername.mbc_str(), blob.data(), blob.size(), probeSignCb,
144 &attempt )
145 == GIT_OK )
146 {
147 wxLogTrace( traceGit, "Asking whether the server takes %s", sshKey );
148 attempt.probing = sshKey;
149 attempt.lastKeyRefused = true;
150 attempt.keysTried.push_back( sshKey );
151 return GIT_OK;
152 }
153 }
154
155 wxString sshPubKey = PublicKeyPath( sshKey );
156
157 wxLogTrace( traceGit, "Testing %s\n", sshKey );
158
159 if( git_credential_ssh_key_new( aOut, aUsername.mbc_str(), sshPubKey.mbc_str(), sshKey.mbc_str(),
160 password.mbc_str() )
161 != GIT_OK )
162 {
163 wxLogTrace( traceGit, "Failed to create SSH key credential for %s: %s", sshKey,
165 return GIT_PASSTHROUGH;
166 }
167
168 // libssh2 reads the file only once authentication starts, so a load failure names this key
169 attempt.keysTried.push_back( sshKey );
170 attempt.lastKeyRefused = false;
171 attempt.passphraseGiven = !password.IsEmpty();
172 return GIT_OK;
173 }
174
175
176 extern "C" int credentialsCb( git_credential** aOut, const char* aUrl, const char* aUsername,
177 unsigned int aAllowedTypes, void* aPayload )
178 {
179 STATE& state = *static_cast<STATE*>( aPayload );
180 KIGIT_REPO_MIXIN* handler = state.handler;
181
182 // The transport's URL outranks a cached remote that may be empty or stale
183 state.Common()->SyncRemoteUrl( wxString::FromUTF8( aUrl ) );
184
185 // The configured remote URL may embed a password. Keep it out of the trace log.
186 wxString safeUrl = StripEmbeddedUserinfo( wxString::FromUTF8( aUrl ) );
187
188 wxLogTrace( traceGit, "Credentials callback for %s, testing %d", safeUrl, aAllowedTypes );
189
190 handler->AuthAttempt().connType = handler->GetConnType();
191
193 {
194 wxLogTrace( traceGit, "Local repository, no credentials needed" );
195 return GIT_PASSTHROUGH;
196 }
197
198 if( ( aAllowedTypes & GIT_CREDENTIAL_USERNAME ) && !( state.tested & GIT_CREDENTIAL_USERNAME ) )
199 {
200 wxString username = handler->GetUsername().Trim().Trim( false );
201
202 // A token in the URL parses as the username, so no trace names it
203 wxLogTrace( traceGit, "Username credential at %s with allowed type %d", safeUrl, aAllowedTypes );
204
205 // An empty username makes the server answer "unsupported authentication", which tells the user nothing
206 if( username.IsEmpty() )
207 return refuseAuthentication( state );
208
209 if( int rc = git_credential_username_new( aOut, username.ToStdString().c_str() ); rc != GIT_OK )
210 {
211 wxLogTrace( traceGit, "Failed to create username credential: %s", KIGIT_COMMON::GetLastGitError() );
212 return rc;
213 }
214
215 state.tested |= GIT_CREDENTIAL_USERNAME;
216 return GIT_OK;
217 }
218
220 && ( aAllowedTypes & GIT_CREDENTIAL_USERPASS_PLAINTEXT )
221 && !( state.tested & GIT_CREDENTIAL_USERPASS_PLAINTEXT ) && !handler->GetUsername().IsEmpty() )
222 {
223 wxLogTrace( traceGit, "Plaintext authentication at %s with allowed type %d", safeUrl, aAllowedTypes );
224
225 wxString password = state.Common()->GetPassword();
226 int rc = git_credential_userpass_plaintext_new( aOut, handler->GetUsername().mbc_str(), password.mbc_str() );
227
228 state.tested |= GIT_CREDENTIAL_USERPASS_PLAINTEXT;
229 handler->AuthAttempt().passwordGiven = !password.IsEmpty();
230 return rc;
231 }
232
234 && ( aAllowedTypes & GIT_CREDENTIAL_SSH_KEY ) && !( state.tested & GIT_CREDENTIAL_SSH_KEY ) )
235 {
236 // libgit2 fails a credential whose user differs from the one the SSH session already uses
237 wxString sshUser = ( aUsername && *aUsername ) ? wxString::FromUTF8( aUsername ) : handler->GetUsername();
238
239 int result = offerSSHKey( state, aOut, sshUser );
240
241 if( result == GIT_PASSTHROUGH )
242 return refuseAuthentication( state );
243
244 return result;
245 }
246
247 return refuseAuthentication( state );
248 }
249
250
251 extern "C" int certificateCb( git_cert* aCert, int aValid, const char* aHost, void* aPayload )
252 {
253 if( !aCert || !aHost || !aPayload || aCert->cert_type != GIT_CERT_HOSTKEY_LIBSSH2 )
254 return GIT_PASSTHROUGH;
255
256 const git_cert_hostkey* cert = reinterpret_cast<const git_cert_hostkey*>( aCert );
257 STATE& state = *static_cast<STATE*>( aPayload );
258 KIGIT_REPO_MIXIN* handler = state.handler;
259
260 auto refuse = [&]( const wxString& aReason )
261 {
262 // libgit2 v1.9.0 ssh_libssh2.c:758-760 replaces any error the callback sets
263 handler->SetHostKeyRefusal( aReason );
264 return GIT_ECERTIFICATE;
265 };
266
267 // libgit2 1.9 connects on a passthrough even when nothing was verified
268 auto refuseUnreadable = [&]()
269 {
270 wxLogTrace( traceGit, "Host key from %s cannot be read, refusing it", aHost );
271 return refuse( wxString::Format( _( "KiCad could not read the key %s presented, so the connection was "
272 "not made. Ask your administrator which host key the server uses." ),
273 wxString::FromUTF8( aHost ) ) );
274 };
275
276 if( !( cert->type & GIT_CERT_SSH_RAW ) || !cert->hostkey || cert->hostkey_len == 0 )
277 return refuseUnreadable();
278
280 key.rawKey.assign( cert->hostkey, cert->hostkey_len );
281 key.host = wxString::FromUTF8( aHost );
282
283 // An SCP address hands over an IPv6 host still in its brackets
284 if( key.host.StartsWith( wxS( "[" ) ) && key.host.EndsWith( wxS( "]" ) ) )
285 key.host = key.host.Mid( 1, key.host.length() - 2 );
286
287 key.port = state.Common()->SSHPortFor( key.host );
288
289 // Checking another port's entries would let a wildcard or plain-host line vouch for this server
290 if( key.port < 0 )
291 {
292 wxLogTrace( traceGit, "Host %s does not match the synced remote, refusing its key", key.host );
293 return refuse( wxString::Format( _( "The address of %s could not be matched to the remote, so its key "
294 "was not checked. Check the remote URL." ),
295 key.host ) );
296 }
297
298 key.keyType = HostKeyType( key.rawKey );
299 key.fingerprint = HostKeyFingerprint( key.rawKey );
300
301 if( key.keyType.IsEmpty() )
302 return refuseUnreadable();
303
304 key.state = LookupKnownHost( ReadKnownHosts(), key.host, key.port, key.keyType, key.rawKey );
305
306 wxLogTrace( traceGit, "Host key %s SHA256:%s for %s port %d, known_hosts state %d, libgit2 valid %d",
307 key.keyType, key.fingerprint, key.host, key.port, static_cast<int>( key.state ), aValid );
308
309 // libssh2 accepts revoked keys and port-22 lines for other ports, and 1.5.0 reads no known_hosts at all
310 if( key.state == KNOWN_HOST_STATE::MATCH )
311 return 0;
312
313 handler->SetHostKeyFailure( key );
314 return GIT_ECERTIFICATE;
315 }
316
317
318 extern "C" int sidebandCb( const char* aData, int aLength, void* aPayload )
319 {
320 STATE& state = *static_cast<STATE*>( aPayload );
321
322 if( state.handler->IsThisOperationCancelled() )
323 {
324 wxLogTrace( traceGit, "Progress CB cancelled" );
325 return GIT_EUSER;
326 }
327
328 state.handler->ReceiveSideband( aData, aLength );
329 return 0;
330 }
331
332
333 extern "C" int transferCb( const git_transfer_progress* aStats, void* aPayload )
334 {
335 STATE& state = *static_cast<STATE*>( aPayload );
336
337 if( state.handler->IsThisOperationCancelled() )
338 {
339 wxLogTrace( traceGit, "Transfer progress cancelled" );
340 return GIT_EUSER;
341 }
342
343 state.handler->UpdateProgress( aStats->received_objects, aStats->total_objects,
344 wxString::Format( _( "Received %u of %u objects" ), aStats->received_objects,
345 aStats->total_objects ) );
346 return 0;
347 }
348
349
350 extern "C" int updateTipsCb( const char* aRefname, const git_oid* aFirst, const git_oid* aSecond,
351 void* aPayload )
352 {
353 constexpr int cstring_len = 8;
354 char a_str[cstring_len + 1];
355 char b_str[cstring_len + 1];
356
357 STATE& state = *static_cast<STATE*>( aPayload );
358 wxString status;
359
360 git_oid_tostr( b_str, cstring_len, aSecond );
361
362#if ( LIBGIT2_VER_MAJOR >= 1 ) || ( LIBGIT2_VER_MINOR >= 99 )
363 if( !git_oid_is_zero( aFirst ) )
364#else
365 if( !git_oid_iszero( aFirst ) )
366#endif
367 {
368 git_oid_tostr( a_str, cstring_len, aFirst );
369 status = wxString::Format( _( "* [updated] %s..%s %s" ), a_str, b_str, aRefname );
370 }
371 else
372 {
373 status = wxString::Format( _( "* [new] %s %s" ), b_str, aRefname );
374 }
375
376 state.handler->UpdateProgress( 0, 0, status );
377 return 0;
378 }
379
380
381 extern "C" int pushTransferCb( unsigned int aCurrent, unsigned int aTotal, size_t aBytes, void* aPayload )
382 {
383 STATE& state = *static_cast<STATE*>( aPayload );
384
385 if( state.handler->IsThisOperationCancelled() )
386 {
387 wxLogTrace( traceGit, "Push progress cancelled" );
388 return GIT_EUSER;
389 }
390
391 long long progress = aTotal ? ( aCurrent * 100ll ) / aTotal : 100;
392
393 state.handler->UpdateProgress( aCurrent, aTotal,
394 wxString::Format( _( "Writing objects: %lld%% (%u/%u), %zu bytes" ), progress,
395 aCurrent, aTotal, aBytes ) );
396 return 0;
397 }
398
399
400 extern "C" int pushUpdateReferenceCb( const char* aRefname, const char* aStatus, void* aPayload )
401 {
402 STATE& state = *static_cast<STATE*>( aPayload );
403
404 if( !aStatus || !*aStatus )
405 {
406 state.handler->UpdateProgress( 0, 0, wxString::Format( _( "[updated] %s" ), aRefname ) );
407 return 0;
408 }
409
410 const wxString status = DecodeServerText( aStatus, strlen( aStatus ) );
411
412 state.handler->SetPushRefusal( wxString::Format( wxS( "%s: %s" ), aRefname, status ) );
413 state.handler->UpdateProgress( 0, 0, wxString::Format( _( "* [rejected] %s (%s)" ), aRefname,
414 PrintableServerText( status ) ) );
415
416 // Without this the push reports success even though the remote refused it
417 git_error_set_str( GIT_ERROR_NET, aStatus );
418 return GIT_ERROR;
419 }
420
421
422 extern "C" void checkoutCb( const char* aPath, size_t aDone, size_t aTotal, void* aPayload )
423 {
424 STATE& state = *static_cast<STATE*>( aPayload );
425
426 state.handler->UpdateProgress( aDone, aTotal, wxString( aPath ) );
427 }
428
429
430 // url.insteadOf can rewrite the clone URL, which would otherwise read as a new identity and drop the
431 // credentials entered for the original
432 extern "C" int cloneRemoteCb( git_remote** aOut, git_repository* aRepo, const char* aName, const char* aUrl,
433 void* aPayload )
434 {
435 if( int rc = git_remote_create( aOut, aRepo, aName, aUrl ); rc != GIT_OK )
436 return rc;
437
438 if( const char* url = git_remote_url( *aOut ) )
439 static_cast<STATE*>( aPayload )->Common()->FollowRewrittenUrl( wxString::FromUTF8( url ) );
440
441 return GIT_OK;
442 }
443
444
445 git_remote_callbacks callbacksFor( STATE& aState )
446 {
447 git_remote_callbacks callbacks;
448 git_remote_init_callbacks( &callbacks, GIT_REMOTE_CALLBACKS_VERSION );
449 callbacks.credentials = credentialsCb;
450 callbacks.certificate_check = certificateCb;
451 callbacks.sideband_progress = sidebandCb;
452 callbacks.transfer_progress = transferCb;
453 callbacks.update_tips = updateTipsCb;
454 callbacks.push_transfer_progress = pushTransferCb;
455 callbacks.push_update_reference = pushUpdateReferenceCb;
456 callbacks.payload = &aState;
457
458 return callbacks;
459 }
460
461
462 git_proxy_options autoProxy()
463 {
464 git_proxy_options proxy;
465 git_proxy_init_options( &proxy, GIT_PROXY_OPTIONS_VERSION );
466 proxy.type = GIT_PROXY_AUTO;
467
468 return proxy;
469 }
470} // namespace
471
472
473REMOTE_TRANSPORT::REMOTE_TRANSPORT( KIGIT_REPO_MIXIN* aHandler, git_remote* aRemote, bool aFollowRedirects ) :
474 m_state( std::make_unique<STATE>() ),
475 m_remote( aRemote ),
476 m_followRedirects( aFollowRedirects )
477{
478 m_state->handler = aHandler;
479}
480
481
483
484
485int REMOTE_TRANSPORT::connect( git_direction aDirection, const git_remote_callbacks& aCallbacks )
486{
487#if LIBGIT2_VER_MAJOR > 1 || ( LIBGIT2_VER_MAJOR == 1 && LIBGIT2_VER_MINOR >= 4 )
488 git_remote_connect_options options;
489 git_remote_connect_options_init( &options, GIT_REMOTE_CONNECT_OPTIONS_VERSION );
490 options.callbacks = aCallbacks;
491 options.proxy_opts = autoProxy();
492
493 // Left unset, libgit2 honours http.followRedirects
494 if( !m_followRedirects )
495 options.follow_redirects = GIT_REMOTE_REDIRECT_NONE;
496
497 if( int rc = git_remote_connect_ext( m_remote, aDirection, &options ) )
498 return m_state->Fail( rc );
499#else
500 // No per-connection redirect control.
501 git_proxy_options proxy = autoProxy();
502
503 if( int rc = git_remote_connect( m_remote, aDirection, &aCallbacks, &proxy, nullptr ) )
504 return m_state->Fail( rc );
505#endif
506
507 // libgit2 asks for nothing more once a credential works, so the key just offered is the one to try first
508 m_state->handler->RememberWorkingSSHKey();
509 return GIT_OK;
510}
511
512
513int REMOTE_TRANSPORT::Fetch( std::vector<wxString>* aBranches )
514{
515 m_state->Begin();
516
517 git_fetch_options options;
518 git_fetch_init_options( &options, GIT_FETCH_OPTIONS_VERSION );
519 options.callbacks = callbacksFor( *m_state );
520 options.proxy_opts = autoProxy();
521
522 if( int rc = connect( GIT_DIRECTION_FETCH, options.callbacks ) )
523 return rc;
524
525 const git_remote_head** heads = nullptr;
526 size_t count = 0;
527
528 // The advertisement, not local tracking refs, because a custom refspec or stale refs mislead those
529 if( aBranches && git_remote_ls( &heads, &count, m_remote ) == GIT_OK )
530 {
531 for( size_t ii = 0; ii < count; ++ii )
532 {
533 if( std::strncmp( heads[ii]->name, "refs/heads/", 11 ) == 0 )
534 aBranches->push_back( wxString::FromUTF8( heads[ii]->name + 11 ) );
535 }
536 }
537
538 int rc = git_remote_fetch( m_remote, nullptr, &options, nullptr );
539
540 if( rc )
541 m_state->Fail( rc );
542
543 git_remote_disconnect( m_remote );
544 return rc;
545}
546
547
548int REMOTE_TRANSPORT::Push( const std::function<wxString()>& aConnected )
549{
550 m_state->Begin();
551
552 git_push_options options;
553 git_push_init_options( &options, GIT_PUSH_OPTIONS_VERSION );
554 options.callbacks = callbacksFor( *m_state );
555 options.proxy_opts = autoProxy();
556
557#if LIBGIT2_VER_MAJOR > 1 || ( LIBGIT2_VER_MAJOR == 1 && LIBGIT2_VER_MINOR >= 4 )
558 if( !m_followRedirects )
559 options.follow_redirects = GIT_REMOTE_REDIRECT_NONE;
560#endif
561
562 if( int rc = connect( GIT_DIRECTION_PUSH, options.callbacks ) )
563 return rc;
564
565 wxString refspec = aConnected();
566
567 if( refspec.IsEmpty() )
568 {
569 git_remote_disconnect( m_remote );
570 return GIT_EUSER;
571 }
572
573 std::string refspecUtf8 = refspec.utf8_string();
574 const char* refs[1] = { refspecUtf8.c_str() };
575 const git_strarray refspecs = { const_cast<char**>( refs ), 1 };
576
577 // The connection is reused, so the push goes to the server the caller just checked against
578 int rc = git_remote_push( m_remote, &refspecs, &options );
579
580 if( rc )
581 m_state->Fail( rc );
582
583 git_remote_disconnect( m_remote );
584 return rc;
585}
586
587
589{
590 m_state->Begin();
591
592 if( int rc = connect( GIT_DIRECTION_FETCH, callbacksFor( *m_state ) ) )
593 return rc;
594
595 git_remote_disconnect( m_remote );
596 return GIT_OK;
597}
598
599
600int REMOTE_TRANSPORT::Clone( const wxString& aUrl, const wxString& aPath, git_repository** aRepo )
601{
602 m_state->Begin();
603
604 git_clone_options options;
605 git_clone_init_options( &options, GIT_CLONE_OPTIONS_VERSION );
606 options.checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
607 options.checkout_opts.progress_cb = checkoutCb;
608 options.checkout_opts.progress_payload = m_state.get();
609 options.fetch_opts.callbacks = callbacksFor( *m_state );
610 options.fetch_opts.proxy_opts = autoProxy();
611 options.remote_cb = cloneRemoteCb;
612 options.remote_cb_payload = m_state.get();
613
614 std::string urlUtf8 = aUrl.utf8_string();
615
616 if( int rc = git_clone( aRepo, urlUtf8.c_str(), aPath.mbc_str(), &options ) )
617 return m_state->Fail( rc );
618
619 m_state->handler->RememberWorkingSSHKey();
620 return GIT_OK;
621}
622
623
625{
626 return m_state->error;
627}
628
629} // namespace KIGIT
const char * name
std::unique_ptr< STATE > m_state
const KIGIT_ERROR_INFO & Error() const
libgit2's error for the last call that failed, read before anything else could replace it
REMOTE_TRANSPORT(KIGIT_REPO_MIXIN *aHandler, git_remote *aRemote=nullptr, bool aFollowRedirects=true)
aHandler supplies the session and records progress, the credentials offered and why a call failed.
int Fetch(std::vector< wxString > *aBranches=nullptr)
Fetch as git fetch would. aBranches, when given, receives the branches the remote advertised.
int Check()
Connect, which proves the credentials and the host key without transferring anything.
int Clone(const wxString &aUrl, const wxString &aPath, git_repository **aRepo)
Clone aUrl into aPath. The new repository is returned in aRepo for the caller to free.
int Push(const std::function< wxString()> &aConnected)
Connect, then push the refspec aConnected answers, so the caller can check what it pushes after a con...
int connect(git_direction aDirection, const git_remote_callbacks &aCallbacks)
The project's git session.
static KIGIT_ERROR_INFO GetLastGitErrorInfo(int aCode)
The error libgit2 holds for a call that returned aCode.
wxString GetNextPublicKey()
By value, so the caller never holds a pointer into the vector.
static wxString GetLastGitError()
libgit2's last message, without credentials from any URL it quotes, so it is safe to show or trace.
wxString GetPassword()
The secret for the remote, read without ever prompting, so it is safe on a transfer worker.
void SetHostKeyRefusal(const wxString &aReason)
wxString GetUsername() const
Get the username.
KIGIT_AUTH_ATTEMPT & AuthAttempt()
void SetHostKeyFailure(const KIGIT::HOST_KEY_FAILURE &aFailure)
KIGIT_COMMON::GIT_CONN_TYPE GetConnType() const
Get the connection type.
#define _(s)
const wxChar *const traceGit
Flag to enable Git debugging output.
The one place a fetch, push, clone or connection check reaches a remote.
bool IsPrivateKeyFileEncrypted(const wxString &aKey)
IsPrivateKeyEncrypted for the key file aKey. A file that cannot be read is reported as unencrypted.
APIEXPORT wxString StripEmbeddedUserinfo(const wxString &aText)
Remove the user and password from every URL quoted in a message, since the remote's can carry a passw...
APIEXPORT wxString PrintableServerText(const wxString &aText)
Text a server sent, made safe to show: no terminal escapes, control or bidi characters,...
@ MATCH
An entry names the host with this key.
APIEXPORT wxString PublicKeyPath(const wxString &aKey)
The public key file to offer with aKey.
APIEXPORT KNOWN_HOST_STATE LookupKnownHost(const wxString &aKnownHostsText, const wxString &aHost, int aPort, const wxString &aKeyType, const std::string &aRawKey)
Classify a server's key against the text of a known_hosts file, as OpenSSH reads it.
APIEXPORT wxString DecodeServerText(const char *aData, size_t aLength)
Bytes a server sent, as UTF-8 or, when they are not valid UTF-8, one character for each byte.
APIEXPORT wxString ReadKnownHosts()
The text of KnownHostsPath(). Empty when it is missing or cannot be read.
APIEXPORT wxString HostKeyType(const std::string &aRawKey)
The type a raw SSH key names for itself, such as ssh-ed25519. Empty when the key is malformed.
APIEXPORT wxString HostKeyFingerprint(const std::string &aRawKey)
SHA256 of a raw key in unpadded base64, as ssh shows it after "SHA256:".
APIEXPORT std::string PublicKeyBlob(const wxString &aKey)
The public key blob from aKey's public key file, as the server sees it, or empty when it cannot be re...
STL namespace.
A server key the connection refused, for the UI to offer to trust or to report.
std::string rawKey
The key as the server sent it.
KIGIT_COMMON * Common() const
void Begin()
Every call offers every credential again and keeps nothing from an earlier failure.
unsigned tested
The git_credential_t kinds this call has offered.
What the credential callback handed out during one operation, kept to explain a rejection.
bool lastKeyRefused
The server refused the last key's public half.
wxString probing
The encrypted key whose public half is out to the server now.
bool passwordGiven
A password went with the last username offered.
KIGIT_COMMON::GIT_CONN_TYPE connType
wxString acceptedKey
An encrypted key whose public half the server accepted.
std::vector< wxString > keysTried
Key files offered, in order.
bool agentTried
The SSH agent was offered before any key file.
bool passphraseGiven
A passphrase went with the last key file offered.
What libgit2 reported for a failed call, read before anything else can replace it.
wxString result
Test unit parsing edge cases and error handling.
wxLogTrace helper definitions.
VIA_CROSS_SECTION_GEOMETRY::STATE STATE