X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/ca0a920d902e70044e20bbd4efd993e5d63789e7..c9f3aa21b5f00bb40fc836f25758c357bf7d4efa:/cydo.cpp diff --git a/cydo.cpp b/cydo.cpp index 89b4323f..168d3c8a 100644 --- a/cydo.cpp +++ b/cydo.cpp @@ -1,3 +1,24 @@ +/* Cydia - iPhone UIKit Front-End for Debian APT + * Copyright (C) 2008-2015 Jay Freeman (saurik) +*/ + +/* GNU General Public License, Version 3 {{{ */ +/* + * Cydia is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * Cydia is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Cydia. If not, see . +**/ +/* }}} */ + #include #include @@ -18,7 +39,7 @@ void launch_data_dict_iterate(launch_data_t data, LaunchDataIterator code) { } int main(int argc, char *argv[]) { - FILE *log(fopen("/tmp/cydia.log", "a+")); + auto log(fopen("/tmp/cydia.log", "a+")); fprintf(log, "cydo:"); for (int arg(1); arg < argc; ++arg) fprintf(log, " %s", argv[arg]); @@ -31,9 +52,9 @@ int main(int argc, char *argv[]) { _assert(response != NULL); _assert(launch_data_get_type(response) == LAUNCH_DATA_DICTIONARY); - int parent(getppid()); + auto parent(getppid()); - bool cydia(false); + auto cydia(false); launch_data_dict_iterate(response, [=, &cydia](const char *name, launch_data_t value) { if (launch_data_get_type(response) != LAUNCH_DATA_DICTIONARY) @@ -47,6 +68,19 @@ int main(int argc, char *argv[]) { if (pid != parent) return; + auto variables(launch_data_dict_lookup(value, LAUNCH_JOBKEY_ENVIRONMENTVARIABLES)); + if (variables != NULL && launch_data_get_type(variables) == LAUNCH_DATA_DICTIONARY) { + auto dyld(false); + + launch_data_dict_iterate(variables, [&dyld](const char *name, launch_data_t value) { + if (strncmp(name, "DYLD_", 5) == 0) + dyld = true; + }); + + if (dyld) + return; + } + auto string(launch_data_dict_lookup(value, LAUNCH_JOBKEY_PROGRAM)); if (string == NULL || launch_data_get_type(string) != LAUNCH_DATA_STRING) { auto array(launch_data_dict_lookup(value, LAUNCH_JOBKEY_PROGRAMARGUMENTS)); @@ -64,7 +98,6 @@ int main(int argc, char *argv[]) { if (program == NULL) return; - fprintf(log, "%lld %s\n", pid, program); if (strcmp(program, "/Applications/Cydia.app/Cydia") == 0) cydia = true; });