Changeset 118
- Timestamp:
- 08/22/07 17:01:09 (1 year ago)
- Files:
-
- trunk/AgentController.m (modified) (2 diffs)
- trunk/Controller.h (modified) (2 diffs)
- trunk/Controller.m (modified) (3 diffs)
- trunk/Libs/SSHAgent.m (modified) (2 diffs)
- trunk/Libs/SSHKeychain.m (modified) (3 diffs)
- trunk/Libs/SSHToken.h (added)
- trunk/Libs/SSHToken.m (added)
- trunk/Libs/SSHTunnel.m (modified) (2 diffs)
- trunk/PassphraseRequester.m (modified) (4 diffs)
- trunk/SSHKeychain.xcodeproj/project.pbxproj (modified) (8 diffs)
- trunk/TokenController.h (added)
- trunk/TokenController.m (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/AgentController.m
r83 r118 1 1 #import "AgentController.h" 2 #import "TokenController.h" 2 3 3 4 #include <unistd.h> … … 564 565 [theTool setEnvironmentVariable:@"SSH_AUTH_SOCK" withValue:[agent socketPath]]; 565 566 566 if([theTool launchAndWait] == NO) 567 /* Set the token and run. */ 568 if(![[TokenController sharedController] generateNewTokenForTool:theTool] || ![theTool launchAndWait]) 567 569 { 568 570 [self warningPanelWithTitle:local(@"AddSingleKeyToAgent") andMessage:local(@"AddSingleKeyToAgentFailed") trunk/Controller.h
r42 r118 4 4 @protocol UI 5 5 6 - (NSString *)askPassphrase:(NSString *)question with Interaction:(BOOL)interaction;6 - (NSString *)askPassphrase:(NSString *)question withToken:(NSString *)token andInteraction:(BOOL)interaction; 7 7 - (void)warningPanelWithTitle:(NSString *)title andMessage:(NSString *)message; 8 8 - (NSData *)statusbarMenu; … … 43 43 - (IBAction)toggleAppleKeychainLock:(id)sender; 44 44 45 - (NSString *)askPassphrase:(NSString *)question with Interaction:(BOOL)interaction;45 - (NSString *)askPassphrase:(NSString *)question withToken:(NSString *)token andInteraction:(BOOL)interaction; 46 46 47 47 - (IBAction)showAboutPanel:(id)sender; trunk/Controller.m
r99 r118 7 7 #import "PreferenceController.h" 8 8 #import "UpdateController.h" 9 #import "TokenController.h" 9 10 10 11 #import "Libs/SSHAgent.h" … … 346 347 } 347 348 348 - (NSString *)askPassphrase:(NSString *)question with Interaction:(BOOL)interaction349 - (NSString *)askPassphrase:(NSString *)question withToken:(NSString *)token andInteraction:(BOOL)interaction 349 350 { 350 351 char *serviceName; … … 368 369 369 370 ProcessSerialNumber focusSerialNumber; 371 372 // Check if the token is valid. 373 if(![[TokenController sharedController] checkToken:token]) 374 { 375 return nil; 376 } 377 370 378 GetFrontProcess(&focusSerialNumber); 371 379 trunk/Libs/SSHAgent.m
r93 r118 4 4 #import "SSHTool.h" 5 5 #import "PreferenceController.h" 6 #import "TokenController.h" 6 7 7 8 #include <string.h> … … 612 613 [theTool setEnvironmentVariable:@"SSH_AUTH_SOCK" withValue:[self agentSocketPath]]; 613 614 615 /* Set the token. */ 616 if([[TokenController sharedController] generateNewTokenForTool:theTool] == NO) 617 { 618 return nil; 619 } 620 614 621 /* Launch the tool and retrieve stdout. */ 615 622 NSString *theOutput = [theTool launchForStandardOutput]; trunk/Libs/SSHKeychain.m
r92 r118 1 1 #import "SSHKeychain.h" 2 2 #import "PreferenceController.h" 3 #import "TokenController.h" 3 4 4 5 #import "SSHKey.h" … … 214 215 NSEnumerator *e = [[self arrayOfPaths] objectEnumerator]; 215 216 NSString *path; 217 216 218 while (path = [e nextObject]) 217 219 { … … 224 226 225 227 [self setAddingKeys:YES]; 226 227 SSHTool *theTool = [SSHTool toolWithName:@"ssh-add"]; 228 [theTool setArguments:paths]; 229 230 /* Set the SSH_ASKPASS + DISPLAY environment variables, so the tool can ask for a passphrase. */ 231 [theTool setEnvironmentVariable:@"SSH_ASKPASS" withValue: 232 [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"PassphraseRequester"]]; 233 234 [theTool setEnvironmentVariable:@"DISPLAY" withValue:@":0"]; 235 236 /* If we want user interaction, we set the environment variable so PassphraseRequester knows this. */ 237 if (interaction) 238 [theTool setEnvironmentVariable:@"INTERACTION" withValue:@"1"]; 239 240 /* Set the SSH_AUTH_SOCK environment variable so the tool can talk to the real agent. */ 241 [theTool setEnvironmentVariable:@"SSH_AUTH_SOCK" withValue:agentSocketPath]; 242 243 if (![theTool launchAndWait]) 228 229 // Add all keys separately since they need different tokens 230 e = [paths objectEnumerator]; 231 while (path = [e nextObject]) 244 232 { 245 [self setAddingKeys:NO]; 246 return NO; 233 SSHTool *theTool = [SSHTool toolWithName:@"ssh-add"]; 234 [theTool setArgument:path]; 235 236 /* Set the SSH_ASKPASS + DISPLAY environment variables, so the tool can ask for a passphrase. */ 237 [theTool setEnvironmentVariable:@"SSH_ASKPASS" withValue: 238 [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"PassphraseRequester"]]; 239 240 [theTool setEnvironmentVariable:@"DISPLAY" withValue:@":0"]; 241 242 /* If we want user interaction, we set the environment variable so PassphraseRequester knows this. */ 243 if (interaction) 244 [theTool setEnvironmentVariable:@"INTERACTION" withValue:@"1"]; 245 246 /* Set the SSH_AUTH_SOCK environment variable so the tool can talk to the real agent. */ 247 [theTool setEnvironmentVariable:@"SSH_AUTH_SOCK" withValue:agentSocketPath]; 248 249 /* Set the token and run. */ 250 if(![[TokenController sharedController] generateNewTokenForTool:theTool] || ![theTool launchAndWait]) 251 { 252 [self setAddingKeys:NO]; 253 return NO; 254 } 247 255 } 248 256 trunk/Libs/SSHTunnel.m
r99 r118 2 2 3 3 #import "PreferenceController.h" 4 #import "TokenController.h" 4 5 5 6 #ifndef NSAppKitVersionNumber10_3 … … 253 254 254 255 [[tunnel task] setStandardOutput:thePipe]; 256 257 // Generate a token. 258 if (![[TokenController sharedController] generateNewTokenForTool:tunnel]) 259 { 260 return NO; 261 } 255 262 256 263 /* Launch ssh. */ trunk/PassphraseRequester.m
r78 r118 8 8 char *interaction; 9 9 NSString *passphrase; 10 NSString *sshkeychainToken = nil; 10 11 11 12 if(argc == 2) … … 21 22 exit(1); 22 23 } 23 24 25 if(getenv("SSHKeychainToken")) 26 { 27 sshkeychainToken = [NSString stringWithCString:getenv("SSHKeychainToken")]; 28 } 29 24 30 [UI setProtocolForProxy:@protocol(UI)]; 25 31 … … 28 34 if((interaction) && (strcmp(interaction, "1") == 0)) 29 35 { 30 passphrase = [UI askPassphrase:[[procinfo arguments] objectAtIndex:1] with Interaction:YES];36 passphrase = [UI askPassphrase:[[procinfo arguments] objectAtIndex:1] withToken:sshkeychainToken andInteraction:YES]; 31 37 32 38 if(passphrase == nil) … … 39 45 else 40 46 { 41 passphrase = [UI askPassphrase:[[procinfo arguments] objectAtIndex:1] with Interaction:NO];47 passphrase = [UI askPassphrase:[[procinfo arguments] objectAtIndex:1] withToken:sshkeychainToken andInteraction:NO]; 42 48 43 49 if(passphrase == nil) trunk/SSHKeychain.xcodeproj/project.pbxproj
r99 r118 35 35 CC4FC46206AD4A0C00B59C21 /* KeysView.h in Headers */ = {isa = PBXBuildFile; fileRef = CC4FC46006AD4A0C00B59C21 /* KeysView.h */; }; 36 36 CC4FC46306AD4A0C00B59C21 /* KeysView.m in Sources */ = {isa = PBXBuildFile; fileRef = CC4FC46106AD4A0C00B59C21 /* KeysView.m */; }; 37 CC51B4110C7C5EE8005D33DB /* TokenController.h in Headers */ = {isa = PBXBuildFile; fileRef = CC51B40F0C7C5EE8005D33DB /* TokenController.h */; }; 38 CC51B4120C7C5EE8005D33DB /* TokenController.m in Sources */ = {isa = PBXBuildFile; fileRef = CC51B4100C7C5EE8005D33DB /* TokenController.m */; }; 37 39 CC586C5106C3D56A00D73261 /* SecurityView.h in Headers */ = {isa = PBXBuildFile; fileRef = CC586C4F06C3D56A00D73261 /* SecurityView.h */; }; 38 40 CC586C5206C3D56A00D73261 /* SecurityView.m in Sources */ = {isa = PBXBuildFile; fileRef = CC586C5006C3D56A00D73261 /* SecurityView.m */; }; … … 74 76 CCE66DE406B15AEA002A5BEE /* TunnelsView.h in Headers */ = {isa = PBXBuildFile; fileRef = CCE66DE206B15AEA002A5BEE /* TunnelsView.h */; }; 75 77 CCE66DE506B15AEA002A5BEE /* TunnelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = CCE66DE306B15AEA002A5BEE /* TunnelsView.m */; }; 78 CCFAAB470C7C870900AD9093 /* SSHToken.h in Headers */ = {isa = PBXBuildFile; fileRef = CCFAAB450C7C870900AD9093 /* SSHToken.h */; }; 79 CCFAAB480C7C870900AD9093 /* SSHToken.m in Sources */ = {isa = PBXBuildFile; fileRef = CCFAAB460C7C870900AD9093 /* SSHToken.m */; }; 76 80 /* End PBXBuildFile section */ 77 81 … … 143 147 CC4FC46006AD4A0C00B59C21 /* KeysView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = KeysView.h; path = PreferenceViews/KeysView.h; sourceTree = "<group>"; usesTabs = 1; }; 144 148 CC4FC46106AD4A0C00B59C21 /* KeysView.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = KeysView.m; path = PreferenceViews/KeysView.m; sourceTree = "<group>"; usesTabs = 1; }; 149 CC51B40F0C7C5EE8005D33DB /* TokenController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TokenController.h; sourceTree = "<group>"; }; 150 CC51B4100C7C5EE8005D33DB /* TokenController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TokenController.m; sourceTree = "<group>"; }; 145 151 CC586C4F06C3D56A00D73261 /* SecurityView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = SecurityView.h; path = PreferenceViews/SecurityView.h; sourceTree = "<group>"; usesTabs = 1; }; 146 152 CC586C5006C3D56A00D73261 /* SecurityView.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = SecurityView.m; path = PreferenceViews/SecurityView.m; sourceTree = "<group>"; usesTabs = 1; }; … … 201 207 CCE66DE206B15AEA002A5BEE /* TunnelsView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = TunnelsView.h; path = PreferenceViews/TunnelsView.h; sourceTree = "<group>"; usesTabs = 1; }; 202 208 CCE66DE306B15AEA002A5BEE /* TunnelsView.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = TunnelsView.m; path = PreferenceViews/TunnelsView.m; sourceTree = "<group>"; usesTabs = 1; }; 209 CCFAAB450C7C870900AD9093 /* SSHToken.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = SSHToken.h; path = Libs/SSHToken.h; sourceTree = "<group>"; }; 210 CCFAAB460C7C870900AD9093 /* SSHToken.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = SSHToken.m; path = Libs/SSHToken.m; sourceTree = "<group>"; }; 203 211 /* End PBXFileReference section */ 204 212 … … 235 243 CCCDD4A506A576CF00B68ED1 /* Controller.h */, 236 244 CCCDD4A606A576CF00B68ED1 /* Controller.m */, 245 CC51B40F0C7C5EE8005D33DB /* TokenController.h */, 246 CC51B4100C7C5EE8005D33DB /* TokenController.m */, 237 247 CC08A64506A876B300C578A3 /* PreferenceController.h */, 238 248 CC6C191307421C8700CB0A18 /* UpdateController.h */, … … 362 372 isa = PBXGroup; 363 373 children = ( 374 CCFAAB450C7C870900AD9093 /* SSHToken.h */, 375 CCFAAB460C7C870900AD9093 /* SSHToken.m */, 364 376 CC40C2D106A6813E00AE58DD /* SSHTunnel.h */, 365 377 CCC9E54306A6802000422E9E /* SSHTunnel.m */, … … 403 415 0A7F549007676EB500E1C1E4 /* Utilities.h in Headers */, 404 416 0A7F555007677DCC00E1C1E4 /* NSMenu_Additions.h in Headers */, 417 CC51B4110C7C5EE8005D33DB /* TokenController.h in Headers */, 418 CCFAAB470C7C870900AD9093 /* SSHToken.h in Headers */, 405 419 ); 406 420 runOnlyForDeploymentPostprocessing = 0; … … 581 595 0A7F549107676EB500E1C1E4 /* Utilities.m in Sources */, 582 596 0A7F555107677DCC00E1C1E4 /* NSMenu_Additions.m in Sources */, 597 CC51B4120C7C5EE8005D33DB /* TokenController.m in Sources */, 598 CCFAAB480C7C870900AD9093 /* SSHToken.m in Sources */, 583 599 ); 584 600 runOnlyForDeploymentPostprocessing = 0;
