From eb7a422176a475f8ee033150a6fa6925a1fb4b63 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Wed, 13 Nov 2024 12:31:38 +0100 Subject: [PATCH] executor: allow to specify --no-pivot-root the functionality is already implemented, it must be exposed through the BuildOptions struct. Signed-off-by: Giuseppe Scrivano --- define/build.go | 2 ++ imagebuildah/executor.go | 2 ++ imagebuildah/stage_executor.go | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/define/build.go b/define/build.go index 68f3455b34c..359eec7d16e 100644 --- a/define/build.go +++ b/define/build.go @@ -379,4 +379,6 @@ type BuildOptions struct { // provides a minimal initial configuration with a working directory // set in it. CompatScratchConfig types.OptionalBool + // NoPivotRoot inhibits the usage of pivot_root when setting up the rootfs + NoPivotRoot bool } diff --git a/imagebuildah/executor.go b/imagebuildah/executor.go index b2526d0390b..e3ee9fc4fa0 100644 --- a/imagebuildah/executor.go +++ b/imagebuildah/executor.go @@ -163,6 +163,7 @@ type Executor struct { compatSetParent types.OptionalBool compatVolumes types.OptionalBool compatScratchConfig types.OptionalBool + noPivotRoot bool } type imageTypeAndHistoryAndDiffIDs struct { @@ -322,6 +323,7 @@ func newExecutor(logger *logrus.Logger, logPrefix string, store storage.Store, o compatSetParent: options.CompatSetParent, compatVolumes: options.CompatVolumes, compatScratchConfig: options.CompatScratchConfig, + noPivotRoot: options.NoPivotRoot, } if exec.err == nil { exec.err = os.Stderr diff --git a/imagebuildah/stage_executor.go b/imagebuildah/stage_executor.go index 9ac5cc43131..3b1784e750c 100644 --- a/imagebuildah/stage_executor.go +++ b/imagebuildah/stage_executor.go @@ -800,7 +800,7 @@ func (s *StageExecutor) Run(run imagebuilder.Run, config docker.Config) error { NamespaceOptions: namespaceOptions, NoHostname: s.executor.noHostname, NoHosts: s.executor.noHosts, - NoPivot: os.Getenv("BUILDAH_NOPIVOT") != "", + NoPivot: os.Getenv("BUILDAH_NOPIVOT") != "" || s.executor.noPivotRoot, Quiet: s.executor.quiet, CompatBuiltinVolumes: types.OptionalBoolFalse, RunMounts: run.Mounts,