From 489c97b8a84399d4210a4d5a75a8e5257923c350 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sat, 10 Oct 2015 17:09:28 -0700 Subject: Add hacky flags to turn off more complex features. --- ldid.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ldid.cpp b/ldid.cpp index 6667b96..9619daf 100644 --- a/ldid.cpp +++ b/ldid.cpp @@ -42,10 +42,12 @@ #include #include +#ifndef LDID_NOSMIME #include #include #include #include +#endif #ifdef __APPLE__ #include @@ -65,7 +67,9 @@ #define LDID_SHA1_Final SHA1_Final #endif +#ifndef LDID_NOPLIST #include +#endif #include "ldid.hpp" @@ -74,11 +78,20 @@ #define _assert__(line) \ _assert___(line) +#ifdef __EXCEPTIONS #define _assert_(expr, format, ...) \ do if (!(expr)) { \ fprintf(stderr, "%s(%u): _assert(): " format "\n", __FILE__, __LINE__, ## __VA_ARGS__); \ throw __FILE__ "(" _assert__(__LINE__) "): _assert(" #expr ")"; \ } while (false) +#else +// XXX: this is not acceptable +#define _assert_(expr, format, ...) \ + do if (!(expr)) { \ + fprintf(stderr, "%s(%u): _assert(): " format "\n", __FILE__, __LINE__, ## __VA_ARGS__); \ + exit(-1); \ + } while (false) +#endif #define _assert(expr) \ _assert_(expr, "%s", #expr) @@ -1204,6 +1217,7 @@ static size_t put(std::streambuf &output, uint32_t magic, const Blobs &blobs) { return offset; } +#ifndef LDID_NOSMIME class Buffer { private: BIO *bio_; @@ -1317,6 +1331,7 @@ class Signature { return value_; } }; +#endif class NullBuffer : public std::streambuf @@ -1547,6 +1562,7 @@ void Sign(const void *idata, size_t isize, std::streambuf &output, const std::st insert(blobs, CSSLOT_CODEDIRECTORY, CSMAGIC_CODEDIRECTORY, data); } +#ifndef LDID_NOSMIME if (!key.empty()) { std::stringbuf data; const std::string &sign(blobs[CSSLOT_CODEDIRECTORY]); @@ -1561,6 +1577,7 @@ void Sign(const void *idata, size_t isize, std::streambuf &output, const std::st insert(blobs, CSSLOT_SIGNATURESLOT, CSMAGIC_BLOBWRAPPER, data); } +#endif return put(output, CSMAGIC_EMBEDDED_SIGNATURE, blobs); })); @@ -1728,6 +1745,7 @@ static size_t copy(std::streambuf &source, std::streambuf &target) { return total; } +#ifndef LDID_NOPLIST static plist_t plist(const std::string &data) { plist_t plist(NULL); if (Starts(data, "bplist00")) @@ -1755,6 +1773,7 @@ static std::string plist_s(plist_t node) { _scope({ free(data); }); return data; } +#endif enum Mode { NoMode, @@ -1831,6 +1850,7 @@ struct RuleCode { } }; +#ifndef LDID_NOPLIST std::string Bundle(const std::string &root, Folder &folder, const std::string &key, std::map> &remote, const std::string &entitlements) { std::string executable; std::string identifier; @@ -2006,11 +2026,14 @@ std::string Bundle(const std::string &root, Folder &folder, const std::string &k return executable; } +#endif } int main(int argc, char *argv[]) { +#ifndef LDID_NOSMIME OpenSSL_add_all_algorithms(); +#endif union { uint16_t word; @@ -2159,10 +2182,14 @@ int main(int argc, char *argv[]) { _syscall(stat(path.c_str(), &info)); if (S_ISDIR(info.st_mode)) { +#ifndef LDID_NOPLIST _assert(!flag_r); ldid::DiskFolder folder(path); std::map> hashes; path += "/" + Bundle("", folder, key, hashes, entitlements); +#else + _assert(false); +#endif } else if (flag_S || flag_r) { Map input(path, O_RDONLY, PROT_READ, MAP_PRIVATE); -- cgit v1.2.3-56-ge451