]> Dogcows Code - chaz/thecheat/commitdiff
The Cheat 1.2.2 v1.2.2
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Tue, 4 Nov 2008 19:00:00 +0000 (12:00 -0700)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Tue, 4 Nov 2008 19:00:00 +0000 (12:00 -0700)
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.

AppController.h
AppController.m
English.lproj/AboutBox.nib/classes.nib
English.lproj/AboutBox.nib/info.nib
English.lproj/AboutBox.nib/keyedobjects.nib
Info.plist
main.m

index e4a9765ba55ce03fd93d164da1b691f73614dc25..7eb651fcbf4b00d5a8e33b770ca51369c8fd3bfe 100644 (file)
@@ -26,7 +26,6 @@
 
 #import "CheatServer.h"
 
-
 @class AboutBoxController;
 @class HelpController;
 @class PreferenceController;
 
 - (IBAction)checkForUpdate:(id)sender;
 
+// Privilage elevation stuff
+AuthorizationRef _authRef;
+AuthorizationItem _authItem;
+AuthorizationRights _authRights;
+- (int) preAuthorize;
+- (int) launchAuthPrgm;
+
 // Server Stuff
 - (CheatServer *)cheatServer;
 - (BOOL)startCheatServer;
index ebae2deae04d2c320139de396c52f10ecd114fc7..303b1eb9d96e9eeb86d36dec0af23639ce1a256c 100644 (file)
 #import "HelpController.h"
 #import "PreferenceController.h"
 
+// Privilage elevation libs
+#include <security/authorization.h>
+#include <security/authorizationdb.h>
+#include <security/authorizationtags.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 @implementation AppController
 
 
 - (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
 {
index f9f39203c5901d3707ae19e7704e5728c4dc133b..c132e54ca576e2d37d459ce35fd1a5f75ea86c40 100644 (file)
@@ -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
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>IBClasses</key>
+       <array>
+               <dict>
+                       <key>ACTIONS</key>
+                       <dict>
+                               <key>ibEmailButton</key>
+                               <string>id</string>
+                               <key>ibWebsiteButton</key>
+                               <string>id</string>
+                       </dict>
+                       <key>CLASS</key>
+                       <string>AboutBoxController</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+                       <key>OUTLETS</key>
+                       <dict>
+                               <key>ibDateText</key>
+                               <string>NSTextField</string>
+                               <key>ibEmailButton</key>
+                               <string>NSButton</string>
+                               <key>ibNameVersionText</key>
+                               <string>NSTextField</string>
+                               <key>ibWebsiteButton</key>
+                               <string>NSButton</string>
+                       </dict>
+                       <key>SUPERCLASS</key>
+                       <string>NSWindowController</string>
+               </dict>
+               <dict>
+                       <key>CLASS</key>
+                       <string>NSMenu</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+                       <key>SUPERCLASS</key>
+                       <string>NSObject</string>
+               </dict>
+               <dict>
+                       <key>CLASS</key>
+                       <string>FirstResponder</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+                       <key>SUPERCLASS</key>
+                       <string>NSObject</string>
+               </dict>
+               <dict>
+                       <key>CLASS</key>
+                       <string>NSObject</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+               </dict>
+       </array>
+       <key>IBVersion</key>
+       <string>1</string>
+</dict>
+</plist>
index 4c7b4ef3e27ca23782d5a6aa2fd8c3f91f6f168b..99d506af914378a9741f2dd8f37d1ae42c7bf4b9 100644 (file)
@@ -1,37 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
-       <key>IBDocumentLocation</key>
-       <string>124 93 356 241 0 0 1280 938 </string>
        <key>IBFramework Version</key>
-       <string>364.0</string>
-       <key>IBGroupedObjects</key>
-       <dict>
-               <key>3</key>
-               <array>
-                       <string>93</string>
-                       <string>91</string>
-               </array>
-               <key>7</key>
-               <array>
-                       <string>77</string>
-                       <string>80</string>
-                       <string>87</string>
-               </array>
-               <key>8</key>
-               <array>
-                       <string>89</string>
-                       <string>81</string>
-               </array>
-       </dict>
-       <key>IBLastGroupID</key>
-       <string>9</string>
+       <string>677</string>
+       <key>IBLastKnownRelativeProjectPath</key>
+       <string>../The Cheat.xcodeproj</string>
+       <key>IBOldestOS</key>
+       <integer>5</integer>
        <key>IBOpenObjects</key>
        <array>
-               <integer>85</integer>
+               <integer>78</integer>
        </array>
        <key>IBSystem Version</key>
-       <string>7U16</string>
+       <string>9C7010</string>
+       <key>targetFramework</key>
+       <string>IBCocoaFramework</string>
 </dict>
 </plist>
index 7ef2eec207537913e91a8f51c1832eb4c6ce0404..c71d319d564f5dabb8df14638c460c3dcda0151a 100644 (file)
Binary files a/English.lproj/AboutBox.nib/keyedobjects.nib and b/English.lproj/AboutBox.nib/keyedobjects.nib differ
index 15323d189e80e258e8715166b020f96c82833468..440bc1361c6f06831985a7e5e50d8e940649934f 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
        <key>CFBundleDevelopmentRegion</key>
@@ -30,7 +30,7 @@
        <key>CFBundleExecutable</key>
        <string>The Cheat</string>
        <key>CFBundleGetInfoString</key>
-       <string>The Cheat 1.2.1</string>
+       <string>The Cheat 1.2.2</string>
        <key>CFBundleIconFile</key>
        <string>icon.icns</string>
        <key>CFBundleIdentifier</key>
@@ -42,7 +42,7 @@
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.2.1</string>
+       <string>1.2.2</string>
        <key>CFBundleSignature</key>
        <string>chœt</string>
        <key>CFBundleURLTypes</key>
@@ -57,7 +57,7 @@
                </dict>
        </array>
        <key>CFBundleVersion</key>
-       <string>1.2.1</string>
+       <string>1.2.2</string>
        <key>NSAppleScriptEnabled</key>
        <string>YES</string>
        <key>NSMainNibFile</key>
diff --git a/main.m b/main.m
index 6c98a2ddcb9f1043f7428e938fb1890bb0fe3607..68dd64f821bb9d8e6688ec68adf4e37e2278ce7e 100644 (file)
--- a/main.m
+++ b/main.m
@@ -21,7 +21,6 @@
 #import <Cocoa/Cocoa.h>
 #include "ChazLog.h"
 
-
 int main( int argc, const char *argv[] )
 {
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
This page took 0.031649 seconds and 4 git commands to generate.