From e76bab7644ed000da9f0df7a0a6b828f40a95b0f Mon Sep 17 00:00:00 2001 From: Jon Williams Date: Fri, 2 Feb 2018 14:27:19 -0500 Subject: [PATCH] Basic initialization of Mac sandbox without extended profile --- include/sandbox.hpp | 5 +++++ src/main.cpp | 2 ++ src/sandbox.cpp | 28 ++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 include/sandbox.hpp create mode 100644 src/sandbox.cpp diff --git a/include/sandbox.hpp b/include/sandbox.hpp new file mode 100644 index 00000000..3d59a4f5 --- /dev/null +++ b/include/sandbox.hpp @@ -0,0 +1,5 @@ +#pragma once + +namespace rack { +bool sandboxInit(); +} diff --git a/src/main.cpp b/src/main.cpp index bc32af17..62ea55fb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,7 @@ #include "engine.hpp" #include "gui.hpp" #include "app.hpp" +#include "sandbox.hpp" #include "plugin.hpp" #include "settings.hpp" #include "asset.hpp" @@ -31,6 +32,7 @@ int main(int argc, char* argv[]) { info("Local directory: %s", localDir.c_str()); } + sandboxInit(); pluginInit(); engineInit(); guiInit(); diff --git a/src/sandbox.cpp b/src/sandbox.cpp new file mode 100644 index 00000000..daad09eb --- /dev/null +++ b/src/sandbox.cpp @@ -0,0 +1,28 @@ +#include "sandbox.hpp" +#include "util.hpp" +namespace rack { +#if defined(ARCH_MAC) +#include + +bool sandboxInit() { + char* error_buff = NULL; + //int error = sandbox_init(final_sandbox_profile_str.c_str(), 0, &error_buff); + int error = sandbox_init(kSBXProfileNoInternet, SANDBOX_NAMED, &error_buff); + bool success = (error == 0 && error_buff == NULL); + if(!success) { + info("Sandbox initialization error (%d): %s", error, error_buff); + } else { + info("Sandbox initialized!"); + } + sandbox_free_error(error_buff); + + return success; +} + + +#else + bool sandboxInit() { + return false; + } +#endif +}