Changeset 3946

Show
Ignore:
Timestamp:
03/23/06 20:47:13 (2 years ago)
Author:
morris
Message:

Move to using SFAuthorization interface for auth, move WCAuthorization code to WCDashboard

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • WiredServer/trunk/PreferencePane/English.lproj/InfoPlist.strings

    r923 r3946  
    22 
    33CFBundleName = "Wired"; 
    4 CFBundleShortVersionString = "1.3"; 
    5 CFBundleGetInfoString = "1.3, Copyright (c) 2003-2004, Zanka Software."; 
    6 NSHumanReadableCopyright = "Copyright (c) 2003-2004, Zanka Software."; 
     4CFBundleShortVersionString = "Wired Server 1.3"; 
     5CFBundleGetInfoString = "Wired Server 1.3, Copyright (c) 2003-2006, Zanka Software."; 
     6NSHumanReadableCopyright = "Copyright (c) 2003-2006, Zanka Software."; 
  • WiredServer/trunk/PreferencePane/English.lproj/Wired.nib/classes.nib

    r3675 r3946  
    22    IBClasses = ( 
    33        {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },  
     4        {CLASS = NSObject; LANGUAGE = ObjC; },  
    45        { 
    56            CLASS = NSPreferencePane;  
     
    1314            SUPERCLASS = NSObject;  
    1415        },  
     16        {CLASS = SFAuthorizationView; LANGUAGE = ObjC; SUPERCLASS = NSView; },  
    1517        { 
    1618            ACTIONS = {add = id; delete = id; selectGroup = id; selectType = id; touch = id; };  
     
    2325                "_cannotBeKickedButton" = NSButton;  
    2426                "_clearNewsButton" = NSButton;  
    25                 "_configController" = WCConfigController;  
    2627                "_createAccountsButton" = NSButton;  
    2728                "_createFoldersButton" = NSButton;  
     
    8081                "_controlPortTextField" = NSTextField;  
    8182                "_createCertificateButton" = NSButton;  
    82                 "_dashboardController" = WCDashboardController;  
    8383                "_deleteTrackerButton" = NSButton;  
    8484                "_descriptionTextField" = NSTextField;  
     
    127127            LANGUAGE = ObjC;  
    128128            OUTLETS = { 
     129                "_authorizationView" = SFAuthorizationView;  
    129130                "_indexButton" = NSButton;  
    130131                "_registerButton" = NSButton;  
     
    167168        {CLASS = WIGraphView; LANGUAGE = ObjC; SUPERCLASS = NSView; },  
    168169        { 
    169             ACTIONS = {authorize = id; help = id; };  
     170            ACTIONS = {help = id; };  
    170171            CLASS = WPWired;  
    171172            LANGUAGE = ObjC;  
    172173            OUTLETS = { 
    173174                "_accountsController" = WCAccountsController;  
    174                 "_authorizationStatusButton" = NSButton;  
    175                 "_authorizationStatusTextField" = NSTextField;  
    176175                "_configController" = WCConfigController;  
    177176                "_dashboardController" = WCDashboardController;  
  • WiredServer/trunk/PreferencePane/English.lproj/Wired.nib/info.nib

    r3729 r3946  
    44<dict> 
    55        <key>IBDocumentLocation</key> 
    6         <string>475 146 446 363 0 0 1280 1002 </string> 
     6        <string>887 151 446 363 0 0 1920 1178 </string> 
    77        <key>IBFramework Version</key> 
    88        <string>443.0</string> 
  • WiredServer/trunk/PreferencePane/WPWired.h

    r3011 r3946  
    3838 
    3939        IBOutlet NSTabView                              *_tabView; 
    40          
    41         IBOutlet NSButton                               *_authorizationStatusButton; 
    42         IBOutlet NSTextField                    *_authorizationStatusTextField; 
    43  
    44         NSImage                                                 *_lockedImage, *_unlockedImage; 
    4540} 
    4641 
    4742 
    48 - (IBAction)authorize:(id)sender; 
    4943- (IBAction)help:(id)sender; 
    5044 
  • WiredServer/trunk/PreferencePane/WPWired.m

    r3857 r3946  
    3838@interface WPWired(Private) 
    3939 
    40 - (void)update; 
    41 - (void)save; 
     40- (void)_save; 
     41 
     42@end 
     43 
     44 
     45@implementation WPWired(Private) 
     46 
     47- (void)_save { 
     48        if([_configController saveFromController]) 
     49                [_accountsController saveFromController]; 
     50
    4251 
    4352@end 
     
    6675 
    6776- (void)mainViewDidLoad { 
    68         _lockedImage = [[NSImage alloc] initWithContentsOfFile: 
    69                 [[self bundle] pathForResource:@"Locked" ofType:@"tiff"]]; 
    70         _unlockedImage = [[NSImage alloc] initWithContentsOfFile: 
    71                 [[self bundle] pathForResource:@"Unlocked" ofType:@"tiff"]]; 
    72  
    73         [_accountsController setRequiresAuthorization:YES]; 
    74         [_configController setRequiresAuthorization:YES]; 
    75         [_dashboardController setRequiresAuthorization:YES]; 
    76          
    7777        [_statusController awakeFromController]; 
    7878        [_logController awakeFromController]; 
     
    8080        [_configController awakeFromController]; 
    8181        [_accountsController awakeFromController]; 
    82          
    83         [self update]; 
    8482} 
    8583 
     
    9290 
    9391- (void)didUnselect { 
    94         [self save]; 
     92        [self _save]; 
    9593} 
    9694 
     
    10098 
    10199- (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem { 
    102         [self save]; 
     100        [self _save]; 
    103101} 
    104102 
     
    106104 
    107105#pragma mark - 
    108  
    109 - (void)update { 
    110         if([[WCAuthorization authorization] isAuthorized]) { 
    111                 [_authorizationStatusButton setImage:_unlockedImage]; 
    112                 [_authorizationStatusTextField setStringValue: 
    113                         WPLS(@"Click the lock to prevent further changes.", @"Authorization status")]; 
    114         } else { 
    115                 [_authorizationStatusButton setImage:_lockedImage]; 
    116                 [_authorizationStatusTextField setStringValue: 
    117                         WPLS(@"Click the lock to make changes.", @"Authorization status")]; 
    118         } 
    119 } 
    120  
    121  
    122  
    123 - (void)save { 
    124         BOOL    status = YES; 
    125          
    126         if(status) 
    127                 status = [_configController saveFromController]; 
    128          
    129         if(status) 
    130                 status = [_accountsController saveFromController]; 
    131 } 
    132  
    133  
    134  
    135 #pragma mark - 
    136  
    137 - (IBAction)authorize:(id)sender { 
    138         BOOL    status = YES; 
    139          
    140         if([[WCAuthorization authorization] isAuthorized]) { 
    141                 [[WCAuthorization authorization] deauthorize]; 
    142         } else { 
    143                 [_authorizationStatusTextField setStringValue:WPLS(@"Authenticating...", @"Authorization status")]; 
    144                 [_authorizationStatusTextField display]; 
    145                  
    146                 status = [[WCAuthorization authorization] authorizeForTasks: 
    147                         [NSArray arrayWithObjects: 
    148                                 WCExpandWiredPath(@"wiredctl"), 
    149                                 @"/usr/bin/touch", 
    150                                 @"/bin/mv", 
    151                                 @"/bin/rm", 
    152                                 @"/usr/bin/openssl", 
    153                                 @"/usr/sbin/chown", 
    154                                 NULL]]; 
    155         } 
    156          
    157         [self update]; 
    158 } 
    159  
    160  
    161106 
    162107- (IBAction)help:(id)sender { 
  • WiredServer/trunk/WCAccounts.m

    r2975 r3946  
    483483 
    484484- (id)initWithContentsOfFile:(NSString *)file type:(WCAccountType)type { 
    485         return [self initWithString:[NSString stringWithContentsOfFile:file] type:type]; 
     485        return [self initWithData:[NSData dataWithContentsOfFile:file] type:type]; 
    486486} 
    487487 
     
    489489 
    490490- (id)initWithContentsOfURL:(NSURL *)url type:(WCAccountType)type { 
    491         return [self initWithString:[NSString stringWithContentsOfURL:url] type:type]; 
     491        return [self initWithData:[NSData dataWithContentsOfURL:url] type:type]; 
    492492} 
    493493 
  • WiredServer/trunk/WCAccountsController.h

    r3900 r3946  
    2727 */ 
    2828 
    29 @class WCConfigController, WCAccounts; 
     29@class WCAccounts; 
    3030 
    3131@interface WCAccountsController : NSObject { 
    32         IBOutlet WCConfigController             *_configController; 
    33          
    3432        IBOutlet NSTableView                    *_tableView; 
    3533        IBOutlet NSButton                               *_addButton; 
     
    7371        NSImage                                                 *_userImage, *_groupImage; 
    7472         
    75         BOOL                                                    _requiresAuthorization; 
    76         BOOL                                                    _authorized; 
    7773        BOOL                                                    _touched; 
    7874} 
     
    8783- (BOOL)saveFromController; 
    8884 
    89 - (void)setRequiresAuthorization:(BOOL)value; 
    90 - (BOOL)requiresAuthorization; 
    91  
    9285- (IBAction)touch:(id)sender; 
    9386- (IBAction)add:(id)sender; 
  • WiredServer/trunk/WCAccountsController.m

    r3900 r3946  
    2929#import "WCAccounts.h" 
    3030#import "WCAccountsController.h" 
    31 #import "WCAuthorization.h" 
    3231#import "WCConfig.h" 
    3332#import "WCConfigController.h" 
     33#import "WCDashboardController.h" 
    3434#import "WCSettings.h" 
    3535 
     
    186186- (void)_validateAccount:(WCAccount *)account { 
    187187        BOOL    enabled; 
    188         BOOL    authorized; 
    189          
    190         authorized = [self requiresAuthorization] ? _authorized : YES; 
    191         enabled = authorized && (account != NULL); 
     188         
     189        enabled = [[WCDashboardController dashboardController] isAuthorized] && (account != NULL); 
    192190        [_addButton setEnabled:enabled]; 
    193191        [_deleteButton setEnabled:enabled]; 
     
    195193        [_nameTextField setEnabled:enabled]; 
    196194         
    197         enabled = (authorized && [account type] == WCAccountUser); 
     195        enabled = ([[WCDashboardController dashboardController] isAuthorized] && [account type] == WCAccountUser); 
    198196        [_passwordTextField setEnabled:enabled]; 
    199197        [_groupPopUpButton setEnabled:enabled]; 
    200198         
    201         enabled = (authorized && [[account group] length] == 0); 
     199        enabled = ([[WCDashboardController dashboardController] isAuthorized] && [[account group] length] == 0); 
    202200        [_getUserInfoButton setEnabled:enabled]; 
    203201        [_broadcastButton setEnabled:enabled]; 
     
    260258 
    261259- (BOOL)_writeUsersToFile:(NSString *)path { 
    262         NSString                        *temp; 
    263         WCAuthorization         *authorization; 
    264         WCConfig                        *config; 
    265         BOOL                            status; 
     260        NSString                                *temp; 
     261        WCDashboardController   *controller; 
     262        WCConfig                                *config; 
    266263         
    267264        [self _unselectAccount:[self _selectedAccount]]; 
    268265         
    269         authorization  = [WCAuthorization authorization]; 
    270         temp                   = [NSFileManager temporaryPathWithPrefix:@"users" suffix:@"conf"]; 
    271         status                 = [_users writeToFile:temp]; 
    272          
    273         if(status) 
    274                 status = [authorization movePath:temp toPath:path]; 
    275          
    276         if(status) { 
    277                 config = [_configController config]; 
    278                 status = [authorization        changeOwnerOfPath:path 
    279                                                                                  toOwner:[config stringForKey:@"user"] 
    280                                                                                        group:[config stringForKey:@"group"]]
    281        
    282  
    283         if(status) 
    284                _touched = NO; 
    285  
    286         return status
     266        controller     = [WCDashboardController dashboardController]; 
     267        config         = [[WCConfigController configController] config]; 
     268        temp           = [NSFileManager temporaryPathWithPrefix:@"users" suffix:@"conf"]; 
     269         
     270        if([_users writeToFile:temp]) { 
     271                if([controller movePath:temp toPath:path]) { 
     272                       if([controller changeOwnerOfPath:path 
     273                                                                        toOwner:[config stringForKey:@"user"] 
     274                                                                          group:[config stringForKey:@"group"]]) { 
     275                               _touched = NO; 
     276                                 
     277                                return YES
     278                       
     279                } 
     280                
     281        } 
     282         
     283        return NO
    287284} 
    288285 
     
    290287 
    291288- (BOOL)_writeGroupsToFile:(NSString *)path { 
    292         NSString                        *temp; 
    293         WCAuthorization         *authorization; 
    294         WCConfig                        *config; 
    295         BOOL                            status; 
     289        NSString                                *temp; 
     290        WCDashboardController   *controller; 
     291        WCConfig                                *config; 
    296292         
    297293        [self _unselectAccount:[self _selectedAccount]]; 
    298294 
    299         authorization  = [WCAuthorization authorization]; 
    300         temp                   = [NSFileManager temporaryPathWithPrefix:@"groups" suffix:@"conf"]; 
    301         status                 = [_groups writeToFile:temp]; 
    302          
    303         if(status) 
    304                 status = [authorization movePath:temp toPath:path]; 
    305          
    306         if(status) { 
    307                 config = [_configController config]; 
    308                 status = [authorization        changeOwnerOfPath:path 
    309                                                                                  toOwner:[config stringForKey:@"user"] 
    310                                                                                        group:[config stringForKey:@"group"]]
    311        
    312  
    313         if(status) 
    314                _touched = NO; 
    315          
    316         return status
     295        controller     = [WCDashboardController dashboardController]; 
     296        config         = [[WCConfigController configController] config]; 
     297        temp           = [NSFileManager temporaryPathWithPrefix:@"groups" suffix:@"conf"]; 
     298         
     299        if([_groups writeToFile:temp]) { 
     300                if([controller movePath:temp toPath:path]) { 
     301                       if([controller changeOwnerOfPath:path 
     302                                                                        toOwner:[config stringForKey:@"user"] 
     303                                                                          group:[config stringForKey:@"group"]]) { 
     304                               _touched = NO; 
     305                                 
     306                                return YES
     307                       
     308                } 
     309                
     310        } 
     311         
     312        return NO
    317313} 
    318314 
     
    373369 
    374370- (BOOL)saveFromController { 
    375         BOOL    status = YES; 
    376          
    377371        if(_touched) { 
    378                 if(status) 
    379                         status = [self _writeUsersToFile:WCExpandWiredPath(@"users")]; 
    380          
    381                 if(status) 
    382                         status = [self _writeGroupsToFile:WCExpandWiredPath(@"groups")]; 
    383                  
    384                 if(status) { 
    385                         [[NSNotificationCenter defaultCenter] 
    386                                 postNotificationName:WCAccountsDidChange 
    387                                 object:NULL]; 
     372                if([self _writeUsersToFile:WCExpandWiredPath(@"users")]) { 
     373                        if([self _writeGroupsToFile:WCExpandWiredPath(@"groups")]) { 
     374                                [[NSNotificationCenter defaultCenter] postNotificationName:WCAccountsDidChange]; 
     375                                 
     376                                return YES; 
     377                        } 
    388378                } 
    389         } 
    390          
    391         return status; 
     379                 
     380                return NO; 
     381        } 
     382         
     383        return YES; 
    392384} 
    393385 
     
    412404 
    413405- (void)authorizationStatusDidChange:(NSNotification *)notification { 
    414         _authorized = [[notification object] boolValue]; 
    415  
    416406        [self _validateAccount:[self _selectedAccount]]; 
    417407} 
     
    429419                [_tableView reloadData]; 
    430420        } 
    431 } 
    432  
    433  
    434  
    435 #pragma mark - 
    436  
    437 - (void)setRequiresAuthorization:(BOOL)value { 
    438         _requiresAuthorization = value; 
    439 } 
    440  
    441  
    442  
    443 - (BOOL)requiresAuthorization { 
    444         return _requiresAuthorization; 
    445421} 
    446422 
  • WiredServer/trunk/WCConfigController.h

    r3199 r3946  
    2727 */ 
    2828 
    29 @class WCDashboardController, WCConfig; 
     29@class WCConfig; 
    3030 
    3131@interface WCConfigController : NSObject { 
    32         IBOutlet WCDashboardController  *_dashboardController; 
    33          
    3432        IBOutlet NSPanel                                *_certificatePanel; 
    3533        IBOutlet NSProgressIndicator    *_certificateProgressIndicator; 
     
    114112- (WCConfig *)config; 
    115113 
    116 - (void)setRequiresAuthorization:(BOOL)value; 
    117 - (BOOL)requiresAuthorization; 
    118  
    119114- (IBAction)touch:(id)sender; 
    120115- (IBAction)setBanner:(id)sender; 
  • WiredServer/trunk/WCConfigController.m

    r3859 r3946  
    3131#undef SYSLOG_NAMES 
    3232 
    33 #import "WCAuthorization.h" 
    3433#import "WCConfig.h" 
    3534#import "WCConfigController.h" 
     
    5756 
    5857- (void)_update { 
     58        BOOL    enabled; 
    5959        int             method; 
    60         BOOL    enabled; 
    61          
    62         enabled = [self requiresAuthorization] ? _authorized : YES; 
     60         
     61        enabled = [[WCDashboardController dashboardController] isAuthorized]; 
    6362        method = [[_logMethodMatrix selectedCell] tag]; 
    6463 
     
    253252 
    254253- (BOOL)_writeToFile:(NSString *)path { 
    255         NSString                *temp; 
    256         WCAuthorization *authorization; 
    257         BOOL                    status; 
     254        NSString                                *temp; 
     255        WCDashboardController   *controller; 
    258256 
    259257        // --- config 
     
    330328        [_config setString:[_groupPopUpButton titleOfSelectedItem] forKey:@"group"]; 
    331329         
    332         authorization   = [WCAuthorization authorization]; 
    333         temp                    = [NSFileManager temporaryPathWithPrefix:@"config" suffix:@"conf"]; 
    334         status                  = [_config writeToFile:temp]; 
    335                  
    336         if(status) 
    337                 status = [authorization movePath:temp toPath:path]; 
    338          
    339         if(status) { 
    340                 status = [authorization changeOwnerOfPath:[WCSettings objectForKey:WCPrefixPath] 
    341                                                                                   toOwner:[_config stringForKey:@"user"] 
    342                                                                                         group:[_config stringForKey:@"group"]]; 
    343         } 
    344          
    345         if(status) 
    346                 _touched = NO; 
    347          
    348         return status; 
     330        controller      = [WCDashboardController dashboardController]; 
     331        temp            = [NSFileManager temporaryPathWithPrefix:@"config" suffix:@"conf"]; 
     332         
     333        if([_config writeToFile:temp]) { 
     334                if([controller movePath:temp toPath:path]) { 
     335                        if([controller changeOwnerOfPath:[WCSettings objectForKey:WCPrefixPath] 
     336                                                                         toOwner:[_config stringForKey:@"user"] 
     337                                                                           group:[_config stringForKey:@"group"]]) { 
     338                                _touched = NO; 
     339                                 
     340                                return YES; 
     341                        } 
     342                } 
     343        } 
     344 
     345        return NO; 
    349346} 
    350347 
     
    352349 
    353350- (BOOL)_writeFlagsToFile:(NSString *)path { 
    354         WCAuthorization         *authorization; 
    355         NSString                        *string, *temp; 
    356         BOOL                            status; 
    357          
    358         authorization   = [WCAuthorization authorization]; 
    359         string                  = [[_dashboardController launchArguments] componentsJoinedByString:@" "]; 
    360         temp                    = [NSFileManager temporaryPathWithPrefix:@"wired" suffix:@"flags"]; 
    361         status                  = [string writeToFile:temp atomically:YES]; 
    362          
    363         if(status) 
    364                 status = [authorization movePath:temp toPath:path]; 
    365          
    366         if(status) { 
    367                 status = [authorization changeOwnerOfPath:path 
    368                                                                                   toOwner:[_config stringForKey:@"user"] 
    369                                                                                         group:[_config stringForKey:@"group"]]; 
    370         } 
    371          
    372         return status; 
     351        NSString                                *string, *temp; 
     352        WCDashboardController   *controller; 
     353         
     354        controller      = [WCDashboardController dashboardController]; 
     355        string          = [[controller launchArguments] componentsJoinedByString:@" "]; 
     356        temp            = [NSFileManager temporaryPathWithPrefix:@"wired" suffix:@"flags"]; 
     357         
     358        if([string writeToFile:temp atomically:YES]) { 
     359                if([controller movePath:temp toPath:path]) { 
     360                        if([controller changeOwnerOfPath:path 
     361                                                                         toOwner:[_config stringForKey:@"user"] 
     362                                                                           group:[_config stringForKey:@"group"]]) 
     363                                return YES; 
     364                } 
     365        } 
     366         
     367        return NO; 
    373368} 
    374369 
     
    378373 
    379374- (void)_setLaunchesAtBoot:(BOOL)value { 
    380         WCAuthorization                *authorization
    381         NSString                       *path
    382          
    383         path                   = WCExpandWiredPath(@"etc/wired.startup"); 
    384         authorization  = [WCAuthorization authorization]; 
     375        NSString                               *path
     376        WCDashboardController  *controller
     377         
     378        path            = WCExpandWiredPath(@"etc/wired.startup"); 
     379        controller     = [WCDashboardController dashboardController]; 
    385380 
    386381        if(value) { 
    387                 if([authorization createFileAtPath:path]) { 
    388                         [authorization changeOwnerOfPath:path 
    389                                                                         toOwner:[_config stringForKey:@"user"] 
    390                                                                            group:[_config stringForKey:@"group"]]; 
     382                if([controller createFileAtPath:path]) { 
     383                        [controller changeOwnerOfPath:path 
     384                                                                toOwner:[_config stringForKey:@"user"] 
     385                                                                        group:[_config stringForKey:@"group"]]; 
    391386                } 
    392387        } else { 
    393                 [authorization removeFileAtPath:path]; 
     388                [controller removeFileAtPath:path]; 
    394389        } 
    395390} 
     
    500495 
    501496- (BOOL)saveFromController { 
    502         BOOL    status = YES; 
    503          
    504497        if(_touched) { 
    505                 status = [self _writeToFile:WCExpandWiredPath(@"etc/wired.conf")]; 
    506  
    507                 if(status) { 
    508                         [[NSNotificationCenter defaultCenter] 
    509                                 postNotificationName:WCConfigDidChange 
    510                                 object:NULL]; 
     498                if([self _writeToFile:WCExpandWiredPath(@"etc/wired.conf")]) { 
     499                        [[NSNotificationCenter defaultCenter] postNotificationName:WCConfigDidChange]; 
    511500 
    512501                        if(_logTouched) { 
    513                                 [[NSNotificationCenter defaultCenter] 
    514                                         postNotificationName:WCLogConfigDidChange 
    515                                         object:NULL]; 
     502                                [[NSNotificationCenter defaultCenter] postNotificationName:WCLogConfigDidChange]; 
    516503                                 
    517504                                _logTouched = YES; 
     
    520507                        [self _writeFlagsToFile:WCExpandWiredPath(@"etc/wired.flags")]; 
    521508                        [self _setLaunchesAtBoot:[_launchAtBootButton state]]; 
     509                         
     510                        return YES; 
    522511                } 
    523         } 
    524          
    525         return status; 
     512                 
     513                return NO; 
     514        } 
     515         
     516        return YES; 
    526517} 
    527518 
     
    621612#pragma mark - 
    622613 
    623 - (void)setRequiresAuthorization:(BOOL)value { 
    624         _requiresAuthorization = value; 
    625 } 
    626  
    627  
    628  
    629 - (BOOL)requiresAuthorization { 
    630         return _requiresAuthorization; 
    631 } 
    632  
    633  
    634  
    635 #pragma mark - 
    636  
    637614- (IBAction)touch:(id)sender { 
    638615        [self _update]; 
     
    647624 
    648625- (IBAction)setBanner:(id)sender { 
    649         NSImage                         *image, *banner; 
    650         NSBitmapImageRep        *imageRep; 
    651         NSData                          *data; 
    652         NSString                        *path, *temp; 
    653         WCAuthorization         *authorization; 
    654         NSSize                          size; 
    655         BOOL                            status; 
     626        NSImage                                 *image, *banner; 
     627        NSBitmapImageRep                *imageRep; 
     628        NSData                                  *data; 
     629        NSString                                *path, *temp; 
     630        WCDashboardController   *controller; 
     631        NSSize                                  size; 
    656632         
    657633        image = [_bannerImageView image]; 
     
    682658    } 
    683659         
    684         imageRep                = [NSBitmapImageRep imageRepWithData:[[_bannerImageView image] TIFFRepresentation]]; 
    685         data                    = [imageRep representationUsingType:NSPNGFileType properties:NULL]; 
    686         path                    = WCExpandWiredPath(@"banner.png"); 
    687         authorization   = [WCAuthorization authorization]; 
    688         temp                    = [NSFileManager temporaryPathWithPrefix:@"banner" suffix:@"png"]; 
    689         status                  = [data writeToFile:temp atomically:YES]; 
    690          
    691         if(status) 
    692                 status = [authorization movePath:temp toPath:path]; 
    693          
    694         if(status) { 
    695                 status = [authorization changeOwnerOfPath:path 
    696                                                                                   toOwner:[_config stringForKey:@"user"] 
    697                                                                                         group:[_config stringForKey:@"group"]]; 
    698         } 
    699          
    700         if(status) { 
    701                 [_config setString:path forKey:@"banner"]; 
    702                 _touched = YES; 
     660        imageRep        = [NSBitmapImageRep imageRepWithData:[[_bannerImageView image] TIFFRepresentation]]; 
     661        data            = [imageRep representationUsingType:NSPNGFileType properties:NULL]; 
     662        path            = WCExpandWiredPath(@"banner.png"); 
     663        controller      = [WCDashboardController dashboardController]; 
     664        temp            = [NSFileManager temporaryPathWithPrefix:@"banner" suffix:@"png"]; 
     665         
     666        if([data writeToFile:temp atomically:YES]) { 
     667                if([controller movePath:temp toPath:path]) { 
     668                        if([controller changeOwnerOfPath:path 
     669                                                                         toOwner:[_config stringForKey:@"user"] 
     670                                                                           group:[_config stringForKey:@"group"]]) { 
     671                                [_config setString:path forKey:@"banner"]; 
     672                                _touched = YES; 
     673                        } 
     674                } 
    703675        } 
    704676} 
     
    752724 
    753725- (IBAction)createCertificate:(id)sender { 
    754         NSArray                         *arguments; 
    755         NSString                        *path, *temp; 
    756         WCAuthorization         *authorization; 
    757         BOOL                            status; 
     726        NSArray                                 *arguments; 
     727        NSString                                *path, *temp; 
     728        WCDashboardController   *controller; 
    758729         
    759730        [_certificateProgressIndicator startAnimation:self]; 
     
    765736          contextInfo:NULL]; 
    766737         
    767         authorization   = [WCAuthorization authorization]; 
    768         path                    = WCExpandWiredPath(@"etc/certificate.pem"); 
    769         temp                    = [NSFileManager temporaryPathWithPrefix:@"certificate" suffix:@"pem"]; 
    770         arguments               = [NSArray arrayWithObjects: 
     738        controller      = [WCDashboardController dashboardController]; 
     739        path            = WCExpandWiredPath(@"etc/certificate.pem"); 
     740        temp            = [NSFileManager temporaryPathWithPrefix:@"certificate" suffix:@"pem"]; 
     741 
     742        arguments = [NSArray arrayWithObjects: 
    771743                @"req", 
    772744                @"-x509", 
     
    784756                NULL]; 
    785757         
    786         status = [authorization launchTaskWithPath:@"/usr/bin/openssl" arguments:arguments]; 
    787          
    788         if(status) 
    789                 status = [authorization movePath:temp toPath:path]; 
    790          
    791         if(status) { 
    792                 status = [authorization changeOwnerOfPath:path 
    793                                                                                   toOwner:[_config stringForKey:@"user"] 
    794                                                                                         group:[_config stringForKey:@"group"]]; 
    795         } 
    796                  
    797         if(status) { 
    798                 [_config setString:WCExpandWiredPath(@"etc/certificate.pem") forKey:@"certificate"]; 
    799                 _touched = YES; 
    800         } 
    801  
     758        if([controller launchTaskWithPath:@"/usr/bin/openssl" arguments:arguments]) { 
     759                if([controller movePath:temp toPath:path]) { 
     760                        if([controller changeOwnerOfPath:path 
     761                                                                         toOwner:[_config stringForKey:@"user"] 
     762                                                                           group:[_config stringForKey:@"group"]]) { 
     763                                [_config setString:WCExpandWiredPath(@"etc/certificate.pem") forKey:@"certificate"]; 
     764                                _touched = YES; 
     765                        } 
     766                } 
     767        } 
     768         
    802769        [self _updateCertificate]; 
    803770 
     
    939906        BOOL    enabled; 
    940907         
    941         enabled = [self requiresAuthorization] ? _authorized : YES
     908        enabled = [[WCDashboardController dashboardController] isAuthorized]
    942909        [cell setEnabled:enabled]; 
    943910        [cell setEditable:enabled]; 
  • WiredServer/trunk/WCDashboardController.h

    r3675 r3946  
    3030 
    3131@interface WCDashboardController : NSObject { 
    32         IBOutlet WCStatusController             *_statusController; 
     32        IBOutlet WCStatusController                    *_statusController; 
    3333         
    34         IBOutlet NSButton                               *_startButton; 
    35         IBOutlet NSButton                               *_restartButton; 
    36         IBOutlet NSButton                               *_reloadButton; 
    37         IBOutlet NSButton                               *_registerButton; 
    38         IBOutlet NSButton