summaryrefslogtreecommitdiff
path: root/vendor/github.com
diff options
context:
space:
mode:
authorUrvashi Mohnani <umohnani@redhat.com>2020-02-27 09:12:10 -0500
committerUrvashi Mohnani <umohnani@redhat.com>2020-02-27 09:12:10 -0500
commit151bf72bedef1cd12875ed70a421df89b5554ba5 (patch)
tree2638223673dee65abafd940ce0d093a537c0f6d9 /vendor/github.com
parentd3aa64c77c501b630ae2e0a227e10c38e14b1f4f (diff)
downloadpodman-151bf72bedef1cd12875ed70a421df89b5554ba5.tar.gz
podman-151bf72bedef1cd12875ed70a421df89b5554ba5.tar.bz2
podman-151bf72bedef1cd12875ed70a421df89b5554ba5.zip
Vendor in latest containers/buildah
Pulls in fix that sets the correct ownership on the working directory during the build process. Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
Diffstat (limited to 'vendor/github.com')
-rw-r--r--vendor/github.com/containers/buildah/imagebuildah/stage_executor.go16
-rw-r--r--vendor/github.com/containers/buildah/run_linux.go5
-rw-r--r--vendor/github.com/containers/buildah/util/util.go31
3 files changed, 51 insertions, 1 deletions
diff --git a/vendor/github.com/containers/buildah/imagebuildah/stage_executor.go b/vendor/github.com/containers/buildah/imagebuildah/stage_executor.go
index 7b6abbe37..6216dac97 100644
--- a/vendor/github.com/containers/buildah/imagebuildah/stage_executor.go
+++ b/vendor/github.com/containers/buildah/imagebuildah/stage_executor.go
@@ -12,6 +12,7 @@ import (
"github.com/containers/buildah"
buildahdocker "github.com/containers/buildah/docker"
+ "github.com/containers/buildah/pkg/chrootuser"
"github.com/containers/buildah/util"
cp "github.com/containers/image/v5/copy"
"github.com/containers/image/v5/docker/reference"
@@ -1248,9 +1249,22 @@ func (s *StageExecutor) EnsureContainerPath(path string) error {
if err != nil {
return errors.Wrapf(err, "error ensuring container path %q", path)
}
- _, err = os.Lstat(targetPath)
+
+ _, err = os.Stat(targetPath)
if err != nil && os.IsNotExist(err) {
err = os.MkdirAll(targetPath, 0755)
+ if err != nil {
+ return errors.Wrapf(err, "error creating directory path %q", targetPath)
+ }
+ // get the uid and gid so that we can set the correct permissions on the
+ // working directory
+ uid, gid, _, err := chrootuser.GetUser(s.mountPoint, s.builder.User())
+ if err != nil {
+ return errors.Wrapf(err, "error getting uid and gid for user %q", s.builder.User())
+ }
+ if err = os.Chown(targetPath, int(uid), int(gid)); err != nil {
+ return errors.Wrapf(err, "error setting ownership on %q", targetPath)
+ }
}
if err != nil {
return errors.Wrapf(err, "error ensuring container path %q", path)
diff --git a/vendor/github.com/containers/buildah/run_linux.go b/vendor/github.com/containers/buildah/run_linux.go
index 3695462bb..d2c0abf9b 100644
--- a/vendor/github.com/containers/buildah/run_linux.go
+++ b/vendor/github.com/containers/buildah/run_linux.go
@@ -678,6 +678,11 @@ func runUsingRuntime(isolation Isolation, options RunOptions, configureNetwork b
runtime := options.Runtime
if runtime == "" {
runtime = util.Runtime()
+
+ localRuntime := util.FindLocalRuntime(runtime)
+ if localRuntime != "" {
+ runtime = localRuntime
+ }
}
// Default to just passing down our stdio.
diff --git a/vendor/github.com/containers/buildah/util/util.go b/vendor/github.com/containers/buildah/util/util.go
index ac5a0f30c..05d661b58 100644
--- a/vendor/github.com/containers/buildah/util/util.go
+++ b/vendor/github.com/containers/buildah/util/util.go
@@ -10,6 +10,7 @@ import (
"sync"
"syscall"
+ "github.com/containers/common/pkg/config"
"github.com/containers/image/v5/docker/reference"
"github.com/containers/image/v5/pkg/sysregistriesv2"
"github.com/containers/image/v5/signature"
@@ -432,3 +433,33 @@ var (
isUnified bool
isUnifiedErr error
)
+
+// fileExistsAndNotADir - Check to see if a file exists
+// and that it is not a directory.
+func fileExistsAndNotADir(path string) bool {
+ file, err := os.Stat(path)
+
+ if file == nil || err != nil || os.IsNotExist(err) {
+ return false
+ }
+ return !file.IsDir()
+}
+
+// FindLocalRuntime find the local runtime of the
+// system searching through the config file for
+// possible locations.
+func FindLocalRuntime(runtime string) string {
+ var localRuntime string
+ conf, err := config.Default()
+ if err != nil {
+ logrus.Debugf("Error loading container config when searching for local runtime.")
+ return localRuntime
+ }
+ for _, val := range conf.Libpod.OCIRuntimes[runtime] {
+ if fileExistsAndNotADir(val) {
+ localRuntime = val
+ break
+ }
+ }
+ return localRuntime
+}