[ARVADOS] created: 1.1.2-1-g11377b3
Git user
git at public.curoverse.com
Thu Dec 21 10:23:24 EST 2017
at 11377b3b6eb9544b9d9bcabab8de495f6e6fcaa4 (commit)
commit 11377b3b6eb9544b9d9bcabab8de495f6e6fcaa4
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date: Thu Dec 21 10:21:04 2017 -0500
12844: Refuse to unreference a directory by moving it into itself.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>
diff --git a/sdk/go/arvados/collection_fs.go b/sdk/go/arvados/collection_fs.go
index 7bbbaa4..d8ee2a2 100644
--- a/sdk/go/arvados/collection_fs.go
+++ b/sdk/go/arvados/collection_fs.go
@@ -1078,6 +1078,10 @@ func (dn *dirnode) Rename(oldname, newname string) error {
if !ok {
return os.ErrNotExist
}
+ if locked[oldinode] {
+ // oldinode cannot become a descendant of itself.
+ return ErrInvalidArgument
+ }
if existing, ok := newdn.inodes[newname]; ok {
// overwriting an existing file or dir
if dn, ok := existing.(*dirnode); ok {
diff --git a/sdk/go/arvados/collection_fs_test.go b/sdk/go/arvados/collection_fs_test.go
index 57ba325..bd5d08b 100644
--- a/sdk/go/arvados/collection_fs_test.go
+++ b/sdk/go/arvados/collection_fs_test.go
@@ -599,6 +599,30 @@ func (s *CollectionFSSuite) TestRemove(c *check.C) {
c.Check(err, check.IsNil)
}
+func (s *CollectionFSSuite) TestRenameError(c *check.C) {
+ fs, err := (&Collection{}).FileSystem(s.client, s.kc)
+ c.Assert(err, check.IsNil)
+ err = fs.Mkdir("first", 0755)
+ c.Assert(err, check.IsNil)
+ err = fs.Mkdir("first/second", 0755)
+ c.Assert(err, check.IsNil)
+ f, err := fs.OpenFile("first/second/file", os.O_CREATE|os.O_WRONLY, 0755)
+ c.Assert(err, check.IsNil)
+ f.Write([]byte{1, 2, 3, 4, 5})
+ f.Close()
+ err = fs.Rename("first", "first/second/third")
+ c.Check(err, check.Equals, ErrInvalidArgument)
+ err = fs.Rename("first", "first/third")
+ c.Check(err, check.Equals, ErrInvalidArgument)
+ err = fs.Rename("first/second", "second")
+ c.Check(err, check.IsNil)
+ f, err = fs.OpenFile("second/file", 0, 0)
+ c.Assert(err, check.IsNil)
+ data, err := ioutil.ReadAll(f)
+ c.Check(err, check.IsNil)
+ c.Check(data, check.DeepEquals, []byte{1, 2, 3, 4, 5})
+}
+
func (s *CollectionFSSuite) TestRename(c *check.C) {
fs, err := (&Collection{}).FileSystem(s.client, s.kc)
c.Assert(err, check.IsNil)
diff --git a/services/keep-web/cadaver_test.go b/services/keep-web/cadaver_test.go
index d4a89c8..eb32367 100644
--- a/services/keep-web/cadaver_test.go
+++ b/services/keep-web/cadaver_test.go
@@ -133,6 +133,17 @@ func (s *IntegrationSuite) TestWebdavWithCadaver(c *check.C) {
},
{
path: writePath,
+ cmd: "move newdir1 newdir1/\n",
+ match: `(?ms).*Moving .* failed.*`,
+ },
+ {
+ path: writePath,
+ cmd: "get newdir1/testfile '" + checkfile.Name() + "'\n",
+ match: `(?ms).*succeeded.*`,
+ data: testdata,
+ },
+ {
+ path: writePath,
cmd: "put '" + localfile.Name() + "' newdir1/testfile1\n",
match: `(?ms).*Uploading .* succeeded.*`,
},
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list