From: Charles McGarvey Date: Tue, 4 Nov 2008 19:00:00 +0000 (-0700) Subject: The Cheat 1.2.2 X-Git-Tag: v1.2.2 X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=0a3d732da131b4505c0dbf2330c4667a29ce90e8;p=chaz%2Fthecheat The Cheat 1.2.2 Bug Fixes: - Privileges to access memory on intel Macs and Leopard. - Crash when performing multiple searches. - Crash when closing a cheat document. Contributed by Adrien Pujol. --- diff --git a/AppController.h b/AppController.h index e4a9765..7eb651f 100644 --- a/AppController.h +++ b/AppController.h @@ -26,7 +26,6 @@ #import "CheatServer.h" - @class AboutBoxController; @class HelpController; @class PreferenceController; @@ -54,6 +53,13 @@ - (IBAction)checkForUpdate:(id)sender; +// Privilage elevation stuff +AuthorizationRef _authRef; +AuthorizationItem _authItem; +AuthorizationRights _authRights; +- (int) preAuthorize; +- (int) launchAuthPrgm; + // Server Stuff - (CheatServer *)cheatServer; - (BOOL)startCheatServer; diff --git a/AppController.m b/AppController.m index ebae2de..303b1eb 100644 --- a/AppController.m +++ b/AppController.m @@ -25,6 +25,12 @@ #import "HelpController.h" #import "PreferenceController.h" +// Privilage elevation libs +#include +#include +#include +#include +#include @implementation AppController @@ -65,13 +71,90 @@ - (id)init { - if ( self = [super init] ) { - [self setDelegate:self]; + if ( self = [super init] ) + { + if( geteuid() != 0 ) + { + [self launchAuthPrgm]; + [self setDelegate:self]; + } } + if( geteuid() != 0 ) + { + NSRunAlertPanel(@"The Cheat must be run as root,", + @"Due to a limitation of Leopard, the application needs elevated privileges to run.", + @"Exit", nil, nil ); + [self terminate: 0]; + } + return self; } +- (int) preAuthorize +{ + int err; + AuthorizationFlags authFlags; + + + NSLog (@"MyWindowController: preAuthorize"); + + if (_authRef) + return errAuthorizationSuccess; + + NSLog (@"MyWindowController: preAuthorize: ** calling AuthorizationCreate...**\n"); + + authFlags = kAuthorizationFlagDefaults; + err = AuthorizationCreate (NULL, kAuthorizationEmptyEnvironment, authFlags, &_authRef); + if (err != errAuthorizationSuccess) + return err; + + NSLog (@"MyWindowController: preAuthorize: ** calling AuthorizationCopyRights...**\n"); + + _authItem.name = kAuthorizationRightExecute; + _authItem.valueLength = 0; + _authItem.value = NULL; + _authItem.flags = 0; + _authRights.count = 1; + _authRights.items = (AuthorizationItem*) malloc (sizeof (_authItem)); + memcpy (&_authRights.items[0], &_authItem, sizeof (_authItem)); + authFlags = kAuthorizationFlagDefaults + | kAuthorizationFlagExtendRights + | kAuthorizationFlagInteractionAllowed + | kAuthorizationFlagPreAuthorize; + err = AuthorizationCopyRights (_authRef, &_authRights, kAuthorizationEmptyEnvironment, authFlags, NULL); + + return err; +} + +- (int) launchAuthPrgm +{ + AuthorizationFlags authFlags; + int err; + + // path + NSString * path = [[NSBundle mainBundle] executablePath]; + if (![[NSFileManager defaultManager] isExecutableFileAtPath: path]) + return -1; + + // auth + + if (!_authRef) + { + err = [self preAuthorize]; + if (err != errAuthorizationSuccess) + return err; + } + + // launch + + NSLog (@"MyWindowController: launchWithPath: ** calling AuthorizationExecuteWithPrivileges...**\n"); + authFlags = kAuthorizationFlagDefaults; + err = AuthorizationExecuteWithPrivileges (_authRef, [path cString], authFlags, NULL, NULL); + if(err==0) [NSApp terminate:self]; + + return err; +} - (void)dealloc { diff --git a/English.lproj/AboutBox.nib/classes.nib b/English.lproj/AboutBox.nib/classes.nib index f9f3920..c132e54 100644 --- a/English.lproj/AboutBox.nib/classes.nib +++ b/English.lproj/AboutBox.nib/classes.nib @@ -1,18 +1,59 @@ -{ - IBClasses = ( - { - ACTIONS = {ibEmailButton = id; ibWebsiteButton = id; }; - CLASS = AboutBoxController; - LANGUAGE = ObjC; - OUTLETS = { - ibDateText = NSTextField; - ibEmailButton = NSButton; - ibNameVersionText = NSTextField; - ibWebsiteButton = NSButton; - }; - SUPERCLASS = NSWindowController; - }, - {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; } - ); - IBVersion = 1; -} \ No newline at end of file + + + + + IBClasses + + + ACTIONS + + ibEmailButton + id + ibWebsiteButton + id + + CLASS + AboutBoxController + LANGUAGE + ObjC + OUTLETS + + ibDateText + NSTextField + ibEmailButton + NSButton + ibNameVersionText + NSTextField + ibWebsiteButton + NSButton + + SUPERCLASS + NSWindowController + + + CLASS + NSMenu + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + CLASS + FirstResponder + LANGUAGE + ObjC + SUPERCLASS + NSObject + + + CLASS + NSObject + LANGUAGE + ObjC + + + IBVersion + 1 + + diff --git a/English.lproj/AboutBox.nib/info.nib b/English.lproj/AboutBox.nib/info.nib index 4c7b4ef..99d506a 100644 --- a/English.lproj/AboutBox.nib/info.nib +++ b/English.lproj/AboutBox.nib/info.nib @@ -1,37 +1,20 @@ - + - IBDocumentLocation - 124 93 356 241 0 0 1280 938 IBFramework Version - 364.0 - IBGroupedObjects - - 3 - - 93 - 91 - - 7 - - 77 - 80 - 87 - - 8 - - 89 - 81 - - - IBLastGroupID - 9 + 677 + IBLastKnownRelativeProjectPath + ../The Cheat.xcodeproj + IBOldestOS + 5 IBOpenObjects - 85 + 78 IBSystem Version - 7U16 + 9C7010 + targetFramework + IBCocoaFramework diff --git a/English.lproj/AboutBox.nib/keyedobjects.nib b/English.lproj/AboutBox.nib/keyedobjects.nib index 7ef2eec..c71d319 100644 Binary files a/English.lproj/AboutBox.nib/keyedobjects.nib and b/English.lproj/AboutBox.nib/keyedobjects.nib differ diff --git a/Info.plist b/Info.plist index 15323d1..440bc13 100644 --- a/Info.plist +++ b/Info.plist @@ -1,5 +1,5 @@ - + CFBundleDevelopmentRegion @@ -30,7 +30,7 @@ CFBundleExecutable The Cheat CFBundleGetInfoString - The Cheat 1.2.1 + The Cheat 1.2.2 CFBundleIconFile icon.icns CFBundleIdentifier @@ -42,7 +42,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.2.1 + 1.2.2 CFBundleSignature chœt CFBundleURLTypes @@ -57,7 +57,7 @@ CFBundleVersion - 1.2.1 + 1.2.2 NSAppleScriptEnabled YES NSMainNibFile diff --git a/main.m b/main.m index 6c98a2d..68dd64f 100644 --- a/main.m +++ b/main.m @@ -21,7 +21,6 @@ #import #include "ChazLog.h" - int main( int argc, const char *argv[] ) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];