Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions open_terminal/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ def _resolve_file_env(var: str, default: str = "") -> str:
config.get("user_prefix", ""),
)

USER_GROUP = os.environ.get(
"OPEN_TERMINAL_USER_GROUP",
config.get("user_group", ""),
)

UVICORN_LOOP = os.environ.get(
"OPEN_TERMINAL_UVICORN_LOOP",
config.get("uvicorn_loop", "auto"),
Expand Down
5 changes: 5 additions & 0 deletions open_terminal/utils/user_isolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def ensure_os_user(username: str) -> str:
for reads while other provisioned users still get ``Permission denied``.
Returns the home directory path.
"""
from open_terminal.env import USER_GROUP

try:
pw = pwd.getpwnam(username)
return pw.pw_dir
Expand All @@ -100,6 +102,9 @@ def ensure_os_user(username: str) -> str:
# different UID assignment) and set permissions.
_run_privileged(["chown", "-R", f"{username}:{username}", home_dir])
_run_privileged(["chmod", "2770", home_dir])
# Optionally add the OS user to a shared group
if USER_GROUP:
_run_privileged(["usermod", "-aG", USER_GROUP, username])
# Add the server process user to the new user's group so Python can
# read files natively without subprocess.
server_user = os.getenv("USER", "user")
Expand Down