Skip to content

[BUG] Editor fails to open root-only files: sudo fallback missing on file size check #1220

Description

@Majues

Title

Editor fails to open root-only files: sudo fallback missing on file size check

Platform

Website - Chrome

Server Installation Method

Docker

Version

2.7.1

CLI Installation Method

None

CLI Version

No response

Troubleshooting

  • I have examined logs and tried to find the issue
  • I have reviewed opened and closed issues
  • I have tried restarting the application
  • I have checked open issues and ensured this is not a duplicate

The Problem

Opening a root-only file in the file manager editor fails on 2.7.1. The editor
shows the correct metadata (size, modified date) but then displays "file is
empty", and a "Server error occurred" toast appears.

Browsing the same directory works fine, because listFiles retries with sudo
after a permission error. The editor's read path does not get that far: the
backend log shows the failure happens in the file size check, before the read
itself.

[INFO] [FILE] Permission denied for listFiles, retrying with sudo: /var/lib/docker/volumes/caddy_file/_data
[INFO] [FILE] Reading file [op:file_read,user:<redacted>,session:1]
[ERROR] [FILE] File size check failed: bash: line 1: /var/lib/docker/volumes/caddy_file/_data/Caddyfile: Permission denied

The error text "bash: line 1: : Permission denied" is a shell redirect
failing (e.g. wc -c < file), not a command like cat. So the size check runs
unelevated and aborts before the sudo fallback added in Termix#787 can take
effect.

How to Reproduce

  1. Log in as a non-root user with sudo rights (SSH key auth, sudo password
    stored in Termix, sudo itself is NOT NOPASSWD).
  2. In the file manager, open /var/lib/docker/volumes//_data
    (/var/lib/docker is 0710 root:root, so the user cannot traverse it).
  3. The listing appears - the sudo retry works here.
  4. Click any file to open it in the editor.

Additional Context

Expected: the file opens, using the same sudo escalation as listFiles.
Actual: empty editor, server error.

Verified on the host that sudo ls -l <dir> and sudo cat <file> both succeed,
so sudo is configured correctly.

This looks like an incomplete fix or a regression of #526 / Termix#787. Given
the file manager rework in 2.7.0, that release seems the likely point of
breakage, though I have not tested older versions.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status
    Ready for Release

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions