From 532925a6089bc451e2ab0c950d0e1db92c13620f Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 21 Dec 2020 00:12:40 +0000 Subject: [PATCH] Remove plugins from macOS quarentine before running them --- source/backend/engine/CarlaEngine.cpp | 8 ++++++++ source/backend/plugin/CarlaPluginJuce.cpp | 2 ++ source/backend/plugin/CarlaPluginLV2.cpp | 14 ++++++++++++++ source/bridges-ui/CarlaBridgeFormatLV2.cpp | 9 +++++++++ source/discovery/carla-discovery.cpp | 16 ++++++++++++++++ source/utils/CarlaMacUtils.cpp | 7 +++++++ source/utils/CarlaMacUtils.hpp | 5 +++++ 7 files changed, 61 insertions(+) diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index 1d9467c10..65c56a02d 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -565,6 +565,8 @@ bool CarlaEngine::addPlugin(const BinaryType btype, } const bool canBeBridged = ptype != PLUGIN_INTERNAL + && ptype != PLUGIN_DLS + && ptype != PLUGIN_GIG && ptype != PLUGIN_SF2 && ptype != PLUGIN_SFZ && ptype != PLUGIN_JACK; @@ -573,6 +575,12 @@ bool CarlaEngine::addPlugin(const BinaryType btype, bool preferBridges = pData->options.preferPluginBridges; const char* needsArchBridge = nullptr; +#ifdef CARLA_OS_MAC + // Plugin might be in quarentine due to Apple stupid notarization rules, let's remove that if possible + if (canBeBridged && ptype != PLUGIN_LV2 && ptype != PLUGIN_AU) + removeFileFromQuarantine(filename); +#endif + #ifndef BUILD_BRIDGE if (canBeBridged && ! preferBridges) { diff --git a/source/backend/plugin/CarlaPluginJuce.cpp b/source/backend/plugin/CarlaPluginJuce.cpp index e0822a2f0..cd238bcb2 100644 --- a/source/backend/plugin/CarlaPluginJuce.cpp +++ b/source/backend/plugin/CarlaPluginJuce.cpp @@ -1411,6 +1411,8 @@ public: for (int i = 0; i < fFormatManager.getNumFormats(); ++i) { juce::AudioPluginFormat* const format = fFormatManager.getFormat(i); + CARLA_SAFE_ASSERT_CONTINUE(format != nullptr); + carla_debug("Trying to load '%s' plugin with format '%s'", fileOrIdentifier.toRawUTF8(), format->getName().toRawUTF8()); try { diff --git a/source/backend/plugin/CarlaPluginLV2.cpp b/source/backend/plugin/CarlaPluginLV2.cpp index ce1f79909..cc74c805d 100644 --- a/source/backend/plugin/CarlaPluginLV2.cpp +++ b/source/backend/plugin/CarlaPluginLV2.cpp @@ -41,6 +41,10 @@ extern "C" { #include "water/files/File.h" #include "water/misc/Time.h" +#ifdef CARLA_OS_MAC +# include "CarlaMacUtils.hpp" +#endif + #include #include @@ -6296,6 +6300,11 @@ public: // --------------------------------------------------------------- // open DLL +#ifdef CARLA_OS_MAC + // Binary might be in quarentine due to Apple stupid notarization rules, let's remove that if possible + removeFileFromQuarantine(fRdfDescriptor->Binary); +#endif + if (! pData->libOpen(fRdfDescriptor->Binary)) { pData->engine->setLastError(pData->libError(fRdfDescriptor->Binary)); @@ -6961,6 +6970,11 @@ public: // --------------------------------------------------------------- // open UI DLL +#ifdef CARLA_OS_MAC + // Binary might be in quarentine due to Apple stupid notarization rules, let's remove that if possible + removeFileFromQuarantine(fUI.rdfDescriptor->Binary); +#endif + if (! pData->uiLibOpen(fUI.rdfDescriptor->Binary, canDelete)) { carla_stderr2("Could not load UI library, error was:\n%s", pData->libError(fUI.rdfDescriptor->Binary)); diff --git a/source/bridges-ui/CarlaBridgeFormatLV2.cpp b/source/bridges-ui/CarlaBridgeFormatLV2.cpp index 72d263758..6eb279065 100644 --- a/source/bridges-ui/CarlaBridgeFormatLV2.cpp +++ b/source/bridges-ui/CarlaBridgeFormatLV2.cpp @@ -25,6 +25,10 @@ #include "water/files/File.h" +#ifdef CARLA_OS_MAC +# include "CarlaMacUtils.hpp" +#endif + #include #include @@ -512,6 +516,11 @@ public: // ------------------------------------------------------------------------------------------------------------ // open DLL +#ifdef CARLA_OS_MAC + // Binary might be in quarentine due to Apple stupid notarization rules, let's remove that if possible + CarlaBackend::removeFileFromQuarantine(fRdfUiDescriptor->Binary); +#endif + if (! libOpen(fRdfUiDescriptor->Binary)) { carla_stderr("Failed to load UI binary, error was:\n%s", libError()); diff --git a/source/discovery/carla-discovery.cpp b/source/discovery/carla-discovery.cpp index d45e6a12a..766d8955c 100644 --- a/source/discovery/carla-discovery.cpp +++ b/source/discovery/carla-discovery.cpp @@ -63,6 +63,7 @@ # undef Component # undef MemoryBlock # undef Point +# include "CarlaMacUtils.cpp" #endif #ifdef CARLA_OS_WIN @@ -1753,6 +1754,21 @@ int main(int argc, char* argv[]) } #endif +#ifdef CARLA_OS_MAC + // Plugin might be in quarentine due to Apple stupid notarization rules, let's remove that if possible + switch (type) + { + case PLUGIN_LADSPA: + case PLUGIN_DSSI: + case PLUGIN_VST2: + case PLUGIN_VST3: + removeFileFromQuarantine(filename); + break; + default: + break; + } +#endif + switch (type) { case PLUGIN_LADSPA: diff --git a/source/utils/CarlaMacUtils.cpp b/source/utils/CarlaMacUtils.cpp index abc79a35b..d5e2edc45 100644 --- a/source/utils/CarlaMacUtils.cpp +++ b/source/utils/CarlaMacUtils.cpp @@ -20,6 +20,8 @@ #include "CarlaMacUtils.hpp" #include "CarlaString.hpp" +#include + #import CARLA_BACKEND_START_NAMESPACE @@ -54,6 +56,11 @@ const char* findBinaryInBundle(const char* const bundleDir) return ret.buffer(); } +bool removeFileFromQuarantine(const char* const filename) +{ + return removexattr(filename, "com.apple.quarantine", 0) == 0; +} + // -------------------------------------------------------------------------------------------------------------------- AutoNSAutoreleasePool::AutoNSAutoreleasePool() diff --git a/source/utils/CarlaMacUtils.hpp b/source/utils/CarlaMacUtils.hpp index bb455879b..9753da824 100644 --- a/source/utils/CarlaMacUtils.hpp +++ b/source/utils/CarlaMacUtils.hpp @@ -33,6 +33,11 @@ CARLA_BACKEND_START_NAMESPACE */ const char* findBinaryInBundle(const char* const bundleDir); +/* + * ... + */ +bool removeFileFromQuarantine(const char* const filename); + /* * ... */