aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2011-01-04 23:04:07 +0000
committerrowanbeentje <rowan@beent.je>2011-01-04 23:04:07 +0000
commitdf7720cd97dcbeeb1ba3a74c2bc2dae2bf4276cd (patch)
treec674e3f2f2c6d80928718327f8e2137dbb70a92a
parent12c773ff7f06a240e66a264b23261f0436e56175 (diff)
downloadsequelpro-df7720cd97dcbeeb1ba3a74c2bc2dae2bf4276cd.tar.gz
sequelpro-df7720cd97dcbeeb1ba3a74c2bc2dae2bf4276cd.tar.bz2
sequelpro-df7720cd97dcbeeb1ba3a74c2bc2dae2bf4276cd.zip
- Fix SSH tunnels for connections with non-Latin characters in their name
- If SSH tunnel password lookups fail, fall back to asking the user for the password - Don't reset keychain IDs across documents if not set; this fixes problems re-saving .spfs or duplicating chains of tabs
-rw-r--r--Source/SPConnectionController.m3
-rw-r--r--Source/SPSSHTunnel.m4
-rw-r--r--Source/SequelProTunnelAssistant.m31
3 files changed, 17 insertions, 21 deletions
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m
index a4adcf92..316d5258 100644
--- a/Source/SPConnectionController.m
+++ b/Source/SPConnectionController.m
@@ -520,9 +520,6 @@
if ([self valueForKeyPath:@"selectedFavorite.id"]) {
[tableDocument setKeychainID:[[self valueForKeyPath:@"selectedFavorite.id"] stringValue]];
}
- else {
- [tableDocument setKeychainID:@""];
- }
// Pass the connection to the table document, allowing it to set
// up the other classes and the rest of the interface.
diff --git a/Source/SPSSHTunnel.m b/Source/SPSSHTunnel.m
index 76508304..0d4b5993 100644
--- a/Source/SPSSHTunnel.m
+++ b/Source/SPSSHTunnel.m
@@ -328,8 +328,8 @@
[taskEnvironment setObject:tunnelConnectionVerifyHash forKey:@"SP_CONNECTION_VERIFY_HASH"];
if (passwordInKeychain) {
[taskEnvironment setObject:[[NSNumber numberWithInteger:SPSSHPasswordUsesKeychain] stringValue] forKey:@"SP_PASSWORD_METHOD"];
- [taskEnvironment setObject:keychainName forKey:@"SP_KEYCHAIN_ITEM_NAME"];
- [taskEnvironment setObject:keychainAccount forKey:@"SP_KEYCHAIN_ITEM_ACCOUNT"];
+ [taskEnvironment setObject:[keychainName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:@"SP_KEYCHAIN_ITEM_NAME"];
+ [taskEnvironment setObject:[keychainAccount stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:@"SP_KEYCHAIN_ITEM_ACCOUNT"];
} else if (password) {
[taskEnvironment setObject:[[NSNumber numberWithInteger:SPSSHPasswordAsksUI] stringValue] forKey:@"SP_PASSWORD_METHOD"];
} else {
diff --git a/Source/SequelProTunnelAssistant.m b/Source/SequelProTunnelAssistant.m
index bbf21a3c..eb16ef5e 100644
--- a/Source/SequelProTunnelAssistant.m
+++ b/Source/SequelProTunnelAssistant.m
@@ -72,8 +72,8 @@ int main(int argc, const char *argv[])
// request the password
if ([[environment objectForKey:@"SP_PASSWORD_METHOD"] integerValue] == SPSSHPasswordUsesKeychain) {
SPKeychain *keychain;
- NSString *keychainName = [environment objectForKey:@"SP_KEYCHAIN_ITEM_NAME"];
- NSString *keychainAccount = [environment objectForKey:@"SP_KEYCHAIN_ITEM_ACCOUNT"];
+ NSString *keychainName = [[environment objectForKey:@"SP_KEYCHAIN_ITEM_NAME"] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+ NSString *keychainAccount = [[environment objectForKey:@"SP_KEYCHAIN_ITEM_ACCOUNT"] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
if (!keychainName || !keychainAccount) {
NSLog(@"SSH Tunnel: keychain authentication specified but insufficient internal details supplied");
@@ -82,17 +82,16 @@ int main(int argc, const char *argv[])
}
keychain = [[SPKeychain alloc] init];
- if (![keychain passwordExistsForName:keychainName account:keychainAccount]) {
- NSLog(@"SSH Tunnel: specified keychain password not found");
+ if ([keychain passwordExistsForName:keychainName account:keychainAccount]) {
+ printf("%s\n", [[keychain getPasswordForName:keychainName account:keychainAccount] UTF8String]);
[keychain release];
[pool release];
- return 1;
+ return 0;
}
- printf("%s\n", [[keychain getPasswordForName:keychainName account:keychainAccount] UTF8String]);
- [keychain release];
- [pool release];
- return 0;
+ // If retrieving the password failed, log an error and fall back to requesting from the GUI
+ NSLog(@"SSH Tunnel: specified keychain password not found");
+ argument = [NSString stringWithFormat:NSLocalizedString(@"The SSH password could not be loaded from the keychain; please enter the SSH password for %@:", @"Prompt for SSH password when keychain fetch failed"), connectionName];
}
// If the password method is set to request the password from the tunnel instance, do so.
@@ -113,15 +112,15 @@ int main(int argc, const char *argv[])
}
password = [sequelProTunnel getPasswordWithVerificationHash:verificationHash];
- if (!password) {
- NSLog(@"SSH Tunnel: unable to successfully request password from Sequel Pro for internal authentication");
+ if (password) {
+ printf("%s\n", [password UTF8String]);
[pool release];
- return 1;
+ return 0;
}
-
- printf("%s\n", [password UTF8String]);
- [pool release];
- return 0;
+
+ // If retrieving the password failed, log an error and fall back to requesting from the GUI
+ NSLog(@"SSH Tunnel: unable to successfully request password from Sequel Pro for internal authentication");
+ argument = [NSString stringWithFormat:NSLocalizedString(@"The SSH password could not be loaded; please enter the SSH password for %@:", @"Prompt for SSH password when direct fetch failed"), connectionName];
}
}