Merge pull request #20 from AnakinMac/master

Some fixes
This commit is contained in:
Hendrik Holtmann
2014-03-26 02:07:14 +01:00
6 changed files with 68 additions and 31 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
/build/
/smcFanControl.xcodeproj/project.xcworkspace/xcshareddata/
/smcFanControl.xcodeproj/project.xcworkspace/xcuserdata/
/smcFanControl.xcodeproj/xcuserdata/

View File

@ -586,8 +586,10 @@ NSUserDefaults *defaults;
//just a helper to bringt update-info-window to the front //just a helper to bringt update-info-window to the front
- (IBAction)updateCheck:(id)sender{ - (IBAction)updateCheck:(id)sender{
[[[SUUpdater alloc] init] checkForUpdates:sender]; SUUpdater *updater = [[SUUpdater alloc] init];
[updater checkForUpdates:sender];
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
[updater release];
} }
- (IBAction)visitHomepage:(id)sender{ - (IBAction)visitHomepage:(id)sender{
@ -651,7 +653,7 @@ NSUserDefaults *defaults;
LSSharedFileListRef loginItems = LSSharedFileListCreate(kCFAllocatorDefault, kLSSharedFileListSessionLoginItems, /*options*/ NULL); LSSharedFileListRef loginItems = LSSharedFileListCreate(kCFAllocatorDefault, kLSSharedFileListSessionLoginItems, /*options*/ NULL);
NSString *path = [[NSBundle mainBundle] bundlePath]; NSString *path = [[NSBundle mainBundle] bundlePath];
CFURLRef URLToToggle = (CFURLRef)[NSURL fileURLWithPath:path]; CFURLRef URLToToggle = (CFURLRef)[NSURL fileURLWithPath:path];
LSSharedFileListItemRef existingItem = NULL; //LSSharedFileListItemRef existingItem = NULL;
UInt32 seed = 0U; UInt32 seed = 0U;
NSArray *currentLoginItems = [NSMakeCollectable(LSSharedFileListCopySnapshot(loginItems, &seed)) autorelease]; NSArray *currentLoginItems = [NSMakeCollectable(LSSharedFileListCopySnapshot(loginItems, &seed)) autorelease];
@ -667,7 +669,7 @@ NSUserDefaults *defaults;
CFRelease(URL); CFRelease(URL);
if (foundIt) { if (foundIt) {
existingItem = item; //existingItem = item;
found = YES; found = YES;
break; break;
} }
@ -728,8 +730,6 @@ NSUserDefaults *defaults;
LSSharedFileListItemRemove(loginItems, existingItem); LSSharedFileListItemRemove(loginItems, existingItem);
} }
#pragma mark **SMC-Binary Owner/Right Check** #pragma mark **SMC-Binary Owner/Right Check**
//TODO: It looks like this function is called inefficiently. //TODO: It looks like this function is called inefficiently.
//call smc binary with sudo rights and apply //call smc binary with sudo rights and apply
@ -748,6 +748,15 @@ NSUserDefaults *defaults;
AuthorizationRights gencright = { 1, &gencitem }; AuthorizationRights gencright = { 1, &gencitem };
int flags = kAuthorizationFlagExtendRights | kAuthorizationFlagInteractionAllowed; int flags = kAuthorizationFlagExtendRights | kAuthorizationFlagInteractionAllowed;
OSStatus status = AuthorizationCreate(&gencright, kAuthorizationEmptyEnvironment, flags, &authorizationRef); OSStatus status = AuthorizationCreate(&gencright, kAuthorizationEmptyEnvironment, flags, &authorizationRef);
if (status != errAuthorizationSuccess) {
NSAlert *alert = [NSAlert alertWithMessageText:@"Authorization failed" defaultButton:@"Quit" alternateButton:nil otherButton:nil informativeTextWithFormat:[NSString stringWithFormat:@"Authorization failed with code %d",status]];
[alert setAlertStyle:2];
NSInteger result = [alert runModal];
if (result == NSAlertDefaultReturn) {
[[NSApplication sharedApplication] terminate:self];
}
}
NSString *tool=@"/usr/sbin/chown"; NSString *tool=@"/usr/sbin/chown";
NSArray *argsArray = [NSArray arrayWithObjects: @"root:admin",smcpath,nil]; NSArray *argsArray = [NSArray arrayWithObjects: @"root:admin",smcpath,nil];
int i; int i;
@ -757,6 +766,15 @@ NSUserDefaults *defaults;
} }
args[i] = NULL; args[i] = NULL;
status=AuthorizationExecuteWithPrivileges(authorizationRef,[tool UTF8String],0,args,&commPipe); status=AuthorizationExecuteWithPrivileges(authorizationRef,[tool UTF8String],0,args,&commPipe);
if (status != errAuthorizationSuccess) {
NSAlert *alert = [NSAlert alertWithMessageText:@"Authorization failed" defaultButton:@"Quit" alternateButton:nil otherButton:nil informativeTextWithFormat:[NSString stringWithFormat:@"Authorization failed with code %d",status]];
[alert setAlertStyle:2];
NSInteger result = [alert runModal];
if (result == NSAlertDefaultReturn) {
[[NSApplication sharedApplication] terminate:self];
}
}
//second call for suid-bit //second call for suid-bit
tool=@"/bin/chmod"; tool=@"/bin/chmod";
argsArray = [NSArray arrayWithObjects: @"6555",smcpath,nil]; argsArray = [NSArray arrayWithObjects: @"6555",smcpath,nil];
@ -765,6 +783,15 @@ NSUserDefaults *defaults;
} }
args[i] = NULL; args[i] = NULL;
status=AuthorizationExecuteWithPrivileges(authorizationRef,[tool UTF8String],0,args,&commPipe); status=AuthorizationExecuteWithPrivileges(authorizationRef,[tool UTF8String],0,args,&commPipe);
if (status != errAuthorizationSuccess) {
NSAlert *alert = [NSAlert alertWithMessageText:@"Authorization failed" defaultButton:@"Quit" alternateButton:nil otherButton:nil informativeTextWithFormat:[NSString stringWithFormat:@"Authorization failed with code %d",status]];
[alert setAlertStyle:2];
NSInteger result = [alert runModal];
if (result == NSAlertDefaultReturn) {
[[NSApplication sharedApplication] terminate:self];
}
}
} }

View File

@ -27,8 +27,10 @@
- (id)init:(NSString*)p_machine{ - (id)init:(NSString*)p_machine{
machine=[MachineDefaults computerModel]; if (self = [super init]){
supported_machines=[[NSArray alloc] initWithContentsOfFile:[[[NSFileManager defaultManager] applicationSupportDirectory] stringByAppendingPathComponent:@"Machines.plist"]]; machine=[MachineDefaults computerModel];
supported_machines=[[NSArray alloc] initWithContentsOfFile:[[[NSFileManager defaultManager] applicationSupportDirectory] stringByAppendingPathComponent:@"Machines.plist"]];
}
return self; return self;
} }
@ -83,7 +85,7 @@
[xmldata writeToFile:[[[NSFileManager defaultManager] applicationSupportDirectory] stringByAppendingPathComponent:@"Machines.plist"] atomically:YES]; [xmldata writeToFile:[[[NSFileManager defaultManager] applicationSupportDirectory] stringByAppendingPathComponent:@"Machines.plist"] atomically:YES];
[supported_m release]; [supported_m release];
//return new machine-live-data //return new machine-live-data
return [new_machine retain]; return new_machine;
} }

View File

@ -107,7 +107,7 @@ static NSArray *allSensors = nil;
SMCVal_t val; SMCVal_t val;
int totalFans; int totalFans;
SMCReadKey2("FNum", &val,conn); SMCReadKey2("FNum", &val,conn);
totalFans = _strtoul(val.bytes, val.dataSize, 10); totalFans = _strtoul((char *)val.bytes, val.dataSize, 10);
return totalFans; return totalFans;
} }

View File

@ -131,7 +131,7 @@ void printFPE2(SMCVal_t val)
void printUInt(SMCVal_t val) void printUInt(SMCVal_t val)
{ {
printf("%u ", (unsigned int) _strtoul(val.bytes, val.dataSize, 10)); printf("%u ", (unsigned int) _strtoul((char *)val.bytes, val.dataSize, 10));
} }
void printSP1E(SMCVal_t val) void printSP1E(SMCVal_t val)
@ -468,7 +468,7 @@ UInt32 SMCReadIndexCount(void)
SMCVal_t val; SMCVal_t val;
SMCReadKey("#KEY", &val); SMCReadKey("#KEY", &val);
return _strtoul(val.bytes, val.dataSize, 10); return _strtoul((char *)val.bytes, val.dataSize, 10);
} }
kern_return_t SMCPrintAll(void) kern_return_t SMCPrintAll(void)
@ -515,7 +515,7 @@ kern_return_t SMCPrintFans(void)
if (result != kIOReturnSuccess) if (result != kIOReturnSuccess)
return kIOReturnError; return kIOReturnError;
totalFans = _strtoul(val.bytes, val.dataSize, 10); totalFans = _strtoul((char *)val.bytes, val.dataSize, 10);
printf("Total fans in system: %d\n", totalFans); printf("Total fans in system: %d\n", totalFans);
for (i = 0; i < totalFans; i++) for (i = 0; i < totalFans; i++)
@ -540,7 +540,7 @@ kern_return_t SMCPrintFans(void)
SMCReadKey(key, &val); SMCReadKey(key, &val);
printf(" Target speed : %.0f\n", _strtof(val.bytes, val.dataSize, 2)); printf(" Target speed : %.0f\n", _strtof(val.bytes, val.dataSize, 2));
SMCReadKey("FS! ", &val); SMCReadKey("FS! ", &val);
if ((_strtoul(val.bytes, 2, 16) & (1 << i)) == 0) if ((_strtoul((char *)val.bytes, 2, 16) & (1 << i)) == 0)
printf(" Mode : auto\n"); printf(" Mode : auto\n");
else else
printf(" Mode : forced\n"); printf(" Mode : forced\n");

View File

@ -301,7 +301,15 @@
29B97313FDCFA39411CA2CEA /* Project object */ = { 29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 0440; LastUpgradeCheck = 0510;
TargetAttributes = {
8924ECED15AC96E70031730C = {
DevelopmentTeam = MC98392EJC;
};
8D1107260486CEB800E47090 = {
DevelopmentTeam = MC98392EJC;
};
};
}; };
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "smcFanControl" */; buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "smcFanControl" */;
compatibilityVersion = "Xcode 3.2"; compatibilityVersion = "Xcode 3.2";
@ -423,10 +431,10 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Developer ID Application: Hendrik Holtmann"; CODE_SIGN_IDENTITY = "Mac Developer";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO; GCC_DYNAMIC_NO_PIC = NO;
@ -442,7 +450,7 @@
ONLY_ACTIVE_ARCH = NO; ONLY_ACTIVE_ARCH = NO;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE = "";
SDKROOT = macosx10.9; SDKROOT = macosx;
}; };
name = Debug; name = Debug;
}; };
@ -450,10 +458,10 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Developer ID Application: Hendrik Holtmann"; CODE_SIGN_IDENTITY = "Mac Developer";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer";
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
@ -466,15 +474,14 @@
MACOSX_DEPLOYMENT_TARGET = 10.5; MACOSX_DEPLOYMENT_TARGET = 10.5;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE = "";
SDKROOT = macosx10.9; SDKROOT = macosx;
}; };
name = Release; name = Release;
}; };
C01FCF4B08A954540054247B /* Debug */ = { C01FCF4B08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; CODE_SIGN_IDENTITY = "Mac Developer: Yancheng Zheng (5FNT3EVMK3)";
CODE_SIGN_IDENTITY = "Developer ID Application: Hendrik Holtmann";
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
@ -498,7 +505,7 @@
ONLY_ACTIVE_ARCH = NO; ONLY_ACTIVE_ARCH = NO;
PRODUCT_NAME = smcFanControl; PRODUCT_NAME = smcFanControl;
PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE = "";
SDKROOT = macosx10.9; SDKROOT = macosx;
WRAPPER_EXTENSION = app; WRAPPER_EXTENSION = app;
ZERO_LINK = YES; ZERO_LINK = YES;
}; };
@ -507,8 +514,7 @@
C01FCF4C08A954540054247B /* Release */ = { C01FCF4C08A954540054247B /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; CODE_SIGN_IDENTITY = "Mac Developer: Yancheng Zheng (5FNT3EVMK3)";
CODE_SIGN_IDENTITY = "Developer ID Application: Hendrik Holtmann";
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
@ -531,7 +537,7 @@
ONLY_ACTIVE_ARCH = NO; ONLY_ACTIVE_ARCH = NO;
PRODUCT_NAME = smcFanControl; PRODUCT_NAME = smcFanControl;
PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE = "";
SDKROOT = macosx10.9; SDKROOT = macosx;
VALID_ARCHS = "i386 x86_64"; VALID_ARCHS = "i386 x86_64";
WRAPPER_EXTENSION = app; WRAPPER_EXTENSION = app;
}; };
@ -540,15 +546,14 @@
C01FCF4F08A954540054247B /* Debug */ = { C01FCF4F08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
GCC_VERSION = com.apple.compilers.llvmgcc42; GCC_VERSION = com.apple.compilers.llvmgcc42;
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.5; MACOSX_DEPLOYMENT_TARGET = 10.5;
ONLY_ACTIVE_ARCH = NO; ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "-fnested-functions"; OTHER_CFLAGS = "-fnested-functions";
OTHER_LDFLAGS = ""; OTHER_LDFLAGS = "";
SDKROOT = macosx10.7; SDKROOT = macosx;
VALID_ARCHS = "i386 x86_64"; VALID_ARCHS = "i386 x86_64";
}; };
name = Debug; name = Debug;
@ -556,7 +561,6 @@
C01FCF5008A954540054247B /* Release */ = { C01FCF5008A954540054247B /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
GCC_VERSION = com.apple.compilers.llvmgcc42; GCC_VERSION = com.apple.compilers.llvmgcc42;
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
@ -564,7 +568,7 @@
ONLY_ACTIVE_ARCH = NO; ONLY_ACTIVE_ARCH = NO;
OTHER_CFLAGS = "-fnested-functions"; OTHER_CFLAGS = "-fnested-functions";
OTHER_LDFLAGS = ""; OTHER_LDFLAGS = "";
SDKROOT = macosx10.7; SDKROOT = macosx;
SYMROOT = "~/builds"; SYMROOT = "~/builds";
VALID_ARCHS = "i386 x86_64"; VALID_ARCHS = "i386 x86_64";
}; };