Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: let managed accounts run terminal and Python tools on macOS (#16579)

Nilayef65f8cafcd3
diff --git a/studio/backend/core/inference/tool_confinement.py b/studio/backend/core/inference/tool_confinement.py
index 8b3e8f06d05..12a5b2b7fa4 100644
--- a/studio/backend/core/inference/tool_confinement.py
+++ b/studio/backend/core/inference/tool_confinement.py
@@ -549,6 +549,8 @@ def macos_profile(
# Network, mach, sysctl and shm grants filtered exactly as the owner's profile filters them.
*_macos_system_rules(writable_roots),
"(allow file-read-metadata)",
+ # dyld reads the root directory at launch and aborts the child if denied.
+ '(allow file-read-data (literal "/"))',
# Pseudo-devices only; the rest of /dev (other sessions' ttys, disks) stays denied.
'(allow file-read* file-write* (literal "/dev/null") (literal "/dev/zero") (literal "/dev/random")'
' (literal "/dev/urandom") (literal "/dev/tty") (literal "/dev/dtracehelper"))',
diff --git a/studio/backend/tests/test_account_tool_confinement.py b/studio/backend/tests/test_account_tool_confinement.py
index b93795ed093..3c873994845 100644
--- a/studio/backend/tests/test_account_tool_confinement.py
+++ b/studio/backend/tests/test_account_tool_confinement.py
@@ -116,6 +116,18 @@ def test_macos_profile_hides_install_root_then_allows_own_roots(tmp_path, monkey
assert argv[3:] == ["bash", "-c", "true"]
+ sys.platform != "darwin" or not tool_confinement.shutil.which("sandbox-exec"),
+ reason = "needs macOS sandbox-exec",
+)
+def test_macos_confined_child_starts_bash_and_python(tmp_path):
+ _seed(tmp_path)
+ out = run_as(ALICE, tools._bash_exec, "/bin/echo TOOL_TERMINAL_OK", session_id = "chat")
+ assert "TOOL_TERMINAL_OK" in out, out
+ out = run_as(ALICE, tools._python_exec, "print('TOOL_PYTHON_OK')", session_id = "chat")
+ assert "TOOL_PYTHON_OK" in out, out
+
+
def test_macos_profile_keeps_the_interpreter_readable_under_a_hidden_root(tmp_path, monkeypatch):
"""Later rules win: an interpreter prefix inside the install root must be allowed again."""
venv = tmp_path / "studio" / "unsloth_studio"