From 2031d4b310b2742ea61ad6483d7e6dfeaadb44cc Mon Sep 17 00:00:00 2001 From: Bibiko Date: Thu, 24 Jun 2010 21:46:02 +0000 Subject: =?UTF-8?q?=E2=80=A2=20fixed=20issue=20for=20saving=20spf=20files?= =?UTF-8?q?=20of=20ssh=20connections=20-=20retrieve=20the=20ssh=20password?= =?UTF-8?q?=20from=20keychain=20=E2=80=A2=20allow=20to=20save=20empty=20pa?= =?UTF-8?q?sswords=20in=20spf=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPDatabaseDocument.m | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index 53a18913..c54a7a8b 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -3222,11 +3222,27 @@ [connection setObject:aString forKey:@"type"]; if([[spfDocData_temp objectForKey:@"save_password"] boolValue]) { + NSString *pw = [self keychainPasswordForConnection:nil]; if(![pw length]) pw = [connectionController password]; - if (pw) [connection setObject:pw forKey:@"password"]; - if([connectionController type] == SPSSHTunnelConnection && [connectionController sshPassword]) - [connection setObject:[connectionController sshPassword] forKey:@"ssh_password"]; + if (pw) + [connection setObject:pw forKey:@"password"]; + else + [connection setObject:@"" forKey:@"password"]; + + if([connectionController type] == SPSSHTunnelConnection) { + SPKeychain *keychain = [[SPKeychain alloc] init]; + NSString *connectionSSHKeychainItemName = [[keychain nameForSSHForFavoriteName:[connectionController name] id:[self keyChainID]] retain]; + NSString *connectionSSHKeychainItemAccount = [[keychain accountForSSHUser:[connectionController sshUser] sshHost:[connectionController sshHost]] retain]; + NSString *sshpw = [keychain getPasswordForName:connectionSSHKeychainItemName account:connectionSSHKeychainItemAccount]; + if (sshpw && [sshpw length]) + [connection setObject:sshpw forKey:@"ssh_password"]; + else + [connection setObject:@"" forKey:@"ssh_password"]; + if(connectionSSHKeychainItemName) [connectionSSHKeychainItemName release]; + if(connectionSSHKeychainItemAccount) [connectionSSHKeychainItemAccount release]; + [keychain release]; + } } if([connectionController port] && [[connectionController port] length]) -- cgit v1.2.3