From f7f32d9a12b75e8e7e57326de881cc8609f738ed Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 2 Jul 2015 07:54:47 -0700 Subject: Cydia no longer runs as root. (WE FINALLY DID IT!) --- MobileCydia.app/Cydia | 6 ------ MobileCydia.mm | 54 +++------------------------------------------------ makefile | 3 +-- 3 files changed, 4 insertions(+), 59 deletions(-) delete mode 100755 MobileCydia.app/Cydia diff --git a/MobileCydia.app/Cydia b/MobileCydia.app/Cydia deleted file mode 100755 index 572af7b..0000000 --- a/MobileCydia.app/Cydia +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -C=/${0} -C=${C%/*} -declare -a flags -[[ :${DYLD_INSERT_LIBRARIES}: == */MobileSubstrate.dylib: ]] && flags[${#flags[@]}]=--substrate -exec "${C:-.}"/MobileCydia "${flags[@]}" -- "$@" 2>>/tmp/cydia.log diff --git a/MobileCydia.mm b/MobileCydia.mm index 612cd23..3c0ffa9 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -237,35 +237,6 @@ union SplitHash { }; // }}} -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_; @@ -9307,12 +9278,10 @@ _end - (void) _uicache { _trace(); - if (UpgradeCydia_ && Finish_ > 0) { - setreugid(0, 0); - system("su -c /usr/bin/uicache mobile"); - } else { + if (UpgradeCydia_ && Finish_ > 0) + system("/usr/libexec/cydia/cydo /bin/su -c /usr/bin/uicache mobile"); + else system("/usr/bin/uicache"); - } _trace(); } @@ -10099,8 +10068,6 @@ MSHook(id, NSUserDefaults$objectForKey$, NSUserDefaults *self, SEL _cmd, NSStrin } int main(int argc, char *argv[]) { - setreugid(501, 501); - NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]); _trace(); @@ -10417,21 +10384,6 @@ int main(int argc, char *argv[]) { Finishes_ = [NSArray arrayWithObjects:@"return", @"reopen", @"restart", @"reload", @"reboot", nil]; -#define MobileSubstrate_(name) \ - if (substrate && access("/Library/MobileSubstrate/DynamicLibraries/" #name ".dylib", F_OK) == 0) { \ - void *handle(dlopen("/Library/MobileSubstrate/DynamicLibraries/" #name ".dylib", RTLD_LAZY | RTLD_GLOBAL)); \ - if (handle == NULL) \ - NSLog(@"%s", dlerror()); \ - } - - MobileSubstrate_(Activator) - MobileSubstrate_(libstatusbar) - MobileSubstrate_(SimulatedKeyEvents) - MobileSubstrate_(WinterBoard) - - /*if (substrate && access("/Library/MobileSubstrate/MobileSubstrate.dylib", F_OK) == 0) - dlopen("/Library/MobileSubstrate/MobileSubstrate.dylib", RTLD_LAZY | RTLD_GLOBAL);*/ - if (kCFCoreFoundationVersionNumber > 1000) system("/usr/libexec/cydia/cydo /usr/libexec/cydia/setnsfpn /var/lib"); diff --git a/makefile b/makefile index 0d5506b..86b4784 100644 --- a/makefile +++ b/makefile @@ -167,7 +167,7 @@ debs/cydia_$(version)_iphoneos-arm.deb: MobileCydia preinst postinst cfversion s mkdir -p _/Applications cp -a MobileCydia.app _/Applications/Cydia.app rm -rf _/Applications/Cydia.app/*.lproj - cp -a MobileCydia _/Applications/Cydia.app/MobileCydia + cp -a MobileCydia _/Applications/Cydia.app/Cydia cd MobileCydia.app && find . -name '*.png' -exec cp -af ../Images/MobileCydia.app/{} ../_/Applications/Cydia.app/{} ';' @@ -183,7 +183,6 @@ debs/cydia_$(version)_iphoneos-arm.deb: MobileCydia preinst postinst cfversion s sudo chown -R 0 _ sudo chgrp -R 0 _ - sudo chmod 6755 _/Applications/Cydia.app/MobileCydia mkdir -p debs ln -sf debs/cydia_$(version)_iphoneos-arm.deb Cydia.deb -- cgit v1.2.3