Skip to content

fix(permission): authorize final write targets and recursive operations - #225

Open
devld wants to merge 3 commits into
masterfrom
fix/recursive-path-permissions
Open

devld wants to merge 3 commits into
masterfrom
fix/recursive-path-permissions

Conversation

@devld

@devld devld commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Recursive deletion could remove protected descendants, and write operations could select a different destination after permission checks. This change checks recursive permissions correctly and authorizes the final virtual write target before storage changes.

  • Intersect independently resolved effective permissions across subtree rules, preserving inheritance and user/group precedence.
  • Add read-only PrepareWrite destination selection shared by save, upload, copy, and move. Check final-path and missing-parent permissions while preserving mount and chroot namespaces.
  • Remove automatic renaming from execution. File-manager copy/move and initial upload requests prepare names first; execution and upload callbacks retain exact targets and reject non-overwrite conflicts.
  • Delegate WebDAV COPY/MOVE to complete drive operations. Permission-rejected replacement moves preserve existing destinations; recursive copies reject unreadable subtrees. Depth: 0 checks the source directory itself and any destination subtree being replaced.
  • Make directory-copy fallback replace stale destination contents and propagate native S3/WebDAV conflicts. Local non-overwrite saves use exclusive creation.

Compatibility: direct execution callers requiring automatic naming must call preparation first. Non-overwrite conflicts are errors rather than skipped entries or implicit renames. Directory-copy overwrite fallback replaces the target rather than merging stale contents. Preparation does not reserve names; atomic conflict handling remains backend-dependent, and storage failures/cancellation do not gain transactional rollback.

Validation:

  • go test ./... passed with localhost binding permitted for HTTP integration tests.
  • go test -race ./drive ./drive/fs ./server/webdav ./common/driveutil passed.
  • Added real filesystem/Dispatcher/WebDAV regressions for the review findings, renamed write authorization, missing parents, mount/chroot paths, upload provider issuance/callbacks, late conflicts, Depth: 0, and replacement behavior.
  • Native S3 and remote WebDAV conflict regressions passed against local HTTP fixtures.
  • Documentation build and translation validation passed from docs/site; git diff --check passed.

devld and others added 2 commits October 18, 2026 21:13
Reject recursive deletion before calling the backend when any configured
path in the subtree lacks read and write permission.

Resolve each configured subtree path independently and intersect effective
permissions so sibling grants cannot mask restrictions. Preserve inherited
permissions and subject precedence for delete, move, and copy checks.

Add resolver, operation-boundary, and local filesystem regression coverage,
and document recursive permission requirements in English and Chinese.

Co-Authored-By: codex <codex@openai.com>
Centralize read-only destination selection for save, upload, copy, and move.
Authorize the final virtual path and missing parents through permission,
mount, listener, and chroot wrappers before storage changes. Execution now
uses exact destinations: non-overwrite conflicts fail instead of renaming.

Keep automatic naming at file-manager and initial-upload entry points, and
retain the selected path for upload callbacks. Make WebDAV transfers use
whole drive operations so rejected moves preserve existing destinations
and recursive copies cannot silently omit unreadable descendants. Preserve
Depth: 0 source semantics and check replaced destination subtrees.

Align fallback directory replacement and native conflict reporting, add
real filesystem/HTTP regressions, and document the execution contract.
Existing internal callers needing automatic names must prepare them first;
preparation does not reserve names or provide cross-backend transactions.

Co-Authored-By: codex <codex@openai.com>
@devld devld changed the title fix(permission): enforce effective permissions for recursive operations fix(permission): authorize final write targets and recursive operations Oct 19, 2026
Delegate overwrite moves to the advertised posix-rename@openssh.com version 1 extension. Reject overwrite mode when it is unavailable, even for a missing destination, and return extension errors without deleting or staging files. This avoids source loss through aliased paths and exposing protected source data through temporary names.

Keep ordinary rename for non-overwrite moves so existing destinations cannot be replaced through POSIX rename. Add protocol and Windows regressions, run SFTP tests in platform CI, and document the compatibility restriction with localized errors.

Co-Authored-By: codex <codex@openai.com>
@devld
devld force-pushed the fix/recursive-path-permissions branch from f69fe48 to 92a038a Compare October 20, 2026 09:21

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant