aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/SPConstants.h1
-rw-r--r--Source/SPConstants.m1
-rw-r--r--Source/SPNetworkPreferencePane.h14
-rw-r--r--Source/SPNetworkPreferencePane.m66
-rw-r--r--Source/SPSSHTunnel.m34
5 files changed, 108 insertions, 8 deletions
diff --git a/Source/SPConstants.h b/Source/SPConstants.h
index 728d213a..38e05cc5 100644
--- a/Source/SPConstants.h
+++ b/Source/SPConstants.h
@@ -428,6 +428,7 @@ extern NSString *SPHiddenKeyFileVisibilityKey;
extern NSString *SPSelectionDetailTypeIndexed;
extern NSString *SPSelectionDetailTypePrimaryKeyed;
extern NSString *SPSSHEnableMuxingPreference;
+extern NSString *SPSSHClientPath;
// URLs
extern NSString *SPDonationsURL;
diff --git a/Source/SPConstants.m b/Source/SPConstants.m
index 292acb3c..fad42bc6 100644
--- a/Source/SPConstants.m
+++ b/Source/SPConstants.m
@@ -229,6 +229,7 @@ NSString *SPHiddenKeyFileVisibilityKey = @"KeySelectionHiddenFilesVisi
NSString *SPSelectionDetailTypeIndexed = @"SelectionDetailTypeNSIndexSet";
NSString *SPSelectionDetailTypePrimaryKeyed = @"SelectionDetailTypePrimaryKeyedDetails";
NSString *SPSSHEnableMuxingPreference = @"SSHMultiplexingEnabled";
+NSString *SPSSHClientPath = @"SSHClientPath";
// URLs
NSString *SPDonationsURL = @"http://www.sequelpro.com/donate/";
diff --git a/Source/SPNetworkPreferencePane.h b/Source/SPNetworkPreferencePane.h
index dc99b3e2..37408c32 100644
--- a/Source/SPNetworkPreferencePane.h
+++ b/Source/SPNetworkPreferencePane.h
@@ -37,6 +37,16 @@
*
* Network preference pane controller.
*/
-@interface SPNetworkPreferencePane : SPPreferencePane <SPPreferencePaneProtocol>
-
+@interface SPNetworkPreferencePane : SPPreferencePane <SPPreferencePaneProtocol>
+{
+ IBOutlet NSView *sshClientPickerView;
+ IBOutlet NSTextField *sshClientPath;
+ IBOutlet NSView *hiddenFileView;
+
+@private
+ NSAlert *_currentAlert;
+ NSOpenPanel *_currentFilePanel;
+}
+- (IBAction)pickSSHClientViaFileBrowser:(id)sender;
+- (IBAction)pickSSHClient:(id)sender;
@end
diff --git a/Source/SPNetworkPreferencePane.m b/Source/SPNetworkPreferencePane.m
index d3e2f52f..376ba39f 100644
--- a/Source/SPNetworkPreferencePane.m
+++ b/Source/SPNetworkPreferencePane.m
@@ -30,6 +30,10 @@
#import "SPNetworkPreferencePane.h"
+@interface SPNetworkPreferencePane (Private)
+- (void)updateHiddenFiles;
+@end
+
@implementation SPNetworkPreferencePane
#pragma mark -
@@ -65,4 +69,66 @@
return NO;
}
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
+{
+ if([SPHiddenKeyFileVisibilityKey isEqualTo:keyPath]) {
+ [self updateHiddenFiles];
+ }
+}
+
+- (void)updateHiddenFiles
+{
+ [_currentFilePanel setShowsHiddenFiles:[prefs boolForKey:SPHiddenKeyFileVisibilityKey]];
+}
+
+- (IBAction)pickSSHClientViaFileBrowser:(id)sender
+{
+ _currentFilePanel = [NSOpenPanel openPanel];
+ [_currentFilePanel setCanChooseFiles:YES];
+ [_currentFilePanel setCanChooseDirectories:NO];
+ [_currentFilePanel setAllowsMultipleSelection:NO];
+ [_currentFilePanel setAccessoryView:hiddenFileView];
+ [self updateHiddenFiles];
+
+ [prefs addObserver:self
+ forKeyPath:SPHiddenKeyFileVisibilityKey
+ options:NSKeyValueObservingOptionNew
+ context:NULL];
+
+ [_currentFilePanel beginSheetModalForWindow:[_currentAlert window] completionHandler:^(NSInteger result) {
+ if(result == NSFileHandlingPanelOKButton) [sshClientPath setStringValue:[[_currentFilePanel URL] path]];
+
+ [prefs removeObserver:self forKeyPath:SPHiddenKeyFileVisibilityKey];
+
+ _currentFilePanel = nil;
+ }];
+}
+
+- (IBAction)pickSSHClient:(id)sender
+{
+ //take value from user defaults
+ NSString *oldPath = [prefs stringForKey:SPSSHClientPath];
+ if([oldPath length]) [sshClientPath setStringValue:oldPath];
+
+ // set up dialog
+ _currentAlert = [[NSAlert alloc] init]; //needs to be ivar so we can attach the OpenPanel later
+ [_currentAlert setAccessoryView:sshClientPickerView];
+ [_currentAlert setAlertStyle:NSWarningAlertStyle];
+ [_currentAlert setMessageText:NSLocalizedString(@"Unsupported configuration!",@"Preferences : Network : Custom SSH client : warning dialog title")];
+ [_currentAlert setInformativeText:NSLocalizedString(@"Sequel Pro only supports and is tested with the default OpenSSH client versions included with Mac OS X. Using different clients might cause connection issues, security risks or not work at all.\n\nPlease be aware, that we cannot provide support for such configurations.",@"Preferences : Network : Custom SSH client : warning dialog message")];
+ [_currentAlert addButtonWithTitle:NSLocalizedString(@"OK",@"Preferences : Network : Custom SSH client : warning dialog : accept button")];
+ [_currentAlert addButtonWithTitle:NSLocalizedString(@"Cancel",@"Preferences : Network : Custom SSH client : warning dialog : cancel button")];
+
+ if([_currentAlert runModal] == NSAlertFirstButtonReturn) {
+ //store new value to user defaults
+ NSString *newPath = [sshClientPath stringValue];
+ if(![newPath length])
+ [prefs removeObjectForKey:SPSSHClientPath];
+ else
+ [prefs setObject:newPath forKey:SPSSHClientPath];
+ }
+
+ SPClear(_currentAlert);
+}
+
@end
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);