summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2008-03-05 03:34:00 +0000
committerJay Freeman (saurik) <saurik@saurik.com>2008-03-05 03:34:00 +0000
commit51a1ffdf1cb0e523178958270347e3207c237159 (patch)
tree11bea12b08d890ab5b2e86227c9139cb8f8a0dc8
parenta330619672d9a8e91411f4fbe865417ee062d9da (diff)
Fixed FW_LEAST and added 'exec' for Installer compatibility.
-rw-r--r--Cydia.mm10
-rw-r--r--exec.mm66
-rw-r--r--makefile7
3 files changed, 76 insertions, 7 deletions
diff --git a/Cydia.mm b/Cydia.mm
index c24ec42..d221178 100644
--- a/Cydia.mm
+++ b/Cydia.mm
@@ -184,9 +184,9 @@ unsigned Minor_;
unsigned BugFix_;
#define FW_LEAST(major, minor, bugfix) \
- (major > Major_ || major == Major_ && \
- (minor > Minor_ || minor == Minor_ && \
- bugfix >= BugFix_))
+ (major < Major_ || major == Major_ && \
+ (minor < Minor_ || minor == Minor_ && \
+ bugfix <= BugFix_))
bool bootstrap_ = false;
@@ -3701,8 +3701,8 @@ int main(int argc, char *argv[]) {
NSArray *versions = [prover componentsSeparatedByString:@"."];
int count = [versions count];
Major_ = count > 0 ? [[versions objectAtIndex:0] intValue] : 0;
- Minor_ = count > 1 ? [[versions objectAtIndex:0] intValue] : 0;
- BugFix_ = count > 2 ? [[versions objectAtIndex:0] intValue] : 0;
+ Minor_ = count > 1 ? [[versions objectAtIndex:1] intValue] : 0;
+ BugFix_ = count > 2 ? [[versions objectAtIndex:2] intValue] : 0;
}
}
diff --git a/exec.mm b/exec.mm
new file mode 100644
index 0000000..751a84a
--- /dev/null
+++ b/exec.mm
@@ -0,0 +1,66 @@
+#include <Foundation/Foundation.h>
+#include <CoreFoundation/CoreFoundation.h>
+
+#include <sys/types.h>
+#include <pwd.h>
+#include <unistd.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+const char *Firmware_ = NULL;
+
+unsigned Major_;
+unsigned Minor_;
+unsigned BugFix_;
+
+#define FW_LEAST(major, minor, bugfix) \
+ (major < Major_ || major == Major_ && \
+ (minor < Minor_ || minor == Minor_ && \
+ bugfix <= BugFix_))
+
+int main(int argc, char *argv[]) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ if (NSDictionary *sysver = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"]) {
+ if (NSString *prover = [sysver valueForKey:@"ProductVersion"]) {
+ Firmware_ = strdup([prover cString]);
+ NSArray *versions = [prover componentsSeparatedByString:@"."];
+ int count = [versions count];
+ Major_ = count > 0 ? [[versions objectAtIndex:0] intValue] : 0;
+ Minor_ = count > 1 ? [[versions objectAtIndex:1] intValue] : 0;
+ BugFix_ = count > 2 ? [[versions objectAtIndex:2] intValue] : 0;
+ }
+ }
+
+ [pool release];
+
+ const char *user;
+ if (FW_LEAST(1,1,3))
+ user = "mobile";
+ else
+ user = "root";
+
+ if (argc == 1)
+ printf("%s\n", user);
+ else {
+ struct passwd *passwd = getpwnam(user);
+
+ if (setreuid(passwd->pw_uid, 0) == -1) {
+ perror("setreuid");
+ exit(1);
+ }
+
+ if (setregid(passwd->pw_gid, 0) == -1) {
+ perror("setregid");
+ exit(1);
+ }
+
+ if (execvp(argv[1], argv + 1) == -1) {
+ perror("execvp");
+ exit(1);
+ }
+ }
+
+ return 0;
+}
diff --git a/makefile b/makefile
index ad0db8a..76093ba 100644
--- a/makefile
+++ b/makefile
@@ -1,10 +1,13 @@
iPhone := 192.168.1.100
-all: Cydia
+all: Cydia exec
test: all
scp -p Cydia saurik@$(iPhone):/dat
ssh saurik@$(iPhone) /dat/Cydia
-Cydia: *.mm *.h makefile
+exec: exec.mm makefile
+ arm-apple-darwin-g++ -Wall -Werror -o $@ $< -framework Foundation -framework CoreFoundation -lobjc
+
+Cydia: Cydia.mm *.h makefile
arm-apple-darwin-g++ -fobjc-call-cxx-cdtors -g3 -O2 -Wall -Werror -o $@ $< -framework UIKit -framework IOKit -framework Foundation -framework CoreFoundation -framework CoreGraphics -framework GraphicsServices -lobjc -lapt-pkg -lpcre -fobjc-exceptions