Skip to content

Commit

Permalink
Merge pull request #43876 from thaJeztah/20.10_backport_42655_vfs_sto…
Browse files Browse the repository at this point in the history
…rage_driver

[20.10 backport] Fix file capabilities dropping in Dockerfile
  • Loading branch information
AkihiroSuda committed Jul 28, 2022
2 parents 21b91d3 + cfdc075 commit a70ae13
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions daemon/graphdriver/copy/copy.go
Expand Up @@ -110,11 +110,13 @@ type dirMtimeInfo struct {
stat *syscall.Stat_t
}

// DirCopy copies or hardlinks the contents of one directory to another,
// properly handling xattrs, and soft links
// DirCopy copies or hardlinks the contents of one directory to another, properly
// handling soft links, "security.capability" and (optionally) "trusted.overlay.opaque"
// xattrs.
//
// Copying xattrs can be opted out of by passing false for copyXattrs.
func DirCopy(srcDir, dstDir string, copyMode Mode, copyXattrs bool) error {
// The copyOpaqueXattrs controls if "trusted.overlay.opaque" xattrs are copied.
// Passing false disables copying "trusted.overlay.opaque" xattrs.
func DirCopy(srcDir, dstDir string, copyMode Mode, copyOpaqueXattrs bool) error {
copyWithFileRange := true
copyWithFileClone := true

Expand Down Expand Up @@ -207,7 +209,11 @@ func DirCopy(srcDir, dstDir string, copyMode Mode, copyXattrs bool) error {
return err
}

if copyXattrs {
if err := copyXattr(srcPath, dstPath, "security.capability"); err != nil {
return err
}

if copyOpaqueXattrs {
if err := doCopyXattrs(srcPath, dstPath); err != nil {
return err
}
Expand Down Expand Up @@ -256,10 +262,6 @@ func DirCopy(srcDir, dstDir string, copyMode Mode, copyXattrs bool) error {
}

func doCopyXattrs(srcPath, dstPath string) error {
if err := copyXattr(srcPath, dstPath, "security.capability"); err != nil {
return err
}

// We need to copy this attribute if it appears in an overlay upper layer, as
// this function is used to copy those. It is set by overlay if a directory
// is removed and then re-created and should not inherit anything from the
Expand Down

0 comments on commit a70ae13

Please sign in to comment.