Skip to content

Commit 8d37d44

Browse files
committed
Add --no-network option
Completely disables network inside the container, making sure we fully control the supply chain. Signed-off-by: Yann Dirson <[email protected]>
1 parent b7fbab7 commit 8d37d44

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/xcp_ng_dev/cli.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ def add_common_args(parser):
5858
help="Directory where the build-dependency RPMs will be taken from.")
5959
group.add_argument('--no-update', action='store_true',
6060
help='do not run "yum update" on container start, use it as it was at build time')
61+
group.add_argument('--no-network', action='store_true',
62+
help='disable all networking support in the build environment')
6163

6264
def add_container_args(parser):
6365
group = parser.add_argument_group("container arguments")
@@ -213,6 +215,11 @@ def container(args):
213215
docker_args += ["-e", "DISABLEREPO=%s" % args.disablerepo]
214216
if args.no_update:
215217
docker_args += ["-e", "NOUPDATE=1"]
218+
if args.no_network:
219+
docker_args += ["--network", "none"]
220+
221+
if args.no_network and not args.no_update:
222+
print("WARNING: network disabled but --no-update not passed", file=sys.stderr)
216223

217224
# container args
218225
if args.volume:
@@ -249,6 +256,9 @@ def container(args):
249256
# action-specific
250257
match args.action:
251258
case 'build':
259+
if args.no_network and not args.local_repo:
260+
print("WARNING: network disabled but --local-repo not passed", file=sys.stderr)
261+
252262
build_dir = os.path.abspath(args.source_dir)
253263
if args.define:
254264
docker_args += ["-e", "RPMBUILD_DEFINE=%s" % args.define]

0 commit comments

Comments
 (0)