Changeset 118

Show
Ignore:
Timestamp:
08/22/07 17:01:09 (1 year ago)
Author:
bart
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/AgentController.m

    r83 r118  
    11#import "AgentController.h" 
     2#import "TokenController.h" 
    23 
    34#include <unistd.h> 
     
    564565        [theTool setEnvironmentVariable:@"SSH_AUTH_SOCK" withValue:[agent socketPath]]; 
    565566 
    566         if([theTool launchAndWait] == NO) 
     567        /* Set the token and run. */ 
     568        if(![[TokenController sharedController] generateNewTokenForTool:theTool] || ![theTool launchAndWait]) 
    567569        { 
    568570                [self warningPanelWithTitle:local(@"AddSingleKeyToAgent") andMessage:local(@"AddSingleKeyToAgentFailed") 
  • trunk/Controller.h

    r42 r118  
    44@protocol UI 
    55 
    6 - (NSString *)askPassphrase:(NSString *)question withInteraction:(BOOL)interaction; 
     6- (NSString *)askPassphrase:(NSString *)question withToken:(NSString *)token andInteraction:(BOOL)interaction; 
    77- (void)warningPanelWithTitle:(NSString *)title andMessage:(NSString *)message; 
    88- (NSData *)statusbarMenu; 
     
    4343- (IBAction)toggleAppleKeychainLock:(id)sender; 
    4444 
    45 - (NSString *)askPassphrase:(NSString *)question withInteraction:(BOOL)interaction; 
     45- (NSString *)askPassphrase:(NSString *)question withToken:(NSString *)token andInteraction:(BOOL)interaction; 
    4646 
    4747- (IBAction)showAboutPanel:(id)sender; 
  • trunk/Controller.m

    r99 r118  
    77#import "PreferenceController.h" 
    88#import "UpdateController.h" 
     9#import "TokenController.h" 
    910 
    1011#import "Libs/SSHAgent.h" 
     
    346347} 
    347348 
    348 - (NSString *)askPassphrase:(NSString *)question withInteraction:(BOOL)interaction 
     349- (NSString *)askPassphrase:(NSString *)question withToken:(NSString *)token andInteraction:(BOOL)interaction 
    349350{ 
    350351        char *serviceName; 
     
    368369 
    369370        ProcessSerialNumber focusSerialNumber; 
     371 
     372        // Check if the token is valid. 
     373        if(![[TokenController sharedController] checkToken:token]) 
     374        { 
     375                return nil; 
     376        } 
     377         
    370378        GetFrontProcess(&focusSerialNumber); 
    371379 
  • trunk/Libs/SSHAgent.m

    r93 r118  
    44#import "SSHTool.h" 
    55#import "PreferenceController.h" 
     6#import "TokenController.h" 
    67 
    78#include <string.h> 
     
    612613        [theTool setEnvironmentVariable:@"SSH_AUTH_SOCK" withValue:[self agentSocketPath]]; 
    613614 
     615        /* Set the token. */ 
     616        if([[TokenController sharedController] generateNewTokenForTool:theTool] == NO) 
     617        { 
     618                return nil; 
     619        } 
     620 
    614621        /* Launch the tool and retrieve stdout. */ 
    615622        NSString *theOutput = [theTool launchForStandardOutput]; 
  • trunk/Libs/SSHKeychain.m

    r92 r118  
    11#import "SSHKeychain.h" 
    22#import "PreferenceController.h" 
     3#import "TokenController.h" 
    34 
    45#import "SSHKey.h" 
     
    214215        NSEnumerator *e = [[self arrayOfPaths] objectEnumerator]; 
    215216        NSString *path; 
     217 
    216218        while (path = [e nextObject]) 
    217219        { 
     
    224226 
    225227        [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])  
    244232        { 
    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                } 
    247255        } 
    248256         
  • trunk/Libs/SSHTunnel.m

    r99 r118  
    22 
    33#import "PreferenceController.h" 
     4#import "TokenController.h" 
    45 
    56#ifndef NSAppKitVersionNumber10_3 
     
    253254 
    254255        [[tunnel task] setStandardOutput:thePipe]; 
     256 
     257        // Generate a token. 
     258        if (![[TokenController sharedController] generateNewTokenForTool:tunnel]) 
     259        { 
     260                return NO; 
     261        } 
    255262         
    256263        /* Launch ssh. */ 
  • trunk/PassphraseRequester.m

    r78 r118  
    88        char *interaction; 
    99        NSString *passphrase; 
     10        NSString *sshkeychainToken = nil; 
    1011 
    1112        if(argc == 2)  
     
    2122                        exit(1);  
    2223                } 
    23  
     24                 
     25                if(getenv("SSHKeychainToken"))  
     26                { 
     27                        sshkeychainToken = [NSString stringWithCString:getenv("SSHKeychainToken")]; 
     28                } 
     29                 
    2430                [UI setProtocolForProxy:@protocol(UI)]; 
    2531 
     
    2834                if((interaction) && (strcmp(interaction, "1") == 0)) 
    2935                { 
    30                         passphrase = [UI askPassphrase:[[procinfo arguments] objectAtIndex:1] withInteraction:YES]; 
     36                        passphrase = [UI askPassphrase:[[procinfo arguments] objectAtIndex:1] withToken:sshkeychainToken andInteraction:YES]; 
    3137                         
    3238                        if(passphrase == nil) 
     
    3945                else 
    4046                { 
    41                         passphrase = [UI askPassphrase:[[procinfo arguments] objectAtIndex:1] withInteraction:NO]; 
     47                        passphrase = [UI askPassphrase:[[procinfo arguments] objectAtIndex:1] withToken:sshkeychainToken andInteraction:NO]; 
    4248                         
    4349                        if(passphrase == nil) 
  • trunk/SSHKeychain.xcodeproj/project.pbxproj

    r99 r118  
    3535                CC4FC46206AD4A0C00B59C21 /* KeysView.h in Headers */ = {isa = PBXBuildFile; fileRef = CC4FC46006AD4A0C00B59C21 /* KeysView.h */; }; 
    3636                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 */; }; 
    3739                CC586C5106C3D56A00D73261 /* SecurityView.h in Headers */ = {isa = PBXBuildFile; fileRef = CC586C4F06C3D56A00D73261 /* SecurityView.h */; }; 
    3840                CC586C5206C3D56A00D73261 /* SecurityView.m in Sources */ = {isa = PBXBuildFile; fileRef = CC586C5006C3D56A00D73261 /* SecurityView.m */; }; 
     
    7476                CCE66DE406B15AEA002A5BEE /* TunnelsView.h in Headers */ = {isa = PBXBuildFile; fileRef = CCE66DE206B15AEA002A5BEE /* TunnelsView.h */; }; 
    7577                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 */; }; 
    7680/* End PBXBuildFile section */ 
    7781 
     
    143147                CC4FC46006AD4A0C00B59C21 /* KeysView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = KeysView.h; path = PreferenceViews/KeysView.h; sourceTree = "<group>"; usesTabs = 1; }; 
    144148                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>"; }; 
    145151                CC586C4F06C3D56A00D73261 /* SecurityView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = SecurityView.h; path = PreferenceViews/SecurityView.h; sourceTree = "<group>"; usesTabs = 1; }; 
    146152                CC586C5006C3D56A00D73261 /* SecurityView.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = SecurityView.m; path = PreferenceViews/SecurityView.m; sourceTree = "<group>"; usesTabs = 1; }; 
     
    201207                CCE66DE206B15AEA002A5BEE /* TunnelsView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = TunnelsView.h; path = PreferenceViews/TunnelsView.h; sourceTree = "<group>"; usesTabs = 1; }; 
    202208                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>"; }; 
    203211/* End PBXFileReference section */ 
    204212 
     
    235243                                CCCDD4A506A576CF00B68ED1 /* Controller.h */, 
    236244                                CCCDD4A606A576CF00B68ED1 /* Controller.m */, 
     245                                CC51B40F0C7C5EE8005D33DB /* TokenController.h */, 
     246                                CC51B4100C7C5EE8005D33DB /* TokenController.m */, 
    237247                                CC08A64506A876B300C578A3 /* PreferenceController.h */, 
    238248                                CC6C191307421C8700CB0A18 /* UpdateController.h */, 
     
    362372                        isa = PBXGroup; 
    363373                        children = ( 
     374                                CCFAAB450C7C870900AD9093 /* SSHToken.h */, 
     375                                CCFAAB460C7C870900AD9093 /* SSHToken.m */, 
    364376                                CC40C2D106A6813E00AE58DD /* SSHTunnel.h */, 
    365377                                CCC9E54306A6802000422E9E /* SSHTunnel.m */, 
     
    403415                                0A7F549007676EB500E1C1E4 /* Utilities.h in Headers */, 
    404416                                0A7F555007677DCC00E1C1E4 /* NSMenu_Additions.h in Headers */, 
     417                                CC51B4110C7C5EE8005D33DB /* TokenController.h in Headers */, 
     418                                CCFAAB470C7C870900AD9093 /* SSHToken.h in Headers */, 
    405419                        ); 
    406420                        runOnlyForDeploymentPostprocessing = 0; 
     
    581595                                0A7F549107676EB500E1C1E4 /* Utilities.m in Sources */, 
    582596                                0A7F555107677DCC00E1C1E4 /* NSMenu_Additions.m in Sources */, 
     597                                CC51B4120C7C5EE8005D33DB /* TokenController.m in Sources */, 
     598                                CCFAAB480C7C870900AD9093 /* SSHToken.m in Sources */, 
    583599                        ); 
    584600                        runOnlyForDeploymentPostprocessing = 0;