From de3b1ab45842f7265fae101aae296d1a2d9b7ae6 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 15 Oct 2008 08:31:39 +0000 Subject: [PATCH 1/1] Quick detour to get Cydia Safe Mode working. --- Cydia.app/Cydia | 4 +++- Cydia.mm | 26 ++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Cydia.app/Cydia b/Cydia.app/Cydia index f0c76fcc..8356734e 100755 --- a/Cydia.app/Cydia +++ b/Cydia.app/Cydia @@ -1,3 +1,5 @@ #!/bin/bash Cydia=$(dirname "$0") -exec "${Cydia}"/Cydia_ 2>>/tmp/cydia.log +declare -a flags +[[ :${DYLD_INSERT_LIBRARIES}: == */MobileSubstrate.dylib: ]] && flags[${#flags[@]}]=--substrate +exec "${Cydia}"/Cydia_ "${flags[@]}" -- "$@" 2>>/tmp/cydia.log diff --git a/Cydia.mm b/Cydia.mm index 0b92c4f3..be88a41f 100644 --- a/Cydia.mm +++ b/Cydia.mm @@ -7258,7 +7258,29 @@ id Dealloc_(id self, SEL selector) { }*/ int main(int argc, char *argv[]) { _pooled - bootstrap_ = argc > 1 && strcmp(argv[1], "--bootstrap") == 0; + bool substrate(false); + + if (argc != 0) { + char **args(argv); + int arge(1); + + for (int argi(1); argi != argc; ++argi) + if (strcmp(argv[argi], "--") == 0) { + arge = argi; + argv[argi] = argv[0]; + argv += argi; + argc -= argi; + break; + } + + for (int argi(1); argi != arge; ++argi) + if (strcmp(args[argi], "--bootstrap") == 0) + bootstrap_ = true; + else if (strcmp(args[argi], "--substrate") == 0) + substrate = true; + else + fprintf(stderr, "unknown argument: %s\n", args[argi]); + } App_ = [[NSBundle mainBundle] bundlePath]; Home_ = NSHomeDirectory(); @@ -7345,7 +7367,7 @@ int main(int argc, char *argv[]) { _pooled Documents_ = [[[NSMutableArray alloc] initWithCapacity:4] autorelease]; #endif - if (access("/Library/MobileSubstrate/MobileSubstrate.dylib", F_OK) == 0) + if (substrate && access("/Library/MobileSubstrate/MobileSubstrate.dylib", F_OK) == 0) dlopen("/Library/MobileSubstrate/MobileSubstrate.dylib", RTLD_LAZY | RTLD_GLOBAL); if (access("/User", F_OK) != 0) -- 2.45.2