diff options
author | Max <post@wickenrode.com> | 2015-03-17 01:37:41 +0100 |
---|---|---|
committer | Max <post@wickenrode.com> | 2015-03-17 01:37:41 +0100 |
commit | 9f2e5a6b0fafeec8f94dfa00414b0016b12194ba (patch) | |
tree | 385c72795f6d96564a7e2b2f4993ab68a6e10fb6 /Source/SPSSHTunnel.m | |
parent | cdf6fa551b9ccfe9980baa6cb9de368b99ab985e (diff) | |
download | sequelpro-9f2e5a6b0fafeec8f94dfa00414b0016b12194ba.tar.gz sequelpro-9f2e5a6b0fafeec8f94dfa00414b0016b12194ba.tar.bz2 sequelpro-9f2e5a6b0fafeec8f94dfa00414b0016b12194ba.zip |
Allow selection of SSH client binary in prefs
Hey, I was against this, but if you want it... - just don't blame me for what might happen :shipit:
Diffstat (limited to 'Source/SPSSHTunnel.m')
-rw-r--r-- | Source/SPSSHTunnel.m | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/Source/SPSSHTunnel.m b/Source/SPSSHTunnel.m index e09d0ce2..8e9ffb13 100644 --- a/Source/SPSSHTunnel.m +++ b/Source/SPSSHTunnel.m @@ -309,7 +309,20 @@ // Set up the NSTask task = [[NSTask alloc] init]; - [task setLaunchPath: @"/usr/bin/ssh"]; + NSString *launchPath = @"/usr/bin/ssh"; + NSString *userSSHPath = [[NSUserDefaults standardUserDefaults] stringForKey:SPSSHClientPath]; + + if([userSSHPath length]) { + launchPath = userSSHPath; + // And I'm sure we will get issue reports about it anyway! + [debugMessagesLock lock]; + [debugMessages addObject:@"################################################################"]; + [debugMessages addObject:[NSString stringWithFormat:@"# %@",NSLocalizedString(@"Custom SSH binary enabled. Disable in Preferences to rule out incompatibilities!", @"SSH connection : debug header with user-defined ssh binary")]]; + [debugMessages addObject:@"################################################################"]; + [debugMessagesLock unlock]; + } + + [task setLaunchPath:launchPath]; // Prepare to set up the arguments for the task taskArguments = [[NSMutableArray alloc] init]; @@ -413,11 +426,20 @@ object:[standardError fileHandleForReading]]; [[standardError fileHandleForReading] waitForDataInBackgroundAndNotify]; - // Launch and run the tunnel - [task launch]; - - // Listen for output - [task waitUntilExit]; + @try { + // Launch and run the tunnel + [task launch]; //throws for invalid paths, missing +x permission + + // Listen for output + [task waitUntilExit]; + } + @catch (NSException *e) { + connectionState = SPMySQLProxyLaunchFailed; + // Log the exception. Could be improved by showing a dedicated alert instead + [debugMessagesLock lock]; + [debugMessages addObject:[NSString stringWithFormat:@"%@: %@\n", [e name], [e reason]]]; + [debugMessagesLock unlock]; + } // On tunnel close, clean up, ready for re-use if the delegate reconnects. SPClear(task); |