aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SequelProTunnelAssistant.m
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 /Source/SequelProTunnelAssistant.m
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
Diffstat (limited to 'Source/SequelProTunnelAssistant.m')
-rw-r--r--Source/SequelProTunnelAssistant.m31
1 files changed, 15 insertions, 16 deletions
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];
}
}