From 7f8a32e9d118c6f7d84d988a6f2462a8a2c9b085 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Wed, 3 Jun 2009 00:05:36 +0000 Subject: - Fix SSH tunnels on PPC - Improve general SSH tunnel stability and automatic reconnection on failure - Improve handling of failed SSH tunnel passwords --- Source/CMMCPConnection.m | 2 ++ Source/SPSSHTunnel.m | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'Source') diff --git a/Source/CMMCPConnection.m b/Source/CMMCPConnection.m index b7fc230f..c5e14567 100644 --- a/Source/CMMCPConnection.m +++ b/Source/CMMCPConnection.m @@ -444,7 +444,9 @@ static void forcePingTimeout(int signalNumber); // Restart the tunnel if it dies if (mConnected && newState == SPSSH_STATE_IDLE && currentSSHTunnelState == SPSSH_STATE_CONNECTED) { currentSSHTunnelState = newState; + [connectionTunnel setConnectionStateChangeSelector:nil delegate:nil]; [self reconnect]; + return; } currentSSHTunnelState = newState; diff --git a/Source/SPSSHTunnel.m b/Source/SPSSHTunnel.m index 20c6b112..433ccad4 100644 --- a/Source/SPSSHTunnel.m +++ b/Source/SPSSHTunnel.m @@ -203,9 +203,10 @@ // [taskArguments addObject:@"-C"]; // TODO: compression? [taskArguments addObject:@"-o ExitOnForwardFailure=yes"]; [taskArguments addObject:[NSString stringWithFormat:@"-o ConnectTimeout=%i", connectionTimeout]]; + [taskArguments addObject:@"-o NumberOfPasswordPrompts=1"]; if (useKeepAlive && keepAliveInterval) { [taskArguments addObject:@"-o TCPKeepAlive=no"]; - [taskArguments addObject:[NSString stringWithFormat:@"-o ServerAliveInterval=%i", ceil(keepAliveInterval)]]; + [taskArguments addObject:[NSString stringWithFormat:@"-o ServerAliveInterval=%i", (int)ceil(keepAliveInterval)]]; [taskArguments addObject:@"-o ServerAliveCountMax=1"]; } [taskArguments addObject:[NSString stringWithFormat:@"-p %i", sshPort]]; @@ -319,6 +320,13 @@ lastError = [[NSString alloc] initWithString:NSLocalizedString(@"The SSH Tunnel was closed 'by the remote host'. This may indicate a networking issue or a network timeout.", @"SSH tunnel was closed by remote host message")]; if (delegate) [delegate performSelectorOnMainThread:stateChangeSelector withObject:self waitUntilDone:NO]; } + if ([message rangeOfString:@"Permission denied (" ].location != NSNotFound) { + connectionState = SPSSH_STATE_IDLE; + [task terminate]; + if (lastError) [lastError release]; + lastError = [[NSString alloc] initWithString:NSLocalizedString(@"The SSH Tunnel could not authenticate with the remote host. Please check your password and ensure you still have access.", @"SSH tunnel authentication failed message")]; + if (delegate) [delegate performSelectorOnMainThread:stateChangeSelector withObject:self waitUntilDone:NO]; + } if ([message rangeOfString:@"Operation timed out" ].location != NSNotFound) { connectionState = SPSSH_STATE_IDLE; [task terminate]; -- cgit v1.2.3