Skip to content

Commit be49cc8

Browse files
committed
chroot: error out on --network != host when $BUILDAH_ISOLATION
Error out if someone tries to mix the --network CLI flag, with a value other than "host", with chroot isolation configured by setting $BUILDAH_ISOLATION to "chroot", as we have been doing for cases where it's done using the "--isolation" option, instead of just ignoring it as we did previously. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
1 parent c97d402 commit be49cc8

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

pkg/cli/build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ func GenBuildOptions(c *cobra.Command, inputArgs []string, iopts BuildOptions) (
331331
}
332332
}
333333

334-
if c.Flag("network").Changed && c.Flag("isolation").Changed {
334+
if c.Flag("network").Changed {
335335
if isolation == define.IsolationChroot {
336336
if ns := namespaceOptions.Find(string(specs.NetworkNamespace)); ns != nil {
337337
if !ns.Host {

tests/bud.bats

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,9 @@ _EOF
569569

570570
run_buildah 125 build --network=none --isolation=chroot $WITH_POLICY_JSON ${TEST_SCRATCH_DIR}
571571
expect_output --substring "cannot set --network other than host with --isolation chroot"
572+
573+
BUILDAH_ISOLATION=chroot run_buildah 125 build --network=none $WITH_POLICY_JSON ${TEST_SCRATCH_DIR}
574+
expect_output --substring "cannot set --network other than host with --isolation chroot"
572575
}
573576

574577
@test "bud with .dockerignore #1" {

0 commit comments

Comments
 (0)