From b28496c7b615099258899c128b255312af8f376f Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Tue, 5 Aug 2025 18:43:16 -0500 Subject: [PATCH] macos fixes --- .../librepertory/src/drives/fuse/fuse_base.cpp | 10 ++++++++++ .../librepertory/src/drives/fuse/fuse_drive.cpp | 2 -- .../librepertory/src/utils/unix/unix_utils.cpp | 16 ++++++++++++++-- .../include/fixtures/fuse_fixture.hpp | 4 ++++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/repertory/librepertory/src/drives/fuse/fuse_base.cpp b/repertory/librepertory/src/drives/fuse/fuse_base.cpp index 9adfe1f2..eaf92cc9 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_base.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_base.cpp @@ -456,6 +456,15 @@ auto fuse_base::mount([[maybe_unused]] std::vector orig_args, return -1; } + system(fmt::format("launchctl bootout gui/{} '{}' 1>/dev/null 2>&1", + getuid(), + utils::path::combine("~", + { + "/Library/LaunchAgents", + fmt::format("{}.plist", label), + })) + .c_str()); + system(fmt::format("launchctl bootstrap gui/{} '{}' 1>/dev/null 2>&1", getuid(), utils::path::combine("~", @@ -464,6 +473,7 @@ auto fuse_base::mount([[maybe_unused]] std::vector orig_args, fmt::format("{}.plist", label), })) .c_str()); + ret = system( fmt::format("launchctl kickstart gui/{}/{}", getuid(), label).c_str()); if (ret != 0) { diff --git a/repertory/librepertory/src/drives/fuse/fuse_drive.cpp b/repertory/librepertory/src/drives/fuse/fuse_drive.cpp index 5a3eeb3c..4f213070 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_drive.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_drive.cpp @@ -502,8 +502,6 @@ auto fuse_drive::getattr_impl(std::string api_path, struct stat *u_stat, auto fuse_drive::getattr_impl(std::string api_path, struct stat *u_stat) -> api_error { #endif - auto parent = utils::path::get_parent_api_path(api_path); - auto res = check_parent_access(api_path, X_OK); if (res != api_error::success) { return res; diff --git a/repertory/librepertory/src/utils/unix/unix_utils.cpp b/repertory/librepertory/src/utils/unix/unix_utils.cpp index 8bf55435..9cb766c2 100644 --- a/repertory/librepertory/src/utils/unix/unix_utils.cpp +++ b/repertory/librepertory/src/utils/unix/unix_utils.cpp @@ -19,6 +19,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include #if !defined(_WIN32) #include "utils/unix/unix_utils.hpp" @@ -277,7 +278,6 @@ auto create_daemon(std::function main_func) -> int { signal(SIGHUP, SIG_DFL); signal(SIGPIPE, SIG_IGN); - umask(0); chdir("/"); return main_func(); #else // !defined(__APPLE__) @@ -297,7 +297,6 @@ auto create_daemon(std::function main_func) -> int { return 1; } - umask(0); chdir("/"); return main_func(); } @@ -333,6 +332,19 @@ auto generate_launchd_plist(const std::string &label, std::string plist_path, array.append_child("string").text().set(arg.c_str()); } + dict.append_child("key").text().set("EnvironmentVariables"); + pugi::xml_node env_dict = dict.append_child("dict"); + if (not utils::get_environment_variable("PROJECT_TEST_CONFIG_DIR").empty()) { + env_dict.append_child("key").text().set("PROJECT_TEST_CONFIG_DIR"); + env_dict.append_child("string").text().set( + utils::get_environment_variable("PROJECT_TEST_CONFIG_DIR")); + } + if (not utils::get_environment_variable("PROJECT_TEST_INPUT_DIR").empty()) { + env_dict.append_child("key").text().set("PROJECT_TEST_INPUT_DIR"); + env_dict.append_child("string").text().set( + utils::get_environment_variable("PROJECT_TEST_INPUT_DIR")); + } + dict.append_child("key").text().set("WorkingDirectory"); dict.append_child("string").text().set(working_dir.c_str()); diff --git a/repertory/repertory_test/include/fixtures/fuse_fixture.hpp b/repertory/repertory_test/include/fixtures/fuse_fixture.hpp index be55050a..b7bcb5c8 100644 --- a/repertory/repertory_test/include/fixtures/fuse_fixture.hpp +++ b/repertory/repertory_test/include/fixtures/fuse_fixture.hpp @@ -349,6 +349,8 @@ public: } static void execute_mount(auto args, auto location) { + EXPECT_TRUE(utils::file::change_to_process_directory()); + args.emplace_back(location); auto mount_cmd = "./repertory " + utils::string::join(args, ' '); std::cout << "mount command: " << mount_cmd << std::endl; @@ -359,6 +361,8 @@ public: } static void execute_unmount(auto args) { + EXPECT_TRUE(utils::file::change_to_process_directory()); + args.emplace_back("-unmount"); auto unmount_cmd = "./repertory " + utils::string::join(args, ' '); std::cout << "unmount command: " << unmount_cmd << std::endl;