Compare commits
68
Commits
v1.74.2
...
v1.74-stable
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5bc93a2a7a | ||
|
|
d9b28b9e7d | ||
|
|
874a804f52 | ||
|
|
e58f09739a | ||
|
|
7e78929575 | ||
|
|
015fd0eba1 | ||
|
|
1a74673244 | ||
|
|
c89b766cf4 | ||
|
|
9ebca99cd2 | ||
|
|
0f4a8fad64 | ||
|
|
888a80e64b | ||
|
|
b440d18897 | ||
|
|
c9ff593a7f | ||
|
|
39487c5ebf | ||
|
|
eb09655949 | ||
|
|
c2d711e714 | ||
|
|
2a6591d1cd | ||
|
|
b9fd40d182 | ||
|
|
e4093ec952 | ||
|
|
2ebb9a6c72 | ||
|
|
76a96a91b4 | ||
|
|
c98ab6ae97 | ||
|
|
e9dcfa12c2 | ||
|
|
a8e9793c02 | ||
|
|
81cfc9ab1b | ||
|
|
efa0e81074 | ||
|
|
5d94fa3184 | ||
|
|
ad7f846048 | ||
|
|
1a55ea17bf | ||
|
|
f0b43b59b4 | ||
|
|
af2853f7c9 | ||
|
|
bc6d5894f2 | ||
|
|
82c899e39c | ||
|
|
215dd7a06a | ||
|
|
5e190ba2a6 | ||
|
|
a19391014f | ||
|
|
dfdcda829e | ||
|
|
e0746b3b8d | ||
|
|
3d560453a1 | ||
|
|
792a8ac91f | ||
|
|
3f80fe0b07 | ||
|
|
660b630979 | ||
|
|
85a12f22c8 | ||
|
|
0e5e79ed50 | ||
|
|
3b00bbf730 | ||
|
|
3654e9cfb7 | ||
|
|
40cd3c99e6 | ||
|
|
6653752779 | ||
|
|
6e67723dc5 | ||
|
|
37e4117f48 | ||
|
|
9222ed2c5a | ||
|
|
48da1774f4 | ||
|
|
2a7b0d0d3b | ||
|
|
fc4349dc16 | ||
|
|
dff3a0731e | ||
|
|
5f5e2ef9cf | ||
|
|
d4397faa94 | ||
|
|
7324ee850a | ||
|
|
3c54a37488 | ||
|
|
a2f8b493ed | ||
|
|
641702fc7f | ||
|
|
f25d9e2bf3 | ||
|
|
ec28206d8a | ||
|
|
ddbc886395 | ||
|
|
c8ceb209fc | ||
|
|
5b4eb0eefb | ||
|
|
223e473e6e | ||
|
|
bac27547d5 |
No files matched your search
+121
-10
@@ -37,7 +37,7 @@ jobs:
|
||||
include:
|
||||
- job_name: linux
|
||||
os: ubuntu-latest
|
||||
go: '~1.26.3'
|
||||
go: '~1.26.5'
|
||||
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.5'
|
||||
goarch: 386
|
||||
gotags: cmount
|
||||
quicktest: true
|
||||
|
||||
- job_name: mac_amd64
|
||||
os: macos-latest
|
||||
go: '~1.26.3'
|
||||
go: '~1.26.5'
|
||||
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.5'
|
||||
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.5'
|
||||
gotags: cmount
|
||||
cgo: '0'
|
||||
build_flags: '-include "^windows/"'
|
||||
@@ -81,14 +81,14 @@ jobs:
|
||||
|
||||
- job_name: other_os
|
||||
os: ubuntu-latest
|
||||
go: '~1.26.3'
|
||||
go: '~1.26.5'
|
||||
build_flags: '-exclude "^(windows/|darwin/|linux/)"'
|
||||
compile_all: true
|
||||
deploy: true
|
||||
|
||||
- job_name: go1.25
|
||||
os: ubuntu-latest
|
||||
go: '~1.25.7'
|
||||
go: '~1.25.12'
|
||||
quicktest: true
|
||||
racequicktest: 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.5'
|
||||
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.5'
|
||||
# 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
+421
-29
@@ -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">Jul 08, 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 "stories/The Quick Brown Fox!.txt" --name-transform "all,command=echo"
|
||||
// Output: stories/The Quick Brown Fox!.txt</code></pre>
|
||||
<pre class="console"><code>rclone convmv "stories/The Quick Brown Fox!" --name-transform "date=-{YYYYMMDD}"
|
||||
// Output: stories/The Quick Brown Fox!-20260522</code></pre>
|
||||
// Output: stories/The Quick Brown Fox!-20260708</code></pre>
|
||||
<pre class="console"><code>rclone convmv "stories/The Quick Brown Fox!" --name-transform "date=-{macfriendlytime}"
|
||||
// Output: stories/The Quick Brown Fox!-2026-05-22 0431PM</code></pre>
|
||||
// Output: stories/The Quick Brown Fox!-2026-07-08 0504PM</code></pre>
|
||||
<pre class="console"><code>rclone convmv "stories/The Quick Brown Fox!.txt" --name-transform "all,regex=[\\.\\w]/ab"
|
||||
// Output: ababababababab/ababab ababababab ababababab ababab!abababab</code></pre>
|
||||
<p>The regex command generally accepts Perl-style regular expressions,
|
||||
@@ -4778,8 +4777,9 @@ for rclone commands, flags and backends.</li>
|
||||
<h2 id="synopsis-47">Synopsis</h2>
|
||||
<p>If source:path is a file or directory then it copies it to a file or
|
||||
directory named dest:path.</p>
|
||||
<p>This can be used to upload single files to other than their current
|
||||
name. If the source is a directory then it acts exactly like the <a
|
||||
<p>This can be used to copy a single file to a destination with a name
|
||||
different from its source - for example, uploading and renaming in one
|
||||
step. If the source is a directory then it acts exactly like the <a
|
||||
href="https://rclone.org/commands/rclone_copy/">copy</a> command.</p>
|
||||
<p>So</p>
|
||||
<pre class="console"><code>rclone copyto src dst</code></pre>
|
||||
@@ -11802,6 +11802,16 @@ backend, which can take some time.</p>
|
||||
<p>Metadata will only be saved in memory other than the rclone
|
||||
<code>mtime</code> metadata which will be set as the modification time
|
||||
of the file.</p>
|
||||
<h2 id="object-names">Object names</h2>
|
||||
<p><code>serve s3</code> stores objects as files in the backend, so
|
||||
object keys are mapped to file paths rather than treated as the opaque
|
||||
strings AWS S3 allows. Keys must be in canonical path form: keys that
|
||||
contain <code>..</code> or <code>.</code> path segments, repeated
|
||||
slashes (<code>//</code>), or a leading or trailing slash are rejected
|
||||
with a <code>400 Bad Request</code> (<code>InvalidArgument</code>)
|
||||
instead of being normalised, since normalising them could alias two
|
||||
distinct keys to the same file or resolve a key outside its bucket. This
|
||||
matches the behaviour of other S3 servers such as MinIO.</p>
|
||||
<h2 id="supported-operations">Supported operations</h2>
|
||||
<p><code>serve s3</code> currently supports the following
|
||||
operations.</p>
|
||||
@@ -15631,7 +15641,8 @@ outputs warnings and significant events.</p>
|
||||
<p><code>ERROR</code> is equivalent to <code>-q</code>. It only outputs
|
||||
error messages.</p>
|
||||
<p>See also the <a href="#logging">logging</a> section.</p>
|
||||
<h3 id="windows-event-log-loglevel">--windows-event-log LogLevel</h3>
|
||||
<h3 id="windows-event-log-level-loglevel">--windows-event-log-level
|
||||
LogLevel</h3>
|
||||
<p>If this is configured (the default is <code>OFF</code>) then logs of
|
||||
this level and above will be logged to the Windows event log in
|
||||
<strong>addition</strong> to the normal logs. These will be logged in
|
||||
@@ -15650,13 +15661,13 @@ defined but not currently used).</li>
|
||||
<p>Rclone will declare its log source as "rclone" if it is has enough
|
||||
permissions to create the registry key needed. If not then logs will
|
||||
appear as "Application". You can run
|
||||
<code>rclone version --windows-event-log DEBUG</code> once as
|
||||
<code>rclone version --windows-event-log-level DEBUG</code> once as
|
||||
administrator to create the registry key in advance.</p>
|
||||
<p><strong>Note</strong> that the <code>--windows-event-log</code> level
|
||||
must be greater (more severe) than or equal to the
|
||||
<p><strong>Note</strong> that the <code>--windows-event-log-level</code>
|
||||
level must be greater (more severe) than or equal to the
|
||||
<code>--log-level</code>. For example to log DEBUG to a log file but
|
||||
ERRORs to the event log you would use</p>
|
||||
<pre class="text"><code>--log-file rclone.log --log-level DEBUG --windows-event-log ERROR</code></pre>
|
||||
<pre class="text"><code>--log-file rclone.log --log-level DEBUG --windows-event-log-level ERROR</code></pre>
|
||||
<p>This option is only supported Windows platforms.</p>
|
||||
<h3 id="use-json-log">--use-json-log</h3>
|
||||
<p>This switches the log format to JSON. The log messages are then
|
||||
@@ -17216,8 +17227,8 @@ y/e/d></code></pre>
|
||||
<h2 id="configuring-by-copying-the-config-file">Configuring by copying
|
||||
the config file</h2>
|
||||
<p>Rclone stores all of its configuration in a single file. This can
|
||||
easily be copied to configure a remote rclone (although some backends
|
||||
does not support reusing the same configuration, consult your backend
|
||||
easily be copied to configure a remote rclone (although some backends do
|
||||
not support reusing the same configuration, consult your backend
|
||||
documentation to be sure).</p>
|
||||
<p>Start by running <a href="/commands/rclone_config">rclone config</a>
|
||||
to create the configuration file on your desktop machine.</p>
|
||||
@@ -18250,6 +18261,52 @@ API.</p>
|
||||
API or <a href="#api-http">use HTTP directly</a>.</p>
|
||||
<p>If you just want to run a remote control then see the <a
|
||||
href="https://rclone.org/commands/rclone_rcd/">rcd</a> command.</p>
|
||||
<h2 id="security">Security</h2>
|
||||
<p><strong>Access to the rc API is equivalent to shell access as the
|
||||
user running rclone.</strong> Treat the rc port as you would an
|
||||
interactive login on the host.</p>
|
||||
<p>Any caller who can reach the API (and pass authentication, if it is
|
||||
enabled) can, among other things:</p>
|
||||
<ul>
|
||||
<li><strong>Run OS commands</strong> as the rclone user.
|
||||
<code>core/command</code> re-executes the rclone binary with arbitrary
|
||||
arguments, and several backend options shell out to programs, so even
|
||||
creating a remote with <code>config/create</code> can lead to command
|
||||
execution.</li>
|
||||
<li><strong>Read and write any file</strong> reachable by the rclone
|
||||
process, by pointing <code>operations/*</code> or <code>sync/*</code> at
|
||||
a <code>local</code> remote (or via <code>--rc-files</code> /
|
||||
<code>--rc-serve</code>). Writing arbitrary files as the rclone user is
|
||||
itself a route to code execution.</li>
|
||||
<li><strong>Read back stored credentials.</strong> rclone configs
|
||||
routinely hold cloud-provider secrets. <code>config/dump</code> and
|
||||
friends expose them, so a compromise of the rc reaches every configured
|
||||
backend.</li>
|
||||
<li><strong>Change rclone's runtime behaviour</strong> with
|
||||
<code>options/set</code>, <strong>manage remotes</strong> with
|
||||
<code>config/*</code>, and <strong>stop the process</strong> with
|
||||
<code>core/quit</code>.</li>
|
||||
</ul>
|
||||
<p>There is currently no per-endpoint capability or scope system:
|
||||
authentication is all-or-nothing. Granting any access grants all of the
|
||||
above.</p>
|
||||
<p>Consequently:</p>
|
||||
<ul>
|
||||
<li><strong>Do not bind the rc to a network address you do not
|
||||
control.</strong> The default bind is loopback
|
||||
(<code>localhost:5572</code>); keep it there unless you have a specific
|
||||
reason to change it.</li>
|
||||
<li><strong>Do not use <code>--rc-no-auth</code> on a non-loopback
|
||||
bind.</strong> It disables authentication on the endpoints that access
|
||||
remotes — see <a
|
||||
href="#--rc-no-auth"><code>--rc-no-auth</code></a>.</li>
|
||||
<li><strong>Use authentication and TLS</strong>
|
||||
(<code>--rc-user</code>/<code>--rc-pass</code> or
|
||||
<code>--rc-htpasswd</code>, plus
|
||||
<code>--rc-cert</code>/<code>--rc-key</code>) whenever the port is
|
||||
reachable by anyone you do not fully trust, and raise
|
||||
<code>--rc-min-tls-version</code>.</li>
|
||||
</ul>
|
||||
<h2 id="supported-parameters">Supported parameters</h2>
|
||||
<h3 id="rc">--rc</h3>
|
||||
<p>Flag to start the http server listen on remote requests.</p>
|
||||
@@ -18288,7 +18345,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 +21771,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 "rclone/v1.74.2")</code></pre>
|
||||
--user-agent string Set the user-agent to a specified string (default "rclone/v1.74.4")</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)
|
||||
@@ -22319,8 +22395,10 @@ split into groups.</p>
|
||||
--local-case-sensitive Force the filesystem to report itself as case sensitive
|
||||
--local-description string Description of the remote
|
||||
--local-encoding Encoding The encoding for the backend (default Slash,Dot)
|
||||
--local-fatal-if-no-space Make out-of-space errors fatal during transfers
|
||||
--local-hashes CommaSepList Comma separated list of supported checksum types
|
||||
--local-links Translate symlinks to/from regular files with a '.rclonelink' extension for the local backend
|
||||
--local-metadata-restore-special-bits Restore the setuid, setgid and sticky bits from metadata
|
||||
--local-no-check-updated Don't check to see if the files change during upload
|
||||
--local-no-clone Disable reflink cloning for server-side copies
|
||||
--local-no-preallocate Disable preallocation of disk space for transferred files
|
||||
@@ -24434,10 +24512,37 @@ 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>TestGoogleCloudStorage,directory_markers</code>
|
||||
(<code>googlecloudstorage</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/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage,directory_markers-1.txt"><code>TestBisyncRemoteLocal/all_changed</code></a></li>
|
||||
<li><a
|
||||
href="https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage,directory_markers-1.txt"><code>TestBisyncRemoteLocal/backupdir</code></a></li>
|
||||
<li><a
|
||||
href="https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage,directory_markers-1.txt"><code>TestBisyncRemoteLocal/basic</code></a></li>
|
||||
<li><a
|
||||
href="https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage,directory_markers-1.txt"><code>TestBisyncRemoteLocal/changes</code></a></li>
|
||||
<li><a
|
||||
href="https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage,directory_markers-1.txt"><code>TestBisyncRemoteLocal/check_access</code></a></li>
|
||||
<li><a href="https://pub.rclone.org/integration-tests/current/">79
|
||||
more</a></li>
|
||||
</ul></li>
|
||||
<li><code>TestGoogleCloudStorage</code>
|
||||
(<code>googlecloudstorage</code>)
|
||||
<ul>
|
||||
<li><a
|
||||
href="https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage-1.txt"><code>TestBisyncRemoteLocal/all_changed</code></a></li>
|
||||
<li><a
|
||||
href="https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage-1.txt"><code>TestBisyncRemoteLocal/backupdir</code></a></li>
|
||||
<li><a
|
||||
href="https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage-1.txt"><code>TestBisyncRemoteLocal/basic</code></a></li>
|
||||
<li><a
|
||||
href="https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage-1.txt"><code>TestBisyncRemoteLocal/changes</code></a></li>
|
||||
<li><a
|
||||
href="https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage-1.txt"><code>TestBisyncRemoteLocal/check_access</code></a></li>
|
||||
<li><a href="https://pub.rclone.org/integration-tests/current/">79
|
||||
more</a></li>
|
||||
</ul></li>
|
||||
<li><code>TestHuaweiDrive</code> (<code>huaweidrive</code>)
|
||||
<ul>
|
||||
@@ -24446,15 +24551,15 @@ 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>Updated: 2026-07-08-010014
|
||||
<!--- 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
|
||||
@@ -24572,6 +24677,11 @@ directory is to rename it to the same name on both sides. (As of
|
||||
<code>rclone v1.64</code>, a <code>--resync</code> is no longer required
|
||||
after doing so, as bisync will automatically detect that Path1 and Path2
|
||||
are in agreement.)</p>
|
||||
<p>Note that although the flag --track-renames ensures that
|
||||
renamed/moved files won't be deleted and uploaded again, they are still
|
||||
counted as deleted files for purposes of the --max-delete flag (as this
|
||||
check happens before the rename detection operation). See <a
|
||||
href="https://github.com/rclone/rclone/issues/8685">this issue</a>.</p>
|
||||
<h3 id="fast-list-used-by-default"><code>--fast-list</code> used by
|
||||
default</h3>
|
||||
<p>Unlike most other rclone commands, bisync uses <a
|
||||
@@ -30861,7 +30971,7 @@ limit.</p>
|
||||
<p>Cutoff for switching to multipart copy.</p>
|
||||
<p>Any files larger than this that need to be server-side copied will be
|
||||
copied in chunks of this size.</p>
|
||||
<p>The minimum is 0 and the maximum is 5 GiB.</p>
|
||||
<p>The minimum is 1 byte and the maximum is 5 GiB.</p>
|
||||
<p>Properties:</p>
|
||||
<ul>
|
||||
<li>Config: copy_cutoff</li>
|
||||
@@ -40802,9 +40912,9 @@ password.</p>
|
||||
<p>1 MiB (1048576 bytes) file will encrypt to</p>
|
||||
<ul>
|
||||
<li>32 bytes header</li>
|
||||
<li>16 chunks of 65568 bytes</li>
|
||||
<li>16 chunks of 65552 bytes</li>
|
||||
</ul>
|
||||
<p>1049120 bytes total (a 0.05% overhead). This is the overhead for big
|
||||
<p>1048864 bytes total (a 0.03% overhead). This is the overhead for big
|
||||
files.</p>
|
||||
<h3 id="name-encryption">Name encryption</h3>
|
||||
<p>File names are encrypted segment by segment - the path is broken up
|
||||
@@ -44796,18 +44906,28 @@ correct root to use itself.</p>
|
||||
<p>However you can set this to restrict rclone to a specific folder
|
||||
hierarchy or to access data within the "Computers" tab on the drive web
|
||||
interface (where files from Google's Backup and Sync desktop program
|
||||
go).</p>
|
||||
<p>In order to do this you will have to find the <code>Folder ID</code>
|
||||
of the directory you wish rclone to display. This will be the last
|
||||
segment of the URL when you open the relevant folder in the drive web
|
||||
interface.</p>
|
||||
go). However, this is not the easiest method. Instead, you can create a
|
||||
shortcut to a folder in "Computers" and place it in "My Drive." To do
|
||||
so, right-click the folder, select "Organize", and then choose "Add
|
||||
shortcut" in the Google Drive web interface. Once you add the shortcut
|
||||
to "My Drive," rclone will display the folder, allowing you to interact
|
||||
with it. See also <a href="#shortcuts">Shortcuts</a>.</p>
|
||||
<p>If, however, you choose to change your root folder, you will have to
|
||||
find the <code>Folder ID</code> of the directory you wish rclone to
|
||||
display. This will be the last segment of the URL when you open the
|
||||
relevant folder in the drive web interface.</p>
|
||||
<p>So if the folder you want rclone to use has a URL which looks like
|
||||
<code>https://drive.google.com/drive/folders/1XyfxxxxxxxxxxxxxxxxxxxxxxxxxKHCh</code>
|
||||
in the browser, then you use
|
||||
<code>1XyfxxxxxxxxxxxxxxxxxxxxxxxxxKHCh</code> as the
|
||||
<code>root_folder_id</code> in the config.</p>
|
||||
<p><strong>NB</strong> folders under the "Computers" tab seem to be read
|
||||
only (drive gives a 500 error) when using rclone.</p>
|
||||
only (drive gives a 500 error) when using rclone, but they are also
|
||||
read-only in the Google Drive web interface, likely because this folder
|
||||
is managed by the Google Drive Desktop tool. Top-level folders in
|
||||
"Computers" are read-only, but you can interact with folders contained
|
||||
within them using rclone. These are the folders for which you can create
|
||||
a shortcut as well, as described above.</p>
|
||||
<p>There doesn't appear to be an API to discover the folder IDs of the
|
||||
"Computers" tab - please contact us if you know otherwise!</p>
|
||||
<p>Note also that rclone can't access any data under the "Backups" tab
|
||||
@@ -46611,6 +46731,23 @@ well, but the limitation is that any grants will expire after a week,
|
||||
which can be annoying to refresh constantly. If, for whatever reason, a
|
||||
short grant time is not a problem, then keeping the application in
|
||||
testing mode would also be sufficient.</p>
|
||||
<p>In most cases verification is not actually required. Google <a
|
||||
href="https://support.google.com/cloud/answer/13464323">exempts a number
|
||||
of app categories</a> from mandatory verification, including:</p>
|
||||
<ul>
|
||||
<li><strong>Personal Use apps</strong>: if the app is for your personal
|
||||
use (fewer than 100 users), you and your limited number of users can
|
||||
keep using it without verification - you will just need to click through
|
||||
the "unverified app" warning screen during sign-in. Verification is only
|
||||
required if you want to grow your user base beyond 100 users.</li>
|
||||
<li><strong>Development/Testing/Staging apps</strong>: apps in
|
||||
development, testing or staging mode are not subject to verification
|
||||
(but are limited to the 100-user cap and the unverified-app warning
|
||||
until verified).</li>
|
||||
</ul>
|
||||
<p>So for typical personal rclone use you can leave the app unverified,
|
||||
accept the warning screen, and publish it (rather than leaving it in
|
||||
"Testing") to avoid the weekly grant expiry described above.</p>
|
||||
<p>(Thanks to <span class="citation"
|
||||
data-cites="balazer">@balazer</span> on github for these
|
||||
instructions.)</p>
|
||||
@@ -64659,6 +64796,31 @@ the local backend. <code>--links</code> and <code>-l</code> enable the
|
||||
feature for all supported backends and the VFS.</p>
|
||||
<p>Note that this flag is incompatible with <code>-copy-links</code> /
|
||||
<code>-L</code>.</p>
|
||||
<h4 id="symlink-targets-and-the-destination">Symlink targets and the
|
||||
destination</h4>
|
||||
<p>When rclone recreates a <code>.rclonelink</code> file as a symlink on
|
||||
local storage, the symlink can point anywhere - including, with an
|
||||
absolute path or one using <code>../</code> - to a location outside the
|
||||
directory you are copying into. This is normal - rclone reproduces
|
||||
whatever target the link had, so backups round-trip faithfully.</p>
|
||||
<p>What rclone will <strong>not</strong> do is <em>write through</em>
|
||||
such a link. If a remote you are copying from contains both a symlink
|
||||
and a file or directory that would be placed inside it - for example a
|
||||
<code>dir.rclonelink</code> pointing somewhere outside the destination,
|
||||
alongside a <code>dir/file.txt</code> - rclone refuses to follow the
|
||||
symlink when writing <code>dir/file.txt</code>. The offending file is
|
||||
skipped with an error, the rest of the transfer continues, and the
|
||||
skipped file is counted in the error summary printed at the end of the
|
||||
run.</p>
|
||||
<p>This protects you from a malicious or compromised remote using
|
||||
<code>-l</code> / <code>--links</code> to plant a symlink and then write
|
||||
through it to somewhere outside your destination. Ordinary symlink
|
||||
round-trips, and symlinks that stay inside the destination, are
|
||||
unaffected.</p>
|
||||
<p>If you have intentionally pre-created a symlinked directory inside
|
||||
your destination and want rclone to write into the directory it points
|
||||
at, do not use <code>-l</code> / <code>--links</code> for that copy, or
|
||||
remove the symlink first.</p>
|
||||
<h3 id="restricting-filesystems-with---one-file-system">Restricting
|
||||
filesystems with --one-file-system</h3>
|
||||
<p>Normally rclone will recurse through filesystems as mounted.</p>
|
||||
@@ -64920,6 +65082,40 @@ file.</p>
|
||||
<li>Type: bool</li>
|
||||
<li>Default: false</li>
|
||||
</ul>
|
||||
<h4
|
||||
id="local-metadata-restore-special-bits">--local-metadata-restore-special-bits</h4>
|
||||
<p>Restore the setuid, setgid and sticky bits from metadata.</p>
|
||||
<p>When restoring metadata with --metadata rclone applies the "mode"
|
||||
from the source. By default rclone applies only the permission bits and
|
||||
strips the setuid, setgid and sticky bits.</p>
|
||||
<p>The "mode" comes from the source remote which may not be trusted.
|
||||
Restoring a setuid or setgid bit onto freshly written, source-controlled
|
||||
content can plant a setuid binary, which is dangerous in particular when
|
||||
restoring from an untrusted source while running as root. For this
|
||||
reason these bits are not restored by default.</p>
|
||||
<p>If you trust the source and want the setuid, setgid and sticky bits
|
||||
restored - for example when restoring a system backup made by rclone -
|
||||
set this flag.</p>
|
||||
<p>Properties:</p>
|
||||
<ul>
|
||||
<li>Config: metadata_restore_special_bits</li>
|
||||
<li>Env Var: RCLONE_LOCAL_METADATA_RESTORE_SPECIAL_BITS</li>
|
||||
<li>Type: bool</li>
|
||||
<li>Default: false</li>
|
||||
</ul>
|
||||
<h4 id="local-fatal-if-no-space">--local-fatal-if-no-space</h4>
|
||||
<p>Make out-of-space errors fatal during transfers.</p>
|
||||
<p>When enabled, an ENOSPC error during a write returns a fatal error so
|
||||
that rclone aborts rather than retrying the operation. Useful for backup
|
||||
scripts that should halt loudly on a full disk rather than spin
|
||||
retrying.</p>
|
||||
<p>Properties:</p>
|
||||
<ul>
|
||||
<li>Config: fatal_if_no_space</li>
|
||||
<li>Env Var: RCLONE_LOCAL_FATAL_IF_NO_SPACE</li>
|
||||
<li>Type: bool</li>
|
||||
<li>Default: false</li>
|
||||
</ul>
|
||||
<h4 id="local-time-type">--local-time-type</h4>
|
||||
<p>Set what kind of time is returned.</p>
|
||||
<p>Normally rclone does all operations on the mtime or Modification
|
||||
@@ -65003,6 +65199,12 @@ pkg/attrs#47</a>).</p>
|
||||
<p>User metadata is stored as extended attributes (which may not be
|
||||
supported by all file systems) under the "user.*" prefix.</p>
|
||||
<p>Metadata is supported on files and directories.</p>
|
||||
<p>When restoring metadata with <code>--metadata</code> rclone applies
|
||||
the "mode", "uid" and "gid" from the source. These come from the source
|
||||
remote which may not be trusted, so restoring metadata as root from an
|
||||
untrusted source can change file ownership and is not recommended. The
|
||||
setuid, setgid and sticky bits are not restored by default - see the
|
||||
<code>--local-metadata-restore-special-bits</code> flag.</p>
|
||||
<p>Here are the possible system metadata items for the local
|
||||
backend.</p>
|
||||
<table>
|
||||
@@ -65099,6 +65301,196 @@ the output.</p>
|
||||
<!-- autogenerated options stop -->
|
||||
<!-- markdownlint-disable line-length -->
|
||||
<h1 id="changelog-1">Changelog</h1>
|
||||
<h2 id="v1.74.4---2026-07-08">v1.74.4 - 2026-07-08</h2>
|
||||
<p><a
|
||||
href="https://github.com/rclone/rclone/compare/v1.74.3...v1.74.4">See
|
||||
commits</a></p>
|
||||
<ul>
|
||||
<li>Bug Fixes
|
||||
<ul>
|
||||
<li>accounting
|
||||
<ul>
|
||||
<li>Fix goroutine leak in ResetCounters (Nick Craig-Wood)</li>
|
||||
<li>Fix goroutine leak in NewStatsGroup for zero-transfer rc jobs
|
||||
(Sanjays2402)</li>
|
||||
</ul></li>
|
||||
<li>archive extract: Fix path traversal letting archives escape the
|
||||
destination CVE-2026-59732 (Nick Craig-Wood)</li>
|
||||
<li>build
|
||||
<ul>
|
||||
<li>Fix multiple CVEs by upgrading to go1.26.5 (Nick Craig-Wood)
|
||||
<ul>
|
||||
<li>CVE-2026-39822: os: Root escape via symlink plus trailing slash</li>
|
||||
<li>CVE-2026-42505: crypto/tls: Encrypted Client Hello privacy leak</li>
|
||||
</ul></li>
|
||||
<li>Update golang.org/x/image to v0.43.0 to fix image decoding
|
||||
vulnerabilities (Nick Craig-Wood)
|
||||
<ul>
|
||||
<li>CVE-2026-46604: panic decoding a TIFF image with an out-of-bounds
|
||||
strip offset</li>
|
||||
<li>CVE-2026-46602: unbounded memory use from lack of a limit on TIFF
|
||||
tile sizes</li>
|
||||
<li>CVE-2026-46601: panic on a WEBP VP8 alpha channel size mismatch</li>
|
||||
<li>CVE-2026-33813: panic decoding a large WEBP image on 32-bit
|
||||
platforms</li>
|
||||
</ul></li>
|
||||
</ul></li>
|
||||
<li>cmd/mount2
|
||||
<ul>
|
||||
<li>Fix NFS file creation by implementing Mknod (Sandy Luppino)</li>
|
||||
<li>Fix ESTALE over NFS by reporting stable inode numbers (Sandy
|
||||
Luppino)</li>
|
||||
<li>Fix NFS directory listings by supporting non-zero Seekdir offsets
|
||||
(Sandy Luppino)</li>
|
||||
</ul></li>
|
||||
<li>completion: Fix powershell completion corrupting non-ASCII names
|
||||
(Yash Anil)</li>
|
||||
<li>doc fixes (Bryan Stenson, Castronaut, Filippo, Gaurav, happysnaker,
|
||||
Jan-Philipp Reßler, Nick Craig-Wood, user77)</li>
|
||||
<li>filter: Fix <code>--files-from</code> copy stopping at the first
|
||||
unreadable file (Nick Craig-Wood)</li>
|
||||
<li>fs
|
||||
<ul>
|
||||
<li>Fix command line flag being ignored when set to its default value
|
||||
(Nick Craig-Wood)</li>
|
||||
<li>Fix negative offset when a suffix Range request exceeds object size
|
||||
(Amit Mishra)</li>
|
||||
</ul></li>
|
||||
<li>gui: Update embedded release to 1.1.10 (Nick Craig-Wood)</li>
|
||||
<li>ncdu: Fix duplicated keystrokes on Windows by pinning tcell to
|
||||
v2.9.0 (Nick Craig-Wood)</li>
|
||||
<li>serve restic: Fix <code>--private-repos</code> isolation bypass
|
||||
CVE-2026-59733 (Nick Craig-Wood)</li>
|
||||
<li>serve s3
|
||||
<ul>
|
||||
<li>Fix spurious 404 on HEAD/GET during VFS writeback (max)</li>
|
||||
<li>Fix path traversal letting clients see files in the root
|
||||
GHSA-8v25-v8p6-qf7v (Nick Craig-Wood)</li>
|
||||
</ul></li>
|
||||
<li>serve webdav: Fix MOVE overwrite failing without Overwrite header
|
||||
(Sanjay Santhanam)</li>
|
||||
<li>serve/http: Fix <code>--disable-zip</code> so it works over rc (Nick
|
||||
Craig-Wood)</li>
|
||||
</ul></li>
|
||||
<li>VFS
|
||||
<ul>
|
||||
<li>Fix hang reopening a file during the handle-caching grace period
|
||||
(Nick Craig-Wood)</li>
|
||||
</ul></li>
|
||||
<li>Local
|
||||
<ul>
|
||||
<li>Stop <code>--links</code> symlinks escaping the destination
|
||||
directory CVE-2026-54572 (Nick Craig-Wood)</li>
|
||||
<li>Don't restore setuid/setgid/sticky bits from metadata by default
|
||||
GHSA-945v-v9p3-v5xw (Nick Craig-Wood)</li>
|
||||
</ul></li>
|
||||
<li>Drive
|
||||
<ul>
|
||||
<li>Warn when non-exportable Google documents are skipped (Nick
|
||||
Craig-Wood)</li>
|
||||
<li>Fix stray %!(EXTRA) in unexportable google document log message
|
||||
(Nick Craig-Wood)</li>
|
||||
<li>Warn when using rclone's shared client_id (Nick Craig-Wood)</li>
|
||||
</ul></li>
|
||||
<li>Filelu
|
||||
<ul>
|
||||
<li>Fix recursive listing path handling and file filtering
|
||||
(kingston125)</li>
|
||||
</ul></li>
|
||||
<li>Googlephotos
|
||||
<ul>
|
||||
<li>Warn when using rclone's shared client_id (Nick Craig-Wood)</li>
|
||||
</ul></li>
|
||||
<li>Mega
|
||||
<ul>
|
||||
<li>Wait for server events after upload, delete and move (Nick
|
||||
Craig-Wood)</li>
|
||||
<li>Fix hard deleted files reappearing in listings (Nick
|
||||
Craig-Wood)</li>
|
||||
</ul></li>
|
||||
<li>S3
|
||||
<ul>
|
||||
<li>Remove session token on cross-host redirects (IceLocke)</li>
|
||||
<li>Strip STS security token on same-host HTTPS->HTTP redirect
|
||||
GHSA-cf44-9pgv-m4xc (Nick Craig-Wood)</li>
|
||||
<li>Fix error mapping in GetObject to match HeadObject (lewoberst)</li>
|
||||
<li>Correct documented <code>copy_cutoff</code> minimum to 1 byte
|
||||
(max)</li>
|
||||
<li>Fix mounting a prefix failing with 403 when HEAD is not permitted
|
||||
(Nick Craig-Wood)</li>
|
||||
</ul></li>
|
||||
<li>Smb
|
||||
<ul>
|
||||
<li>Fix for IBM iSeries and signature verification (dithwick)</li>
|
||||
</ul></li>
|
||||
<li>WebDAV
|
||||
<ul>
|
||||
<li>Fix mixed property statuses in multi-status responses
|
||||
(nako-ruru)</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
<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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
% rclone(1) User Manual
|
||||
% Nick Craig-Wood
|
||||
% May 22, 2026
|
||||
% Jul 08, 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!-20260708
|
||||
```
|
||||
|
||||
```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-07-08 0504PM
|
||||
```
|
||||
|
||||
```console
|
||||
@@ -5631,8 +5631,9 @@ Copy files from source to dest, skipping identical files.
|
||||
If source:path is a file or directory then it copies it to a file or
|
||||
directory named dest:path.
|
||||
|
||||
This can be used to upload single files to other than their current
|
||||
name. If the source is a directory then it acts exactly like the
|
||||
This can be used to copy a single file to a destination with a name
|
||||
different from its source - for example, uploading and renaming in one
|
||||
step. If the source is a directory then it acts exactly like the
|
||||
[copy](https://rclone.org/commands/rclone_copy/) command.
|
||||
|
||||
So
|
||||
@@ -14066,6 +14067,17 @@ Versioning is not currently supported.
|
||||
Metadata will only be saved in memory other than the rclone `mtime`
|
||||
metadata which will be set as the modification time of the file.
|
||||
|
||||
## Object names
|
||||
|
||||
`serve s3` stores objects as files in the backend, so object keys are
|
||||
mapped to file paths rather than treated as the opaque strings AWS S3
|
||||
allows. Keys must be in canonical path form: keys that contain `..` or
|
||||
`.` path segments, repeated slashes (`//`), or a leading or trailing
|
||||
slash are rejected with a `400 Bad Request` (`InvalidArgument`)
|
||||
instead of being normalised, since normalising them could alias two
|
||||
distinct keys to the same file or resolve a key outside its bucket.
|
||||
This matches the behaviour of other S3 servers such as MinIO.
|
||||
|
||||
## Supported operations
|
||||
|
||||
`serve s3` currently supports the following operations.
|
||||
@@ -18664,7 +18676,7 @@ warnings and significant events.
|
||||
|
||||
See also the [logging](#logging) section.
|
||||
|
||||
### --windows-event-log LogLevel
|
||||
### --windows-event-log-level LogLevel
|
||||
|
||||
If this is configured (the default is `OFF`) then logs of this level
|
||||
and above will be logged to the Windows event log in **addition** to
|
||||
@@ -18680,15 +18692,15 @@ and `Error`. If enabled we map rclone levels like this.
|
||||
|
||||
Rclone will declare its log source as "rclone" if it is has enough
|
||||
permissions to create the registry key needed. If not then logs will
|
||||
appear as "Application". You can run `rclone version --windows-event-log DEBUG`
|
||||
appear as "Application". You can run `rclone version --windows-event-log-level DEBUG`
|
||||
once as administrator to create the registry key in advance.
|
||||
|
||||
**Note** that the `--windows-event-log` level must be greater (more
|
||||
**Note** that the `--windows-event-log-level` level must be greater (more
|
||||
severe) than or equal to the `--log-level`. For example to log DEBUG
|
||||
to a log file but ERRORs to the event log you would use
|
||||
|
||||
```text
|
||||
--log-file rclone.log --log-level DEBUG --windows-event-log ERROR
|
||||
--log-file rclone.log --log-level DEBUG --windows-event-log-level ERROR
|
||||
```
|
||||
|
||||
This option is only supported Windows platforms.
|
||||
@@ -20470,7 +20482,7 @@ y/e/d>
|
||||
## Configuring by copying the config file
|
||||
|
||||
Rclone stores all of its configuration in a single file. This can easily be
|
||||
copied to configure a remote rclone (although some backends does not support
|
||||
copied to configure a remote rclone (although some backends do not support
|
||||
reusing the same configuration, consult your backend documentation to be
|
||||
sure).
|
||||
|
||||
@@ -21640,6 +21652,43 @@ or [use HTTP directly](#api-http).
|
||||
If you just want to run a remote control then see the [rcd](https://rclone.org/commands/rclone_rcd/)
|
||||
command.
|
||||
|
||||
## Security {#security}
|
||||
|
||||
**Access to the rc API is equivalent to shell access as the user running
|
||||
rclone.** Treat the rc port as you would an interactive login on the host.
|
||||
|
||||
Any caller who can reach the API (and pass authentication, if it is enabled)
|
||||
can, among other things:
|
||||
|
||||
- **Run OS commands** as the rclone user. `core/command` re-executes the rclone
|
||||
binary with arbitrary arguments, and several backend options shell out to
|
||||
programs, so even creating a remote with `config/create` can lead to command
|
||||
execution.
|
||||
- **Read and write any file** reachable by the rclone process, by pointing
|
||||
`operations/*` or `sync/*` at a `local` remote (or via `--rc-files` /
|
||||
`--rc-serve`). Writing arbitrary files as the rclone user is itself a route to
|
||||
code execution.
|
||||
- **Read back stored credentials.** rclone configs routinely hold cloud-provider
|
||||
secrets. `config/dump` and friends expose them, so a compromise of the rc
|
||||
reaches every configured backend.
|
||||
- **Change rclone's runtime behaviour** with `options/set`, **manage remotes**
|
||||
with `config/*`, and **stop the process** with `core/quit`.
|
||||
|
||||
There is currently no per-endpoint capability or scope system: authentication is
|
||||
all-or-nothing. Granting any access grants all of the above.
|
||||
|
||||
Consequently:
|
||||
|
||||
- **Do not bind the rc to a network address you do not control.** The default
|
||||
bind is loopback (`localhost:5572`); keep it there unless you have a specific
|
||||
reason to change it.
|
||||
- **Do not use `--rc-no-auth` on a non-loopback bind.** It disables
|
||||
authentication on the endpoints that access remotes — see
|
||||
[`--rc-no-auth`](#--rc-no-auth).
|
||||
- **Use authentication and TLS** (`--rc-user`/`--rc-pass` or `--rc-htpasswd`,
|
||||
plus `--rc-cert`/`--rc-key`) whenever the port is reachable by anyone you do
|
||||
not fully trust, and raise `--rc-min-tls-version`.
|
||||
|
||||
## Supported parameters
|
||||
|
||||
### --rc
|
||||
@@ -21703,8 +21752,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 +25052,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.4")
|
||||
```
|
||||
|
||||
|
||||
@@ -25669,8 +25736,10 @@ Backend-only flags (these can be set in the config file also).
|
||||
--local-case-sensitive Force the filesystem to report itself as case sensitive
|
||||
--local-description string Description of the remote
|
||||
--local-encoding Encoding The encoding for the backend (default Slash,Dot)
|
||||
--local-fatal-if-no-space Make out-of-space errors fatal during transfers
|
||||
--local-hashes CommaSepList Comma separated list of supported checksum types
|
||||
--local-links Translate symlinks to/from regular files with a '.rclonelink' extension for the local backend
|
||||
--local-metadata-restore-special-bits Restore the setuid, setgid and sticky bits from metadata
|
||||
--local-no-check-updated Don't check to see if the files change during upload
|
||||
--local-no-clone Disable reflink cloning for server-side copies
|
||||
--local-no-preallocate Disable preallocation of disk space for transferred files
|
||||
@@ -27197,8 +27266,8 @@ internals of the generated export file.) Therefore, bisync automatically skips
|
||||
`--download-hash` for files with a size less than 0.
|
||||
|
||||
See also: [`Hasher`](https://rclone.org/hasher/) backend,
|
||||
[`cryptcheck`](https://rclone.org/commands/rclone_cryptcheck/) command, [`rclone check
|
||||
--download`](https://rclone.org/commands/rclone_check/) option,
|
||||
[`cryptcheck`](https://rclone.org/commands/rclone_cryptcheck/) command,
|
||||
[`rclone check --download`](https://rclone.org/commands/rclone_check/) option,
|
||||
[`md5sum`](https://rclone.org/commands/rclone_md5sum/) command
|
||||
|
||||
### --max-delete
|
||||
@@ -27772,16 +27841,28 @@ 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)
|
||||
- `TestGoogleCloudStorage,directory_markers` (`googlecloudstorage`)
|
||||
- [`TestBisyncRemoteLocal/all_changed`](https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage,directory_markers-1.txt)
|
||||
- [`TestBisyncRemoteLocal/backupdir`](https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage,directory_markers-1.txt)
|
||||
- [`TestBisyncRemoteLocal/basic`](https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage,directory_markers-1.txt)
|
||||
- [`TestBisyncRemoteLocal/changes`](https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage,directory_markers-1.txt)
|
||||
- [`TestBisyncRemoteLocal/check_access`](https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage,directory_markers-1.txt)
|
||||
- [79 more](https://pub.rclone.org/integration-tests/current/)
|
||||
- `TestGoogleCloudStorage` (`googlecloudstorage`)
|
||||
- [`TestBisyncRemoteLocal/all_changed`](https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage-1.txt)
|
||||
- [`TestBisyncRemoteLocal/backupdir`](https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage-1.txt)
|
||||
- [`TestBisyncRemoteLocal/basic`](https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage-1.txt)
|
||||
- [`TestBisyncRemoteLocal/changes`](https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage-1.txt)
|
||||
- [`TestBisyncRemoteLocal/check_access`](https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage-1.txt)
|
||||
- [79 more](https://pub.rclone.org/integration-tests/current/)
|
||||
- `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/)
|
||||
- Updated: 2026-07-08-010014
|
||||
<!--- end list_failures - DO NOT EDIT THIS SECTION - use make commanddocs --->
|
||||
|
||||
The following backends either have not been tested recently or have known issues
|
||||
@@ -27887,6 +27968,11 @@ is to rename it to the same name on both sides. (As of `rclone v1.64`,
|
||||
a `--resync` is no longer required after doing so, as bisync will automatically
|
||||
detect that Path1 and Path2 are in agreement.)
|
||||
|
||||
Note that although the flag --track-renames ensures that renamed/moved files won't
|
||||
be deleted and uploaded again, they are still counted as deleted files for purposes
|
||||
of the --max-delete flag (as this check happens before the rename detection
|
||||
operation). See [this issue](https://github.com/rclone/rclone/issues/8685).
|
||||
|
||||
### `--fast-list` used by default
|
||||
|
||||
Unlike most other rclone commands, bisync uses [`--fast-list`](https://rclone.org/docs/#fast-list)
|
||||
@@ -32751,7 +32837,7 @@ Cutoff for switching to multipart copy.
|
||||
Any files larger than this that need to be server-side copied will be
|
||||
copied in chunks of this size.
|
||||
|
||||
The minimum is 0 and the maximum is 5 GiB.
|
||||
The minimum is 1 byte and the maximum is 5 GiB.
|
||||
|
||||
Properties:
|
||||
|
||||
@@ -43969,9 +44055,9 @@ This uses a 32 byte (256 bit key) key derived from the user password.
|
||||
1 MiB (1048576 bytes) file will encrypt to
|
||||
|
||||
- 32 bytes header
|
||||
- 16 chunks of 65568 bytes
|
||||
- 16 chunks of 65552 bytes
|
||||
|
||||
1049120 bytes total (a 0.05% overhead). This is the overhead for big
|
||||
1048864 bytes total (a 0.03% overhead). This is the overhead for big
|
||||
files.
|
||||
|
||||
### Name encryption
|
||||
@@ -48494,9 +48580,14 @@ correct root to use itself.
|
||||
However you can set this to restrict rclone to a specific folder
|
||||
hierarchy or to access data within the "Computers" tab on the drive
|
||||
web interface (where files from Google's Backup and Sync desktop
|
||||
program go).
|
||||
program go). However, this is not the easiest method.
|
||||
Instead, you can create a shortcut to a folder in "Computers" and
|
||||
place it in "My Drive." To do so, right-click the folder, select
|
||||
"Organize", and then choose "Add shortcut" in the Google Drive web interface.
|
||||
Once you add the shortcut to "My Drive," rclone will display the folder, allowing you to interact with it.
|
||||
See also [Shortcuts](#shortcuts).
|
||||
|
||||
In order to do this you will have to find the `Folder ID` of the
|
||||
If, however, you choose to change your root folder, you will have to find the `Folder ID` of the
|
||||
directory you wish rclone to display. This will be the last segment
|
||||
of the URL when you open the relevant folder in the drive web
|
||||
interface.
|
||||
@@ -48507,7 +48598,11 @@ in the browser, then you use `1XyfxxxxxxxxxxxxxxxxxxxxxxxxxKHCh` as
|
||||
the `root_folder_id` in the config.
|
||||
|
||||
**NB** folders under the "Computers" tab seem to be read only (drive
|
||||
gives a 500 error) when using rclone.
|
||||
gives a 500 error) when using rclone, but they are also read-only in the Google Drive web interface,
|
||||
likely because this folder is managed by the Google Drive Desktop tool.
|
||||
Top-level folders in "Computers" are read-only, but you can interact
|
||||
with folders contained within them using rclone.
|
||||
These are the folders for which you can create a shortcut as well, as described above.
|
||||
|
||||
There doesn't appear to be an API to discover the folder IDs of the
|
||||
"Computers" tab - please contact us if you know otherwise!
|
||||
@@ -50331,6 +50426,23 @@ after a week, which can be annoying to refresh constantly. If, for whatever
|
||||
reason, a short grant time is not a problem, then keeping the application in
|
||||
testing mode would also be sufficient.
|
||||
|
||||
In most cases verification is not actually required. Google [exempts a number of
|
||||
app categories](https://support.google.com/cloud/answer/13464323) from mandatory
|
||||
verification, including:
|
||||
|
||||
- **Personal Use apps**: if the app is for your personal use (fewer than 100
|
||||
users), you and your limited number of users can keep using it without
|
||||
verification - you will just need to click through the "unverified app"
|
||||
warning screen during sign-in. Verification is only required if you want to
|
||||
grow your user base beyond 100 users.
|
||||
- **Development/Testing/Staging apps**: apps in development, testing or staging
|
||||
mode are not subject to verification (but are limited to the 100-user cap and
|
||||
the unverified-app warning until verified).
|
||||
|
||||
So for typical personal rclone use you can leave the app unverified, accept the
|
||||
warning screen, and publish it (rather than leaving it in "Testing") to avoid
|
||||
the weekly grant expiry described above.
|
||||
|
||||
(Thanks to @balazer on github for these instructions.)
|
||||
|
||||
Sometimes, creation of an OAuth consent in Google API Console fails due to an
|
||||
@@ -69843,6 +69955,31 @@ backends and the VFS.
|
||||
|
||||
Note that this flag is incompatible with `-copy-links` / `-L`.
|
||||
|
||||
#### Symlink targets and the destination
|
||||
|
||||
When rclone recreates a `.rclonelink` file as a symlink on local storage,
|
||||
the symlink can point anywhere - including, with an absolute path or one
|
||||
using `../` - to a location outside the directory you are copying into. This
|
||||
is normal - rclone reproduces whatever target the link had, so backups
|
||||
round-trip faithfully.
|
||||
|
||||
What rclone will **not** do is *write through* such a link. If a remote you
|
||||
are copying from contains both a symlink and a file or directory that would
|
||||
be placed inside it - for example a `dir.rclonelink` pointing somewhere
|
||||
outside the destination, alongside a `dir/file.txt` - rclone refuses to
|
||||
follow the symlink when writing `dir/file.txt`. The offending file is
|
||||
skipped with an error, the rest of the transfer continues, and the skipped
|
||||
file is counted in the error summary printed at the end of the run.
|
||||
|
||||
This protects you from a malicious or compromised remote using `-l` /
|
||||
`--links` to plant a symlink and then write through it to somewhere outside
|
||||
your destination. Ordinary symlink round-trips, and symlinks that stay
|
||||
inside the destination, are unaffected.
|
||||
|
||||
If you have intentionally pre-created a symlinked directory inside your
|
||||
destination and want rclone to write into the directory it points at, do
|
||||
not use `-l` / `--links` for that copy, or remove the symlink first.
|
||||
|
||||
### Restricting filesystems with --one-file-system
|
||||
|
||||
Normally rclone will recurse through filesystems as mounted.
|
||||
@@ -70159,6 +70296,47 @@ Properties:
|
||||
- Type: bool
|
||||
- Default: false
|
||||
|
||||
#### --local-metadata-restore-special-bits
|
||||
|
||||
Restore the setuid, setgid and sticky bits from metadata.
|
||||
|
||||
When restoring metadata with --metadata rclone applies the "mode" from
|
||||
the source. By default rclone applies only the permission bits and
|
||||
strips the setuid, setgid and sticky bits.
|
||||
|
||||
The "mode" comes from the source remote which may not be trusted.
|
||||
Restoring a setuid or setgid bit onto freshly written,
|
||||
source-controlled content can plant a setuid binary, which is dangerous
|
||||
in particular when restoring from an untrusted source while running as
|
||||
root. For this reason these bits are not restored by default.
|
||||
|
||||
If you trust the source and want the setuid, setgid and sticky bits
|
||||
restored - for example when restoring a system backup made by rclone -
|
||||
set this flag.
|
||||
|
||||
Properties:
|
||||
|
||||
- Config: metadata_restore_special_bits
|
||||
- Env Var: RCLONE_LOCAL_METADATA_RESTORE_SPECIAL_BITS
|
||||
- Type: bool
|
||||
- Default: false
|
||||
|
||||
#### --local-fatal-if-no-space
|
||||
|
||||
Make out-of-space errors fatal during transfers.
|
||||
|
||||
When enabled, an ENOSPC error during a write returns a fatal error so
|
||||
that rclone aborts rather than retrying the operation. Useful for
|
||||
backup scripts that should halt loudly on a full disk rather than spin
|
||||
retrying.
|
||||
|
||||
Properties:
|
||||
|
||||
- Config: fatal_if_no_space
|
||||
- Env Var: RCLONE_LOCAL_FATAL_IF_NO_SPACE
|
||||
- Type: bool
|
||||
- Default: false
|
||||
|
||||
#### --local-time-type
|
||||
|
||||
Set what kind of time is returned.
|
||||
@@ -70245,6 +70423,13 @@ supported by all file systems) under the "user.*" prefix.
|
||||
|
||||
Metadata is supported on files and directories.
|
||||
|
||||
When restoring metadata with `--metadata` rclone applies the
|
||||
"mode", "uid" and "gid" from the source. These come from the source
|
||||
remote which may not be trusted, so restoring metadata as root from an
|
||||
untrusted source can change file ownership and is not recommended. The
|
||||
setuid, setgid and sticky bits are not restored by default - see the
|
||||
`--local-metadata-restore-special-bits` flag.
|
||||
|
||||
Here are the possible system metadata items for the local backend.
|
||||
|
||||
| Name | Help | Type | Example | Read Only |
|
||||
@@ -70298,6 +70483,100 @@ Options:
|
||||
|
||||
# Changelog
|
||||
|
||||
## v1.74.4 - 2026-07-08
|
||||
|
||||
[See commits](https://github.com/rclone/rclone/compare/v1.74.3...v1.74.4)
|
||||
|
||||
- Bug Fixes
|
||||
- accounting
|
||||
- Fix goroutine leak in ResetCounters (Nick Craig-Wood)
|
||||
- Fix goroutine leak in NewStatsGroup for zero-transfer rc jobs (Sanjays2402)
|
||||
- archive extract: Fix path traversal letting archives escape the destination CVE-2026-59732 (Nick Craig-Wood)
|
||||
- build
|
||||
- Fix multiple CVEs by upgrading to go1.26.5 (Nick Craig-Wood)
|
||||
- CVE-2026-39822: os: Root escape via symlink plus trailing slash
|
||||
- CVE-2026-42505: crypto/tls: Encrypted Client Hello privacy leak
|
||||
- Update golang.org/x/image to v0.43.0 to fix image decoding vulnerabilities (Nick Craig-Wood)
|
||||
- CVE-2026-46604: panic decoding a TIFF image with an out-of-bounds strip offset
|
||||
- CVE-2026-46602: unbounded memory use from lack of a limit on TIFF tile sizes
|
||||
- CVE-2026-46601: panic on a WEBP VP8 alpha channel size mismatch
|
||||
- CVE-2026-33813: panic decoding a large WEBP image on 32-bit platforms
|
||||
- cmd/mount2
|
||||
- Fix NFS file creation by implementing Mknod (Sandy Luppino)
|
||||
- Fix ESTALE over NFS by reporting stable inode numbers (Sandy Luppino)
|
||||
- Fix NFS directory listings by supporting non-zero Seekdir offsets (Sandy Luppino)
|
||||
- completion: Fix powershell completion corrupting non-ASCII names (Yash Anil)
|
||||
- doc fixes (Bryan Stenson, Castronaut, Filippo, Gaurav, happysnaker, Jan-Philipp Reßler, Nick Craig-Wood, user77)
|
||||
- filter: Fix `--files-from` copy stopping at the first unreadable file (Nick Craig-Wood)
|
||||
- fs
|
||||
- Fix command line flag being ignored when set to its default value (Nick Craig-Wood)
|
||||
- Fix negative offset when a suffix Range request exceeds object size (Amit Mishra)
|
||||
- gui: Update embedded release to 1.1.10 (Nick Craig-Wood)
|
||||
- ncdu: Fix duplicated keystrokes on Windows by pinning tcell to v2.9.0 (Nick Craig-Wood)
|
||||
- serve restic: Fix `--private-repos` isolation bypass CVE-2026-59733 (Nick Craig-Wood)
|
||||
- serve s3
|
||||
- Fix spurious 404 on HEAD/GET during VFS writeback (max)
|
||||
- Fix path traversal letting clients see files in the root GHSA-8v25-v8p6-qf7v (Nick Craig-Wood)
|
||||
- serve webdav: Fix MOVE overwrite failing without Overwrite header (Sanjay Santhanam)
|
||||
- serve/http: Fix `--disable-zip` so it works over rc (Nick Craig-Wood)
|
||||
- VFS
|
||||
- Fix hang reopening a file during the handle-caching grace period (Nick Craig-Wood)
|
||||
- Local
|
||||
- Stop `--links` symlinks escaping the destination directory CVE-2026-54572 (Nick Craig-Wood)
|
||||
- Don't restore setuid/setgid/sticky bits from metadata by default GHSA-945v-v9p3-v5xw (Nick Craig-Wood)
|
||||
- Drive
|
||||
- Warn when non-exportable Google documents are skipped (Nick Craig-Wood)
|
||||
- Fix stray %!(EXTRA) in unexportable google document log message (Nick Craig-Wood)
|
||||
- Warn when using rclone's shared client_id (Nick Craig-Wood)
|
||||
- Filelu
|
||||
- Fix recursive listing path handling and file filtering (kingston125)
|
||||
- Googlephotos
|
||||
- Warn when using rclone's shared client_id (Nick Craig-Wood)
|
||||
- Mega
|
||||
- Wait for server events after upload, delete and move (Nick Craig-Wood)
|
||||
- Fix hard deleted files reappearing in listings (Nick Craig-Wood)
|
||||
- S3
|
||||
- Remove session token on cross-host redirects (IceLocke)
|
||||
- Strip STS security token on same-host HTTPS->HTTP redirect GHSA-cf44-9pgv-m4xc (Nick Craig-Wood)
|
||||
- Fix error mapping in GetObject to match HeadObject (lewoberst)
|
||||
- Correct documented `copy_cutoff` minimum to 1 byte (max)
|
||||
- Fix mounting a prefix failing with 403 when HEAD is not permitted (Nick Craig-Wood)
|
||||
- Smb
|
||||
- Fix for IBM iSeries and signature verification (dithwick)
|
||||
- WebDAV
|
||||
- Fix mixed property statuses in multi-status responses (nako-ruru)
|
||||
|
||||
## 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
+356
-27
@@ -1,6 +1,6 @@
|
||||
rclone(1) User Manual
|
||||
Nick Craig-Wood
|
||||
May 22, 2026
|
||||
Jul 08, 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!-20260708
|
||||
|
||||
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-07-08 0504PM
|
||||
|
||||
rclone convmv "stories/The Quick Brown Fox!.txt" --name-transform "all,regex=[\\.\\w]/ab"
|
||||
// Output: ababababababab/ababab ababababab ababababab ababab!abababab
|
||||
@@ -4837,8 +4837,9 @@ Synopsis
|
||||
If source:path is a file or directory then it copies it to a file or
|
||||
directory named dest:path.
|
||||
|
||||
This can be used to upload single files to other than their current
|
||||
name. If the source is a directory then it acts exactly like the copy
|
||||
This can be used to copy a single file to a destination with a name
|
||||
different from its source - for example, uploading and renaming in one
|
||||
step. If the source is a directory then it acts exactly like the copy
|
||||
command.
|
||||
|
||||
So
|
||||
@@ -12661,6 +12662,17 @@ Versioning is not currently supported.
|
||||
Metadata will only be saved in memory other than the rclone mtime
|
||||
metadata which will be set as the modification time of the file.
|
||||
|
||||
Object names
|
||||
|
||||
serve s3 stores objects as files in the backend, so object keys are
|
||||
mapped to file paths rather than treated as the opaque strings AWS S3
|
||||
allows. Keys must be in canonical path form: keys that contain .. or .
|
||||
path segments, repeated slashes (//), or a leading or trailing slash are
|
||||
rejected with a 400 Bad Request (InvalidArgument) instead of being
|
||||
normalised, since normalising them could alias two distinct keys to the
|
||||
same file or resolve a key outside its bucket. This matches the
|
||||
behaviour of other S3 servers such as MinIO.
|
||||
|
||||
Supported operations
|
||||
|
||||
serve s3 currently supports the following operations.
|
||||
@@ -16947,7 +16959,7 @@ ERROR is equivalent to -q. It only outputs error messages.
|
||||
|
||||
See also the logging section.
|
||||
|
||||
--windows-event-log LogLevel
|
||||
--windows-event-log-level LogLevel
|
||||
|
||||
If this is configured (the default is OFF) then logs of this level and
|
||||
above will be logged to the Windows event log in addition to the normal
|
||||
@@ -16965,14 +16977,14 @@ Error. If enabled we map rclone levels like this.
|
||||
Rclone will declare its log source as "rclone" if it is has enough
|
||||
permissions to create the registry key needed. If not then logs will
|
||||
appear as "Application". You can run
|
||||
rclone version --windows-event-log DEBUG once as administrator to create
|
||||
the registry key in advance.
|
||||
rclone version --windows-event-log-level DEBUG once as administrator to
|
||||
create the registry key in advance.
|
||||
|
||||
Note that the --windows-event-log level must be greater (more severe)
|
||||
than or equal to the --log-level. For example to log DEBUG to a log file
|
||||
but ERRORs to the event log you would use
|
||||
Note that the --windows-event-log-level level must be greater (more
|
||||
severe) than or equal to the --log-level. For example to log DEBUG to a
|
||||
log file but ERRORs to the event log you would use
|
||||
|
||||
--log-file rclone.log --log-level DEBUG --windows-event-log ERROR
|
||||
--log-file rclone.log --log-level DEBUG --windows-event-log-level ERROR
|
||||
|
||||
This option is only supported Windows platforms.
|
||||
|
||||
@@ -18694,7 +18706,7 @@ Then back to the headless machine, paste in the code.
|
||||
Configuring by copying the config file
|
||||
|
||||
Rclone stores all of its configuration in a single file. This can easily
|
||||
be copied to configure a remote rclone (although some backends does not
|
||||
be copied to configure a remote rclone (although some backends do not
|
||||
support reusing the same configuration, consult your backend
|
||||
documentation to be sure).
|
||||
|
||||
@@ -19775,6 +19787,44 @@ directly.
|
||||
|
||||
If you just want to run a remote control then see the rcd command.
|
||||
|
||||
Security
|
||||
|
||||
Access to the rc API is equivalent to shell access as the user running
|
||||
rclone. Treat the rc port as you would an interactive login on the host.
|
||||
|
||||
Any caller who can reach the API (and pass authentication, if it is
|
||||
enabled) can, among other things:
|
||||
|
||||
- Run OS commands as the rclone user. core/command re-executes the
|
||||
rclone binary with arbitrary arguments, and several backend options
|
||||
shell out to programs, so even creating a remote with config/create
|
||||
can lead to command execution.
|
||||
- Read and write any file reachable by the rclone process, by pointing
|
||||
operations/* or sync/* at a local remote (or via --rc-files /
|
||||
--rc-serve). Writing arbitrary files as the rclone user is itself a
|
||||
route to code execution.
|
||||
- Read back stored credentials. rclone configs routinely hold
|
||||
cloud-provider secrets. config/dump and friends expose them, so a
|
||||
compromise of the rc reaches every configured backend.
|
||||
- Change rclone's runtime behaviour with options/set, manage remotes
|
||||
with config/*, and stop the process with core/quit.
|
||||
|
||||
There is currently no per-endpoint capability or scope system:
|
||||
authentication is all-or-nothing. Granting any access grants all of the
|
||||
above.
|
||||
|
||||
Consequently:
|
||||
|
||||
- Do not bind the rc to a network address you do not control. The
|
||||
default bind is loopback (localhost:5572); keep it there unless you
|
||||
have a specific reason to change it.
|
||||
- Do not use --rc-no-auth on a non-loopback bind. It disables
|
||||
authentication on the endpoints that access remotes — see
|
||||
--rc-no-auth.
|
||||
- Use authentication and TLS (--rc-user/--rc-pass or --rc-htpasswd,
|
||||
plus --rc-cert/--rc-key) whenever the port is reachable by anyone
|
||||
you do not fully trust, and raise --rc-min-tls-version.
|
||||
|
||||
Supported parameters
|
||||
|
||||
--rc
|
||||
@@ -19838,8 +19888,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 +23208,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.4")
|
||||
|
||||
Performance
|
||||
|
||||
@@ -23794,8 +23862,10 @@ Backend-only flags (these can be set in the config file also).
|
||||
--local-case-sensitive Force the filesystem to report itself as case sensitive
|
||||
--local-description string Description of the remote
|
||||
--local-encoding Encoding The encoding for the backend (default Slash,Dot)
|
||||
--local-fatal-if-no-space Make out-of-space errors fatal during transfers
|
||||
--local-hashes CommaSepList Comma separated list of supported checksum types
|
||||
--local-links Translate symlinks to/from regular files with a '.rclonelink' extension for the local backend
|
||||
--local-metadata-restore-special-bits Restore the setuid, setgid and sticky bits from metadata
|
||||
--local-no-check-updated Don't check to see if the files change during upload
|
||||
--local-no-clone Disable reflink cloning for server-side copies
|
||||
--local-no-preallocate Disable preallocation of disk space for transferred files
|
||||
@@ -25839,16 +25909,28 @@ disallowed special characters and filename encodings.)
|
||||
|
||||
The following backends have known issues that need more investigation:
|
||||
|
||||
- TestGoFile (gofile)
|
||||
- TestBisyncRemoteLocal/rclone_args
|
||||
- TestGoogleCloudStorage,directory_markers (googlecloudstorage)
|
||||
- TestBisyncRemoteLocal/all_changed
|
||||
- TestBisyncRemoteLocal/backupdir
|
||||
- TestBisyncRemoteLocal/basic
|
||||
- TestBisyncRemoteLocal/changes
|
||||
- TestBisyncRemoteLocal/check_access
|
||||
- 79 more
|
||||
- TestGoogleCloudStorage (googlecloudstorage)
|
||||
- TestBisyncRemoteLocal/all_changed
|
||||
- TestBisyncRemoteLocal/backupdir
|
||||
- TestBisyncRemoteLocal/basic
|
||||
- TestBisyncRemoteLocal/changes
|
||||
- TestBisyncRemoteLocal/check_access
|
||||
- 79 more
|
||||
- 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
|
||||
- Updated: 2026-07-08-010014
|
||||
|
||||
The following backends either have not been tested recently or have
|
||||
known issues that are deemed unfixable for the time being:
|
||||
@@ -25951,6 +26033,11 @@ directory is to rename it to the same name on both sides. (As of
|
||||
rclone v1.64, a --resync is no longer required after doing so, as bisync
|
||||
will automatically detect that Path1 and Path2 are in agreement.)
|
||||
|
||||
Note that although the flag --track-renames ensures that renamed/moved
|
||||
files won't be deleted and uploaded again, they are still counted as
|
||||
deleted files for purposes of the --max-delete flag (as this check
|
||||
happens before the rename detection operation). See this issue.
|
||||
|
||||
--fast-list used by default
|
||||
|
||||
Unlike most other rclone commands, bisync uses --fast-list by default,
|
||||
@@ -30820,7 +30907,7 @@ Cutoff for switching to multipart copy.
|
||||
Any files larger than this that need to be server-side copied will be
|
||||
copied in chunks of this size.
|
||||
|
||||
The minimum is 0 and the maximum is 5 GiB.
|
||||
The minimum is 1 byte and the maximum is 5 GiB.
|
||||
|
||||
Properties:
|
||||
|
||||
@@ -41629,9 +41716,9 @@ Examples
|
||||
1 MiB (1048576 bytes) file will encrypt to
|
||||
|
||||
- 32 bytes header
|
||||
- 16 chunks of 65568 bytes
|
||||
- 16 chunks of 65552 bytes
|
||||
|
||||
1049120 bytes total (a 0.05% overhead). This is the overhead for big
|
||||
1048864 bytes total (a 0.03% overhead). This is the overhead for big
|
||||
files.
|
||||
|
||||
Name encryption
|
||||
@@ -45934,11 +46021,17 @@ root to use itself.
|
||||
However you can set this to restrict rclone to a specific folder
|
||||
hierarchy or to access data within the "Computers" tab on the drive web
|
||||
interface (where files from Google's Backup and Sync desktop program
|
||||
go).
|
||||
go). However, this is not the easiest method. Instead, you can create a
|
||||
shortcut to a folder in "Computers" and place it in "My Drive." To do
|
||||
so, right-click the folder, select "Organize", and then choose "Add
|
||||
shortcut" in the Google Drive web interface. Once you add the shortcut
|
||||
to "My Drive," rclone will display the folder, allowing you to interact
|
||||
with it. See also Shortcuts.
|
||||
|
||||
In order to do this you will have to find the Folder ID of the directory
|
||||
you wish rclone to display. This will be the last segment of the URL
|
||||
when you open the relevant folder in the drive web interface.
|
||||
If, however, you choose to change your root folder, you will have to
|
||||
find the Folder ID of the directory you wish rclone to display. This
|
||||
will be the last segment of the URL when you open the relevant folder in
|
||||
the drive web interface.
|
||||
|
||||
So if the folder you want rclone to use has a URL which looks like
|
||||
https://drive.google.com/drive/folders/1XyfxxxxxxxxxxxxxxxxxxxxxxxxxKHCh
|
||||
@@ -45946,7 +46039,12 @@ in the browser, then you use 1XyfxxxxxxxxxxxxxxxxxxxxxxxxxKHCh as the
|
||||
root_folder_id in the config.
|
||||
|
||||
NB folders under the "Computers" tab seem to be read only (drive gives a
|
||||
500 error) when using rclone.
|
||||
500 error) when using rclone, but they are also read-only in the Google
|
||||
Drive web interface, likely because this folder is managed by the Google
|
||||
Drive Desktop tool. Top-level folders in "Computers" are read-only, but
|
||||
you can interact with folders contained within them using rclone. These
|
||||
are the folders for which you can create a shortcut as well, as
|
||||
described above.
|
||||
|
||||
There doesn't appear to be an API to discover the folder IDs of the
|
||||
"Computers" tab - please contact us if you know otherwise!
|
||||
@@ -47783,6 +47881,22 @@ which can be annoying to refresh constantly. If, for whatever reason, a
|
||||
short grant time is not a problem, then keeping the application in
|
||||
testing mode would also be sufficient.
|
||||
|
||||
In most cases verification is not actually required. Google exempts a
|
||||
number of app categories from mandatory verification, including:
|
||||
|
||||
- Personal Use apps: if the app is for your personal use (fewer than
|
||||
100 users), you and your limited number of users can keep using it
|
||||
without verification - you will just need to click through the
|
||||
"unverified app" warning screen during sign-in. Verification is only
|
||||
required if you want to grow your user base beyond 100 users.
|
||||
- Development/Testing/Staging apps: apps in development, testing or
|
||||
staging mode are not subject to verification (but are limited to the
|
||||
100-user cap and the unverified-app warning until verified).
|
||||
|
||||
So for typical personal rclone use you can leave the app unverified,
|
||||
accept the warning screen, and publish it (rather than leaving it in
|
||||
"Testing") to avoid the weekly grant expiry described above.
|
||||
|
||||
(Thanks to @balazer on github for these instructions.)
|
||||
|
||||
Sometimes, creation of an OAuth consent in Google API Console fails due
|
||||
@@ -66932,6 +67046,32 @@ VFS.
|
||||
|
||||
Note that this flag is incompatible with -copy-links / -L.
|
||||
|
||||
Symlink targets and the destination
|
||||
|
||||
When rclone recreates a .rclonelink file as a symlink on local storage,
|
||||
the symlink can point anywhere - including, with an absolute path or one
|
||||
using ../ - to a location outside the directory you are copying into.
|
||||
This is normal - rclone reproduces whatever target the link had, so
|
||||
backups round-trip faithfully.
|
||||
|
||||
What rclone will not do is write through such a link. If a remote you
|
||||
are copying from contains both a symlink and a file or directory that
|
||||
would be placed inside it - for example a dir.rclonelink pointing
|
||||
somewhere outside the destination, alongside a dir/file.txt - rclone
|
||||
refuses to follow the symlink when writing dir/file.txt. The offending
|
||||
file is skipped with an error, the rest of the transfer continues, and
|
||||
the skipped file is counted in the error summary printed at the end of
|
||||
the run.
|
||||
|
||||
This protects you from a malicious or compromised remote using -l /
|
||||
--links to plant a symlink and then write through it to somewhere
|
||||
outside your destination. Ordinary symlink round-trips, and symlinks
|
||||
that stay inside the destination, are unaffected.
|
||||
|
||||
If you have intentionally pre-created a symlinked directory inside your
|
||||
destination and want rclone to write into the directory it points at, do
|
||||
not use -l / --links for that copy, or remove the symlink first.
|
||||
|
||||
Restricting filesystems with --one-file-system
|
||||
|
||||
Normally rclone will recurse through filesystems as mounted.
|
||||
@@ -67241,6 +67381,47 @@ Properties:
|
||||
- Type: bool
|
||||
- Default: false
|
||||
|
||||
--local-metadata-restore-special-bits
|
||||
|
||||
Restore the setuid, setgid and sticky bits from metadata.
|
||||
|
||||
When restoring metadata with --metadata rclone applies the "mode" from
|
||||
the source. By default rclone applies only the permission bits and
|
||||
strips the setuid, setgid and sticky bits.
|
||||
|
||||
The "mode" comes from the source remote which may not be trusted.
|
||||
Restoring a setuid or setgid bit onto freshly written, source-controlled
|
||||
content can plant a setuid binary, which is dangerous in particular when
|
||||
restoring from an untrusted source while running as root. For this
|
||||
reason these bits are not restored by default.
|
||||
|
||||
If you trust the source and want the setuid, setgid and sticky bits
|
||||
restored - for example when restoring a system backup made by rclone -
|
||||
set this flag.
|
||||
|
||||
Properties:
|
||||
|
||||
- Config: metadata_restore_special_bits
|
||||
- Env Var: RCLONE_LOCAL_METADATA_RESTORE_SPECIAL_BITS
|
||||
- Type: bool
|
||||
- Default: false
|
||||
|
||||
--local-fatal-if-no-space
|
||||
|
||||
Make out-of-space errors fatal during transfers.
|
||||
|
||||
When enabled, an ENOSPC error during a write returns a fatal error so
|
||||
that rclone aborts rather than retrying the operation. Useful for backup
|
||||
scripts that should halt loudly on a full disk rather than spin
|
||||
retrying.
|
||||
|
||||
Properties:
|
||||
|
||||
- Config: fatal_if_no_space
|
||||
- Env Var: RCLONE_LOCAL_FATAL_IF_NO_SPACE
|
||||
- Type: bool
|
||||
- Default: false
|
||||
|
||||
--local-time-type
|
||||
|
||||
Set what kind of time is returned.
|
||||
@@ -67327,6 +67508,13 @@ supported by all file systems) under the "user.*" prefix.
|
||||
|
||||
Metadata is supported on files and directories.
|
||||
|
||||
When restoring metadata with --metadata rclone applies the "mode", "uid"
|
||||
and "gid" from the source. These come from the source remote which may
|
||||
not be trusted, so restoring metadata as root from an untrusted source
|
||||
can change file ownership and is not recommended. The setuid, setgid and
|
||||
sticky bits are not restored by default - see the
|
||||
--local-metadata-restore-special-bits flag.
|
||||
|
||||
Here are the possible system metadata items for the local backend.
|
||||
|
||||
---------------------------------------------------------------------------------------------------
|
||||
@@ -67389,6 +67577,147 @@ Options:
|
||||
|
||||
Changelog
|
||||
|
||||
v1.74.4 - 2026-07-08
|
||||
|
||||
See commits
|
||||
|
||||
- Bug Fixes
|
||||
- accounting
|
||||
- Fix goroutine leak in ResetCounters (Nick Craig-Wood)
|
||||
- Fix goroutine leak in NewStatsGroup for zero-transfer rc
|
||||
jobs (Sanjays2402)
|
||||
- archive extract: Fix path traversal letting archives escape the
|
||||
destination CVE-2026-59732 (Nick Craig-Wood)
|
||||
- build
|
||||
- Fix multiple CVEs by upgrading to go1.26.5 (Nick Craig-Wood)
|
||||
- CVE-2026-39822: os: Root escape via symlink plus
|
||||
trailing slash
|
||||
- CVE-2026-42505: crypto/tls: Encrypted Client Hello
|
||||
privacy leak
|
||||
- Update golang.org/x/image to v0.43.0 to fix image decoding
|
||||
vulnerabilities (Nick Craig-Wood)
|
||||
- CVE-2026-46604: panic decoding a TIFF image with an
|
||||
out-of-bounds strip offset
|
||||
- CVE-2026-46602: unbounded memory use from lack of a
|
||||
limit on TIFF tile sizes
|
||||
- CVE-2026-46601: panic on a WEBP VP8 alpha channel size
|
||||
mismatch
|
||||
- CVE-2026-33813: panic decoding a large WEBP image on
|
||||
32-bit platforms
|
||||
- cmd/mount2
|
||||
- Fix NFS file creation by implementing Mknod (Sandy Luppino)
|
||||
- Fix ESTALE over NFS by reporting stable inode numbers (Sandy
|
||||
Luppino)
|
||||
- Fix NFS directory listings by supporting non-zero Seekdir
|
||||
offsets (Sandy Luppino)
|
||||
- completion: Fix powershell completion corrupting non-ASCII names
|
||||
(Yash Anil)
|
||||
- doc fixes (Bryan Stenson, Castronaut, Filippo, Gaurav,
|
||||
happysnaker, Jan-Philipp Reßler, Nick Craig-Wood, user77)
|
||||
- filter: Fix --files-from copy stopping at the first unreadable
|
||||
file (Nick Craig-Wood)
|
||||
- fs
|
||||
- Fix command line flag being ignored when set to its default
|
||||
value (Nick Craig-Wood)
|
||||
- Fix negative offset when a suffix Range request exceeds
|
||||
object size (Amit Mishra)
|
||||
- gui: Update embedded release to 1.1.10 (Nick Craig-Wood)
|
||||
- ncdu: Fix duplicated keystrokes on Windows by pinning tcell to
|
||||
v2.9.0 (Nick Craig-Wood)
|
||||
- serve restic: Fix --private-repos isolation bypass
|
||||
CVE-2026-59733 (Nick Craig-Wood)
|
||||
- serve s3
|
||||
- Fix spurious 404 on HEAD/GET during VFS writeback (max)
|
||||
- Fix path traversal letting clients see files in the root
|
||||
GHSA-8v25-v8p6-qf7v (Nick Craig-Wood)
|
||||
- serve webdav: Fix MOVE overwrite failing without Overwrite
|
||||
header (Sanjay Santhanam)
|
||||
- serve/http: Fix --disable-zip so it works over rc (Nick
|
||||
Craig-Wood)
|
||||
- VFS
|
||||
- Fix hang reopening a file during the handle-caching grace period
|
||||
(Nick Craig-Wood)
|
||||
- Local
|
||||
- Stop --links symlinks escaping the destination directory
|
||||
CVE-2026-54572 (Nick Craig-Wood)
|
||||
- Don't restore setuid/setgid/sticky bits from metadata by default
|
||||
GHSA-945v-v9p3-v5xw (Nick Craig-Wood)
|
||||
- Drive
|
||||
- Warn when non-exportable Google documents are skipped (Nick
|
||||
Craig-Wood)
|
||||
- Fix stray %!(EXTRA) in unexportable google document log message
|
||||
(Nick Craig-Wood)
|
||||
- Warn when using rclone's shared client_id (Nick Craig-Wood)
|
||||
- Filelu
|
||||
- Fix recursive listing path handling and file filtering
|
||||
(kingston125)
|
||||
- Googlephotos
|
||||
- Warn when using rclone's shared client_id (Nick Craig-Wood)
|
||||
- Mega
|
||||
- Wait for server events after upload, delete and move (Nick
|
||||
Craig-Wood)
|
||||
- Fix hard deleted files reappearing in listings (Nick Craig-Wood)
|
||||
- S3
|
||||
- Remove session token on cross-host redirects (IceLocke)
|
||||
- Strip STS security token on same-host HTTPS->HTTP redirect
|
||||
GHSA-cf44-9pgv-m4xc (Nick Craig-Wood)
|
||||
- Fix error mapping in GetObject to match HeadObject (lewoberst)
|
||||
- Correct documented copy_cutoff minimum to 1 byte (max)
|
||||
- Fix mounting a prefix failing with 403 when HEAD is not
|
||||
permitted (Nick Craig-Wood)
|
||||
- Smb
|
||||
- Fix for IBM iSeries and signature verification (dithwick)
|
||||
- WebDAV
|
||||
- Fix mixed property statuses in multi-status responses
|
||||
(nako-ruru)
|
||||
|
||||
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
|
||||
|
||||
+5
-2
@@ -43,7 +43,10 @@ This file describes how to make the various kinds of releases
|
||||
|
||||
Early in the next release cycle update the dependencies.
|
||||
|
||||
- Review any pinned packages in go.mod and remove if possible
|
||||
- Active Pins
|
||||
- `github.com/gdamore/tcell/v2` v2.9.0 - awaiting fix for [tcell/issues/1124](https://github.com/gdamore/tcell/issues/1124)
|
||||
- See: [#9539](https://github.com/rclone/rclone/issues/9539)
|
||||
- Review Active Pins in go.mod and remove if possible
|
||||
- `make updatedirect`
|
||||
- `make GOTAGS=cmount`
|
||||
- `make compiletest`
|
||||
@@ -192,7 +195,7 @@ this will be done already.
|
||||
Now
|
||||
|
||||
- git co ${BASE_TAG}-stable
|
||||
- git cherry-pick any fixes
|
||||
- `git cherry-pick -x` any fixes
|
||||
- make startstable
|
||||
- Do the steps as above
|
||||
- git co master
|
||||
|
||||
@@ -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
@@ -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{
|
||||
|
||||
+16
-4
@@ -144,6 +144,7 @@ var (
|
||||
_importFormats map[string][]string // allowed import MIME type conversions
|
||||
templatesOnce sync.Once // parse link templates only once
|
||||
_linkTemplates map[string]*template.Template // available link types
|
||||
gdocsWarnOnce sync.Once // warn once about skipped non-exportable Google documents
|
||||
)
|
||||
|
||||
// rwChoices type for fs.Bits
|
||||
@@ -1302,6 +1303,7 @@ func createOAuthClient(ctx context.Context, opt *Options, name string, m configm
|
||||
return nil, fmt.Errorf("failed to create client from environment: %w", err)
|
||||
}
|
||||
} else {
|
||||
oauthutil.SharedClientIDWarning(name, "Google Drive", "https://rclone.org/drive/#making-your-own-client-id", m)
|
||||
oAuthClient, _, err = oauthutil.NewClientWithBaseClient(ctx, name, m, driveConfig, getClient(ctx, opt))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create oauth client: %w", err)
|
||||
@@ -1686,6 +1688,9 @@ func (f *Fs) newObjectWithExportInfo(
|
||||
// If item MimeType is in the ExportFormats then it is a google doc
|
||||
if !isDocument {
|
||||
fs.Debugf(remote, "Ignoring unknown document type %q", info.MimeType)
|
||||
gdocsWarnOnce.Do(func() {
|
||||
fs.Logf(remote, "Skipping unexportable google document %q. Use --drive-show-all-gdocs to include them in server side copy and move", info.MimeType)
|
||||
})
|
||||
return nil, fs.ErrorObjectNotFound
|
||||
}
|
||||
if extension == "" {
|
||||
@@ -3034,11 +3039,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))
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
+15
-17
@@ -222,38 +222,36 @@ func (f *Fs) List(ctx context.Context, dir string) (fs.DirEntries, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fldMap := map[string]bool{}
|
||||
for _, folder := range result.Result.Folders {
|
||||
fldMap[folder.FldID.String()] = true
|
||||
if f.root == "" && dir == "" && strings.Contains(folder.Path, "/") {
|
||||
continue
|
||||
}
|
||||
|
||||
paths := strings.Split(folder.Path, fullPath+"/")
|
||||
remote := paths[0]
|
||||
if len(paths) > 1 {
|
||||
remote = paths[1]
|
||||
folderPath := strings.Trim(folder.Path, "/")
|
||||
root := strings.Trim(f.root, "/")
|
||||
|
||||
remotePathWithoutRoot := folderPath
|
||||
|
||||
if root != "" {
|
||||
if remotePathWithoutRoot == root {
|
||||
continue
|
||||
}
|
||||
remotePathWithoutRoot = strings.TrimPrefix(remotePathWithoutRoot, root+"/")
|
||||
}
|
||||
|
||||
if strings.Contains(remote, "/") {
|
||||
remotePathWithoutRoot = strings.TrimPrefix(remotePathWithoutRoot, "/")
|
||||
|
||||
if remotePathWithoutRoot == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
pathsWithoutRoot := strings.Split(folder.Path, "/"+f.root+"/")
|
||||
remotePathWithoutRoot := pathsWithoutRoot[0]
|
||||
if len(pathsWithoutRoot) > 1 {
|
||||
remotePathWithoutRoot = pathsWithoutRoot[1]
|
||||
}
|
||||
remotePathWithoutRoot = strings.TrimPrefix(remotePathWithoutRoot, "/")
|
||||
entries = append(entries, fs.NewDir(remotePathWithoutRoot, time.Now()))
|
||||
}
|
||||
|
||||
for _, file := range result.Result.Files {
|
||||
if _, ok := fldMap[file.FldID.String()]; ok {
|
||||
continue
|
||||
}
|
||||
remote := path.Join(dir, file.Name)
|
||||
// trim leading slashes
|
||||
remote = strings.TrimPrefix(remote, "/")
|
||||
|
||||
obj := &Object{
|
||||
fs: f,
|
||||
remote: remote,
|
||||
|
||||
@@ -349,6 +349,8 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
|
||||
return nil, err
|
||||
}
|
||||
|
||||
oauthutil.SharedClientIDWarning(name, "Google Photos", "https://rclone.org/googlephotos/#making-your-own-client-id", m)
|
||||
|
||||
baseClient := fshttp.NewClient(ctx)
|
||||
oAuthClient, ts, err := oauthutil.NewClientWithBaseClient(ctx, name, m, oauthConfig, baseClient)
|
||||
if err != nil {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
+140
-32
@@ -78,6 +78,13 @@ User metadata is stored as extended attributes (which may not be
|
||||
supported by all file systems) under the "user.*" prefix.
|
||||
|
||||
Metadata is supported on files and directories.
|
||||
|
||||
When restoring metadata with ` + "`--metadata`" + ` rclone applies the
|
||||
"mode", "uid" and "gid" from the source. These come from the source
|
||||
remote which may not be trusted, so restoring metadata as root from an
|
||||
untrusted source can change file ownership and is not recommended. The
|
||||
setuid, setgid and sticky bits are not restored by default - see the
|
||||
` + "`--local-metadata-restore-special-bits`" + ` flag.
|
||||
`,
|
||||
},
|
||||
Options: []fs.Option{
|
||||
@@ -280,6 +287,37 @@ enabled, rclone will no longer update the modtime after copying a file.`,
|
||||
Default: false,
|
||||
Advanced: true,
|
||||
},
|
||||
{
|
||||
Name: "metadata_restore_special_bits",
|
||||
Help: `Restore the setuid, setgid and sticky bits from metadata.
|
||||
|
||||
When restoring metadata with --metadata rclone applies the "mode" from
|
||||
the source. By default rclone applies only the permission bits and
|
||||
strips the setuid, setgid and sticky bits.
|
||||
|
||||
The "mode" comes from the source remote which may not be trusted.
|
||||
Restoring a setuid or setgid bit onto freshly written,
|
||||
source-controlled content can plant a setuid binary, which is dangerous
|
||||
in particular when restoring from an untrusted source while running as
|
||||
root. For this reason these bits are not restored by default.
|
||||
|
||||
If you trust the source and want the setuid, setgid and sticky bits
|
||||
restored - for example when restoring a system backup made by rclone -
|
||||
set this flag.`,
|
||||
Default: false,
|
||||
Advanced: true,
|
||||
},
|
||||
{
|
||||
Name: "fatal_if_no_space",
|
||||
Help: `Make out-of-space errors fatal during transfers.
|
||||
|
||||
When enabled, an ENOSPC error during a write returns a fatal error so
|
||||
that rclone aborts rather than retrying the operation. Useful for
|
||||
backup scripts that should halt loudly on a full disk rather than spin
|
||||
retrying.`,
|
||||
Default: false,
|
||||
Advanced: true,
|
||||
},
|
||||
{
|
||||
Name: "time_type",
|
||||
Help: `Set what kind of time is returned.
|
||||
@@ -336,23 +374,24 @@ only useful for reading.
|
||||
|
||||
// Options defines the configuration for this backend
|
||||
type Options struct {
|
||||
FollowSymlinks bool `config:"copy_links"`
|
||||
TranslateSymlinks bool `config:"links"`
|
||||
SkipSymlinks bool `config:"skip_links"`
|
||||
SkipSpecials bool `config:"skip_specials"`
|
||||
UTFNorm bool `config:"unicode_normalization"`
|
||||
NoCheckUpdated bool `config:"no_check_updated"`
|
||||
NoUNC bool `config:"nounc"`
|
||||
OneFileSystem bool `config:"one_file_system"`
|
||||
CaseSensitive bool `config:"case_sensitive"`
|
||||
CaseInsensitive bool `config:"case_insensitive"`
|
||||
NoPreAllocate bool `config:"no_preallocate"`
|
||||
NoSparse bool `config:"no_sparse"`
|
||||
NoSetModTime bool `config:"no_set_modtime"`
|
||||
TimeType timeType `config:"time_type"`
|
||||
Hashes fs.CommaSepList `config:"hashes"`
|
||||
Enc encoder.MultiEncoder `config:"encoding"`
|
||||
NoClone bool `config:"no_clone"`
|
||||
FollowSymlinks bool `config:"copy_links"`
|
||||
TranslateSymlinks bool `config:"links"`
|
||||
SkipSymlinks bool `config:"skip_links"`
|
||||
SkipSpecials bool `config:"skip_specials"`
|
||||
UTFNorm bool `config:"unicode_normalization"`
|
||||
NoCheckUpdated bool `config:"no_check_updated"`
|
||||
NoUNC bool `config:"nounc"`
|
||||
OneFileSystem bool `config:"one_file_system"`
|
||||
CaseSensitive bool `config:"case_sensitive"`
|
||||
CaseInsensitive bool `config:"case_insensitive"`
|
||||
NoPreAllocate bool `config:"no_preallocate"`
|
||||
NoSparse bool `config:"no_sparse"`
|
||||
NoSetModTime bool `config:"no_set_modtime"`
|
||||
TimeType timeType `config:"time_type"`
|
||||
Hashes fs.CommaSepList `config:"hashes"`
|
||||
Enc encoder.MultiEncoder `config:"encoding"`
|
||||
NoClone bool `config:"no_clone"`
|
||||
MetadataRestoreSpecial bool `config:"metadata_restore_special_bits"`
|
||||
}
|
||||
|
||||
// Fs represents a local filesystem rooted at root
|
||||
@@ -778,7 +817,7 @@ func (f *Fs) PutStream(ctx context.Context, in io.Reader, src fs.ObjectInfo, opt
|
||||
// Mkdir creates the directory if it doesn't exist
|
||||
func (f *Fs) Mkdir(ctx context.Context, dir string) error {
|
||||
localPath := f.localPath(dir)
|
||||
err := file.MkdirAll(localPath, 0777)
|
||||
err := f.mkdirAll(localPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1395,10 +1434,84 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.Read
|
||||
return in, nil
|
||||
}
|
||||
|
||||
// osRoot opens an *os.Root anchored at f.root, together with localPath
|
||||
// expressed relative to it. The caller must Close the returned root.
|
||||
//
|
||||
// When translating symlinks (-l/--links) all writes go through an os.Root so a
|
||||
// symlink planted by a malicious source can never be traversed to escape the
|
||||
// destination (CWE-59, GHSA-cf44-9pgv-m4xc).
|
||||
//
|
||||
// f.root is the trusted destination the user chose, so it is created (and
|
||||
// followed if it is itself a symlink) before being opened.
|
||||
func (f *Fs) osRoot(localPath string) (root *os.Root, rel string, err error) {
|
||||
rel, err = filepath.Rel(f.root, localPath)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
if err = file.MkdirAll(f.root, 0777); err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
root, err = os.OpenRoot(f.root)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
return root, rel, nil
|
||||
}
|
||||
|
||||
// mkdirAll makes localPath and any missing parents. When translating
|
||||
// symlinks it does so through os.Root so directory creation can't be
|
||||
// redirected through a planted symlink out of the destination.
|
||||
func (f *Fs) mkdirAll(localPath string) (err error) {
|
||||
if !f.opt.TranslateSymlinks {
|
||||
return file.MkdirAll(localPath, 0777)
|
||||
}
|
||||
root, rel, err := f.osRoot(localPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer fs.CheckClose(root, &err)
|
||||
if rel == "." {
|
||||
return nil // the root itself, already created by linkRoot
|
||||
}
|
||||
return root.MkdirAll(rel, 0777)
|
||||
}
|
||||
|
||||
// openFile opens localPath for writing. When translating symlinks it goes
|
||||
// through os.Root so a symlink planted at the path, or at any parent, is never
|
||||
// followed out of the destination. The returned file is independent of the
|
||||
// root, which is closed before returning.
|
||||
func (f *Fs) openFile(localPath string, flags int, perm os.FileMode) (fi *os.File, err error) {
|
||||
if !f.opt.TranslateSymlinks {
|
||||
return file.OpenFile(localPath, flags, perm)
|
||||
}
|
||||
root, rel, err := f.osRoot(localPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer fs.CheckClose(root, &err)
|
||||
return root.OpenFile(rel, flags, perm)
|
||||
}
|
||||
|
||||
// symlink creates a symlink with the given target at localPath, removing
|
||||
// any existing file or symlink there first. It goes through os.Root, which
|
||||
// creates the link verbatim (the target may point anywhere, preserving a
|
||||
// faithful backup) but refuses to create it through a planted symlink, and
|
||||
// won't remove a directory in the way.
|
||||
func (f *Fs) symlink(target, localPath string) (err error) {
|
||||
root, rel, err := f.osRoot(localPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer fs.CheckClose(root, &err)
|
||||
if err := root.Remove(rel); err != nil && !os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
return root.Symlink(target, rel)
|
||||
}
|
||||
|
||||
// mkdirAll makes all the directories needed to store the object
|
||||
func (o *Object) mkdirAll() error {
|
||||
dir := filepath.Dir(o.path)
|
||||
return file.MkdirAll(dir, 0777)
|
||||
return o.fs.mkdirAll(filepath.Dir(o.path))
|
||||
}
|
||||
|
||||
type nopWriterCloser struct {
|
||||
@@ -1440,13 +1553,13 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
|
||||
// If it is a translated link, just read in the contents, and
|
||||
// then create a symlink
|
||||
if !o.translatedLink {
|
||||
f, err := file.OpenFile(o.path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
|
||||
f, err := o.fs.openFile(o.path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
|
||||
if err != nil {
|
||||
if runtime.GOOS == "windows" && os.IsPermission(err) {
|
||||
// If permission denied on Windows might be trying to update a
|
||||
// hidden file, in which case try opening without CREATE
|
||||
// See: https://stackoverflow.com/questions/13215716/ioerror-errno-13-permission-denied-when-trying-to-open-hidden-file-in-w-mod
|
||||
f, err = file.OpenFile(o.path, os.O_WRONLY|os.O_TRUNC, 0666)
|
||||
f, err = o.fs.openFile(o.path, os.O_WRONLY|os.O_TRUNC, 0666)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1483,15 +1596,10 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
|
||||
|
||||
if o.translatedLink {
|
||||
if err == nil {
|
||||
// Remove any current symlink or file, if one exists
|
||||
if _, err := os.Lstat(o.path); err == nil {
|
||||
if removeErr := os.Remove(o.path); removeErr != nil {
|
||||
fs.Errorf(o, "Failed to remove previous file: %v", removeErr)
|
||||
return removeErr
|
||||
}
|
||||
}
|
||||
// Use the contents for the copied object to create a symlink
|
||||
err = os.Symlink(symlinkData.String(), o.path)
|
||||
// Use the contents of the copied object to create a symlink,
|
||||
// without following or creating it through a planted symlink
|
||||
// (CWE-59). Any existing file or symlink at the path is replaced.
|
||||
err = o.fs.symlink(symlinkData.String(), o.path)
|
||||
}
|
||||
|
||||
// only continue if symlink creation succeeded
|
||||
@@ -1555,7 +1663,7 @@ func (f *Fs) OpenWriterAt(ctx context.Context, remote string, size int64) (fs.Wr
|
||||
return nil, errors.New("can't open a symlink for random writing")
|
||||
}
|
||||
|
||||
out, err := file.OpenFile(o.path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
|
||||
out, err := f.openFile(o.path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sort"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -204,6 +205,140 @@ func TestSymlinkError(t *testing.T) {
|
||||
assert.Equal(t, errLinksAndCopyLinks, err)
|
||||
}
|
||||
|
||||
// putLink writes target as a translated link object (name + ".rclonelink") on f.
|
||||
func putLink(ctx context.Context, f fs.Fs, name, target string) error {
|
||||
in := bytes.NewBufferString(target)
|
||||
src := object.NewStaticObjectInfo(name+fs.LinkSuffix, fstest.Time("2001-02-03T04:05:10Z"), int64(len(target)), true, nil, nil)
|
||||
_, err := f.Put(ctx, in, src)
|
||||
return err
|
||||
}
|
||||
|
||||
// putFile writes content as a regular object on f.
|
||||
func putFile(ctx context.Context, f fs.Fs, remote, content string) error {
|
||||
in := bytes.NewBufferString(content)
|
||||
src := object.NewStaticObjectInfo(remote, fstest.Time("2001-02-03T04:05:10Z"), int64(len(content)), true, nil, nil)
|
||||
_, err := f.Put(ctx, in, src)
|
||||
return err
|
||||
}
|
||||
|
||||
// linksMode puts f into "-l/--links" mode, as if --links or the backend
|
||||
// links=true option were set.
|
||||
func linksMode(f *Fs) {
|
||||
f.opt.FollowSymlinks = false
|
||||
f.opt.TranslateSymlinks = true
|
||||
f.lstat = os.Lstat
|
||||
}
|
||||
|
||||
// TestSymlinkEscapeWriteThroughBlocked mirrors the GHSA-cf44-9pgv-m4xc PoC: a
|
||||
// malicious --links source serves "pwn.rclonelink" whose body is a path outside
|
||||
// the destination, plus a sibling "pwn/authkeys" that sorts after it and would
|
||||
// be written through the planted symlink. rclone reproduces the symlink (a
|
||||
// faithful backup of the source) but must refuse to write through it, so
|
||||
// nothing lands outside the destination (CWE-59).
|
||||
func TestSymlinkEscapeWriteThroughBlocked(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
// A directory outside the destination the attacker wants to write into
|
||||
evil := t.TempDir()
|
||||
evilFile := filepath.Join(evil, "authkeys")
|
||||
|
||||
r := fstest.NewRun(t)
|
||||
f := r.Flocal.(*Fs)
|
||||
linksMode(f)
|
||||
|
||||
// The symlink is reproduced faithfully, pointing outside the destination.
|
||||
require.NoError(t, putLink(ctx, f, "pwn", evil))
|
||||
link := filepath.Join(f.root, "pwn")
|
||||
fi, err := os.Lstat(link)
|
||||
require.NoError(t, err)
|
||||
require.True(t, fi.Mode()&os.ModeSymlink != 0, "symlink should be reproduced faithfully")
|
||||
target, err := os.Readlink(link)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, evil, target)
|
||||
|
||||
// But writing the sibling object through it must be refused.
|
||||
err = putFile(ctx, f, "pwn/authkeys", "PWNED")
|
||||
require.Error(t, err, "writing through a planted symlink should be refused")
|
||||
|
||||
// Nothing escaped the destination.
|
||||
_, err = os.Stat(evilFile)
|
||||
require.True(t, os.IsNotExist(err), "a file escaped the destination into %q", evilFile)
|
||||
}
|
||||
|
||||
// TestSymlinkEscapeNestedBlocked covers the chained variant: an in-tree symlink
|
||||
// "evil" -> "." (the destination root) is created, then "evil/pwn" -> outside
|
||||
// is planted through it, then a write nested under that. Every component is
|
||||
// re-validated against the root, so the write-through is refused and nothing
|
||||
// escapes.
|
||||
func TestSymlinkEscapeNestedBlocked(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
evil := t.TempDir()
|
||||
evilFile := filepath.Join(evil, "authkeys")
|
||||
|
||||
r := fstest.NewRun(t)
|
||||
f := r.Flocal.(*Fs)
|
||||
linksMode(f)
|
||||
|
||||
require.NoError(t, putLink(ctx, f, "evil", "."))
|
||||
require.NoError(t, putLink(ctx, f, "evil/pwn", evil))
|
||||
|
||||
err := putFile(ctx, f, "evil/pwn/authkeys", "PWNED")
|
||||
require.Error(t, err, "writing through a nested planted symlink should be refused")
|
||||
|
||||
_, err = os.Stat(evilFile)
|
||||
require.True(t, os.IsNotExist(err), "a file escaped the destination into %q", evilFile)
|
||||
}
|
||||
|
||||
// TestSymlinkEscapeConcurrent races symlink creation against the sibling write
|
||||
// for many pairs at once, exercising the time-of-check/time-of-use window.
|
||||
// os.Root resolves relative to a directory file descriptor, so whatever the
|
||||
// interleaving nothing may escape the destination.
|
||||
func TestSymlinkEscapeConcurrent(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
evil := t.TempDir()
|
||||
|
||||
r := fstest.NewRun(t)
|
||||
f := r.Flocal.(*Fs)
|
||||
linksMode(f)
|
||||
|
||||
const pairs = 50
|
||||
var wg sync.WaitGroup
|
||||
for i := range pairs {
|
||||
name := fmt.Sprintf("pwn%d", i)
|
||||
wg.Add(2)
|
||||
go func() { defer wg.Done(); _ = putLink(ctx, f, name, evil) }()
|
||||
go func() { defer wg.Done(); _ = putFile(ctx, f, name+"/authkeys", "PWNED") }()
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
entries, err := os.ReadDir(evil)
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, entries, "files escaped the destination into %q", evil)
|
||||
}
|
||||
|
||||
// TestSymlinkInTreeWriteThroughWorks checks the fix doesn't break legitimate
|
||||
// use: an in-tree symlink to a sibling directory can still be created and
|
||||
// written through, since that write stays inside the destination.
|
||||
func TestSymlinkInTreeWriteThroughWorks(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
r := fstest.NewRun(t)
|
||||
f := r.Flocal.(*Fs)
|
||||
linksMode(f)
|
||||
|
||||
require.NoError(t, putFile(ctx, f, "sub/keep.txt", "hello"))
|
||||
require.NoError(t, putLink(ctx, f, "link", "sub"))
|
||||
|
||||
require.NoError(t, putFile(ctx, f, "link/file.txt", "world"))
|
||||
|
||||
// The write landed in the real sibling directory, inside the destination.
|
||||
got, err := os.ReadFile(filepath.Join(f.root, "sub", "file.txt"))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "world", string(got))
|
||||
}
|
||||
|
||||
func TestHashWithTypeNone(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
r := fstest.NewRun(t)
|
||||
@@ -471,6 +606,59 @@ func testMetadata(t *testing.T, r *fstest.Run, o *Object, when time.Time) {
|
||||
})
|
||||
}
|
||||
|
||||
// Check that the setuid, setgid and sticky bits from "mode" metadata are
|
||||
// stripped by default and only restored with --local-metadata-restore-special-bits.
|
||||
//
|
||||
// See: https://github.com/rclone/rclone/security/advisories/GHSA-945v-v9p3-v5xw
|
||||
func TestMetadataSpecialBits(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "windows", "plan9", "js":
|
||||
t.Skip("mode metadata is not applied on this OS")
|
||||
}
|
||||
ctx := context.Background()
|
||||
r := fstest.NewRun(t)
|
||||
const filePath = "setuid.bin"
|
||||
r.WriteFile(filePath, "payload", time.Now())
|
||||
f := r.Flocal.(*Fs)
|
||||
|
||||
obj, err := f.NewObject(ctx, filePath)
|
||||
require.NoError(t, err)
|
||||
o := obj.(*Object)
|
||||
osPath := filepath.Join(f.root, filePath)
|
||||
|
||||
statMode := func() os.FileMode {
|
||||
t.Helper()
|
||||
fi, err := os.Stat(osPath)
|
||||
require.NoError(t, err)
|
||||
return fi.Mode()
|
||||
}
|
||||
|
||||
// "40000755" is Go's os.FileMode layout for setuid|0755 - a value a real
|
||||
// unix st_mode can never produce, so it can only come from an
|
||||
// attacker-controlled source remote.
|
||||
const setuidMode = "40000755"
|
||||
|
||||
t.Run("StrippedByDefault", func(t *testing.T) {
|
||||
require.NoError(t, os.Chmod(osPath, 0644))
|
||||
require.NoError(t, o.writeMetadataToFile(fs.Metadata{"mode": setuidMode}))
|
||||
mode := statMode()
|
||||
assert.Equal(t, os.FileMode(0755), mode.Perm())
|
||||
assert.Zero(t, mode&(os.ModeSetuid|os.ModeSetgid|os.ModeSticky),
|
||||
fmt.Sprintf("special bits should be stripped by default, got %v", mode))
|
||||
})
|
||||
|
||||
t.Run("RestoredWithFlag", func(t *testing.T) {
|
||||
f.opt.MetadataRestoreSpecial = true
|
||||
defer func() { f.opt.MetadataRestoreSpecial = false }()
|
||||
require.NoError(t, os.Chmod(osPath, 0644))
|
||||
require.NoError(t, o.writeMetadataToFile(fs.Metadata{"mode": setuidMode}))
|
||||
mode := statMode()
|
||||
assert.Equal(t, os.FileMode(0755), mode.Perm())
|
||||
assert.NotZero(t, mode&os.ModeSetuid,
|
||||
fmt.Sprintf("setuid bit should be restored with the flag, got %v", mode))
|
||||
})
|
||||
}
|
||||
|
||||
func TestFilter(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
r := fstest.NewRun(t)
|
||||
|
||||
@@ -140,15 +140,22 @@ func (o *Object) writeMetadataToFile(m fs.Metadata) (outErr error) {
|
||||
if mode >= 0 {
|
||||
umode := uint(mode)
|
||||
if umode <= math.MaxUint32 {
|
||||
fileMode := os.FileMode(umode)
|
||||
// fileMode comes from the source, which may be untrusted, so
|
||||
// by default apply only the permission bits and strip the
|
||||
// setuid, setgid and sticky bits.
|
||||
if !o.fs.opt.MetadataRestoreSpecial {
|
||||
fileMode = fileMode.Perm()
|
||||
}
|
||||
if o.translatedLink {
|
||||
if haveLChmod {
|
||||
err = lChmod(o.path, os.FileMode(umode))
|
||||
err = lChmod(o.path, fileMode)
|
||||
} else {
|
||||
fs.Debugf(o, "Unable to set mode %v on a symlink on this OS", os.FileMode(umode))
|
||||
fs.Debugf(o, "Unable to set mode %v on a symlink on this OS", fileMode)
|
||||
err = nil
|
||||
}
|
||||
} else {
|
||||
err = os.Chmod(o.path, os.FileMode(umode))
|
||||
err = os.Chmod(o.path, fileMode)
|
||||
}
|
||||
if err != nil {
|
||||
outErr = fmt.Errorf("failed to change permissions: %w", err)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
+12
-2
@@ -770,6 +770,8 @@ func (f *Fs) move(ctx context.Context, dstRemote string, srcFs *Fs, srcRemote st
|
||||
return fmt.Errorf("server-side move failed to lookup src parent dir: %w", err)
|
||||
}
|
||||
|
||||
waitEvent := f.srv.WaitEventsStart()
|
||||
|
||||
// move the object into its new directory if required
|
||||
if srcDirNode != dstDirNode && srcDirNode.GetHash() != dstDirNode.GetHash() {
|
||||
//log.Printf("move src %p %q dst %p %q", srcDirNode, srcDirNode.GetName(), dstDirNode, dstDirNode.GetName())
|
||||
@@ -782,8 +784,6 @@ func (f *Fs) move(ctx context.Context, dstRemote string, srcFs *Fs, srcRemote st
|
||||
}
|
||||
}
|
||||
|
||||
waitEvent := f.srv.WaitEventsStart()
|
||||
|
||||
// rename the object if required
|
||||
if srcLeaf != dstLeaf {
|
||||
//log.Printf("rename %q to %q", srcLeaf, dstLeaf)
|
||||
@@ -1216,6 +1216,8 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
|
||||
}
|
||||
}
|
||||
|
||||
waitEvent := o.fs.srv.WaitEventsStart()
|
||||
|
||||
// Finish the upload
|
||||
var info *mega.Node
|
||||
err = o.fs.pacer.Call(func() (bool, error) {
|
||||
@@ -1235,15 +1237,23 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
|
||||
o.info = nil
|
||||
}
|
||||
|
||||
// Wait for the server to confirm the new file
|
||||
o.fs.srv.WaitEvents(waitEvent, eventWaitTime)
|
||||
|
||||
return o.setMetaData(info)
|
||||
}
|
||||
|
||||
// Remove an object
|
||||
func (o *Object) Remove(ctx context.Context) error {
|
||||
waitEvent := o.fs.srv.WaitEventsStart()
|
||||
|
||||
err := o.fs.deleteNode(ctx, o.info)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Remove object failed: %w", err)
|
||||
}
|
||||
|
||||
// Wait for the server to confirm the deletion
|
||||
o.fs.srv.WaitEvents(waitEvent, eventWaitTime)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package mega
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/rclone/rclone/fs/object"
|
||||
"github.com/rclone/rclone/fstest/fstests"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// InternalTestGhostAfterRemove checks that a file removed in a long-running
|
||||
// process disappears from listings straight away rather than lingering as a
|
||||
// ghost until go-mega's next event poll reconciles the in-memory tree.
|
||||
//
|
||||
// It puts, removes and lists in a tight loop to make any lingering entry
|
||||
// show up reliably, exercising whichever delete mode the remote is
|
||||
// configured with (hard_delete or the default trash).
|
||||
func (f *Fs) InternalTestGhostAfterRemove(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
dir := "ghost-test"
|
||||
require.NoError(t, f.Mkdir(ctx, dir))
|
||||
defer func() { _ = f.Rmdir(ctx, dir) }()
|
||||
|
||||
contents := []byte("ghost test contents")
|
||||
for i := range 10 {
|
||||
remote := dir + "/test.txt"
|
||||
src := object.NewStaticObjectInfo(remote, time.Now(), int64(len(contents)), true, nil, nil)
|
||||
obj, err := f.Put(ctx, bytes.NewReader(contents), src)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, obj.Remove(ctx))
|
||||
|
||||
// The file must be gone from the listing straight away - if the
|
||||
// in-memory tree isn't settled it lingers as a ghost.
|
||||
entries, err := f.List(ctx, dir)
|
||||
require.NoError(t, err)
|
||||
names := make([]string, 0, len(entries))
|
||||
for _, entry := range entries {
|
||||
names = append(names, entry.Remote())
|
||||
}
|
||||
assert.NotContains(t, names, remote, "file should be gone immediately after remove (iteration %d)", i)
|
||||
}
|
||||
}
|
||||
|
||||
// InternalTest dispatches the backend specific internal tests
|
||||
func (f *Fs) InternalTest(t *testing.T) {
|
||||
t.Run("GhostAfterRemove", f.InternalTestGhostAfterRemove)
|
||||
}
|
||||
|
||||
var _ fstests.InternalTester = (*Fs)(nil)
|
||||
+67
-8
@@ -286,7 +286,7 @@ large file of a known size to stay below this number of chunks limit.
|
||||
Any files larger than this that need to be server-side copied will be
|
||||
copied in chunks of this size.
|
||||
|
||||
The minimum is 0 and the maximum is 5 GiB.`,
|
||||
The minimum is 1 byte and the maximum is 5 GiB.`,
|
||||
Default: fs.SizeSuffix(maxSizeForCopy),
|
||||
Advanced: true,
|
||||
}, {
|
||||
@@ -1351,10 +1351,34 @@ func getClient(ctx context.Context, opt *Options) *http.Client {
|
||||
}
|
||||
})
|
||||
return &http.Client{
|
||||
Transport: t,
|
||||
Transport: t,
|
||||
CheckRedirect: s3CheckRedirect,
|
||||
}
|
||||
}
|
||||
|
||||
func s3CheckRedirect(req *http.Request, via []*http.Request) error {
|
||||
if len(via) >= 10 {
|
||||
return errors.New("stopped after 10 redirects")
|
||||
}
|
||||
if s3RedirectCrossesHost(req, via) {
|
||||
req.Header.Del("X-Amz-Security-Token")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func s3RedirectCrossesHost(req *http.Request, via []*http.Request) bool {
|
||||
if len(via) == 0 {
|
||||
return false
|
||||
}
|
||||
scheme, host := via[0].URL.Scheme, via[0].URL.Host
|
||||
for _, redirect := range via[1:] {
|
||||
if redirect.URL.Host != host || redirect.URL.Scheme != scheme {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return host != req.URL.Host || scheme != req.URL.Scheme
|
||||
}
|
||||
|
||||
// Fixup the request if needed.
|
||||
//
|
||||
// Google Cloud Storage alters the Accept-Encoding header, which
|
||||
@@ -1899,20 +1923,52 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
|
||||
newRoot, leaf := path.Split(oldRoot)
|
||||
f.setRoot(newRoot)
|
||||
_, err := f.NewObject(ctx, leaf)
|
||||
if errors.Is(err, fs.ErrorObjectNotFound) {
|
||||
switch {
|
||||
case err == nil:
|
||||
// It is a file so return an fs which points to the parent
|
||||
return f, fs.ErrorIsFile
|
||||
case errors.Is(err, fs.ErrorObjectNotFound):
|
||||
// File doesn't exist or is a directory so return old f
|
||||
f.setRoot(oldRoot)
|
||||
return f, nil
|
||||
default:
|
||||
// We couldn't HEAD the object so now attempt to list it
|
||||
hasChildren, listErr := f.hasChildren(ctx, leaf)
|
||||
if listErr != nil {
|
||||
fs.Debugf(f, "Couldn't check %q for children after HEAD failed (%v): %v", oldRoot, err, listErr)
|
||||
}
|
||||
// If it listed and has children it must be a directory
|
||||
if hasChildren {
|
||||
f.setRoot(oldRoot)
|
||||
return f, nil
|
||||
}
|
||||
// If it has no children it is either a file or an empty directory. We can't
|
||||
// tell these two cases apart. We choose file which is more likely, and
|
||||
// return an fs which points to the parent.
|
||||
return f, fs.ErrorIsFile
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// return an error with an fs which points to the parent
|
||||
return f, fs.ErrorIsFile
|
||||
}
|
||||
return f, nil
|
||||
}
|
||||
|
||||
// hasChildren reports whether the directory dir contains any objects.
|
||||
func (f *Fs) hasChildren(ctx context.Context, dir string) (found bool, err error) {
|
||||
bucket, directory := f.split(dir)
|
||||
err = f.list(ctx, listOpt{
|
||||
bucket: bucket,
|
||||
directory: directory,
|
||||
prefix: f.rootDirectory,
|
||||
recurse: true,
|
||||
}, func(remote string, object *types.Object, versionID *string, isDirectory bool) error {
|
||||
found = true
|
||||
return errEndList // stop after the first object
|
||||
})
|
||||
if err != nil && err != fs.ErrorDirNotFound {
|
||||
return false, err
|
||||
}
|
||||
return found, nil
|
||||
}
|
||||
|
||||
// getMetaDataListing gets the metadata from the object unconditionally from the listing
|
||||
//
|
||||
// This is needed to find versioned objects from their paths.
|
||||
@@ -4337,6 +4393,9 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.Read
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
if statusCode := getHTTPStatusCode(err); statusCode == http.StatusNotFound || statusCode == http.StatusMethodNotAllowed {
|
||||
return nil, fs.ErrorObjectNotFound
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
@@ -144,6 +144,31 @@ func (f *Fs) InternalTestNoHead(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func (f *Fs) InternalTestHasChildren(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
contents := random.String(100)
|
||||
item := fstest.NewItem("has-children/file.txt", contents, fstest.Time("2001-05-06T04:05:06.499999999Z"))
|
||||
obj := fstests.PutTestContents(ctx, t, f, &item, contents, true)
|
||||
defer func() {
|
||||
assert.NoError(t, obj.Remove(ctx))
|
||||
}()
|
||||
|
||||
// A prefix with an object under it is a directory
|
||||
found, err := f.hasChildren(ctx, "has-children")
|
||||
require.NoError(t, err)
|
||||
assert.True(t, found, "prefix with an object should report children")
|
||||
|
||||
// The object itself is a file so has no children
|
||||
found, err = f.hasChildren(ctx, "has-children/file.txt")
|
||||
require.NoError(t, err)
|
||||
assert.False(t, found, "a file should not report children")
|
||||
|
||||
// A path which doesn't exist has no children
|
||||
found, err = f.hasChildren(ctx, "has-children/does-not-exist")
|
||||
require.NoError(t, err)
|
||||
assert.False(t, found, "a missing path should not report children")
|
||||
}
|
||||
|
||||
func TestVersionLess(t *testing.T) {
|
||||
key1 := "key1"
|
||||
key2 := "key2"
|
||||
@@ -785,6 +810,7 @@ func (f *Fs) InternalTestObjectLock(t *testing.T) {
|
||||
func (f *Fs) InternalTest(t *testing.T) {
|
||||
t.Run("Metadata", f.InternalTestMetadata)
|
||||
t.Run("NoHead", f.InternalTestNoHead)
|
||||
t.Run("HasChildren", f.InternalTestHasChildren)
|
||||
t.Run("Versions", f.InternalTestVersions)
|
||||
t.Run("ObjectLock", f.InternalTestObjectLock)
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ package s3
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -11,6 +12,8 @@ import (
|
||||
"github.com/rclone/rclone/fs"
|
||||
"github.com/rclone/rclone/fstest"
|
||||
"github.com/rclone/rclone/fstest/fstests"
|
||||
"github.com/rclone/rclone/lib/bucket"
|
||||
"github.com/rclone/rclone/lib/pacer"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -22,6 +25,211 @@ func SetupS3Test(t *testing.T) (context.Context, *Options, *http.Client) {
|
||||
return ctx, opt, client
|
||||
}
|
||||
|
||||
func TestClientRemovesSecurityTokenOnCrossHostRedirect(t *testing.T) {
|
||||
ctx, _, client := SetupS3Test(t)
|
||||
|
||||
redirectServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
assert.Empty(t, r.Header.Get("X-Amz-Security-Token"))
|
||||
assert.Equal(t, "date", r.Header.Get("X-Amz-Date"))
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}))
|
||||
defer redirectServer.Close()
|
||||
|
||||
initialServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
assert.Equal(t, "token", r.Header.Get("X-Amz-Security-Token"))
|
||||
http.Redirect(w, r, redirectServer.URL, http.StatusTemporaryRedirect)
|
||||
}))
|
||||
defer initialServer.Close()
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, initialServer.URL, nil)
|
||||
require.NoError(t, err)
|
||||
req.Header.Set("X-Amz-Security-Token", "token")
|
||||
req.Header.Set("X-Amz-Date", "date")
|
||||
|
||||
resp, err := client.Do(req)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
assert.NoError(t, resp.Body.Close())
|
||||
}
|
||||
|
||||
func TestClientDoesNotRestoreSecurityTokenAfterCrossHostRedirect(t *testing.T) {
|
||||
ctx, _, client := SetupS3Test(t)
|
||||
|
||||
redirectServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case "/middle":
|
||||
assert.Empty(t, r.Header.Get("X-Amz-Security-Token"))
|
||||
assert.Equal(t, "date", r.Header.Get("X-Amz-Date"))
|
||||
http.Redirect(w, r, "/final", http.StatusTemporaryRedirect)
|
||||
case "/final":
|
||||
assert.Empty(t, r.Header.Get("X-Amz-Security-Token"))
|
||||
assert.Equal(t, "date", r.Header.Get("X-Amz-Date"))
|
||||
w.WriteHeader(http.StatusOK)
|
||||
default:
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
}))
|
||||
defer redirectServer.Close()
|
||||
|
||||
initialServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
assert.Equal(t, "token", r.Header.Get("X-Amz-Security-Token"))
|
||||
http.Redirect(w, r, redirectServer.URL+"/middle", http.StatusTemporaryRedirect)
|
||||
}))
|
||||
defer initialServer.Close()
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, initialServer.URL, nil)
|
||||
require.NoError(t, err)
|
||||
req.Header.Set("X-Amz-Security-Token", "token")
|
||||
req.Header.Set("X-Amz-Date", "date")
|
||||
|
||||
resp, err := client.Do(req)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
assert.NoError(t, resp.Body.Close())
|
||||
}
|
||||
|
||||
func TestClientKeepsSecurityTokenOnSameHostRedirect(t *testing.T) {
|
||||
ctx, _, client := SetupS3Test(t)
|
||||
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case "/":
|
||||
assert.Equal(t, "token", r.Header.Get("X-Amz-Security-Token"))
|
||||
http.Redirect(w, r, "/redirected", http.StatusTemporaryRedirect)
|
||||
case "/redirected":
|
||||
assert.Equal(t, "token", r.Header.Get("X-Amz-Security-Token"))
|
||||
w.WriteHeader(http.StatusOK)
|
||||
default:
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, server.URL, nil)
|
||||
require.NoError(t, err)
|
||||
req.Header.Set("X-Amz-Security-Token", "token")
|
||||
|
||||
resp, err := client.Do(req)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
assert.NoError(t, resp.Body.Close())
|
||||
}
|
||||
|
||||
func TestRedirectCrossesHost(t *testing.T) {
|
||||
mustReq := func(method, url string) *http.Request {
|
||||
req, err := http.NewRequest(method, url, nil)
|
||||
require.NoError(t, err)
|
||||
return req
|
||||
}
|
||||
for _, test := range []struct {
|
||||
name string
|
||||
via []string
|
||||
req string
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
name: "SameHost",
|
||||
via: []string{"https://bucket.example.com/"},
|
||||
req: "https://bucket.example.com/redirected",
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "DifferentHost",
|
||||
via: []string{"https://bucket.example.com/"},
|
||||
req: "https://evil.example.com/redirected",
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "SchemeDowngradeSameHost",
|
||||
via: []string{"https://bucket.example.com/"},
|
||||
req: "http://bucket.example.com/redirected",
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "SchemeDowngradeMidChain",
|
||||
via: []string{"https://bucket.example.com/", "http://bucket.example.com/middle"},
|
||||
req: "http://bucket.example.com/final",
|
||||
want: true,
|
||||
},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
via := make([]*http.Request, len(test.via))
|
||||
for i, url := range test.via {
|
||||
via[i] = mustReq(http.MethodGet, url)
|
||||
}
|
||||
got := s3RedirectCrossesHost(mustReq(http.MethodGet, test.req), via)
|
||||
assert.Equal(t, test.want, got)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestClientStopsAfterTenRedirects(t *testing.T) {
|
||||
_, _, client := SetupS3Test(t)
|
||||
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, r.URL.String(), http.StatusTemporaryRedirect)
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
resp, err := client.Get(server.URL)
|
||||
if resp != nil {
|
||||
_ = resp.Body.Close()
|
||||
}
|
||||
require.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "stopped after 10 redirects")
|
||||
}
|
||||
|
||||
func TestObjectNotFoundMapping(t *testing.T) {
|
||||
ctx, opt, client := SetupS3Test(t)
|
||||
gotHead, gotGet := false, false
|
||||
|
||||
// Return 404 for all requests.
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.Method {
|
||||
case http.MethodHead:
|
||||
gotHead = true
|
||||
case http.MethodGet:
|
||||
gotGet = true
|
||||
}
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
opt.Endpoint = server.URL
|
||||
opt.ForcePathStyle = true
|
||||
opt.Region = "us-east-1"
|
||||
opt.AccessKeyID = "id"
|
||||
opt.SecretAccessKey = "secret"
|
||||
c, _, err := s3Connection(ctx, opt, client)
|
||||
require.NoError(t, err)
|
||||
|
||||
f := &Fs{
|
||||
name: "s3test",
|
||||
opt: *opt,
|
||||
ctx: ctx,
|
||||
c: c,
|
||||
pacer: fs.NewPacer(ctx, pacer.NewS3(pacer.MinSleep(minSleep))),
|
||||
cache: bucket.NewCache(),
|
||||
}
|
||||
f.setRoot("bucket")
|
||||
|
||||
// HEAD path: NewObject reads metadata via HeadObject.
|
||||
_, headErr := f.NewObject(ctx, "missing.txt")
|
||||
require.True(t, gotHead, "server should have received a HEAD request")
|
||||
assert.ErrorIs(t, headErr, fs.ErrorObjectNotFound)
|
||||
|
||||
// GET path: Object.Open issues a GetObject.
|
||||
o := &Object{fs: f, remote: "missing.txt"}
|
||||
in, getErr := o.Open(ctx)
|
||||
if in != nil {
|
||||
_ = in.Close()
|
||||
}
|
||||
require.True(t, gotGet, "server should have received a GET request")
|
||||
assert.ErrorIs(t, getErr, fs.ErrorObjectNotFound)
|
||||
|
||||
assert.Equal(t, headErr, getErr, "HeadObject and GetObject should map a 404 to the same error")
|
||||
}
|
||||
|
||||
// TestIntegration runs integration tests against the remote
|
||||
func TestIntegration(t *testing.T) {
|
||||
opt := &fstests.Opt{
|
||||
|
||||
@@ -98,21 +98,19 @@ func (p *Prop) Code() int {
|
||||
return code
|
||||
}
|
||||
|
||||
// StatusOK examines the Status and returns an OK flag
|
||||
// Parse a status of the form "HTTP/1.1 2xx"
|
||||
var parseStatus2XX = regexp.MustCompile(`^HTTP/[\d.]+\s+2\d{2}`)
|
||||
|
||||
// StatusOK returns true if there is at least one 2XX response.
|
||||
func (p *Prop) StatusOK() bool {
|
||||
// Fetch status code as int
|
||||
c := p.Code()
|
||||
|
||||
// Assume OK if no statuses received
|
||||
if c == -1 {
|
||||
if len(p.Status) == 0 {
|
||||
return true
|
||||
}
|
||||
if c == 0 {
|
||||
return false
|
||||
}
|
||||
if c >= 200 && c < 300 {
|
||||
return true
|
||||
|
||||
for _, statusStr := range p.Status {
|
||||
if parseStatus2XX.MatchString(statusStr) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPropStatusOK(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
status []string
|
||||
want bool
|
||||
}{
|
||||
{"Empty status", []string{}, true},
|
||||
{"Single 200 OK", []string{"HTTP/1.1 200 OK"}, true},
|
||||
{"Single 404 Not Found", []string{"HTTP/1.1 404 Not Found"}, false},
|
||||
{"Mixed status with 404 first", []string{"HTTP/1.1 404 Not Found", "HTTP/1.1 200 OK"}, true},
|
||||
{"Mixed status with 200 first", []string{"HTTP/1.1 200 OK", "HTTP/1.1 404 Not Found"}, true},
|
||||
{"Multiple non-2xx statuses", []string{"HTTP/1.1 404 Not Found", "HTTP/1.1 403 Forbidden"}, false},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
p := &Prop{Status: tt.status}
|
||||
if got := p.StatusOK(); got != tt.want {
|
||||
t.Errorf("Prop.StatusOK() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package archive_test
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"bytes"
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -170,6 +172,60 @@ func TestIntegration(t *testing.T) {
|
||||
testArchive(t)
|
||||
}
|
||||
|
||||
// craftZip builds an in-memory zip archive with the given entries, returning
|
||||
// it as a string. The entry names are written verbatim so they can include
|
||||
// crafted path traversal sequences that the archive create command would
|
||||
// never produce from real files.
|
||||
func craftZip(t *testing.T, entries []struct{ name, content string }) string {
|
||||
var buf bytes.Buffer
|
||||
zw := zip.NewWriter(&buf)
|
||||
for _, e := range entries {
|
||||
w, err := zw.CreateHeader(&zip.FileHeader{Name: e.name, Method: zip.Store})
|
||||
require.NoError(t, err)
|
||||
_, err = w.Write([]byte(e.content))
|
||||
require.NoError(t, err)
|
||||
}
|
||||
require.NoError(t, zw.Close())
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
// TestExtractPathTraversal checks that a crafted archive whose entries try to
|
||||
// escape the destination directory with ".." components is rejected and does
|
||||
// not write anything outside the destination (GHSA-4vr5-p2gc-h23p).
|
||||
func TestExtractPathTraversal(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
entry string
|
||||
}{
|
||||
{name: "forward slash", entry: "../escaped.txt"},
|
||||
{name: "backslash", entry: `..\escaped.txt`},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
r := fstest.NewRun(t)
|
||||
|
||||
zipData := craftZip(t, []struct{ name, content string }{
|
||||
{"safe.txt", "safe content"},
|
||||
{tc.entry, "escaped content"},
|
||||
})
|
||||
r.WriteObject(ctx, "malicious.zip", zipData, t1)
|
||||
|
||||
// Extract into a subdirectory so a successful escape would land
|
||||
// in "safe/escaped.txt", a sibling of the "safe/prefix" target.
|
||||
err := extract.ArchiveExtract(ctx, r.Flocal, "safe/prefix", r.Fremote, "malicious.zip")
|
||||
require.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "..")
|
||||
|
||||
// Nothing should have escaped the destination directory.
|
||||
for _, escaped := range []string{"safe/escaped.txt", "escaped.txt"} {
|
||||
_, err := r.Flocal.NewObject(ctx, escaped)
|
||||
assert.ErrorIs(t, err, fs.ErrorObjectNotFound, escaped)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMemory(t *testing.T) {
|
||||
if *fstest.RemoteName != "" {
|
||||
t.Skip("skipping as -remote is set")
|
||||
|
||||
@@ -150,19 +150,13 @@ func ArchiveExtract(ctx context.Context, dst fs.Fs, dstDir string, src fs.Fs, sr
|
||||
}
|
||||
// extract files
|
||||
err = ex.Extract(ctx, in, func(ctx context.Context, f archives.FileInfo) error {
|
||||
remote := f.NameInArchive
|
||||
// Strip leading "./" from archive paths. Tar files created with
|
||||
// relative paths (e.g. "tar -czf archive.tar.gz .") use "./" prefixed
|
||||
// entries. Without stripping, rclone encodes the "." as a full-width
|
||||
// dot character creating a spurious directory. We only strip "./"
|
||||
// specifically to avoid enabling path traversal attacks via "../".
|
||||
remote = strings.TrimPrefix(remote, "./")
|
||||
// If the entry was exactly "./" (the root dir), skip it
|
||||
if remote == "" && f.IsDir() {
|
||||
return nil
|
||||
remote, err := destPath(f.NameInArchive, dstDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if dstDir != "" {
|
||||
remote = path.Join(dstDir, remote)
|
||||
// Skip the archive root entry ("./") which has no name of its own.
|
||||
if remote == "" {
|
||||
return nil
|
||||
}
|
||||
// check if file should be extracted
|
||||
if !fi.Include(remote, f.Size(), f.ModTime(), fs.Metadata{}) {
|
||||
@@ -203,3 +197,38 @@ func ArchiveExtract(ctx context.Context, dst fs.Fs, dstDir string, src fs.Fs, sr
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// destPath maps an archive entry name onto its destination remote within
|
||||
// dstDir, returning an error if the name is unsafe.
|
||||
//
|
||||
// Archive entry names are attacker controlled. A leading "./" is stripped:
|
||||
// tar archives created with relative paths (e.g. "tar -czf archive.tar.gz .")
|
||||
// use "./" prefixed entries and, without stripping, rclone would encode the
|
||||
// "." as a full-width dot character creating a spurious directory.
|
||||
//
|
||||
// Any entry with a ".." path component is then rejected to prevent a path
|
||||
// traversal ("Zip Slip") attack: path.Join collapses "..", so an entry such
|
||||
// as "../escaped.txt" joined onto "dir" would resolve to "escaped.txt" and be
|
||||
// written outside the selected destination directory. Both "/" and "\" are
|
||||
// treated as separators when looking for ".." segments: archive names should
|
||||
// use "/", but a crafted archive may use "\", which the local backend treats
|
||||
// as a path separator on Windows.
|
||||
//
|
||||
// The returned remote is empty for the archive root entry ("./"), which the
|
||||
// caller should skip.
|
||||
func destPath(nameInArchive, dstDir string) (string, error) {
|
||||
remote := strings.TrimPrefix(nameInArchive, "./")
|
||||
isSeparator := func(r rune) bool { return r == '/' || r == '\\' }
|
||||
for _, segment := range strings.FieldsFunc(remote, isSeparator) {
|
||||
if segment == ".." {
|
||||
return "", fmt.Errorf("refusing to extract archive entry %q with a %q path component", nameInArchive, "..")
|
||||
}
|
||||
}
|
||||
if remote == "" {
|
||||
return "", nil
|
||||
}
|
||||
if dstDir != "" {
|
||||
remote = path.Join(dstDir, remote)
|
||||
}
|
||||
return remote, nil
|
||||
}
|
||||
@@ -3,17 +3,19 @@
|
||||
package extract
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestStripDotSlashPrefix(t *testing.T) {
|
||||
func TestDestPath(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input string
|
||||
dstDir string
|
||||
expected string
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "strip leading dot-slash from file",
|
||||
@@ -36,12 +38,13 @@ func TestStripDotSlashPrefix(t *testing.T) {
|
||||
expected: "dir/file.txt",
|
||||
},
|
||||
{
|
||||
name: "dot-dot-slash NOT stripped (path traversal safety)",
|
||||
input: "../etc/passwd",
|
||||
expected: "../etc/passwd",
|
||||
name: "joined onto destination directory",
|
||||
input: "file.txt",
|
||||
dstDir: "safe/prefix",
|
||||
expected: "safe/prefix/file.txt",
|
||||
},
|
||||
{
|
||||
name: "dot-slash directory entry becomes empty",
|
||||
name: "archive root entry skipped",
|
||||
input: "./",
|
||||
expected: "",
|
||||
},
|
||||
@@ -50,12 +53,49 @@ func TestStripDotSlashPrefix(t *testing.T) {
|
||||
input: "././file.txt",
|
||||
expected: "./file.txt",
|
||||
},
|
||||
{
|
||||
name: "leading dot-dot rejected",
|
||||
input: "../etc/passwd",
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "leading dot-dot rejected with destination",
|
||||
input: "../escaped.txt",
|
||||
dstDir: "safe/prefix",
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "interior dot-dot rejected",
|
||||
input: "dir/../../escaped.txt",
|
||||
dstDir: "safe/prefix",
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "trailing dot-dot rejected",
|
||||
input: "dir/..",
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "backslash dot-dot rejected",
|
||||
input: `..\escaped.txt`,
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "nested backslash dot-dot rejected",
|
||||
input: `dir\..\..\escaped.txt`,
|
||||
dstDir: "safe/prefix",
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
// This mirrors the stripping logic in ArchiveExtract
|
||||
got := strings.TrimPrefix(tc.input, "./")
|
||||
got, err := destPath(tc.input, tc.dstDir)
|
||||
if tc.wantErr {
|
||||
require.Error(t, err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, tc.expected, got)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -29,8 +29,9 @@ var commandDefinition = &cobra.Command{
|
||||
Long: `If source:path is a file or directory then it copies it to a file or
|
||||
directory named dest:path.
|
||||
|
||||
This can be used to upload single files to other than their current
|
||||
name. If the source is a directory then it acts exactly like the
|
||||
This can be used to copy a single file to a destination with a name
|
||||
different from its source - for example, uploading and renaming in one
|
||||
step. If the source is a directory then it acts exactly like the
|
||||
[copy](/commands/rclone_copy/) command.
|
||||
|
||||
So
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package genautocomplete
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/rclone/rclone/cmd"
|
||||
"github.com/rclone/rclone/fs"
|
||||
@@ -13,6 +15,34 @@ func init() {
|
||||
completionDefinition.AddCommand(powershellCommandDefinition)
|
||||
}
|
||||
|
||||
// powerShellInvokeLine is the line in the Cobra generated PowerShell completion
|
||||
// script that captures rclone's output through a pipeline.
|
||||
const powerShellInvokeLine = `Invoke-Expression -OutVariable out "$RequestComp" 2>&1 | Out-Null`
|
||||
|
||||
// powerShellUTF8Fix forces the captured output to be decoded as UTF-8. When
|
||||
// PowerShell captures a child process' stdout through a pipeline it decodes the
|
||||
// bytes using [Console]::OutputEncoding, which on non-UTF-8 systems (for
|
||||
// example PowerShell 5.1 on a Windows install with an OEM code page such as
|
||||
// CP852) corrupts the UTF-8 that rclone emits. Setting the encoding to UTF-8 is
|
||||
// safe on PowerShell 7+, where it is already the default.
|
||||
const powerShellUTF8Fix = `[Console]::OutputEncoding = [System.Text.Encoding]::UTF8`
|
||||
|
||||
// patchPowerShellCompletion injects the UTF-8 output encoding fix immediately
|
||||
// before the Invoke-Expression call in the Cobra generated PowerShell
|
||||
// completion script. If the expected line is not found (for example because the
|
||||
// upstream Cobra template changed), the script is returned unmodified so we
|
||||
// never emit a corrupted completion script.
|
||||
func patchPowerShellCompletion(script string) string {
|
||||
idx := strings.Index(script, powerShellInvokeLine)
|
||||
if idx == -1 {
|
||||
return script
|
||||
}
|
||||
// Reuse the indentation of the Invoke-Expression line for the inserted line.
|
||||
lineStart := strings.LastIndex(script[:idx], "\n") + 1
|
||||
indent := script[lineStart:idx]
|
||||
return script[:lineStart] + indent + powerShellUTF8Fix + "\n" + script[lineStart:]
|
||||
}
|
||||
|
||||
var powershellCommandDefinition = &cobra.Command{
|
||||
Use: "powershell [output_file]",
|
||||
Short: `Output powershell completion script for rclone.`,
|
||||
@@ -30,15 +60,18 @@ to your powershell profile.
|
||||
If output_file is "-" or missing, then the output will be written to stdout.`,
|
||||
Run: func(command *cobra.Command, args []string) {
|
||||
cmd.CheckArgs(0, 1, command, args)
|
||||
var buf bytes.Buffer
|
||||
if err := cmd.Root.GenPowerShellCompletion(&buf); err != nil {
|
||||
fs.Fatal(nil, fmt.Sprint(err))
|
||||
}
|
||||
script := patchPowerShellCompletion(buf.String())
|
||||
if len(args) == 0 || (len(args) > 0 && args[0] == "-") {
|
||||
err := cmd.Root.GenPowerShellCompletion(os.Stdout)
|
||||
if err != nil {
|
||||
if _, err := os.Stdout.WriteString(script); err != nil {
|
||||
fs.Fatal(nil, fmt.Sprint(err))
|
||||
}
|
||||
return
|
||||
}
|
||||
err := cmd.Root.GenPowerShellCompletionFile(args[0])
|
||||
if err != nil {
|
||||
if err := os.WriteFile(args[0], []byte(script), 0644); err != nil {
|
||||
fs.Fatal(nil, fmt.Sprint(err))
|
||||
}
|
||||
},
|
||||
|
||||
@@ -2,6 +2,7 @@ package genautocomplete
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -107,3 +108,58 @@ func TestCompletionFishStdout(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, string(output))
|
||||
}
|
||||
|
||||
func TestCompletionPowershell(t *testing.T) {
|
||||
tempFile, err := os.CreateTemp("", "completion_powershell")
|
||||
assert.NoError(t, err)
|
||||
defer func() {
|
||||
_ = tempFile.Close()
|
||||
_ = os.Remove(tempFile.Name())
|
||||
}()
|
||||
|
||||
powershellCommandDefinition.Run(powershellCommandDefinition, []string{tempFile.Name()})
|
||||
|
||||
bs, err := os.ReadFile(tempFile.Name())
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, string(bs))
|
||||
// The generated script must force UTF-8 output decoding so that non-ASCII
|
||||
// remote names are not corrupted on non-UTF-8 PowerShell hosts.
|
||||
assert.Contains(t, string(bs), powerShellUTF8Fix)
|
||||
}
|
||||
|
||||
func TestCompletionPowershellStdout(t *testing.T) {
|
||||
originalStdout := os.Stdout
|
||||
tempFile, err := os.CreateTemp("", "completion_powershell")
|
||||
assert.NoError(t, err)
|
||||
defer func() {
|
||||
_ = tempFile.Close()
|
||||
_ = os.Remove(tempFile.Name())
|
||||
}()
|
||||
|
||||
os.Stdout = tempFile
|
||||
defer func() { os.Stdout = originalStdout }()
|
||||
|
||||
powershellCommandDefinition.Run(powershellCommandDefinition, []string{"-"})
|
||||
|
||||
output, err := os.ReadFile(tempFile.Name())
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, string(output))
|
||||
assert.Contains(t, string(output), powerShellUTF8Fix)
|
||||
}
|
||||
|
||||
func TestPatchPowerShellCompletion(t *testing.T) {
|
||||
t.Run("injects the encoding fix before the invoke line", func(t *testing.T) {
|
||||
script := "before\n " + powerShellInvokeLine + "\nafter\n"
|
||||
got := patchPowerShellCompletion(script)
|
||||
// The fix is inserted on its own line, sharing the indentation of the
|
||||
// invoke line, immediately before it.
|
||||
want := "before\n " + powerShellUTF8Fix + "\n " + powerShellInvokeLine + "\nafter\n"
|
||||
assert.Equal(t, want, got)
|
||||
assert.Less(t, strings.Index(got, powerShellUTF8Fix), strings.Index(got, powerShellInvokeLine))
|
||||
})
|
||||
|
||||
t.Run("leaves the script unchanged when the invoke line is absent", func(t *testing.T) {
|
||||
script := "some other script\nwithout the expected line\n"
|
||||
assert.Equal(t, script, patchPowerShellCompletion(script))
|
||||
})
|
||||
}
|
||||
+1
-1
@@ -1 +1 @@
|
||||
1.1.8
|
||||
1.1.10
|
||||
Binary file not shown.
@@ -75,6 +75,7 @@ func setAttr(node vfs.Node, attr *fuse.Attr) {
|
||||
vfs := node.VFS()
|
||||
attr.Owner.Gid = vfs.Opt.GID
|
||||
attr.Owner.Uid = vfs.Opt.UID
|
||||
attr.Ino = node.Inode()
|
||||
attr.Mode = getMode(node)
|
||||
attr.Size = Size
|
||||
attr.Nlink = 1
|
||||
|
||||
+56
-4
@@ -201,7 +201,7 @@ func (n *Node) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (ino
|
||||
// out.SetAttrTimeout(dt time.Duration)
|
||||
n.fsys.setEntryOut(vfsNode, out)
|
||||
|
||||
return n.NewInode(ctx, newNode, fusefs.StableAttr{Mode: out.Attr.Mode}), 0
|
||||
return n.NewInode(ctx, newNode, fusefs.StableAttr{Mode: out.Attr.Mode, Ino: newNode.node.Inode()}), 0
|
||||
}
|
||||
|
||||
var _ = (fusefs.NodeLookuper)((*Node)(nil))
|
||||
@@ -271,7 +271,26 @@ func (ds *dirStream) Next() (de fuse.DirEntry, errno syscall.Errno) {
|
||||
func (ds *dirStream) Close() {
|
||||
}
|
||||
|
||||
// Seekdir implements fusefs.FileSeekdirer so go-fuse can reposition the
|
||||
// directory stream. The kernel calls this both to rewind (lseek(fd, 0,
|
||||
// SEEK_SET) before a second getdents) and, for a kernel-NFS-exported mount,
|
||||
// to resume from a previously returned directory cookie: nfsd is stateless,
|
||||
// so it opens a fresh handle and seeks to the last offset on every readdir
|
||||
// continuation. Handling only offset 0 made go-fuse return ENOTSUP for those
|
||||
// resumes, so any listing spanning more than one readdir batch failed over NFS.
|
||||
//
|
||||
// dirStream is a snapshot taken at Readdir time and go-fuse assigns each entry
|
||||
// a sequential offset in Next() order (the entry yielded at index i carries
|
||||
// offset i+1), so repositioning to off means the next entry is the one at
|
||||
// index off. Values past the end clamp to EOF via HasNext.
|
||||
// See: https://github.com/hanwen/go-fuse/issues/549
|
||||
func (ds *dirStream) Seekdir(_ context.Context, off uint64) syscall.Errno {
|
||||
ds.i = int(off)
|
||||
return 0
|
||||
}
|
||||
|
||||
var _ fusefs.DirStream = (*dirStream)(nil)
|
||||
var _ fusefs.FileSeekdirer = (*dirStream)(nil)
|
||||
|
||||
// Readdir opens a stream of directory entries.
|
||||
//
|
||||
@@ -324,7 +343,7 @@ func (n *Node) Mkdir(ctx context.Context, name string, mode uint32, out *fuse.En
|
||||
}
|
||||
newNode := newNode(n.fsys, newDir)
|
||||
n.fsys.setEntryOut(newNode.node, out)
|
||||
newInode := n.NewInode(ctx, newNode, fusefs.StableAttr{Mode: out.Attr.Mode})
|
||||
newInode := n.NewInode(ctx, newNode, fusefs.StableAttr{Mode: out.Attr.Mode, Ino: newNode.node.Inode()})
|
||||
return newInode, 0
|
||||
}
|
||||
|
||||
@@ -366,12 +385,45 @@ func (n *Node) Create(ctx context.Context, name string, flags uint32, mode uint3
|
||||
n.fsys.setEntryOut(vfsNode, out)
|
||||
newNode := newNode(n.fsys, vfsNode)
|
||||
fs.Debugf(nil, "attr=%#v", out.Attr)
|
||||
newInode := n.NewInode(ctx, newNode, fusefs.StableAttr{Mode: out.Attr.Mode})
|
||||
newInode := n.NewInode(ctx, newNode, fusefs.StableAttr{Mode: out.Attr.Mode, Ino: newNode.node.Inode()})
|
||||
return newInode, fh, 0, 0
|
||||
}
|
||||
|
||||
var _ = (fusefs.NodeCreater)((*Node)(nil))
|
||||
|
||||
// Mknod creates a regular file. The kernel NFS server creates regular files
|
||||
// with MKNOD (it creates-then-opens, so vfs_create routes through fuse_create
|
||||
// which sends FUSE_MKNOD when there is no open intent), so without this an
|
||||
// NFS-exported mount fails every file creation with ENOTSUPP. Local and SMB
|
||||
// clients create via Create (FUSE_CREATE) and are unaffected. This mirrors the
|
||||
// cmd/mount (bazil) backend, which implements mknod for the same reason
|
||||
// (see #2115).
|
||||
//
|
||||
// Device/special files are not supported by the VFS, so a non-zero rdev is
|
||||
// rejected. Mknod returns no open handle (unlike Create), so the handle Create
|
||||
// opens is flushed (to instantiate the file and surface any I/O error) and
|
||||
// released before returning.
|
||||
func (n *Node) Mknod(ctx context.Context, name string, mode uint32, rdev uint32, out *fuse.EntryOut) (node *fusefs.Inode, errno syscall.Errno) {
|
||||
defer log.Trace(n, "name=%q, mode=%#o, rdev=%d", name, mode, rdev)("node=%v, errno=%v", &node, &errno)
|
||||
if rdev != 0 {
|
||||
fs.Errorf(n, "Can't create device node %q", name)
|
||||
return nil, syscall.EIO
|
||||
}
|
||||
node, fh, _, errno := n.Create(ctx, name, uint32(os.O_CREATE|os.O_WRONLY), mode, out)
|
||||
if errno != 0 {
|
||||
return nil, errno
|
||||
}
|
||||
if fh != nil {
|
||||
if errno := fh.(fusefs.FileFlusher).Flush(ctx); errno != 0 {
|
||||
return nil, errno
|
||||
}
|
||||
_ = fh.(fusefs.FileReleaser).Release(ctx)
|
||||
}
|
||||
return node, 0
|
||||
}
|
||||
|
||||
var _ = (fusefs.NodeMknoder)((*Node)(nil))
|
||||
|
||||
// Unlink should remove a child from this directory. If the
|
||||
// return status is OK, the Inode is removed as child in the
|
||||
// FS tree automatically. Default is to return EROFS.
|
||||
@@ -482,7 +534,7 @@ func (n *Node) Symlink(ctx context.Context, target, name string, out *fuse.Entry
|
||||
|
||||
n.fsys.setEntryOut(vfsNode, out)
|
||||
newNode := newNode(n.fsys, vfsNode)
|
||||
newInode := n.NewInode(ctx, newNode, fusefs.StableAttr{Mode: out.Attr.Mode})
|
||||
newInode := n.NewInode(ctx, newNode, fusefs.StableAttr{Mode: out.Attr.Mode, Ino: newNode.node.Inode()})
|
||||
|
||||
return newInode, 0
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
//go:build linux || (darwin && amd64)
|
||||
|
||||
package mount2
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestDirStreamSeekdir checks that Seekdir repositions the snapshot directory
|
||||
// stream to an arbitrary offset. A kernel-NFS-exported mount needs this for
|
||||
// readdir continuation: the stateless server opens a fresh handle and seeks to
|
||||
// the last returned cookie on every batch. Offset 0 must still reset to the
|
||||
// start (the rewind / re-read case) and offsets at or past the end must clamp
|
||||
// to EOF.
|
||||
func TestDirStreamSeekdir(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
// 3 real entries plus the synthesized "." and ".." => 5 entries total,
|
||||
// occupying internal indices 0..4 (go-fuse offsets 1..5). HasNext is true
|
||||
// while i < len(nodes)+2, i.e. i < 5.
|
||||
ds := &dirStream{nodes: make([]os.FileInfo, 3)}
|
||||
|
||||
for _, tc := range []struct {
|
||||
off uint64
|
||||
wantI int
|
||||
wantNext bool
|
||||
}{
|
||||
{0, 0, true}, // rewind to start (the re-read case)
|
||||
{2, 2, true}, // resume at the first real entry
|
||||
{4, 4, true}, // last entry
|
||||
{5, 5, false}, // exactly at end => EOF
|
||||
{99, 99, false}, // past end => clamped to EOF via HasNext
|
||||
} {
|
||||
if errno := ds.Seekdir(ctx, tc.off); errno != 0 {
|
||||
t.Fatalf("Seekdir(%d) returned errno %v, want 0", tc.off, errno)
|
||||
}
|
||||
if ds.i != tc.wantI {
|
||||
t.Errorf("Seekdir(%d): i = %d, want %d", tc.off, ds.i, tc.wantI)
|
||||
}
|
||||
if got := ds.HasNext(); got != tc.wantNext {
|
||||
t.Errorf("Seekdir(%d): HasNext() = %v, want %v", tc.off, got, tc.wantNext)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,11 @@ import (
|
||||
)
|
||||
|
||||
// OptionsInfo describes the Options in use
|
||||
var OptionsInfo = fs.Options{}.
|
||||
var OptionsInfo = fs.Options{{
|
||||
Name: "disable_zip",
|
||||
Default: false,
|
||||
Help: "Disable zip download of directories",
|
||||
}}.
|
||||
Add(libhttp.ConfigInfo).
|
||||
Add(libhttp.AuthConfigInfo).
|
||||
Add(libhttp.TemplateConfigInfo)
|
||||
@@ -45,7 +49,7 @@ type Options struct {
|
||||
Auth libhttp.AuthConfig
|
||||
HTTP libhttp.Config
|
||||
Template libhttp.TemplateConfig
|
||||
DisableZip bool
|
||||
DisableZip bool `config:"disable_zip"`
|
||||
}
|
||||
|
||||
// DefaultOpt is the default values used for Options
|
||||
@@ -74,7 +78,6 @@ func init() {
|
||||
flags.AddFlagsFromOptions(flagSet, "", OptionsInfo)
|
||||
vfsflags.AddFlags(flagSet)
|
||||
proxyflags.AddFlags(flagSet)
|
||||
flagSet.BoolVar(&Opt.DisableZip, "disable-zip", false, "Disable zip download of directories")
|
||||
cmdserve.Command.AddCommand(Command)
|
||||
cmdserve.AddRc("http", func(ctx context.Context, f fs.Fs, in rc.Params) (cmdserve.Handle, error) {
|
||||
// Read VFS Opts
|
||||
|
||||
@@ -244,6 +244,12 @@ func WithRemote(next http.Handler) http.Handler {
|
||||
urlpath = r.URL.Path
|
||||
}
|
||||
urlpath = strings.Trim(urlpath, "/")
|
||||
// Reject any non-canonical path, in particular one containing ".."
|
||||
// traversal elements.
|
||||
if urlpath != "" && path.Clean(urlpath) != urlpath {
|
||||
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
parts := matchData.FindStringSubmatch(urlpath)
|
||||
// if no data directory, layout is flat
|
||||
if parts != nil {
|
||||
|
||||
@@ -75,4 +75,16 @@ func TestResticPrivateRepositories(t *testing.T) {
|
||||
checkRequest(t, router.ServeHTTP, req, []wantFunc{wantCode(http.StatusForbidden)})
|
||||
}
|
||||
|
||||
// Reaching another user's repo via a ".." traversal in the path must be
|
||||
// rejected even though the {userID} segment matches the authenticated user
|
||||
// (GHSA-fqj9-69pf-6pjg).
|
||||
reqs = []*http.Request{
|
||||
newAuthenticatedRequest(t, "GET", "/test/../other_user/config", nil, opt.Auth.BasicUser, opt.Auth.BasicPass),
|
||||
newAuthenticatedRequest(t, "POST", "/test/../other_user/config", strings.NewReader("evil"), opt.Auth.BasicUser, opt.Auth.BasicPass),
|
||||
newAuthenticatedRequest(t, "DELETE", "/test/../other_user/config", nil, opt.Auth.BasicUser, opt.Auth.BasicPass),
|
||||
}
|
||||
for _, req := range reqs {
|
||||
checkRequest(t, router.ServeHTTP, req, []wantFunc{wantCode(http.StatusBadRequest)})
|
||||
}
|
||||
|
||||
}
|
||||
+43
-19
@@ -117,7 +117,10 @@ func (b *s3Backend) HeadObject(ctx context.Context, bucketName, objectName strin
|
||||
return nil, gofakes3.BucketNotFound(bucketName)
|
||||
}
|
||||
|
||||
fp := path.Join(bucketName, objectName)
|
||||
fp, err := bucketObjectPath(bucketName, objectName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
node, err := _vfs.Stat(fp)
|
||||
if err != nil {
|
||||
return nil, gofakes3.KeyNotFound(objectName)
|
||||
@@ -127,18 +130,24 @@ func (b *s3Backend) HeadObject(ctx context.Context, bucketName, objectName strin
|
||||
return nil, gofakes3.KeyNotFound(objectName)
|
||||
}
|
||||
|
||||
// node.DirEntry() is nil while the file is still being uploaded to the
|
||||
// backing remote (e.g. just after a multipart upload, before the VFS
|
||||
// writeback completes). In that window the file already exists in the VFS
|
||||
// and is returned by ListBucket, so serve its metadata from the node
|
||||
// rather than returning a spurious 404. getFileHashByte already falls back
|
||||
// to hashing the VFS cache when the backing object is not available yet.
|
||||
entry := node.DirEntry()
|
||||
if entry == nil {
|
||||
return nil, gofakes3.KeyNotFound(objectName)
|
||||
}
|
||||
|
||||
fobj := entry.(fs.Object)
|
||||
size := node.Size()
|
||||
hash := getFileHashByte(fobj, b.s.etagHashType)
|
||||
hash := getFileHashByte(node, b.s.etagHashType)
|
||||
|
||||
mimeType := fs.MimeTypeFromName(objectName)
|
||||
if fobj, ok := entry.(fs.Object); ok {
|
||||
mimeType = fs.MimeType(context.Background(), fobj)
|
||||
}
|
||||
|
||||
meta := map[string]string{
|
||||
"Last-Modified": formatHeaderTime(node.ModTime()),
|
||||
"Content-Type": fs.MimeType(context.Background(), fobj),
|
||||
"Content-Type": mimeType,
|
||||
}
|
||||
|
||||
if val, ok := b.meta.Load(fp); ok {
|
||||
@@ -166,7 +175,10 @@ func (b *s3Backend) GetObject(ctx context.Context, bucketName, objectName string
|
||||
return nil, gofakes3.BucketNotFound(bucketName)
|
||||
}
|
||||
|
||||
fp := path.Join(bucketName, objectName)
|
||||
fp, err := bucketObjectPath(bucketName, objectName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
node, err := _vfs.Stat(fp)
|
||||
if err != nil {
|
||||
return nil, gofakes3.KeyNotFound(objectName)
|
||||
@@ -176,16 +188,14 @@ func (b *s3Backend) GetObject(ctx context.Context, bucketName, objectName string
|
||||
return nil, gofakes3.KeyNotFound(objectName)
|
||||
}
|
||||
|
||||
// As in HeadObject, node.DirEntry() may be nil while the file is still
|
||||
// being written back to the backing remote. The data is readable from the
|
||||
// VFS cache via file.Open regardless, so serve it instead of 404ing.
|
||||
entry := node.DirEntry()
|
||||
if entry == nil {
|
||||
return nil, gofakes3.KeyNotFound(objectName)
|
||||
}
|
||||
|
||||
fobj := entry.(fs.Object)
|
||||
file := node.(*vfs.File)
|
||||
|
||||
size := node.Size()
|
||||
hash := getFileHashByte(fobj, b.s.etagHashType)
|
||||
hash := getFileHashByte(node, b.s.etagHashType)
|
||||
|
||||
in, err := file.Open(os.O_RDONLY)
|
||||
if err != nil {
|
||||
@@ -211,9 +221,14 @@ func (b *s3Backend) GetObject(ctx context.Context, bucketName, objectName string
|
||||
rdr = limitReadCloser(rdr, in.Close, rnge.Length)
|
||||
}
|
||||
|
||||
mimeType := fs.MimeTypeFromName(objectName)
|
||||
if fobj, ok := entry.(fs.Object); ok {
|
||||
mimeType = fs.MimeType(context.Background(), fobj)
|
||||
}
|
||||
|
||||
meta := map[string]string{
|
||||
"Last-Modified": formatHeaderTime(node.ModTime()),
|
||||
"Content-Type": fs.MimeType(context.Background(), fobj),
|
||||
"Content-Type": mimeType,
|
||||
}
|
||||
|
||||
if val, ok := b.meta.Load(fp); ok {
|
||||
@@ -301,7 +316,10 @@ func (b *s3Backend) PutObject(
|
||||
return result, gofakes3.BucketNotFound(bucketName)
|
||||
}
|
||||
|
||||
fp := path.Join(bucketName, objectName)
|
||||
fp, err := bucketObjectPath(bucketName, objectName)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
objectDir := path.Dir(fp)
|
||||
// _, err = db.fs.Stat(objectDir)
|
||||
// if err == vfs.ENOENT {
|
||||
@@ -394,7 +412,10 @@ func (b *s3Backend) deleteObject(ctx context.Context, bucketName, objectName str
|
||||
return gofakes3.BucketNotFound(bucketName)
|
||||
}
|
||||
|
||||
fp := path.Join(bucketName, objectName)
|
||||
fp, err := bucketObjectPath(bucketName, objectName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// S3 does not report an error when attempting to delete a key that does not exist, so
|
||||
// we need to skip IsNotExist errors.
|
||||
if err := _vfs.Remove(fp); err != nil && !os.IsNotExist(err) {
|
||||
@@ -465,7 +486,10 @@ func (b *s3Backend) CopyObject(ctx context.Context, srcBucket, srcKey, dstBucket
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
fp := path.Join(srcBucket, srcKey)
|
||||
fp, err := bucketObjectPath(srcBucket, srcKey)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
if srcBucket == dstBucket && srcKey == dstKey {
|
||||
b.meta.Store(fp, meta)
|
||||
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
package s3
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/rclone/gofakes3"
|
||||
_ "github.com/rclone/rclone/backend/local"
|
||||
"github.com/rclone/rclone/cmd/serve/proxy"
|
||||
"github.com/rclone/rclone/fs"
|
||||
"github.com/rclone/rclone/fstest"
|
||||
"github.com/rclone/rclone/vfs/vfscommon"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// newTestBackend serves a root directory containing a bucket directory, an
|
||||
// object inside that bucket and a root-level file that is not part of any
|
||||
// bucket. It returns the backend and the serve root path.
|
||||
func newTestBackend(t *testing.T) (*s3Backend, string) {
|
||||
fstest.Initialise()
|
||||
ctx := context.Background()
|
||||
root := t.TempDir()
|
||||
require.NoError(t, os.MkdirAll(filepath.Join(root, "bucket"), 0777))
|
||||
require.NoError(t, os.WriteFile(filepath.Join(root, "root-secret.txt"), []byte(rootSecret), 0666))
|
||||
require.NoError(t, os.WriteFile(filepath.Join(root, "bucket", "object.txt"), []byte("normal object"), 0666))
|
||||
|
||||
f, err := fs.NewFs(ctx, root)
|
||||
require.NoError(t, err)
|
||||
|
||||
opt := Opt
|
||||
opt.HTTP.ListenAddr = []string{endpoint}
|
||||
w, err := newServer(ctx, f, &opt, &vfscommon.Opt, &proxy.Opt)
|
||||
require.NoError(t, err)
|
||||
|
||||
return newBackend(w).(*s3Backend), root
|
||||
}
|
||||
|
||||
const rootSecret = "ROOT_LEVEL_SECRET_MARKER"
|
||||
|
||||
// TestPathTraversal checks that dot-dot segments in an object key cannot
|
||||
// escape the bucket namespace to read, overwrite or create files outside the
|
||||
// selected bucket.
|
||||
func TestPathTraversal(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
t.Run("Get", func(t *testing.T) {
|
||||
b, _ := newTestBackend(t)
|
||||
_, err := b.GetObject(ctx, "bucket", "../root-secret.txt", nil)
|
||||
assert.Error(t, err, "GET with dot-dot key must not read the root-level file")
|
||||
})
|
||||
|
||||
t.Run("Head", func(t *testing.T) {
|
||||
b, _ := newTestBackend(t)
|
||||
_, err := b.HeadObject(ctx, "bucket", "../root-secret.txt")
|
||||
assert.Error(t, err, "HEAD with dot-dot key must not find the root-level file")
|
||||
})
|
||||
|
||||
t.Run("Put", func(t *testing.T) {
|
||||
b, root := newTestBackend(t)
|
||||
const payload = "OVERWRITTEN_BY_DOTDOT"
|
||||
_, err := b.PutObject(ctx, "bucket", "../root-secret.txt", map[string]string{}, strings.NewReader(payload), int64(len(payload)))
|
||||
assert.Error(t, err, "PUT with dot-dot key must not overwrite the root-level file")
|
||||
got, readErr := os.ReadFile(filepath.Join(root, "root-secret.txt"))
|
||||
require.NoError(t, readErr)
|
||||
assert.Equal(t, rootSecret, string(got), "root-level file must be unchanged")
|
||||
})
|
||||
|
||||
// path.Dir of the joined path can re-introduce a traversal, so check that a
|
||||
// rejected PUT does not create directories outside the bucket as a side
|
||||
// effect of making the object's parent directory.
|
||||
t.Run("PutNoSideEffectDir", func(t *testing.T) {
|
||||
b, root := newTestBackend(t)
|
||||
_, err := b.PutObject(ctx, "bucket", "../sneaky-dir/f.txt", map[string]string{}, strings.NewReader("x"), 1)
|
||||
assert.Error(t, err, "PUT with dot-dot key must be rejected")
|
||||
_, statErr := os.Stat(filepath.Join(root, "sneaky-dir"))
|
||||
assert.True(t, os.IsNotExist(statErr), "no directory must be created outside the bucket")
|
||||
})
|
||||
|
||||
// A legitimate object inside the bucket must still be readable.
|
||||
t.Run("LegitimateObject", func(t *testing.T) {
|
||||
b, _ := newTestBackend(t)
|
||||
obj, err := b.GetObject(ctx, "bucket", "object.txt", nil)
|
||||
require.NoError(t, err)
|
||||
defer func() { _ = obj.Contents.Close() }()
|
||||
contents, err := io.ReadAll(obj.Contents)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "normal object", string(contents))
|
||||
})
|
||||
|
||||
// A legitimate nested object must still be writable, creating its parent
|
||||
// directory inside the bucket.
|
||||
t.Run("LegitimateNestedPut", func(t *testing.T) {
|
||||
b, root := newTestBackend(t)
|
||||
const payload = "nested"
|
||||
_, err := b.PutObject(ctx, "bucket", "sub/dir/file.txt", map[string]string{}, strings.NewReader(payload), int64(len(payload)))
|
||||
require.NoError(t, err)
|
||||
got, readErr := os.ReadFile(filepath.Join(root, "bucket", "sub", "dir", "file.txt"))
|
||||
require.NoError(t, readErr)
|
||||
assert.Equal(t, payload, string(got))
|
||||
})
|
||||
}
|
||||
|
||||
// TestBucketObjectPath unit-tests the bucket/key join used by serve s3. Object
|
||||
// keys are opaque, so non-canonical keys (containing "..", ".", "//", or
|
||||
// leading/trailing slashes) are rejected rather than normalised.
|
||||
func TestBucketObjectPath(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
bucket, key string
|
||||
want string
|
||||
wantErr bool
|
||||
}{
|
||||
{"bucket", "object.txt", "bucket/object.txt", false},
|
||||
{"bucket", "a/b/c.txt", "bucket/a/b/c.txt", false},
|
||||
{"bucket", "a/../b.txt", "", true}, // distinct from b.txt, not normalised
|
||||
{"bucket", "a/./b.txt", "", true},
|
||||
{"bucket", "a//b.txt", "", true},
|
||||
{"bucket", "/leading", "", true},
|
||||
{"bucket", "trailing/", "", true},
|
||||
{"bucket", "", "", true},
|
||||
{"bucket", "../root-secret.txt", "", true},
|
||||
{"bucket", "../../etc/passwd", "", true},
|
||||
{"bucket", "../otherbucket/x", "", true},
|
||||
{"bucket", "a/../../escape", "", true},
|
||||
{"bucket", "..", "", true},
|
||||
} {
|
||||
got, err := bucketObjectPath(test.bucket, test.key)
|
||||
if test.wantErr {
|
||||
assert.Error(t, err, "bucket=%q key=%q", test.bucket, test.key)
|
||||
assert.True(t, gofakes3.HasErrorCode(err, gofakes3.ErrInvalidArgument), "want 400 InvalidArgument for key=%q, got %v", test.key, err)
|
||||
} else {
|
||||
require.NoError(t, err, "bucket=%q key=%q", test.bucket, test.key)
|
||||
assert.Equal(t, test.want, got, "bucket=%q key=%q", test.bucket, test.key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestBucketDirPath unit-tests the directory-prefix join: the empty prefix
|
||||
// addresses the bucket root and a trailing slash is ignored, but traversal and
|
||||
// other non-canonical prefixes are still rejected.
|
||||
func TestBucketDirPath(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
bucket, dir string
|
||||
want string
|
||||
wantErr bool
|
||||
}{
|
||||
{"bucket", "", "bucket", false}, // empty prefix addresses the bucket root
|
||||
{"bucket", "dir", "bucket/dir", false},
|
||||
{"bucket", "dir/", "", true}, // trailing slash not normalised away
|
||||
{"bucket", "a/b", "bucket/a/b", false},
|
||||
{"bucket", "../x", "", true},
|
||||
{"bucket", "a//b", "", true},
|
||||
{"bucket", "..", "", true},
|
||||
} {
|
||||
got, err := bucketDirPath(test.bucket, test.dir)
|
||||
if test.wantErr {
|
||||
assert.Error(t, err, "bucket=%q dir=%q", test.bucket, test.dir)
|
||||
} else {
|
||||
require.NoError(t, err, "bucket=%q dir=%q", test.bucket, test.dir)
|
||||
assert.Equal(t, test.want, got, "bucket=%q dir=%q", test.bucket, test.dir)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,12 @@ import (
|
||||
"github.com/rclone/rclone/vfs"
|
||||
)
|
||||
|
||||
func (b *s3Backend) entryListR(_vfs *vfs.VFS, bucket, fdPath, name string, addPrefix bool, response *gofakes3.ObjectList) error {
|
||||
fp := path.Join(bucket, fdPath)
|
||||
func (b *s3Backend) entryListR(_vfs *vfs.VFS, bucketName, fdPath, name string, addPrefix bool, response *gofakes3.ObjectList) error {
|
||||
fp, err := bucketDirPath(bucketName, fdPath)
|
||||
if err != nil {
|
||||
// A listing prefix that can't be represented as a path matches nothing.
|
||||
return gofakes3.ErrNoSuchKey
|
||||
}
|
||||
|
||||
dirEntries, err := getDirEntries(fp, _vfs)
|
||||
if err != nil {
|
||||
@@ -32,7 +36,7 @@ func (b *s3Backend) entryListR(_vfs *vfs.VFS, bucket, fdPath, name string, addPr
|
||||
response.AddPrefix(prefixWithTrailingSlash)
|
||||
continue
|
||||
}
|
||||
err := b.entryListR(_vfs, bucket, path.Join(fdPath, object), "", false, response)
|
||||
err := b.entryListR(_vfs, bucketName, path.Join(fdPath, object), "", false, response)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -131,6 +131,17 @@ Versioning is not currently supported.
|
||||
Metadata will only be saved in memory other than the rclone `mtime`
|
||||
metadata which will be set as the modification time of the file.
|
||||
|
||||
### Object names
|
||||
|
||||
`serve s3` stores objects as files in the backend, so object keys are
|
||||
mapped to file paths rather than treated as the opaque strings AWS S3
|
||||
allows. Keys must be in canonical path form: keys that contain `..` or
|
||||
`.` path segments, repeated slashes (`//`), or a leading or trailing
|
||||
slash are rejected with a `400 Bad Request` (`InvalidArgument`)
|
||||
instead of being normalised, since normalising them could alias two
|
||||
distinct keys to the same file or resolve a key outside its bucket.
|
||||
This matches the behaviour of other S3 servers such as MinIO.
|
||||
|
||||
### Supported operations
|
||||
|
||||
`serve s3` currently supports the following operations.
|
||||
|
||||
@@ -86,6 +86,50 @@ func getFileHash(node any, hashType hash.Type) string {
|
||||
return hash
|
||||
}
|
||||
|
||||
// canonicalKey reports whether key is a non-empty path in canonical form: it
|
||||
// is equal to the path it cleans to, so it has no ".", ".." or empty
|
||||
// (repeated, leading or trailing slash) segments.
|
||||
//
|
||||
// The key is anchored with a leading "/" before cleaning so that a leading
|
||||
// ".." cannot silently escape upwards and still compare equal.
|
||||
func canonicalKey(key string) bool {
|
||||
return key != "" && "/"+key == path.Clean("/"+key)
|
||||
}
|
||||
|
||||
// errInvalidObjectName is returned for object keys that cannot be represented
|
||||
// as a backend path, for example because they contain "..", "." or "//"
|
||||
// segments. Like MinIO, this is reported as a 400 Bad Request rather than
|
||||
// silently resolving the key to a different object (or one outside the
|
||||
// bucket).
|
||||
func errInvalidObjectName(key string) error {
|
||||
return gofakes3.ErrorMessagef(gofakes3.ErrInvalidArgument, "Object name contains unsupported characters: %q", key)
|
||||
}
|
||||
|
||||
// bucketObjectPath joins the bucket name and object key into a backend path.
|
||||
//
|
||||
// S3 object keys are opaque, so rclone treats "dir/../file" and "file" as
|
||||
// distinct keys and refuses to normalise one into the other. Keys that are
|
||||
// not in canonical form (or that would escape the bucket) are rejected with
|
||||
// errInvalidObjectName rather than resolved.
|
||||
func bucketObjectPath(bucketName, objectName string) (string, error) {
|
||||
if !canonicalKey(objectName) {
|
||||
return "", errInvalidObjectName(objectName)
|
||||
}
|
||||
return path.Join(bucketName, objectName), nil
|
||||
}
|
||||
|
||||
// bucketDirPath joins the bucket name and a directory path (a listing prefix)
|
||||
// into a backend path. It is like bucketObjectPath except that the empty path
|
||||
// is allowed and addresses the bucket root. Every other non-canonical path,
|
||||
// including one with a trailing slash, is rejected - it is not normalised, so
|
||||
// "dir" and "dir/" are not treated as the same directory.
|
||||
func bucketDirPath(bucketName, dirName string) (string, error) {
|
||||
if dirName == "" {
|
||||
return bucketName, nil
|
||||
}
|
||||
return bucketObjectPath(bucketName, dirName)
|
||||
}
|
||||
|
||||
func prefixParser(p *gofakes3.Prefix) (path, remaining string) {
|
||||
idx := strings.LastIndexByte(p.Prefix, '/')
|
||||
if idx < 0 {
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
// Regression test for #8188: HEAD/GET during the VFS writeback window.
|
||||
|
||||
package s3
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/url"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
"github.com/rclone/rclone/cmd/serve/proxy"
|
||||
"github.com/rclone/rclone/fs"
|
||||
"github.com/rclone/rclone/fstest"
|
||||
"github.com/rclone/rclone/lib/random"
|
||||
"github.com/rclone/rclone/vfs/vfscommon"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// TestHeadGetDuringWriteback uploads an object and immediately HEADs and GETs it
|
||||
// while it is still in the VFS write-back window — i.e. before the dirty file is
|
||||
// flushed to the backing remote, so node.DirEntry() is still nil. Previously
|
||||
// HeadObject/GetObject returned a spurious 404 (KeyNotFound) in that window even
|
||||
// though ListBucket already reported the object. A long --vfs-write-back keeps
|
||||
// the window open deterministically. Regression test for #8188.
|
||||
func TestHeadGetDuringWriteback(t *testing.T) {
|
||||
fstest.Initialise()
|
||||
ctx := context.Background()
|
||||
f, err := fs.NewFs(ctx, t.TempDir())
|
||||
require.NoError(t, err)
|
||||
const bucket = "test"
|
||||
require.NoError(t, f.Mkdir(ctx, bucket))
|
||||
|
||||
keyid := random.String(16)
|
||||
keysec := random.String(16)
|
||||
opt := Opt
|
||||
opt.AuthKey = []string{fmt.Sprintf("%s,%s", keyid, keysec)}
|
||||
opt.HTTP.ListenAddr = []string{endpoint}
|
||||
|
||||
// Cache writes and hold the writeback so DirEntry() stays nil for the HEAD/GET.
|
||||
vfsOpt := vfscommon.Opt
|
||||
vfsOpt.CacheMode = vfscommon.CacheModeWrites
|
||||
vfsOpt.WriteBack = fs.Duration(2 * time.Minute)
|
||||
|
||||
w, err := newServer(ctx, f, &opt, &vfsOpt, &proxy.Opt)
|
||||
require.NoError(t, err)
|
||||
go func() { _ = w.Serve() }()
|
||||
t.Cleanup(func() { _ = w.Shutdown() })
|
||||
|
||||
u, err := url.Parse(w.server.URLs()[0])
|
||||
require.NoError(t, err)
|
||||
client, err := minio.New(u.Host, &minio.Options{
|
||||
Creds: credentials.NewStaticV4(keyid, keysec, ""),
|
||||
Secure: false,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
const object = "writeback.txt"
|
||||
want := []byte("hello writeback window")
|
||||
_, err = client.PutObject(ctx, bucket, object, bytes.NewReader(want), int64(len(want)), minio.PutObjectOptions{})
|
||||
require.NoError(t, err)
|
||||
|
||||
// HEAD must not 404 while the object is still being written back.
|
||||
info, err := client.StatObject(ctx, bucket, object, minio.StatObjectOptions{})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, int64(len(want)), info.Size)
|
||||
|
||||
// GET must return the body from the VFS cache, not 404.
|
||||
rc, err := client.GetObject(ctx, bucket, object, minio.GetObjectOptions{})
|
||||
require.NoError(t, err)
|
||||
got, err := io.ReadAll(rc)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, rc.Close())
|
||||
assert.Equal(t, want, got)
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
@@ -391,6 +391,12 @@ func (w *WebDAV) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
w.serveDir(rw, r, remote)
|
||||
return
|
||||
}
|
||||
// Work around bug in x/net/webdav which handles Overwrite incorrectly
|
||||
// See: https://github.com/golang/go/issues/66059
|
||||
// Remove when the above bug is fixed.
|
||||
if (r.Method == "COPY" || r.Method == "MOVE") && r.Header.Get("Overwrite") == "" {
|
||||
r.Header.Set("Overwrite", "T")
|
||||
}
|
||||
// Add URL Prefix back to path since webdavhandler needs to
|
||||
// return absolute references.
|
||||
r.URL.Path = w.opt.HTTP.BaseURL + r.URL.Path
|
||||
|
||||
@@ -271,3 +271,89 @@ func TestRc(t *testing.T) {
|
||||
"vfs_cache_mode": "off",
|
||||
})
|
||||
}
|
||||
|
||||
// startWritableServer starts a webdav server backed by a fresh temp
|
||||
// directory and returns the server URL. It is used by the Overwrite tests
|
||||
// which need to exercise mutating verbs such as MKCOL and MOVE.
|
||||
func startWritableServer(t *testing.T) string {
|
||||
t.Helper()
|
||||
|
||||
f, err := fs.NewFs(context.Background(), t.TempDir())
|
||||
require.NoError(t, err)
|
||||
|
||||
opt := Opt
|
||||
opt.HTTP.ListenAddr = []string{testBindAddress}
|
||||
|
||||
w, err := newWebDAV(context.Background(), f, &opt, &vfscommon.Opt, &proxy.Opt)
|
||||
require.NoError(t, err)
|
||||
go func() {
|
||||
require.NoError(t, w.Serve())
|
||||
}()
|
||||
t.Cleanup(func() {
|
||||
assert.NoError(t, w.Shutdown())
|
||||
})
|
||||
|
||||
return w.server.URLs()[0]
|
||||
}
|
||||
|
||||
func mkcol(t *testing.T, baseURL, path string) {
|
||||
t.Helper()
|
||||
req, err := http.NewRequest("MKCOL", baseURL+path, nil)
|
||||
require.NoError(t, err)
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
require.NoError(t, err)
|
||||
_ = resp.Body.Close()
|
||||
require.Equal(t, http.StatusCreated, resp.StatusCode, "MKCOL %s", path)
|
||||
}
|
||||
|
||||
// TestMoveDefaultsToOverwrite is a regression test for
|
||||
// https://github.com/rclone/rclone/issues/9496
|
||||
//
|
||||
// RFC 4918 section 10.6 requires that when the Overwrite header is omitted
|
||||
// from a COPY or MOVE request, the resource MUST behave as if Overwrite: T
|
||||
// had been sent. The upstream golang.org/x/net/webdav library mis-handles
|
||||
// the MOVE case (see https://github.com/golang/go/issues/66059), so rclone
|
||||
// normalises the header before delegating so the default matches the RFC.
|
||||
func TestMoveDefaultsToOverwrite(t *testing.T) {
|
||||
testURL := startWritableServer(t)
|
||||
|
||||
mkcol(t, testURL, "dir1")
|
||||
mkcol(t, testURL, "dir2")
|
||||
|
||||
// MOVE without Overwrite header: per RFC 4918 the default is T, so the
|
||||
// existing destination must be replaced and the server must return 2xx.
|
||||
req, err := http.NewRequest("MOVE", testURL+"dir2", nil)
|
||||
require.NoError(t, err)
|
||||
req.Header.Set("Destination", testURL+"dir1")
|
||||
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
require.NoError(t, err)
|
||||
defer func() { _ = resp.Body.Close() }()
|
||||
|
||||
assert.NotEqual(t, http.StatusPreconditionFailed, resp.StatusCode,
|
||||
"MOVE without Overwrite header must not return 412; RFC 4918 default is Overwrite: T")
|
||||
assert.True(t, resp.StatusCode >= 200 && resp.StatusCode < 300,
|
||||
"expected 2xx, got %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
// TestMoveOverwriteFalseStillRejects ensures the rclone normalisation only
|
||||
// fills in a missing Overwrite header and never overrides an explicit
|
||||
// Overwrite: F sent by the client.
|
||||
func TestMoveOverwriteFalseStillRejects(t *testing.T) {
|
||||
testURL := startWritableServer(t)
|
||||
|
||||
mkcol(t, testURL, "dir1")
|
||||
mkcol(t, testURL, "dir2")
|
||||
|
||||
req, err := http.NewRequest("MOVE", testURL+"dir2", nil)
|
||||
require.NoError(t, err)
|
||||
req.Header.Set("Destination", testURL+"dir1")
|
||||
req.Header.Set("Overwrite", "F")
|
||||
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
require.NoError(t, err)
|
||||
defer func() { _ = resp.Body.Close() }()
|
||||
|
||||
assert.Equal(t, http.StatusPreconditionFailed, resp.StatusCode,
|
||||
"MOVE with explicit Overwrite: F must still return 412 when destination exists")
|
||||
}
|
||||
+28
-11
@@ -477,9 +477,9 @@ their checksums would change from run to run (due to small variances in the
|
||||
internals of the generated export file.) Therefore, bisync automatically skips
|
||||
`--download-hash` for files with a size less than 0.
|
||||
|
||||
See also: [`Hasher`](https://rclone.org/hasher/) backend,
|
||||
[`cryptcheck`](/commands/rclone_cryptcheck/) command, [`rclone check
|
||||
--download`](/commands/rclone_check/) option,
|
||||
See also: [`Hasher`](/hasher/) backend,
|
||||
[`cryptcheck`](/commands/rclone_cryptcheck/) command,
|
||||
[`rclone check --download`](/commands/rclone_check/) option,
|
||||
[`md5sum`](/commands/rclone_md5sum/) command
|
||||
|
||||
### --max-delete
|
||||
@@ -1053,16 +1053,28 @@ 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)
|
||||
- `TestGoogleCloudStorage,directory_markers` (`googlecloudstorage`)
|
||||
- [`TestBisyncRemoteLocal/all_changed`](https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage,directory_markers-1.txt)
|
||||
- [`TestBisyncRemoteLocal/backupdir`](https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage,directory_markers-1.txt)
|
||||
- [`TestBisyncRemoteLocal/basic`](https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage,directory_markers-1.txt)
|
||||
- [`TestBisyncRemoteLocal/changes`](https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage,directory_markers-1.txt)
|
||||
- [`TestBisyncRemoteLocal/check_access`](https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage,directory_markers-1.txt)
|
||||
- [79 more](https://pub.rclone.org/integration-tests/current/)
|
||||
- `TestGoogleCloudStorage` (`googlecloudstorage`)
|
||||
- [`TestBisyncRemoteLocal/all_changed`](https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage-1.txt)
|
||||
- [`TestBisyncRemoteLocal/backupdir`](https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage-1.txt)
|
||||
- [`TestBisyncRemoteLocal/basic`](https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage-1.txt)
|
||||
- [`TestBisyncRemoteLocal/changes`](https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage-1.txt)
|
||||
- [`TestBisyncRemoteLocal/check_access`](https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage-1.txt)
|
||||
- [79 more](https://pub.rclone.org/integration-tests/current/)
|
||||
- `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/)
|
||||
- Updated: 2026-07-08-010014
|
||||
<!--- end list_failures - DO NOT EDIT THIS SECTION - use make commanddocs --->
|
||||
|
||||
The following backends either have not been tested recently or have known issues
|
||||
@@ -1127,8 +1139,8 @@ a mechanism to mark files as needing to be internally rechecked next time, for
|
||||
added safety. It should therefore no longer be necessary to sync only at quiet
|
||||
times -- however, note that an error can still occur if a file happens to change
|
||||
at the exact moment it's being read/written by bisync (same as would happen in
|
||||
`rclone sync`.) (See also: [`--ignore-checksum`](https://rclone.org/docs/#ignore-checksum),
|
||||
[`--local-no-check-updated`](https://rclone.org/local/#local-no-check-updated))
|
||||
`rclone sync`.) (See also: [`--ignore-checksum`](/docs/#ignore-checksum),
|
||||
[`--local-no-check-updated`](/local/#local-no-check-updated))
|
||||
|
||||
### Empty directories
|
||||
|
||||
@@ -1168,6 +1180,11 @@ is to rename it to the same name on both sides. (As of `rclone v1.64`,
|
||||
a `--resync` is no longer required after doing so, as bisync will automatically
|
||||
detect that Path1 and Path2 are in agreement.)
|
||||
|
||||
Note that although the flag --track-renames ensures that renamed/moved files won't
|
||||
be deleted and uploaded again, they are still counted as deleted files for purposes
|
||||
of the --max-delete flag (as this check happens before the rename detection
|
||||
operation). See [this issue](https://github.com/rclone/rclone/issues/8685).
|
||||
|
||||
### `--fast-list` used by default
|
||||
|
||||
Unlike most other rclone commands, bisync uses [`--fast-list`](/docs/#fast-list)
|
||||
@@ -1501,7 +1518,7 @@ and in most cases it's probably not what you want!
|
||||
|
||||
To bisync Google Docs as URL shortcut links (in a manner similar to "Drive for
|
||||
Desktop"), use: `--drive-export-formats url` (or
|
||||
[alternatives](https://rclone.org/drive/#exportformats:~:text=available%20Google%20Documents.-,Extension,macOS,-Standard%20options).)
|
||||
[alternatives](/drive/#exportformats:~:text=available%20Google%20Documents.-,Extension,macOS,-Standard%20options).)
|
||||
|
||||
Note that these link files cannot be edited on the non-drive side -- you will
|
||||
get errors if you try to sync an edited link file back to drive. They CAN be
|
||||
|
||||
@@ -6,6 +6,100 @@ description: "Rclone Changelog"
|
||||
|
||||
# Changelog
|
||||
|
||||
## v1.74.4 - 2026-07-08
|
||||
|
||||
[See commits](https://github.com/rclone/rclone/compare/v1.74.3...v1.74.4)
|
||||
|
||||
- Bug Fixes
|
||||
- accounting
|
||||
- Fix goroutine leak in ResetCounters (Nick Craig-Wood)
|
||||
- Fix goroutine leak in NewStatsGroup for zero-transfer rc jobs (Sanjays2402)
|
||||
- archive extract: Fix path traversal letting archives escape the destination CVE-2026-59732 (Nick Craig-Wood)
|
||||
- build
|
||||
- Fix multiple CVEs by upgrading to go1.26.5 (Nick Craig-Wood)
|
||||
- CVE-2026-39822: os: Root escape via symlink plus trailing slash
|
||||
- CVE-2026-42505: crypto/tls: Encrypted Client Hello privacy leak
|
||||
- Update golang.org/x/image to v0.43.0 to fix image decoding vulnerabilities (Nick Craig-Wood)
|
||||
- CVE-2026-46604: panic decoding a TIFF image with an out-of-bounds strip offset
|
||||
- CVE-2026-46602: unbounded memory use from lack of a limit on TIFF tile sizes
|
||||
- CVE-2026-46601: panic on a WEBP VP8 alpha channel size mismatch
|
||||
- CVE-2026-33813: panic decoding a large WEBP image on 32-bit platforms
|
||||
- cmd/mount2
|
||||
- Fix NFS file creation by implementing Mknod (Sandy Luppino)
|
||||
- Fix ESTALE over NFS by reporting stable inode numbers (Sandy Luppino)
|
||||
- Fix NFS directory listings by supporting non-zero Seekdir offsets (Sandy Luppino)
|
||||
- completion: Fix powershell completion corrupting non-ASCII names (Yash Anil)
|
||||
- doc fixes (Bryan Stenson, Castronaut, Filippo, Gaurav, happysnaker, Jan-Philipp Reßler, Nick Craig-Wood, user77)
|
||||
- filter: Fix `--files-from` copy stopping at the first unreadable file (Nick Craig-Wood)
|
||||
- fs
|
||||
- Fix command line flag being ignored when set to its default value (Nick Craig-Wood)
|
||||
- Fix negative offset when a suffix Range request exceeds object size (Amit Mishra)
|
||||
- gui: Update embedded release to 1.1.10 (Nick Craig-Wood)
|
||||
- ncdu: Fix duplicated keystrokes on Windows by pinning tcell to v2.9.0 (Nick Craig-Wood)
|
||||
- serve restic: Fix `--private-repos` isolation bypass CVE-2026-59733 (Nick Craig-Wood)
|
||||
- serve s3
|
||||
- Fix spurious 404 on HEAD/GET during VFS writeback (max)
|
||||
- Fix path traversal letting clients see files in the root GHSA-8v25-v8p6-qf7v (Nick Craig-Wood)
|
||||
- serve webdav: Fix MOVE overwrite failing without Overwrite header (Sanjay Santhanam)
|
||||
- serve/http: Fix `--disable-zip` so it works over rc (Nick Craig-Wood)
|
||||
- VFS
|
||||
- Fix hang reopening a file during the handle-caching grace period (Nick Craig-Wood)
|
||||
- Local
|
||||
- Stop `--links` symlinks escaping the destination directory CVE-2026-54572 (Nick Craig-Wood)
|
||||
- Don't restore setuid/setgid/sticky bits from metadata by default GHSA-945v-v9p3-v5xw (Nick Craig-Wood)
|
||||
- Drive
|
||||
- Warn when non-exportable Google documents are skipped (Nick Craig-Wood)
|
||||
- Fix stray %!(EXTRA) in unexportable google document log message (Nick Craig-Wood)
|
||||
- Warn when using rclone's shared client_id (Nick Craig-Wood)
|
||||
- Filelu
|
||||
- Fix recursive listing path handling and file filtering (kingston125)
|
||||
- Googlephotos
|
||||
- Warn when using rclone's shared client_id (Nick Craig-Wood)
|
||||
- Mega
|
||||
- Wait for server events after upload, delete and move (Nick Craig-Wood)
|
||||
- Fix hard deleted files reappearing in listings (Nick Craig-Wood)
|
||||
- S3
|
||||
- Remove session token on cross-host redirects (IceLocke)
|
||||
- Strip STS security token on same-host HTTPS->HTTP redirect GHSA-cf44-9pgv-m4xc (Nick Craig-Wood)
|
||||
- Fix error mapping in GetObject to match HeadObject (lewoberst)
|
||||
- Correct documented `copy_cutoff` minimum to 1 byte (max)
|
||||
- Fix mounting a prefix failing with 403 when HEAD is not permitted (Nick Craig-Wood)
|
||||
- Smb
|
||||
- Fix for IBM iSeries and signature verification (dithwick)
|
||||
- WebDAV
|
||||
- Fix mixed property statuses in multi-status responses (nako-ruru)
|
||||
|
||||
## 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)
|
||||
|
||||
@@ -558,8 +558,10 @@ rclone [flags]
|
||||
--local-case-sensitive Force the filesystem to report itself as case sensitive
|
||||
--local-description string Description of the remote
|
||||
--local-encoding Encoding The encoding for the backend (default Slash,Dot)
|
||||
--local-fatal-if-no-space Make out-of-space errors fatal during transfers
|
||||
--local-hashes CommaSepList Comma separated list of supported checksum types
|
||||
--local-links Translate symlinks to/from regular files with a '.rclonelink' extension for the local backend
|
||||
--local-metadata-restore-special-bits Restore the setuid, setgid and sticky bits from metadata
|
||||
--local-no-check-updated Don't check to see if the files change during upload
|
||||
--local-no-clone Disable reflink cloning for server-side copies
|
||||
--local-no-preallocate Disable preallocation of disk space for transferred files
|
||||
@@ -1094,7 +1096,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.4")
|
||||
-v, --verbose count Print lots more stuff (repeat for more)
|
||||
-V, --version Print the version number
|
||||
--webdav-auth-redirect Preserve authentication on redirect
|
||||
|
||||
@@ -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!-20260708
|
||||
```
|
||||
|
||||
```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-07-08 0504PM
|
||||
```
|
||||
|
||||
```console
|
||||
|
||||
@@ -13,8 +13,9 @@ Copy files from source to dest, skipping identical files.
|
||||
If source:path is a file or directory then it copies it to a file or
|
||||
directory named dest:path.
|
||||
|
||||
This can be used to upload single files to other than their current
|
||||
name. If the source is a directory then it acts exactly like the
|
||||
This can be used to copy a single file to a destination with a name
|
||||
different from its source - for example, uploading and renaming in one
|
||||
step. If the source is a directory then it acts exactly like the
|
||||
[copy](/commands/rclone_copy/) command.
|
||||
|
||||
So
|
||||
|
||||
@@ -144,6 +144,17 @@ Versioning is not currently supported.
|
||||
Metadata will only be saved in memory other than the rclone `mtime`
|
||||
metadata which will be set as the modification time of the file.
|
||||
|
||||
## Object names
|
||||
|
||||
`serve s3` stores objects as files in the backend, so object keys are
|
||||
mapped to file paths rather than treated as the opaque strings AWS S3
|
||||
allows. Keys must be in canonical path form: keys that contain `..` or
|
||||
`.` path segments, repeated slashes (`//`), or a leading or trailing
|
||||
slash are rejected with a `400 Bad Request` (`InvalidArgument`)
|
||||
instead of being normalised, since normalising them could alias two
|
||||
distinct keys to the same file or resolve a key outside its bucket.
|
||||
This matches the behaviour of other S3 servers such as MinIO.
|
||||
|
||||
## Supported operations
|
||||
|
||||
`serve s3` currently supports the following operations.
|
||||
|
||||
@@ -787,9 +787,9 @@ This uses a 32 byte (256 bit key) key derived from the user password.
|
||||
1 MiB (1048576 bytes) file will encrypt to
|
||||
|
||||
- 32 bytes header
|
||||
- 16 chunks of 65568 bytes
|
||||
- 16 chunks of 65552 bytes
|
||||
|
||||
1049120 bytes total (a 0.05% overhead). This is the overhead for big
|
||||
1048864 bytes total (a 0.03% overhead). This is the overhead for big
|
||||
files.
|
||||
|
||||
### Name encryption
|
||||
|
||||
@@ -1824,7 +1824,7 @@ warnings and significant events.
|
||||
|
||||
See also the [logging](#logging) section.
|
||||
|
||||
### --windows-event-log LogLevel
|
||||
### --windows-event-log-level LogLevel
|
||||
|
||||
If this is configured (the default is `OFF`) then logs of this level
|
||||
and above will be logged to the Windows event log in **addition** to
|
||||
@@ -1840,15 +1840,15 @@ and `Error`. If enabled we map rclone levels like this.
|
||||
|
||||
Rclone will declare its log source as "rclone" if it is has enough
|
||||
permissions to create the registry key needed. If not then logs will
|
||||
appear as "Application". You can run `rclone version --windows-event-log DEBUG`
|
||||
appear as "Application". You can run `rclone version --windows-event-log-level DEBUG`
|
||||
once as administrator to create the registry key in advance.
|
||||
|
||||
**Note** that the `--windows-event-log` level must be greater (more
|
||||
**Note** that the `--windows-event-log-level` level must be greater (more
|
||||
severe) than or equal to the `--log-level`. For example to log DEBUG
|
||||
to a log file but ERRORs to the event log you would use
|
||||
|
||||
```text
|
||||
--log-file rclone.log --log-level DEBUG --windows-event-log ERROR
|
||||
--log-file rclone.log --log-level DEBUG --windows-event-log-level ERROR
|
||||
```
|
||||
|
||||
This option is only supported Windows platforms.
|
||||
|
||||
+29
-3
@@ -186,9 +186,14 @@ correct root to use itself.
|
||||
However you can set this to restrict rclone to a specific folder
|
||||
hierarchy or to access data within the "Computers" tab on the drive
|
||||
web interface (where files from Google's Backup and Sync desktop
|
||||
program go).
|
||||
program go). However, this is not the easiest method.
|
||||
Instead, you can create a shortcut to a folder in "Computers" and
|
||||
place it in "My Drive." To do so, right-click the folder, select
|
||||
"Organize", and then choose "Add shortcut" in the Google Drive web interface.
|
||||
Once you add the shortcut to "My Drive," rclone will display the folder, allowing you to interact with it.
|
||||
See also [Shortcuts](#shortcuts).
|
||||
|
||||
In order to do this you will have to find the `Folder ID` of the
|
||||
If, however, you choose to change your root folder, you will have to find the `Folder ID` of the
|
||||
directory you wish rclone to display. This will be the last segment
|
||||
of the URL when you open the relevant folder in the drive web
|
||||
interface.
|
||||
@@ -199,7 +204,11 @@ in the browser, then you use `1XyfxxxxxxxxxxxxxxxxxxxxxxxxxKHCh` as
|
||||
the `root_folder_id` in the config.
|
||||
|
||||
**NB** folders under the "Computers" tab seem to be read only (drive
|
||||
gives a 500 error) when using rclone.
|
||||
gives a 500 error) when using rclone, but they are also read-only in the Google Drive web interface,
|
||||
likely because this folder is managed by the Google Drive Desktop tool.
|
||||
Top-level folders in "Computers" are read-only, but you can interact
|
||||
with folders contained within them using rclone.
|
||||
These are the folders for which you can create a shortcut as well, as described above.
|
||||
|
||||
There doesn't appear to be an API to discover the folder IDs of the
|
||||
"Computers" tab - please contact us if you know otherwise!
|
||||
@@ -2023,6 +2032,23 @@ after a week, which can be annoying to refresh constantly. If, for whatever
|
||||
reason, a short grant time is not a problem, then keeping the application in
|
||||
testing mode would also be sufficient.
|
||||
|
||||
In most cases verification is not actually required. Google [exempts a number of
|
||||
app categories](https://support.google.com/cloud/answer/13464323) from mandatory
|
||||
verification, including:
|
||||
|
||||
- **Personal Use apps**: if the app is for your personal use (fewer than 100
|
||||
users), you and your limited number of users can keep using it without
|
||||
verification - you will just need to click through the "unverified app"
|
||||
warning screen during sign-in. Verification is only required if you want to
|
||||
grow your user base beyond 100 users.
|
||||
- **Development/Testing/Staging apps**: apps in development, testing or staging
|
||||
mode are not subject to verification (but are limited to the 100-user cap and
|
||||
the unverified-app warning until verified).
|
||||
|
||||
So for typical personal rclone use you can leave the app unverified, accept the
|
||||
warning screen, and publish it (rather than leaving it in "Testing") to avoid
|
||||
the weekly grant expiry described above.
|
||||
|
||||
(Thanks to @balazer on github for these instructions.)
|
||||
|
||||
Sometimes, creation of an OAuth consent in Google API Console fails due to an
|
||||
|
||||
@@ -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.4")
|
||||
```
|
||||
|
||||
|
||||
@@ -805,8 +805,10 @@ Backend-only flags (these can be set in the config file also).
|
||||
--local-case-sensitive Force the filesystem to report itself as case sensitive
|
||||
--local-description string Description of the remote
|
||||
--local-encoding Encoding The encoding for the backend (default Slash,Dot)
|
||||
--local-fatal-if-no-space Make out-of-space errors fatal during transfers
|
||||
--local-hashes CommaSepList Comma separated list of supported checksum types
|
||||
--local-links Translate symlinks to/from regular files with a '.rclonelink' extension for the local backend
|
||||
--local-metadata-restore-special-bits Restore the setuid, setgid and sticky bits from metadata
|
||||
--local-no-check-updated Don't check to see if the files change during upload
|
||||
--local-no-clone Disable reflink cloning for server-side copies
|
||||
--local-no-preallocate Disable preallocation of disk space for transferred files
|
||||
|
||||
@@ -296,6 +296,31 @@ backends and the VFS.
|
||||
|
||||
Note that this flag is incompatible with `-copy-links` / `-L`.
|
||||
|
||||
#### Symlink targets and the destination
|
||||
|
||||
When rclone recreates a `.rclonelink` file as a symlink on local storage,
|
||||
the symlink can point anywhere - including, with an absolute path or one
|
||||
using `../` - to a location outside the directory you are copying into. This
|
||||
is normal - rclone reproduces whatever target the link had, so backups
|
||||
round-trip faithfully.
|
||||
|
||||
What rclone will **not** do is *write through* such a link. If a remote you
|
||||
are copying from contains both a symlink and a file or directory that would
|
||||
be placed inside it - for example a `dir.rclonelink` pointing somewhere
|
||||
outside the destination, alongside a `dir/file.txt` - rclone refuses to
|
||||
follow the symlink when writing `dir/file.txt`. The offending file is
|
||||
skipped with an error, the rest of the transfer continues, and the skipped
|
||||
file is counted in the error summary printed at the end of the run.
|
||||
|
||||
This protects you from a malicious or compromised remote using `-l` /
|
||||
`--links` to plant a symlink and then write through it to somewhere outside
|
||||
your destination. Ordinary symlink round-trips, and symlinks that stay
|
||||
inside the destination, are unaffected.
|
||||
|
||||
If you have intentionally pre-created a symlinked directory inside your
|
||||
destination and want rclone to write into the directory it points at, do
|
||||
not use `-l` / `--links` for that copy, or remove the symlink first.
|
||||
|
||||
### Restricting filesystems with --one-file-system
|
||||
|
||||
Normally rclone will recurse through filesystems as mounted.
|
||||
@@ -612,6 +637,47 @@ Properties:
|
||||
- Type: bool
|
||||
- Default: false
|
||||
|
||||
#### --local-metadata-restore-special-bits
|
||||
|
||||
Restore the setuid, setgid and sticky bits from metadata.
|
||||
|
||||
When restoring metadata with --metadata rclone applies the "mode" from
|
||||
the source. By default rclone applies only the permission bits and
|
||||
strips the setuid, setgid and sticky bits.
|
||||
|
||||
The "mode" comes from the source remote which may not be trusted.
|
||||
Restoring a setuid or setgid bit onto freshly written,
|
||||
source-controlled content can plant a setuid binary, which is dangerous
|
||||
in particular when restoring from an untrusted source while running as
|
||||
root. For this reason these bits are not restored by default.
|
||||
|
||||
If you trust the source and want the setuid, setgid and sticky bits
|
||||
restored - for example when restoring a system backup made by rclone -
|
||||
set this flag.
|
||||
|
||||
Properties:
|
||||
|
||||
- Config: metadata_restore_special_bits
|
||||
- Env Var: RCLONE_LOCAL_METADATA_RESTORE_SPECIAL_BITS
|
||||
- Type: bool
|
||||
- Default: false
|
||||
|
||||
#### --local-fatal-if-no-space
|
||||
|
||||
Make out-of-space errors fatal during transfers.
|
||||
|
||||
When enabled, an ENOSPC error during a write returns a fatal error so
|
||||
that rclone aborts rather than retrying the operation. Useful for
|
||||
backup scripts that should halt loudly on a full disk rather than spin
|
||||
retrying.
|
||||
|
||||
Properties:
|
||||
|
||||
- Config: fatal_if_no_space
|
||||
- Env Var: RCLONE_LOCAL_FATAL_IF_NO_SPACE
|
||||
- Type: bool
|
||||
- Default: false
|
||||
|
||||
#### --local-time-type
|
||||
|
||||
Set what kind of time is returned.
|
||||
@@ -698,6 +764,13 @@ supported by all file systems) under the "user.*" prefix.
|
||||
|
||||
Metadata is supported on files and directories.
|
||||
|
||||
When restoring metadata with `--metadata` rclone applies the
|
||||
"mode", "uid" and "gid" from the source. These come from the source
|
||||
remote which may not be trusted, so restoring metadata as root from an
|
||||
untrusted source can change file ownership and is not recommended. The
|
||||
setuid, setgid and sticky bits are not restored by default - see the
|
||||
`--local-metadata-restore-special-bits` flag.
|
||||
|
||||
Here are the possible system metadata items for the local backend.
|
||||
|
||||
| Name | Help | Type | Example | Read Only |
|
||||
|
||||
@@ -15,6 +15,43 @@ or [use HTTP directly](#api-http).
|
||||
If you just want to run a remote control then see the [rcd](/commands/rclone_rcd/)
|
||||
command.
|
||||
|
||||
## Security {#security}
|
||||
|
||||
**Access to the rc API is equivalent to shell access as the user running
|
||||
rclone.** Treat the rc port as you would an interactive login on the host.
|
||||
|
||||
Any caller who can reach the API (and pass authentication, if it is enabled)
|
||||
can, among other things:
|
||||
|
||||
- **Run OS commands** as the rclone user. `core/command` re-executes the rclone
|
||||
binary with arbitrary arguments, and several backend options shell out to
|
||||
programs, so even creating a remote with `config/create` can lead to command
|
||||
execution.
|
||||
- **Read and write any file** reachable by the rclone process, by pointing
|
||||
`operations/*` or `sync/*` at a `local` remote (or via `--rc-files` /
|
||||
`--rc-serve`). Writing arbitrary files as the rclone user is itself a route to
|
||||
code execution.
|
||||
- **Read back stored credentials.** rclone configs routinely hold cloud-provider
|
||||
secrets. `config/dump` and friends expose them, so a compromise of the rc
|
||||
reaches every configured backend.
|
||||
- **Change rclone's runtime behaviour** with `options/set`, **manage remotes**
|
||||
with `config/*`, and **stop the process** with `core/quit`.
|
||||
|
||||
There is currently no per-endpoint capability or scope system: authentication is
|
||||
all-or-nothing. Granting any access grants all of the above.
|
||||
|
||||
Consequently:
|
||||
|
||||
- **Do not bind the rc to a network address you do not control.** The default
|
||||
bind is loopback (`localhost:5572`); keep it there unless you have a specific
|
||||
reason to change it.
|
||||
- **Do not use `--rc-no-auth` on a non-loopback bind.** It disables
|
||||
authentication on the endpoints that access remotes — see
|
||||
[`--rc-no-auth`](#--rc-no-auth).
|
||||
- **Use authentication and TLS** (`--rc-user`/`--rc-pass` or `--rc-htpasswd`,
|
||||
plus `--rc-cert`/`--rc-key`) whenever the port is reachable by anyone you do
|
||||
not fully trust, and raise `--rc-min-tls-version`.
|
||||
|
||||
## Supported parameters
|
||||
|
||||
### --rc
|
||||
@@ -78,8 +115,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).
|
||||
|
||||
@@ -75,7 +75,7 @@ y/e/d>
|
||||
## Configuring by copying the config file
|
||||
|
||||
Rclone stores all of its configuration in a single file. This can easily be
|
||||
copied to configure a remote rclone (although some backends does not support
|
||||
copied to configure a remote rclone (although some backends do not support
|
||||
reusing the same configuration, consult your backend documentation to be
|
||||
sure).
|
||||
|
||||
|
||||
+1
-1
@@ -3512,7 +3512,7 @@ Cutoff for switching to multipart copy.
|
||||
Any files larger than this that need to be server-side copied will be
|
||||
copied in chunks of this size.
|
||||
|
||||
The minimum is 0 and the maximum is 5 GiB.
|
||||
The minimum is 1 byte and the maximum is 5 GiB.
|
||||
|
||||
Properties:
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
v1.74.2
|
||||
v1.74.4
|
||||
Vendored
+7
-4
@@ -513,11 +513,14 @@
|
||||
|
||||
// Determine what to copy
|
||||
var text;
|
||||
var pre = btn.closest("pre");
|
||||
if (pre) {
|
||||
var preWrap = btn.closest(".pre-wrap");
|
||||
if (preWrap) {
|
||||
// Code block: copy the code element text (excludes button)
|
||||
var code = pre.querySelector("code");
|
||||
text = (code || pre).textContent;
|
||||
var pre = preWrap.querySelector("pre");
|
||||
if (pre) {
|
||||
var code = pre.querySelector("code");
|
||||
text = (code || pre).textContent;
|
||||
}
|
||||
} else {
|
||||
// Input field: copy value of the preceding input
|
||||
var input = btn.previousElementSibling;
|
||||
|
||||
@@ -730,9 +730,15 @@ func (s *StatsInfo) ResetCounters() {
|
||||
s.startedTransfers = nil
|
||||
s.oldDuration = 0
|
||||
|
||||
// Only restart the average loop if it was running. Otherwise
|
||||
// ResetCounters would spawn a goroutine that pins the StatsInfo,
|
||||
// leaking memory when called on stats that never started the loop.
|
||||
wasStarted := s.average.started
|
||||
s._stopAverageLoop()
|
||||
s.average = averageValues{}
|
||||
s._startAverageLoop()
|
||||
if wasStarted {
|
||||
s._startAverageLoop()
|
||||
}
|
||||
}
|
||||
|
||||
// ResetErrors sets the errors count to 0 and resets lastError, fatalError and retryError
|
||||
|
||||
@@ -301,9 +301,16 @@ func GlobalStats() *StatsInfo {
|
||||
}
|
||||
|
||||
// NewStatsGroup creates new stats under named group.
|
||||
//
|
||||
// The averageLoop is intentionally NOT started here: it is started on
|
||||
// demand by NewTransfer / NewTransferRemoteSize when real transfer
|
||||
// activity begins and stopped by DoneTransferring when the last
|
||||
// transfer completes. Starting it eagerly leaked one goroutine per
|
||||
// group that never performed a transfer (issue #9567) - e.g. rcd
|
||||
// daemons driven by frequent rc sync/move calls where each call gets
|
||||
// a fresh job/N group and the source is often empty.
|
||||
func NewStatsGroup(ctx context.Context, group string) *StatsInfo {
|
||||
stats := NewStats(ctx)
|
||||
stats.startAverageLoop()
|
||||
stats.group = group
|
||||
groups.set(ctx, group, stats)
|
||||
return stats
|
||||
|
||||
@@ -271,3 +271,42 @@ func percentDiff(start, end uint64) uint64 {
|
||||
}
|
||||
return (diff * 100) / start
|
||||
}
|
||||
|
||||
// Regression for #9567: NewStatsGroup used to start the averageLoop
|
||||
// goroutine unconditionally at group creation. When an rcd daemon was
|
||||
// driven by many rc sync/move calls that transferred zero files, each
|
||||
// call created a fresh job/N group whose averageLoop was started but
|
||||
// never stopped (nothing ever went transferring->empty), leaking one
|
||||
// goroutine per call. The loop must only start on demand from
|
||||
// NewTransfer / NewTransferRemoteSize, and it must still stop when the
|
||||
// last transfer completes.
|
||||
func TestNewStatsGroupDoesNotStartAverageLoop(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
defer func() {
|
||||
groups = newStatsGroups()
|
||||
}()
|
||||
|
||||
stats := NewStatsGroup(ctx, "test-group-9567")
|
||||
|
||||
stats.mu.RLock()
|
||||
started := stats.average.started
|
||||
stats.mu.RUnlock()
|
||||
assert.False(t, started,
|
||||
"NewStatsGroup must not start averageLoop for a zero-transfer group (issue #9567)")
|
||||
|
||||
// The loop must still start on demand when a real transfer is added,
|
||||
// and stop cleanly once the last transfer completes.
|
||||
tr := stats.NewTransferRemoteSize("regression-9567", 0, nil, nil)
|
||||
stats.mu.RLock()
|
||||
startedAfterTransfer := stats.average.started
|
||||
stats.mu.RUnlock()
|
||||
assert.True(t, startedAfterTransfer,
|
||||
"averageLoop should start on demand when a transfer is added")
|
||||
|
||||
tr.Done(ctx, nil)
|
||||
stats.mu.RLock()
|
||||
startedAfterDone := stats.average.started
|
||||
stats.mu.RUnlock()
|
||||
assert.False(t, startedAfterDone,
|
||||
"averageLoop should stop when the last transfer is done")
|
||||
}
|
||||
+5
-1
@@ -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
|
||||
|
||||
@@ -168,6 +168,12 @@ func installFlag(flags *pflag.FlagSet, name string, groupsString string) {
|
||||
}
|
||||
fs.Debugf(nil, "Setting --%s %q from environment variable %s=%q", name, flag.Value, envKey, envValue)
|
||||
flag.DefValue = envValue
|
||||
// This is a default from the environment, not an explicit
|
||||
// flag on the command line, so don't let it take precedence
|
||||
// over more specific configuration sources.
|
||||
if isOption {
|
||||
opt.MarkUnset()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)))
|
||||
}
|
||||
+5
-1
@@ -64,7 +64,11 @@ type regInfoValues struct {
|
||||
// the default values
|
||||
func (r *regInfoValues) Get(key string) (value string, ok bool) {
|
||||
opt := r.options.Get(key)
|
||||
if opt != nil && (r.useDefault || !opt.IsDefault()) {
|
||||
// Return the value if it was explicitly set (e.g. a flag on the
|
||||
// command line, even when equal to the default) or if it differs
|
||||
// from the default (e.g. loaded from the environment as a flag
|
||||
// default by installFlag).
|
||||
if opt != nil && (r.useDefault || opt.IsSet() || !opt.IsDefault()) {
|
||||
return opt.String(), true
|
||||
}
|
||||
return "", false
|
||||
|
||||
+5
-1
@@ -631,7 +631,11 @@ func (f *Filter) MakeListR(ctx context.Context, NewObject func(ctx context.Conte
|
||||
if err == fs.ErrorObjectNotFound {
|
||||
// Skip files that are not found
|
||||
} else if err != nil {
|
||||
return err
|
||||
// Count and log the error but carry on so that one
|
||||
// unreadable file (e.g. permission denied) doesn't stop
|
||||
// the other --files-from files being processed.
|
||||
fs.Errorf(remote, "--files-from failed to read file: %v", err)
|
||||
_ = fs.CountError(gCtx, err)
|
||||
} else {
|
||||
err = callback(entries)
|
||||
if err != nil {
|
||||
|
||||
@@ -391,19 +391,22 @@ func TestNewFilterMakeListR(t *testing.T) {
|
||||
assert.Equal(t, want, newObjects)
|
||||
assert.Equal(t, want, listRObjects)
|
||||
|
||||
// Now check an error is returned from NewObject
|
||||
// Check that a file which errors on NewObject doesn't stop the
|
||||
// others being listed - the error is counted and logged rather than
|
||||
// being returned.
|
||||
require.NoError(t, f.AddFile("error"))
|
||||
err = listR(context.Background(), "", listRcallback)
|
||||
require.EqualError(t, err, assert.AnError.Error())
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, want, listRObjects)
|
||||
|
||||
// The checker will exit by the error above
|
||||
// The same with a single checker
|
||||
ci := fs.GetConfig(context.Background())
|
||||
ci.Checkers = 1
|
||||
|
||||
// Now check an error is returned from NewObject
|
||||
require.NoError(t, f.AddFile("error"))
|
||||
err = listR(context.Background(), "", listRcallback)
|
||||
require.EqualError(t, err, assert.AnError.Error())
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, want, listRObjects)
|
||||
}
|
||||
|
||||
func TestNewFilterMinSize(t *testing.T) {
|
||||
|
||||
+15
-2
@@ -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
|
||||
|
||||
@@ -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
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
+14
-1
@@ -126,6 +126,12 @@ func (o *RangeOption) Decode(size int64) (offset, limit int64) {
|
||||
} else {
|
||||
if o.End >= 0 {
|
||||
offset = size - o.End
|
||||
if offset < 0 {
|
||||
// RFC 7233 section 2.1: if the suffix-length is
|
||||
// larger than the representation, use the entire
|
||||
// representation.
|
||||
offset = 0
|
||||
}
|
||||
} else {
|
||||
offset = 0
|
||||
}
|
||||
@@ -162,7 +168,14 @@ func FixRangeOption(options []OpenOption, size int64) {
|
||||
case *RangeOption:
|
||||
// If start is < 0 then fetch from the end
|
||||
if x.Start < 0 {
|
||||
x = &RangeOption{Start: size - x.End, End: -1}
|
||||
start := size - x.End
|
||||
if start < 0 {
|
||||
// RFC 7233 section 2.1: if the suffix-length is
|
||||
// larger than the representation, use the entire
|
||||
// representation (#6310).
|
||||
start = 0
|
||||
}
|
||||
x = &RangeOption{Start: start, End: -1}
|
||||
options[i] = x
|
||||
}
|
||||
// If end is too big or undefined, fetch to the end
|
||||
|
||||
@@ -53,6 +53,13 @@ func TestRangeOptionDecode(t *testing.T) {
|
||||
{in: RangeOption{Start: 1, End: -1}, size: 100, wantOffset: 1, wantLimit: -1},
|
||||
{in: RangeOption{Start: -1, End: 90}, size: 100, wantOffset: 10, wantLimit: -1},
|
||||
{in: RangeOption{Start: -1, End: -1}, size: 100, wantOffset: 0, wantLimit: -1},
|
||||
// Regression test for #6310: a suffix range whose length exceeds
|
||||
// the size of the object must not produce a negative offset -
|
||||
// RFC 7233 section 2.1 says the entire representation should be
|
||||
// used instead. "bytes=-90407" against a 5 byte object panicked
|
||||
// downstream with "slice bounds out of range [-90402:]".
|
||||
{in: RangeOption{Start: -1, End: 90407}, size: 5, wantOffset: 0, wantLimit: -1},
|
||||
{in: RangeOption{Start: -1, End: 5}, size: 5, wantOffset: 0, wantLimit: -1},
|
||||
} {
|
||||
gotOffset, gotLimit := test.in.Decode(test.size)
|
||||
what := fmt.Sprintf("%+v size=%d", test.in, test.size)
|
||||
@@ -227,6 +234,20 @@ func TestFixRangeOptions(t *testing.T) {
|
||||
},
|
||||
size: 100,
|
||||
},
|
||||
{
|
||||
// Regression test for #6310: a suffix range longer than the
|
||||
// object must clamp to the start of the file (Start: 0),
|
||||
// not produce a negative Start which would corrupt the
|
||||
// Range header sent to the remote.
|
||||
name: "Fetch the last N bytes where N is bigger than size",
|
||||
in: []OpenOption{
|
||||
&RangeOption{Start: -1, End: 90407},
|
||||
},
|
||||
want: []OpenOption{
|
||||
&RangeOption{Start: 0, End: 99},
|
||||
},
|
||||
size: 100,
|
||||
},
|
||||
{
|
||||
name: "SeekOption",
|
||||
in: []OpenOption{
|
||||
|
||||
@@ -546,7 +546,11 @@ func SuffixName(ctx context.Context, remote string) string {
|
||||
// and accumulating stats and errors.
|
||||
//
|
||||
// If backupDir is set then it moves the file to there instead of
|
||||
// deleting
|
||||
// deleting.
|
||||
//
|
||||
// Use BackupDir to find backupDir from --backup-dir. That lookup is
|
||||
// relatively expensive, so when deleting many files do it once outside
|
||||
// the loop rather than calling it for every object.
|
||||
func DeleteFileWithBackupDir(ctx context.Context, dst fs.Object, backupDir fs.Fs) (err error) {
|
||||
tr := accounting.Stats(ctx).NewCheckingTransfer(dst, "deleting")
|
||||
defer func() {
|
||||
@@ -579,8 +583,8 @@ func DeleteFileWithBackupDir(ctx context.Context, dst fs.Object, backupDir fs.Fs
|
||||
|
||||
// DeleteFile deletes a single file respecting --dry-run and accumulating stats and errors.
|
||||
//
|
||||
// If useBackupDir is set and --backup-dir is in effect then it moves
|
||||
// the file to there instead of deleting
|
||||
// DeleteFile does not honour --backup-dir: it always deletes. Call
|
||||
// DeleteFileWithBackupDir instead if --backup-dir support is required.
|
||||
func DeleteFile(ctx context.Context, dst fs.Object) (err error) {
|
||||
return DeleteFileWithBackupDir(ctx, dst, nil)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -229,6 +229,7 @@ type Option struct {
|
||||
Provider string `json:",omitempty"` // set to filter on provider
|
||||
Default any // default value, nil => "", if set (and not to nil or "") then Required does nothing
|
||||
Value any // value to be set by flags
|
||||
set bool // true once Set has been called, so an explicit value equal to Default is still honoured over the config file
|
||||
Examples OptionExamples `json:",omitempty"` // predefined values that can be selected from list (multiple-choice option)
|
||||
ShortOpt string `json:",omitempty"` // the short option for this if required
|
||||
Hide OptionVisibility // set this to hide the config from the configurator or the command line
|
||||
@@ -327,6 +328,7 @@ func (o *Option) Set(s string) (err error) {
|
||||
stringArray = []string{}
|
||||
}
|
||||
o.Value = append(stringArray, s)
|
||||
o.set = true
|
||||
return nil
|
||||
}
|
||||
newValue, err := configstruct.StringToInterface(v, s)
|
||||
@@ -334,9 +336,27 @@ func (o *Option) Set(s string) (err error) {
|
||||
return err
|
||||
}
|
||||
o.Value = newValue
|
||||
o.set = true
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsSet returns true if Set has been called on the option, for example
|
||||
// when its flag was provided on the command line. Unlike IsDefault this
|
||||
// is true even when the value supplied is equal to the default.
|
||||
func (o *Option) IsSet() bool {
|
||||
return o.set
|
||||
}
|
||||
|
||||
// MarkUnset marks the option as not having been set explicitly.
|
||||
//
|
||||
// It is used after a value has been loaded from the environment as a
|
||||
// flag default, so that the value is treated like a default rather than
|
||||
// an explicit command line flag and more specific configuration sources
|
||||
// still take precedence over it.
|
||||
func (o *Option) MarkUnset() {
|
||||
o.set = false
|
||||
}
|
||||
|
||||
type typer interface {
|
||||
Type() string
|
||||
}
|
||||
|
||||
+26
-1
@@ -45,9 +45,31 @@ var (
|
||||
Name: "case_insensitive",
|
||||
Default: false,
|
||||
Value: true,
|
||||
set: true, // set as if from a flag
|
||||
Advanced: true,
|
||||
}
|
||||
testOptions = Options{nouncOption, copyLinksOption, caseInsensitiveOption}
|
||||
// setToDefaultOption has been set explicitly to a value which
|
||||
// happens to equal its default - it must still override the config
|
||||
setToDefaultOption = Option{
|
||||
Name: "set_to_default",
|
||||
Default: "deflt",
|
||||
Value: "deflt",
|
||||
set: true,
|
||||
}
|
||||
// envDefaultOption has had a value loaded as a default from the
|
||||
// environment (so set is false). It is only honoured over more
|
||||
// specific sources when it differs from the default.
|
||||
envDefaultOption = Option{
|
||||
Name: "env_default",
|
||||
Default: "deflt",
|
||||
Value: "deflt", // equal to default, so must not be surfaced
|
||||
}
|
||||
envDefaultDiffOption = Option{
|
||||
Name: "env_default_diff",
|
||||
Default: "deflt",
|
||||
Value: "fromenv", // differs from default, so must be surfaced
|
||||
}
|
||||
testOptions = Options{nouncOption, copyLinksOption, caseInsensitiveOption, setToDefaultOption, envDefaultOption, envDefaultDiffOption}
|
||||
)
|
||||
|
||||
func TestOptionsSetValues(t *testing.T) {
|
||||
@@ -266,6 +288,9 @@ func TestOptionGetters(t *testing.T) {
|
||||
{regInfoValuesGetterFalse, "not_found", "", false},
|
||||
{regInfoValuesGetterFalse, "case_insensitive", "true", true},
|
||||
{regInfoValuesGetterFalse, "copy_links", "", false},
|
||||
{regInfoValuesGetterFalse, "set_to_default", "deflt", true},
|
||||
{regInfoValuesGetterFalse, "env_default", "", false},
|
||||
{regInfoValuesGetterFalse, "env_default_diff", "fromenv", true},
|
||||
{regInfoValuesGetterTrue, "not_found", "", false},
|
||||
{regInfoValuesGetterTrue, "case_insensitive", "true", true},
|
||||
{regInfoValuesGetterTrue, "copy_links", "false", true},
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package fs
|
||||
|
||||
// VersionTag of rclone
|
||||
var VersionTag = "v1.74.2"
|
||||
var VersionTag = "v1.74.4"
|
||||
@@ -31,7 +31,7 @@ require (
|
||||
github.com/aws/smithy-go v1.24.3
|
||||
github.com/buengese/sgzip v0.1.1
|
||||
github.com/cloudinary/cloudinary-go/v2 v2.15.0
|
||||
github.com/cloudsoda/go-smb2 v0.0.0-20250228001242-d4c70e6251cc
|
||||
github.com/cloudsoda/go-smb2 v0.0.0-20260701064823-d8c5600d73b8
|
||||
github.com/colinmarc/hdfs/v2 v2.4.0
|
||||
github.com/coreos/go-semver v0.3.1
|
||||
github.com/coreos/go-systemd/v22 v22.6.0
|
||||
@@ -39,7 +39,7 @@ require (
|
||||
github.com/dop251/scsu v0.0.0-20220106150536-84ac88021d00
|
||||
github.com/dropbox/dropbox-sdk-go-unofficial/v6 v6.0.5
|
||||
github.com/gabriel-vasile/mimetype v1.4.13
|
||||
github.com/gdamore/tcell/v2 v2.13.8
|
||||
github.com/gdamore/tcell/v2 v2.9.0
|
||||
github.com/go-chi/chi/v5 v5.2.5
|
||||
github.com/go-darwin/apfs v0.0.0-20211011131704-f84b94dbf348
|
||||
github.com/go-git/go-billy/v5 v5.9.0
|
||||
@@ -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
|
||||
@@ -82,7 +82,7 @@ require (
|
||||
github.com/spf13/cobra v1.10.2
|
||||
github.com/spf13/pflag v1.0.10
|
||||
github.com/stretchr/testify v1.11.1
|
||||
github.com/t3rm1n4l/go-mega v0.0.0-20251120131202-6845944c051c
|
||||
github.com/t3rm1n4l/go-mega v0.0.0-20260630094356-4de2f127f34a
|
||||
github.com/unknwon/goconfig v1.0.0
|
||||
github.com/willscott/go-nfs v0.0.4
|
||||
github.com/winfsp/cgofuse v1.6.1-0.20260126094232-f2c4fccdb286
|
||||
@@ -97,9 +97,9 @@ require (
|
||||
golang.org/x/crypto v0.52.0
|
||||
golang.org/x/net v0.55.0
|
||||
golang.org/x/oauth2 v0.36.0
|
||||
golang.org/x/sync v0.20.0
|
||||
golang.org/x/sync v0.21.0
|
||||
golang.org/x/sys v0.45.0
|
||||
golang.org/x/text v0.37.0
|
||||
golang.org/x/text v0.38.0
|
||||
golang.org/x/time v0.15.0
|
||||
google.golang.org/api v0.275.0
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||
@@ -262,8 +262,8 @@ require (
|
||||
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||
go4.org v0.0.0-20260112195520-a5071408f32f // indirect
|
||||
golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f // indirect
|
||||
golang.org/x/image v0.41.0 // indirect
|
||||
golang.org/x/tools v0.44.0 // indirect
|
||||
golang.org/x/image v0.43.0 // indirect
|
||||
golang.org/x/tools v0.45.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 // indirect
|
||||
google.golang.org/grpc v1.80.0 // indirect
|
||||
google.golang.org/protobuf v1.36.11 // indirect
|
||||
|
||||
@@ -204,8 +204,8 @@ github.com/cloudflare/circl v1.6.3 h1:9GPOhQGF9MCYUeXyMYlqTR6a5gTrgR/fBLXvUgtVcg
|
||||
github.com/cloudflare/circl v1.6.3/go.mod h1:2eXP6Qfat4O/Yhh8BznvKnJ+uzEoTQ6jVKJRn81BiS4=
|
||||
github.com/cloudinary/cloudinary-go/v2 v2.15.0 h1:iLoIwb7BJECHTbNcmIhYDsQhoZiACWGNvEpyqQy97Dk=
|
||||
github.com/cloudinary/cloudinary-go/v2 v2.15.0/go.mod h1:ireC4gqVetsjVhYlwjUJwKTbZuWjEIynbR9zQTlqsvo=
|
||||
github.com/cloudsoda/go-smb2 v0.0.0-20250228001242-d4c70e6251cc h1:t8YjNUCt1DimB4HCIXBztwWMhgxr5yG5/YaRl9Afdfg=
|
||||
github.com/cloudsoda/go-smb2 v0.0.0-20250228001242-d4c70e6251cc/go.mod h1:CgWpFCFWzzEA5hVkhAc6DZZzGd3czx+BblvOzjmg6KA=
|
||||
github.com/cloudsoda/go-smb2 v0.0.0-20260701064823-d8c5600d73b8 h1:+KC2I+emnT6ccWmo7IHbtchGc/vFqAxUuovo2eUgMuM=
|
||||
github.com/cloudsoda/go-smb2 v0.0.0-20260701064823-d8c5600d73b8/go.mod h1:1pQXB0vAlzRlqcY7LYKOOZMw0wKfJPFxTLsJRF2Gswo=
|
||||
github.com/cloudsoda/sddl v0.0.0-20250224235906-926454e91efc h1:0xCWmFKBmarCqqqLeM7jFBSw/Or81UEElFqO8MY+GDs=
|
||||
github.com/cloudsoda/sddl v0.0.0-20250224235906-926454e91efc/go.mod h1:uvR42Hb/t52HQd7x5/ZLzZEK8oihrFpgnodIJ1vte2E=
|
||||
github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=
|
||||
@@ -275,8 +275,8 @@ github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9
|
||||
github.com/gabriel-vasile/mimetype v1.4.13/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||
github.com/gdamore/encoding v1.0.1 h1:YzKZckdBL6jVt2Gc+5p82qhrGiqMdG/eNs6Wy0u3Uhw=
|
||||
github.com/gdamore/encoding v1.0.1/go.mod h1:0Z0cMFinngz9kS1QfMjCP8TY7em3bZYeeklsSDPivEo=
|
||||
github.com/gdamore/tcell/v2 v2.13.8 h1:Mys/Kl5wfC/GcC5Cx4C2BIQH9dbnhnkPgS9/wF3RlfU=
|
||||
github.com/gdamore/tcell/v2 v2.13.8/go.mod h1:+Wfe208WDdB7INEtCsNrAN6O2m+wsTPk1RAovjaILlo=
|
||||
github.com/gdamore/tcell/v2 v2.9.0 h1:N6t+eqK7/xwtRPwxzs1PXeRWnm0H9l02CrgJ7DLn1ys=
|
||||
github.com/gdamore/tcell/v2 v2.9.0/go.mod h1:8/ZoqM9rxzYphT9tH/9LnunhV9oPBqwS8WHGYm5nrmo=
|
||||
github.com/geoffgarside/ber v1.2.0 h1:/loowoRcs/MWLYmGX9QtIAbA+V/FrnVLsMMPhwiRm64=
|
||||
github.com/geoffgarside/ber v1.2.0/go.mod h1:jVPKeCbj6MvQZhwLYsGwaGI52oUorHoHKNecGT85ZCc=
|
||||
github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E=
|
||||
@@ -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=
|
||||
@@ -666,8 +666,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/t3rm1n4l/go-mega v0.0.0-20251120131202-6845944c051c h1:dtcOwRimeiBFrlutmF6K94l0rxYFARNFMA+lSQ41C+M=
|
||||
github.com/t3rm1n4l/go-mega v0.0.0-20251120131202-6845944c051c/go.mod h1:BF/l2jNyK+2h/BJZ7VLMAz6m/IWjA2F67gTjV1C/+Bo=
|
||||
github.com/t3rm1n4l/go-mega v0.0.0-20260630094356-4de2f127f34a h1:VQ9CmpYeTgdFvg748N6tIOHBZn+hXjJe2xNuOJHW07E=
|
||||
github.com/t3rm1n4l/go-mega v0.0.0-20260630094356-4de2f127f34a/go.mod h1:BF/l2jNyK+2h/BJZ7VLMAz6m/IWjA2F67gTjV1C/+Bo=
|
||||
github.com/tailscale/depaware v0.0.0-20210622194025-720c4b409502/go.mod h1:p9lPsd+cx33L3H9nNoecRRxPssFKUwwI50I3pZ0yT+8=
|
||||
github.com/tinylib/msgp v1.6.3 h1:bCSxiTz386UTgyT1i0MSCvdbWjVW+8sG3PjkGsZQt4s=
|
||||
github.com/tinylib/msgp v1.6.3/go.mod h1:RSp0LW9oSxFut3KzESt5Voq4GVWyS+PSulT77roAqEA=
|
||||
@@ -789,8 +789,8 @@ golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f h1:W3F4c+6OLc6H2lb//N1q4WpJk
|
||||
golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f/go.mod h1:J1xhfL/vlindoeF/aINzNzt2Bket5bjo9sdOYzOsU80=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.41.0 h1:8wS72eGJMJaBxK6okTzd4WaXumUlTVlb753MlsSvTCo=
|
||||
golang.org/x/image v0.41.0/go.mod h1:uIc348UZMSvS5Z65CVZ7iDPaNobNFEPeJ4kbqTOszmA=
|
||||
golang.org/x/image v0.43.0 h1:FLxcP4ec2350nTfOC8ysKtqYSIFbk/QGjw1ZHNP4tsY=
|
||||
golang.org/x/image v0.43.0/go.mod h1:rrpelvGFt+kLPAjPM4HeWPgrl0FtafueU//e5N0qk/Q=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
@@ -881,8 +881,8 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
|
||||
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=
|
||||
golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -962,8 +962,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc=
|
||||
golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38=
|
||||
golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE=
|
||||
golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
@@ -1017,8 +1017,8 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c=
|
||||
golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI=
|
||||
golang.org/x/tools v0.45.0 h1:18qN3FAooORvApf5XjCXgsuayZOEtXf6JK18I3+ONa8=
|
||||
golang.org/x/tools v0.45.0/go.mod h1:LuUGqqaXcXMEFEruIVJVm5mgDD8vww/z/SR1gQ4uE/0=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
||||
@@ -70,6 +70,24 @@ func TestObjectRange(t *testing.T) {
|
||||
assert.Equal(t, "345", string(body))
|
||||
}
|
||||
|
||||
func TestObjectRangeSuffixLongerThanObject(t *testing.T) {
|
||||
// Regression test for #6310: a suffix range request (e.g. "bytes=-90407")
|
||||
// asking for more bytes than the object contains used to compute a
|
||||
// negative offset and panic with "slice bounds out of range". Per
|
||||
// RFC 7233 section 2.1, the entire object should be served instead.
|
||||
w := httptest.NewRecorder()
|
||||
r := httptest.NewRequest("GET", "http://example.com/aFile", nil)
|
||||
r.Header.Add("Range", "bytes=-90407")
|
||||
o := mockobject.New("aFile").WithContent([]byte("hello"), mockobject.SeekModeNone)
|
||||
Object(w, r, o)
|
||||
resp := w.Result()
|
||||
assert.Equal(t, http.StatusPartialContent, resp.StatusCode)
|
||||
assert.Equal(t, "5", resp.Header.Get("Content-Length"))
|
||||
assert.Equal(t, "bytes 0-4/5", resp.Header.Get("Content-Range"))
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
assert.Equal(t, "hello", string(body))
|
||||
}
|
||||
|
||||
func TestObjectBadRange(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
r := httptest.NewRequest("GET", "http://example.com/aFile", nil)
|
||||
|
||||
@@ -476,6 +476,24 @@ func OverrideCredentials(name string, m configmap.Mapper, origConfig *Config) (n
|
||||
return newConfig, changed
|
||||
}
|
||||
|
||||
// SharedClientIDWarning warns the user that this remote is relying on
|
||||
// rclone's built-in shared OAuth client_id.
|
||||
//
|
||||
// It only warns when the user has not configured their own client_id
|
||||
// (config.ConfigClientID is blank in the config), so it must only be
|
||||
// called from the code path that actually uses the shared client_id -
|
||||
// not for service account, environment or anonymous auth which don't.
|
||||
//
|
||||
// name is the remote's name, service is the human readable name of the
|
||||
// service (eg "Google Drive") and helpURL points at the docs describing
|
||||
// how to make your own client_id.
|
||||
func SharedClientIDWarning(name, service, helpURL string, m configmap.Mapper) {
|
||||
if clientID, _ := m.Get(config.ConfigClientID); clientID != "" {
|
||||
return
|
||||
}
|
||||
fs.Logf(name, "This remote uses rclone's shared %s client_id, which is being retired and will stop working during 2026. Create your own client_id to avoid interruption: %s", service, helpURL)
|
||||
}
|
||||
|
||||
// NewClientWithBaseClient gets a token from the config file and
|
||||
// configures a Client with it. It returns the client and a
|
||||
// TokenSource which Invalidate may need to be called on. It uses the
|
||||
|
||||
@@ -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!-20260708
|
||||
```
|
||||
|
||||
```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-07-08 0517PM
|
||||
```
|
||||
|
||||
```console
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
. ftr VB CB
|
||||
. ftr VBI CBI
|
||||
.\}
|
||||
.TH "rclone" "1" "May 22, 2026" "User Manual" ""
|
||||
.TH "rclone" "1" "Jul 08, 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!-20260708
|
||||
\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-07-08 0504PM
|
||||
\f[R]
|
||||
.fi
|
||||
.IP
|
||||
@@ -6596,8 +6596,9 @@ Copy files from source to dest, skipping identical files.
|
||||
If source:path is a file or directory then it copies it to a file or
|
||||
directory named dest:path.
|
||||
.PP
|
||||
This can be used to upload single files to other than their current
|
||||
name.
|
||||
This can be used to copy a single file to a destination with a name
|
||||
different from its source - for example, uploading and renaming in one
|
||||
step.
|
||||
If the source is a directory then it acts exactly like the
|
||||
copy (https://rclone.org/commands/rclone_copy/) command.
|
||||
.PP
|
||||
@@ -16323,6 +16324,18 @@ Versioning is not currently supported.
|
||||
Metadata will only be saved in memory other than the rclone
|
||||
\f[V]mtime\f[R] metadata which will be set as the modification time of
|
||||
the file.
|
||||
.SS Object names
|
||||
.PP
|
||||
\f[V]serve s3\f[R] stores objects as files in the backend, so object
|
||||
keys are mapped to file paths rather than treated as the opaque strings
|
||||
AWS S3 allows.
|
||||
Keys must be in canonical path form: keys that contain \f[V]..\f[R] or
|
||||
\f[V].\f[R] path segments, repeated slashes (\f[V]//\f[R]), or a leading
|
||||
or trailing slash are rejected with a \f[V]400 Bad Request\f[R]
|
||||
(\f[V]InvalidArgument\f[R]) instead of being normalised, since
|
||||
normalising them could alias two distinct keys to the same file or
|
||||
resolve a key outside its bucket.
|
||||
This matches the behaviour of other S3 servers such as MinIO.
|
||||
.SS Supported operations
|
||||
.PP
|
||||
\f[V]serve s3\f[R] currently supports the following operations.
|
||||
@@ -21747,7 +21760,7 @@ It outputs warnings and significant events.
|
||||
It only outputs error messages.
|
||||
.PP
|
||||
See also the logging section.
|
||||
.SS --windows-event-log LogLevel
|
||||
.SS --windows-event-log-level LogLevel
|
||||
.PP
|
||||
If this is configured (the default is \f[V]OFF\f[R]) then logs of this
|
||||
level and above will be logged to the Windows event log in
|
||||
@@ -21769,17 +21782,17 @@ but not currently used).
|
||||
Rclone will declare its log source as \[dq]rclone\[dq] if it is has
|
||||
enough permissions to create the registry key needed.
|
||||
If not then logs will appear as \[dq]Application\[dq].
|
||||
You can run \f[V]rclone version --windows-event-log DEBUG\f[R] once as
|
||||
administrator to create the registry key in advance.
|
||||
You can run \f[V]rclone version --windows-event-log-level DEBUG\f[R]
|
||||
once as administrator to create the registry key in advance.
|
||||
.PP
|
||||
\f[B]Note\f[R] that the \f[V]--windows-event-log\f[R] level must be
|
||||
greater (more severe) than or equal to the \f[V]--log-level\f[R].
|
||||
\f[B]Note\f[R] that the \f[V]--windows-event-log-level\f[R] level must
|
||||
be greater (more severe) than or equal to the \f[V]--log-level\f[R].
|
||||
For example to log DEBUG to a log file but ERRORs to the event log you
|
||||
would use
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
--log-file rclone.log --log-level DEBUG --windows-event-log ERROR
|
||||
--log-file rclone.log --log-level DEBUG --windows-event-log-level ERROR
|
||||
\f[R]
|
||||
.fi
|
||||
.PP
|
||||
@@ -23858,7 +23871,7 @@ y/e/d>
|
||||
.PP
|
||||
Rclone stores all of its configuration in a single file.
|
||||
This can easily be copied to configure a remote rclone (although some
|
||||
backends does not support reusing the same configuration, consult your
|
||||
backends do not support reusing the same configuration, consult your
|
||||
backend documentation to be sure).
|
||||
.PP
|
||||
Start by running rclone config to create the configuration file on your
|
||||
@@ -25377,6 +25390,55 @@ directly.
|
||||
.PP
|
||||
If you just want to run a remote control then see the
|
||||
rcd (https://rclone.org/commands/rclone_rcd/) command.
|
||||
.SS Security
|
||||
.PP
|
||||
\f[B]Access to the rc API is equivalent to shell access as the user
|
||||
running rclone.\f[R] Treat the rc port as you would an interactive login
|
||||
on the host.
|
||||
.PP
|
||||
Any caller who can reach the API (and pass authentication, if it is
|
||||
enabled) can, among other things:
|
||||
.IP \[bu] 2
|
||||
\f[B]Run OS commands\f[R] as the rclone user.
|
||||
\f[V]core/command\f[R] re-executes the rclone binary with arbitrary
|
||||
arguments, and several backend options shell out to programs, so even
|
||||
creating a remote with \f[V]config/create\f[R] can lead to command
|
||||
execution.
|
||||
.IP \[bu] 2
|
||||
\f[B]Read and write any file\f[R] reachable by the rclone process, by
|
||||
pointing \f[V]operations/*\f[R] or \f[V]sync/*\f[R] at a \f[V]local\f[R]
|
||||
remote (or via \f[V]--rc-files\f[R] / \f[V]--rc-serve\f[R]).
|
||||
Writing arbitrary files as the rclone user is itself a route to code
|
||||
execution.
|
||||
.IP \[bu] 2
|
||||
\f[B]Read back stored credentials.\f[R] rclone configs routinely hold
|
||||
cloud-provider secrets.
|
||||
\f[V]config/dump\f[R] and friends expose them, so a compromise of the rc
|
||||
reaches every configured backend.
|
||||
.IP \[bu] 2
|
||||
\f[B]Change rclone\[aq]s runtime behaviour\f[R] with
|
||||
\f[V]options/set\f[R], \f[B]manage remotes\f[R] with \f[V]config/*\f[R],
|
||||
and \f[B]stop the process\f[R] with \f[V]core/quit\f[R].
|
||||
.PP
|
||||
There is currently no per-endpoint capability or scope system:
|
||||
authentication is all-or-nothing.
|
||||
Granting any access grants all of the above.
|
||||
.PP
|
||||
Consequently:
|
||||
.IP \[bu] 2
|
||||
\f[B]Do not bind the rc to a network address you do not control.\f[R]
|
||||
The default bind is loopback (\f[V]localhost:5572\f[R]); keep it there
|
||||
unless you have a specific reason to change it.
|
||||
.IP \[bu] 2
|
||||
\f[B]Do not use \f[VB]--rc-no-auth\f[B] on a non-loopback bind.\f[R] It
|
||||
disables authentication on the endpoints that access remotes \[em] see
|
||||
\f[V]--rc-no-auth\f[R].
|
||||
.IP \[bu] 2
|
||||
\f[B]Use authentication and TLS\f[R]
|
||||
(\f[V]--rc-user\f[R]/\f[V]--rc-pass\f[R] or \f[V]--rc-htpasswd\f[R],
|
||||
plus \f[V]--rc-cert\f[R]/\f[V]--rc-key\f[R]) whenever the port is
|
||||
reachable by anyone you do not fully trust, and raise
|
||||
\f[V]--rc-min-tls-version\f[R].
|
||||
.SS Supported parameters
|
||||
.SS --rc
|
||||
.PP
|
||||
@@ -25430,7 +25492,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 +30262,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.4\[dq])
|
||||
\f[R]
|
||||
.fi
|
||||
.SS Performance
|
||||
@@ -30863,8 +30946,10 @@ Backend-only flags (these can be set in the config file also).
|
||||
--local-case-sensitive Force the filesystem to report itself as case sensitive
|
||||
--local-description string Description of the remote
|
||||
--local-encoding Encoding The encoding for the backend (default Slash,Dot)
|
||||
--local-fatal-if-no-space Make out-of-space errors fatal during transfers
|
||||
--local-hashes CommaSepList Comma separated list of supported checksum types
|
||||
--local-links Translate symlinks to/from regular files with a \[aq].rclonelink\[aq] extension for the local backend
|
||||
--local-metadata-restore-special-bits Restore the setuid, setgid and sticky bits from metadata
|
||||
--local-no-check-updated Don\[aq]t check to see if the files change during upload
|
||||
--local-no-clone Disable reflink cloning for server-side copies
|
||||
--local-no-preallocate Disable preallocation of disk space for transferred files
|
||||
@@ -33477,10 +33562,37 @@ 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]TestGoogleCloudStorage,directory_markers\f[R]
|
||||
(\f[V]googlecloudstorage\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]TestBisyncRemoteLocal/all_changed\f[R] (https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage,directory_markers-1.txt)
|
||||
.IP \[bu] 2
|
||||
\f[V]TestBisyncRemoteLocal/backupdir\f[R] (https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage,directory_markers-1.txt)
|
||||
.IP \[bu] 2
|
||||
\f[V]TestBisyncRemoteLocal/basic\f[R] (https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage,directory_markers-1.txt)
|
||||
.IP \[bu] 2
|
||||
\f[V]TestBisyncRemoteLocal/changes\f[R] (https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage,directory_markers-1.txt)
|
||||
.IP \[bu] 2
|
||||
\f[V]TestBisyncRemoteLocal/check_access\f[R] (https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage,directory_markers-1.txt)
|
||||
.IP \[bu] 2
|
||||
79 more (https://pub.rclone.org/integration-tests/current/)
|
||||
.RE
|
||||
.IP \[bu] 2
|
||||
\f[V]TestGoogleCloudStorage\f[R] (\f[V]googlecloudstorage\f[R])
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
\f[V]TestBisyncRemoteLocal/all_changed\f[R] (https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage-1.txt)
|
||||
.IP \[bu] 2
|
||||
\f[V]TestBisyncRemoteLocal/backupdir\f[R] (https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage-1.txt)
|
||||
.IP \[bu] 2
|
||||
\f[V]TestBisyncRemoteLocal/basic\f[R] (https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage-1.txt)
|
||||
.IP \[bu] 2
|
||||
\f[V]TestBisyncRemoteLocal/changes\f[R] (https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage-1.txt)
|
||||
.IP \[bu] 2
|
||||
\f[V]TestBisyncRemoteLocal/check_access\f[R] (https://pub.rclone.org/integration-tests/current/googlecloudstorage-cmd.bisync-TestGoogleCloudStorage-1.txt)
|
||||
.IP \[bu] 2
|
||||
79 more (https://pub.rclone.org/integration-tests/current/)
|
||||
.RE
|
||||
.IP \[bu] 2
|
||||
\f[V]TestHuaweiDrive\f[R] (\f[V]huaweidrive\f[R])
|
||||
@@ -33490,16 +33602,16 @@ 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
|
||||
Updated: 2026-07-08-010014
|
||||
.PP
|
||||
The following backends either have not been tested recently or have
|
||||
known issues that are deemed unfixable for the time being:
|
||||
@@ -33646,6 +33758,12 @@ directory is to rename it to the same name on both sides.
|
||||
(As of \f[V]rclone v1.64\f[R], a \f[V]--resync\f[R] is no longer
|
||||
required after doing so, as bisync will automatically detect that Path1
|
||||
and Path2 are in agreement.)
|
||||
.PP
|
||||
Note that although the flag --track-renames ensures that renamed/moved
|
||||
files won\[aq]t be deleted and uploaded again, they are still counted as
|
||||
deleted files for purposes of the --max-delete flag (as this check
|
||||
happens before the rename detection operation).
|
||||
See this issue (https://github.com/rclone/rclone/issues/8685).
|
||||
.SS \f[V]--fast-list\f[R] used by default
|
||||
.PP
|
||||
Unlike most other rclone commands, bisync uses
|
||||
@@ -42935,7 +43053,7 @@ Cutoff for switching to multipart copy.
|
||||
Any files larger than this that need to be server-side copied will be
|
||||
copied in chunks of this size.
|
||||
.PP
|
||||
The minimum is 0 and the maximum is 5 GiB.
|
||||
The minimum is 1 byte and the maximum is 5 GiB.
|
||||
.PP
|
||||
Properties:
|
||||
.IP \[bu] 2
|
||||
@@ -56089,9 +56207,9 @@ This uses a 32 byte (256 bit key) key derived from the user password.
|
||||
.IP \[bu] 2
|
||||
32 bytes header
|
||||
.IP \[bu] 2
|
||||
16 chunks of 65568 bytes
|
||||
16 chunks of 65552 bytes
|
||||
.PP
|
||||
1049120 bytes total (a 0.05% overhead).
|
||||
1048864 bytes total (a 0.03% overhead).
|
||||
This is the overhead for big files.
|
||||
.SS Name encryption
|
||||
.PP
|
||||
@@ -61735,9 +61853,18 @@ However you can set this to restrict rclone to a specific folder
|
||||
hierarchy or to access data within the \[dq]Computers\[dq] tab on the
|
||||
drive web interface (where files from Google\[aq]s Backup and Sync
|
||||
desktop program go).
|
||||
However, this is not the easiest method.
|
||||
Instead, you can create a shortcut to a folder in \[dq]Computers\[dq]
|
||||
and place it in \[dq]My Drive.\[dq] To do so, right-click the folder,
|
||||
select \[dq]Organize\[dq], and then choose \[dq]Add shortcut\[dq] in the
|
||||
Google Drive web interface.
|
||||
Once you add the shortcut to \[dq]My Drive,\[dq] rclone will display the
|
||||
folder, allowing you to interact with it.
|
||||
See also Shortcuts.
|
||||
.PP
|
||||
In order to do this you will have to find the \f[V]Folder ID\f[R] of the
|
||||
directory you wish rclone to display.
|
||||
If, however, you choose to change your root folder, you will have to
|
||||
find the \f[V]Folder ID\f[R] of the directory you wish rclone to
|
||||
display.
|
||||
This will be the last segment of the URL when you open the relevant
|
||||
folder in the drive web interface.
|
||||
.PP
|
||||
@@ -61747,7 +61874,13 @@ in the browser, then you use \f[V]1XyfxxxxxxxxxxxxxxxxxxxxxxxxxKHCh\f[R]
|
||||
as the \f[V]root_folder_id\f[R] in the config.
|
||||
.PP
|
||||
\f[B]NB\f[R] folders under the \[dq]Computers\[dq] tab seem to be read
|
||||
only (drive gives a 500 error) when using rclone.
|
||||
only (drive gives a 500 error) when using rclone, but they are also
|
||||
read-only in the Google Drive web interface, likely because this folder
|
||||
is managed by the Google Drive Desktop tool.
|
||||
Top-level folders in \[dq]Computers\[dq] are read-only, but you can
|
||||
interact with folders contained within them using rclone.
|
||||
These are the folders for which you can create a shortcut as well, as
|
||||
described above.
|
||||
.PP
|
||||
There doesn\[aq]t appear to be an API to discover the folder IDs of the
|
||||
\[dq]Computers\[dq] tab - please contact us if you know otherwise!
|
||||
@@ -64356,6 +64489,26 @@ annoying to refresh constantly.
|
||||
If, for whatever reason, a short grant time is not a problem, then
|
||||
keeping the application in testing mode would also be sufficient.
|
||||
.PP
|
||||
In most cases verification is not actually required.
|
||||
Google exempts a number of app
|
||||
categories (https://support.google.com/cloud/answer/13464323) from
|
||||
mandatory verification, including:
|
||||
.IP \[bu] 2
|
||||
\f[B]Personal Use apps\f[R]: if the app is for your personal use (fewer
|
||||
than 100 users), you and your limited number of users can keep using it
|
||||
without verification - you will just need to click through the
|
||||
\[dq]unverified app\[dq] warning screen during sign-in.
|
||||
Verification is only required if you want to grow your user base beyond
|
||||
100 users.
|
||||
.IP \[bu] 2
|
||||
\f[B]Development/Testing/Staging apps\f[R]: apps in development, testing
|
||||
or staging mode are not subject to verification (but are limited to the
|
||||
100-user cap and the unverified-app warning until verified).
|
||||
.PP
|
||||
So for typical personal rclone use you can leave the app unverified,
|
||||
accept the warning screen, and publish it (rather than leaving it in
|
||||
\[dq]Testing\[dq]) to avoid the weekly grant expiry described above.
|
||||
.PP
|
||||
(Thanks to \[at]balazer on github for these instructions.)
|
||||
.PP
|
||||
Sometimes, creation of an OAuth consent in Google API Console fails due
|
||||
@@ -89494,6 +89647,36 @@ backends and the VFS.
|
||||
.PP
|
||||
Note that this flag is incompatible with \f[V]-copy-links\f[R] /
|
||||
\f[V]-L\f[R].
|
||||
.SS Symlink targets and the destination
|
||||
.PP
|
||||
When rclone recreates a \f[V].rclonelink\f[R] file as a symlink on local
|
||||
storage, the symlink can point anywhere - including, with an absolute
|
||||
path or one using \f[V]../\f[R] - to a location outside the directory
|
||||
you are copying into.
|
||||
This is normal - rclone reproduces whatever target the link had, so
|
||||
backups round-trip faithfully.
|
||||
.PP
|
||||
What rclone will \f[B]not\f[R] do is \f[I]write through\f[R] such a
|
||||
link.
|
||||
If a remote you are copying from contains both a symlink and a file or
|
||||
directory that would be placed inside it - for example a
|
||||
\f[V]dir.rclonelink\f[R] pointing somewhere outside the destination,
|
||||
alongside a \f[V]dir/file.txt\f[R] - rclone refuses to follow the
|
||||
symlink when writing \f[V]dir/file.txt\f[R].
|
||||
The offending file is skipped with an error, the rest of the transfer
|
||||
continues, and the skipped file is counted in the error summary printed
|
||||
at the end of the run.
|
||||
.PP
|
||||
This protects you from a malicious or compromised remote using
|
||||
\f[V]-l\f[R] / \f[V]--links\f[R] to plant a symlink and then write
|
||||
through it to somewhere outside your destination.
|
||||
Ordinary symlink round-trips, and symlinks that stay inside the
|
||||
destination, are unaffected.
|
||||
.PP
|
||||
If you have intentionally pre-created a symlinked directory inside your
|
||||
destination and want rclone to write into the directory it points at, do
|
||||
not use \f[V]-l\f[R] / \f[V]--links\f[R] for that copy, or remove the
|
||||
symlink first.
|
||||
.SS Restricting filesystems with --one-file-system
|
||||
.PP
|
||||
Normally rclone will recurse through filesystems as mounted.
|
||||
@@ -89867,6 +90050,53 @@ Env Var: RCLONE_LOCAL_NO_SET_MODTIME
|
||||
Type: bool
|
||||
.IP \[bu] 2
|
||||
Default: false
|
||||
.SS --local-metadata-restore-special-bits
|
||||
.PP
|
||||
Restore the setuid, setgid and sticky bits from metadata.
|
||||
.PP
|
||||
When restoring metadata with --metadata rclone applies the
|
||||
\[dq]mode\[dq] from the source.
|
||||
By default rclone applies only the permission bits and strips the
|
||||
setuid, setgid and sticky bits.
|
||||
.PP
|
||||
The \[dq]mode\[dq] comes from the source remote which may not be
|
||||
trusted.
|
||||
Restoring a setuid or setgid bit onto freshly written, source-controlled
|
||||
content can plant a setuid binary, which is dangerous in particular when
|
||||
restoring from an untrusted source while running as root.
|
||||
For this reason these bits are not restored by default.
|
||||
.PP
|
||||
If you trust the source and want the setuid, setgid and sticky bits
|
||||
restored - for example when restoring a system backup made by rclone -
|
||||
set this flag.
|
||||
.PP
|
||||
Properties:
|
||||
.IP \[bu] 2
|
||||
Config: metadata_restore_special_bits
|
||||
.IP \[bu] 2
|
||||
Env Var: RCLONE_LOCAL_METADATA_RESTORE_SPECIAL_BITS
|
||||
.IP \[bu] 2
|
||||
Type: bool
|
||||
.IP \[bu] 2
|
||||
Default: false
|
||||
.SS --local-fatal-if-no-space
|
||||
.PP
|
||||
Make out-of-space errors fatal during transfers.
|
||||
.PP
|
||||
When enabled, an ENOSPC error during a write returns a fatal error so
|
||||
that rclone aborts rather than retrying the operation.
|
||||
Useful for backup scripts that should halt loudly on a full disk rather
|
||||
than spin retrying.
|
||||
.PP
|
||||
Properties:
|
||||
.IP \[bu] 2
|
||||
Config: fatal_if_no_space
|
||||
.IP \[bu] 2
|
||||
Env Var: RCLONE_LOCAL_FATAL_IF_NO_SPACE
|
||||
.IP \[bu] 2
|
||||
Type: bool
|
||||
.IP \[bu] 2
|
||||
Default: false
|
||||
.SS --local-time-type
|
||||
.PP
|
||||
Set what kind of time is returned.
|
||||
@@ -89986,6 +90216,14 @@ supported by all file systems) under the \[dq]user.*\[dq] prefix.
|
||||
.PP
|
||||
Metadata is supported on files and directories.
|
||||
.PP
|
||||
When restoring metadata with \f[V]--metadata\f[R] rclone applies the
|
||||
\[dq]mode\[dq], \[dq]uid\[dq] and \[dq]gid\[dq] from the source.
|
||||
These come from the source remote which may not be trusted, so restoring
|
||||
metadata as root from an untrusted source can change file ownership and
|
||||
is not recommended.
|
||||
The setuid, setgid and sticky bits are not restored by default - see the
|
||||
\f[V]--local-metadata-restore-special-bits\f[R] flag.
|
||||
.PP
|
||||
Here are the possible system metadata items for the local backend.
|
||||
.PP
|
||||
.TS
|
||||
@@ -90121,6 +90359,261 @@ Options:
|
||||
.IP \[bu] 2
|
||||
\[dq]error\[dq]: Return an error based on option value.
|
||||
.SH Changelog
|
||||
.SS v1.74.4 - 2026-07-08
|
||||
.PP
|
||||
See commits (https://github.com/rclone/rclone/compare/v1.74.3...v1.74.4)
|
||||
.IP \[bu] 2
|
||||
Bug Fixes
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
accounting
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
Fix goroutine leak in ResetCounters (Nick Craig-Wood)
|
||||
.IP \[bu] 2
|
||||
Fix goroutine leak in NewStatsGroup for zero-transfer rc jobs
|
||||
(Sanjays2402)
|
||||
.RE
|
||||
.IP \[bu] 2
|
||||
archive extract: Fix path traversal letting archives escape the
|
||||
destination CVE-2026-59732 (Nick Craig-Wood)
|
||||
.IP \[bu] 2
|
||||
build
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
Fix multiple CVEs by upgrading to go1.26.5 (Nick Craig-Wood)
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
CVE-2026-39822: os: Root escape via symlink plus trailing slash
|
||||
.IP \[bu] 2
|
||||
CVE-2026-42505: crypto/tls: Encrypted Client Hello privacy leak
|
||||
.RE
|
||||
.IP \[bu] 2
|
||||
Update golang.org/x/image to v0.43.0 to fix image decoding
|
||||
vulnerabilities (Nick Craig-Wood)
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
CVE-2026-46604: panic decoding a TIFF image with an out-of-bounds strip
|
||||
offset
|
||||
.IP \[bu] 2
|
||||
CVE-2026-46602: unbounded memory use from lack of a limit on TIFF tile
|
||||
sizes
|
||||
.IP \[bu] 2
|
||||
CVE-2026-46601: panic on a WEBP VP8 alpha channel size mismatch
|
||||
.IP \[bu] 2
|
||||
CVE-2026-33813: panic decoding a large WEBP image on 32-bit platforms
|
||||
.RE
|
||||
.RE
|
||||
.IP \[bu] 2
|
||||
cmd/mount2
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
Fix NFS file creation by implementing Mknod (Sandy Luppino)
|
||||
.IP \[bu] 2
|
||||
Fix ESTALE over NFS by reporting stable inode numbers (Sandy Luppino)
|
||||
.IP \[bu] 2
|
||||
Fix NFS directory listings by supporting non-zero Seekdir offsets (Sandy
|
||||
Luppino)
|
||||
.RE
|
||||
.IP \[bu] 2
|
||||
completion: Fix powershell completion corrupting non-ASCII names (Yash
|
||||
Anil)
|
||||
.IP \[bu] 2
|
||||
doc fixes (Bryan Stenson, Castronaut, Filippo, Gaurav, happysnaker,
|
||||
Jan-Philipp Reßler, Nick Craig-Wood, user77)
|
||||
.IP \[bu] 2
|
||||
filter: Fix \f[V]--files-from\f[R] copy stopping at the first unreadable
|
||||
file (Nick Craig-Wood)
|
||||
.IP \[bu] 2
|
||||
fs
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
Fix command line flag being ignored when set to its default value (Nick
|
||||
Craig-Wood)
|
||||
.IP \[bu] 2
|
||||
Fix negative offset when a suffix Range request exceeds object size
|
||||
(Amit Mishra)
|
||||
.RE
|
||||
.IP \[bu] 2
|
||||
gui: Update embedded release to 1.1.10 (Nick Craig-Wood)
|
||||
.IP \[bu] 2
|
||||
ncdu: Fix duplicated keystrokes on Windows by pinning tcell to v2.9.0
|
||||
(Nick Craig-Wood)
|
||||
.IP \[bu] 2
|
||||
serve restic: Fix \f[V]--private-repos\f[R] isolation bypass
|
||||
CVE-2026-59733 (Nick Craig-Wood)
|
||||
.IP \[bu] 2
|
||||
serve s3
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
Fix spurious 404 on HEAD/GET during VFS writeback (max)
|
||||
.IP \[bu] 2
|
||||
Fix path traversal letting clients see files in the root
|
||||
GHSA-8v25-v8p6-qf7v (Nick Craig-Wood)
|
||||
.RE
|
||||
.IP \[bu] 2
|
||||
serve webdav: Fix MOVE overwrite failing without Overwrite header
|
||||
(Sanjay Santhanam)
|
||||
.IP \[bu] 2
|
||||
serve/http: Fix \f[V]--disable-zip\f[R] so it works over rc (Nick
|
||||
Craig-Wood)
|
||||
.RE
|
||||
.IP \[bu] 2
|
||||
VFS
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
Fix hang reopening a file during the handle-caching grace period (Nick
|
||||
Craig-Wood)
|
||||
.RE
|
||||
.IP \[bu] 2
|
||||
Local
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
Stop \f[V]--links\f[R] symlinks escaping the destination directory
|
||||
CVE-2026-54572 (Nick Craig-Wood)
|
||||
.IP \[bu] 2
|
||||
Don\[aq]t restore setuid/setgid/sticky bits from metadata by default
|
||||
GHSA-945v-v9p3-v5xw (Nick Craig-Wood)
|
||||
.RE
|
||||
.IP \[bu] 2
|
||||
Drive
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
Warn when non-exportable Google documents are skipped (Nick Craig-Wood)
|
||||
.IP \[bu] 2
|
||||
Fix stray %!(EXTRA) in unexportable google document log message (Nick
|
||||
Craig-Wood)
|
||||
.IP \[bu] 2
|
||||
Warn when using rclone\[aq]s shared client_id (Nick Craig-Wood)
|
||||
.RE
|
||||
.IP \[bu] 2
|
||||
Filelu
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
Fix recursive listing path handling and file filtering (kingston125)
|
||||
.RE
|
||||
.IP \[bu] 2
|
||||
Googlephotos
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
Warn when using rclone\[aq]s shared client_id (Nick Craig-Wood)
|
||||
.RE
|
||||
.IP \[bu] 2
|
||||
Mega
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
Wait for server events after upload, delete and move (Nick Craig-Wood)
|
||||
.IP \[bu] 2
|
||||
Fix hard deleted files reappearing in listings (Nick Craig-Wood)
|
||||
.RE
|
||||
.IP \[bu] 2
|
||||
S3
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
Remove session token on cross-host redirects (IceLocke)
|
||||
.IP \[bu] 2
|
||||
Strip STS security token on same-host HTTPS->HTTP redirect
|
||||
GHSA-cf44-9pgv-m4xc (Nick Craig-Wood)
|
||||
.IP \[bu] 2
|
||||
Fix error mapping in GetObject to match HeadObject (lewoberst)
|
||||
.IP \[bu] 2
|
||||
Correct documented \f[V]copy_cutoff\f[R] minimum to 1 byte (max)
|
||||
.IP \[bu] 2
|
||||
Fix mounting a prefix failing with 403 when HEAD is not permitted (Nick
|
||||
Craig-Wood)
|
||||
.RE
|
||||
.IP \[bu] 2
|
||||
Smb
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
Fix for IBM iSeries and signature verification (dithwick)
|
||||
.RE
|
||||
.IP \[bu] 2
|
||||
WebDAV
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
Fix mixed property statuses in multi-status responses (nako-ruru)
|
||||
.RE
|
||||
.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)
|
||||
|
||||
@@ -69,6 +69,7 @@ type Item struct {
|
||||
modified bool // set if the file has been modified since the last Open
|
||||
beingReset bool // cache cleaner is resetting the cache file, access not allowed
|
||||
graceTimer *time.Timer // timer for delayed close after grace period
|
||||
closing chan struct{} // non-nil while a grace-period close is tearing the handle down, closed when done
|
||||
}
|
||||
|
||||
// Info is persisted to backing store
|
||||
@@ -520,6 +521,15 @@ func (item *Item) open(o fs.Object) (err error) {
|
||||
item.mu.Lock()
|
||||
defer item.mu.Unlock()
|
||||
|
||||
// Wait for any in-progress grace-period close to finish so we start
|
||||
// from a fully closed item rather than racing the fd teardown.
|
||||
for item.closing != nil {
|
||||
closing := item.closing
|
||||
item.mu.Unlock()
|
||||
<-closing
|
||||
item.mu.Lock()
|
||||
}
|
||||
|
||||
item.info.ATime = time.Now()
|
||||
|
||||
osPath, err := item.c.createItemDir(item.name) // No locking in Cache
|
||||
@@ -714,7 +724,14 @@ func (item *Item) closeAfterGrace() {
|
||||
}
|
||||
item.graceTimer = nil
|
||||
|
||||
// _actualClose drops item.mu while it tears down the downloaders,
|
||||
// during which the fd is still open. Publish that a close is in
|
||||
// progress so a concurrent open waits rather than tripping over the
|
||||
// half-closed handle.
|
||||
item.closing = make(chan struct{})
|
||||
err := item._actualClose(nil, false)
|
||||
close(item.closing)
|
||||
item.closing = nil
|
||||
if err != nil {
|
||||
fs.Errorf(item.name, "vfs cache: close after grace period failed: %v", err)
|
||||
}
|
||||
|
||||
Loaded 100 of 104 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user