10.6 update(Workaround for kerberos bug) and cleaning of deprecated function form...
authorClaudio Bisegni <Claudio.Bisegni@lnf.infn.it>
Wed, 26 Aug 2009 15:18:37 +0000 (17:18 +0200)
committerDerrick Brashear <shadow|account-1000005@unknown>
Wed, 26 Aug 2009 15:34:21 +0000 (08:34 -0700)
For aklog has been added the workaround for kerberos function KLAcquireInitialTickets that in 10.6 return always error.
First is called KLCacheHasValidTickets for check user ticket presence, if there are no ticket  KLAcquireNewInitialTickets will be called for get user credential.
Has been removed also many deprecated api.

Reviewed-on: http://gerrit.openafs.org/341
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>

src/platform/DARWIN/AFSPreference/AFSBackgrounder/AFSBackgrounderDelegate.m
src/platform/DARWIN/AFSPreference/AFSBackgrounder/AFSMenuExtraView.h
src/platform/DARWIN/AFSPreference/AFSBackgrounder/AFSMenuExtraView.m
src/platform/DARWIN/AFSPreference/AFSCommanderPref.m
src/platform/DARWIN/AFSPreference/AFSPropertyManager.m
src/platform/DARWIN/AFSPreference/AuthUtil.m
src/platform/DARWIN/AFSPreference/OpenAFS.xcodeproj/project.pbxproj
src/platform/DARWIN/AFSPreference/PListManager.m
src/platform/DARWIN/AFSPreference/afshlp.m

index 9c1152d..1ff2daf 100644 (file)
        
        //Dispose afs manager
        [afsPropMngr release];
+       [[NSDistributedNotificationCenter defaultCenter] postNotificationName:kAfsCommanderID 
+                                                                                                                                  object:kMenuExtraEventOccured];
 }
 
 // -------------------------------------------------------------------------------
 {
        [afsMngr unlog:nil];
        [self updateAfsStatus:nil];
+       [[NSDistributedNotificationCenter defaultCenter] postNotificationName:kAfsCommanderID 
+                                                                                                                                  object:kMenuExtraEventOccured];
 }
 
 
 }
 
 -(IBAction) getReleaseTokenEvent:(id)sender {
-       [self getToken:sender];
+       if(gotToken)
+               [self releaseToken:sender];
+       else
+               [self getToken:sender];
 }
 @end
index d5c839c..915dc2f 100644 (file)
@@ -17,4 +17,8 @@
 }
 - initWithFrame:(NSRect)myRect backgrounder:(AFSBackgrounderDelegate*)backgrounder menu:(NSMenu*)menu;
 - (NSAttributedString*) makeKerberosIndicator:(int*)fontHeight;
+- (void)mouseDown:(NSEvent *)event;
+- (void)menuWillOpen:(NSMenu *)menu;
+- (void)menuDidClose:(NSMenu *)menu;
+- (void)menuNeedsUpdate:(NSMenu *)menu;
 @end
index 41e4cb6..8abd48f 100644 (file)
@@ -70,7 +70,7 @@
     @discussion Make a letter to render in menu view to inform the user if is enable aklog use
 */
 - (NSAttributedString*) makeKerberosIndicator:(int*)fontHeight  {
-       NSFont *font = [NSFont fontWithName:@"Palatino-Roman" size:9.0];
+       NSFont *font = [NSFont systemFontOfSize:9.0];
        NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObject:font
                                                                                                                                forKey:NSFontAttributeName];
        NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"K"
index 963d7ef..b562acd 100644 (file)
        switch (returnCode) {
                case  1:
                        if([[NSFileManager defaultManager] createDirectoryAtPath:[HOME_LAUNCHD_AGENT_FOLDER stringByExpandingTildeInPath] 
-                                                                                                                 attributes:nil]) {
+                                                                                withIntermediateDirectories:NO
+                                                                                                                 attributes:nil
+                                                                                                                          error:nil]) {
                                
                                //Create the file
                                [PListManager installBackgrounderLaunchdFile:YES
                                do {
                                        DBCellElement *cellElement =  (DBCellElement*)[filteredCellDB objectAtIndex:index];
                                        [[afsProperty getCellList] removeObject:cellElement];
-                               } while ((index = [selectedIndex indexGreaterThanIndex: index]) != NSNotFound);
+                               } while ((index = [selectedIndex indexGreaterThanIndex:index]) != NSNotFound);
                        }
                }
                break;
 - (void) refreshGui:(NSNotification *)notification{
        BOOL afsIsUp = [afsProperty checkAfsStatus];
        [self setAfsStatus];
-       //[self refreshTokens:nil];
+       [self refreshTokens:nil];
        [tokensButton setEnabled:afsIsUp];
        [unlogButton setEnabled:afsIsUp];
 }
index b82226e..e18925a 100644 (file)
        NSString *afsdOptionStrData = [[NSString alloc] initWithData:fileHData
                                                                                                                encoding:NSASCIIStringEncoding];*/
        if(!filePath) return;
-       [self readAFSDParamLineContent:[[NSString stringWithContentsOfFile:filePath] stringByStandardizingPath]];
+       [self readAFSDParamLineContent:[[NSString stringWithContentsOfFile:filePath 
+                                                                                                                         encoding:NSUTF8StringEncoding 
+                                                                                                                                error:nil] stringByStandardizingPath]];
 }
 
 // -------------------------------------------------------------------------------
        NSScanner *lineScanner = nil;
        
        //Get file content
-       NSString *newAFSDConfContent = [NSString stringWithContentsOfFile:filePath];
+       NSString *newAFSDConfContent = [NSString stringWithContentsOfFile:filePath 
+                                                                                                                        encoding:NSUTF8StringEncoding 
+                                                                                                                               error:nil];
        
        //get lines in array
        NSArray *confLines = [newAFSDConfContent componentsSeparatedByString:@"\n"];
 //  +(void) aklog
 // -------------------------------------------------------------------------------
 -(void) aklog:(NSString*)theCell noKerberosCall:(BOOL)krb5CallEnable {
-       KLPrincipal  princ = nil;
-       KLStatus kstatus = noErr;
-       char *princName = malloc(255);
+       KLPrincipal             princ = nil;
+       KLStatus                kstatus = noErr;
+       char                    *princName = 0L;
+       KLBoolean       outFoundValidTickets = false;
        @try {
                // trying to ket kerberos ticket
                if(krb5CallEnable) {
-                       kstatus =  KLAcquireInitialTickets (0L, 0L, &princ,  &princName);
-                       if(kstatus != noErr && kstatus != klUserCanceledErr) @throw [NSException exceptionWithName:@"aklog" 
-                                                                                                                                                                                               reason:kPathNotEmpty 
-                                                                                                                                                                                         userInfo:nil];
+                       kstatus = KLCacheHasValidTickets(nil, nil, &outFoundValidTickets, nil, nil);
+                       //kstatus =  KLAcquireInitialTickets (0L, 0L, &princ,  &princName);
+                       if(!outFoundValidTickets) {
+                               kstatus = KLAcquireNewInitialTickets(nil, nil, &princ, &princName);
+                               if(kstatus != noErr && kstatus != klUserCanceledErr) @throw [NSException exceptionWithName:@"aklog" 
+                                                                                                                                                                                                       reason:@"KLAcquireInitialTickets" 
+                                                                                                                                                                                                 userInfo:nil];
+                       }
                } else kstatus = klNoErr;
                
-                //ok to launch aklog
+               
+               //ok to launch aklog
                if(kstatus == klNoErr) [TaskUtil executeTaskSearchingPath:@"aklog" 
                                                                                                                         args:(theCell==nil?[NSArray arrayWithObjects:nil]:[NSArray arrayWithObjects:@"-c", theCell, nil])];
                
        }
        @finally {
                // destory the kerberos va
-               if(princName && princ != nil) 
-                       KLDisposeString(princName);
-               else if(princName) free(princName);
+               if (kstatus == klNoErr) {
+                       KLDisposeString (princName);
+                       KLDisposePrincipal (princ);
+               }
        }
                
 }
index fa3d16e..f626dc3 100644 (file)
@@ -146,7 +146,7 @@ static AuthUtil *sharedAuthUtil = nil;
                        if (bytesRead < 1) break;
                        //write (fileno (stdout), buff, bytesRead);
                        if(output) {
-                               [output appendString:[NSString stringWithCString:buff length:bytesRead]];
+                               [output appendString:[NSString stringWithCString:buff  encoding:NSUTF8StringEncoding]];
                        }
                }
        }
index d62b812..6cb1009 100644 (file)
                1DBD214D08BA80EA00186707 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               ARCHS = (
-                                       ppc,
-                                       i386,
-                               );
+                               ARCHS = "$(ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1)";
+                               ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 = "x86_64 i386 ppc";
                                GCC_C_LANGUAGE_STANDARD = gnu99;
                                GCC_ENABLE_OBJC_EXCEPTIONS = YES;
                                GCC_WARN_ABOUT_RETURN_TYPE = YES;
                                GCC_WARN_UNUSED_VARIABLE = YES;
                                INSTALL_PATH = /Library/PreferencePanes;
+                               ONLY_ACTIVE_ARCH = NO;
                                PREBINDING = NO;
                                SKIP_INSTALL = NO;
+                               VALID_ARCHS = "i386 ppc x86_64";
                        };
                        name = Debug;
                };
index fac3772..ff67b4a 100644 (file)
@@ -67,6 +67,7 @@
                        break;
                        
                case 5:
+               case 6:
                        if(enable){
                                //remove
                                toRemove = DELETE_IN_10_5;
 +(BOOL) checkKrb5AtLoginTimeLaunchdEnable {
        BOOL result = false;
        NSString *authFileContent = nil;
-       authFileContent = [NSString stringWithContentsOfFile:AUTH_FILE];
+       authFileContent = [NSString stringWithContentsOfFile:AUTH_FILE 
+                                                                                                                 encoding:NSUTF8StringEncoding 
+                                                                                                                        error:nil];
        if(authFileContent) {
                result = [authFileContent rangeOfString:ADD_IN_PLIST].location != NSNotFound;   
        }
index 5860844..6723939 100644 (file)
@@ -67,6 +67,7 @@ void runCommand(int argc, char *argv[])
                NSLog(@"Start afs from helper");
                setuid(0);
                const char *startArgs[] = {argv[2], argv[3], 0L};
+               NSLog(@"%s, %s, %s", argv[1], argv[2], argv[3]);
                [[AuthUtil shared] execUnixCommand:argv[1] 
                                                                          args:startArgs
                                                                        output:nil];
@@ -80,9 +81,9 @@ void runCommand(int argc, char *argv[])
                setuid(0);
                NSLog(@"Manage start_afs_at_startup with option %s from helper", argv[2]);
                [PListManager manageAfsStartupLaunchdFile:YES 
-                                                                afsStartupScript:[NSString stringWithCString:argv[2]]
-                                                                         afsBasePath:[NSString stringWithCString:argv[4]]
-                                                                                afsdPath:[NSString stringWithCString:argv[3]]];
+                                                                afsStartupScript:[NSString stringWithCString:argv[2] encoding:NSUTF8StringEncoding]
+                                                                         afsBasePath:[NSString stringWithCString:argv[4] encoding:NSUTF8StringEncoding]
+                                                                                afsdPath:[NSString stringWithCString:argv[3] encoding:NSUTF8StringEncoding]];
        }
 }