X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/6218c58ce1228c98d2fc8da5ff22fb23b01c051b..9e738e51025fb8e0cc7ca6ff872b1756c9ce84d4:/MobileCydia.mm diff --git a/MobileCydia.mm b/MobileCydia.mm index 7316a245..e0adf360 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -239,29 +239,29 @@ union SplitHash { }; // }}} -static void setreugid(uid_t uid, gid_t gid) { - _assert(setreuid(uid, uid) != -1); - _assert(setregid(gid, gid) != -1); -} +#define seteugid(uid, gid) do { \ + _assert(setreuid(0, uid) != -1); \ + _assert(setregid(0, gid) != -1); \ +} while (false) -static void setreguid(gid_t gid, uid_t uid) { - _assert(setregid(gid, gid) != -1); - _assert(setreuid(uid, uid) != -1); -} +#define seteguid(uid, gid) do { \ + _assert(setregid(0, gid) != -1); \ + _assert(setreuid(0, uid) != -1); \ +} while (false) struct Root { Root() { _trace(); - setreugid(0, 0); + seteugid(0, 0); _assert(pthread_setugid_np(0, 0) != -1); - setreguid(501, 501); + seteguid(501, 501); } ~Root() { _trace(); - setreugid(0, 0); + seteugid(0, 0); _assert(pthread_setugid_np(KAUTH_UID_NONE, KAUTH_GID_NONE) != -1); - setreguid(501, 501); + seteguid(501, 501); } }; @@ -4956,6 +4956,10 @@ static _H Diversions_; return [CydiaWebViewController requestWithHeaders:[super webView:view resource:resource willSendRequest:request redirectResponse:response fromDataSource:source]]; } +- (NSURLRequest *) webThreadWebView:(WebView *)view resource:(id)resource willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source { + return [CydiaWebViewController requestWithHeaders:[super webThreadWebView:view resource:resource willSendRequest:request redirectResponse:response fromDataSource:source]]; +} + + (NSURLRequest *) requestWithHeaders:(NSURLRequest *)request { NSMutableURLRequest *copy([[request mutableCopy] autorelease]); @@ -7124,9 +7128,11 @@ static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachabi // on the iPad, this view controller is ALSO visible. :( if (IsWildcat_) - if (UIViewController *top = [self topViewController]) - if (top != visible) - [top reloadData]; + if (UIViewController *modal = [self modalViewController]) + if ([modal modalPresentationStyle] == UIModalPresentationFormSheet) + if (UIViewController *top = [self topViewController]) + if (top != visible) + [top reloadData]; } - (void) unloadData { @@ -8619,7 +8625,7 @@ static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachabi case 1: { NSString *href = [[alert textField] text]; - static Pcre href_r("^http(s?)://[^# ]*$"); + static Pcre href_r("^(http(s?)://|file:///)[^# ]*$"); if (!href_r(href)) { UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:Colon_, Error_, UCLocalize("INVALID_URL")] @@ -9229,8 +9235,6 @@ _end - (void) presentModalViewController:(UIViewController *)controller force:(BOOL)force { UINavigationController *navigation([[[UINavigationController alloc] initWithRootViewController:controller] autorelease]); - if (IsWildcat_) - [navigation setModalPresentationStyle:UIModalPresentationFormSheet]; UIViewController *parent; if (emulated_ == nil) @@ -9242,6 +9246,8 @@ _end parent = tabbar_; } + if (IsWildcat_) + [navigation setModalPresentationStyle:UIModalPresentationFormSheet]; [parent presentModalViewController:navigation animated:YES]; } @@ -9379,7 +9385,7 @@ _end _trace(); if (UpgradeCydia_ && Finish_ > 0) { - setreugid(0, 0); + seteugid(0, 0); system("su -c /usr/bin/uicache mobile"); } else { system("/usr/bin/uicache"); @@ -10164,7 +10170,8 @@ MSHook(id, NSUserDefaults$objectForKey$, NSUserDefaults *self, SEL _cmd, NSStrin } int main(int argc, char *argv[]) { - setreugid(501, 501); + seteugid(0, 0); + seteguid(501, 501); NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]); @@ -10515,8 +10522,7 @@ int main(int argc, char *argv[]) { dlopen("/Library/MobileSubstrate/MobileSubstrate.dylib", RTLD_LAZY | RTLD_GLOBAL);*/ if (kCFCoreFoundationVersionNumber > 1000) - for (const char *path : (const char *[]) {"/var/lib", "/var/cache"}) - _root(system([[NSString stringWithFormat:@"/usr/libexec/cydia/setnsfpn %s", path] UTF8String])); + _root(system([[NSString stringWithFormat:@"/usr/libexec/cydia/setnsfpn /var/lib"] UTF8String])); int version([[NSString stringWithContentsOfFile:@"/var/lib/cydia/firmware.ver"] intValue]);