X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/06325acfa9b258fd7ab170880a4050fe8c4394b6..5ecd43c35e8a5bb666624af9ab6279ccc78c7cf2:/cydo.cpp diff --git a/cydo.cpp b/cydo.cpp index 1bc2a22c..d6e6f758 100644 --- a/cydo.cpp +++ b/cydo.cpp @@ -28,6 +28,8 @@ #include +#include + #include typedef Function LaunchDataIterator; @@ -50,8 +52,14 @@ int main(int argc, char *argv[]) { auto cydia(false); + struct stat correct; + if (lstat("/Applications/Cydia.app/Cydia", &correct) == -1) { + fprintf(stderr, "you have no arms left"); + return EX_NOPERM; + } + launch_data_dict_iterate(response, [=, &cydia](const char *name, launch_data_t value) { - if (launch_data_get_type(response) != LAUNCH_DATA_DICTIONARY) + if (launch_data_get_type(value) != LAUNCH_DATA_DICTIONARY) return; auto integer(launch_data_dict_lookup(value, LAUNCH_JOBKEY_PID)); @@ -92,12 +100,16 @@ int main(int argc, char *argv[]) { if (program == NULL) return; - if (strcmp(program, "/Applications/Cydia.app/Cydia") == 0) + struct stat check; + if (lstat(program, &check) == -1) + return; + + if (correct.st_dev == check.st_dev && correct.st_ino == check.st_ino) cydia = true; }); if (!cydia) { - fprintf(stderr, "thou shalt not pass\n"); + fprintf(stderr, "none shall pass\n"); return EX_NOPERM; }