aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TunnelPassphraseRequester.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-06-06 23:25:06 +0000
committerrowanbeentje <rowan@beent.je>2009-06-06 23:25:06 +0000
commitab4d3557db6d823275b688ccb7210830f029fd5c (patch)
treecf0ba9733d03868c22d81904d4486ed2de350f4c /Source/TunnelPassphraseRequester.m
parent2f5c4b9bab18b54f2d37f4b4a05afa116cfd0c44 (diff)
downloadsequelpro-ab4d3557db6d823275b688ccb7210830f029fd5c.tar.gz
sequelpro-ab4d3557db6d823275b688ccb7210830f029fd5c.tar.bz2
sequelpro-ab4d3557db6d823275b688ccb7210830f029fd5c.zip
Further SSH tunnel improvements:
- Redesigned SSH key authentication dialog - Added ability to add SSH key passphrases to keychain (sharing details with system SSH) - SSH tunnels with keys which fail are now correctly restarted, interacting with the GUI as necessary - GUI interaction now performed on the main thread for increased stability
Diffstat (limited to 'Source/TunnelPassphraseRequester.m')
-rw-r--r--Source/TunnelPassphraseRequester.m19
1 files changed, 18 insertions, 1 deletions
diff --git a/Source/TunnelPassphraseRequester.m b/Source/TunnelPassphraseRequester.m
index 31c4b54a..11665449 100644
--- a/Source/TunnelPassphraseRequester.m
+++ b/Source/TunnelPassphraseRequester.m
@@ -23,6 +23,7 @@
#import <Cocoa/Cocoa.h>
#import "KeyChain.h"
#import "SPSSHTunnel.h"
+#import "RegexKitLite.h"
int main(int argc, const char *argv[])
{
@@ -120,9 +121,25 @@ int main(int argc, const char *argv[])
}
}
- // Check whether we're being asked for a SSH key passphrase, forward requests to the GUI
+ // Check whether we're being asked for a SSH key passphrase
if (argument && [[argument lowercaseString] rangeOfString:@"enter passphrase for"].location != NSNotFound ) {
NSString *passphrase;
+ NSString *keyName = [argument stringByMatching:@"^\\s*Enter passphrase for key \\'(.*)\\':\\s*$" capture:1L];
+
+ if (keyName) {
+
+ // Check whether the passphrase is in the keychain, using standard OS X sshagent name and account
+ KeyChain *keychain = [[KeyChain alloc] init];
+ if ([keychain passwordExistsForName:@"SSH" account:keyName]) {
+ printf("%s\n", [[keychain getPasswordForName:@"SSH" account:keyName] UTF8String]);
+ [keychain release];
+ [pool release];
+ return 0;
+ }
+ [keychain release];
+ }
+
+ // Not found in the keychain - we need to ask the GUI.
if (!verificationHash) {
NSLog(@"SSH Tunnel: key passphrase authentication required but insufficient details supplied to connect to GUI");