| 1 | //go:build !windows |
| 2 | // +build !windows |
| 3 | |
| 4 | package fsscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/ |
| 5 | |
| 6 | import ( |
| 7 | "contextscip-go gomod github.com/golang/go/src go1.21 context/" |
| 8 | "osscip-go gomod github.com/golang/go/src go1.21 os/" |
| 9 | "path/filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/" |
| 10 | "syscallscip-go gomod github.com/golang/go/src go1.21 syscall/" |
| 11 | "testingscip-go gomod github.com/golang/go/src go1.21 testing/" |
| 12 | |
| 13 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/" |
| 14 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/" |
| 15 | "golang.org/x/sys/unixscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/" |
| 16 | ) |
| 17 | |
| 18 | func TestCopyDevicesAndFifoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/TestCopyDevicesAndFifo().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) { |
| 19 | requiresRootscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/requiresRoot().(t) |
| 20 | |
| 21 | t1 := t.TempDirscip-go gomod github.com/golang/go/src go1.21 testing/common#TempDir().() |
| 22 | |
| 23 | err := mknodscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/mknod().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(t1, "char"), unixscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/.S_IFCHRscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/S_IFCHR.|0444, int(unixscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/.Mkdevscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/Mkdev().(1, 9))) |
| 24 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 25 | |
| 26 | err = mknodscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/mknod().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(t1, "block"), unixscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/.S_IFBLKscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/S_IFBLK.|0441, int(unixscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/.Mkdevscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/Mkdev().(3, 2))) |
| 27 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 28 | |
| 29 | err = mknodscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/mknod().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(t1, "socket"), unixscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/.S_IFSOCKscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/S_IFSOCK.|0555, 0) |
| 30 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 31 | |
| 32 | err = unixscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/.Mkfifoscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/Mkfifo().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(t1, "fifo"), 0555) |
| 33 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 34 | |
| 35 | t2 := t.TempDirscip-go gomod github.com/golang/go/src go1.21 testing/common#TempDir().() |
| 36 | |
| 37 | err = Copyscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/Copy().(contextscip-go gomod github.com/golang/go/src go1.21 context/.TODOscip-go gomod github.com/golang/go/src go1.21 context/TODO().(), t1, ".", t2, ".") |
| 38 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 39 | |
| 40 | fi, err := osscip-go gomod github.com/golang/go/src go1.21 os/.Lstatscip-go gomod github.com/golang/go/src go1.21 os/Lstat().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(t2, "char")) |
| 41 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 42 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, osscip-go gomod github.com/golang/go/src go1.21 os/.ModeCharDevicescip-go gomod github.com/golang/go/src go1.21 os/ModeCharDevice., fi.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().()&osscip-go gomod github.com/golang/go/src go1.21 os/.ModeCharDevicescip-go gomod github.com/golang/go/src go1.21 os/ModeCharDevice.) |
| 43 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, osscip-go gomod github.com/golang/go/src go1.21 os/.FileModescip-go gomod github.com/golang/go/src go1.21 os/FileMode#(0444), fi.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().()&0777) |
| 44 | |
| 45 | fi, err = osscip-go gomod github.com/golang/go/src go1.21 os/.Lstatscip-go gomod github.com/golang/go/src go1.21 os/Lstat().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(t2, "block")) |
| 46 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 47 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, osscip-go gomod github.com/golang/go/src go1.21 os/.ModeDevicescip-go gomod github.com/golang/go/src go1.21 os/ModeDevice., fi.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().()&osscip-go gomod github.com/golang/go/src go1.21 os/.ModeDevicescip-go gomod github.com/golang/go/src go1.21 os/ModeDevice.) |
| 48 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, osscip-go gomod github.com/golang/go/src go1.21 os/.FileModescip-go gomod github.com/golang/go/src go1.21 os/FileMode#(0441), fi.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().()&0777) |
| 49 | |
| 50 | fi, err = osscip-go gomod github.com/golang/go/src go1.21 os/.Lstatscip-go gomod github.com/golang/go/src go1.21 os/Lstat().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(t2, "fifo")) |
| 51 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 52 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, osscip-go gomod github.com/golang/go/src go1.21 os/.ModeNamedPipescip-go gomod github.com/golang/go/src go1.21 os/ModeNamedPipe., fi.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().()&osscip-go gomod github.com/golang/go/src go1.21 os/.ModeNamedPipescip-go gomod github.com/golang/go/src go1.21 os/ModeNamedPipe.) |
| 53 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, osscip-go gomod github.com/golang/go/src go1.21 os/.FileModescip-go gomod github.com/golang/go/src go1.21 os/FileMode#(0555), fi.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().()&0777) |
| 54 | |
| 55 | fi, err = osscip-go gomod github.com/golang/go/src go1.21 os/.Lstatscip-go gomod github.com/golang/go/src go1.21 os/Lstat().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(t2, "socket")) |
| 56 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 57 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.NotEqualscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/NotEqual().(t, osscip-go gomod github.com/golang/go/src go1.21 os/.ModeSocketscip-go gomod github.com/golang/go/src go1.21 os/ModeSocket., fi.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().()&osscip-go gomod github.com/golang/go/src go1.21 os/.ModeSocketscip-go gomod github.com/golang/go/src go1.21 os/ModeSocket.) // socket copied as stub |
| 58 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, osscip-go gomod github.com/golang/go/src go1.21 os/.FileModescip-go gomod github.com/golang/go/src go1.21 os/FileMode#(0555), fi.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().()&0777) |
| 59 | } |
| 60 | |
| 61 | func TestCopySetuidscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/TestCopySetuid().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) { |
| 62 | requiresRootscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/requiresRoot().(t) |
| 63 | |
| 64 | t1 := t.TempDirscip-go gomod github.com/golang/go/src go1.21 testing/common#TempDir().() |
| 65 | |
| 66 | err := mknodscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/mknod().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(t1, "char"), unixscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/.S_IFCHRscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/S_IFCHR.|0444, int(unixscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/.Mkdevscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/Mkdev().(1, 9))) |
| 67 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 68 | |
| 69 | t2 := t.TempDirscip-go gomod github.com/golang/go/src go1.21 testing/common#TempDir().() |
| 70 | |
| 71 | err = Copyscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/Copy().(contextscip-go gomod github.com/golang/go/src go1.21 context/.TODOscip-go gomod github.com/golang/go/src go1.21 context/TODO().(), t1, ".", t2, ".") |
| 72 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 73 | |
| 74 | fi, err := osscip-go gomod github.com/golang/go/src go1.21 os/.Lstatscip-go gomod github.com/golang/go/src go1.21 os/Lstat().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(t2, "char")) |
| 75 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 76 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, osscip-go gomod github.com/golang/go/src go1.21 os/.FileModescip-go gomod github.com/golang/go/src go1.21 os/FileMode#(0444), fi.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().().Permscip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileMode#Perm().()) |
| 77 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, osscip-go gomod github.com/golang/go/src go1.21 os/.FileModescip-go gomod github.com/golang/go/src go1.21 os/FileMode#(0), fi.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().()&osscip-go gomod github.com/golang/go/src go1.21 os/.ModeSetuidscip-go gomod github.com/golang/go/src go1.21 os/ModeSetuid.) |
| 78 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, osscip-go gomod github.com/golang/go/src go1.21 os/.FileModescip-go gomod github.com/golang/go/src go1.21 os/FileMode#(0), fi.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().()&osscip-go gomod github.com/golang/go/src go1.21 os/.ModeSetgidscip-go gomod github.com/golang/go/src go1.21 os/ModeSetgid.) |
| 79 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, osscip-go gomod github.com/golang/go/src go1.21 os/.FileModescip-go gomod github.com/golang/go/src go1.21 os/FileMode#(0), fi.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().()&osscip-go gomod github.com/golang/go/src go1.21 os/.ModeStickyscip-go gomod github.com/golang/go/src go1.21 os/ModeSticky.) |
| 80 | |
| 81 | t3 := t.TempDirscip-go gomod github.com/golang/go/src go1.21 testing/common#TempDir().() |
| 82 | |
| 83 | p := 0444 | syscallscip-go gomod github.com/golang/go/src go1.21 syscall/.S_ISUIDscip-go gomod github.com/golang/go/src go1.21 syscall/S_ISUID. |
| 84 | err = Copyscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/Copy().(contextscip-go gomod github.com/golang/go/src go1.21 context/.TODOscip-go gomod github.com/golang/go/src go1.21 context/TODO().(), t1, ".", t3, ".", WithCopyInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/WithCopyInfo().(CopyInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/CopyInfo#{ |
| 85 | Modescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/CopyInfo#Mode.: &p, |
| 86 | })) |
| 87 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 88 | |
| 89 | fi, err = osscip-go gomod github.com/golang/go/src go1.21 os/.Lstatscip-go gomod github.com/golang/go/src go1.21 os/Lstat().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(t3, "char")) |
| 90 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 91 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, osscip-go gomod github.com/golang/go/src go1.21 os/.FileModescip-go gomod github.com/golang/go/src go1.21 os/FileMode#(0444), fi.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().().Permscip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileMode#Perm().()) |
| 92 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, osscip-go gomod github.com/golang/go/src go1.21 os/.ModeSetuidscip-go gomod github.com/golang/go/src go1.21 os/ModeSetuid., fi.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().()&osscip-go gomod github.com/golang/go/src go1.21 os/.ModeSetuidscip-go gomod github.com/golang/go/src go1.21 os/ModeSetuid.) |
| 93 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, osscip-go gomod github.com/golang/go/src go1.21 os/.FileModescip-go gomod github.com/golang/go/src go1.21 os/FileMode#(0), fi.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().()&osscip-go gomod github.com/golang/go/src go1.21 os/.ModeSetgidscip-go gomod github.com/golang/go/src go1.21 os/ModeSetgid.) |
| 94 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, osscip-go gomod github.com/golang/go/src go1.21 os/.FileModescip-go gomod github.com/golang/go/src go1.21 os/FileMode#(0), fi.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().()&osscip-go gomod github.com/golang/go/src go1.21 os/.ModeStickyscip-go gomod github.com/golang/go/src go1.21 os/ModeSticky.) |
| 95 | } |
| 96 | |
| 97 | func TestCopyModeTextFormatscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/TestCopyModeTextFormat().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) { |
| 98 | t1 := t.TempDirscip-go gomod github.com/golang/go/src go1.21 testing/common#TempDir().() |
| 99 | |
| 100 | err := osscip-go gomod github.com/golang/go/src go1.21 os/.WriteFilescip-go gomod github.com/golang/go/src go1.21 os/WriteFile().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(t1, "file"), []byte("hello"), 0644) |
| 101 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 102 | |
| 103 | err = osscip-go gomod github.com/golang/go/src go1.21 os/.WriteFilescip-go gomod github.com/golang/go/src go1.21 os/WriteFile().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(t1, "executable_file"), []byte("world"), 0755) |
| 104 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 105 | |
| 106 | err = osscip-go gomod github.com/golang/go/src go1.21 os/.Mkdirscip-go gomod github.com/golang/go/src go1.21 os/Mkdir().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(t1, "dir"), 0750) |
| 107 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 108 | |
| 109 | err = osscip-go gomod github.com/golang/go/src go1.21 os/.Mkdirscip-go gomod github.com/golang/go/src go1.21 os/Mkdir().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(t1, "restricted_dir"), 0700) |
| 110 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 111 | |
| 112 | testCases := []struct { |
| 113 | name string |
| 114 | modeStr string |
| 115 | expectedFilePerm osscip-go gomod github.com/golang/go/src go1.21 os/.FileModescip-go gomod github.com/golang/go/src go1.21 os/FileMode# |
| 116 | expectedExecPerm osscip-go gomod github.com/golang/go/src go1.21 os/.FileModescip-go gomod github.com/golang/go/src go1.21 os/FileMode# |
| 117 | expectedDirPerm osscip-go gomod github.com/golang/go/src go1.21 os/.FileModescip-go gomod github.com/golang/go/src go1.21 os/FileMode# |
| 118 | expectedRestrictDirPerm osscip-go gomod github.com/golang/go/src go1.21 os/.FileModescip-go gomod github.com/golang/go/src go1.21 os/FileMode# |
| 119 | }{ |
| 120 | {"remove write for others", "go-w", 0644, 0755, 0750, 0700}, |
| 121 | {"add execute for user", "u+x", 0744, 0755, 0750, 0700}, |
| 122 | {"remove all permissions for group", "g-rwx", 0604, 0705, 0700, 0700}, |
| 123 | {"add read for others", "o+r", 0644, 0755, 0754, 0704}, |
| 124 | {"remove execute for all", "a-x", 0644, 0644, 0640, 0600}, |
| 125 | {"remove others and add execute for group", "o-rwx,g+x", 0650, 0750, 0750, 0710}, |
| 126 | {"capital X (apply execute only if directory)", "a+X", 0644, 0755, 0751, 0711}, |
| 127 | {"capital u-go X (apply execute only if directory)", "u=rwX,go=rX", 0644, 0755, 0755, 0755}, |
| 128 | {"capital u-go X (apply execute only if directory)", "u=rX,go=r", 0444, 0544, 0544, 0544}, |
| 129 | {"remove execute and add write for user", "u-x,u+w", 0644, 0655, 0650, 0600}, |
| 130 | {"add execute for user and others", "u+x,o+x", 0745, 0755, 0751, 0701}, |
| 131 | {"add write and read for group and others", "g+rw,o+rw", 0666, 0777, 0776, 0766}, |
| 132 | {"set read-only for all", "a=r", 0444, 0444, 0444, 0444}, |
| 133 | {"set full permissions for user only", "u=rwx,g=,o=", 0700, 0700, 0700, 0700}, |
| 134 | {"remove all permissions for others", "o-rwx", 0640, 0750, 0750, 0700}, |
| 135 | {"remove read for group, add execute for all", "g-r,a+x", 0715, 0715, 0711, 0711}, |
| 136 | {"complex permissions change", "u+rw,g+r,o-x,o+w", 0646, 0756, 0752, 0742}, |
| 137 | } |
| 138 | |
| 139 | for _, tc := range testCases { |
| 140 | t.Runscip-go gomod github.com/golang/go/src go1.21 testing/T#Run().(tc.name, func(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) { |
| 141 | t2 := t.TempDirscip-go gomod github.com/golang/go/src go1.21 testing/common#TempDir().() |
| 142 | |
| 143 | err := Copyscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/Copy().(contextscip-go gomod github.com/golang/go/src go1.21 context/.TODOscip-go gomod github.com/golang/go/src go1.21 context/TODO().(), t1, ".", t2, ".", WithCopyInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/WithCopyInfo().(CopyInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/CopyInfo#{ |
| 144 | ModeStrscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/CopyInfo#ModeStr.: tc.modeStr, |
| 145 | })) |
| 146 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 147 | |
| 148 | fi, err := osscip-go gomod github.com/golang/go/src go1.21 os/.Lstatscip-go gomod github.com/golang/go/src go1.21 os/Lstat().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(t2, "file")) |
| 149 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 150 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, tc.expectedFilePerm, fi.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().().Permscip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileMode#Perm().(), "file %04o, got %04o", tc.expectedFilePerm, fi.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().().Permscip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileMode#Perm().()) |
| 151 | |
| 152 | execFileInfo, err := osscip-go gomod github.com/golang/go/src go1.21 os/.Lstatscip-go gomod github.com/golang/go/src go1.21 os/Lstat().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(t2, "executable_file")) |
| 153 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 154 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, tc.expectedExecPerm, execFileInfo.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().().Permscip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileMode#Perm().(), "executable file %04o, got %04o", tc.expectedExecPerm, execFileInfo.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().().Permscip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileMode#Perm().()) |
| 155 | |
| 156 | dirInfo, err := osscip-go gomod github.com/golang/go/src go1.21 os/.Lstatscip-go gomod github.com/golang/go/src go1.21 os/Lstat().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(t2, "dir")) |
| 157 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 158 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, tc.expectedDirPerm, dirInfo.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().().Permscip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileMode#Perm().(), "dir %04o, got %04o", tc.expectedDirPerm, dirInfo.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().().Permscip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileMode#Perm().()) |
| 159 | |
| 160 | restrictDirInfo, err := osscip-go gomod github.com/golang/go/src go1.21 os/.Lstatscip-go gomod github.com/golang/go/src go1.21 os/Lstat().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(t2, "restricted_dir")) |
| 161 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 162 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, tc.expectedRestrictDirPerm, restrictDirInfo.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().().Permscip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileMode#Perm().(), "restricted dir %04o, got %04o", tc.expectedRestrictDirPerm, restrictDirInfo.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().().Permscip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileMode#Perm().()) |
| 163 | }) |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | // requiresRoot skips tests that require root |
| 168 | func requiresRootscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/requiresRoot().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) { |
| 169 | t.Helperscip-go gomod github.com/golang/go/src go1.21 testing/common#Helper().() |
| 170 | if osscip-go gomod github.com/golang/go/src go1.21 os/.Getuidscip-go gomod github.com/golang/go/src go1.21 os/Getuid().() != 0 { |
| 171 | t.Skipscip-go gomod github.com/golang/go/src go1.21 testing/common#Skip().("skipping test that requires root") |
| 172 | return |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | func readUidGidscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/copy`/readUidGid().(fi osscip-go gomod github.com/golang/go/src go1.21 os/.FileInfoscip-go gomod github.com/golang/go/src go1.21 os/FileInfo#) (uid, gid int, ok bool) { |
| 177 | if stat, ok := fi.Sysscip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Sys().().(*syscallscip-go gomod github.com/golang/go/src go1.21 syscall/.Stat_tscip-go gomod github.com/golang/go/src go1.21 syscall/Stat_t#); ok { |
| 178 | return int(stat.Uidscip-go gomod github.com/golang/go/src go1.21 syscall/Stat_t#Uid.), int(stat.Gidscip-go gomod github.com/golang/go/src go1.21 syscall/Stat_t#Gid.), true |
| 179 | } |
| 180 | return 0, 0, false |
| 181 | } |