Skip to content

Commit

Permalink
Add the --no-pivot flag to the run command
Browse files Browse the repository at this point in the history
--no-pivot: "do not use pivot root to jail process inside rootfs.
  This should be used whenever the rootfs is on top of a ramdisk"
  • Loading branch information
afbjorklund committed Oct 5, 2018
1 parent 318fc89 commit 515e436
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cmd/buildah/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ var (
Name: "runtime-flag",
Usage: "add global flags for the container runtime",
},
cli.BoolFlag{
Name: "no-pivot",
Usage: "do not use pivot root to jail process inside rootfs",
},
cli.StringSliceFlag{
Name: "security-opt",
Usage: "security options (default [])",
Expand Down Expand Up @@ -108,6 +112,8 @@ func runCmd(c *cli.Context) error {
runtimeFlags = append(runtimeFlags, "--"+arg)
}

noPivot := c.Bool("no-pivot")

namespaceOptions, networkPolicy, err := parse.NamespaceOptions(c)
if err != nil {
return errors.Wrapf(err, "error parsing namespace-related options")
Expand All @@ -117,6 +123,7 @@ func runCmd(c *cli.Context) error {
Hostname: c.String("hostname"),
Runtime: c.String("runtime"),
Args: runtimeFlags,
NoPivot: noPivot,
User: c.String("user"),
Isolation: isolation,
NamespaceOptions: namespaceOptions,
Expand Down
10 changes: 9 additions & 1 deletion run.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ type RunOptions struct {
Runtime string
// Args adds global arguments for the runtime.
Args []string
// NoPivot adds the --no-pivot runtime flag.
NoPivot bool
// Mounts are additional mount points which we want to provide.
Mounts []specs.Mount
// Env is additional environment variables to set.
Expand Down Expand Up @@ -1091,7 +1093,13 @@ func (b *Builder) Run(command []string, options RunOptions) error {
// }
// }
// options.Args = append(options.Args, rootlessFlag...)
err = b.runUsingRuntimeSubproc(options, configureNetwork, configureNetworks, nil, spec, mountPoint, path, Package+"-"+filepath.Base(path))
var moreCreateArgs []string
if options.NoPivot {
moreCreateArgs = []string{"--no-pivot"}
} else {
moreCreateArgs = nil
}
err = b.runUsingRuntimeSubproc(options, configureNetwork, configureNetworks, moreCreateArgs, spec, mountPoint, path, Package+"-"+filepath.Base(path))
case IsolationChroot:
err = chroot.RunUsingChroot(spec, path, options.Stdin, options.Stdout, options.Stderr)
case IsolationOCIRootless:
Expand Down

0 comments on commit 515e436

Please sign in to comment.