From d0c605cd3da07175478b5c3947056856558be9f7 Mon Sep 17 00:00:00 2001 From: Aditya Rajan Date: Wed, 15 Sep 2021 14:58:44 +0530 Subject: build: mirror --authfile to filesystem if pointing to FD instead of file Following commit makes sure that podman mirrors --authfile to a temporary file in filesystem if arg is pointing to an FD instead of actual file as FD can be only consumed once. Reference: * https://github.com/containers/buildah/pull/3498 * https://github.com/containers/buildah/issues/3070 [NO TESTS NEEDED] Signed-off-by: Aditya Rajan --- cmd/podman/images/build.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'cmd') diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go index a1a28b809..985cdf920 100644 --- a/cmd/podman/images/build.go +++ b/cmd/podman/images/build.go @@ -11,6 +11,7 @@ import ( buildahDefine "github.com/containers/buildah/define" buildahCLI "github.com/containers/buildah/pkg/cli" "github.com/containers/buildah/pkg/parse" + buildahUtil "github.com/containers/buildah/pkg/util" "github.com/containers/common/pkg/auth" "github.com/containers/common/pkg/completion" "github.com/containers/common/pkg/config" @@ -359,6 +360,12 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil } } + cleanTmpFile := false + flags.Authfile, cleanTmpFile = buildahUtil.MirrorToTempFileIfPathIsDescriptor(flags.Authfile) + if cleanTmpFile { + defer os.Remove(flags.Authfile) + } + args := make(map[string]string) if c.Flag("build-arg").Changed { for _, arg := range flags.BuildArg { -- cgit v1.2.3-54-g00ecf