Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.
C++ 3d3d-sculptingcppdear-imguidigital-sculptingfbxgame-developmentgaussian-splattinggltfimage-to-3dmcpopenglopenusdsculptingtext-to-3dunreal-engine
Live mode on macOS: a socket path too long for sun_path (long $TMPDIR) falls back to a short owner-only /tmp folder
islandmedd5feb0ea0b2b
diff --git a/src/link/AiLink.cpp b/src/link/AiLink.cppindex da2e600b..f68d08c3 100644--- a/src/link/AiLink.cpp+++ b/src/link/AiLink.cpp@@ -193,6 +193,11 @@ std::string aiLinkEndpoint(std::string& error) {while (base.size() > 1 && base.back() == '/') base.pop_back();dir = base + "/sculptforge-" + std::to_string(::getuid());}+ // A Unix socket path must fit sun_path (104 bytes on macOS, whose $TMPDIR and test folders are long): then a+ // short owner-only folder in /tmp, one per original folder so isolated runs never share the user's socket.+ if (dir.size() + sizeof("/ai-live.sock") > sizeof(sockaddr_un{}.sun_path))+ dir = "/tmp/sf-live-" + std::to_string(::getuid()) + "-" ++ std::to_string(std::hash<std::string>{}(dir) % 1000000007u);if (!safeDir(dir, error)) return {};return dir + "/ai-live.sock";#endifdiff --git a/tests/test_ai_link.cpp b/tests/test_ai_link.cppindex 15a6dfa0..7166eb3f 100644--- a/tests/test_ai_link.cpp+++ b/tests/test_ai_link.cpp@@ -203,7 +203,7 @@ TEST(ai_link_socket_permissions_and_disconnect) {std::string err;const std::string endpoint = aiLinkEndpoint(err);CHECK(!endpoint.empty());- CHECK(aiLinkFileMode(run + "/sculptforge") == 0700);+ CHECK(aiLinkFileMode(std::filesystem::path(endpoint).parent_path().string()) == 0700);AiLinkListener listener;CHECK(listener.open(endpoint, err));@@ -256,6 +256,27 @@ TEST(ai_link_socket_permissions_and_disconnect) {else unsetenv("XDG_RUNTIME_DIR");}+TEST(ai_link_long_runtime_folder_still_listens) {+ // macOS: $TMPDIR (and so test folders) is long, and a socket path must fit sun_path (104 bytes there).+ const std::string run = scratchDir("sf_ai_link_long_runtime_folder_padding_padding_padding_padding_padding_padding");+ const char* old = std::getenv("XDG_RUNTIME_DIR");+ const std::string saved = old ? old : "";+ setenv("XDG_RUNTIME_DIR", run.c_str(), 1);+ std::string err;+ const std::string endpoint = aiLinkEndpoint(err);+ CHECK(!endpoint.empty() && endpoint.size() < 100);+ CHECK(aiLinkFileMode(std::filesystem::path(endpoint).parent_path().string()) == 0700);+ AiLinkListener listener;+ CHECK(listener.open(endpoint, err));+ AiLinkConn client, server;+ CHECK(aiLinkConnect(client, endpoint, err));+ CHECK(listener.accept(server, 2000));+ listener.close();+ std::filesystem::remove(std::filesystem::path(endpoint).parent_path());+ if (old) setenv("XDG_RUNTIME_DIR", saved.c_str(), 1);+ else unsetenv("XDG_RUNTIME_DIR");+}+TEST(ai_link_attach_end_to_end) {// sculptforge-cli --mcp --attach against a stand-in app: live_connect waits, the code pairs, tools are forwarded.const std::string run = scratchDir("sf_ai_link_attach");