From 43a27a12183d6636e5d770abe41e6f47462e59d0 Mon Sep 17 00:00:00 2001 From: Oli Dagenais Date: Fri, 20 May 2016 14:48:27 -0400 Subject: [PATCH 1/2] The EraseOsxKeyChain setting defaults to TRUE The "Apple Git" workaround can still be disabled by configuring it to FALSE. --- .../microsoft/alm/gitcredentialmanager/OperationArguments.java | 2 +- .../java/com/microsoft/alm/gitcredentialmanager/Program.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/microsoft/alm/gitcredentialmanager/OperationArguments.java b/src/main/java/com/microsoft/alm/gitcredentialmanager/OperationArguments.java index c3ef6dfc..3cd48250 100644 --- a/src/main/java/com/microsoft/alm/gitcredentialmanager/OperationArguments.java +++ b/src/main/java/com/microsoft/alm/gitcredentialmanager/OperationArguments.java @@ -23,7 +23,7 @@ final class OperationArguments this.Interactivity = com.microsoft.alm.gitcredentialmanager.Interactivity.Auto; this.ValidateCredentials = true; this.WriteLog = false; - this.EraseOsxKeyChain = false; + this.EraseOsxKeyChain = true; String protocol = null; String host = null; diff --git a/src/main/java/com/microsoft/alm/gitcredentialmanager/Program.java b/src/main/java/com/microsoft/alm/gitcredentialmanager/Program.java index da068a37..675e76ca 100644 --- a/src/main/java/com/microsoft/alm/gitcredentialmanager/Program.java +++ b/src/main/java/com/microsoft/alm/gitcredentialmanager/Program.java @@ -221,7 +221,7 @@ private void printHelpMessage() standardOut.println(" The workaround is to preemptively erase from osxkeychain"); standardOut.println(" any Git credentials that can be refreshed or re-acquired"); standardOut.println(" by this credential helper."); - standardOut.println(" Defaults to FALSE. Ignored by Basic authority."); + standardOut.println(" Defaults to TRUE. Ignored by Basic authority."); standardOut.println(" Does nothing if Apple Git on Mac OS X isn't detected."); standardOut.println(); standardOut.println(" `git config --global credential.microsoft.visualstudio.com.eraseosxkeychain false`"); From 22f8d6d813b36db826020061893a3987f45220f0 Mon Sep 17 00:00:00 2001 From: Oli Dagenais Date: Thu, 30 Jun 2016 22:32:00 -0400 Subject: [PATCH 2/2] Expand workaround to any Git with osxkeychain It turns out the "Git OSX Installer" brings the same hardcoded osxkeychain credential helper and thus it is no longer sufficient to try to detect based on the Git version. --- .../alm/gitcredentialmanager/Program.java | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/microsoft/alm/gitcredentialmanager/Program.java b/src/main/java/com/microsoft/alm/gitcredentialmanager/Program.java index 675e76ca..df826427 100644 --- a/src/main/java/com/microsoft/alm/gitcredentialmanager/Program.java +++ b/src/main/java/com/microsoft/alm/gitcredentialmanager/Program.java @@ -214,7 +214,7 @@ private void printHelpMessage() standardOut.println(" `git config --global credential.microsoft.visualstudio.com.authority AAD`"); standardOut.println(); standardOut.println(" eraseosxkeychain Enables a workaround when running on Mac OS X"); - standardOut.println(" and using 'Apple Git' (which includes the osxkeychain"); + standardOut.println(" and using a version of Git which includes the osxkeychain"); standardOut.println(" credential helper, hardcoded before all other helpers)."); standardOut.println(" The problem is osxkeychain may return expired or"); standardOut.println(" revoked credentials, aborting the Git operation."); @@ -222,7 +222,7 @@ private void printHelpMessage() standardOut.println(" any Git credentials that can be refreshed or re-acquired"); standardOut.println(" by this credential helper."); standardOut.println(" Defaults to TRUE. Ignored by Basic authority."); - standardOut.println(" Does nothing if Apple Git on Mac OS X isn't detected."); + standardOut.println(" Does nothing if osxkeychain on Mac OS X isn't detected."); standardOut.println(); standardOut.println(" `git config --global credential.microsoft.visualstudio.com.eraseosxkeychain false`"); standardOut.println(); @@ -437,30 +437,26 @@ public static void store(final OperationArguments operationArguments, final IAut { if (operationArguments.EraseOsxKeyChain && Provider.isMac(osName)) { - final String gitResponse = fetchGitVersion(processFactory); - if (gitResponse.contains("Apple Git-")) + // check for the presence of git-credential-osxkeychain by scanning PATH + final File osxkeychainFile = findProgram(pathString, pathSeparator, "git-credential-osxkeychain", fileChecker); + if (osxkeychainFile != null) { - // check for the presence of git-credential-osxkeychain by scanning PATH - final File osxkeychainFile = findProgram(pathString, pathSeparator, "git-credential-osxkeychain", fileChecker); - if (osxkeychainFile != null) + // erase these credentials from osxkeychain + try { - // erase these credentials from osxkeychain - try - { - final String program = osxkeychainFile.getAbsolutePath(); - final TestableProcess process = processFactory.create(program, "erase"); - final ProcessCoordinator coordinator = new ProcessCoordinator(process); - coordinator.print(operationArguments.toString()); - coordinator.waitFor(); - } - catch (final IOException e) - { - throw new Error(e); - } - catch (final InterruptedException e) - { - throw new Error(e); - } + final String program = osxkeychainFile.getAbsolutePath(); + final TestableProcess process = processFactory.create(program, "erase"); + final ProcessCoordinator coordinator = new ProcessCoordinator(process); + coordinator.print(operationArguments.toString()); + coordinator.waitFor(); + } + catch (final IOException e) + { + throw new Error(e); + } + catch (final InterruptedException e) + { + throw new Error(e); } } }