diff --git a/vendor.conf b/vendor.conf index b29ca9f5..fcb1f559 100644 --- a/vendor.conf +++ b/vendor.conf @@ -5,7 +5,7 @@ k8s.io/apimachinery release-1.6 https://github.com/kubernetes/apimachinery k8s.io/apiserver release-1.6 https://github.com/kubernetes/apiserver # github.com/Sirupsen/logrus v0.11.5 -github.com/containers/image c2a797dfe5bb4a9dd7f48332ce40c6223ffba492 +github.com/containers/image 106607808da3cff168be56821e994611c919d283 github.com/ostreedev/ostree-go master github.com/containers/storage 5d8c2f87387fa5be9fa526ae39fbd79b8bdf27be github.com/containernetworking/cni v0.4.0 diff --git a/vendor/github.com/containers/image/docker/archive/dest.go b/vendor/github.com/containers/image/docker/archive/dest.go index 14360699..9fc85bd8 100644 --- a/vendor/github.com/containers/image/docker/archive/dest.go +++ b/vendor/github.com/containers/image/docker/archive/dest.go @@ -19,15 +19,24 @@ func newImageDestination(ctx *types.SystemContext, ref archiveReference) (types. if ref.destinationRef == nil { return nil, errors.Errorf("docker-archive: destination reference not supplied (must be of form :)") } - fh, err := os.OpenFile(ref.path, os.O_WRONLY|os.O_EXCL|os.O_CREATE, 0644) + + // ref.path can be either a pipe or a regular file + // in the case of a pipe, we require that we can open it for write + // in the case of a regular file, we don't want to overwrite any pre-existing file + // so we check for Size() == 0 below (This is racy, but using O_EXCL would also be racy, + // only in a different way. Either way, it’s up to the user to not have two writers to the same path.) + fh, err := os.OpenFile(ref.path, os.O_WRONLY|os.O_CREATE, 0644) if err != nil { - // FIXME: It should be possible to modify archives, but the only really - // sane way of doing it is to create a copy of the image, modify - // it and then do a rename(2). - if os.IsExist(err) { - err = errors.New("docker-archive doesn't support modifying existing images") - } - return nil, err + return nil, errors.Wrapf(err, "error opening file %q", ref.path) + } + + fhStat, err := fh.Stat() + if err != nil { + return nil, errors.Wrapf(err, "error statting file %q", ref.path) + } + + if fhStat.Mode().IsRegular() && fhStat.Size() != 0 { + return nil, errors.New("docker-archive doesn't support modifying existing images") } return &archiveImageDestination{