[gnome-builder] git: prevent infinite loop trying repeat credentials



commit dfa8bc7a69f7623f9ef7cc2cb7ba3c68de2438a2
Author: Christian Hergert <christian hergert me>
Date:   Wed Apr 27 19:20:05 2016 -0700

    git: prevent infinite loop trying repeat credentials
    
    After we have tried a given credentials type, mark it so that we do not
    try it again using this callbacks instance.

 plugins/git/ide-git-remote-callbacks.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/plugins/git/ide-git-remote-callbacks.c b/plugins/git/ide-git-remote-callbacks.c
index 2dd11d0..beeb318 100644
--- a/plugins/git/ide-git-remote-callbacks.c
+++ b/plugins/git/ide-git-remote-callbacks.c
@@ -33,6 +33,7 @@ struct _IdeGitRemoteCallbacks
   EggAnimation        *animation;
   IdeProgress         *progress;
   gdouble              fraction;
+  GgitCredtype         tried;
 };
 
 G_DEFINE_TYPE (IdeGitRemoteCallbacks, ide_git_remote_callbacks, GGIT_TYPE_REMOTE_CALLBACKS)
@@ -138,21 +139,25 @@ ide_git_remote_callbacks_real_credentials (GgitRemoteCallbacks  *callbacks,
                                            GgitCredtype          allowed_types,
                                            GError              **error)
 {
+  IdeGitRemoteCallbacks *self = (IdeGitRemoteCallbacks *)callbacks;
   GgitCred *ret = NULL;
 
   IDE_ENTRY;
 
-  g_assert (IDE_IS_GIT_REMOTE_CALLBACKS (callbacks));
+  g_assert (IDE_IS_GIT_REMOTE_CALLBACKS (self));
   g_assert (url != NULL);
 
   IDE_TRACE_MSG ("username=%s url=%s", username_from_url ?: "", url);
 
+  allowed_types &= ~self->tried;
+
   if ((allowed_types & GGIT_CREDTYPE_SSH_KEY) != 0)
     {
       GgitCredSshKeyFromAgent *cred;
 
       cred = ggit_cred_ssh_key_from_agent_new (username_from_url, error);
       ret = GGIT_CRED (cred);
+      self->tried |= GGIT_CREDTYPE_SSH_KEY;
     }
 
   if ((allowed_types & GGIT_CREDTYPE_SSH_INTERACTIVE) != 0)
@@ -161,6 +166,7 @@ ide_git_remote_callbacks_real_credentials (GgitRemoteCallbacks  *callbacks,
 
       cred = ggit_cred_ssh_interactive_new (username_from_url, error);
       ret = GGIT_CRED (cred);
+      self->tried |= GGIT_CREDTYPE_SSH_INTERACTIVE;
     }
 
   IDE_RETURN (ret);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]