From e2d1cbfe7139bf39e498fe16c73573852c679a64 Mon Sep 17 00:00:00 2001 From: Cole Wippern Date: Fri, 10 Jan 2020 13:07:50 -0800 Subject: [PATCH] Fix #647 Copy dir permissions * update otiai10 to latest version which has correct permission logic --- go.mod | 3 +-- go.sum | 2 ++ vendor/github.com/otiai10/copy/.gitignore | 1 + vendor/github.com/otiai10/copy/copy.go | 15 ++++++++++++++- vendor/github.com/otiai10/copy/go.mod | 5 +++++ vendor/github.com/otiai10/copy/go.sum | 3 +++ vendor/modules.txt | 2 +- 7 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 vendor/github.com/otiai10/copy/go.mod create mode 100644 vendor/github.com/otiai10/copy/go.sum diff --git a/go.mod b/go.mod index c28e5dc2d..47c583a23 100644 --- a/go.mod +++ b/go.mod @@ -71,8 +71,7 @@ require ( github.com/opencontainers/runtime-spec v1.0.1 // indirect github.com/opencontainers/selinux v1.0.0-rc1 // indirect github.com/opentracing/opentracing-go v1.0.2 // indirect - github.com/otiai10/copy v0.0.0-20180813032824-7e9a647135a1 - github.com/otiai10/mint v1.3.0 // indirect + github.com/otiai10/copy v1.0.2 github.com/pborman/uuid v1.2.0 // indirect github.com/pelletier/go-buffruneio v0.2.0 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect diff --git a/go.sum b/go.sum index fde49dfca..32b35ffad 100644 --- a/go.sum +++ b/go.sum @@ -176,6 +176,8 @@ github.com/opentracing/opentracing-go v1.0.2 h1:3jA2P6O1F9UOrWVpwrIo17pu01KWvNWg github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/otiai10/copy v0.0.0-20180813032824-7e9a647135a1 h1:A7kMXwDPBTfIVRv2l6XV3U6Su3SzLUzZjxnDDQVZDIY= github.com/otiai10/copy v0.0.0-20180813032824-7e9a647135a1/go.mod h1:pXzZSDlN+HPzSdyIBnKNN9ptD9Hx7iZMWIJPTwo4FPE= +github.com/otiai10/copy v1.0.2 h1:DDNipYy6RkIkjMwy+AWzgKiNTyj2RUI9yEMeETEpVyc= +github.com/otiai10/copy v1.0.2/go.mod h1:c7RpqBkwMom4bYTSkLSym4VSJz/XtncWRAj/J4PEIMY= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95 h1:+OLn68pqasWca0z5ryit9KGfp3sUsW4Lqg32iRMJyzs= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= github.com/otiai10/mint v1.3.0 h1:Ady6MKVezQwHBkGzLFbrsywyp09Ah7rkmfjV3Bcr5uc= diff --git a/vendor/github.com/otiai10/copy/.gitignore b/vendor/github.com/otiai10/copy/.gitignore index 686ec2df3..5b5ae0a52 100644 --- a/vendor/github.com/otiai10/copy/.gitignore +++ b/vendor/github.com/otiai10/copy/.gitignore @@ -1,2 +1,3 @@ testdata.copy coverage.txt +vendor diff --git a/vendor/github.com/otiai10/copy/copy.go b/vendor/github.com/otiai10/copy/copy.go index 9e0b09162..52afac483 100644 --- a/vendor/github.com/otiai10/copy/copy.go +++ b/vendor/github.com/otiai10/copy/copy.go @@ -7,6 +7,13 @@ import ( "path/filepath" ) +const ( + // tmpPermissionForDirectory makes the destination directory writable, + // so that stuff can be copied recursively even if any original directory is NOT writable. + // See https://github.com/otiai10/copy/pull/9 for more information. + tmpPermissionForDirectory = os.FileMode(0755) +) + // Copy copies src to dest, doesn't matter if src is a directory or a file func Copy(src, dest string) error { info, err := os.Lstat(src) @@ -63,9 +70,14 @@ func fcopy(src, dest string, info os.FileInfo) error { // and pass everything to "copy" recursively. func dcopy(srcdir, destdir string, info os.FileInfo) error { - if err := os.MkdirAll(destdir, info.Mode()); err != nil { + originalMode := info.Mode() + + // Make dest dir with 0755 so that everything writable. + if err := os.MkdirAll(destdir, tmpPermissionForDirectory); err != nil { return err } + // Recover dir mode with original one. + defer os.Chmod(destdir, originalMode) contents, err := ioutil.ReadDir(srcdir) if err != nil { @@ -79,6 +91,7 @@ func dcopy(srcdir, destdir string, info os.FileInfo) error { return err } } + return nil } diff --git a/vendor/github.com/otiai10/copy/go.mod b/vendor/github.com/otiai10/copy/go.mod new file mode 100644 index 000000000..b560f3247 --- /dev/null +++ b/vendor/github.com/otiai10/copy/go.mod @@ -0,0 +1,5 @@ +module github.com/otiai10/copy + +go 1.12 + +require github.com/otiai10/mint v1.3.0 diff --git a/vendor/github.com/otiai10/copy/go.sum b/vendor/github.com/otiai10/copy/go.sum new file mode 100644 index 000000000..f34949038 --- /dev/null +++ b/vendor/github.com/otiai10/copy/go.sum @@ -0,0 +1,3 @@ +github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= +github.com/otiai10/mint v1.3.0 h1:Ady6MKVezQwHBkGzLFbrsywyp09Ah7rkmfjV3Bcr5uc= +github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= diff --git a/vendor/modules.txt b/vendor/modules.txt index 512e27ecf..333d0f166 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -331,7 +331,7 @@ github.com/opencontainers/selinux/go-selinux/label github.com/opentracing/opentracing-go github.com/opentracing/opentracing-go/ext github.com/opentracing/opentracing-go/log -# github.com/otiai10/copy v0.0.0-20180813032824-7e9a647135a1 +# github.com/otiai10/copy v1.0.2 github.com/otiai10/copy # github.com/pelletier/go-buffruneio v0.2.0 github.com/pelletier/go-buffruneio