Changeset 3857
- Timestamp:
- 03/01/06 19:43:47 (3 years ago)
- Files:
-
- WiredServer/trunk/PreferencePane/WPWired.m (modified) (1 diff)
- WiredServer/trunk/WCAuthorization.h (modified) (1 diff)
- WiredServer/trunk/WCAuthorization.m (modified) (1 diff)
- WiredServer/trunk/WCConfigController.m (modified) (3 diffs)
- WiredServer/trunk/WCDashboardController.m (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
WiredServer/trunk/PreferencePane/WPWired.m
r3403 r3857 147 147 [NSArray arrayWithObjects: 148 148 WCExpandWiredPath(@"wiredctl"), 149 @"/usr/bin/touch", 149 150 @"/bin/mv", 150 151 @"/bin/rm", WiredServer/trunk/WCAuthorization.h
r3011 r3857 44 44 - (BOOL)launchTaskWithPath:(NSString *)path arguments:(NSArray *)arguments; 45 45 46 - (BOOL)createFileAtPath:(NSString *)path; 46 47 - (BOOL)movePath:(NSString *)fromPath toPath:(NSString *)toPath; 47 48 - (BOOL)removeFileAtPath:(NSString *)path; WiredServer/trunk/WCAuthorization.m
r2975 r3857 206 206 #pragma mark - 207 207 208 - (BOOL)createFileAtPath:(NSString *)path { 209 return [self launchTaskWithPath:@"/usr/bin/touch" arguments:[NSArray arrayWithObject:path]]; 210 } 211 212 213 208 214 - (BOOL)movePath:(NSString *)fromPath toPath:(NSString *)toPath { 209 215 NSArray *arguments; WiredServer/trunk/WCConfigController.m
r3675 r3857 47 47 - (void)_readFromFile:(NSString *)path; 48 48 - (BOOL)_writeToFile:(NSString *)path; 49 - (BOOL)_writeFlagsToFile:(NSString *)path; 49 50 50 51 - (void)_setLaunchesAtBoot:(BOOL)value; … … 357 358 358 359 360 - (BOOL)_writeFlagsToFile:(NSString *)path { 361 WCAuthorization *authorization; 362 NSString *string, *owner, *temp; 363 BOOL status = YES; 364 365 string = [[_dashboardController launchArguments] componentsJoinedByString:@" "]; 366 367 owner = [[NSFileManager defaultManager] ownerAtPath:path]; 368 369 if(!owner) 370 owner = [[NSFileManager defaultManager] ownerAtPath:[path stringByDeletingLastPathComponent]]; 371 372 if([[[NSFileManager defaultManager] ownerAtPath:path] isEqualToString:NSUserName()]) { 373 status = [string writeToFile:path atomically:YES]; 374 } else { 375 authorization = [WCAuthorization authorization]; 376 377 if(status) { 378 temp = [NSFileManager temporaryPathWithPrefix:@"wired" suffix:@"flags"]; 379 status = [string writeToFile:temp atomically:YES]; 380 } 381 382 if(status) 383 status = [authorization movePath:temp toPath:path]; 384 385 if(status) { 386 status = [authorization changeOwnerOfPath:path 387 toOwner:[_config stringForKey:@"user"] 388 group:[_config stringForKey:@"group"]]; 389 } 390 } 391 392 return status; 393 } 394 395 396 359 397 #pragma mark - 360 398 361 399 - (void)_setLaunchesAtBoot:(BOOL)value { 362 NSFileManager *fileManager;363 NSString *path, *owner, *temp, *string;364 400 WCAuthorization *authorization; 365 WCConfig *config; 366 BOOL status; 367 368 authorization = [WCAuthorization authorization]; 369 fileManager = [NSFileManager defaultManager]; 401 NSString *path, *owner; 402 370 403 path = WCExpandWiredPath(@"etc/wired.startup"); 371 372 if(value) { 373 string = [[_dashboardController launchArguments] componentsJoinedByString:@" "]; 374 owner = [fileManager ownerAtPath:path]; 375 376 if(!owner) 377 owner = [fileManager ownerAtPath:[path stringByDeletingLastPathComponent]]; 378 379 if([owner isEqualToString:NSUserName()]) { 380 [string writeToFile:path atomically:YES]; 404 owner = [[NSFileManager defaultManager] ownerAtPath:path]; 405 406 if(!owner) 407 owner = [[NSFileManager defaultManager] ownerAtPath:[path stringByDeletingLastPathComponent]]; 408 409 if([[[NSFileManager defaultManager] ownerAtPath:path] isEqualToString:NSUserName()]) { 410 if(value) 411 [[NSFileManager defaultManager] createFileAtPath:path]; 412 else 413 [[NSFileManager defaultManager] removeFileAtPath:path]; 414 } else { 415 authorization = [WCAuthorization authorization]; 416 417 if(value) { 418 if([authorization createFileAtPath:path]) { 419 [authorization changeOwnerOfPath:path 420 toOwner:[_config stringForKey:@"user"] 421 group:[_config stringForKey:@"group"]]; 422 } 423 } else { 424 [authorization removeFileAtPath:path]; 381 425 } 382 else if([authorization isAuthorized]) {383 temp = [NSFileManager temporaryPathWithPrefix:@"wired" suffix:@"startup"];384 status = [string writeToFile:temp atomically:YES];385 386 if(status)387 status = [authorization movePath:temp toPath:path];388 389 if(status) {390 config = [self config];391 status = [authorization changeOwnerOfPath:path392 toOwner:[config stringForKey:@"user"]393 group:[config stringForKey:@"group"]];394 }395 }396 } else {397 if([[fileManager ownerAtPath:path] isEqualToString:NSUserName()])398 [fileManager removeFileAtPath:path];399 else if([authorization isAuthorized])400 [authorization removeFileAtPath:path];401 426 } 402 427 } … … 524 549 _logTouched = YES; 525 550 } 551 552 [self _writeFlagsToFile:WCExpandWiredPath(@"etc/wired.flags")]; 553 [self _setLaunchesAtBoot:[_launchAtBootButton state]]; 526 554 } 527 528 [self _setLaunchesAtBoot:[_launchAtBootButton state]];529 555 } 530 556 WiredServer/trunk/WCDashboardController.m
r3675 r3857 192 192 arguments = [NSMutableArray array]; 193 193 194 if([_statusController isRunning]) {194 if([_statusController isRunning]) 195 195 [arguments addObject:@"stop"]; 196 } else {196 else 197 197 [arguments addObject:@"start"]; 198 [arguments addObjectsFromArray:[self launchArguments]];199 }200 198 201 199 [[WCAuthorization authorization] launchTaskWithPath:WCExpandWiredPath(@"wiredctl") … … 210 208 arguments = [NSMutableArray array]; 211 209 [arguments addObject:@"restart"]; 212 [arguments addObjectsFromArray:[self launchArguments]];213 210 214 211 [[WCAuthorization authorization] launchTaskWithPath:WCExpandWiredPath(@"wiredctl")
