]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
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 9c1152dcfee06299cc05fd5d7b8567a2144c43b5..1ff2daf05b4217839b982b73d09668f822a5b54a 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 d5c839c1a45fca7168e4575046a549c0320331e6..915dc2fc58302902a41a77d217d25c160ffd1492 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 41e4cb6bcb5ae51239427c81af7876016d52de32..8abd48f73fa3066720a977a0e1279de0008dd164 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 963d7ef8655c2a941472dfbb726ad5bd1fc945e4..b562acd1e689cd096b28f46902830d2a81ee98d8 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 b82226e4661f06c9255b8de7ee305f43fe97b1c7..e18925a1a9c015e16d0582efccc265e8d242830a 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 fa3d16e3fdc6b82d2cecc49ae8a214d4097ce4ce..f626dc3cbf148e864bfd3d790d582564aff57e25 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 d62b81243552e648bc792cd8a2813e9dc3fd45d4..6cb10094d63f25c1b48af3322cb37a427638b1ee 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 fac3772d6401ee637f718322ae00e7018e17e91d..ff67b4aae301e9f1bd00b3d43fb5fa1d3a97f3eb 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 5860844acd55d3fdd4d172e089a64d4116b3c316..67239395c3ec785c1359b63c2f7c4a3fcd761eca 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]];
        }
 }