aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SequelProTunnelAssistant.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2011-01-27 20:38:23 +0000
committerstuconnolly <stuart02@gmail.com>2011-01-27 20:38:23 +0000
commit8db2f78294982e89fce5a162d92b2be6d9291aa1 (patch)
treeb8dc7736f4af896aa3ed3fa9a96d1f3c4bfd0e59 /Source/SequelProTunnelAssistant.m
parentfa7cff57548edc51420693e6909fe2adb3c18951 (diff)
parent7cc062247ff23496dd0390cf07b5d45d6bc49777 (diff)
downloadsequelpro-8db2f78294982e89fce5a162d92b2be6d9291aa1.tar.gz
sequelpro-8db2f78294982e89fce5a162d92b2be6d9291aa1.tar.bz2
sequelpro-8db2f78294982e89fce5a162d92b2be6d9291aa1.zip
Bring outline view branch up to date with trunk (r3056:r3162).
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];
}
}