aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TunnelPassphraseRequester.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-06-04 01:44:16 +0000
committerrowanbeentje <rowan@beent.je>2009-06-04 01:44:16 +0000
commit31123c9ff149908120a5bca94e76f5023c0b7e1e (patch)
treef76933e4c19d63cd17f160919731fbb5c9162b75 /Source/TunnelPassphraseRequester.m
parentfc748400d92a0b7874a19eba3fa573cdf1415ee5 (diff)
downloadsequelpro-31123c9ff149908120a5bca94e76f5023c0b7e1e.tar.gz
sequelpro-31123c9ff149908120a5bca94e76f5023c0b7e1e.tar.bz2
sequelpro-31123c9ff149908120a5bca94e76f5023c0b7e1e.zip
Further SSH tunnel improvements, password handling improvements, and minor bugfixes:
- SSH tunnels can now correctly show dialogs for ssh queries, eg host key mismatches - SSH tunnels are now correctly closed by the document for connection failures - Keychain password item name and account generation has been moved to within the keychain class, to centralise generation for consistency - Keychain item names and accounts now correctly deal with nil values, allowing more keychain items to be read - "Add to favorites" button and menu item now correctly store passwords and SSH tunnel settings - Duplicating favorites in preferences now selects the newly created favorite instead of deselecting everything - Fixes an occasional crasher sometimes encountered in keychain usage
Diffstat (limited to 'Source/TunnelPassphraseRequester.m')
-rw-r--r--Source/TunnelPassphraseRequester.m27
1 files changed, 25 insertions, 2 deletions
diff --git a/Source/TunnelPassphraseRequester.m b/Source/TunnelPassphraseRequester.m
index a39c4fd1..4391e3e7 100644
--- a/Source/TunnelPassphraseRequester.m
+++ b/Source/TunnelPassphraseRequester.m
@@ -28,12 +28,37 @@ int main(int argc, const char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSDictionary *environment = [[NSProcessInfo processInfo] environment];
+ NSString *argument = nil;
+ SPSSHTunnel *sequelProTunnel;
+ NSString *connectionName = [environment objectForKey:@"SP_CONNECTION_NAME"];
if (![environment objectForKey:@"SP_PASSWORD_METHOD"]) {
[pool release];
return 1;
}
+ if (argc > 1) {
+ argument = [[NSString alloc] initWithCString:argv[1] encoding:NSUTF8StringEncoding];
+ }
+
+ // Check if we're being asked a question and respond if so
+ if (argument && [argument rangeOfString:@" (yes/no)?"].location != NSNotFound) {
+ sequelProTunnel = (SPSSHTunnel *)[NSConnection rootProxyForConnectionWithRegisteredName:connectionName host:nil];
+ if (!sequelProTunnel) {
+ NSLog(@"SSH Tunnel: unable to connect to Sequel Pro to show SSH question");
+ [pool release];
+ return 1;
+ }
+ BOOL response = [sequelProTunnel getResponseForQuestion:argument];
+ if (response) {
+ printf("yes\n");
+ } else {
+ printf("no\n");
+ }
+ [pool release];
+ return 0;
+ }
+
// If the password method is set to use the keychain, use the supplied keychain name to
// request the password
if ([[environment objectForKey:@"SP_PASSWORD_METHOD"] intValue] == SPSSH_PASSWORD_USES_KEYCHAIN) {
@@ -61,9 +86,7 @@ int main(int argc, const char *argv[])
// If the password method is set to request the password from the tunnel instance, do so.
if ([[environment objectForKey:@"SP_PASSWORD_METHOD"] intValue] == SPSSH_PASSWORD_ASKS_UI) {
- SPSSHTunnel *sequelProTunnel;
NSString *password;
- NSString *connectionName = [environment objectForKey:@"SP_CONNECTION_NAME"];
NSString *verificationHash = [environment objectForKey:@"SP_CONNECTION_VERIFY_HASH"];
if (!connectionName || !verificationHash) {