763d839261
This implements chown support on Windows. Built-in accounts as well as accounts included in the SAM database of the container are supported. NOTE: IDPair is now named Identity and IDMappings is now named IdentityMapping. The following are valid examples: ADD --chown=Guest . <some directory> COPY --chown=Administrator . <some directory> COPY --chown=Guests . <some directory> COPY --chown=ContainerUser . <some directory> On Windows an owner is only granted the permission to read the security descriptor and read/write the discretionary access control list. This fix also grants read/write and execute permissions to the owner. Signed-off-by: Salahuddin Khan <salah@docker.com>
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
// +build !windows
|
|
|
|
package dockerfile // import "github.com/docker/docker/builder/dockerfile"
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/docker/docker/pkg/containerfs"
|
|
"github.com/docker/docker/pkg/idtools"
|
|
)
|
|
|
|
func fixPermissions(source, destination string, identity idtools.Identity, overrideSkip bool) error {
|
|
var (
|
|
skipChownRoot bool
|
|
err error
|
|
)
|
|
if !overrideSkip {
|
|
destEndpoint := ©Endpoint{driver: containerfs.NewLocalDriver(), path: destination}
|
|
skipChownRoot, err = isExistingDirectory(destEndpoint)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
// We Walk on the source rather than on the destination because we don't
|
|
// want to change permissions on things we haven't created or modified.
|
|
return filepath.Walk(source, func(fullpath string, info os.FileInfo, err error) error {
|
|
// Do not alter the walk root iff. it existed before, as it doesn't fall under
|
|
// the domain of "things we should chown".
|
|
if skipChownRoot && source == fullpath {
|
|
return nil
|
|
}
|
|
|
|
// Path is prefixed by source: substitute with destination instead.
|
|
cleaned, err := filepath.Rel(source, fullpath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
fullpath = filepath.Join(destination, cleaned)
|
|
return os.Lchown(fullpath, identity.UID, identity.GID)
|
|
})
|
|
}
|
|
|
|
func validateCopySourcePath(imageSource *imageMount, origPath, platform string) error {
|
|
return nil
|
|
}
|