- Catch NotImplementedError as the primary fallback since os.access(..., effective_ids=True) is not implemented on Windows
- Also catch AttributeError, OSError, and TypeError as supplementary guards
- Prevents crashes when checking file writability on Windows platforms, primarily fixing directory listing operations (/files/list, stat, listdir)
Fixes#174
All LLM-exposed file endpoints (list_files, read_file, write_file,
display_file, replace_file_content, grep_search, glob_search) now
read the X-Session-Id header and resolve relative paths against the
session's working directory instead of always using fs.home.
- Added optional cwd parameter to UserFS.resolve_path()
- Relative paths join against cwd if provided, else fs.home
- Absolute paths are unaffected
- execute endpoint also resolves relative cwd param against session cwd
_chown() transferred file ownership to the provisioned user but didn't
set group-write permission, leaving files at 644. The server process
(a group member) could create new files but couldn't overwrite them on
subsequent saves, returning PermissionError. Now sets chmod g+w after
chown, matching the 2770 treatment already applied to directories.
Fixes#93
Directories created by run_command (as the provisioned user via sudo -u)
get default 755 permissions, leaving the server process without group-write.
Both makedirs (creating subdirs) and aiofiles.open (creating files) fail
with EPERM.
UserFS._ensure_parents now:
- Creates directories as the provisioned user (sudo -u mkdir -p) to bypass
755 restrictions on existing parent directories
- Sets 2770 (setgid + group rwx) on all intermediate directories up to the
user's home, matching the home directory's permissions
- Falls through to plain makedirs in single-user mode (no behavior change)
Closes#70
- get_system_info() no longer includes 'as user user' when MULTI_USER is
active, removing the hint that caused smaller LLMs to hardcode /home/user
- resolve_path() now rewrites /home/usr → actual user home, matching the
existing /home/user rewrite
Closes#57
Added is_path_allowed() to UserFS and wired it into all directory
traversal code paths. In multi-user mode, entries belonging to other
users' home directories are now filtered out during os.walk/os.listdir,
preventing file listing leaks when searching parent directories like
/home. Single-user mode is unaffected (early return on username=None).
- Add resolve_path() to UserFS that resolves relative paths against
self.home instead of os.getcwd()
- Replace all os.path.abspath() calls in route handlers with
fs.resolve_path()
- Auto-swap /home/user → provisioned user home for hardcoded paths
- Add fs dependency to grep_search and glob_search endpoints
Replace all subprocess-based writes (sudo tee, mkdir -p, rm -rf, mv)
with native Python I/O. The only subprocess left is 'sudo chown' for
ownership fixup after writes.
- chmod 2770 (setgid + group rwx) on home dirs so native writes work
- write/write_bytes: aiofiles.open + chown
- mkdir: os.makedirs + chown
- remove: shutil.rmtree / os.remove (no chown needed)
- move: shutil.move + chown
- UserFS._check_path blocks access to other users' /home/<user>/ paths
- PermissionError → 403 Forbidden (global exception handler)
- Terminal spawn uses 'sudo -i -u' with cwd=fs.home so the shell
starts in the user's own home directory
- System paths (/etc, /usr, etc.) remain accessible to all users
Replace subprocess-based reads (cat, find, stat, test) with native
Python file I/O. Uses chmod 750 + group membership so the server
process can read user directories directly. Writes still use sudo -u
for correct ownership.
- Dockerfile: add CAP_SETGID to Python binary via setcap
- user_isolation: chmod 750, usermod -aG, os.setgroups() refresh
- utils/fs.py: all reads now use aiofiles/os (no subprocess branching)
Replace per-endpoint sudo wrappers with a unified UserFS class in
utils/fs.py. All file endpoints now receive a UserFS instance via
FastAPI dependency injection. Single-user mode uses stdlib/aiofiles,
multi-user mode routes all I/O through sudo -u.
- New: open_terminal/utils/fs.py (UserFS class)
- Simplified: user_isolation.py (provisioning only, sudo helpers removed)
- Updated: all 16 file endpoints in main.py (no more if-branches)
- Removed: user_fs.py (moved to utils/fs.py)