X-Git-Url: https://git.openafs.org/?p=openafs.git;a=blobdiff_plain;f=src%2Fplatform%2FDARWIN%2FAFSPreference%2FAFSPropertyManager.m;h=a5fb45e3d7644be3d7c3bbea735b01ee0973943d;hp=aaefbd517baa3bfdd0e9dd6a8f5851c6ddb8a00a;hb=f0ce809181d19e865817200dab4fb8370bceeb59;hpb=694c5ca3f400ce88219f60edec75249bf73cc8fc diff --git a/src/platform/DARWIN/AFSPreference/AFSPropertyManager.m b/src/platform/DARWIN/AFSPreference/AFSPropertyManager.m index aaefbd5..a5fb45e 100644 --- a/src/platform/DARWIN/AFSPreference/AFSPropertyManager.m +++ b/src/platform/DARWIN/AFSPreference/AFSPropertyManager.m @@ -88,9 +88,9 @@ // ------------------------------------------------------------------------------- -(void) dealloc { - if(installationPath){ [installationPath release]; NSLog(@"Released installationPath"); } - if(cellList) { NSLog(@"Released cellList");[cellList removeAllObjects];[cellList release];} - if(cellName) { NSLog(@"Released cellName");[cellName release];} + if(installationPath){ [installationPath release];} + if(cellList) {[cellList removeAllObjects];[cellList release];} + if(cellName) {[cellName release];} if(futil) { [futil endAutorization]; [futil release]; @@ -311,41 +311,32 @@ // read thiscell config file [filePath setString:installationPath]; [filePath appendString: @"/etc/ThisCell"]; - NSLog(@"Search for cell name."); + [self readCellInfo:filePath]; if(!cellName){ @throw [NSException exceptionWithName:@"readCellInfo" reason:kThisCellFOError userInfo:nil]; } - NSLog(@"Cell found: %s", [cellName cString]); - //read TheseCell file [filePath setString: installationPath]; [filePath appendString: @"/etc/TheseCells"]; userDefaultCellArray = [self readTheseCell:filePath]; //read cell serv db - NSLog(@"Scan for cell db"); [filePath setString: installationPath]; [filePath appendString: @"/etc/CellServDB"]; [self readCellDB:filePath]; - NSLog(@"Server found: %d", [cellList count]); - - //Read cacheinfo - NSLog(@"Scan cacheinfo file"); [filePath setString: installationPath]; [filePath appendString: @"/etc/cacheinfo"]; [self readCacheInfo:filePath]; - NSLog(@"End scan cacheinfo file"); //Read config/afsd.options [filePath setString: installationPath]; [filePath appendString: useAfsdConfVersion?AFSD_NEW_PREFERENCE_FILE:AFSD_OLD_PREFERENCE_FILE]; [self readAfsdOption:filePath]; - } @catch(NSException * e){ @throw e; } @finally { @@ -476,7 +467,9 @@ 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]]; } // ------------------------------------------------------------------------------- @@ -490,8 +483,6 @@ do{ [afsdOptionS scanUpToCharactersFromSet:space intoString:&tmpString]; if(!tmpString) continue; - - NSLog(tmpString); //check parameter type if([tmpString isEqualToString:@AFSD_OPTION_DAEMONS_KEY]) { @@ -551,7 +542,9 @@ 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"]; @@ -569,8 +562,8 @@ //scann the line - [lineScanner scanUpToString:@"\"" intoString:¶mValue]; NSLog(paramValue);[lineScanner scanUpToString:@"-" intoString:¶mValue]; - [lineScanner scanUpToString:@"\"" intoString:¶mValue]; NSLog(paramValue); + [lineScanner scanUpToString:@"\"" intoString:¶mValue];[lineScanner scanUpToString:@"-" intoString:¶mValue]; + [lineScanner scanUpToString:@"\"" intoString:¶mValue]; // read the asfd option param line [self readAFSDParamLineContent:paramValue]; @@ -671,11 +664,7 @@ { NSString *tmpString = nil; NSString *result = [TaskUtil executeTaskSearchingPath:@"fs" args:[NSArray arrayWithObjects:@"-version", nil]]; - if(result) NSLog(@"fs -version return: %s", [result cString]); - - NSCharacterSet *endVersionCS = [NSCharacterSet characterSetWithCharactersInString:@"qwertyuiopasdfghjklzxcvbnmMNBVCXZLKJHGFDSAPOIUYTREWQ"]; - NSCharacterSet *spaceCS = [NSCharacterSet characterSetWithCharactersInString:@" "]; NSScanner *versionS = [NSScanner scannerWithString:result]; //go to start of version @@ -828,11 +817,8 @@ // readCellInfo: // ------------------------------------------------------------------------------- -(void) readCellInfo:(NSString*) configFile { - - NSError *error = nil; NSString *tmpStr = nil; - NSLog(@"Try to opening file: %s",[configFile cString] ); NSString * result = [NSString stringWithContentsOfFile:configFile encoding:NSASCIIStringEncoding error:&error]; @@ -843,7 +829,6 @@ userInfo:nil]; } NSScanner *scanner = [NSScanner scannerWithString:result]; - [scanner scanUpToString:@"\n" intoString:&tmpStr]; @@ -988,7 +973,6 @@ if(line >= 2){ - NSLog(@"Token found %s", [tokenLine UTF8String]); // add enteir row to result [tokenList addObject:tokenLine]; // create the line scanner for all the row that contains token info @@ -1016,19 +1000,25 @@ // +(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])]; @@ -1038,9 +1028,10 @@ } @finally { // destory the kerberos va - if(princName && princ != nil) - KLDisposeString(princName); - else if(princName) free(princName); + if (kstatus == klNoErr) { + KLDisposeString (princName); + KLDisposePrincipal (princ); + } } } @@ -1091,32 +1082,14 @@ // ------------------------------------------------------------------------------- -(void) shutdown { - NSMutableString *filePath = [[NSMutableString alloc] initWithCapacity:256]; @try { - if([[AuthUtil shared] autorize] != noErr) - return; - - /*const char *args0[] = {"stop", 0L}; - [[AuthUtil shared] execUnixCommand:"/Library/StartupItems/OpenAFS/OpenAFS_stop" - args:args0 - output:0L];*/ - - // unmount afs - const char *args1[] = {"-f", "/afs", 0L}; - [[AuthUtil shared] execUnixCommand:"/sbin/umount" - args:args1 - output:0L]; - - const char *args2[] = {"-shutdown", 0L}; - [[AuthUtil shared] execUnixCommand:"/usr/sbin/afsd" - args:args2 - output:0L]; - - const char *args3[] = {[filePath UTF8String], 0L}; - [[AuthUtil shared] execUnixCommand:"/sbin/kextunload" - args:args3 - output:0L]; - + const char *stopArgs[] = {"stop", 0L}; + if([[AuthUtil shared] autorize] == noErr) { + [[AuthUtil shared] execUnixCommand:AFS_DAEMON_STARTUPSCRIPT + args:stopArgs + output:nil]; + } + } @catch (NSException * e) { @throw e; @@ -1128,6 +1101,30 @@ } + +// ------------------------------------------------------------------------------- +// -(void) shutdown +// ------------------------------------------------------------------------------- +-(void) startup +{ + @try { + const char *startArgs[] = {"start", 0L}; + if([[AuthUtil shared] autorize] == noErr) { + [[AuthUtil shared] execUnixCommand:AFS_DAEMON_STARTUPSCRIPT + args:startArgs + output:nil]; + } + + } + @catch (NSException * e) { + @throw e; + } + @finally { + + } + + +} // ------------------------------------------------------------------------------- // -(void) saveConfigurationFiles // ------------------------------------------------------------------------------- @@ -1356,6 +1353,7 @@ if(filePath) [filePath release]; } } + // ------------------------------------------------------------------------------- // checkAfsStatus:[NSArray arrayWithObjects:@"checkserver", nil]; // ------------------------------------------------------------------------------- @@ -1368,6 +1366,16 @@ } // ------------------------------------------------------------------------------- +// checkAfsStatus:[NSArray arrayWithObjects:@"checkserver", nil]; +// ------------------------------------------------------------------------------- +-(BOOL) checkAfsStatusForStartup { + BOOL result = NO; + NSString *dfResult = [TaskUtil executeTaskSearchingPath:@"/bin/df" args:[NSArray arrayWithObjects:nil]]; + result = (dfResult?([dfResult rangeOfString:@AFS_FS_MOUNT].location != NSNotFound):NO); + return result; +} + +// ------------------------------------------------------------------------------- // makeChaceParamString // ------------------------------------------------------------------------------- -(NSString*) makeChaceParamString