Compare commits

...
19 Commits
Author SHA1 Message Date
Nick Craig-Wood 37e4117f48 Version v1.74.3 2026-06-05 16:20:23 +01:00
Nick Craig-Wood 9222ed2c5a rc: stop global.* connection string options changing config CVE-2026-49980
A connection string can carry global.* options which change rclone's
process-wide configuration (e.g. global.http_proxy). This is
undesirable for the rc interface which was designed to have multiple
users or connections at once. The rc interface has the `_config`
mechanism for setting request scoped global config.

This blocks global.* options on all rc paths by marking the context as
a remote control request at the rc boundaries. fs.NewFs then skips
applying global.* to the process-wide config for a marked context.

The marker is reapplied in fs.CopyConfig, which is the call rclone
uses to detach context but keep config.

global.* options still apply to the individual backend they are set
on, exactly like override.* options; they just no longer leak into the
rest of the process. Remotes created directly on the command line are
unaffected as are remotes defined in the config file.

See: GHSA-qw24-gh76-8rvv
(cherry picked from commit 53f972830c)
2026-06-05 15:22:06 +01:00
Nick Craig-Wood 48da1774f4 rc: fix unauthenticated command execution via --rc-serve inline remotes CVE-2026-49980
The --rc-serve GET/HEAD file serving path accepted bracketed inline
remotes from the URL and instantiated them, so a single
unauthenticated request could run a command as the rclone user via
backend options such as webdav bearer_token_command or sftp ssh, read
arbitrary local files, or change process-wide config via global.*
options.

This was the GET/HEAD equivalent of the POST hole fixed for
CVE-2026-41179, which only guarded the rc call dispatch path.

Now, unless the rc server has authentication configured or
--rc-no-auth is set, the serve path only allows remotes already
present in the config file: inline remotes, connection string
parameters and bare local paths are rejected. Connection string
global.* options are never honoured on the serve path, even when
authenticated.

See: GHSA-qw24-gh76-8rvv
(cherry picked from commit 2326ea79f7)
2026-06-05 15:22:03 +01:00
Nick Craig-Wood 2a7b0d0d3b build: fix multiple CVEs by upgrading to go1.26.4
- CVE-2026-42504: mime: quadratic complexity in WordDecoder.DecodeHeader
- CVE-2026-42507: net/textproto: arbitrary input are included in errors without any escaping
- CVE-2026-27145: crypto/x509: split candidate hostname only once
2026-06-03 17:51:47 +01:00
Nick Craig-Wood fc4349dc16 iclouddrive: fix "Index has invalid data" error listing iCloud Photos
Accounts with shared-album zones (named CMM-*) returned these zones in
the photos changes/database listing alongside the real photo
libraries. rclone treated them as libraries and queried their albums,
but these zones have no CPLAlbumByPositionLive index so the query
failed with BAD_REQUEST / "Index has invalid data", aborting the whole
listing.

Only PrimarySync and SharedSync-* zones are photo libraries, so skip
any other zone during discovery.

See: https://forum.rclone.org/t/sync-to-icloud-gives-index-has-invalid-data-errors/53852
2026-06-03 17:51:47 +01:00
Nick Craig-Wood dff3a0731e build: cache Go build and module dirs to speed up CI
The build matrix relied on setup-go's built-in cache, which keys only on
go.sum with no job differentiation. All matrix jobs computed the same
cache key and raced to save it; since cache keys are immutable, only the
first job to finish saved its cache. That winner was usually a fast job
whose build cache contained none of the cross-compiled architectures, so
the compile_all and ci_beta steps started from a cold cache on every run.

Disable setup-go's cache and add two explicit actions/cache steps to the
build matrix, the android job and the lint job:

  - the module cache (~/go/pkg/mod) depends only on go.sum, so it is
    shared across all jobs under a single key; it used to be duplicated in
    every job's cache. The downloaded module .zip archives are pruned
    before saving as they are not needed to build from the extracted
    module cache, roughly halving it to ~260 MiB per OS;
  - the build cache (compiled artifacts) is specific to OS, arch and Go
    version, so it is kept per job, keyed on the job name.

This lets the cross-compile steps reuse per-architecture build artifacts
and keeps the total cache within the repository limit.

Measured on CI, comparing a cold-cache run against the following
warm-cache run:

    other_os    23m12s -> 3m35s    (compile_all 14m -> 21s)
    linux       23m13s -> 12m14s   (deploy 11m -> 1m37s,
                                     race test 8m -> 4m45s)

Both jobs now finish well under 15 minutes once the cache is warm.
2026-06-03 17:51:47 +01:00
Nick Craig-Wood 5f5e2ef9cf log: fix wrong source file:line in JSON logs from release builds
JSON logs reported "source":"slog/logger.go:256" instead of the real
caller. getCaller skips logging-machinery frames by file path, but
release builds use -trimpath which rewrites the standard library slog
frame's path to "log/slog/logger.go" - matching neither the "/log/" nor
the "log.go" check, so it was reported as the source. Also skip frames
whose function belongs to the log/slog package, which is immune to
-trimpath.
2026-06-03 17:51:47 +01:00
Janne Beate BakengandNick Craig-Wood d4397faa94 mount2: fix empty directory listings on re-read
With cmd/mount2, reading a directory more than once returned the correct
entries on the first read but nothing on subsequent reads. Plain `ls`
triggers this: it does lseek(fd, 0, SEEK_SET) to rewind the directory
before a second getdents.

go-fuse v2.9.0 rewinds a directory stream by calling Seekdir on the
FileSeekdirer interface. dirStream did not implement it, so go-fuse
returned ENOTSUP and produced an empty listing on every read after the
first.

This implements Seekdir on dirStream: a rewind to offset 0 resets the
stream to the start, restoring correct listings on re-read. Non-zero
offsets are uncommon for in-memory listings and still return ENOTSUP,
matching go-fuse's own default. A compile-time interface assertion is
added so signature drift on future go-fuse updates is caught at build
time.

Before: second and subsequent reads of a directory returned no entries.
After: directories list correctly on every read.

See: https://github.com/hanwen/go-fuse/issues/549
Co-authored-by: Nick Craig-Wood <nick@craig-wood.com>
2026-06-03 17:51:47 +01:00
Yakov Till 7324ee850a iclouddrive: fix ADP/PCS cookie acquisition for iCloud Drive 2026-06-03 17:51:47 +01:00
Nick Craig-Wood 3c54a37488 drive: fix server-side move failing on shared drives with duplicate dirs - fixes #9472
When moving a file rclone removed the file from its old parent by
looking the parent ID up from the path using the directory cache. When
the source contained two directories with the same name and path, the
cache could resolve to the wrong duplicate, so the removeParents
request didn't match the file's real parent.

This left the file with both its old and new parent, which fails on
shared drives with:

    A shared drive item must have exactly one parent., teamDrivesParentLimit

This uses the source object's actual parent ID instead when it is
known, falling back to the path lookup only when the object has zero
or multiple parents.
2026-06-03 17:51:47 +01:00
Leon Brocard a2f8b493ed local: fix getXattr returning empty map instead of nil
At least on my macOS Sequoia 15.7.4, the system automatically adds a
com.apple.provenance xattr to files created by processes. This xattr
lacks the "user." prefix so getXattr filters it out, but the metadata
map was already allocated, resulting in an empty non-nil map being
returned instead of nil.

This caused TestMetadata/Symlink/Xattr and TestMetadata/File/Xattr
to fail because they assert the return value is nil when no user
xattrs are present.

The fix checks if the metadata map is empty after filtering and
returns nil if so.
2026-06-03 17:51:47 +01:00
Nick Craig-Wood 641702fc7f serve s3: fix multipart ListParts pagination returning wrong part numbers - fixes #9460
Listing the parts of a multipart upload with a MaxParts smaller than
the number of parts returned wrong PartNumber values and duplicate
parts on pages after the first, and the part number marker regressed
instead of advancing, causing clients to loop forever.

This bumps github.com/rclone/gofakes3 to v0.0.6 pick up the fix.
2026-06-03 17:51:47 +01:00
Nick Craig-Wood f25d9e2bf3 drime: fix directory rename leaving the renamed folder empty in VFS
Drime's folder rename returns success immediately but the children
listing of the renamed folder briefly returns empty before settling,
which made VFS see an empty directory right after a successful rename
and broke subsequent operations on its contents.

After a successful DirMove, poll the renamed folder's listing until it
shows the pre-rename child count, with a 30s timeout and exponential
backoff. The backend integration test already tolerated this via its
own list-consistency retries; this brings VFS into line.

Fixes #9450
2026-06-03 17:51:47 +01:00
Nick Craig-Wood ec28206d8a drime: remove duplicate upload_cutoff config option
The upload_cutoff option was registered twice with identical content.
Remove the second copy.
2026-06-03 17:51:47 +01:00
Nick Craig-Wood ddbc886395 drime: fix files being uploaded to the wrong directory
Large files (sent as multipart uploads) were placed in the wrong folder
for two reasons:

- the parent folder was sent as "parent_id", but the API ignores that
  and expects "parentId", so the parent was never honoured
- relativePath was sent as the full path from the drive root, which made
  the server build folders from it and silently drop any "0" path
  segment (e.g. ".../data/0/file" lost the "0")

Send the parent as "parentId" and use just the leaf as relativePath,
matching the working single-part upload. This also lets us remove the
now-unneeded absolute-path resolution code.

Fixes #9392
Co-authored-by: Brian King <BrianDKing@gmail.com>
2026-06-03 17:51:47 +01:00
Nick Craig-Wood c8ceb209fc drime: fix server-side copy and move failing with Cloudflare 520 error
The drime origin returns a malformed response (reported by Cloudflare as
a 520 error) for a literal PUT request to the file-entries update
endpoint, which broke renaming, and so server-side copy and move.

Use a POST with the X-HTTP-Method-Override: PUT header instead - the API
routes this to the same handler and it works reliably.

Also retry Cloudflare 520-524 errors which may occur transiently.
2026-06-03 17:51:47 +01:00
Nick Craig-Wood 5b4eb0eefb serve sftp: fix truncate request being silently ignored
The SFTP serve handler ignored the size attribute of SETSTAT/FSETSTAT
requests, only acting on the modification time. This meant a client
asking to truncate a file (eg setting the final size of an upload, or
an explicit truncate) had no effect at all.

This respects the size attribute (if present) by truncating the file
to the requested size.
2026-06-03 17:51:47 +01:00
Nick Craig-Wood 223e473e6e serve sftp: fix file corruption when a client resumes an upload
The SFTP serve write handler always opened files with O_TRUNC,
ignoring the flags requested in the SFTP OPEN packet. Some clients
(notably WinSCP's "Process in Background", which resumes an upload on
a second connection) re-open the partially written file without the
truncate flag and continue writing from the offset they had reached,
relying on the existing data being preserved. Forcing O_TRUNC zeroed
that prefix, so the start of the uploaded file ended up as a block of
zero bytes.

This fix respects the requested open flags instead so a resume open
without truncate keeps the already written data intact.

See: https://forum.rclone.org/t/rclone-serve-sftp-winscp-background-mode-uploading-causes-file-corruption/53841
2026-06-03 17:51:47 +01:00
Nick Craig-Wood bac27547d5 Start v1.74.3-DEV development 2026-05-23 11:32:11 +01:00
45 changed files with 1478 additions and 235 deletions

No files matched your search

+120 -9
View File
@@ -37,7 +37,7 @@ jobs:
include:
- job_name: linux
os: ubuntu-latest
go: '~1.26.3'
go: '~1.26.4'
gotags: cmount
build_flags: '-include "^linux/"'
check: true
@@ -48,14 +48,14 @@ jobs:
- job_name: linux_386
os: ubuntu-latest
go: '~1.26.3'
go: '~1.26.4'
goarch: 386
gotags: cmount
quicktest: true
- job_name: mac_amd64
os: macos-latest
go: '~1.26.3'
go: '~1.26.4'
gotags: 'cmount'
build_flags: '-include "^darwin/amd64" -cgo'
quicktest: true
@@ -64,14 +64,14 @@ jobs:
- job_name: mac_arm64
os: macos-latest
go: '~1.26.3'
go: '~1.26.4'
gotags: 'cmount'
build_flags: '-include "^darwin/arm64" -cgo -macos-arch arm64 -cgo-cflags=-I/usr/local/include -cgo-ldflags=-L/usr/local/lib'
deploy: true
- job_name: windows
os: windows-latest
go: '~1.26.3'
go: '~1.26.4'
gotags: cmount
cgo: '0'
build_flags: '-include "^windows/"'
@@ -81,7 +81,7 @@ jobs:
- job_name: other_os
os: ubuntu-latest
go: '~1.26.3'
go: '~1.26.4'
build_flags: '-exclude "^(windows/|darwin/|linux/)"'
compile_all: true
deploy: true
@@ -97,16 +97,58 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Get runner parameters
id: get-runner-parameters
run: |
echo "year-week=$(date -u "+%Y%V")" >> $GITHUB_OUTPUT
echo "runner-os-version=$ImageOS" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install Go
id: setup-go
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go }}
check-latest: true
# Caching is handled explicitly below. setup-go's built-in cache
# keys only on go.sum, so all matrix jobs collide on one key and
# only the first to finish saves - which loses the cross-compile
# build cache.
cache: false
- name: Get Go paths
id: go-paths
run: |
echo "build-cache=$(go env GOCACHE)" >> $GITHUB_OUTPUT
echo "mod-cache=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
# The module cache holds downloaded source and is identical across
# jobs (it depends only on go.sum, not on OS, arch or Go version), so
# it is shared via a single key to avoid storing the same ~600 MiB in
# every job's cache and overflowing the repo cache limit.
- name: Module cache
uses: actions/cache@v5
with:
path: ${{ steps.go-paths.outputs.mod-cache }}
key: go-mod-${{ steps.get-runner-parameters.outputs.year-week }}-${{ hashFiles('go.sum') }}
restore-keys: |
go-mod-${{ steps.get-runner-parameters.outputs.year-week }}-
go-mod-
# The build cache holds compiled artifacts which are specific to the
# OS, arch and Go version, so it is kept per job.
- name: Build cache
uses: actions/cache@v5
with:
path: ${{ steps.go-paths.outputs.build-cache }}
key: go-build-${{ matrix.job_name }}-${{ steps.get-runner-parameters.outputs.runner-os-version }}-go${{ steps.setup-go.outputs.go-version }}-${{ steps.get-runner-parameters.outputs.year-week }}-${{ hashFiles('go.sum') }}
restore-keys: |
go-build-${{ matrix.job_name }}-${{ steps.get-runner-parameters.outputs.runner-os-version }}-go${{ steps.setup-go.outputs.go-version }}-${{ steps.get-runner-parameters.outputs.year-week }}-
go-build-${{ matrix.job_name }}-${{ steps.get-runner-parameters.outputs.runner-os-version }}-go${{ steps.setup-go.outputs.go-version }}-
- name: Set environment variables
run: |
@@ -205,6 +247,15 @@ jobs:
# Deploy binaries if enabled in config && not a PR && not a fork
if: env.RCLONE_CONFIG_PASS != '' && matrix.deploy && github.head_ref == '' && github.repository == 'rclone/rclone'
- name: Trim module cache before saving
if: always()
run: |
# The downloaded module .zip archives are not needed to build from
# the already-extracted module cache, so drop them before the cache
# is saved - this roughly halves the module cache size.
modcache=$(go env GOMODCACHE | tr '\\' '/')
find "$modcache/cache/download" -name '*.zip' -type f -delete 2>/dev/null || true
lint:
if: inputs.manual || (github.repository == 'rclone/rclone' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name))
timeout-minutes: 30
@@ -227,15 +278,23 @@ jobs:
id: setup-go
uses: actions/setup-go@v6
with:
go-version: '~1.26.3'
go-version: '~1.26.4'
check-latest: true
cache: false
- name: Module cache
uses: actions/cache@v5
with:
path: ~/go/pkg/mod
key: go-mod-${{ steps.get-runner-parameters.outputs.year-week }}-${{ hashFiles('go.sum') }}
restore-keys: |
go-mod-${{ steps.get-runner-parameters.outputs.year-week }}-
go-mod-
- name: Cache
uses: actions/cache@v5
with:
path: |
~/go/pkg/mod
~/.cache/go-build
~/.cache/golangci-lint
key: golangci-lint-${{ steps.get-runner-parameters.outputs.runner-os-version }}-go${{ steps.setup-go.outputs.go-version }}-${{ steps.get-runner-parameters.outputs.year-week }}-${{ hashFiles('go.sum') }}
@@ -302,6 +361,15 @@ jobs:
run: bin/check_autogenerated_edits.py 'origin/${{ github.base_ref }}'
if: github.event_name == 'pull_request'
- name: Trim module cache before saving
if: always()
run: |
# The downloaded module .zip archives are not needed to build from
# the already-extracted module cache, so drop them before the cache
# is saved - this roughly halves the module cache size.
modcache=$(go env GOMODCACHE | tr '\\' '/')
find "$modcache/cache/download" -name '*.zip' -type f -delete 2>/dev/null || true
android:
if: inputs.manual || (github.repository == 'rclone/rclone' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name))
timeout-minutes: 30
@@ -309,6 +377,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Get runner parameters
id: get-runner-parameters
run: |
echo "year-week=$(date -u "+%Y%V")" >> $GITHUB_OUTPUT
echo "runner-os-version=$ImageOS" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v6
with:
@@ -316,9 +390,37 @@ jobs:
# Upgrade together with NDK version
- name: Set up Go
id: setup-go
uses: actions/setup-go@v6
with:
go-version: '~1.26.3'
go-version: '~1.26.4'
# Caching is handled explicitly below to share the module cache
# with the other jobs - see the build job for the rationale.
cache: false
- name: Get Go paths
id: go-paths
run: |
echo "build-cache=$(go env GOCACHE)" >> $GITHUB_OUTPUT
echo "mod-cache=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
- name: Module cache
uses: actions/cache@v5
with:
path: ${{ steps.go-paths.outputs.mod-cache }}
key: go-mod-${{ steps.get-runner-parameters.outputs.year-week }}-${{ hashFiles('go.sum') }}
restore-keys: |
go-mod-${{ steps.get-runner-parameters.outputs.year-week }}-
go-mod-
- name: Build cache
uses: actions/cache@v5
with:
path: ${{ steps.go-paths.outputs.build-cache }}
key: go-build-android-${{ steps.get-runner-parameters.outputs.runner-os-version }}-go${{ steps.setup-go.outputs.go-version }}-${{ steps.get-runner-parameters.outputs.year-week }}-${{ hashFiles('go.sum') }}
restore-keys: |
go-build-android-${{ steps.get-runner-parameters.outputs.runner-os-version }}-go${{ steps.setup-go.outputs.go-version }}-${{ steps.get-runner-parameters.outputs.year-week }}-
go-build-android-${{ steps.get-runner-parameters.outputs.runner-os-version }}-go${{ steps.setup-go.outputs.go-version }}-
- name: Set global environment variables
run: |
@@ -394,3 +496,12 @@ jobs:
RCLONE_CONFIG_PASS: ${{ secrets.RCLONE_CONFIG_PASS }}
# Upload artifacts if not a PR && not a fork
if: env.RCLONE_CONFIG_PASS != '' && github.head_ref == '' && github.repository == 'rclone/rclone'
- name: Trim module cache before saving
if: always()
run: |
# The downloaded module .zip archives are not needed to build from
# the already-extracted module cache, so drop them before the cache
# is saved - this roughly halves the module cache size.
modcache=$(go env GOMODCACHE | tr '\\' '/')
find "$modcache/cache/download" -name '*.zip' -type f -delete 2>/dev/null || true
Generated
+98 -11
View File
@@ -5,7 +5,6 @@
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<meta name="author" content="Nick Craig-Wood" />
<meta name="dcterms.date" content="2026-05-22" />
<title>rclone(1) User Manual</title>
<style>
html {
@@ -234,7 +233,7 @@
<header id="title-block-header">
<h1 class="title">rclone(1) User Manual</h1>
<p class="author">Nick Craig-Wood</p>
<p class="date">May 22, 2026</p>
<p class="date">Jun 05, 2026</p>
</header>
<h1 id="name">NAME</h1>
<p>rclone - manage files on cloud storage</p>
@@ -4576,9 +4575,9 @@ SquareBracket</code></pre>
<pre class="console"><code>rclone convmv &quot;stories/The Quick Brown Fox!.txt&quot; --name-transform &quot;all,command=echo&quot;
// Output: stories/The Quick Brown Fox!.txt</code></pre>
<pre class="console"><code>rclone convmv &quot;stories/The Quick Brown Fox!&quot; --name-transform &quot;date=-{YYYYMMDD}&quot;
// Output: stories/The Quick Brown Fox!-20260522</code></pre>
// Output: stories/The Quick Brown Fox!-20260605</code></pre>
<pre class="console"><code>rclone convmv &quot;stories/The Quick Brown Fox!&quot; --name-transform &quot;date=-{macfriendlytime}&quot;
// Output: stories/The Quick Brown Fox!-2026-05-22 0431PM</code></pre>
// Output: stories/The Quick Brown Fox!-2026-06-05 0414PM</code></pre>
<pre class="console"><code>rclone convmv &quot;stories/The Quick Brown Fox!.txt&quot; --name-transform &quot;all,regex=[\\.\\w]/ab&quot;
// Output: ababababababab/ababab ababababab ababababab ababab!abababab</code></pre>
<p>The regex command generally accepts Perl-style regular expressions,
@@ -18288,7 +18287,26 @@ by default, so you can browse to <code>http://127.0.0.1:5572/</code> or
<code>http://127.0.0.1:5572/*</code> to see a listing of the remotes.
Objects may be requested from remotes using this syntax
<code>http://127.0.0.1:5572/[remote:path]/path/to/object</code></p>
<p>Unless the rc server has authentication configured
(<code>--rc-user</code>/<code>--rc-pass</code> or
<code>--rc-htpasswd</code>) or the <code>--rc-no-auth</code> flag is
set, only remotes already present in the config file may be served this
way. Inline remotes (e.g. <code>[:webdav,url=...:]</code>), connection
string parameters and bare local paths are rejected, since instantiating
them from an unauthenticated request could run commands or read
arbitrary local files.</p>
<p>Default Off.</p>
<h3 id="global.-connection-string-options-and-the-rc">global.*
connection string options and the rc</h3>
<p>Remotes instantiated by the rc do not let <a
href="https://rclone.org/docs/#connection-strings">connection string</a>
<code>global.*</code> options change rclone's process-wide
configuration. Remotes created directly on the command line or defined
in the config file are unaffected.</p>
<p>A <code>global.*</code> option still takes effect for the individual
backend it is set on (exactly like an <code>override.*</code> option),
it just does not leak into the global config for the rest of the
process.</p>
<h3 id="rc-serve-no-modtime">--rc-serve-no-modtime</h3>
<p>Set this flag to skip reading the modification time (can speed things
up).</p>
@@ -21695,7 +21713,7 @@ split into groups.</p>
--tpslimit float Limit HTTP transactions per second to this
--tpslimit-burst int Max burst of transactions for --tpslimit (default 1)
--use-cookies Enable session cookiejar
--user-agent string Set the user-agent to a specified string (default &quot;rclone/v1.74.2&quot;)</code></pre>
--user-agent string Set the user-agent to a specified string (default &quot;rclone/v1.74.3&quot;)</code></pre>
<h2 id="performance">Performance</h2>
<p>Flags helpful for increasing performance.</p>
<pre><code> --buffer-size SizeSuffix In memory buffer size when reading files for each --transfer (default 16Mi)
@@ -24434,10 +24452,12 @@ disallowed special characters and filename encodings.)</p>
investigation:</p>
<!--- start list_failures - DO NOT EDIT THIS SECTION - use make commanddocs --->
<ul>
<li><code>TestGoFile</code> (<code>gofile</code>)
<li><code>TestFilen</code> (<code>filen</code>)
<ul>
<li><a
href="https://pub.rclone.org/integration-tests/current/gofile-cmd.bisync-TestGoFile-1.txt"><code>TestBisyncRemoteLocal/rclone_args</code></a></li>
href="https://pub.rclone.org/integration-tests/current/filen-cmd.bisync-TestFilen-1.txt"><code>TestBisyncRemoteRemote/resync_modes</code></a></li>
<li><a
href="https://pub.rclone.org/integration-tests/current/filen-cmd.bisync-TestFilen-1.txt"><code>TestBisyncRemoteRemote/rmdirs</code></a></li>
</ul></li>
<li><code>TestHuaweiDrive</code> (<code>huaweidrive</code>)
<ul>
@@ -24446,15 +24466,20 @@ href="https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-Te
<li><a
href="https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt"><code>TestBisyncRemoteLocal/extended_filenames</code></a></li>
<li><a
href="https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt"><code>TestBisyncRemoteLocal/normalization</code></a></li>
<li><a
href="https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt"><code>TestBisyncLocalRemote/ext_paths</code></a></li>
<li><a
href="https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt"><code>TestBisyncLocalRemote/extended_filenames</code></a></li>
<li><a
href="https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt"><code>TestBisyncRemoteRemote/ext_paths</code></a></li>
<li><a href="https://pub.rclone.org/integration-tests/current/">2
<li><a href="https://pub.rclone.org/integration-tests/current/">4
more</a></li>
</ul></li>
<li>Updated: 2026-05-22-010013
<li><code>TestSeafile</code> (<code>seafile</code>)
<ul>
<li><a
href="https://pub.rclone.org/integration-tests/current/seafile-cmd.bisync-TestSeafile-1.txt"><code>TestBisyncLocalRemote/rmdirs</code></a></li>
</ul></li>
<li>Updated: 2026-06-05-010010
<!--- end list_failures - DO NOT EDIT THIS SECTION - use make commanddocs ---></li>
</ul>
<p>The following backends either have not been tested recently or have
@@ -65099,6 +65124,68 @@ the output.</p>
<!-- autogenerated options stop -->
<!-- markdownlint-disable line-length -->
<h1 id="changelog-1">Changelog</h1>
<h2 id="v1.74.3---2026-06-05">v1.74.3 - 2026-06-05</h2>
<p><a
href="https://github.com/rclone/rclone/compare/v1.74.2...v1.74.3">See
commits</a></p>
<ul>
<li>Bug Fixes
<ul>
<li>rc
<ul>
<li>Fix unauthenticated command execution via <code>--rc-serve</code>
inline remotes CVE-2026-49980 (Nick Craig-Wood)</li>
<li>Stop <code>global.*</code> connection string options changing config
CVE-2026-49980 (Nick Craig-Wood)</li>
</ul></li>
<li>build: Fix multiple CVEs by upgrading to go1.26.4 (Nick Craig-Wood)
<ul>
<li>CVE-2026-42504: mime: quadratic complexity in
WordDecoder.DecodeHeader</li>
<li>CVE-2026-42507: net/textproto: arbitrary input are included in
errors without any escaping</li>
<li>CVE-2026-27145: crypto/x509: split candidate hostname only once</li>
</ul></li>
<li>log: Fix wrong source <code>file:line</code> in JSON logs from
release builds (Nick Craig-Wood)</li>
<li>mount2: Fix empty directory listings on re-read (Janne Beate
Bakeng)</li>
<li>serve s3: Fix multipart <code>ListParts</code> pagination returning
wrong part numbers (Nick Craig-Wood)</li>
<li>serve sftp
<ul>
<li>Fix file corruption when a client resumes an upload (Nick
Craig-Wood)</li>
<li>Fix truncate request being silently ignored (Nick Craig-Wood)</li>
</ul></li>
</ul></li>
<li>Local
<ul>
<li>Fix <code>getXattr</code> returning empty map instead of nil (Leon
Brocard)</li>
</ul></li>
<li>Drime
<ul>
<li>Fix server-side copy and move failing with Cloudflare 520 error
(Nick Craig-Wood)</li>
<li>Fix files being uploaded to the wrong directory (Nick
Craig-Wood)</li>
<li>Remove duplicate upload_cutoff config option (Nick Craig-Wood)</li>
<li>Fix directory rename leaving the renamed folder empty in VFS (Nick
Craig-Wood)</li>
</ul></li>
<li>Drive
<ul>
<li>Fix server-side move failing on shared drives with duplicate dirs
(Nick Craig-Wood)</li>
</ul></li>
<li>Iclouddrive
<ul>
<li>Fix ADP/PCS cookie acquisition for iCloud Drive (Yakov Till)</li>
<li>Fix "Index has invalid data" error listing iCloud Photos (Nick
Craig-Wood)</li>
</ul></li>
</ul>
<h2 id="v1.74.2---2026-05-22">v1.74.2 - 2026-05-22</h2>
<p><a
href="https://github.com/rclone/rclone/compare/v1.74.1...v1.74.2">See
Generated
+61 -9
View File
@@ -1,6 +1,6 @@
% rclone(1) User Manual
% Nick Craig-Wood
% May 22, 2026
% Jun 05, 2026
# NAME
@@ -5416,12 +5416,12 @@ rclone convmv "stories/The Quick Brown Fox!.txt" --name-transform "all,command=e
```console
rclone convmv "stories/The Quick Brown Fox!" --name-transform "date=-{YYYYMMDD}"
// Output: stories/The Quick Brown Fox!-20260522
// Output: stories/The Quick Brown Fox!-20260605
```
```console
rclone convmv "stories/The Quick Brown Fox!" --name-transform "date=-{macfriendlytime}"
// Output: stories/The Quick Brown Fox!-2026-05-22 0431PM
// Output: stories/The Quick Brown Fox!-2026-06-05 0414PM
```
```console
@@ -21703,8 +21703,26 @@ so you can browse to `http://127.0.0.1:5572/` or `http://127.0.0.1:5572/*`
to see a listing of the remotes. Objects may be requested from
remotes using this syntax `http://127.0.0.1:5572/[remote:path]/path/to/object`
Unless the rc server has authentication configured (`--rc-user`/`--rc-pass`
or `--rc-htpasswd`) or the `--rc-no-auth` flag is set, only remotes already
present in the config file may be served this way. Inline remotes (e.g.
`[:webdav,url=...:]`), connection string parameters and bare local paths are
rejected, since instantiating them from an unauthenticated request could run
commands or read arbitrary local files.
Default Off.
### global.* connection string options and the rc
Remotes instantiated by the rc do not let [connection
string](https://rclone.org/docs/#connection-strings) `global.*` options change rclone's
process-wide configuration. Remotes created directly on the command
line or defined in the config file are unaffected.
A `global.*` option still takes effect for the individual backend it
is set on (exactly like an `override.*` option), it just does not leak
into the global config for the rest of the process.
### --rc-serve-no-modtime
Set this flag to skip reading the modification time (can speed things up).
@@ -24985,7 +25003,7 @@ Flags for general networking and HTTP stuff.
--tpslimit float Limit HTTP transactions per second to this
--tpslimit-burst int Max burst of transactions for --tpslimit (default 1)
--use-cookies Enable session cookiejar
--user-agent string Set the user-agent to a specified string (default "rclone/v1.74.2")
--user-agent string Set the user-agent to a specified string (default "rclone/v1.74.3")
```
@@ -27772,16 +27790,19 @@ encodings.)
The following backends have known issues that need more investigation:
<!--- start list_failures - DO NOT EDIT THIS SECTION - use make commanddocs --->
- `TestGoFile` (`gofile`)
- [`TestBisyncRemoteLocal/rclone_args`](https://pub.rclone.org/integration-tests/current/gofile-cmd.bisync-TestGoFile-1.txt)
- `TestFilen` (`filen`)
- [`TestBisyncRemoteRemote/resync_modes`](https://pub.rclone.org/integration-tests/current/filen-cmd.bisync-TestFilen-1.txt)
- [`TestBisyncRemoteRemote/rmdirs`](https://pub.rclone.org/integration-tests/current/filen-cmd.bisync-TestFilen-1.txt)
- `TestHuaweiDrive` (`huaweidrive`)
- [`TestBisyncRemoteLocal/ext_paths`](https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt)
- [`TestBisyncRemoteLocal/extended_filenames`](https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt)
- [`TestBisyncRemoteLocal/normalization`](https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt)
- [`TestBisyncLocalRemote/ext_paths`](https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt)
- [`TestBisyncLocalRemote/extended_filenames`](https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt)
- [`TestBisyncRemoteRemote/ext_paths`](https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt)
- [2 more](https://pub.rclone.org/integration-tests/current/)
- Updated: 2026-05-22-010013
- [4 more](https://pub.rclone.org/integration-tests/current/)
- `TestSeafile` (`seafile`)
- [`TestBisyncLocalRemote/rmdirs`](https://pub.rclone.org/integration-tests/current/seafile-cmd.bisync-TestSeafile-1.txt)
- Updated: 2026-06-05-010010
<!--- end list_failures - DO NOT EDIT THIS SECTION - use make commanddocs --->
The following backends either have not been tested recently or have known issues
@@ -70298,6 +70319,37 @@ Options:
# Changelog
## v1.74.3 - 2026-06-05
[See commits](https://github.com/rclone/rclone/compare/v1.74.2...v1.74.3)
- Bug Fixes
- rc
- Fix unauthenticated command execution via `--rc-serve` inline remotes CVE-2026-49980 (Nick Craig-Wood)
- Stop `global.*` connection string options changing config CVE-2026-49980 (Nick Craig-Wood)
- build: Fix multiple CVEs by upgrading to go1.26.4 (Nick Craig-Wood)
- CVE-2026-42504: mime: quadratic complexity in WordDecoder.DecodeHeader
- CVE-2026-42507: net/textproto: arbitrary input are included in errors without any escaping
- CVE-2026-27145: crypto/x509: split candidate hostname only once
- log: Fix wrong source `file:line` in JSON logs from release builds (Nick Craig-Wood)
- mount2: Fix empty directory listings on re-read (Janne Beate Bakeng)
- serve s3: Fix multipart `ListParts` pagination returning wrong part numbers (Nick Craig-Wood)
- serve sftp
- Fix file corruption when a client resumes an upload (Nick Craig-Wood)
- Fix truncate request being silently ignored (Nick Craig-Wood)
- Local
- Fix `getXattr` returning empty map instead of nil (Leon Brocard)
- Drime
- Fix server-side copy and move failing with Cloudflare 520 error (Nick Craig-Wood)
- Fix files being uploaded to the wrong directory (Nick Craig-Wood)
- Remove duplicate upload_cutoff config option (Nick Craig-Wood)
- Fix directory rename leaving the renamed folder empty in VFS (Nick Craig-Wood)
- Drive
- Fix server-side move failing on shared drives with duplicate dirs (Nick Craig-Wood)
- Iclouddrive
- Fix ADP/PCS cookie acquisition for iCloud Drive (Yakov Till)
- Fix "Index has invalid data" error listing iCloud Photos (Nick Craig-Wood)
## v1.74.2 - 2026-05-22
[See commits](https://github.com/rclone/rclone/compare/v1.74.1...v1.74.2)
Generated
+77 -9
View File
@@ -1,6 +1,6 @@
rclone(1) User Manual
Nick Craig-Wood
May 22, 2026
Jun 05, 2026
NAME
@@ -4632,10 +4632,10 @@ Examples:
// Output: stories/The Quick Brown Fox!.txt
rclone convmv "stories/The Quick Brown Fox!" --name-transform "date=-{YYYYMMDD}"
// Output: stories/The Quick Brown Fox!-20260522
// Output: stories/The Quick Brown Fox!-20260605
rclone convmv "stories/The Quick Brown Fox!" --name-transform "date=-{macfriendlytime}"
// Output: stories/The Quick Brown Fox!-2026-05-22 0431PM
// Output: stories/The Quick Brown Fox!-2026-06-05 0414PM
rclone convmv "stories/The Quick Brown Fox!.txt" --name-transform "all,regex=[\\.\\w]/ab"
// Output: ababababababab/ababab ababababab ababababab ababab!abababab
@@ -19838,8 +19838,26 @@ can browse to http://127.0.0.1:5572/ or http://127.0.0.1:5572/* to see a
listing of the remotes. Objects may be requested from remotes using this
syntax http://127.0.0.1:5572/[remote:path]/path/to/object
Unless the rc server has authentication configured (--rc-user/--rc-pass
or --rc-htpasswd) or the --rc-no-auth flag is set, only remotes already
present in the config file may be served this way. Inline remotes (e.g.
[:webdav,url=...:]), connection string parameters and bare local paths
are rejected, since instantiating them from an unauthenticated request
could run commands or read arbitrary local files.
Default Off.
global.* connection string options and the rc
Remotes instantiated by the rc do not let connection string global.*
options change rclone's process-wide configuration. Remotes created
directly on the command line or defined in the config file are
unaffected.
A global.* option still takes effect for the individual backend it is
set on (exactly like an override.* option), it just does not leak into
the global config for the rest of the process.
--rc-serve-no-modtime
Set this flag to skip reading the modification time (can speed things
@@ -23140,7 +23158,7 @@ Flags for general networking and HTTP stuff.
--tpslimit float Limit HTTP transactions per second to this
--tpslimit-burst int Max burst of transactions for --tpslimit (default 1)
--use-cookies Enable session cookiejar
--user-agent string Set the user-agent to a specified string (default "rclone/v1.74.2")
--user-agent string Set the user-agent to a specified string (default "rclone/v1.74.3")
Performance
@@ -25839,16 +25857,19 @@ disallowed special characters and filename encodings.)
The following backends have known issues that need more investigation:
- TestGoFile (gofile)
- TestBisyncRemoteLocal/rclone_args
- TestFilen (filen)
- TestBisyncRemoteRemote/resync_modes
- TestBisyncRemoteRemote/rmdirs
- TestHuaweiDrive (huaweidrive)
- TestBisyncRemoteLocal/ext_paths
- TestBisyncRemoteLocal/extended_filenames
- TestBisyncRemoteLocal/normalization
- TestBisyncLocalRemote/ext_paths
- TestBisyncLocalRemote/extended_filenames
- TestBisyncRemoteRemote/ext_paths
- 2 more
- Updated: 2026-05-22-010013
- 4 more
- TestSeafile (seafile)
- TestBisyncLocalRemote/rmdirs
- Updated: 2026-06-05-010010
The following backends either have not been tested recently or have
known issues that are deemed unfixable for the time being:
@@ -67389,6 +67410,53 @@ Options:
Changelog
v1.74.3 - 2026-06-05
See commits
- Bug Fixes
- rc
- Fix unauthenticated command execution via --rc-serve inline
remotes CVE-2026-49980 (Nick Craig-Wood)
- Stop global.* connection string options changing config
CVE-2026-49980 (Nick Craig-Wood)
- build: Fix multiple CVEs by upgrading to go1.26.4 (Nick
Craig-Wood)
- CVE-2026-42504: mime: quadratic complexity in
WordDecoder.DecodeHeader
- CVE-2026-42507: net/textproto: arbitrary input are included
in errors without any escaping
- CVE-2026-27145: crypto/x509: split candidate hostname only
once
- log: Fix wrong source file:line in JSON logs from release builds
(Nick Craig-Wood)
- mount2: Fix empty directory listings on re-read (Janne Beate
Bakeng)
- serve s3: Fix multipart ListParts pagination returning wrong
part numbers (Nick Craig-Wood)
- serve sftp
- Fix file corruption when a client resumes an upload (Nick
Craig-Wood)
- Fix truncate request being silently ignored (Nick
Craig-Wood)
- Local
- Fix getXattr returning empty map instead of nil (Leon Brocard)
- Drime
- Fix server-side copy and move failing with Cloudflare 520 error
(Nick Craig-Wood)
- Fix files being uploaded to the wrong directory (Nick
Craig-Wood)
- Remove duplicate upload_cutoff config option (Nick Craig-Wood)
- Fix directory rename leaving the renamed folder empty in VFS
(Nick Craig-Wood)
- Drive
- Fix server-side move failing on shared drives with duplicate
dirs (Nick Craig-Wood)
- Iclouddrive
- Fix ADP/PCS cookie acquisition for iCloud Drive (Yakov Till)
- Fix "Index has invalid data" error listing iCloud Photos (Nick
Craig-Wood)
v1.74.2 - 2026-05-22
See commits
+1 -1
View File
@@ -1 +1 @@
v1.74.2
v1.74.3
+2 -10
View File
@@ -171,7 +171,7 @@ type MultiPartCreateRequest struct {
Mime string `json:"mime"`
Size int64 `json:"size"`
Extension string `json:"extension"`
ParentID json.Number `json:"parent_id"`
ParentID json.Number `json:"parentId"`
RelativePath string `json:"relativePath"`
WorkspaceID string `json:"workspaceId,omitempty"`
}
@@ -222,7 +222,7 @@ type MultiPartEntriesRequest struct {
Filename string `json:"filename"`
Size int64 `json:"size"`
ClientExtension string `json:"clientExtension"`
ParentID json.Number `json:"parent_id"`
ParentID json.Number `json:"parentId"`
RelativePath string `json:"relativePath"`
WorkspaceID string `json:"workspaceId,omitempty"`
}
@@ -238,14 +238,6 @@ type MultiPartAbort struct {
Key string `json:"key"`
}
// FolderPathResponse is returned by GET /folders/{hash}/path
//
// Path is the breadcrumb from the drive root down to the requested folder.
type FolderPathResponse struct {
Status string `json:"status"`
Path []Item `json:"path"`
}
// SpaceUsageResponse is returned by GET /user/space-usage
type SpaceUsageResponse struct {
Used int64 `json:"used"`
+85 -91
View File
@@ -15,7 +15,6 @@ should stay under that.
import (
"context"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
@@ -147,14 +146,6 @@ and these uploads do not fully utilize your bandwidth, then increasing
this may help to speed up the transfers.`,
Default: 4,
Advanced: true,
}, {
Name: "upload_cutoff",
Help: `Cutoff for switching to chunked upload.
Any files larger than this will be uploaded in chunks of chunk_size.
The minimum is 0 and the maximum is 5 GiB.`,
Default: defaultUploadCutoff,
Advanced: true,
}, {
Name: config.ConfigEncoding,
Help: config.ConfigEncodingHelp,
@@ -200,16 +191,13 @@ type Options struct {
// Fs represents a remote drime
type Fs struct {
name string // name of this remote
root string // the path we are working on
opt Options // parsed options
features *fs.Features // optional features
srv *rest.Client // the connection to the server
dirCache *dircache.DirCache // Map of directory path to directory id
pacer *fs.Pacer // pacer for API calls
absRootOnce *sync.Once // protects absRoot computation
absRoot string // absolute path of f.root from drive root
absRootErr error // error from computing absRoot, if any
name string // name of this remote
root string // the path we are working on
opt Options // parsed options
features *fs.Features // optional features
srv *rest.Client // the connection to the server
dirCache *dircache.DirCache // Map of directory path to directory id
pacer *fs.Pacer // pacer for API calls
}
// Object describes a drime object
@@ -282,6 +270,11 @@ var retryErrorCodes = []int{
503, // Service Unavailable
504, // Gateway Timeout
509, // Bandwidth Limit Exceeded
520, // Cloudflare: Web server returns an unknown error
521, // Cloudflare: Web server is down
522, // Cloudflare: Connection timed out
523, // Cloudflare: Origin is unreachable
524, // Cloudflare: A timeout occurred
}
// shouldRetry returns a boolean as to whether this resp and err
@@ -334,62 +327,6 @@ func (f *Fs) getItem(ctx context.Context, id string, dirID string, leaf string)
return info, err
}
// idToAbsolutePath returns the absolute path (from the user's drive root) of
// the folder with the given ID.
//
// Drime exposes GET /folders/{hash}/path which returns the breadcrumb from
// drive root down to the folder. The hash format is undocumented but
// observed to be base64("<id>|") - every item drime returns has a `hash`
// field of that shape (e.g. id 704791396 => "NzA0NzkxMzk2fA"). The docs
// example "MTExMzQ0fHBhZA" decodes to "111344|pad", so a non-empty suffix
// after the pipe is also accepted; if drime ever starts requiring a
// specific suffix this will break.
//
// Returns "" for an empty/zero ID (drive root).
func (f *Fs) idToAbsolutePath(ctx context.Context, id string) (string, error) {
if id == "" || id == "0" {
return "", nil
}
hash := base64.StdEncoding.EncodeToString([]byte(id + "|"))
opts := rest.Opts{
Method: "GET",
Path: "/folders/" + hash + "/path",
Parameters: url.Values{},
}
if f.opt.WorkspaceID != "" {
opts.Parameters.Set("workspaceId", f.opt.WorkspaceID)
}
var result api.FolderPathResponse
var resp *http.Response
err := f.pacer.Call(func() (bool, error) {
var err error
resp, err = f.srv.CallJSON(ctx, &opts, nil, &result)
return shouldRetry(ctx, resp, err)
})
if err != nil {
return "", fmt.Errorf("failed to get folder path for %q: %w", id, err)
}
parts := make([]string, 0, len(result.Path))
for _, item := range result.Path {
parts = append(parts, f.opt.Enc.ToStandardName(item.Name))
}
return path.Join(parts...), nil
}
// absoluteRoot returns the absolute path from the drive root to the Fs root.
// Computed once and cached.
func (f *Fs) absoluteRoot(ctx context.Context) (string, error) {
f.absRootOnce.Do(func() {
rootID, err := f.dirCache.RootID(ctx, false)
if err != nil {
f.absRootErr = err
return
}
f.absRoot, f.absRootErr = f.idToAbsolutePath(ctx, rootID)
})
return f.absRoot, f.absRootErr
}
// errorHandler parses a non 2xx error response into an error
func errorHandler(resp *http.Response) error {
body, err := rest.ReadBody(resp)
@@ -430,12 +367,11 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
client := fshttp.NewClient(ctx)
f := &Fs{
name: name,
root: root,
opt: *opt,
srv: rest.NewClient(client).SetRoot(rootURL),
pacer: fs.NewPacer(ctx, pacer.NewDefault(pacer.MinSleep(minSleep), pacer.MaxSleep(maxSleep), pacer.DecayConstant(decayConstant))),
absRootOnce: new(sync.Once),
name: name,
root: root,
opt: *opt,
srv: rest.NewClient(client).SetRoot(rootURL),
pacer: fs.NewPacer(ctx, pacer.NewDefault(pacer.MinSleep(minSleep), pacer.MaxSleep(maxSleep), pacer.DecayConstant(decayConstant))),
}
f.features = (&fs.Features{
CanHaveEmptyDirectories: true,
@@ -848,10 +784,16 @@ func (f *Fs) patch(ctx context.Context, id, attribute string, value string) (ite
Name: value,
}
var result api.UpdateItemResponse
// The drime origin returns a malformed response (seen by Cloudflare as
// a 520) for a literal PUT to this endpoint, so use a POST with Laravel
// method spoofing instead - the API routes it to the same handler.
opts := rest.Opts{
Method: "PUT",
Method: "POST",
Path: "/file-entries/" + id,
Parameters: url.Values{},
ExtraHeaders: map[string]string{
"X-HTTP-Method-Override": "PUT",
},
}
if f.opt.WorkspaceID != "" {
opts.Parameters.Set("workspaceId", f.opt.WorkspaceID)
@@ -985,6 +927,48 @@ func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object,
return dstObj, nil
}
// countDirChildren returns the number of direct children of dirID.
func (f *Fs) countDirChildren(ctx context.Context, dirID string) (int, error) {
n := 0
_, err := f.listAll(ctx, dirID, false, false, "", func(*api.Item) bool {
n++
return false
})
return n, err
}
// waitForDirChildren polls dirID until it lists at least want direct
// children, or the timeout elapses. Drime's folder rename has visible
// eventual-consistency on the children listing - the rename returns
// success immediately but the renamed folder lists as empty for a
// short window - so callers that rename a folder use this to wait for
// the listing to settle before returning (see issue #9450).
func (f *Fs) waitForDirChildren(ctx context.Context, dirID string, want int) error {
const timeout = 30 * time.Second
deadline := time.Now().Add(timeout)
backoff := 100 * time.Millisecond
for {
got, err := f.countDirChildren(ctx, dirID)
if err != nil {
return err
}
if got >= want {
return nil
}
if time.Now().After(deadline) {
return fmt.Errorf("timed out waiting for directory listing to settle: got %d, want %d", got, want)
}
select {
case <-ctx.Done():
return ctx.Err()
case <-time.After(backoff):
}
if backoff < 2*time.Second {
backoff *= 2
}
}
}
// DirMove moves src, srcRemote to this remote at dstRemote
// using server-side move operations.
//
@@ -1005,11 +989,25 @@ func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote string
return err
}
// Count children before the move so we can wait for the server's
// children listing to reflect the rename - see waitForDirChildren.
preCount, err := f.countDirChildren(ctx, srcID)
if err != nil {
return fmt.Errorf("DirMove: count source children: %w", err)
}
// Do the move
_, err = f.moveTo(ctx, srcID, srcLeaf, dstLeaf, srcDirectoryID, dstDirectoryID)
info, err := f.moveTo(ctx, srcID, srcLeaf, dstLeaf, srcDirectoryID, dstDirectoryID)
if err != nil {
return err
}
if preCount > 0 {
if err := f.waitForDirChildren(ctx, info.ID.String(), preCount); err != nil {
fs.Logf(f, "DirMove: %v (continuing)", err)
}
}
srcFs.dirCache.FlushDir(srcRemote)
return nil
}
@@ -1162,14 +1160,10 @@ func (f *Fs) OpenChunkWriter(ctx context.Context, remote string, src fs.ObjectIn
return info, nil, err
}
// The /s3/multipart/create and /s3/entries endpoints interpret
// relativePath as an absolute path from the drive root, not relative to
// parent_id. Resolve our root's absolute path so we can build it.
absRoot, err := f.absoluteRoot(ctx)
if err != nil {
return info, nil, fmt.Errorf("failed to resolve absolute path of root: %w", err)
}
relPath := f.opt.Enc.FromStandardPath(path.Join(absRoot, remote))
// Send just the leaf as relativePath, matching the single-part /uploads
// convention. The file is placed by parentId; sending an absolute path
// here makes the server build folders from it and drop "0" path segments.
relPath := f.opt.Enc.FromStandardName(leaf)
// Temporary Object under construction
o := &Object{
+11 -4
View File
@@ -3034,11 +3034,18 @@ func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object,
remote = remote[:len(remote)-len(ext)]
}
_, srcParentID, err := srcObj.fs.dirCache.FindPath(ctx, src.Remote(), false)
if err != nil {
return nil, err
// Find the ID of the parent to remove the file from.
var srcParentID string
if len(srcObj.parents) == 1 {
srcParentID = srcObj.parents[0]
} else {
var err error
_, srcParentID, err = srcObj.fs.dirCache.FindPath(ctx, src.Remote(), false)
if err != nil {
return nil, err
}
srcParentID = actualID(srcParentID)
}
srcParentID = actualID(srcParentID)
// Temporary Object under construction
dstInfo, err := f.createFileInfo(ctx, remote, src.ModTime(ctx))
+78
View File
@@ -681,6 +681,83 @@ func (f *Fs) InternalTestSingleQuoteFolder(t *testing.T) {
assert.NoError(t, err)
}
// TestIntegration/FsMkdir/FsPutFiles/Internal/MoveDuplicateParent
//
// Check that moving a file removes it from its real parent even when there
// are two directories with the same name and the directory cache resolves the
// path to the wrong duplicate. Otherwise the file ends up with two parents
// which fails on shared drives with a teamDrivesParentLimit error (#9472).
func (f *Fs) InternalTestMoveDuplicateParent(t *testing.T) {
ctx := context.Background()
if f.Features().Move == nil {
t.Skip("Move not supported")
}
rootID, err := f.dirCache.RootID(ctx, false)
require.NoError(t, err)
const dupName = "dup9472"
const dstName = "dst9472"
const fileName = "michael.txt"
// Create the first "dup9472" directory - this is the one the directory
// cache will resolve the path to.
dirA, err := f.createDir(ctx, rootID, dupName, nil)
require.NoError(t, err)
f.dirCache.Put(dupName, dirA.Id)
// Create a second directory with the SAME name and parent: a duplicate
// the directory cache does not know about.
dirB, err := f.createDir(ctx, rootID, dupName, nil)
require.NoError(t, err)
// Destination directory
dirDst, err := f.createDir(ctx, rootID, dstName, nil)
require.NoError(t, err)
defer func() {
_ = f.delete(ctx, dirA.Id, false)
_ = f.delete(ctx, dirB.Id, false)
_ = f.delete(ctx, dirDst.Id, false)
f.dirCache.Flush()
}()
// Upload a file directly into dirB (the duplicate the cache doesn't know).
createInfo := &drive.File{
Name: fileName,
Parents: []string{dirB.Id},
}
var fileInfo *drive.File
err = f.pacer.Call(func() (bool, error) {
fileInfo, err = f.svc.Files.Create(createInfo).
Media(strings.NewReader("9472 duplicate parent test")).
Fields(f.getFileFields(ctx)).
SupportsAllDrives(true).
Context(ctx).Do()
return f.shouldRetry(ctx, err)
})
require.NoError(t, err)
require.Equal(t, []string{dirB.Id}, fileInfo.Parents)
// Sanity check: the directory cache resolves the path to dirA, not the
// dirB the file actually lives in.
gotDirID, err := f.dirCache.FindDir(ctx, dupName, false)
require.NoError(t, err)
require.Equal(t, dirA.Id, gotDirID, "directory cache should resolve to the wrong duplicate")
// Build the source object pointing at the file in dirB and move it.
srcObj, err := f.newObjectWithInfo(ctx, dupName+"/"+fileName, fileInfo)
require.NoError(t, err)
dstObj, err := f.Move(ctx, srcObj, dstName+"/"+fileName)
require.NoError(t, err)
// The moved file must have exactly one parent: the destination.
movedInfo, err := f.getFile(ctx, dstObj.(fs.IDer).ID(), "id,parents")
require.NoError(t, err)
assert.Equal(t, []string{dirDst.Id}, movedInfo.Parents)
}
func (f *Fs) InternalTest(t *testing.T) {
// These tests all depend on each other so run them as nested tests
t.Run("DocumentImport", func(t *testing.T) {
@@ -701,6 +778,7 @@ func (f *Fs) InternalTest(t *testing.T) {
t.Run("Query", f.InternalTestQuery)
t.Run("AgeQuery", f.InternalTestAgeQuery)
t.Run("SingleQuoteFolder", f.InternalTestSingleQuoteFolder)
t.Run("MoveDuplicateParent", f.InternalTestMoveDuplicateParent)
t.Run("ShouldRetry", f.InternalTestShouldRetry)
}
+32 -3
View File
@@ -25,6 +25,13 @@ const (
authEndpoint = "https://idmsa.apple.com/appleauth/auth"
)
// Webservice keys in AccountInfo.Webservices map
const (
WsDrive = "drivews"
WsDocs = "docws"
WsPhotos = "ckdatabasews"
)
type sessionSave func(*Session)
// Client defines the client configuration
@@ -32,6 +39,7 @@ type Client struct {
appleID string
password string
remoteName string // rclone remote name, used for cache namespacing
pcsWSKey string // webservice key for PCS cookie scoping (e.g. WsDrive, WsPhotos)
srv *rest.Client
Session *Session
sessionSaveCallback sessionSave
@@ -41,11 +49,14 @@ type Client struct {
}
// New creates a new iCloud API client and initializes its HTTP session
func New(appleID, password, trustToken string, clientID string, cookies []*http.Cookie, sessionSaveCallback sessionSave, remoteName string) (*Client, error) {
// pcsWSKey scopes PCS cookie acquisition to the caller's webservice (WsDrive, WsPhotos);
// empty string skips PCS entirely
func New(appleID, password, trustToken string, clientID string, cookies []*http.Cookie, sessionSaveCallback sessionSave, remoteName string, pcsWSKey string) (*Client, error) {
icloud := &Client{
appleID: strings.ToLower(appleID), // Apple SRP requires lowercase in client-side proof
password: password,
remoteName: filepath.Base(remoteName),
pcsWSKey: pcsWSKey,
srv: rest.NewClient(fshttp.NewClient(context.Background())),
Session: NewSession(),
sessionSaveCallback: sessionSaveCallback,
@@ -75,8 +86,8 @@ func (c *Client) DriveService() (*DriveService, error) {
func (c *Client) Request(ctx context.Context, opts rest.Opts, request any, response any) (resp *http.Response, err error) {
resp, err = c.Session.Request(ctx, opts, request, response)
if err != nil && resp != nil {
// try to reauth
if resp.StatusCode == 401 || resp.StatusCode == 421 {
// 401/421 = session expired, 423 = missing PCS cookies (ADP)
if resp.StatusCode == 401 || resp.StatusCode == 421 || resp.StatusCode == 423 {
err = c.Authenticate(ctx)
if err != nil {
return nil, err
@@ -95,6 +106,24 @@ func (c *Client) Request(ctx context.Context, opts rest.Opts, request any, respo
func (c *Client) Authenticate(ctx context.Context) error {
c.mu.Lock()
defer c.mu.Unlock()
if err := c.authenticateSession(ctx); err != nil {
return err
}
// Ensure PCS cookies after any successful auth path (ADP accounts)
acquired, err := c.Session.ensurePCSCookies(ctx, c.pcsWSKey)
if err != nil {
return err
}
if acquired && c.sessionSaveCallback != nil {
c.sessionSaveCallback(c.Session)
}
return nil
}
// authenticateSession establishes a valid session via the cheapest available path
func (c *Client) authenticateSession(ctx context.Context) error {
// Skip /validate round-trip when saved session has cookies + service endpoints
// Native client behavior: use cached session, reauth lazily on 401/421
if c.Session.Cookies != nil && len(c.Session.AccountInfo.Webservices) > 0 {
+1 -1
View File
@@ -33,7 +33,7 @@ type DriveService struct {
// NewDriveService creates a new DriveService instance.
func NewDriveService(icloud *Client) (*DriveService, error) {
return &DriveService{icloud: icloud, RootID: "FOLDER::com.apple.CloudDocs::root", endpoint: icloud.Session.AccountInfo.Webservices["drivews"].URL, docsEndpoint: icloud.Session.AccountInfo.Webservices["docws"].URL}, nil
return &DriveService{icloud: icloud, RootID: "FOLDER::com.apple.CloudDocs::root", endpoint: icloud.Session.AccountInfo.Webservices[WsDrive].URL, docsEndpoint: icloud.Session.AccountInfo.Webservices[WsDocs].URL}, nil
}
// GetItemByDriveID retrieves a DriveItem by its Drive ID.
+9 -2
View File
@@ -510,7 +510,7 @@ func (album *Album) SetTestPhotoCache(cache map[string]*Photo) {
// NewPhotosService creates a new PhotosService instance
func NewPhotosService(ctx context.Context, client *Client, pacer *fs.Pacer, shouldRetry ShouldRetryFunc) (*PhotosService, error) {
service, exists := client.Session.AccountInfo.Webservices["ckdatabasews"]
service, exists := client.Session.AccountInfo.Webservices[WsPhotos]
if !exists || service.Status != "active" {
return nil, fmt.Errorf("ckdatabasews service not available")
}
@@ -605,6 +605,13 @@ func (ps *PhotosService) discoverLibraries(ctx context.Context) (*libraryDiscove
continue
}
name := zone.ZoneID.ZoneName
// Only PrimarySync and SharedSync-* are photo libraries. Other
// zones (e.g. CMM-* shared-album zones) appear in changes/database
// but have no CPLAlbumByPositionLive index, so querying their
// albums returns BAD_REQUEST / "Index has invalid data".
if name != "PrimarySync" && !strings.HasPrefix(name, "SharedSync") {
continue
}
// SharedSync-* found in private takes precedence over shared
if _, exists := result.libraries[name]; exists {
continue
@@ -2313,7 +2320,7 @@ func (ps *PhotosService) requestWithReauth(ctx context.Context, makeOpts func()
reauthDone := false
return ps.pacer.Call(func() (bool, error) {
resp, err := ps.client.Session.Request(ctx, makeOpts(), data, response)
if !reauthDone && err != nil && resp != nil && (resp.StatusCode == 401 || resp.StatusCode == 421) {
if !reauthDone && err != nil && resp != nil && (resp.StatusCode == 401 || resp.StatusCode == 421 || resp.StatusCode == 423) {
reauthDone = true
if authErr := ps.client.Authenticate(ctx); authErr != nil {
return false, authErr
+70 -46
View File
@@ -495,7 +495,7 @@ func (s *Session) getSRPAuthHeaders() map[string]string {
return headers
}
// AuthWithToken authenticates the session
// AuthWithToken authenticates the session with the account login endpoint
func (s *Session) AuthWithToken(ctx context.Context) error {
values := map[string]any{
"accountCountryCode": s.AccountCountry,
@@ -522,86 +522,110 @@ func (s *Session) AuthWithToken(ctx context.Context) error {
fs.Debugf(nil, "iclouddrive: accountLogin response cookies: %v", cookieDebugSummaries(resp.Cookies()))
fs.Debugf(nil, "iclouddrive: session cookie jar after accountLogin: %v", cookieJarDebugSummaries(s.Cookies))
// Acquire PCS cookies if Advanced Data Protection is enabled
if ws := s.AccountInfo.Webservices["ckdatabasews"]; ws != nil && ws.PcsRequired {
fs.Debugf(nil, "iclouddrive: ADP detected (pcsRequired=true)")
if s.hasPCSCookies() {
fs.Debugf(nil, "iclouddrive: PCS cookies already present, skipping acquisition")
} else {
if err := s.acquirePCSCookies(ctx); err != nil {
return err
}
}
} else {
fs.Debugf(nil, "iclouddrive: no ADP (pcsRequired=false)")
}
return nil
}
// hasPCSCookies checks if the required PCS cookies for Photos are already present
func (s *Session) hasPCSCookies() bool {
var hasPhotos, hasSharing bool
for _, c := range s.Cookies {
switch c.Name {
case "X-APPLE-WEBAUTH-PCS-Photos":
hasPhotos = true
case "X-APPLE-WEBAUTH-PCS-Sharing":
hasSharing = true
}
}
return hasPhotos && hasSharing
type pcsService struct {
wsKey string
appName string
cookies []string
}
// acquirePCSCookies requests PCS cookies for ADP-enabled accounts
// pcsServices lists all services that need PCS cookies
// appName values from icloud.com JS (Build 2616/19)
var pcsServices = []pcsService{
{WsPhotos, "photos", []string{"X-APPLE-WEBAUTH-PCS-Photos", "X-APPLE-WEBAUTH-PCS-Sharing"}},
{WsDrive, "iclouddrive", []string{"X-APPLE-WEBAUTH-PCS-Documents"}},
}
func (s *Session) hasPCSCookiesFor(names []string) bool {
for _, name := range names {
if !slices.ContainsFunc(s.Cookies, func(c *http.Cookie) bool { return c.Name == name }) {
return false
}
}
return true
}
// ensurePCSCookies checks whether the session needs PCS cookies for the given
// webservice and acquires them if missing, returning true if new cookies were acquired
func (s *Session) ensurePCSCookies(ctx context.Context, pcsWSKey string) (bool, error) {
if pcsWSKey == "" {
return false, nil
}
for _, pcs := range pcsServices {
if pcs.wsKey != pcsWSKey {
continue
}
ws := s.AccountInfo.Webservices[pcs.wsKey]
if ws == nil || !ws.PcsRequired {
return false, nil
}
if s.hasPCSCookiesFor(pcs.cookies) {
return false, nil
}
fs.Debugf(nil, "iclouddrive: ADP detected, acquiring PCS cookies for %s", pcs.appName)
if err := s.acquirePCSCookiesFor(ctx, pcs.appName, pcs.cookies); err != nil {
return false, err
}
return true, nil
}
return false, nil
}
// acquirePCSCookiesFor requests PCS cookies for a specific service on ADP-enabled accounts
// May require user approval on a trusted device (polls every 10s, max 5 min)
func (s *Session) acquirePCSCookies(ctx context.Context) error {
fs.Logf(nil, "iclouddrive: Advanced Data Protection enabled, requesting PCS cookies")
const maxAttempts = 30 // 30 * 10s = 5 minutes max
for attempt := 0; attempt < maxAttempts; attempt++ {
fs.Debugf(nil, "iclouddrive: requestPCS outgoing cookies: %v", cookieJarDebugSummaries(s.Cookies))
func (s *Session) acquirePCSCookiesFor(ctx context.Context, appName string, cookies []string) error {
fs.Logf(nil, "iclouddrive: Advanced Data Protection enabled, requesting PCS cookies for %s", appName)
const maxAttempts = 30
for range maxAttempts {
fs.Debugf(nil, "iclouddrive: requestPCS(%s) outgoing cookies: %v", appName, cookieJarDebugSummaries(s.Cookies))
values := map[string]any{
"appName": "photos",
"appName": appName,
"derivedFromUserAction": true,
}
body, err := IntoReader(values)
if err != nil {
return fmt.Errorf("requestPCS: %w", err)
return fmt.Errorf("requestPCS(%s): %w", appName, err)
}
opts := rest.Opts{
Method: "POST",
Path: "/requestPCS",
ExtraHeaders: s.GetHeaders(map[string]string{}),
RootURL: setupEndpoint,
Body: body,
}
opts.Body = body
var pcsResp struct {
Status string `json:"status"`
Message string `json:"message"`
}
resp, err := s.Request(ctx, opts, nil, &pcsResp)
if err != nil {
return fmt.Errorf("requestPCS: %w", err)
return fmt.Errorf("requestPCS(%s): %w", appName, err)
}
fs.Debugf(nil, "iclouddrive: requestPCS response cookies: %v", cookieDebugSummaries(resp.Cookies()))
fs.Debugf(nil, "iclouddrive: requestPCS response: status=%q message=%q cookies=%d",
pcsResp.Status, pcsResp.Message, len(resp.Cookies()))
fs.Debugf(nil, "iclouddrive: requestPCS(%s) response: status=%q message=%q cookies=%d %v",
appName, pcsResp.Status, pcsResp.Message, len(resp.Cookies()), cookieDebugSummaries(resp.Cookies()))
if pcsResp.Status == "success" {
if !s.hasPCSCookies() {
return fmt.Errorf("requestPCS: server returned success but PCS cookies missing")
if !s.hasPCSCookiesFor(cookies) {
var missing []string
for _, name := range cookies {
if !slices.ContainsFunc(s.Cookies, func(c *http.Cookie) bool { return c.Name == name }) {
missing = append(missing, name)
}
}
return fmt.Errorf("requestPCS(%s): server returned success but cookies still missing: %v", appName, missing)
}
fs.Logf(nil, "iclouddrive: PCS cookies acquired")
fs.Logf(nil, "iclouddrive: PCS cookies acquired for %s", appName)
return nil
}
// Device consent required - poll until approved
fs.Logf(nil, "iclouddrive: waiting for device approval for PCS (%s)", pcsResp.Message)
fs.Logf(nil, "iclouddrive: waiting for device approval for PCS/%s (%s)", appName, pcsResp.Message)
select {
case <-ctx.Done():
return ctx.Err()
case <-time.After(10 * time.Second):
}
}
return fmt.Errorf("requestPCS: timed out waiting for device approval after 5 minutes")
return fmt.Errorf("requestPCS(%s): timed out waiting for device approval after 5 minutes", appName)
}
// RequestPushNotification explicitly requests a push notification to trusted devices
+5 -3
View File
@@ -96,7 +96,7 @@ func resumeConfigClient(m configmap.Mapper, appleid, password, trustToken, clien
if err != nil {
return nil, nil, err
}
icloud, err := api.New(appleid, password, trustToken, clientID, cookies, nil, "_config")
icloud, err := api.New(appleid, password, trustToken, clientID, cookies, nil, "_config", "")
if err != nil {
return nil, nil, err
}
@@ -280,7 +280,7 @@ func Config(ctx context.Context, name string, m configmap.Mapper, config fs.Conf
// Force fresh SRP authentication - ignore stale trust token and cookies
// so that reconnect always prompts for 2FA
m.Set(configAuthSession, "")
icloud, err := api.New(appleid, password, "", clientID, nil, nil, "_config")
icloud, err := api.New(appleid, password, "", clientID, nil, nil, "_config", "")
if err != nil {
return nil, err
}
@@ -410,7 +410,8 @@ func Config(ctx context.Context, name string, m configmap.Mapper, config fs.Conf
// newICloudClient parses options, authenticates, and returns a ready client
// Shared between NewFs (Drive) and NewFsPhotos (Photos) to avoid duplication
func newICloudClient(ctx context.Context, name string, m configmap.Mapper) (*api.Client, *Options, error) {
// pcsWSKey scopes PCS cookie acquisition to the caller's service
func newICloudClient(ctx context.Context, name string, m configmap.Mapper, pcsWSKey string) (*api.Client, *Options, error) {
opt := new(Options)
err := configstruct.Set(m, opt)
if err != nil {
@@ -442,6 +443,7 @@ func newICloudClient(ctx context.Context, name string, m configmap.Mapper) (*api
cookies,
callback,
name,
pcsWSKey,
)
if err != nil {
return nil, nil, err
+1 -1
View File
@@ -677,7 +677,7 @@ func retryResultUnknown(ctx context.Context, resp *http.Response, err error) (bo
// NewFs constructs an Fs from the path, container:path
func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, error) {
icloud, opt, err := newICloudClient(ctx, name, m)
icloud, opt, err := newICloudClient(ctx, name, m, api.WsDrive)
if err != nil {
return nil, err
}
+1 -1
View File
@@ -59,7 +59,7 @@ type PhotosObject struct {
// NewFsPhotos constructs an Fs for Photos from the path, container:path
func NewFsPhotos(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, error) {
icloud, opt, err := newICloudClient(ctx, name, m)
icloud, opt, err := newICloudClient(ctx, name, m, api.WsPhotos)
if err != nil {
return nil, err
}
+4
View File
@@ -81,6 +81,10 @@ func (o *Object) getXattr() (metadata fs.Metadata, err error) {
}
metadata[k] = string(v)
}
// Return nil if all xattrs were filtered out (e.g. com.apple.provenance on macOS)
if len(metadata) == 0 {
return nil, nil
}
return metadata, nil
}
+13
View File
@@ -271,7 +271,20 @@ func (ds *dirStream) Next() (de fuse.DirEntry, errno syscall.Errno) {
func (ds *dirStream) Close() {
}
// Seekdir implements fusefs.FileSeekdirer so go-fuse can rewind the directory
// stream when the kernel calls lseek(fd, 0, SEEK_SET) before a second getdents.
// Without this, go-fuse returns ENOTSUP and ls returns empty on every call after
// the first. See: https://github.com/hanwen/go-fuse/issues/549
func (ds *dirStream) Seekdir(_ context.Context, off uint64) syscall.Errno {
if off == 0 {
ds.i = 0
return 0
}
return syscall.ENOTSUP
}
var _ fusefs.DirStream = (*dirStream)(nil)
var _ fusefs.FileSeekdirer = (*dirStream)(nil)
// Readdir opens a stream of directory entries.
//
+28 -2
View File
@@ -38,7 +38,22 @@ func (v vfsHandler) Fileread(r *sftp.Request) (io.ReaderAt, error) {
}
func (v vfsHandler) Filewrite(r *sftp.Request) (io.WriterAt, error) {
file, err := v.OpenFile(r.Filepath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0777)
// Respect the flags requested in the SFTP OPEN packet
p := r.Pflags()
flags := os.O_WRONLY
if p.Append {
flags |= os.O_APPEND
}
if p.Creat {
flags |= os.O_CREATE
}
if p.Trunc {
flags |= os.O_TRUNC
}
if p.Excl {
flags |= os.O_EXCL
}
file, err := v.OpenFile(r.Filepath, flags, 0777)
if err != nil {
return nil, err
}
@@ -49,7 +64,18 @@ func (v vfsHandler) Filecmd(r *sftp.Request) error {
switch r.Method {
case "Setstat":
attr := r.Attributes()
if attr.Mtime != 0 {
flags := r.AttrFlags()
// A size attribute is a request to truncate the file
if flags.Size {
node, err := v.Stat(r.Filepath)
if err != nil {
return err
}
if err := node.Truncate(int64(attr.Size)); err != nil {
return err
}
}
if flags.Acmodtime {
modTime := time.Unix(int64(attr.Mtime), 0)
err := v.Chtimes(r.Filepath, modTime, modTime)
if err != nil {
+183
View File
@@ -0,0 +1,183 @@
// Test the SFTP serve handler against a real server and client.
//
// We skip tests on platforms with troublesome character mappings
//go:build !windows && !darwin && !plan9
package sftp
import (
"context"
"io"
"os"
"strings"
"testing"
"github.com/pkg/sftp"
_ "github.com/rclone/rclone/backend/local"
"github.com/rclone/rclone/cmd/serve/proxy"
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/vfs/vfscommon"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/crypto/ssh"
)
// startTestServer starts an sftp server serving a temporary local directory
// with the given VFS options and returns a connected sftp client.
func startTestServer(t *testing.T, vfsOpt *vfscommon.Options) *sftp.Client {
ctx := context.Background()
f, err := fs.NewFs(ctx, t.TempDir())
require.NoError(t, err)
opt := Opt
opt.ListenAddr = testBindAddress
opt.User = testUser
opt.Pass = testPass
w, err := newServer(ctx, f, &opt, vfsOpt, &proxy.Opt)
require.NoError(t, err)
go func() {
_ = w.Serve()
}()
t.Cleanup(func() {
assert.NoError(t, w.Shutdown())
})
clientConfig := &ssh.ClientConfig{
User: testUser,
Auth: []ssh.AuthMethod{ssh.Password(testPass)},
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
}
conn, err := ssh.Dial("tcp", w.Addr().String(), clientConfig)
require.NoError(t, err)
t.Cleanup(func() {
_ = conn.Close()
})
client, err := sftp.NewClient(conn)
require.NoError(t, err)
t.Cleanup(func() {
_ = client.Close()
})
return client
}
// Test that re-opening a file for write without the truncate flag preserves
// the data already written, rather than zeroing the start of the file.
//
// This reproduces a corruption seen with WinSCP "Process in Background", which
// resumes an upload on a second connection by re-opening the partial file
// without SSH_FXF_TRUNC and writing from the offset it had reached.
func TestFilewriteResumeNoTruncate(t *testing.T) {
vfsOpt := vfscommon.Opt
vfsOpt.CacheMode = vfscommon.CacheModeWrites
client := startTestServer(t, &vfsOpt)
const (
fileName = "file.bin"
total = 1024 * 1024 // 1 MiB
split = 700 * 1024 // where the upload is "backgrounded"
)
// Deterministic non-zero contents so a zeroed hole is easy to spot
contents := make([]byte, total)
for i := range contents {
contents[i] = byte(i%251 + 1)
}
// First connection: write the first part with truncate, as a fresh upload
f, err := client.OpenFile(fileName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC)
require.NoError(t, err)
_, err = f.Write(contents[:split])
require.NoError(t, err)
require.NoError(t, f.Close())
// Resume: re-open WITHOUT truncate and write the remainder at its offset
f, err = client.OpenFile(fileName, os.O_WRONLY|os.O_CREATE)
require.NoError(t, err)
_, err = f.WriteAt(contents[split:], int64(split))
require.NoError(t, err)
require.NoError(t, f.Close())
// Read the file back and check it is intact - no zeroed prefix
rd, err := client.Open(fileName)
require.NoError(t, err)
got, err := io.ReadAll(rd)
require.NoError(t, err)
require.NoError(t, rd.Close())
require.Equal(t, total, len(got), "wrong file size")
assert.Equal(t, contents, got, "file contents corrupted on resumed upload")
}
// Test that opening a file for write with the truncate flag does truncate any
// existing data, which is the normal overwrite case for most clients.
func TestFilewriteTruncate(t *testing.T) {
vfsOpt := vfscommon.Opt
vfsOpt.CacheMode = vfscommon.CacheModeWrites
client := startTestServer(t, &vfsOpt)
const fileName = "file.bin"
// Write some initial long contents
require.NoError(t, writeFile(client, fileName, strings.Repeat("A", 1024)))
// Overwrite with shorter contents using truncate
const newContents = "hello"
require.NoError(t, writeFile(client, fileName, newContents))
rd, err := client.Open(fileName)
require.NoError(t, err)
got, err := io.ReadAll(rd)
require.NoError(t, err)
require.NoError(t, rd.Close())
assert.Equal(t, newContents, string(got))
}
// Test that a SETSTAT request with a size attribute truncates the file, rather
// than being silently ignored.
func TestSetstatTruncate(t *testing.T) {
vfsOpt := vfscommon.Opt
vfsOpt.CacheMode = vfscommon.CacheModeWrites
client := startTestServer(t, &vfsOpt)
const fileName = "file.bin"
// Write a file and then truncate it via FSETSTAT (a size attribute) on the
// open handle, the way a client setting the final size of an upload does.
f, err := client.OpenFile(fileName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC)
require.NoError(t, err)
_, err = f.Write([]byte(strings.Repeat("A", 1024)))
require.NoError(t, err)
require.NoError(t, f.Truncate(10))
require.NoError(t, f.Close())
fi, err := client.Stat(fileName)
require.NoError(t, err)
assert.Equal(t, int64(10), fi.Size(), "file not truncated to requested size")
rd, err := client.Open(fileName)
require.NoError(t, err)
got, err := io.ReadAll(rd)
require.NoError(t, err)
require.NoError(t, rd.Close())
assert.Equal(t, strings.Repeat("A", 10), string(got))
}
// writeFile writes contents to fileName via the client truncating any existing
// data, the way a normal upload does.
func writeFile(client *sftp.Client, fileName, contents string) error {
f, err := client.OpenFile(fileName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC)
if err != nil {
return err
}
if _, err := f.Write([]byte(contents)); err != nil {
_ = f.Close()
return err
}
return f.Close()
}
+8 -5
View File
@@ -1053,16 +1053,19 @@ encodings.)
The following backends have known issues that need more investigation:
<!--- start list_failures - DO NOT EDIT THIS SECTION - use make commanddocs --->
- `TestGoFile` (`gofile`)
- [`TestBisyncRemoteLocal/rclone_args`](https://pub.rclone.org/integration-tests/current/gofile-cmd.bisync-TestGoFile-1.txt)
- `TestFilen` (`filen`)
- [`TestBisyncRemoteRemote/resync_modes`](https://pub.rclone.org/integration-tests/current/filen-cmd.bisync-TestFilen-1.txt)
- [`TestBisyncRemoteRemote/rmdirs`](https://pub.rclone.org/integration-tests/current/filen-cmd.bisync-TestFilen-1.txt)
- `TestHuaweiDrive` (`huaweidrive`)
- [`TestBisyncRemoteLocal/ext_paths`](https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt)
- [`TestBisyncRemoteLocal/extended_filenames`](https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt)
- [`TestBisyncRemoteLocal/normalization`](https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt)
- [`TestBisyncLocalRemote/ext_paths`](https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt)
- [`TestBisyncLocalRemote/extended_filenames`](https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt)
- [`TestBisyncRemoteRemote/ext_paths`](https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt)
- [2 more](https://pub.rclone.org/integration-tests/current/)
- Updated: 2026-05-22-010013
- [4 more](https://pub.rclone.org/integration-tests/current/)
- `TestSeafile` (`seafile`)
- [`TestBisyncLocalRemote/rmdirs`](https://pub.rclone.org/integration-tests/current/seafile-cmd.bisync-TestSeafile-1.txt)
- Updated: 2026-06-05-010010
<!--- end list_failures - DO NOT EDIT THIS SECTION - use make commanddocs --->
The following backends either have not been tested recently or have known issues
+31
View File
@@ -6,6 +6,37 @@ description: "Rclone Changelog"
# Changelog
## v1.74.3 - 2026-06-05
[See commits](https://github.com/rclone/rclone/compare/v1.74.2...v1.74.3)
- Bug Fixes
- rc
- Fix unauthenticated command execution via `--rc-serve` inline remotes CVE-2026-49980 (Nick Craig-Wood)
- Stop `global.*` connection string options changing config CVE-2026-49980 (Nick Craig-Wood)
- build: Fix multiple CVEs by upgrading to go1.26.4 (Nick Craig-Wood)
- CVE-2026-42504: mime: quadratic complexity in WordDecoder.DecodeHeader
- CVE-2026-42507: net/textproto: arbitrary input are included in errors without any escaping
- CVE-2026-27145: crypto/x509: split candidate hostname only once
- log: Fix wrong source `file:line` in JSON logs from release builds (Nick Craig-Wood)
- mount2: Fix empty directory listings on re-read (Janne Beate Bakeng)
- serve s3: Fix multipart `ListParts` pagination returning wrong part numbers (Nick Craig-Wood)
- serve sftp
- Fix file corruption when a client resumes an upload (Nick Craig-Wood)
- Fix truncate request being silently ignored (Nick Craig-Wood)
- Local
- Fix `getXattr` returning empty map instead of nil (Leon Brocard)
- Drime
- Fix server-side copy and move failing with Cloudflare 520 error (Nick Craig-Wood)
- Fix files being uploaded to the wrong directory (Nick Craig-Wood)
- Remove duplicate upload_cutoff config option (Nick Craig-Wood)
- Fix directory rename leaving the renamed folder empty in VFS (Nick Craig-Wood)
- Drive
- Fix server-side move failing on shared drives with duplicate dirs (Nick Craig-Wood)
- Iclouddrive
- Fix ADP/PCS cookie acquisition for iCloud Drive (Yakov Till)
- Fix "Index has invalid data" error listing iCloud Photos (Nick Craig-Wood)
## v1.74.2 - 2026-05-22
[See commits](https://github.com/rclone/rclone/compare/v1.74.1...v1.74.2)
+1 -1
View File
@@ -1094,7 +1094,7 @@ rclone [flags]
--use-json-log Use json log format
--use-mmap Use mmap allocator (see docs)
--use-server-modtime Use server modified time instead of object metadata
--user-agent string Set the user-agent to a specified string (default "rclone/v1.74.2")
--user-agent string Set the user-agent to a specified string (default "rclone/v1.74.3")
-v, --verbose count Print lots more stuff (repeat for more)
-V, --version Print the version number
--webdav-auth-redirect Preserve authentication on redirect
+2 -2
View File
@@ -231,12 +231,12 @@ rclone convmv "stories/The Quick Brown Fox!.txt" --name-transform "all,command=e
```console
rclone convmv "stories/The Quick Brown Fox!" --name-transform "date=-{YYYYMMDD}"
// Output: stories/The Quick Brown Fox!-20260522
// Output: stories/The Quick Brown Fox!-20260605
```
```console
rclone convmv "stories/The Quick Brown Fox!" --name-transform "date=-{macfriendlytime}"
// Output: stories/The Quick Brown Fox!-2026-05-22 0431PM
// Output: stories/The Quick Brown Fox!-2026-06-05 0414PM
```
```console
+1 -1
View File
@@ -121,7 +121,7 @@ Flags for general networking and HTTP stuff.
--tpslimit float Limit HTTP transactions per second to this
--tpslimit-burst int Max burst of transactions for --tpslimit (default 1)
--use-cookies Enable session cookiejar
--user-agent string Set the user-agent to a specified string (default "rclone/v1.74.2")
--user-agent string Set the user-agent to a specified string (default "rclone/v1.74.3")
```
+18
View File
@@ -78,8 +78,26 @@ so you can browse to `http://127.0.0.1:5572/` or `http://127.0.0.1:5572/*`
to see a listing of the remotes. Objects may be requested from
remotes using this syntax `http://127.0.0.1:5572/[remote:path]/path/to/object`
Unless the rc server has authentication configured (`--rc-user`/`--rc-pass`
or `--rc-htpasswd`) or the `--rc-no-auth` flag is set, only remotes already
present in the config file may be served this way. Inline remotes (e.g.
`[:webdav,url=...:]`), connection string parameters and bare local paths are
rejected, since instantiating them from an unauthenticated request could run
commands or read arbitrary local files.
Default Off.
### global.* connection string options and the rc
Remotes instantiated by the rc do not let [connection
string](/docs/#connection-strings) `global.*` options change rclone's
process-wide configuration. Remotes created directly on the command
line or defined in the config file are unaffected.
A `global.*` option still takes effect for the individual backend it
is set on (exactly like an `override.*` option), it just does not leak
into the global config for the rest of the process.
### --rc-serve-no-modtime
Set this flag to skip reading the modification time (can speed things up).
+1 -1
View File
@@ -1 +1 @@
v1.74.2
v1.74.3
+5 -1
View File
@@ -802,11 +802,15 @@ func GetConfig(ctx context.Context) *ConfigInfo {
}
// CopyConfig copies the global config (if any) from srcCtx into
// dstCtx returning the new context.
// dstCtx returning the new context. It also copies the rc request
// marker if present.
func CopyConfig(dstCtx, srcCtx context.Context) context.Context {
if srcCtx == nil {
return dstCtx
}
if IsRCRequest(srcCtx) {
dstCtx = WithRCRequest(dstCtx)
}
c := srcCtx.Value(configContextKey)
if c == nil {
return dstCtx
+18
View File
@@ -29,3 +29,21 @@ func TestGetConfig(t *testing.T) {
config2ctx := GetConfig(ctx2)
assert.Equal(t, config2, config2ctx)
}
// The rc request marker must survive CopyConfig, which is how rclone
// does detach context but keep config.
func TestRCRequestContext(t *testing.T) {
ctx := context.Background()
assert.False(t, IsRCRequest(ctx))
rcCtx := WithRCRequest(ctx)
assert.True(t, IsRCRequest(rcCtx))
// CopyConfig carries the marker even when there is no config to copy
assert.True(t, IsRCRequest(CopyConfig(context.Background(), rcCtx)))
// and when there is
rcCtx, _ = AddConfig(rcCtx)
assert.True(t, IsRCRequest(CopyConfig(context.Background(), rcCtx)))
// An unmarked context stays unmarked
assert.False(t, IsRCRequest(CopyConfig(context.Background(), ctx)))
}
+15 -2
View File
@@ -79,6 +79,19 @@ func mapLogLevelNames(groups []string, a slog.Attr) slog.Attr {
return a
}
// isLogFrame reports whether frame belongs to the logging machinery
// and so should be skipped when finding the real caller.
//
// rclone's own log packages are matched by file path, but the standard
// library log/slog package is matched by function name: under -trimpath
// its path is rewritten to "log/slog/logger.go", which neither file
// check catches.
func isLogFrame(frame runtime.Frame) bool {
file := frame.File
return strings.HasPrefix(frame.Function, "log/slog.") ||
strings.Contains(file, "/log/") || strings.HasSuffix(file, "log.go")
}
// get the file and line number of the caller skipping skip levels
func getCaller(skip int) string {
var pc [64]uintptr
@@ -92,10 +105,10 @@ func getCaller(skip int) string {
for more {
frame, more = frames.Next()
file := frame.File
if strings.Contains(file, "/log/") || strings.HasSuffix(file, "log.go") {
if isLogFrame(frame) {
continue
}
file := frame.File
line := frame.Line
// shorten file name
+28
View File
@@ -7,6 +7,7 @@ import (
"io"
"os"
"regexp"
"runtime"
"strings"
"sync"
"testing"
@@ -71,6 +72,33 @@ func TestGetCaller(t *testing.T) {
// assert.Equal(t, "slog_test.go", match[1])
}
// Test isLogFrame skips logging-machinery frames, including the
// standard library log/slog frames whose path is trimmed by -trimpath.
func TestIsLogFrame(t *testing.T) {
tests := []struct {
name string
file string
fn string
want bool
}{
// rclone's own log packages
{"fsLog", "github.com/rclone/rclone/fs/log.go", "github.com/rclone/rclone/fs.Debugf", true},
{"fsLogSlog", "github.com/rclone/rclone/fs/log/slog.go", "github.com/rclone/rclone/fs/log.(*OutputHandler).Handle", true},
// standard library slog with -trimpath: path is "log/slog/logger.go"
{"slogTrimpath", "log/slog/logger.go", "log/slog.(*Logger).log", true},
// standard library slog without -trimpath: full path contains "/log/"
{"slogFullPath", "/usr/local/go/src/log/slog/logger.go", "log/slog.(*Logger).Log", true},
// a real caller must not be skipped
{"realCaller", "github.com/rclone/rclone/backend/drive/drive.go", "github.com/rclone/rclone/backend/drive.(*Fs).newObjectWithInfo", false},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
got := isLogFrame(runtime.Frame{File: tc.file, Function: tc.fn})
assert.Equal(t, tc.want, got)
})
}
}
// Test formatStdLogHeader for various flag combinations.
func TestFormatStdLogHeader(t *testing.T) {
cases := []struct {
+18 -2
View File
@@ -25,6 +25,22 @@ var (
overriddenConfig = make(map[string]string)
)
// rcRequestKey marks a context as created by a remote control (rc) request.
type rcRequestKeyType struct{}
var rcRequestKey = rcRequestKeyType{}
// WithRCRequest marks ctx as created by a remote control (rc) request.
func WithRCRequest(ctx context.Context) context.Context {
return context.WithValue(ctx, rcRequestKey, true)
}
// IsRCRequest returns true if ctx was created by a remote control (rc) request.
func IsRCRequest(ctx context.Context) bool {
v, _ := ctx.Value(rcRequestKey).(bool)
return v
}
// NewFs makes a new Fs object from the path
//
// The path is of the form remote:path
@@ -115,8 +131,8 @@ func addConfigToContext(ctx context.Context, configName string, config configmap
return ctx, fmt.Errorf("failed to set override config variables %q: %w", overrideKeys, err)
}
Debugf(configName, "Set overridden config %q for backend startup", overrideKeys)
// Set the global context only
if len(globalConfig) != 0 {
// Set the global context unless this Fs is being created for an rc request
if len(globalConfig) != 0 && !IsRCRequest(ctx) {
globalCI := GetConfig(context.Background())
err = configstruct.Set(globalConfig, globalCI)
if err != nil {
+22
View File
@@ -53,3 +53,25 @@ func TestAddConfigToContext_GlobalOnly(t *testing.T) {
ci := GetConfig(newCtx)
assert.Equal(t, "potato2", ci.UserAgent)
}
// When the ctx is marked as a remote control (rc) request, a global.key must
// apply to the backend's own ctx but must NOT change the process-wide config.
func TestAddConfigToContext_GlobalFromRC(t *testing.T) {
global := configmap.Simple{
"global.user_agent": "potato3",
}
ctx := WithRCRequest(context.Background())
globalCI := GetConfig(ctx)
original := globalCI.UserAgent
defer func() {
globalCI.UserAgent = original
}()
newCtx, err := addConfigToContext(ctx, "unit-test", global)
require.NoError(t, err)
assert.NotEqual(t, newCtx, ctx)
// The process-wide config must be untouched
assert.Equal(t, original, globalCI.UserAgent)
// but the backend's own ctx still gets the value
ci := GetConfig(newCtx)
assert.Equal(t, "potato3", ci.UserAgent)
}
+3
View File
@@ -328,6 +328,9 @@ func (jobs *Jobs) NewJob(ctx context.Context, fn rc.Func, in rc.Params) (job *Jo
// Add the job to the context
ctx = context.WithValue(ctx, jobKey, job)
// Mark the context as created from an rc request
ctx = fs.WithRCRequest(ctx)
if isAsync {
go job.run(ctx, fn, in)
out = make(rc.Params)
+31
View File
@@ -300,6 +300,37 @@ func TestExecuteJobWithConfig(t *testing.T) {
assert.NotEqual(t, 42*fs.Mebi, ci.BufferSize)
}
// NewJob must mark the context as a remote control (rc) request, including for
// asynchronous jobs whose context is detached
func TestNewJobMarksRCRequest(t *testing.T) {
jobID.Store(0)
jobs := newJobs() // local instance so we don't pollute the global registry
// synchronous job
var syncMarked bool
_, _, err := jobs.NewJob(context.Background(), func(ctx context.Context, in rc.Params) (rc.Params, error) {
syncMarked = fs.IsRCRequest(ctx)
return nil, nil
}, rc.Params{})
require.NoError(t, err)
assert.True(t, syncMarked, "sync rc job context must be marked as an rc request")
// asynchronous job - the context is detached, so the marker must be set
// after that detachment to survive
done := make(chan bool, 1)
_, _, err = jobs.NewJob(context.Background(), func(ctx context.Context, in rc.Params) (rc.Params, error) {
done <- fs.IsRCRequest(ctx)
return nil, nil
}, rc.Params{"_async": true})
require.NoError(t, err)
select {
case asyncMarked := <-done:
assert.True(t, asyncMarked, "async rc job context must be marked as an rc request")
case <-time.After(5 * time.Second):
t.Fatal("async job did not run")
}
}
func TestExecuteJobWithFilter(t *testing.T) {
ctx := context.Background()
called := false
+52 -1
View File
@@ -5,6 +5,7 @@ import (
"context"
"encoding/base64"
"encoding/json"
"errors"
"flag"
"fmt"
"mime"
@@ -20,6 +21,7 @@ import (
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fs/cache"
"github.com/rclone/rclone/fs/config"
"github.com/rclone/rclone/fs/fspath"
"github.com/rclone/rclone/fs/list"
"github.com/rclone/rclone/fs/rc"
"github.com/rclone/rclone/fs/rc/jobs"
@@ -325,8 +327,57 @@ func (s *Server) serveRoot(w http.ResponseWriter, r *http.Request) {
directory.Serve(w, r)
}
// checkServeRemote returns an error if fsName must not be instantiated on the
// file-serving (--rc-serve) path given the current authentication state.
//
// Instantiating a backend from request-supplied configuration can execute
// commands during initialisation (e.g. webdav bearer_token_command, sftp ssh),
// read arbitrary local files, or mutate process-wide config via global.*
// options so shouldn't be done without authentication.
//
// authenticated must be true if the request has been authenticated (HTTP auth
// is configured on the server) or --rc-no-auth was passed to explicitly opt in
// to running without authentication.
func checkServeRemote(fsName string, authenticated bool) error {
parsed, err := fspath.Parse(fsName)
if err != nil {
return fmt.Errorf("invalid remote %q: %w", fsName, err)
}
// global.* connection string options mutate process-wide rclone config. Never honour these
// from a request-derived remote, even when the request is authenticated
for k := range parsed.Config {
if strings.HasPrefix(k, "global.") {
return fmt.Errorf("setting %q on a served remote is not allowed", k)
}
}
if authenticated {
return nil
}
// On an unauthenticated server only allow access to pre-configured named remotes. Reject
// inline backend definitions, connection string option overrides and bare local paths
switch {
case parsed.Name == "":
return errors.New("serving local paths requires authentication to be set up on the rc server or the --rc-no-auth flag")
case strings.HasPrefix(parsed.Name, ":"):
return errors.New("serving inline remotes requires authentication to be set up on the rc server or the --rc-no-auth flag")
case len(parsed.Config) > 0:
return errors.New("serving remotes with connection string parameters requires authentication to be set up on the rc server or the --rc-no-auth flag")
}
return nil
}
func (s *Server) serveRemote(w http.ResponseWriter, r *http.Request, path string, fsName string) {
f, err := cache.Get(s.ctx, fsName)
// Check we are allowed to instantiate this remote
authenticated := s.noAuth || s.server.UsingAuth()
if err := checkServeRemote(fsName, authenticated); err != nil {
writeError(path, nil, w, err, http.StatusForbidden)
return
}
// Mark as an rc request e.g. so NewFs can reject global.* config
f, err := cache.Get(fs.WithRCRequest(s.ctx), fsName)
if err != nil {
writeError(path, nil, w, fmt.Errorf("failed to make Fs: %w", err), http.StatusInternalServerError)
return
+130
View File
@@ -368,9 +368,138 @@ func TestRemoteServing(t *testing.T) {
opt := newTestOpt()
opt.Serve = true
opt.Files = testFs
opt.NoAuth = true
testServer(t, tests, &opt)
}
// checkServeRemote must reject request-derived backend instantiation on the
// unauthenticated file-serving path, and global.* config mutation.
func TestCheckServeRemote(t *testing.T) {
for _, test := range []struct {
name string
fsName string
authenticated bool
wantErr string // substring of expected error, "" means no error
}{
// Plain named remotes are always allowed
{name: "named remote unauth", fsName: "remote:path", wantErr: ""},
{name: "named remote auth", fsName: "remote:path", authenticated: true, wantErr: ""},
// Inline backend definitions can run commands (webdav bearer_token_command, sftp ssh)
{name: "inline webdav unauth", fsName: ":webdav,url=http://localhost,bearer_token_command=id:", wantErr: "inline remotes"},
{name: "inline sftp unauth", fsName: ":sftp,ssh=id:", wantErr: "inline remotes"},
{name: "inline local unauth", fsName: ":local:/etc", wantErr: "inline remotes"},
{name: "inline allowed when authed", fsName: ":local:/etc", authenticated: true, wantErr: ""},
// Bare local paths allow arbitrary local file access
{name: "bare path unauth", fsName: "/etc/passwd", wantErr: "local paths"},
{name: "bare path allowed when authed", fsName: "/etc/passwd", authenticated: true, wantErr: ""},
// Connection string overrides can set command-executing options
{name: "connection string unauth", fsName: "remote,vendor=other:path", wantErr: "connection string"},
{name: "connection string allowed when authed", fsName: "remote,vendor=other:path", authenticated: true, wantErr: ""},
// global.* mutates process-wide config and is never allowed
{name: "global config unauth", fsName: "remote,global.http_proxy=x:path", wantErr: "global.http_proxy"},
{name: "global config blocked even when authed", fsName: "remote,global.http_proxy=x:path", authenticated: true, wantErr: "global.http_proxy"},
} {
t.Run(test.name, func(t *testing.T) {
err := checkServeRemote(test.fsName, test.authenticated)
if test.wantErr == "" {
assert.NoError(t, err)
} else {
require.Error(t, err)
assert.Contains(t, err.Error(), test.wantErr)
}
})
}
}
// On an unauthenticated server the serve path must not instantiate
// attacker-supplied inline remotes or local paths, but must still allow
// configured named remotes.
func TestServeRemoteUnauthenticated(t *testing.T) {
forbidden := regexp.MustCompile(`"status": 403`)
tests := []testRun{{
// An inline remote could run a command during initialisation
Name: "inline-remote-rejected",
URL: "[:local:" + testFs + "]/file.txt",
Status: http.StatusForbidden,
Contains: forbidden,
}, {
Name: "bare-local-path-rejected",
URL: remoteURL + "file.txt",
Status: http.StatusForbidden,
Contains: forbidden,
}, {
// A configured (here non-existent) named remote is allowed through to
// the backend, which then reports it isn't in the config file
Name: "named-remote-allowed-through",
URL: "[notfoundremote:]/",
Status: http.StatusInternalServerError,
Contains: regexp.MustCompile(`didn't find section in config file`),
}}
opt := newTestOpt()
opt.Serve = true
testServer(t, tests, &opt)
}
// With authentication configured the serve path may instantiate inline remotes
// (the request is authenticated) but must still refuse to mutate process-wide
// config via global.* options.
func TestServeRemoteWithAuth(t *testing.T) {
const user, pass = "user", "pass"
tests := []testRun{{
// Authenticated requests can serve bare local paths again
Name: "bare-local-path-served-when-authenticated",
URL: remoteURL + "file.txt",
User: user,
Pass: pass,
Status: http.StatusOK,
Expected: "this is file1.txt\n",
}, {
// global.* is blocked even for an authenticated request
Name: "global-config-blocked-when-authenticated",
URL: "[notfoundremote,global.http_proxy=x:]/",
User: user,
Pass: pass,
Status: http.StatusForbidden,
Contains: regexp.MustCompile(`global\.http_proxy`),
}, {
// A request without credentials is rejected before reaching the handler
Name: "unauthenticated-request-rejected",
URL: remoteURL + "file.txt",
Status: http.StatusUnauthorized,
Contains: regexp.MustCompile(``),
}}
opt := newTestOpt()
opt.Serve = true
opt.Files = testFs
opt.Auth.BasicUser = user
opt.Auth.BasicPass = pass
testServer(t, tests, &opt)
}
// The serve path must mark backend creation as a remote control (rc) request
// so a request-supplied remote can't change process-wide config via global.*
// options.
func TestServeRemoteMarksRCRequest(t *testing.T) {
configfile.Install()
opt := newTestOpt()
opt.Serve = true
opt.NoAuth = true // allow inline remotes so we reach backend creation
opt.Template.Path = defaultTestTemplate
rcServer, err := newServer(context.Background(), &opt, http.NewServeMux())
require.NoError(t, err)
ctx := context.Background()
original := fs.GetConfig(ctx).UserAgent
defer func() { fs.GetConfig(ctx).UserAgent = original }()
// serveRemote uses s.ctx, marked as an rc request, so global.* must not
// change the process-wide config.
rcServer.serveRemote(httptest.NewRecorder(), httptest.NewRequest("GET", "/file.txt", nil),
"file.txt", ":local,global.user_agent=rcservertest:"+testFs)
assert.Equal(t, original, fs.GetConfig(ctx).UserAgent,
"the serve path must not let global.* change the process-wide config")
}
func TestRC(t *testing.T) {
tests := []testRun{{
Name: "rc-root",
@@ -853,6 +982,7 @@ func TestServeModTime(t *testing.T) {
opt := newTestOpt()
opt.Serve = true
opt.Template.Path = "testdata/golden/testmodtime.html"
opt.NoAuth = true
tests := []testRun{{
Name: "modtime",
+1 -1
View File
@@ -1,4 +1,4 @@
package fs
// VersionTag of rclone
var VersionTag = "v1.74.2"
var VersionTag = "v1.74.3"
+1 -1
View File
@@ -73,7 +73,7 @@ require (
github.com/quasilyte/go-ruleguard/dsl v0.3.23
github.com/rclone/Proton-API-Bridge v1.0.3
github.com/rclone/go-proton-api v1.0.2
github.com/rclone/gofakes3 v0.0.4
github.com/rclone/gofakes3 v0.0.6
github.com/rfjakob/eme v1.2.0
github.com/rivo/uniseg v0.4.7
github.com/rogpeppe/go-internal v1.14.1
+2 -2
View File
@@ -598,8 +598,8 @@ github.com/rclone/Proton-API-Bridge v1.0.3 h1:Bs7RC4xCFSN0BPIYVda/BNxp0qo3NV0gB2
github.com/rclone/Proton-API-Bridge v1.0.3/go.mod h1:26RAest751Ofk+F/d8xtl4UyWXrZvMQwn39U8rm/WKM=
github.com/rclone/go-proton-api v1.0.2 h1:cJtJUab0MGJ3C6q5kiEJs3pbyhSLnOKMyYOQehA0PBc=
github.com/rclone/go-proton-api v1.0.2/go.mod h1:LB2kCEaZMzNn3ocdz+qYfxXmuLxxN0ka62KJd2x53Bc=
github.com/rclone/gofakes3 v0.0.4 h1:LswpC49VY/UJ1zucoL5ktnOEX6lq3qK7e1aFIAfqCbk=
github.com/rclone/gofakes3 v0.0.4/go.mod h1:j/UoS+2/Mr7xAlfKhyVC58YyFQmh9uoQA5YZQXQUqmg=
github.com/rclone/gofakes3 v0.0.6 h1:gTW5Dq04EouaoKyyTSuSL+WS3VZU3k2QNOBn9ghX7kE=
github.com/rclone/gofakes3 v0.0.6/go.mod h1:M/uFc52GcEFuIP4stgrSR99SqqqxMR0ncgiTbj0eszc=
github.com/relvacode/iso8601 v1.7.0 h1:BXy+V60stMP6cpswc+a93Mq3e65PfXCgDFfhvNNGrdo=
github.com/relvacode/iso8601 v1.7.0/go.mod h1:FlNp+jz+TXpyRqgmM7tnzHHzBnz776kmAH2h3sZCn0I=
github.com/rfjakob/eme v1.2.0 h1:8dAHL+WVAw06+7DkRKnRiFp1JL3QjcJEZFqDnndUaSI=
+2 -2
View File
@@ -218,12 +218,12 @@ rclone convmv "stories/The Quick Brown Fox!.txt" --name-transform "all,command=e
```console
rclone convmv "stories/The Quick Brown Fox!" --name-transform "date=-{YYYYMMDD}"
// Output: stories/The Quick Brown Fox!-20260522
// Output: stories/The Quick Brown Fox!-20260605
```
```console
rclone convmv "stories/The Quick Brown Fox!" --name-transform "date=-{macfriendlytime}"
// Output: stories/The Quick Brown Fox!-2026-05-22 0446PM
// Output: stories/The Quick Brown Fox!-2026-06-05 0419PM
```
```console
Generated
+119 -10
View File
@@ -15,7 +15,7 @@
. ftr VB CB
. ftr VBI CBI
.\}
.TH "rclone" "1" "May 22, 2026" "User Manual" ""
.TH "rclone" "1" "Jun 05, 2026" "User Manual" ""
.hy
.SH NAME
.PP
@@ -6326,14 +6326,14 @@ rclone convmv \[dq]stories/The Quick Brown Fox!.txt\[dq] --name-transform \[dq]a
.nf
\f[C]
rclone convmv \[dq]stories/The Quick Brown Fox!\[dq] --name-transform \[dq]date=-{YYYYMMDD}\[dq]
// Output: stories/The Quick Brown Fox!-20260522
// Output: stories/The Quick Brown Fox!-20260605
\f[R]
.fi
.IP
.nf
\f[C]
rclone convmv \[dq]stories/The Quick Brown Fox!\[dq] --name-transform \[dq]date=-{macfriendlytime}\[dq]
// Output: stories/The Quick Brown Fox!-2026-05-22 0431PM
// Output: stories/The Quick Brown Fox!-2026-06-05 0414PM
\f[R]
.fi
.IP
@@ -25430,7 +25430,28 @@ see a listing of the remotes.
Objects may be requested from remotes using this syntax
\f[V]http://127.0.0.1:5572/[remote:path]/path/to/object\f[R]
.PP
Unless the rc server has authentication configured
(\f[V]--rc-user\f[R]/\f[V]--rc-pass\f[R] or \f[V]--rc-htpasswd\f[R]) or
the \f[V]--rc-no-auth\f[R] flag is set, only remotes already present in
the config file may be served this way.
Inline remotes (e.g.
\f[V][:webdav,url=...:]\f[R]), connection string parameters and bare
local paths are rejected, since instantiating them from an
unauthenticated request could run commands or read arbitrary local
files.
.PP
Default Off.
.SS global.* connection string options and the rc
.PP
Remotes instantiated by the rc do not let connection
string (https://rclone.org/docs/#connection-strings) \f[V]global.*\f[R]
options change rclone\[aq]s process-wide configuration.
Remotes created directly on the command line or defined in the config
file are unaffected.
.PP
A \f[V]global.*\f[R] option still takes effect for the individual
backend it is set on (exactly like an \f[V]override.*\f[R] option), it
just does not leak into the global config for the rest of the process.
.SS --rc-serve-no-modtime
.PP
Set this flag to skip reading the modification time (can speed things
@@ -30179,7 +30200,7 @@ Flags for general networking and HTTP stuff.
--tpslimit float Limit HTTP transactions per second to this
--tpslimit-burst int Max burst of transactions for --tpslimit (default 1)
--use-cookies Enable session cookiejar
--user-agent string Set the user-agent to a specified string (default \[dq]rclone/v1.74.2\[dq])
--user-agent string Set the user-agent to a specified string (default \[dq]rclone/v1.74.3\[dq])
\f[R]
.fi
.SS Performance
@@ -33477,10 +33498,12 @@ filename encodings.)
.PP
The following backends have known issues that need more investigation:
.IP \[bu] 2
\f[V]TestGoFile\f[R] (\f[V]gofile\f[R])
\f[V]TestFilen\f[R] (\f[V]filen\f[R])
.RS 2
.IP \[bu] 2
\f[V]TestBisyncRemoteLocal/rclone_args\f[R] (https://pub.rclone.org/integration-tests/current/gofile-cmd.bisync-TestGoFile-1.txt)
\f[V]TestBisyncRemoteRemote/resync_modes\f[R] (https://pub.rclone.org/integration-tests/current/filen-cmd.bisync-TestFilen-1.txt)
.IP \[bu] 2
\f[V]TestBisyncRemoteRemote/rmdirs\f[R] (https://pub.rclone.org/integration-tests/current/filen-cmd.bisync-TestFilen-1.txt)
.RE
.IP \[bu] 2
\f[V]TestHuaweiDrive\f[R] (\f[V]huaweidrive\f[R])
@@ -33490,16 +33513,22 @@ The following backends have known issues that need more investigation:
.IP \[bu] 2
\f[V]TestBisyncRemoteLocal/extended_filenames\f[R] (https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt)
.IP \[bu] 2
\f[V]TestBisyncRemoteLocal/normalization\f[R] (https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt)
.IP \[bu] 2
\f[V]TestBisyncLocalRemote/ext_paths\f[R] (https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt)
.IP \[bu] 2
\f[V]TestBisyncLocalRemote/extended_filenames\f[R] (https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt)
.IP \[bu] 2
\f[V]TestBisyncRemoteRemote/ext_paths\f[R] (https://pub.rclone.org/integration-tests/current/huaweidrive-cmd.bisync-TestHuaweiDrive-1.txt)
.IP \[bu] 2
2 more (https://pub.rclone.org/integration-tests/current/)
4 more (https://pub.rclone.org/integration-tests/current/)
.RE
.IP \[bu] 2
Updated: 2026-05-22-010013
\f[V]TestSeafile\f[R] (\f[V]seafile\f[R])
.RS 2
.IP \[bu] 2
\f[V]TestBisyncLocalRemote/rmdirs\f[R] (https://pub.rclone.org/integration-tests/current/seafile-cmd.bisync-TestSeafile-1.txt)
.RE
.IP \[bu] 2
Updated: 2026-06-05-010010
.PP
The following backends either have not been tested recently or have
known issues that are deemed unfixable for the time being:
@@ -90121,6 +90150,86 @@ Options:
.IP \[bu] 2
\[dq]error\[dq]: Return an error based on option value.
.SH Changelog
.SS v1.74.3 - 2026-06-05
.PP
See commits (https://github.com/rclone/rclone/compare/v1.74.2...v1.74.3)
.IP \[bu] 2
Bug Fixes
.RS 2
.IP \[bu] 2
rc
.RS 2
.IP \[bu] 2
Fix unauthenticated command execution via \f[V]--rc-serve\f[R] inline
remotes CVE-2026-49980 (Nick Craig-Wood)
.IP \[bu] 2
Stop \f[V]global.*\f[R] connection string options changing config
CVE-2026-49980 (Nick Craig-Wood)
.RE
.IP \[bu] 2
build: Fix multiple CVEs by upgrading to go1.26.4 (Nick Craig-Wood)
.RS 2
.IP \[bu] 2
CVE-2026-42504: mime: quadratic complexity in WordDecoder.DecodeHeader
.IP \[bu] 2
CVE-2026-42507: net/textproto: arbitrary input are included in errors
without any escaping
.IP \[bu] 2
CVE-2026-27145: crypto/x509: split candidate hostname only once
.RE
.IP \[bu] 2
log: Fix wrong source \f[V]file:line\f[R] in JSON logs from release
builds (Nick Craig-Wood)
.IP \[bu] 2
mount2: Fix empty directory listings on re-read (Janne Beate Bakeng)
.IP \[bu] 2
serve s3: Fix multipart \f[V]ListParts\f[R] pagination returning wrong
part numbers (Nick Craig-Wood)
.IP \[bu] 2
serve sftp
.RS 2
.IP \[bu] 2
Fix file corruption when a client resumes an upload (Nick Craig-Wood)
.IP \[bu] 2
Fix truncate request being silently ignored (Nick Craig-Wood)
.RE
.RE
.IP \[bu] 2
Local
.RS 2
.IP \[bu] 2
Fix \f[V]getXattr\f[R] returning empty map instead of nil (Leon Brocard)
.RE
.IP \[bu] 2
Drime
.RS 2
.IP \[bu] 2
Fix server-side copy and move failing with Cloudflare 520 error (Nick
Craig-Wood)
.IP \[bu] 2
Fix files being uploaded to the wrong directory (Nick Craig-Wood)
.IP \[bu] 2
Remove duplicate upload_cutoff config option (Nick Craig-Wood)
.IP \[bu] 2
Fix directory rename leaving the renamed folder empty in VFS (Nick
Craig-Wood)
.RE
.IP \[bu] 2
Drive
.RS 2
.IP \[bu] 2
Fix server-side move failing on shared drives with duplicate dirs (Nick
Craig-Wood)
.RE
.IP \[bu] 2
Iclouddrive
.RS 2
.IP \[bu] 2
Fix ADP/PCS cookie acquisition for iCloud Drive (Yakov Till)
.IP \[bu] 2
Fix \[dq]Index has invalid data\[dq] error listing iCloud Photos (Nick
Craig-Wood)
.RE
.SS v1.74.2 - 2026-05-22
.PP
See commits (https://github.com/rclone/rclone/compare/v1.74.1...v1.74.2)
+13
View File
@@ -0,0 +1,13 @@
//go:build !linux && !darwin && !freebsd
package vfstest
import (
"runtime"
"testing"
)
// TestDirRewind checks that re-reading a rewound directory works
func TestDirRewind(t *testing.T) {
t.Skip("not supported on " + runtime.GOOS)
}
+75
View File
@@ -0,0 +1,75 @@
//go:build linux || darwin || freebsd
package vfstest
import (
"syscall"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// countDirFd reads the directory referred to by fd to end-of-stream using
// raw getdents syscalls and returns the number of entries (excluding "." and
// ".." which ParseDirent skips).
//
// This deliberately uses syscall.ReadDirent rather than (*os.File).Readdir so
// that it exercises the kernel readdir path directly on a single file
// descriptor, the same way an in-process rewinddir does.
func countDirFd(t *testing.T, fd int) int {
buf := make([]byte, 8192)
var names []string
for {
n, err := syscall.ReadDirent(fd, buf)
require.NoError(t, err)
if n <= 0 {
break
}
_, _, names = syscall.ParseDirent(buf[:n], -1, names)
}
return len(names)
}
// TestDirRewind checks that re-reading a directory after rewinding the
// directory stream (lseek(fd, 0, SEEK_SET), as rewinddir(3) does) returns the
// same entries as the first read.
//
// This reproduces the bug where the mount2 backend returned an empty listing
// on every read after the first because go-fuse v2.9.0 rewinds a directory by
// calling Seekdir, which dirStream did not implement. See PR #9469 and
// https://github.com/hanwen/go-fuse/issues/549
func TestDirRewind(t *testing.T) {
run.skipIfVFS(t)
run.skipIfNoFUSE(t)
run.mkdir(t, "dir")
run.createFile(t, "dir/f1", "1")
run.createFile(t, "dir/f2", "2")
run.createFile(t, "dir/f3", "3")
run.checkDir(t, "dir/|dir/f1 1|dir/f2 1|dir/f3 1")
fh, err := run.os.Open(run.path("dir"))
require.NoError(t, err)
defer func() {
_ = fh.Close()
}()
fd := int(fh.Fd())
first := countDirFd(t, fd)
assert.Equal(t, 3, first, "first read should see all entries")
// rewinddir == lseek(fd, 0, SEEK_SET)
_, err = syscall.Seek(fd, 0, 0)
require.NoError(t, err)
second := countDirFd(t, fd)
assert.Equal(t, first, second, "re-read after rewind should match first read")
require.NoError(t, fh.Close())
run.rm(t, "dir/f1")
run.rm(t, "dir/f2")
run.rm(t, "dir/f3")
run.rmdir(t, "dir")
run.checkDir(t, "")
}
+1
View File
@@ -86,6 +86,7 @@ func RunTests(t *testing.T, useVFS bool, minimumRequiredCacheMode vfscommon.Cach
t.Run("TestDirRenameEmptyDir", TestDirRenameEmptyDir)
t.Run("TestDirRenameFullDir", TestDirRenameFullDir)
t.Run("TestDirModTime", TestDirModTime)
t.Run("TestDirRewind", TestDirRewind)
if enableCacheTests {
t.Run("TestDirCacheFlush", TestDirCacheFlush)
}