};
// }}}
+static void setreugid(uid_t uid, gid_t gid) {
+ _assert(setreuid(uid, uid) != -1);
+ _assert(setregid(gid, gid) != -1);
+}
+
+static void setreguid(gid_t gid, uid_t uid) {
+ _assert(setregid(gid, gid) != -1);
+ _assert(setreuid(uid, uid) != -1);
+}
+
+struct Root {
+ Root() {
+ _trace();
+ setreugid(0, 0);
+ _assert(pthread_setugid_np(0, 0) != -1);
+ setreguid(501, 501);
+ }
+
+ ~Root() {
+ _trace();
+ setreugid(0, 0);
+ _assert(pthread_setugid_np(KAUTH_UID_NONE, KAUTH_GID_NONE) != -1);
+ setreguid(501, 501);
+ }
+};
+
+#define _root(code) \
+ ({ Root _root; code; })
+
static NSString *Colon_;
NSString *Elision_;
static NSString *Error_;
static NSString *Warning_;
static NSString *Cache_;
+#define Cache(file) \
+ [NSString stringWithFormat:@"%@/%s", Cache_, file]
static void (*$SBSSetInterceptsMenuButtonForever)(bool);
if ([dicon hasPrefix:@"file:///"])
icon = [UIImage imageAtPath:[[dicon substringFromIndex:7] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
if (icon == nil)
- icon = [UIImage applicationImageNamed:@"unknown.png"];
+ icon = [UIImage imageNamed:@"unknown.png"];
return icon;
}
}
_end
+ _root(_system->Lock());
+
_trace();
OpProgress progress;
bool opened;
open:
_profile(reloadDataWithInvocation$pkgCacheFile)
- opened = cache_.Open(progress, true);
+ opened = cache_.Open(progress, false);
_end
if (!opened) {
// XXX: what if there are errors, but Open() == true? this should be merged with popError:
}
}
+ _system->UnLock();
return;
}
_trace();
- (void) configure {
NSString *dpkg = [NSString stringWithFormat:@"dpkg --configure -a --status-fd %u", statusfd_];
_trace();
- system([dpkg UTF8String]);
+ _root(system([dpkg UTF8String]));
_trace();
}
RestartSubstrate_ = true;
_system->UnLock();
- pkgPackageManager::OrderResult result = manager_->DoInstall(statusfd_);
+ pkgPackageManager::OrderResult result(_root(manager_->DoInstall(statusfd_)));
if ([self popErrorWithTitle:title])
return;
_assert(close(fds[0]) != -1);
_assert(close(fds[1]) != -1);
/* XXX: this should probably not use du */
- execl("/usr/libexec/cydia/du", "du", "-s", [path UTF8String], NULL);
+ _root(execl("/usr/libexec/cydia/du", "du", "-s", [path UTF8String], NULL));
exit(1);
} else {
_assert(close(fds[1]) != -1);
if ([context isEqualToString:@"remove"]) {
if (button == [alert cancelButtonIndex])
- [self dismissModalViewControllerAnimated:YES];
+ [self _doContinue];
else if (button == [alert firstOtherButtonIndex]) {
[self performSelector:@selector(complete) withObject:nil afterDelay:0];
}
pid_t pid(ExecFork());
if (pid == 0) {
- execl("/usr/bin/sbreload", "sbreload", NULL);
+ _root(execl("/usr/bin/sbreload", "sbreload", NULL));
perror("sbreload");
exit(0);
- (id) initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
if ((self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) != nil) {
- icon_ = [UIImage applicationImageNamed:@"folder.png"];
+ icon_ = [UIImage imageNamed:@"folder.png"];
// XXX: this initial frame is wrong, but is fixed later
switch_ = [[[UISwitch alloc] initWithFrame:CGRectMake(218, 9, 60, 25)] autorelease];
[switch_ addTarget:self action:@selector(onSwitch:) forEvents:UIControlEventValueChanged];
if ([context isEqualToString:@"modify"]) {
if (button != [sheet cancelButtonIndex]) {
- [self _clickButtonWithName:buttons_[button].first];
+ [self performSelector:@selector(_clickButtonWithName:) withObject:buttons_[button].first afterDelay:0];
}
[sheet dismissWithClickedButtonIndex:-1 animated:YES];
path = [path stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
UIImage *icon([UIImage imageAtPath:[NSString stringWithFormat:@"%@/Sections/%@.png", App_, [path stringByReplacingOccurrencesOfString:@" " withString:@"_"]]]);
if (icon == nil)
- icon = [UIImage applicationImageNamed:@"unknown.png"];
+ icon = [UIImage imageNamed:@"unknown.png"];
[self _returnPNGWithImage:icon forRequest:request];
} else fail: {
[client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
pid_t pid(ExecFork());
if (pid == 0) {
- FILE *dpkg(popen("dpkg --set-selections", "w"));
+ FILE *dpkg(_root(popen("dpkg --set-selections", "w")));
fwrite(package, strlen(package), 1, dpkg);
if (on)
[self setFetch:[NSNumber numberWithBool:[source_ fetch]]];
- icon_ = [UIImage applicationImageNamed:@"unknown.png"];
+ icon_ = [UIImage imageNamed:@"unknown.png"];
origin_ = [source name];
label_ = [source rooturi];
source_ = nil;
[indicator_ stopAnimating];
- icon_ = [UIImage applicationImageNamed:@"folder.png"];
+ icon_ = [UIImage imageNamed:@"folder.png"];
origin_ = UCLocalize("ALL_SOURCES");
label_ = UCLocalize("ALL_SOURCES_EX");
[content_ setNeedsDisplay];
[super storeCachedResponse:cached forRequest:request];
}
+- (void) createDiskCachePath {
+ [super createDiskCachePath];
+ _root(chown([[self diskCachePath] UTF8String], 501, 501));
+}
+
@end
@interface Cydia : UIApplication <
_H<UIWindow> window_;
_H<CydiaTabBarController> tabbar_;
_H<CyteTabBarController> emulated_;
+ _H<AppCacheController> appcache_;
_H<NSMutableArray> essential_;
_H<NSMutableArray> broken_;
if (NSData *data = [NSPropertyListSerialization dataFromPropertyList:Metadata_ format:NSPropertyListBinaryFormat_v1_0 errorDescription:&error]) {
_trace();
NSError *error(nil);
- if (![data writeToFile:@"/var/lib/cydia/metadata.plist" options:NSAtomicWrite error:&error])
+ if (!_root([data writeToFile:@"/var/lib/cydia/metadata.plist" options:NSAtomicWrite error:&error]))
NSLog(@"failure to save metadata data: %@", error);
_trace();
}
}
- CydiaWriteSources();
+ _root(CydiaWriteSources());
}
// Navigation controller for the queuing badge.
bool recently = false;
if (update != nil) {
NSTimeInterval interval([update timeIntervalSinceNow]);
- if (interval <= 0 && interval > -(15*60))
+ if (interval > -(15*60))
recently = true;
}
[self setApplicationIconBadgeNumber:0];
}
+ Queuing_ = false;
[self _updateData];
if (hud != nil)
- (void) _uicache {
_trace();
- system("su -c /usr/bin/uicache mobile");
+ system("/usr/bin/uicache");
_trace();
}
@synchronized (self) {
for (Package *broken in (id) broken_) {
[broken remove];
-
NSString *id = [broken id];
- unlink([[NSString stringWithFormat:@"/var/lib/dpkg/info/%@.prerm", id] UTF8String]);
- unlink([[NSString stringWithFormat:@"/var/lib/dpkg/info/%@.postrm", id] UTF8String]);
- unlink([[NSString stringWithFormat:@"/var/lib/dpkg/info/%@.preinst", id] UTF8String]);
- unlink([[NSString stringWithFormat:@"/var/lib/dpkg/info/%@.postinst", id] UTF8String]);
+
+ _root({
+ unlink([[NSString stringWithFormat:@"/var/lib/dpkg/info/%@.prerm", id] UTF8String]);
+ unlink([[NSString stringWithFormat:@"/var/lib/dpkg/info/%@.postrm", id] UTF8String]);
+ unlink([[NSString stringWithFormat:@"/var/lib/dpkg/info/%@.preinst", id] UTF8String]);
+ unlink([[NSString stringWithFormat:@"/var/lib/dpkg/info/%@.postinst", id] UTF8String]);
+ });
}
[self resolve];
NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
_trace();
- system([command UTF8String]);
+ _root(system([command UTF8String]));
_trace();
[pool release];
return true;
}
+- (void) suspendReturningToLastApp:(BOOL)returning {
+ if ([self isSafeToSuspend])
+ [super suspendReturningToLastApp:returning];
+}
+
+- (void) suspend {
+ if ([self isSafeToSuspend])
+ [super suspend];
+}
+
+- (void) applicationSuspend {
+ if ([self isSafeToSuspend])
+ [super applicationSuspend];
+}
+
- (void) applicationSuspend:(__GSEvent *)event {
if ([self isSafeToSuspend])
[super applicationSuspend:event];
[self saveState];
}
+- (void) applicationDidEnterBackground:(UIApplication *)application {
+ [self saveState];
+}
+
+- (void) applicationWillEnterForeground:(UIApplication *)application {
+ NSDate *closed = [Metadata_ objectForKey:@"LastClosed"];
+ if (closed == nil)
+ return;
+
+ NSTimeInterval interval([closed timeIntervalSinceNow]);
+
+ if (interval <= -(30)) {
+ [tabbar_ setSelectedIndex:0];
+ [[[tabbar_ viewControllers] objectAtIndex:0] popToRootViewControllerAnimated:NO];
+ }
+
+ if (interval <= -(15)) {
+ if (IsReachable("cydia.saurik.com")) {
+ [tabbar_ beginUpdate];
+ [appcache_ reloadURLWithCache:YES];
+ }
+ }
+}
+
- (void) setConfigurationData:(NSString *)data {
static Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
NSMutableArray *items;
if (kCFCoreFoundationVersionNumber < 800) {
items = [NSMutableArray arrayWithObjects:
- [[[UITabBarItem alloc] initWithTitle:@"Cydia" image:[UIImage applicationImageNamed:@"home.png"] tag:0] autorelease],
- [[[UITabBarItem alloc] initWithTitle:UCLocalize("SOURCES") image:[UIImage applicationImageNamed:@"install.png"] tag:0] autorelease],
- [[[UITabBarItem alloc] initWithTitle:UCLocalize("CHANGES") image:[UIImage applicationImageNamed:@"changes.png"] tag:0] autorelease],
- [[[UITabBarItem alloc] initWithTitle:UCLocalize("INSTALLED") image:[UIImage applicationImageNamed:@"manage.png"] tag:0] autorelease],
- [[[UITabBarItem alloc] initWithTitle:UCLocalize("SEARCH") image:[UIImage applicationImageNamed:@"search.png"] tag:0] autorelease],
+ [[[UITabBarItem alloc] initWithTitle:@"Cydia" image:[UIImage imageNamed:@"home.png"] tag:0] autorelease],
+ [[[UITabBarItem alloc] initWithTitle:UCLocalize("SOURCES") image:[UIImage imageNamed:@"install.png"] tag:0] autorelease],
+ [[[UITabBarItem alloc] initWithTitle:UCLocalize("CHANGES") image:[UIImage imageNamed:@"changes.png"] tag:0] autorelease],
+ [[[UITabBarItem alloc] initWithTitle:UCLocalize("INSTALLED") image:[UIImage imageNamed:@"manage.png"] tag:0] autorelease],
+ [[[UITabBarItem alloc] initWithTitle:UCLocalize("SEARCH") image:[UIImage imageNamed:@"search.png"] tag:0] autorelease],
nil];
} else {
items = [NSMutableArray arrayWithObjects:
- [[[UITabBarItem alloc] initWithTitle:@"Cydia" image:[UIImage applicationImageNamed:@"home7.png"] selectedImage:[UIImage applicationImageNamed:@"home7s.png"]] autorelease],
- [[[UITabBarItem alloc] initWithTitle:UCLocalize("SOURCES") image:[UIImage applicationImageNamed:@"install7.png"] selectedImage:[UIImage applicationImageNamed:@"install7s.png"]] autorelease],
- [[[UITabBarItem alloc] initWithTitle:UCLocalize("CHANGES") image:[UIImage applicationImageNamed:@"changes7.png"] selectedImage:[UIImage applicationImageNamed:@"changes7s.png"]] autorelease],
- [[[UITabBarItem alloc] initWithTitle:UCLocalize("INSTALLED") image:[UIImage applicationImageNamed:@"manage7.png"] selectedImage:[UIImage applicationImageNamed:@"manage7s.png"]] autorelease],
- [[[UITabBarItem alloc] initWithTitle:UCLocalize("SEARCH") image:[UIImage applicationImageNamed:@"search7.png"] selectedImage:[UIImage applicationImageNamed:@"search7s.png"]] autorelease],
+ [[[UITabBarItem alloc] initWithTitle:@"Cydia" image:[UIImage imageNamed:@"home7.png"] selectedImage:[UIImage imageNamed:@"home7s.png"]] autorelease],
+ [[[UITabBarItem alloc] initWithTitle:UCLocalize("SOURCES") image:[UIImage imageNamed:@"install7.png"] selectedImage:[UIImage imageNamed:@"install7s.png"]] autorelease],
+ [[[UITabBarItem alloc] initWithTitle:UCLocalize("CHANGES") image:[UIImage imageNamed:@"changes7.png"] selectedImage:[UIImage imageNamed:@"changes7s.png"]] autorelease],
+ [[[UITabBarItem alloc] initWithTitle:UCLocalize("INSTALLED") image:[UIImage imageNamed:@"manage7.png"] selectedImage:[UIImage imageNamed:@"manage7s.png"]] autorelease],
+ [[[UITabBarItem alloc] initWithTitle:UCLocalize("SEARCH") image:[UIImage imageNamed:@"search7.png"] selectedImage:[UIImage imageNamed:@"search7s.png"]] autorelease],
nil];
}
[NSURLCache setSharedURLCache:[[[CYURLCache alloc]
initWithMemoryCapacity:524288
diskCapacity:10485760
- diskPath:[NSString stringWithFormat:@"%@/SDURLCache", Cache_]
+ diskPath:Cache("SDURLCache")
] autorelease]];
[CydiaWebViewController _initialize];
broken_ = [NSMutableArray arrayWithCapacity:4];
// XXX: I really need this thing... like, seriously... I'm sorry
- [[[AppCacheController alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/appcache/", UI_]]] reloadData];
+ appcache_ = [[[AppCacheController alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/appcache/", UI_]]] autorelease];
+ [appcache_ reloadData];
window_ = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
[window_ orderFront:self];
NSDate *closed = [Metadata_ objectForKey:@"LastClosed"];
if (valid && closed != nil) {
NSTimeInterval interval([closed timeIntervalSinceNow]);
- // XXX: Is 30 minutes the optimal time here?
if (interval <= -(30*60))
valid = NO;
}
return object;
}*/
-static NSSet *MobilizedFiles_;
-
-static NSURL *MobilizeURL(NSURL *url) {
- NSString *path([url path]);
- if ([path hasPrefix:@"/var/root/"]) {
- NSString *file([path substringFromIndex:10]);
- if ([MobilizedFiles_ containsObject:file])
- url = [NSURL fileURLWithPath:[@"/var/mobile/" stringByAppendingString:file] isDirectory:NO];
- }
-
- return url;
-}
-
-Class $CFXPreferencesPropertyListSource;
-@class CFXPreferencesPropertyListSource;
-
-MSHook(BOOL, CFXPreferencesPropertyListSource$_backingPlistChangedSinceLastSync, CFXPreferencesPropertyListSource *self, SEL _cmd) {
- NSURL *&url(MSHookIvar<NSURL *>(self, "_url")), *old(url);
- NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
-
- url = MobilizeURL(url);
- BOOL value; @try {
- value = _CFXPreferencesPropertyListSource$_backingPlistChangedSinceLastSync(self, _cmd);
- //NSLog(@"CFX %@ %s", [url absoluteString], value ? "YES" : "NO");
- } @finally {
- url = old;
- }
-
- [pool release];
- return value;
-}
-
-MSHook(void *, CFXPreferencesPropertyListSource$createPlistFromDisk, CFXPreferencesPropertyListSource *self, SEL _cmd) {
- NSURL *&url(MSHookIvar<NSURL *>(self, "_url")), *old(url);
- NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
-
- url = MobilizeURL(url);
- void *value; @try {
- value = _CFXPreferencesPropertyListSource$createPlistFromDisk(self, _cmd);
- //NSLog(@"CFX %@ %@", [url absoluteString], value);
- } @finally {
- url = old;
- }
-
- [pool release];
- return value;
-}
-
Class $NSURLConnection;
MSHook(id, NSURLConnection$init$, NSURLConnection *self, SEL _cmd, NSURLRequest *request, id delegate, BOOL usesCache, int64_t maxContentLength, BOOL startImmediately, NSDictionary *connectionProperties) {
MSHook(id, NSUserDefaults$objectForKey$, NSUserDefaults *self, SEL _cmd, NSString *key) {
if ([key respondsToSelector:@selector(isEqualToString:)] && [key isEqualToString:@"WebKitLocalStorageDatabasePathPreferenceKey"])
- return [NSString stringWithFormat:@"%@/LocalStorage", Cache_];
+ return Cache("LocalStorage");
return _NSUserDefaults$objectForKey$(self, _cmd, key);
}
int main(int argc, char *argv[]) {
+ setreugid(501, 501);
+
NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);
_trace();
PackageName = reinterpret_cast<CYString &(*)(Package *, SEL)>(method_getImplementation(class_getInstanceMethod([Package class], @selector(cyname))));
- MobilizedFiles_ = [NSMutableSet setWithObjects:
- @"Library/Preferences/.GlobalPreferences.plist",
- @"Library/Preferences/com.apple.Accessibility.plist",
- @"Library/Preferences/com.apple.preferences.sounds.plist",
- nil];
-
/* Library Hacks {{{ */
class_addMethod(objc_getClass("DOMNodeList"), @selector(countByEnumeratingWithState:objects:count:), (IMP) &DOMNodeList$countByEnumeratingWithState$objects$count$, "I20@0:4^{NSFastEnumerationState}8^@12I16");
if (Method method = class_getInstanceMethod($WAKWindow, @selector(screenSize)))
method_setImplementation(method, (IMP) &$WAKWindow$screenSize);
- $CFXPreferencesPropertyListSource = objc_getClass("CFXPreferencesPropertyListSourceSynchronizer");
- if ($CFXPreferencesPropertyListSource == Nil)
- $CFXPreferencesPropertyListSource = objc_getClass("CFXPreferencesPropertyListSource");
-
- Method CFXPreferencesPropertyListSource$_backingPlistChangedSinceLastSync(class_getInstanceMethod($CFXPreferencesPropertyListSource, @selector(_backingPlistChangedSinceLastSync)));
- if (CFXPreferencesPropertyListSource$_backingPlistChangedSinceLastSync != NULL) {
- _CFXPreferencesPropertyListSource$_backingPlistChangedSinceLastSync = reinterpret_cast<BOOL (*)(CFXPreferencesPropertyListSource *, SEL)>(method_getImplementation(CFXPreferencesPropertyListSource$_backingPlistChangedSinceLastSync));
- method_setImplementation(CFXPreferencesPropertyListSource$_backingPlistChangedSinceLastSync, reinterpret_cast<IMP>(&$CFXPreferencesPropertyListSource$_backingPlistChangedSinceLastSync));
- }
-
- Method CFXPreferencesPropertyListSource$createPlistFromDisk(class_getInstanceMethod($CFXPreferencesPropertyListSource, @selector(createPlistFromDisk)));
- if (CFXPreferencesPropertyListSource$createPlistFromDisk != NULL) {
- _CFXPreferencesPropertyListSource$createPlistFromDisk = reinterpret_cast<void *(*)(CFXPreferencesPropertyListSource *, SEL)>(method_getImplementation(CFXPreferencesPropertyListSource$createPlistFromDisk));
- method_setImplementation(CFXPreferencesPropertyListSource$createPlistFromDisk, reinterpret_cast<IMP>(&$CFXPreferencesPropertyListSource$createPlistFromDisk));
- }
-
$NSURLConnection = objc_getClass("NSURLConnection");
Method NSURLConnection$init$(class_getInstanceMethod($NSURLConnection, @selector(_initWithRequest:delegate:usesCache:maxContentLength:startImmediately:connectionProperties:)));
if (NSURLConnection$init$ != NULL) {
App_ = [[NSBundle mainBundle] bundlePath];
Advanced_ = YES;
- setuid(0);
- setgid(0);
-
- if (access("/var/mobile/Library/Keyboard/UserDictionary.sqlite", F_OK) == 0)
- system("mkdir -p /var/root/Library/Keyboard; cp -af /var/mobile/Library/Keyboard/UserDictionary.sqlite /var/root/Library/Keyboard/");
-
- Cache_ = [[NSString stringWithFormat:@"%@/Library/Caches/com.saurik.Cydia", @"/var/root"] retain];
+ Cache_ = [[NSString stringWithFormat:@"%@/Library/Caches/com.saurik.Cydia", @"/var/mobile"] retain];
/*Method alloc = class_getClassMethod([NSObject class], @selector(alloc));
alloc_ = alloc->method_imp;
} broken = nil;
/* }}} */
- CydiaWriteSources();
+ _root(CydiaWriteSources());
_trace();
- MetaFile_.Open("/var/lib/cydia/metadata.cb0");
+ _root(MetaFile_.Open("/var/lib/cydia/metadata.cb0"));
_trace();
if (Packages_ != nil) {
if (access("/User", F_OK) != 0 || version != 6) {
_trace();
- system("/usr/libexec/cydia/firmware.sh");
+ _root(system("/usr/libexec/cydia/firmware.sh"));
_trace();
}
- _assert([[NSFileManager defaultManager]
- createDirectoryAtPath:@"/var/cache/apt/archives/partial"
- withIntermediateDirectories:YES
- attributes:nil
- error:NULL
- ]);
-
if (access("/tmp/cydia.chk", F_OK) == 0) {
- if (unlink("/var/cache/apt/pkgcache.bin") == -1)
+ if (unlink([Cache("pkgcache.bin") UTF8String]) == -1)
_assert(errno == ENOENT);
- if (unlink("/var/cache/apt/srcpkgcache.bin") == -1)
+ if (unlink([Cache("srcpkgcache.bin") UTF8String]) == -1)
_assert(errno == ENOENT);
}
//_config->Set("Acquire::http::Timeout", 15);
_config->Set("Acquire::http::MaxParallel", usermem >= 384 * 1024 * 1024 ? 16 : 3);
+
+ mkdir([Cache_ UTF8String], 0755);
+ mkdir([Cache("archives") UTF8String], 0755);
+ mkdir([Cache("archives/partial") UTF8String], 0755);
+ _config->Set("Dir::Cache", [Cache_ UTF8String]);
+
+ mkdir([Cache("lists") UTF8String], 0755);
+ mkdir([Cache("lists/partial") UTF8String], 0755);
+ mkdir([Cache("periodic") UTF8String], 0755);
+ _config->Set("Dir::State::Lists", [Cache("lists") UTF8String]);
/* }}} */
/* Color Choices {{{ */
space_ = CGColorSpaceCreateDeviceRGB();
//UIKeyboardDisableAutomaticAppearance();
/* }}} */
+ _root({
+ chown([Cache("ApplicationCache.db") UTF8String], 501, 501);
+ chown([Cache("Cache.db") UTF8String], 501, 501);
+ chown([Cache("Cache.db-shm") UTF8String], 501, 501);
+ chown([Cache("Cache.db-wal") UTF8String], 501, 501);
+ });
+
$SBSSetInterceptsMenuButtonForever = reinterpret_cast<void (*)(bool)>(dlsym(RTLD_DEFAULT, "SBSSetInterceptsMenuButtonForever"));
const char *symbol(kCFCoreFoundationVersionNumber >= 800 ? "MGGetBoolAnswer" : "GSSystemHasCapability");