From f2eb981cf8d20ab013d559fa7d383e656954f12d Mon Sep 17 00:00:00 2001 From: Cameron Katri Date: Tue, 19 Jul 2022 21:55:49 -0400 Subject: Fix -S -M and -s on .app bundles (Closes #18) --- ldid.cpp | 18 +++++++++--------- ldid.hpp | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ldid.cpp b/ldid.cpp index 1703da0..9a9339b 100644 --- a/ldid.cpp +++ b/ldid.cpp @@ -2822,7 +2822,7 @@ struct State { } }; -Bundle Sign(const std::string &root, Folder &parent, const std::string &key, State &local, const std::string &requirements, const Functor &alter, const Progress &progress) { +Bundle Sign(const std::string &root, Folder &parent, const std::string &key, State &local, const std::string &requirements, const Functor &alter, bool merge, const Progress &progress) { std::string executable; std::string identifier; @@ -2930,7 +2930,7 @@ Bundle Sign(const std::string &root, Folder &parent, const std::string &key, Sta State remote; bundles[nested[1]] = Sign(root + bundle, subfolder, key, remote, "", Starts(name, "PlugIns/") ? alter : static_cast &>(fun([&](const std::string &, const std::string &) -> std::string { return entitlements; })) - , progress); + , merge, progress); local.Merge(bundle, remote); }), fun([&](const std::string &name, const Functor &read) { })); @@ -3114,16 +3114,16 @@ Bundle Sign(const std::string &root, Folder &parent, const std::string &key, Sta Slots slots; slots[1] = local.files.at(info); slots[3] = local.files.at(signature); - bundle.hash = Sign(NULL, 0, buffer, local.files[executable], save, identifier, entitlements, false, requirements, key, slots, length, 0, false, Progression(progress, root + executable)); + bundle.hash = Sign(NULL, 0, buffer, local.files[executable], save, identifier, entitlements, merge, requirements, key, slots, length, 0, false, Progression(progress, root + executable)); })); })); return bundle; } -Bundle Sign(const std::string &root, Folder &folder, const std::string &key, const std::string &requirements, const Functor &alter, const Progress &progress) { +Bundle Sign(const std::string &root, Folder &folder, const std::string &key, const std::string &requirements, const Functor &alter, bool merge, const Progress &progress) { State local; - return Sign(root, folder, key, local, requirements, alter, progress); + return Sign(root, folder, key, local, requirements, alter, merge, progress); } #endif @@ -3434,13 +3434,13 @@ int main(int argc, char *argv[]) { } if (S_ISDIR(info.st_mode)) { - if (!flag_S) { - fprintf(stderr, "ldid: Only -S can be used on directories\n"); + if (!flag_S && !flag_s) { + fprintf(stderr, "ldid: Only -S and -s can be used on directories\n"); exit(1); } ldid::DiskFolder folder(path + "/"); - path += "/" + Sign("", folder, key, requirements, ldid::fun([&](const std::string &, const std::string &) -> std::string { return entitlements; }), dummy_).path; - } else if (flag_S || flag_r) { + path += "/" + Sign("", folder, key, requirements, ldid::fun([&](const std::string &, const std::string &) -> std::string { return entitlements; }), flag_M, dummy_).path; + } else if (flag_S || flag_r || flag_s) { Map input(path, O_RDONLY, PROT_READ, MAP_PRIVATE); std::filebuf output; diff --git a/ldid.hpp b/ldid.hpp index 1e46f56..ef77477 100644 --- a/ldid.hpp +++ b/ldid.hpp @@ -157,7 +157,7 @@ struct Bundle { Hash hash; }; -Bundle Sign(const std::string &root, Folder &folder, const std::string &key, const std::string &requirements, const Functor &alter, const Progress &progress); +Bundle Sign(const std::string &root, Folder &folder, const std::string &key, const std::string &requirements, const Functor &alter, bool merge, const Progress &progress); typedef std::map Slots; -- cgit v1.2.3-56-ge451