Compare commits

...
Author SHA1 Message Date
Nick Craig-Wood e426492549 local: fix hang listing the root of a Windows network share - fixes #10280
Since v1.75.0 using a bare UNC share such as \\server\share as the
root of a local remote hung forever on Windows.

This was caused by the check that names stay inside the root. This
calls filepath.Rel which never returns on Windows when the base is a
bare UNC share and the target is the same share with a trailing
separator, which is what filepath.Join makes of the root and "".

This fixes it by treating the root and the root with a trailing
separator as the root itself without calling filepath.Rel.
2026-11-07 18:56:55 +00:00
Nick Craig-Wood 82cb84b201 Start v1.77.0-DEV development 2026-11-06 16:31:22 +00:00
Nick Craig-Wood 7d9963121a build: stop the librclone tests marking the Linux release binaries as modified
librclone/python/test_rclone.py builds ./librclone.so with
-buildmode=c-shared, which also writes librclone.h. The test removes
the .so but not the header, so the CI Linux job built the release
binaries from a tree with an untracked file and they reported
vcs.modified=true in their build info.

Ignore librclone.h so it no longer counts as a modification.
2026-11-06 15:57:32 +00:00
Nick Craig-Wood 98d4e8f369 build: stop make fetch_binaries downloading the beta site's index files
The beta site now has index.html and index.json directory listings
made by rclone index. fetch_binaries copied them into build/ where
make upload and make upload_github would have published them with the
release.
2026-11-06 15:52:50 +00:00
Nick Craig-Wood ea9f816061 docs: wait for CI on master to pass before pushing the release tag
Commits which were only local, such as security fixes, aren't tested
by CI until master is pushed. Pushing the tag at the same time meant a
CI failure in them could stop the release binaries being built, which
happened for the Windows build of v1.76.0.
2026-11-06 15:46:29 +00:00
Nick Craig-Wood dfbe3ae1d0 lib/http: fix auth timing tests failing on Windows
The tests timed one rejection at a time, but checking a --user/--pass
password takes less than the resolution of the clock on Windows, so
the known and unknown users both measured 0s and the comparison
failed.

Time many rejections with testing.Benchmark instead, which runs
enough of them to measure on a coarse clock.
2026-11-06 15:39:27 +00:00
Nick Craig-Wood 6a4b77208e local: fix TestRemoveThroughPlantedSymlinkBlocked failing on Windows
On Windows os.Root.Symlink always makes a file symlink when the
target is an absolute path outside the root, and Windows can't
traverse a file symlink as a directory. The planted link can't reach
the outside files, so the test failed setting up the attack with "The
filename, directory name, or volume label syntax is incorrect".

Skip the test on Windows as the other planted symlink tests do.
2026-11-06 15:39:27 +00:00
10 changed files with 87 additions and 25 deletions

No files matched your search

+1
View File
@@ -19,5 +19,6 @@ Thumbs.db
__pycache__
.DS_Store
resource_windows_*.syso
/librclone.h
.devcontainer
/cmd/bisync/testdata/bisync_vscode_debuggers_launch.json
+1 -1
View File
@@ -285,7 +285,7 @@ endif
# Fetch the binary builds from GitHub actions
fetch_binaries:
rclone -P sync --exclude "/testbuilds/**" --delete-excluded $(BETA_UPLOAD) build/
rclone -P sync --exclude "/testbuilds/**" --exclude "/index.{html,json}" --delete-excluded $(BETA_UPLOAD) build/
serve: website
cd docs && hugo server --logLevel info -w --disableFastRender --ignoreCache
+7 -3
View File
@@ -32,10 +32,14 @@ This file describes how to make the various kinds of releases
- git commit -a -v -m "Version v1.XX.0"
- make check # if this fails, fix, git commit --amend and run it again
- make retag # moves the tag onto the Version commit
- git push origin # without --follow-tags so it doesn't push the tag if it fails
- git push origin # without --follow-tags so it doesn't push the tag yet
- Wait for the GitHub actions build of master to complete and check it is
green - this is the first time CI sees any commits which were only local,
such as security fixes, so it must pass before the tag is pushed
- if it fails: fix, git commit, make retag, git push origin and wait again
- git push --follow-tags origin
- \# Wait for the GitHub builds to complete then...
- \# Don't commit anything until after make upload_github as these steps
- \# Wait for the GitHub builds of the tag to complete then...
- \# Don't commit or push anything until after make upload_github as these steps
use the tag on HEAD to find the version
- make fetch_binaries
- make tarball
+1 -1
View File
@@ -1 +1 @@
v1.76.0
v1.77.0
+14 -2
View File
@@ -887,13 +887,25 @@ func (f *Fs) nativePath(name string) string {
// happen depending on the encoding.
func (f *Fs) localPath(name string) (string, error) {
localPath := filepath.Join(f.root, f.nativePath(name))
rel, err := filepath.Rel(f.root, localPath)
rel, err := f.relToRoot(localPath)
if err != nil || rel == ".." || strings.HasPrefix(rel, ".."+string(filepath.Separator)) {
return "", fserrors.NoRetryError(fmt.Errorf("%q: %w", name, errPathEscapes))
}
return localPath, nil
}
// relToRoot returns localPath relative to f.root.
func (f *Fs) relToRoot(localPath string) (string, error) {
// On Windows filepath.Rel loops forever if the base is a bare UNC
// share and the target is the same share with a trailing
// separator, eg `\\server\share` and `\\server\share\`, which is
// what filepath.Join makes of f.root and "".
if localPath == f.root || localPath == f.root+string(filepath.Separator) {
return ".", nil
}
return filepath.Rel(f.root, localPath)
}
// Put the Object to the local filesystem
func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error) {
// Temporary Object under construction - info filled in by Update()
@@ -1594,7 +1606,7 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.Read
// 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)
rel, err = f.relToRoot(localPath)
if err != nil {
return nil, "", err
}
+6
View File
@@ -597,6 +597,12 @@ func TestMkdirMetadataThroughPlantedSymlinkBlocked(t *testing.T) {
// TestRemoveThroughPlantedSymlinkBlocked checks Remove and Rmdir can't
// delete anything outside the root through a planted symlink.
func TestRemoveThroughPlantedSymlinkBlocked(t *testing.T) {
if runtime.GOOS == "windows" {
// os.Root.Symlink makes a file symlink to a directory outside
// the root, which Windows can't traverse, so the planted link
// can't reach the outside files.
t.Skip("planted directory symlinks can't be traversed on Windows")
}
skipIfNoSymlinks(t)
ctx := context.Background()
@@ -8,6 +8,7 @@ import (
"runtime"
"syscall"
"testing"
"time"
"github.com/rclone/rclone/fs/operations"
"github.com/rclone/rclone/fstest"
@@ -38,3 +39,36 @@ func TestRmdirWindows(t *testing.T) {
err = operations.Rmdir(context.Background(), r.Flocal, "testdir")
assert.NoError(t, err)
}
// TestLocalPathUNCShareRoot checks localPath works when the root is a
// bare UNC share, where filepath.Rel would never return.
func TestLocalPathUNCShareRoot(t *testing.T) {
for _, root := range []string{`\\server\share`, `\\?\UNC\server\share`} {
f := &Fs{root: root}
for _, test := range []struct {
name string
want string
}{
{name: "", want: root + `\`},
{name: "file.txt", want: root + `\file.txt`},
{name: "sub/file.txt", want: root + `\sub\file.txt`},
} {
type result struct {
path string
err error
}
done := make(chan result, 1)
go func() {
path, err := f.localPath(test.name)
done <- result{path, err}
}()
select {
case res := <-done:
require.NoError(t, res.err, root, test.name)
assert.Equal(t, test.want, res.path, root, test.name)
case <-time.After(10 * time.Second):
t.Fatalf("localPath(%q) with root %q did not return", test.name, root)
}
}
}
}
+1 -1
View File
@@ -1 +1 @@
v1.76.0
v1.77.0
+1 -1
View File
@@ -1,4 +1,4 @@
package fs
// VersionTag of rclone
var VersionTag = "v1.76.0"
var VersionTag = "v1.77.0"
+21 -16
View File
@@ -245,23 +245,28 @@ func TestMiddlewareAuth(t *testing.T) {
}
}
// minAuthTime returns the shortest time handler took to reject user
// with a wrong password over a few attempts.
func minAuthTime(t *testing.T, handler http.Handler, user string) time.Duration {
var best time.Duration
for i := range 10 {
// authTime returns the average time handler takes to reject user with
// a wrong password.
//
// It times many attempts with testing.Benchmark rather than timing them
// one at a time as a single rejection can take less than the resolution
// of the clock on Windows.
func authTime(t *testing.T, handler http.Handler, user string) time.Duration {
t.Helper()
reject := func() int {
req := httptest.NewRequest("GET", "/", nil)
req.SetBasicAuth(user, "definitely-wrong-password")
rec := httptest.NewRecorder()
start := time.Now()
handler.ServeHTTP(rec, req)
elapsed := time.Since(start)
require.Equal(t, http.StatusUnauthorized, rec.Code)
if i == 0 || elapsed < best {
best = elapsed
}
return rec.Code
}
return best
require.Equal(t, http.StatusUnauthorized, reject())
result := testing.Benchmark(func(b *testing.B) {
for b.Loop() {
reject()
}
})
return time.Duration(result.NsPerOp())
}
// Rejecting an unknown user must take about as long as rejecting a
@@ -269,16 +274,16 @@ func minAuthTime(t *testing.T, handler http.Handler, user string) time.Duration
// users exist.
func TestMiddlewareAuthHtpasswdUnknownUserTiming(t *testing.T) {
handler := MiddlewareAuthHtpasswd("./testdata/.htpasswd", "test")(testEchoHandler([]byte("ok")))
known := minAuthTime(t, handler, "bcrypt")
unknown := minAuthTime(t, handler, "nosuchuser")
known := authTime(t, handler, "bcrypt")
unknown := authTime(t, handler, "nosuchuser")
assert.Greater(t, unknown, known/4, "unknown user rejected in %v but known user in %v", unknown, known)
}
// As TestMiddlewareAuthHtpasswdUnknownUserTiming but for --user/--pass
func TestMiddlewareAuthBasicUnknownUserTiming(t *testing.T) {
handler := MiddlewareAuthBasic("user", "pass", "test", "dlPL2MqE")(testEchoHandler([]byte("ok")))
known := minAuthTime(t, handler, "user")
unknown := minAuthTime(t, handler, "nosuchuser")
known := authTime(t, handler, "user")
unknown := authTime(t, handler, "nosuchuser")
assert.Greater(t, unknown, known/4, "unknown user rejected in %v but known user in %v", unknown, known)
req := httptest.NewRequest("GET", "/", nil)