Changeset 66
- Timestamp:
- 11/17/05 13:08:41 (3 years ago)
- Files:
-
- trunk/AgentController.m (modified) (1 diff)
- trunk/Controller.m (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/AgentController.m
r41 r66 225 225 [allKeysOnAgentLock unlock]; 226 226 227 SecKeychainGetStatus(nil, &status); 228 229 if((status & 1) && ([agent isRunning])) 230 { 231 [NSThread detachNewThreadSelector:@selector(addKeysToAgentWithoutInteractionInNewThread) 227 [NSThread detachNewThreadSelector:@selector(addKeysToAgentWithoutInteractionInNewThread) 232 228 toTarget:self withObject:self]; 233 }234 229 } 235 230 } trunk/Controller.m
r64 r66 336 336 [appleKeychainUnlockedLock unlock]; 337 337 338 if([[NSUserDefaults standardUserDefaults] integerForKey:DisplayString] != 1) 339 { 340 giveFocusBack = YES; 341 GetFrontProcess(&focusSerialNumber); 342 } 338 GetFrontProcess(&focusSerialNumber); 343 339 344 340 [NSApp activateIgnoringOtherApps:YES]; 345 341 SecKeychainUnlock(nil, 0, nil, 0); 346 342 347 if(giveFocusBack) 348 { 349 SetFrontProcess(&focusSerialNumber); 350 giveFocusBack = NO; 351 } 343 SetFrontProcess(&focusSerialNumber); 352 344 } 353 345 } … … 359 351 char *kcPassword; 360 352 UInt32 passwordLength; 361 SecKeychainStatus status; 353 SecKeychainStatus keychainStatus; 354 OSStatus returnStatus; 355 SecKeychainRef keychain; 356 357 CFArrayRef searchList; 362 358 363 359 SInt32 error; … … 366 362 CFStringRef enteredPassphrase; 367 363 368 NSString *passphrase, *firstQuestion , *secondQuestion;364 NSString *passphrase, *firstQuestion; 369 365 NSMutableDictionary *dict; 370 366 BOOL consultKeychain = NO; 371 367 372 368 ProcessSerialNumber focusSerialNumber; 373 BOOL giveFocusBack = NO; 369 370 SecKeychainSetUserInteractionAllowed(TRUE); 371 372 int i; 374 373 375 374 [passphraseIsRequestedLock lock]; … … 385 384 386 385 firstQuestion = @"Enter passphrase for "; 387 secondQuestion = @"'s password: ";388 386 389 387 if([question hasPrefix:firstQuestion]) … … 391 389 consultKeychain = YES; 392 390 accountName = [[[[question substringFromIndex:[firstQuestion length]] 393 componentsSeparatedByString:@": "] objectAtIndex:0] cString];391 componentsSeparatedByString:@": "] objectAtIndex:0] cString]; 394 392 } 393 395 394 else 396 395 { 397 if ([question hasSuffix:secondQuestion])396 if([question hasSuffix:@"'s password: "]) 398 397 { 399 398 consultKeychain = [[NSUserDefaults standardUserDefaults] boolForKey:AddInteractivePasswordString]; 400 399 accountName = [[[question componentsSeparatedByString:@"'s"] objectAtIndex:0] cString]; 401 400 } 401 402 402 else 403 403 { 404 if ([question hasPrefix:@"The authenticity of host"])404 if([question hasPrefix:@"The authenticity of host"]) 405 405 { 406 406 [passphraseIsRequestedLock lock]; 407 407 passphraseIsRequested = NO; 408 408 [passphraseIsRequestedLock unlock]; 409 if (interaction) 409 410 if(interaction) 410 411 { 411 int r = NSRunAlertPanel(local(@"UnknownHostKey"), 412 question, 413 local(@"No"), 414 local(@"Yes"), 415 nil); 412 int r = NSRunAlertPanel(local(@"UnknownHostKey"), question, local(@"No"), local(@"Yes"), nil); 416 413 NSString *response = ( r == NSAlertAlternateReturn) ? @"yes" : @"no"; 417 414 return response; 418 415 } 416 419 417 else 420 418 { … … 429 427 serviceName = "SSHKeychain"; 430 428 431 SecKeychainGetStatus(nil, &status); 432 433 [appleKeychainUnlockedLock lock]; 434 435 if(!appleKeychainUnlocked) 436 { 437 if([[NSUserDefaults standardUserDefaults] integerForKey:DisplayString] != 1) 438 { 439 giveFocusBack = YES; 440 GetFrontProcess(&focusSerialNumber); 429 GetFrontProcess(&focusSerialNumber); 430 431 if(!interaction) 432 { 433 SecKeychainCopySearchList(&searchList); 434 435 for(i=0; i < [(NSArray *)searchList count]; i++) { 436 keychain = (SecKeychainRef)[(NSArray *)searchList objectAtIndex:i]; 437 438 SecKeychainGetStatus(keychain, &keychainStatus); 439 440 if(keychainStatus & 1) { 441 returnStatus = SecKeychainFindGenericPassword(keychain, strlen(serviceName), serviceName, strlen(accountName), accountName, &passwordLength, (void **)&kcPassword, nil); 442 443 if(returnStatus == 0) { 444 break; 445 } 446 } 441 447 } 442 443 [NSApp activateIgnoringOtherApps:YES]; 444 } 445 446 [appleKeychainUnlockedLock unlock]; 447 448 if(!interaction) 449 { 450 SecKeychainSetUserInteractionAllowed(NO); 451 status = SecKeychainFindGenericPassword(nil, strlen(serviceName), serviceName, strlen(accountName), accountName, &passwordLength, (void **)&kcPassword, nil); 452 SecKeychainSetUserInteractionAllowed(YES); 448 449 CFRelease(searchList); 453 450 } 454 451 455 452 else 456 453 { 457 status = SecKeychainFindGenericPassword(nil, strlen(serviceName), serviceName, strlen(accountName), accountName, &passwordLength, (void **)&kcPassword, nil); 458 } 459 460 if(giveFocusBack) 461 { 462 SetFrontProcess(&focusSerialNumber); 463 giveFocusBack = NO; 464 } 454 returnStatus = SecKeychainFindGenericPassword(nil, strlen(serviceName), serviceName, strlen(accountName), accountName, &passwordLength, (void **)&kcPassword, nil); 455 } 456 457 SetFrontProcess(&focusSerialNumber); 465 458 466 459 [passphraseIsRequestedLock lock]; … … 468 461 [passphraseIsRequestedLock unlock]; 469 462 470 if( status == 0)463 if(returnStatus == 0) 471 464 { 472 465 kcPassword[passwordLength] = '\0'; … … 538 531 serviceName = "SSHKeychain"; 539 532 540 [appleKeychainUnlockedLock lock]; 541 542 if(!appleKeychainUnlocked) 543 { 544 if([[NSUserDefaults standardUserDefaults] integerForKey:DisplayString] != 1) 545 { 546 giveFocusBack = YES; 547 GetFrontProcess(&focusSerialNumber); 548 } 549 550 [NSApp activateIgnoringOtherApps:YES]; 551 } 552 553 [appleKeychainUnlockedLock unlock]; 533 GetFrontProcess(&focusSerialNumber); 554 534 555 535 SecKeychainAddGenericPassword(nil, strlen(serviceName), serviceName, strlen(accountName), accountName, [passphrase length], (const void *)[passphrase cString], nil); 556 536 557 if(giveFocusBack) 558 { 559 SetFrontProcess(&focusSerialNumber); 560 giveFocusBack = NO; 561 } 537 SetFrontProcess(&focusSerialNumber); 562 538 } 563 539
